diff --git a/include/d3d12.idl b/include/d3d12.idl index 4be51be1..ea5a485e 100644 --- a/include/d3d12.idl +++ b/include/d3d12.idl @@ -22,6 +22,8 @@ import "dxgibase.idl"; #include "unknown.idl" +const UINT D3D12_MAX_ROOT_COST = 64; + const UINT D3D12_APPEND_ALIGNED_ELEMENT = 0xffffffff; cpp_quote("#define D3D12_DEFAULT_BLEND_FACTOR_ALPHA (1.0f)") cpp_quote("#define D3D12_DEFAULT_BLEND_FACTOR_BLUE (1.0f)") diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index b75bf514..534e0978 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -326,6 +326,7 @@ struct d3d12_root_signature_info size_t sampler_count; size_t descriptor_count; size_t root_constant_count; + size_t cost; }; static bool d3d12_root_signature_info_count_descriptors(struct d3d12_root_signature_info *info, @@ -380,23 +381,28 @@ static HRESULT d3d12_root_signature_info_from_desc(struct d3d12_root_signature_i if (FAILED(hr = d3d12_root_signature_info_count_descriptors(info, &p->u.DescriptorTable.pDescriptorRanges[j]))) return hr; + ++info->cost; break; case D3D12_ROOT_PARAMETER_TYPE_CBV: ++info->cbv_count; ++info->descriptor_count; + info->cost += 2; break; case D3D12_ROOT_PARAMETER_TYPE_SRV: ++info->buffer_srv_count; ++info->descriptor_count; + info->cost += 2; break; case D3D12_ROOT_PARAMETER_TYPE_UAV: ++info->buffer_uav_count; ++info->descriptor_count; + info->cost += 2; break; case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: ++info->root_constant_count; + info->cost += p->u.Constants.Num32BitValues; break; default: @@ -838,6 +844,12 @@ static HRESULT d3d12_root_signature_init(struct d3d12_root_signature *root_signa if (FAILED(hr = d3d12_root_signature_info_from_desc(&info, desc))) return hr; + if (info.cost > D3D12_MAX_ROOT_COST) + { + WARN("Root signature cost %zu exceeds maximum allowed cost.\n", info.cost); + return E_INVALIDARG; + } + /* XXX: Vulkan buffer and image descriptors have different types. In order * to preserve compatibility between Vulkan resource bindings for the same * root signature, we create descriptor set layouts with two bindings for