mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Validate resource pointer for transition barriers.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b6e35378fc
commit
e912a2c329
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user