tests: Immediately transition resources after readback in the shader runner.

The resource could be destructed before the command list left open
is executed; instead, we immediately perform the transition.
This commit is contained in:
Giovanni Mascellani 2023-10-23 21:53:51 +02:00 committed by Alexandre Julliard
parent 589670180a
commit ca7fa0c015
Notes: Alexandre Julliard 2023-11-01 22:40:06 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/425
2 changed files with 21 additions and 8 deletions

View File

@ -415,8 +415,11 @@ struct d3d12_resource_readback
ID3D12Resource *resource;
};
static void get_resource_readback_with_command_list(ID3D12Resource *resource, unsigned int sub_resource,
struct d3d12_resource_readback *rb, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list)
#define RESOURCE_STATE_DO_NOT_CHANGE (~0u)
static void get_resource_readback_with_command_list_and_states(ID3D12Resource *resource, unsigned int sub_resource,
struct d3d12_resource_readback *rb, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
D3D12_RESOURCE_STATES initial_state, D3D12_RESOURCE_STATES final_state)
{
D3D12_HEAP_PROPERTIES heap_properties;
D3D12_RESOURCE_DESC resource_desc;
@ -444,6 +447,9 @@ static void get_resource_readback_with_command_list(ID3D12Resource *resource, un
rb->rb.row_pitch = align(rb->rb.row_pitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
rb->rb.data = NULL;
if (initial_state != RESOURCE_STATE_DO_NOT_CHANGE)
transition_sub_resource_state(command_list, resource, sub_resource, initial_state, D3D12_RESOURCE_STATE_COPY_SOURCE);
src_resource = resource;
if (resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && resource_desc.SampleDesc.Count > 1)
{
@ -493,6 +499,10 @@ static void get_resource_readback_with_command_list(ID3D12Resource *resource, un
ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, 0, 0, 0, &src_location, NULL);
}
if (final_state != RESOURCE_STATE_DO_NOT_CHANGE)
transition_sub_resource_state(command_list, resource, sub_resource, D3D12_RESOURCE_STATE_COPY_SOURCE, final_state);
hr = ID3D12GraphicsCommandList_Close(command_list);
assert_that(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
@ -509,6 +519,13 @@ static void get_resource_readback_with_command_list(ID3D12Resource *resource, un
assert_that(hr == S_OK, "Failed to map readback buffer, hr %#x.\n", hr);
}
static void get_resource_readback_with_command_list(ID3D12Resource *resource, unsigned int sub_resource,
struct d3d12_resource_readback *rb, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list)
{
return get_resource_readback_with_command_list_and_states(resource, sub_resource, rb, queue, command_list,
RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE);
}
static unsigned int get_readback_uint(struct resource_readback *rb,
unsigned int x, unsigned int y, unsigned int z)
{

View File

@ -546,13 +546,9 @@ static struct resource_readback *d3d12_runner_get_resource_readback(struct shade
else
state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
transition_resource_state(test_context->list, resource->resource,
state, D3D12_RESOURCE_STATE_COPY_SOURCE);
get_resource_readback_with_command_list(resource->resource, 0, rb,
test_context->queue, test_context->list);
get_resource_readback_with_command_list_and_states(resource->resource, 0, rb,
test_context->queue, test_context->list, state, state);
reset_command_list(test_context->list, test_context->allocator);
transition_resource_state(test_context->list, resource->resource,
D3D12_RESOURCE_STATE_COPY_SOURCE, state);
return &rb->rb;
}