Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 27393eec..8ae40afa 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2703,6 +2703,26 @@ static void test_create_root_signature(void) hr = create_root_signature(device, &root_signature_desc, &root_signature); ok(hr == E_INVALIDARG, "Failed to create root signature, hr %#x.\n", hr);
+ /* empty descriptor table */ + descriptor_ranges[0].NumDescriptors = 0; + root_parameters[0].DescriptorTable.NumDescriptorRanges = 1; + hr = create_root_signature(device, &root_signature_desc, &root_signature); + todo + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D12RootSignature_Release(root_signature); + + /* descriptor register range overflow + * Windows results vary for overflowing to zero, but anything beyond that is invalid. */ + descriptor_ranges[0].NumDescriptors = 0x1000; + descriptor_ranges[0].BaseShaderRegister = 0xfffff001; + root_parameters[0].DescriptorTable.NumDescriptorRanges = 1; + hr = create_root_signature(device, &root_signature_desc, &root_signature); + todo + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D12RootSignature_Release(root_signature); + /* empty root signature */ root_signature_desc.NumParameters = 0; root_signature_desc.pParameters = NULL;
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/state.c | 6 ++++++ tests/d3d12.c | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 6b088fff..92978a1b 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -345,6 +345,12 @@ static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_sig const D3D12_DESCRIPTOR_RANGE *range = &table->pDescriptorRanges[i]; unsigned int binding_count;
+ if (!range->NumDescriptors) + { + WARN("A descriptor register range is empty.\n"); + return E_INVALIDARG; + } + if (unbounded && range->OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) { WARN("An unbounded range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after " diff --git a/tests/d3d12.c b/tests/d3d12.c index 8ae40afa..775fabff 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2707,10 +2707,7 @@ static void test_create_root_signature(void) descriptor_ranges[0].NumDescriptors = 0; root_parameters[0].DescriptorTable.NumDescriptorRanges = 1; hr = create_root_signature(device, &root_signature_desc, &root_signature); - todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) - ID3D12RootSignature_Release(root_signature);
/* descriptor register range overflow * Windows results vary for overflowing to zero, but anything beyond that is invalid. */
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/state.c | 7 +++++++ tests/d3d12.c | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 92978a1b..094530b8 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -351,6 +351,13 @@ static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_sig return E_INVALIDARG; }
+ if (range->NumDescriptors != UINT_MAX && !vkd3d_bound_range(range->BaseShaderRegister, + range->NumDescriptors, UINT_MAX)) + { + WARN("A descriptor register range overflows.\n"); + return E_INVALIDARG; + } + if (unbounded && range->OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) { WARN("An unbounded range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after " diff --git a/tests/d3d12.c b/tests/d3d12.c index 775fabff..70f73b79 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2715,10 +2715,7 @@ static void test_create_root_signature(void) descriptor_ranges[0].BaseShaderRegister = 0xfffff001; root_parameters[0].DescriptorTable.NumDescriptorRanges = 1; hr = create_root_signature(device, &root_signature_desc, &root_signature); - todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) - ID3D12RootSignature_Release(root_signature);
/* empty root signature */ root_signature_desc.NumParameters = 0;
On Mon, 11 Oct 2021 at 16:33, Conor McCarthy cmccarthy@codeweavers.com wrote:
- /* descriptor register range overflow
* Windows results vary for overflowing to zero, but anything beyond that is invalid. */
"descriptor register range" seems a little out of place. We usually use "descriptor range", matching the d3d12 terminology. That applies to the subsequent patches in this series as well.