Module: vkd3d Branch: master Commit: 705cf106264f03cb22a906fbca00d56bb3d0ea96 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/705cf106264f03cb22a906fbca00d5...
Author: Stefan Dösinger stefan@codeweavers.com Date: Sat Dec 2 21:22:43 2023 +0300
tests: Show that creating identical root signatures returns the same pointer.
---
tests/d3d12.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 12 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 49e3a840..5d894d4b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2633,15 +2633,19 @@ static void test_create_unordered_access_view(void)
static void test_create_root_signature(void) { + ID3D12RootSignature *root_signature, *root_signature2; D3D12_ROOT_SIGNATURE_DESC root_signature_desc; D3D12_DESCRIPTOR_RANGE descriptor_ranges[2]; D3D12_RESOURCE_BINDING_TIER binding_tier; D3D12_ROOT_PARAMETER root_parameters[3]; - ID3D12RootSignature *root_signature; ID3D12Device *device, *tmp_device; + unsigned int size; ULONG refcount; HRESULT hr;
+ static const GUID test_guid + = {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}}; + if (!(device = create_device())) { skip("Failed to create device.\n"); @@ -2653,6 +2657,43 @@ static void test_create_root_signature(void) * ranges of different types. */ 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_ranges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; 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_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); 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); 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_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; root_parameters[0].Constants.ShaderRegister = 0;