tests: Fix shader tests crashes on WARP driver.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-12-19 15:41:06 +03:00 committed by Alexandre Julliard
parent d0e539aec9
commit 3a480415c1
2 changed files with 17 additions and 3 deletions

View File

@ -956,6 +956,8 @@ struct test_context
ID3D12CommandQueue *queue;
ID3D12CommandAllocator *allocator;
ID3D12GraphicsCommandList *list;
ID3D12PipelineState **pso;
size_t pso_count, pso_capacity;
D3D12_RESOURCE_DESC render_target_desc;
ID3D12Resource *render_target;
@ -1074,6 +1076,15 @@ static inline bool init_test_context_(unsigned int line, struct test_context *co
return true;
}
static inline void destroy_pipeline_state_objects(struct test_context *context)
{
size_t i;
for (i = 0; i < context->pso_count; ++i)
ID3D12PipelineState_Release(context->pso[i]);
context->pso_count = 0;
}
#define destroy_test_context(context) destroy_test_context_(__LINE__, context)
static inline void destroy_test_context_(unsigned int line, struct test_context *context)
{
@ -1092,6 +1103,8 @@ static inline void destroy_test_context_(unsigned int line, struct test_context
ID3D12CommandAllocator_Release(context->allocator);
ID3D12CommandQueue_Release(context->queue);
ID3D12GraphicsCommandList_Release(context->list);
destroy_pipeline_state_objects(context);
free(context->pso);
refcount = ID3D12Device_Release(context->device);
ok_(line)(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);

View File

@ -419,10 +419,12 @@ static void parse_test_directive(struct shader_context *context, const char *lin
hr = create_root_signature(context->c.device, &root_signature_desc, &context->c.root_signature);
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
pso = create_pipeline_state(context->c.device, context->c.root_signature,
context->c.render_target_desc.Format, NULL, &ps, NULL);
pso = create_pipeline_state(context->c.device, context->c.root_signature, context->c.render_target_desc.Format,
NULL, &ps, NULL);
if (!pso)
return;
vkd3d_array_reserve((void **)&context->c.pso, &context->c.pso_capacity, context->c.pso_count + 1, sizeof(*context->c.pso));
context->c.pso[context->c.pso_count++] = pso;
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context->c.root_signature);
if (context->uniform_count)
@ -439,7 +441,6 @@ static void parse_test_directive(struct shader_context *context, const char *lin
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context->c.rtv, clear_color, 0, NULL);
ID3D12GraphicsCommandList_SetPipelineState(command_list, pso);
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
ID3D12PipelineState_Release(pso);
transition_resource_state(command_list, context->c.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
}