Module: vkd3d Branch: master Commit: c691ad8869abda68038c225c98e5f1bec8b98efa URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/c691ad8869abda68038c225c98e5f1...
Author: Giovanni Mascellani gmascellani@codeweavers.com Date: Tue Oct 31 14:00:35 2023 +0100
tests: Immediately transition buffers after creation in the shader runner.
The resource could be destructed before the command list left open is executed; instead, we immediately perform the transition.
---
tests/d3d12_test_utils.h | 21 ++++++++++++++++++--- tests/shader_runner_d3d12.c | 7 +++---- 2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index 3c3e50ca..7473bbc4 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -773,9 +773,10 @@ static inline void upload_texture_data_(unsigned int line, ID3D12Resource *textu RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE); }
-#define upload_buffer_data(a, b, c, d, e, f) upload_buffer_data_(__LINE__, a, b, c, d, e, f) -static inline void upload_buffer_data_(unsigned int line, ID3D12Resource *buffer, size_t offset, - size_t size, const void *data, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list) +#define upload_buffer_data_with_states(a, b, c, d, e, f, g, h) upload_buffer_data_with_states_(__LINE__, a, b, c, d, e, f, g, h) +static inline void upload_buffer_data_with_states_(unsigned int line, ID3D12Resource *buffer, size_t offset, + size_t size, const void *data, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, + D3D12_RESOURCE_STATES initial_state, D3D12_RESOURCE_STATES final_state) { ID3D12Resource *upload_buffer; ID3D12Device *device; @@ -786,9 +787,15 @@ static inline void upload_buffer_data_(unsigned int line, ID3D12Resource *buffer
upload_buffer = create_upload_buffer_(line, device, size, data);
+ if (initial_state != RESOURCE_STATE_DO_NOT_CHANGE) + transition_resource_state(command_list, buffer, initial_state, D3D12_RESOURCE_STATE_COPY_DEST); + ID3D12GraphicsCommandList_CopyBufferRegion(command_list, buffer, offset, upload_buffer, 0, size);
+ if (final_state != RESOURCE_STATE_DO_NOT_CHANGE) + transition_resource_state(command_list, buffer, D3D12_RESOURCE_STATE_COPY_DEST, final_state); + hr = ID3D12GraphicsCommandList_Close(command_list); ok_(line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); exec_command_list(queue, command_list); @@ -798,6 +805,14 @@ static inline void upload_buffer_data_(unsigned int line, ID3D12Resource *buffer ID3D12Device_Release(device); }
+#define upload_buffer_data(a, b, c, d, e, f) upload_buffer_data_(__LINE__, a, b, c, d, e, f) +static inline void upload_buffer_data_(unsigned int line, ID3D12Resource *buffer, size_t offset, + size_t size, const void *data, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list) +{ + return upload_buffer_data_with_states_(line, buffer, offset, size, data, queue, command_list, + RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE); +} + static HRESULT create_root_signature(ID3D12Device *device, const D3D12_ROOT_SIGNATURE_DESC *desc, ID3D12RootSignature **root_signature) { diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 6c71b90f..a05dfd05 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -181,11 +181,10 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
resource->resource = create_default_buffer(device, params->data_size, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST); - upload_buffer_data(resource->resource, 0, params->data_size, resource_data, - test_context->queue, test_context->list); + upload_buffer_data_with_states(resource->resource, 0, params->data_size, resource_data, + test_context->queue, test_context->list, + RESOURCE_STATE_DO_NOT_CHANGE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); reset_command_list(test_context->list, test_context->allocator); - transition_resource_state(test_context->list, resource->resource, - D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
uav_desc.Format = params->format; uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;