tests: Show that creating identical root signatures returns the same pointer.

This commit is contained in:
Stefan Dösinger 2023-12-02 21:22:43 +03:00 committed by Alexandre Julliard
parent 26a30b8539
commit 705cf10626
Notes: Alexandre Julliard 2023-12-07 22:48:26 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/507

View File

@ -2633,15 +2633,19 @@ static void test_create_unordered_access_view(void)
static void test_create_root_signature(void) static void test_create_root_signature(void)
{ {
ID3D12RootSignature *root_signature, *root_signature2;
D3D12_ROOT_SIGNATURE_DESC root_signature_desc; D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
D3D12_DESCRIPTOR_RANGE descriptor_ranges[2]; D3D12_DESCRIPTOR_RANGE descriptor_ranges[2];
D3D12_RESOURCE_BINDING_TIER binding_tier; D3D12_RESOURCE_BINDING_TIER binding_tier;
D3D12_ROOT_PARAMETER root_parameters[3]; D3D12_ROOT_PARAMETER root_parameters[3];
ID3D12RootSignature *root_signature;
ID3D12Device *device, *tmp_device; ID3D12Device *device, *tmp_device;
unsigned int size;
ULONG refcount; ULONG refcount;
HRESULT hr; HRESULT hr;
static const GUID test_guid
= {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
if (!(device = create_device())) if (!(device = create_device()))
{ {
skip("Failed to create device.\n"); skip("Failed to create device.\n");
@ -2653,6 +2657,43 @@ static void test_create_root_signature(void)
* ranges of different types. */ * ranges of different types. */
binding_tier = get_resource_binding_tier(device); binding_tier = get_resource_binding_tier(device);
/* empty root signature */
root_signature_desc.NumParameters = 0;
root_signature_desc.pParameters = NULL;
root_signature_desc.NumStaticSamplers = 0;
root_signature_desc.pStaticSamplers = NULL;
root_signature_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;
hr = create_root_signature(device, &root_signature_desc, &root_signature);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
/* Creating the same root signature twice returns the same interface pointer.
*
* However, the root signature object actually gets destroyed after releasing
* the last reference. Re-creating the same root descriptor later does not
* reliably return the same interface pointer, although it might do so if the
* heap manager reuses the allocation. */
hr = create_root_signature(device, &root_signature_desc, &root_signature2);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
todo ok(root_signature == root_signature2, "Got different root signature pointers.\n");
refcount = ID3D12RootSignature_Release(root_signature2);
todo ok(refcount == 1, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
hr = 0xdeadbeef;
hr = ID3D12RootSignature_SetPrivateData(root_signature, &test_guid, sizeof(hr), &hr);
ok(hr == S_OK, "Failed to set private data, hr %#x.\n", hr);
hr = ID3D12RootSignature_GetPrivateData(root_signature, &test_guid, &size, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
refcount = ID3D12RootSignature_Release(root_signature);
ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
hr = create_root_signature(device, &root_signature_desc, &root_signature);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
hr = ID3D12RootSignature_GetPrivateData(root_signature, &test_guid, &size, NULL);
ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
refcount = ID3D12RootSignature_Release(root_signature);
ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
/* descriptor table */ /* descriptor table */
descriptor_ranges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; descriptor_ranges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
descriptor_ranges[0].NumDescriptors = 1; descriptor_ranges[0].NumDescriptors = 1;
@ -2685,6 +2726,12 @@ static void test_create_root_signature(void)
check_interface(root_signature, &IID_ID3D12Pageable, false); check_interface(root_signature, &IID_ID3D12Pageable, false);
check_interface(root_signature, &IID_ID3D12RootSignature, true); check_interface(root_signature, &IID_ID3D12RootSignature, true);
hr = create_root_signature(device, &root_signature_desc, &root_signature2);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
todo ok(root_signature == root_signature2, "Got different root signature pointers.\n");
refcount = ID3D12RootSignature_Release(root_signature2);
todo ok(refcount == 1, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
refcount = ID3D12RootSignature_Release(root_signature); refcount = ID3D12RootSignature_Release(root_signature);
ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount); ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
@ -2747,17 +2794,6 @@ static void test_create_root_signature(void)
hr = create_root_signature(device, &root_signature_desc, &root_signature); hr = create_root_signature(device, &root_signature_desc, &root_signature);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
/* empty root signature */
root_signature_desc.NumParameters = 0;
root_signature_desc.pParameters = NULL;
root_signature_desc.NumStaticSamplers = 0;
root_signature_desc.pStaticSamplers = NULL;
root_signature_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;
hr = create_root_signature(device, &root_signature_desc, &root_signature);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
refcount = ID3D12RootSignature_Release(root_signature);
ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
/* root constants */ /* root constants */
root_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; root_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
root_parameters[0].Constants.ShaderRegister = 0; root_parameters[0].Constants.ShaderRegister = 0;