tests/d3d12: Do not crash when failing to create a shader cache session.

With some (Windows 11) runtimes creating a shader cache session fails
when the requested size is too small. The test will have to be fixed for
that, but in the meantime let's at least ensure it doesn't crash.
This commit is contained in:
Giovanni Mascellani
2025-10-17 12:01:01 +02:00
committed by Henri Verbeet
parent 67d391fad8
commit 0c9a5b7a0c
Notes: Henri Verbeet 2025-11-10 16:27:06 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1800

View File

@@ -38592,12 +38592,15 @@ static void test_shader_cache(void)
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc,
&IID_ID3D12ShaderCacheSession, (void **)&session);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
desc = ID3D12ShaderCacheSession_GetDesc(session);
ID3D12ShaderCacheSession_Release(session);
ok(desc.MaximumInMemoryCacheSizeBytes == 1, "Got MaximumInMemoryCacheSizeBytes %u.\n",
desc.MaximumInMemoryCacheSizeBytes);
ok(desc.MaximumValueFileSizeBytes == 1, "Got MaximumValueFileSizeBytes %u.\n",
desc.MaximumValueFileSizeBytes);
}
/* Invalid flags and mode are rejected. */
memset(&desc, 0, sizeof(desc));
@@ -38623,6 +38626,8 @@ static void test_shader_cache(void)
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc, &IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
refcount = get_refcount(device);
ok(refcount == base_refcount + 1, "Got unexpected refcount %u.\n", refcount);
@@ -38662,6 +38667,7 @@ static void test_shader_cache(void)
ok(hr == S_FALSE, "NULL outptr: Got hr %#x.\n", hr);
ID3D12ShaderCacheSession_Release(session);
}
refcount = get_refcount(device);
ok(refcount == base_refcount, "Got unexpected refcount %u.\n", refcount);
@@ -38670,6 +38676,9 @@ static void test_shader_cache(void)
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc,
&IID_ID3D12ShaderCacheSession, (void **)&session);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc,
&IID_ID3D12ShaderCacheSession, (void **)&session2);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -38707,9 +38716,14 @@ static void test_shader_cache(void)
memset(blob3, '3', sizeof(blob3));
ID3D12ShaderCacheSession_Release(session);
}
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc,
&IID_ID3D12ShaderCacheSession, (void **)&session);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = ID3D12ShaderCacheSession_StoreValue(session, key1, sizeof(key1), blob1, sizeof(blob1));
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -38794,11 +38808,15 @@ static void test_shader_cache(void)
/* Reset the cache so we don't get collisions on 'key1' if eviction failed. */
ID3D12ShaderCacheSession_Release(session);
}
desc.Mode = D3D12_SHADER_CACHE_MODE_MEMORY;
hr = ID3D12Device9_CreateShaderCacheSession(device, &desc,
&IID_ID3D12ShaderCacheSession, (void **)&session);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
/* Store a blob that is too big. It goes in at first but gets evicted next time.
*
* Why are we not getting DXGI_ERROR_CACHE_FULL here? I don't know. */
@@ -38830,6 +38848,7 @@ static void test_shader_cache(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ID3D12ShaderCacheSession_Release(session);
}
ID3D12Device9_Release(device);
destroy_test_context(&context);