Skip to content

renderer_vulkan: Bind descriptors to specific stages in layout. #2458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand All @@ -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),
};
Expand Down Expand Up @@ -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({
Expand All @@ -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) {
Expand All @@ -369,15 +379,15 @@ 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) {
bindings.push_back({
.binding = binding++,
.descriptorType = vk::DescriptorType::eSampler,
.descriptorCount = 1,
.stageFlags = gp_stage_flags,
.stageFlags = stage_bit,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down