GPUDevice: Add MultiTextureAndUBOAndPushConstants pipeline layout

This commit is contained in:
Stenzek
2025-10-14 19:47:01 +10:00
parent 916b23f85c
commit 47c820455d
3 changed files with 57 additions and 4 deletions

View File

@@ -1609,6 +1609,8 @@ void D3D12Device::PushUniformBuffer(ID3D12GraphicsCommandList4* const cmdlist, b
1, // SingleTextureBufferAndPushConstants
0, // MultiTextureAndUBO
2, // MultiTextureAndPushConstants
3, // MultiTextureAndUBOAndPushConstants
0, // ComputeMultiTextureAndUBO
2, // ComputeSingleTextureAndPushConstants
};
@@ -1737,7 +1739,26 @@ bool D3D12Device::CreateRootSignatures(Error* error)
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(), "Multi Texture Pipeline Layout");
D3D12::SetObjectName(rs.Get(), "Multi Texture + Push Constant Pipeline Layout");
}
{
auto& rs = m_root_signatures[rov][static_cast<u8>(GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants)];
rsb.SetInputAssemblerFlag();
rsb.AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, MAX_TEXTURE_SAMPLERS, D3D12_SHADER_VISIBILITY_PIXEL);
rsb.AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, MAX_TEXTURE_SAMPLERS,
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(), "Multi Texture + UBO + Push Constant Pipeline Layout");
}
}
@@ -2473,6 +2494,7 @@ bool D3D12Device::UpdateParametersForLayout(u32 dirty)
if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO)
{
if (dirty & DIRTY_FLAG_CONSTANT_BUFFER)
@@ -2577,7 +2599,8 @@ bool D3D12Device::UpdateParametersForLayout(u32 dirty)
2 :
((layout == GPUPipeline::Layout::SingleTextureBufferAndPushConstants) ?
1 :
((layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO) ?
((layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ?
3 :
2));
if constexpr (!IsComputeLayout(layout))
@@ -2608,6 +2631,9 @@ bool D3D12Device::UpdateRootParameters(u32 dirty)
case GPUPipeline::Layout::MultiTextureAndPushConstants:
return UpdateParametersForLayout<GPUPipeline::Layout::MultiTextureAndPushConstants>(dirty);
case GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants:
return UpdateParametersForLayout<GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants>(dirty);
case GPUPipeline::Layout::ComputeMultiTextureAndUBO:
return UpdateParametersForLayout<GPUPipeline::Layout::ComputeMultiTextureAndUBO>(dirty);

View File

@@ -213,6 +213,9 @@ public:
// Multiple textures, 128 byte UBO via push constants.
MultiTextureAndPushConstants,
// Multiple textures, 1 streamed UBO, 128 byte push constants.
MultiTextureAndUBOAndPushConstants,
// Multiple textures, 1 streamed UBO, compute shader.
ComputeMultiTextureAndUBO,
@@ -734,6 +737,7 @@ public:
0, // SingleTextureBufferAndPushConstants
MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBO
MAX_TEXTURE_SAMPLERS, // MultiTextureAndPushConstants
MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBOAndPushConstants
MAX_TEXTURE_SAMPLERS, // ComputeMultiTextureAndUBO
MAX_TEXTURE_SAMPLERS, // ComputeMultiTextureAndPushConstants
};

View File

@@ -3043,7 +3043,7 @@ bool VulkanDevice::CreatePipelineLayouts()
plb.AddDescriptorSet(m_image_ds_layout);
if ((pl = plb.Create(m_device)) == VK_NULL_HANDLE)
return false;
Vulkan::SetObjectName(m_device, pl, "Multi Texture + UBO Pipeline Layout");
Vulkan::SetObjectName(m_device, pl, "Multi Texture + UBO + Push Constant Pipeline Layout");
}
{
@@ -3059,6 +3059,21 @@ bool VulkanDevice::CreatePipelineLayouts()
return false;
Vulkan::SetObjectName(m_device, pl, "Multi Texture Pipeline Layout");
}
{
VkPipelineLayout& pl =
m_pipeline_layouts[type][static_cast<u8>(GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants)];
plb.AddDescriptorSet(m_ubo_ds_layout);
plb.AddDescriptorSet(m_multi_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, "Multi Texture + UBO + Push Constant Pipeline Layout");
}
}
{
@@ -3894,6 +3909,7 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty)
if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO)
{
new_dynamic_offsets = ((dirty & DIRTY_FLAG_DYNAMIC_OFFSETS) != 0);
@@ -3924,6 +3940,7 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty)
}
else if constexpr (layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndPushConstants ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndPushConstants)
{
@@ -3940,7 +3957,10 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty)
tex->GetVkLayout());
}
const u32 set = (layout == GPUPipeline::Layout::MultiTextureAndUBO) ? 1 : 0;
const u32 set = (layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ?
1 :
0;
dsub.PushUpdate(m_current_command_buffer, vk_bind_point, vk_pipeline_layout, set);
if (num_ds == 0)
return true;
@@ -4035,6 +4055,9 @@ bool VulkanDevice::UpdateDescriptorSets(u32 dirty)
case GPUPipeline::Layout::MultiTextureAndPushConstants:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::MultiTextureAndPushConstants>(dirty);
case GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants>(dirty);
case GPUPipeline::Layout::ComputeMultiTextureAndUBO:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::ComputeMultiTextureAndUBO>(dirty);