diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 4723e796..d3feb785 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -1140,6 +1140,18 @@ HRESULT d3d12_fence_create(struct d3d12_device *device, } /* Command buffers */ +static void d3d12_command_list_mark_as_invalid(struct d3d12_command_list *list, + const char *message, ...) +{ + va_list args; + + va_start(args, message); + WARN("Command list %p is invalid: \"%s\".\n", list, vkd3d_dbg_vsprintf(message, args)); + va_end(args); + + list->is_valid = false; +} + static HRESULT d3d12_command_list_begin_command_buffer(struct d3d12_command_list *list) { struct d3d12_device *device = list->device; @@ -3731,19 +3743,23 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC if (!is_valid_resource_state(transition->StateBefore)) { - WARN("Invalid StateBefore %#x (barrier %u).\n", transition->StateBefore, i); - list->is_valid = false; + d3d12_command_list_mark_as_invalid(list, + "Invalid StateBefore %#x (barrier %u).", transition->StateBefore, i); continue; } if (!is_valid_resource_state(transition->StateAfter)) { - WARN("Invalid StateAfter %#x (barrier %u).\n", transition->StateAfter, i); - list->is_valid = false; + d3d12_command_list_mark_as_invalid(list, + "Invalid StateAfter %#x (barrier %u).", transition->StateAfter, i); + continue; + } + + if (!(resource = unsafe_impl_from_ID3D12Resource(transition->pResource))) + { + d3d12_command_list_mark_as_invalid(list, "A resource pointer is NULL."); continue; } - resource = unsafe_impl_from_ID3D12Resource(transition->pResource); - assert(resource); sub_resource_idx = transition->Subresource; if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateBefore, diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 217c1c85..37bfc407 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -3201,7 +3201,7 @@ void d3d12_device_mark_as_removed(struct d3d12_device *device, HRESULT reason, va_list args; va_start(args, message); - WARN("Device %p is lost (reason %#x, message \"%s\").\n", + WARN("Device %p is lost (reason %#x, \"%s\").\n", device, reason, vkd3d_dbg_vsprintf(message, args)); va_end(args); diff --git a/tests/d3d12_invalid_usage.c b/tests/d3d12_invalid_usage.c index ab5deb5b..feb45b45 100644 --- a/tests/d3d12_invalid_usage.c +++ b/tests/d3d12_invalid_usage.c @@ -32,7 +32,7 @@ static void recreate_command_list_(unsigned int line, ID3D12Device *device, ok_(line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); } -static void test_invalid_texture_resource_barriers(void) +static void test_invalid_resource_barriers(void) { ID3D12Resource *texture, *readback_buffer, *upload_buffer; ID3D12CommandAllocator *command_allocator; @@ -127,6 +127,14 @@ static void test_invalid_texture_resource_barriers(void) hr = ID3D12GraphicsCommandList_Close(command_list); todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + recreate_command_list(device, command_allocator, &command_list); + + /* NULL resource. */ + transition_resource_state(command_list, NULL, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ID3D12CommandAllocator_Release(command_allocator); ID3D12CommandQueue_Release(queue); ID3D12GraphicsCommandList_Release(command_list); @@ -284,6 +292,6 @@ START_TEST(d3d12_invalid_usage) enable_d3d12_debug_layer(argc, argv); init_adapter_info(); - run_test(test_invalid_texture_resource_barriers); + run_test(test_invalid_resource_barriers); run_test(test_invalid_copy_texture_region); }