From 51c37735a911e415392ca0b06f8aa276ade01cb6 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Tue, 23 Apr 2024 12:45:45 +1000 Subject: [PATCH] tests: Use state RESOLVE_SOURCE for readback from multisampled textures. --- tests/d3d12_test_utils.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index 79c8bb69..fb6857e6 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -573,6 +573,7 @@ static void get_resource_readback_with_command_list_and_states(ID3D12Resource *r D3D12_RESOURCE_STATES initial_state, D3D12_RESOURCE_STATES final_state) { D3D12_HEAP_PROPERTIES heap_properties; + D3D12_RESOURCE_STATES readback_state; D3D12_RESOURCE_DESC resource_desc; ID3D12Resource *src_resource; D3D12_RANGE read_range; @@ -580,6 +581,7 @@ static void get_resource_readback_with_command_list_and_states(ID3D12Resource *r ID3D12Device *device; uint64_t buffer_size; HRESULT hr; + bool is_ms; hr = ID3D12Resource_GetDevice(resource, &IID_ID3D12Device, (void **)&device); assert_that(hr == S_OK, "Failed to get device, hr %#x.\n", hr); @@ -598,11 +600,14 @@ static void get_resource_readback_with_command_list_and_states(ID3D12Resource *r rb->rb.row_pitch = align(rb->rb.row_pitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); rb->rb.data = NULL; + is_ms = resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && resource_desc.SampleDesc.Count > 1; + readback_state = is_ms ? D3D12_RESOURCE_STATE_RESOLVE_SOURCE : D3D12_RESOURCE_STATE_COPY_SOURCE; + if (initial_state != RESOURCE_STATE_DO_NOT_CHANGE) - transition_sub_resource_state(command_list, resource, sub_resource, initial_state, D3D12_RESOURCE_STATE_COPY_SOURCE); + transition_sub_resource_state(command_list, resource, sub_resource, initial_state, readback_state); src_resource = resource; - if (resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && resource_desc.SampleDesc.Count > 1) + if (is_ms) { memset(&heap_properties, 0, sizeof(heap_properties)); heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT; @@ -652,7 +657,7 @@ static void get_resource_readback_with_command_list_and_states(ID3D12Resource *r } if (final_state != RESOURCE_STATE_DO_NOT_CHANGE) - transition_sub_resource_state(command_list, resource, sub_resource, D3D12_RESOURCE_STATE_COPY_SOURCE, final_state); + transition_sub_resource_state(command_list, resource, sub_resource, readback_state, final_state); hr = ID3D12GraphicsCommandList_Close(command_list); assert_that(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);