GPUDevice: Add SingleTextureAndUBOAndPushConstants layout

pull/3794/head
Stenzek 2 weeks ago
parent 3f5dca5cec
commit 2cb1bf7b91
No known key found for this signature in database

@ -1609,6 +1609,7 @@ void D3D12Device::PushUniformBuffer(ID3D12GraphicsCommandList4* const cmdlist, b
static constexpr std::array<u8, static_cast<u8>(GPUPipeline::Layout::MaxCount)> push_parameters = { static constexpr std::array<u8, static_cast<u8>(GPUPipeline::Layout::MaxCount)> push_parameters = {
0, // SingleTextureAndUBO 0, // SingleTextureAndUBO
2, // SingleTextureAndPushConstants 2, // SingleTextureAndPushConstants
3, // SingleTextureAndUBOAndPushConstants
1, // SingleTextureBufferAndPushConstants 1, // SingleTextureBufferAndPushConstants
0, // MultiTextureAndUBO 0, // MultiTextureAndUBO
2, // MultiTextureAndPushConstants 2, // MultiTextureAndPushConstants
@ -1693,6 +1694,24 @@ bool D3D12Device::CreateRootSignatures(Error* error)
D3D12::SetObjectName(rs.Get(), "Single Texture Pipeline Layout"); D3D12::SetObjectName(rs.Get(), "Single Texture Pipeline Layout");
} }
{
auto& rs = m_root_signatures[rov][static_cast<u8>(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<u8>(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)]; auto& rs = m_root_signatures[rov][static_cast<u8>(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)];
@ -2554,6 +2573,7 @@ bool D3D12Device::UpdateParametersForLayout(u32 dirty)
ID3D12GraphicsCommandList4* cmdlist = GetCommandList(); ID3D12GraphicsCommandList4* cmdlist = GetCommandList();
if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO || if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::MultiTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants || layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO) 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, 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); D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
constexpr u32 rov_param = constexpr u32 rov_param = IsComputeLayout(layout) ?
IsComputeLayout(layout) ? 2 :
2 : ((layout == GPUPipeline::Layout::SingleTextureBufferAndPushConstants) ?
((layout == GPUPipeline::Layout::SingleTextureBufferAndPushConstants) ? 1 :
1 : ((layout == GPUPipeline::Layout::SingleTextureAndUBO ||
((layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO || layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ? layout == GPUPipeline::Layout::MultiTextureAndUBO ||
3 : layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants) ?
2)); 3 :
2));
if constexpr (!IsComputeLayout(layout)) if constexpr (!IsComputeLayout(layout))
cmdlist->SetGraphicsRootDescriptorTable(rov_param, gpu_handle); cmdlist->SetGraphicsRootDescriptorTable(rov_param, gpu_handle);
else else
@ -2683,6 +2704,9 @@ bool D3D12Device::UpdateRootParameters(u32 dirty)
case GPUPipeline::Layout::SingleTextureAndPushConstants: case GPUPipeline::Layout::SingleTextureAndPushConstants:
return UpdateParametersForLayout<GPUPipeline::Layout::SingleTextureAndPushConstants>(dirty); return UpdateParametersForLayout<GPUPipeline::Layout::SingleTextureAndPushConstants>(dirty);
case GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants:
return UpdateParametersForLayout<GPUPipeline::Layout::SingleTextureAndPushConstants>(dirty);
case GPUPipeline::Layout::SingleTextureBufferAndPushConstants: case GPUPipeline::Layout::SingleTextureBufferAndPushConstants:
return UpdateParametersForLayout<GPUPipeline::Layout::SingleTextureBufferAndPushConstants>(dirty); return UpdateParametersForLayout<GPUPipeline::Layout::SingleTextureBufferAndPushConstants>(dirty);

@ -133,6 +133,9 @@ public:
// 128 byte UBO via push constants, 1 texture. // 128 byte UBO via push constants, 1 texture.
SingleTextureAndPushConstants, SingleTextureAndPushConstants,
// 128 byte UBO via push constants, 1 streamed UBO, 1 texture.
SingleTextureAndUBOAndPushConstants,
// 128 byte UBO via push constants, 1 texture buffer/SSBO. // 128 byte UBO via push constants, 1 texture buffer/SSBO.
SingleTextureBufferAndPushConstants, SingleTextureBufferAndPushConstants,
@ -656,6 +659,7 @@ public:
constexpr std::array<u8, static_cast<u8>(GPUPipeline::Layout::MaxCount)> counts = { constexpr std::array<u8, static_cast<u8>(GPUPipeline::Layout::MaxCount)> counts = {
1, // SingleTextureAndUBO 1, // SingleTextureAndUBO
1, // SingleTextureAndPushConstants 1, // SingleTextureAndPushConstants
1, // SingleTextureAndUBOAndPushConstants
0, // SingleTextureBufferAndPushConstants 0, // SingleTextureBufferAndPushConstants
MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBO MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBO
MAX_TEXTURE_SAMPLERS, // MultiTextureAndPushConstants MAX_TEXTURE_SAMPLERS, // MultiTextureAndPushConstants

@ -2481,6 +2481,21 @@ bool VulkanDevice::CreatePipelineLayouts()
Vulkan::SetObjectName(m_device, pl, "Single Texture Pipeline Layout"); Vulkan::SetObjectName(m_device, pl, "Single Texture Pipeline Layout");
} }
{
VkPipelineLayout& pl =
m_pipeline_layouts[type][static_cast<u8>(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 = VkPipelineLayout& pl =
m_pipeline_layouts[type][static_cast<u8>(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)]; m_pipeline_layouts[type][static_cast<u8>(GPUPipeline::Layout::SingleTextureBufferAndPushConstants)];
@ -3408,10 +3423,11 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty)
[[maybe_unused]] bool new_dynamic_offsets = false; [[maybe_unused]] bool new_dynamic_offsets = false;
constexpr bool is_compute = IsComputeLayout(layout); constexpr bool is_compute = IsComputeLayout(layout);
constexpr bool has_ubo = constexpr bool has_ubo = (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
(layout == GPUPipeline::Layout::SingleTextureAndUBO || layout == GPUPipeline::Layout::MultiTextureAndUBO || layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants || layout == GPUPipeline::Layout::MultiTextureAndUBO ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO); layout == GPUPipeline::Layout::MultiTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::ComputeMultiTextureAndUBO);
constexpr VkPipelineBindPoint vk_bind_point = constexpr VkPipelineBindPoint vk_bind_point =
(is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS); (is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS);
const VkPipelineLayout vk_pipeline_layout = GetCurrentVkPipelineLayout(is_compute); const VkPipelineLayout vk_pipeline_layout = GetCurrentVkPipelineLayout(is_compute);
@ -3435,6 +3451,7 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(u32 dirty)
} }
if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO || if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
layout == GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants ||
layout == GPUPipeline::Layout::SingleTextureAndPushConstants) layout == GPUPipeline::Layout::SingleTextureAndPushConstants)
{ {
VulkanTexture* const tex = VulkanTexture* const tex =
@ -3556,6 +3573,9 @@ bool VulkanDevice::UpdateDescriptorSets(u32 dirty)
case GPUPipeline::Layout::SingleTextureAndPushConstants: case GPUPipeline::Layout::SingleTextureAndPushConstants:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::SingleTextureAndPushConstants>(dirty); return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::SingleTextureAndPushConstants>(dirty);
case GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::SingleTextureAndUBOAndPushConstants>(dirty);
case GPUPipeline::Layout::SingleTextureBufferAndPushConstants: case GPUPipeline::Layout::SingleTextureBufferAndPushConstants:
return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::SingleTextureBufferAndPushConstants>(dirty); return UpdateDescriptorSetsForLayout<GPUPipeline::Layout::SingleTextureBufferAndPushConstants>(dirty);

Loading…
Cancel
Save