mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 03:24:49 +00:00
renderer_vulkan: Bind descriptors to specific stages in layout. (#2458)
This commit is contained in:
parent
26bb3d40d9
commit
e13fb2e366
3 changed files with 16 additions and 6 deletions
|
@ -19,6 +19,15 @@ namespace Vulkan {
|
|||
|
||||
using Shader::Backend::SPIRV::AuxShaderType;
|
||||
|
||||
static constexpr std::array LogicalStageToStageBit = {
|
||||
vk::ShaderStageFlagBits::eFragment,
|
||||
vk::ShaderStageFlagBits::eTessellationControl,
|
||||
vk::ShaderStageFlagBits::eTessellationEvaluation,
|
||||
vk::ShaderStageFlagBits::eVertex,
|
||||
vk::ShaderStageFlagBits::eGeometry,
|
||||
vk::ShaderStageFlagBits::eCompute,
|
||||
};
|
||||
|
||||
GraphicsPipeline::GraphicsPipeline(
|
||||
const Instance& instance, Scheduler& scheduler, DescriptorHeap& desc_heap,
|
||||
const Shader::Profile& profile, const GraphicsPipelineKey& key_,
|
||||
|
@ -34,7 +43,7 @@ GraphicsPipeline::GraphicsPipeline(
|
|||
const auto debug_str = GetDebugString();
|
||||
|
||||
const vk::PushConstantRange push_constants = {
|
||||
.stageFlags = gp_stage_flags,
|
||||
.stageFlags = AllGraphicsStageBits,
|
||||
.offset = 0,
|
||||
.size = sizeof(Shader::PushData),
|
||||
};
|
||||
|
@ -352,6 +361,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
|
|||
if (!stage) {
|
||||
continue;
|
||||
}
|
||||
const auto stage_bit = LogicalStageToStageBit[u32(stage->l_stage)];
|
||||
for (const auto& buffer : stage->buffers) {
|
||||
const auto sharp = buffer.GetSharp(*stage);
|
||||
bindings.push_back({
|
||||
|
@ -360,7 +370,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
|
|||
? vk::DescriptorType::eStorageBuffer
|
||||
: vk::DescriptorType::eUniformBuffer,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = gp_stage_flags,
|
||||
.stageFlags = stage_bit,
|
||||
});
|
||||
}
|
||||
for (const auto& image : stage->images) {
|
||||
|
@ -369,7 +379,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
|
|||
.descriptorType = image.is_written ? vk::DescriptorType::eStorageImage
|
||||
: vk::DescriptorType::eSampledImage,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = gp_stage_flags,
|
||||
.stageFlags = stage_bit,
|
||||
});
|
||||
}
|
||||
for (const auto& sampler : stage->samplers) {
|
||||
|
@ -377,7 +387,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
|
|||
.binding = binding++,
|
||||
.descriptorType = vk::DescriptorType::eSampler,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = gp_stage_flags,
|
||||
.stageFlags = stage_bit,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void Pipeline::BindResources(DescriptorWrites& set_writes, const BufferBarriers&
|
|||
cmdbuf.pipelineBarrier2(dependencies);
|
||||
}
|
||||
|
||||
const auto stage_flags = IsCompute() ? vk::ShaderStageFlagBits::eCompute : gp_stage_flags;
|
||||
const auto stage_flags = IsCompute() ? vk::ShaderStageFlagBits::eCompute : AllGraphicsStageBits;
|
||||
cmdbuf.pushConstants(*pipeline_layout, stage_flags, 0u, sizeof(push_data), &push_data);
|
||||
|
||||
// Bind descriptor set.
|
||||
|
|
|
@ -15,7 +15,7 @@ class BufferCache;
|
|||
|
||||
namespace Vulkan {
|
||||
|
||||
static constexpr auto gp_stage_flags =
|
||||
static constexpr auto AllGraphicsStageBits =
|
||||
vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eTessellationControl |
|
||||
vk::ShaderStageFlagBits::eTessellationEvaluation | vk::ShaderStageFlagBits::eGeometry |
|
||||
vk::ShaderStageFlagBits::eFragment;
|
||||
|
|
Loading…
Add table
Reference in a new issue