mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07: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"
|
#include "unknown.idl"
|
||||||
|
|
||||||
|
const UINT D3D12_MAX_ROOT_COST = 64;
|
||||||
|
|
||||||
const UINT D3D12_APPEND_ALIGNED_ELEMENT = 0xffffffff;
|
const UINT D3D12_APPEND_ALIGNED_ELEMENT = 0xffffffff;
|
||||||
cpp_quote("#define D3D12_DEFAULT_BLEND_FACTOR_ALPHA (1.0f)")
|
cpp_quote("#define D3D12_DEFAULT_BLEND_FACTOR_ALPHA (1.0f)")
|
||||||
cpp_quote("#define D3D12_DEFAULT_BLEND_FACTOR_BLUE (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 sampler_count;
|
||||||
size_t descriptor_count;
|
size_t descriptor_count;
|
||||||
size_t root_constant_count;
|
size_t root_constant_count;
|
||||||
|
size_t cost;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool d3d12_root_signature_info_count_descriptors(struct d3d12_root_signature_info *info,
|
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,
|
if (FAILED(hr = d3d12_root_signature_info_count_descriptors(info,
|
||||||
&p->u.DescriptorTable.pDescriptorRanges[j])))
|
&p->u.DescriptorTable.pDescriptorRanges[j])))
|
||||||
return hr;
|
return hr;
|
||||||
|
++info->cost;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_ROOT_PARAMETER_TYPE_CBV:
|
case D3D12_ROOT_PARAMETER_TYPE_CBV:
|
||||||
++info->cbv_count;
|
++info->cbv_count;
|
||||||
++info->descriptor_count;
|
++info->descriptor_count;
|
||||||
|
info->cost += 2;
|
||||||
break;
|
break;
|
||||||
case D3D12_ROOT_PARAMETER_TYPE_SRV:
|
case D3D12_ROOT_PARAMETER_TYPE_SRV:
|
||||||
++info->buffer_srv_count;
|
++info->buffer_srv_count;
|
||||||
++info->descriptor_count;
|
++info->descriptor_count;
|
||||||
|
info->cost += 2;
|
||||||
break;
|
break;
|
||||||
case D3D12_ROOT_PARAMETER_TYPE_UAV:
|
case D3D12_ROOT_PARAMETER_TYPE_UAV:
|
||||||
++info->buffer_uav_count;
|
++info->buffer_uav_count;
|
||||||
++info->descriptor_count;
|
++info->descriptor_count;
|
||||||
|
info->cost += 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
||||||
++info->root_constant_count;
|
++info->root_constant_count;
|
||||||
|
info->cost += p->u.Constants.Num32BitValues;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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)))
|
if (FAILED(hr = d3d12_root_signature_info_from_desc(&info, desc)))
|
||||||
return hr;
|
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
|
/* XXX: Vulkan buffer and image descriptors have different types. In order
|
||||||
* to preserve compatibility between Vulkan resource bindings for the same
|
* to preserve compatibility between Vulkan resource bindings for the same
|
||||||
* root signature, we create descriptor set layouts with two bindings for
|
* root signature, we create descriptor set layouts with two bindings for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user