From 2cb1bf7b9188b51df7c0ceae3d1fb4378cd47c88 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 6 Sep 2026 22:35:20 +1000 Subject: [PATCH] GPUDevice: Add SingleTextureAndUBOAndPushConstants layout --- src/util/d3d12_device.cpp | 42 ++++++++++++++++++++++++++++++-------- src/util/gpu_device.h | 4 ++++ src/util/vulkan_device.cpp | 28 +++++++++++++++++++++---- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index ce59a0257..e3827db64 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -1609,6 +1609,7 @@ void D3D12Device::PushUniformBuffer(ID3D12GraphicsCommandList4* const cmdlist, b static constexpr std::array(GPUPipeline::Layout::MaxCount)> push_parameters = { 0, // SingleTextureAndUBO 2, // SingleTextureAndPushConstants + 3, // SingleTextureAndUBOAndPushConstants 1, // SingleTextureBufferAndPushConstants 0, // MultiTextureAndUBO 2, // MultiTextureAndPushConstants @@ -1693,6 +1694,24 @@ bool D3D12Device::CreateRootSignatures(Error* error) D3D12::SetObjectName(rs.Get(), "Single Texture Pipeline Layout"); } + { + auto& rs = m_root_signatures[rov][static_cast(GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants)]; + + rsb.SetInputAssemblerFlag(); + rsb.AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1, D3D12_SHADER_VISIBILITY_PIXEL); + rsb.AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 1, D3D12_SHADER_VISIBILITY_PIXEL); + rsb.AddCBVParameter(0, D3D12_SHADER_VISIBILITY_ALL); + if (rov) + { + rsb.AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, MAX_IMAGE_RENDER_TARGETS, + D3D12_SHADER_VISIBILITY_PIXEL); + } + rsb.Add32BitConstants(1, UNIFORM_PUSH_CONSTANTS_SIZE / sizeof(u32), D3D12_SHADER_VISIBILITY_ALL); + if (!(rs = rsb.Create(error, true))) + return false; + D3D12::SetObjectName(rs.Get(), "Single Texture + UBO + Push Constant Pipeline Layout"); + } + { auto& rs = m_root_signatures[rov][static_cast(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)]; @@ -2554,6 +2573,7 @@ bool D3D12Device::UpdateParametersForLayout(u32 dirty) ID3D12GraphicsCommandList4* cmdlist = GetCommandList(); if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO || + layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants || layout == GPUPipeline::Layout::MultiTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants || layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO) @@ -2655,15 +2675,16 @@ bool D3D12Device::UpdateParametersForLayout(u32 dirty) m_device->CopyDescriptors(1, &gpu_handle.cpu_handle, &dst_size, MAX_IMAGE_RENDER_TARGETS, src_handles, src_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - constexpr u32 rov_param = - IsComputeLayout(layout) ? - 2 : - ((layout == GPUPipeline::Layout::SingleTextureBufferAndPushConstants) ? - 1 : - ((layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO || - layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ? - 3 : - 2)); + constexpr u32 rov_param = IsComputeLayout(layout) ? + 2 : + ((layout == GPUPipeline::Layout::SingleTextureBufferAndPushConstants) ? + 1 : + ((layout == GPUPipeline::Layout::SingleTextureAndUBO || + layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants || + layout == GPUPipeline::Layout::MultiTextureAndUBO || + layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ? + 3 : + 2)); if constexpr (!IsComputeLayout(layout)) cmdlist->SetGraphicsRootDescriptorTable(rov_param, gpu_handle); else @@ -2683,6 +2704,9 @@ bool D3D12Device::UpdateRootParameters(u32 dirty) case GPUPipeline::Layout::SingleTextureAndPushConstants: return UpdateParametersForLayout(dirty); + case GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants: + return UpdateParametersForLayout(dirty); + case GPUPipeline::Layout::SingleTextureBufferAndPushConstants: return UpdateParametersForLayout(dirty); diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index b434998ef..4e5e9dbce 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -133,6 +133,9 @@ public: // 128 byte UBO via push constants, 1 texture. SingleTextureAndPushConstants, + // 128 byte UBO via push constants, 1 streamed UBO, 1 texture. + SingleTextureAndUBOAndPushConstants, + // 128 byte UBO via push constants, 1 texture buffer/SSBO. SingleTextureBufferAndPushConstants, @@ -656,6 +659,7 @@ public: constexpr std::array(GPUPipeline::Layout::MaxCount)> counts = { 1, // SingleTextureAndUBO 1, // SingleTextureAndPushConstants + 1, // SingleTextureAndUBOAndPushConstants 0, // SingleTextureBufferAndPushConstants MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBO MAX_TEXTURE_SAMPLERS, // MultiTextureAndPushConstants diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index de5449db4..592dfda4d 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -2481,6 +2481,21 @@ bool VulkanDevice::CreatePipelineLayouts() Vulkan::SetObjectName(m_device, pl, "Single Texture Pipeline Layout"); } + { + VkPipelineLayout& pl = + m_pipeline_layouts[type][static_cast(GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants)]; + plb.AddDescriptorSet(m_ubo_ds_layout); + plb.AddDescriptorSet(m_single_texture_ds_layout); + plb.AddPushConstants(UNIFORM_PUSH_CONSTANTS_STAGES, 0, UNIFORM_PUSH_CONSTANTS_SIZE); + if (feedback_loop) + plb.AddDescriptorSet(m_feedback_loop_ds_layout); + else if (rov) + plb.AddDescriptorSet(m_image_ds_layout); + if ((pl = plb.Create(m_device)) == VK_NULL_HANDLE) + return false; + Vulkan::SetObjectName(m_device, pl, "Single Texture + UBO + Push Constant Pipeline Layout"); + } + { VkPipelineLayout& pl = m_pipeline_layouts[type][static_cast(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)]; @@ -3408,10 +3423,11 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty) [[maybe_unused]] bool new_dynamic_offsets = false; constexpr bool is_compute = IsComputeLayout(layout); - constexpr bool has_ubo = - (layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO || - layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants || - layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO); + constexpr bool has_ubo = (layout == GPUPipeline::Layout::SingleTextureAndUBO || + layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants || + layout == GPUPipeline::Layout::MultiTextureAndUBO || + layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants || + layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO); constexpr VkPipelineBindPoint vk_bind_point = (is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS); const VkPipelineLayout vk_pipeline_layout = GetCurrentVkPipelineLayout(is_compute); @@ -3435,6 +3451,7 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty) } if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO || + layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants || layout == GPUPipeline::Layout::SingleTextureAndPushConstants) { VulkanTexture* const tex = @@ -3556,6 +3573,9 @@ bool VulkanDevice::UpdateDescriptorSets(u32 dirty) case GPUPipeline::Layout::SingleTextureAndPushConstants: return UpdateDescriptorSetsForLayout(dirty); + case GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants: + return UpdateDescriptorSetsForLayout(dirty); + case GPUPipeline::Layout::SingleTextureBufferAndPushConstants: return UpdateDescriptorSetsForLayout(dirty);