Skip to content

Commit e13fb2e

Browse files
authored
renderer_vulkan: Bind descriptors to specific stages in layout. (#2458)
1 parent 26bb3d4 commit e13fb2e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ namespace Vulkan {
1919

2020
using Shader::Backend::SPIRV::AuxShaderType;
2121

22+
static constexpr std::array LogicalStageToStageBit = {
23+
vk::ShaderStageFlagBits::eFragment,
24+
vk::ShaderStageFlagBits::eTessellationControl,
25+
vk::ShaderStageFlagBits::eTessellationEvaluation,
26+
vk::ShaderStageFlagBits::eVertex,
27+
vk::ShaderStageFlagBits::eGeometry,
28+
vk::ShaderStageFlagBits::eCompute,
29+
};
30+
2231
GraphicsPipeline::GraphicsPipeline(
2332
const Instance& instance, Scheduler& scheduler, DescriptorHeap& desc_heap,
2433
const Shader::Profile& profile, const GraphicsPipelineKey& key_,
@@ -34,7 +43,7 @@ GraphicsPipeline::GraphicsPipeline(
3443
const auto debug_str = GetDebugString();
3544

3645
const vk::PushConstantRange push_constants = {
37-
.stageFlags = gp_stage_flags,
46+
.stageFlags = AllGraphicsStageBits,
3847
.offset = 0,
3948
.size = sizeof(Shader::PushData),
4049
};
@@ -352,6 +361,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
352361
if (!stage) {
353362
continue;
354363
}
364+
const auto stage_bit = LogicalStageToStageBit[u32(stage->l_stage)];
355365
for (const auto& buffer : stage->buffers) {
356366
const auto sharp = buffer.GetSharp(*stage);
357367
bindings.push_back({
@@ -360,7 +370,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
360370
? vk::DescriptorType::eStorageBuffer
361371
: vk::DescriptorType::eUniformBuffer,
362372
.descriptorCount = 1,
363-
.stageFlags = gp_stage_flags,
373+
.stageFlags = stage_bit,
364374
});
365375
}
366376
for (const auto& image : stage->images) {
@@ -369,15 +379,15 @@ void GraphicsPipeline::BuildDescSetLayout() {
369379
.descriptorType = image.is_written ? vk::DescriptorType::eStorageImage
370380
: vk::DescriptorType::eSampledImage,
371381
.descriptorCount = 1,
372-
.stageFlags = gp_stage_flags,
382+
.stageFlags = stage_bit,
373383
});
374384
}
375385
for (const auto& sampler : stage->samplers) {
376386
bindings.push_back({
377387
.binding = binding++,
378388
.descriptorType = vk::DescriptorType::eSampler,
379389
.descriptorCount = 1,
380-
.stageFlags = gp_stage_flags,
390+
.stageFlags = stage_bit,
381391
});
382392
}
383393
}

src/video_core/renderer_vulkan/vk_pipeline_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void Pipeline::BindResources(DescriptorWrites& set_writes, const BufferBarriers&
3737
cmdbuf.pipelineBarrier2(dependencies);
3838
}
3939

40-
const auto stage_flags = IsCompute() ? vk::ShaderStageFlagBits::eCompute : gp_stage_flags;
40+
const auto stage_flags = IsCompute() ? vk::ShaderStageFlagBits::eCompute : AllGraphicsStageBits;
4141
cmdbuf.pushConstants(*pipeline_layout, stage_flags, 0u, sizeof(push_data), &push_data);
4242

4343
// Bind descriptor set.

src/video_core/renderer_vulkan/vk_pipeline_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BufferCache;
1515

1616
namespace Vulkan {
1717

18-
static constexpr auto gp_stage_flags =
18+
static constexpr auto AllGraphicsStageBits =
1919
vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eTessellationControl |
2020
vk::ShaderStageFlagBits::eTessellationEvaluation | vk::ShaderStageFlagBits::eGeometry |
2121
vk::ShaderStageFlagBits::eFragment;

0 commit comments

Comments
 (0)