[PATCH vkd3d 1/2] tests: Fix shader tests crashes on WARP driver.
Giovanni Mascellani
gmascellani at codeweavers.com
Mon Dec 13 02:59:12 CST 2021
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
On 11/12/21 20:44, Nikolay Sivov wrote:
> Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
> ---
> tests/d3d12_test_utils.h | 3 +++
> tests/shader_runner_d3d12.c | 10 +++++-----
> 2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
> index 5d900f8..1f54e10 100644
> --- a/tests/d3d12_test_utils.h
> +++ b/tests/d3d12_test_utils.h
> @@ -956,6 +956,7 @@ struct test_context
> ID3D12CommandQueue *queue;
> ID3D12CommandAllocator *allocator;
> ID3D12GraphicsCommandList *list;
> + ID3D12PipelineState *pso;
>
> D3D12_RESOURCE_DESC render_target_desc;
> ID3D12Resource *render_target;
> @@ -1092,6 +1093,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);
> + if (context->pso)
> + ID3D12PipelineState_Release(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..283a264 100644
> --- a/tests/shader_runner_d3d12.c
> +++ b/tests/shader_runner_d3d12.c
> @@ -341,7 +341,6 @@ static void parse_test_directive(struct shader_context *context, const char *lin
> D3D12_STATIC_SAMPLER_DESC static_samplers[1];
> static const float clear_color[4];
> unsigned int uniform_index;
> - ID3D12PipelineState *pso;
> HRESULT hr;
> size_t i;
>
> @@ -419,9 +418,11 @@ 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,
> + if (context->c.pso)
> + ID3D12PipelineState_Release(context->c.pso);
> + context->c.pso = create_pipeline_state(context->c.device, context->c.root_signature,
> context->c.render_target_desc.Format, NULL, &ps, NULL);
> - if (!pso)
> + if (!context->c.pso)
> return;
>
> ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context->c.root_signature);
> @@ -437,9 +438,8 @@ static void parse_test_directive(struct shader_context *context, const char *lin
> ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context->c.viewport);
> ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
> ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context->c.rtv, clear_color, 0, NULL);
> - ID3D12GraphicsCommandList_SetPipelineState(command_list, pso);
> + ID3D12GraphicsCommandList_SetPipelineState(command_list, context->c.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);
> }
>
More information about the wine-devel
mailing list