Hack up test for repro.

This commit is contained in:
Hans-Kristian Arntzen 2021-09-23 23:07:04 +02:00
parent 768ccee59e
commit 985c906d3a
1 changed files with 49 additions and 26 deletions

View File

@ -87,7 +87,7 @@ void test_queue_wait(void)
context.pipeline_state = create_pipeline_state(context.device,
context.root_signature, context.render_target_desc.Format, NULL, &ps, NULL);
cb = create_upload_buffer(device, sizeof(color), NULL);
cb = create_upload_buffer(device, 512, NULL);
resource_desc = ID3D12Resource_GetDesc(context.render_target);
@ -95,20 +95,6 @@ void test_queue_wait(void)
buffer_size = row_pitch * resource_desc.Height;
readback_buffer = create_readback_buffer(device, buffer_size);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(command_list, 0,
ID3D12Resource_GetGPUVirtualAddress(cb));
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
dst_location.pResource = readback_buffer;
dst_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
dst_location.PlacedFootprint.Offset = 0;
@ -120,14 +106,47 @@ void test_queue_wait(void)
src_location.pResource = context.render_target;
src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
src_location.SubresourceIndex = 0;
ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, 0, 0, 0, &src_location, NULL);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(command_list, 0,
ID3D12Resource_GetGPUVirtualAddress(cb));
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, 0, 0, 0, &src_location, NULL);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
hr = ID3D12GraphicsCommandList_Close(command_list);
ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
ID3D12GraphicsCommandList *command_list2;
ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
context.allocator, NULL, &IID_ID3D12GraphicsCommandList, (void**)&command_list2);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list2, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list2, 1, &context.rtv, false, NULL);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list2, context.root_signature);
ID3D12GraphicsCommandList_SetPipelineState(command_list2, context.pipeline_state);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list2, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list2, 1, &context.viewport);
ID3D12GraphicsCommandList_RSSetScissorRects(command_list2, 1, &context.scissor_rect);
ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(command_list2, 0,
ID3D12Resource_GetGPUVirtualAddress(cb) + 0);
ID3D12GraphicsCommandList_DrawInstanced(command_list2, 3, 1, 0, 0);
transition_resource_state(command_list2, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
ID3D12GraphicsCommandList_CopyTextureRegion(command_list2, &dst_location, 0, 0, 0, &src_location, NULL);
transition_resource_state(command_list2, context.render_target,
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
hr = ID3D12GraphicsCommandList_Close(command_list2);
ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
/* Wait() with signaled fence */
update_buffer_data(cb, 0, sizeof(green), &green);
queue_wait(queue, fence, 1);
@ -139,20 +158,21 @@ void test_queue_wait(void)
/* Wait() before CPU signal */
update_buffer_data(cb, 0, sizeof(blue), &blue);
queue_wait(queue, fence, 2);
queue_wait(queue, fence, 1000);
exec_command_list(queue, command_list);
queue_signal(queue, fence2, 1);
hr = ID3D12Fence_SetEventOnCompletion(fence2, 1, event);
ok(hr == S_OK, "Failed to set event on completion, hr %#x.\n", hr);
ret = wait_event(event, 0);
ok(ret == WAIT_TIMEOUT, "Got unexpected return value %#x.\n", ret);
init_readback(&rb, readback_buffer, buffer_size, resource_desc.Width, resource_desc.Height, 1, row_pitch);
check_readback_data_uint(&rb, NULL, 0xff00ff00, 0);
release_resource_readback(&rb);
value = ID3D12Fence_GetCompletedValue(fence2);
ok(value == 0, "Got unexpected value %"PRIu64".\n", value);
hr = ID3D12Fence_Signal(fence, 2);
//ret = wait_event(event, 0);
//ok(ret == WAIT_TIMEOUT, "Got unexpected return value %#x.\n", ret);
//init_readback(&rb, readback_buffer, buffer_size, resource_desc.Width, resource_desc.Height, 1, row_pitch);
//check_readback_data_uint(&rb, NULL, 0xff00ff00, 0);
//release_resource_readback(&rb);
//value = ID3D12Fence_GetCompletedValue(fence2);
//ok(value == 0, "Got unexpected value %"PRIu64".\n", value);
hr = ID3D12Fence_Signal(fence, 1000);
ok(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr);
ret = wait_event(event, INFINITE);
ok(ret == WAIT_OBJECT_0, "Got unexpected return value %#x.\n", ret);
@ -164,6 +184,7 @@ void test_queue_wait(void)
value = ID3D12Fence_GetCompletedValue(fence2);
ok(value == 1, "Got unexpected value %"PRIu64".\n", value);
#if 0
/* Wait() before GPU signal */
update_buffer_data(cb, 0, sizeof(green), &green);
queue_wait(queue, fence, 3);
@ -224,6 +245,7 @@ void test_queue_wait(void)
value = ID3D12Fence_GetCompletedValue(fence);
ok(value == 7, "Got unexpected value %"PRIu64".\n", value);
#endif
destroy_event(event);
ID3D12Fence_Release(fence);
@ -231,6 +253,7 @@ void test_queue_wait(void)
ID3D12Resource_Release(cb);
ID3D12CommandQueue_Release(queue2);
ID3D12Resource_Release(readback_buffer);
ID3D12GraphicsCommandList_Release(command_list2);
destroy_test_context(&context);
}