[v2 PATCH vkd3d 1/4] tests: Fix shader tests crashes on WARP driver.

Nikolay Sivov nsivov at codeweavers.com
Sun Dec 19 06:41:06 CST 2021


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 tests/d3d12_test_utils.h    | 13 +++++++++++++
 tests/shader_runner_d3d12.c |  7 ++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index 5d900f8..f2ce922 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -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);
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
index d404895..47f419b 100644
--- a/tests/shader_runner_d3d12.c
+++ b/tests/shader_runner_d3d12.c
@@ -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);
     }
-- 
2.34.1




More information about the wine-devel mailing list