vkd3d: Validate box in d3d12_command_list_CopyTextureRegion().

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:
Józef Kucia 2019-03-18 10:03:02 +01:00 committed by Alexandre Julliard
parent c960e10ea5
commit e9574e1f39
4 changed files with 29 additions and 0 deletions

View File

@ -2715,6 +2715,13 @@ static void d3d12_command_list_copy_incompatible_texture_region(struct d3d12_com
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &buffer_image_copy)); VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &buffer_image_copy));
} }
static bool validate_d3d12_box(const D3D12_BOX *box)
{
return box->right > box->left
&& box->bottom > box->top
&& box->back > box->front;
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12GraphicsCommandList1 *iface, static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12GraphicsCommandList1 *iface,
const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z, const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z,
const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box) const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box)
@ -2729,6 +2736,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
TRACE("iface %p, dst %p, dst_x %u, dst_y %u, dst_z %u, src %p, src_box %p.\n", TRACE("iface %p, dst %p, dst_x %u, dst_y %u, dst_z %u, src %p, src_box %p.\n",
iface, dst, dst_x, dst_y, dst_z, src, src_box); iface, dst, dst_x, dst_y, dst_z, src, src_box);
if (src_box && !validate_d3d12_box(src_box))
{
WARN("Empty box %s.\n", debug_d3d12_box(src_box));
return;
}
vk_procs = &list->device->vk_procs; vk_procs = &list->device->vk_procs;
dst_resource = unsafe_impl_from_ID3D12Resource(dst->pResource); dst_resource = unsafe_impl_from_ID3D12Resource(dst->pResource);

View File

@ -321,6 +321,16 @@ HRESULT return_interface(void *iface, REFIID iface_iid,
return hr; return hr;
} }
const char *debug_d3d12_box(const D3D12_BOX *box)
{
if (!box)
return "(null)";
return vkd3d_dbg_sprintf("(%u, %u, %u)-(%u, %u, %u)",
box->left, box->top, box->front,
box->right, box->bottom, box->back);
}
const char *debug_vk_extent_3d(VkExtent3D extent) const char *debug_vk_extent_3d(VkExtent3D extent)
{ {
return vkd3d_dbg_sprintf("(%u, %u, %u)", return vkd3d_dbg_sprintf("(%u, %u, %u)",

View File

@ -1015,6 +1015,7 @@ static inline bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *propertie
HRESULT return_interface(void *iface, REFIID iface_iid, HRESULT return_interface(void *iface, REFIID iface_iid,
REFIID requested_iid, void **object) DECLSPEC_HIDDEN; REFIID requested_iid, void **object) DECLSPEC_HIDDEN;
const char *debug_d3d12_box(const D3D12_BOX *box) DECLSPEC_HIDDEN;
const char *debug_vk_extent_3d(VkExtent3D extent) DECLSPEC_HIDDEN; const char *debug_vk_extent_3d(VkExtent3D extent) DECLSPEC_HIDDEN;
const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags) DECLSPEC_HIDDEN; const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags) DECLSPEC_HIDDEN;
const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN; const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;

View File

@ -20933,6 +20933,11 @@ static void test_copy_texture_buffer(void)
ID3D12GraphicsCommandList_CopyTextureRegion(command_list, ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
&dst_location, 32, 0, 0, &src_location, &box); &dst_location, 32, 0, 0, &src_location, &box);
/* empty box */
set_box(&box, 128, 0, 0, 32, 32, 1);
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
&dst_location, 0, 0, 0, &src_location, &box);
for (i = 0; i < ARRAY_SIZE(dst_buffers); ++i) for (i = 0; i < ARRAY_SIZE(dst_buffers); ++i)
{ {
transition_resource_state(command_list, dst_buffers[i], transition_resource_state(command_list, dst_buffers[i],