Skip to content

Commit e0fed4e

Browse files
committed
renderer_vulkan: Bind descriptors to specific stages in layout.
1 parent 26bb3d4 commit e0fed4e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ GraphicsPipeline::GraphicsPipeline(
3434
const auto debug_str = GetDebugString();
3535

3636
const vk::PushConstantRange push_constants = {
37-
.stageFlags = gp_stage_flags,
37+
.stageFlags = AllGraphicsStageBits,
3838
.offset = 0,
3939
.size = sizeof(Shader::PushData),
4040
};
@@ -352,6 +352,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
352352
if (!stage) {
353353
continue;
354354
}
355+
const auto stage_bit = LogicalStageToStageBit[u32(stage->l_stage)];
355356
for (const auto& buffer : stage->buffers) {
356357
const auto sharp = buffer.GetSharp(*stage);
357358
bindings.push_back({
@@ -360,7 +361,7 @@ void GraphicsPipeline::BuildDescSetLayout() {
360361
? vk::DescriptorType::eStorageBuffer
361362
: vk::DescriptorType::eUniformBuffer,
362363
.descriptorCount = 1,
363-
.stageFlags = gp_stage_flags,
364+
.stageFlags = stage_bit,
364365
});
365366
}
366367
for (const auto& image : stage->images) {
@@ -369,15 +370,15 @@ void GraphicsPipeline::BuildDescSetLayout() {
369370
.descriptorType = image.is_written ? vk::DescriptorType::eStorageImage
370371
: vk::DescriptorType::eSampledImage,
371372
.descriptorCount = 1,
372-
.stageFlags = gp_stage_flags,
373+
.stageFlags = stage_bit,
373374
});
374375
}
375376
for (const auto& sampler : stage->samplers) {
376377
bindings.push_back({
377378
.binding = binding++,
378379
.descriptorType = vk::DescriptorType::eSampler,
379380
.descriptorCount = 1,
380-
.stageFlags = gp_stage_flags,
381+
.stageFlags = stage_bit,
381382
});
382383
}
383384
}

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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ 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;
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+
};
2230

2331
class Instance;
2432
class Scheduler;

0 commit comments

Comments
 (0)