mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
libs/vkd3d: Validate root signature size.
This commit is contained in:
parent
579a8bc3e0
commit
9eee65c3ab
@ -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)")
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user