vkd3d: Pass device to vkd3d_format_from_d3d12_resource_desc().

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-05-07 15:37:01 +02:00 committed by Alexandre Julliard
parent 9babc0fb44
commit 7c8ce3c51c
4 changed files with 29 additions and 20 deletions

View File

@ -2029,7 +2029,7 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12
assert(d3d12_resource_is_texture(resource));
if (!(format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, 0)))
if (!(format = vkd3d_format_from_d3d12_resource_desc(list->device, &resource->desc, 0)))
{
ERR("Resource %p has invalid format %#x.\n", resource, resource->desc.Format);
return;
@ -3226,8 +3226,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
assert(d3d12_resource_is_buffer(dst_resource));
assert(d3d12_resource_is_texture(src_resource));
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc,
dst->u.PlacedFootprint.Footprint.Format)))
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&src_resource->desc, dst->u.PlacedFootprint.Footprint.Format)))
{
WARN("Invalid format %#x.\n", dst->u.PlacedFootprint.Footprint.Format);
return;
@ -3249,8 +3249,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
assert(d3d12_resource_is_texture(dst_resource));
assert(d3d12_resource_is_buffer(src_resource));
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc,
src->u.PlacedFootprint.Footprint.Format)))
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&dst_resource->desc, src->u.PlacedFootprint.Footprint.Format)))
{
WARN("Invalid format %#x.\n", src->u.PlacedFootprint.Footprint.Format);
return;
@ -3272,12 +3272,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
assert(d3d12_resource_is_texture(dst_resource));
assert(d3d12_resource_is_texture(src_resource));
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", dst_resource->desc.Format);
return;
}
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&src_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", src_resource->desc.Format);
return;
@ -3348,12 +3350,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(ID3D12GraphicsComm
}
else
{
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", dst_resource->desc.Format);
return;
}
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&src_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", src_resource->desc.Format);
return;
@ -3398,12 +3402,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi
const struct vkd3d_format *src_format, *dst_format, *vk_format;
struct d3d12_resource *dst_resource, *src_resource;
const struct vkd3d_vk_device_procs *vk_procs;
const struct d3d12_device *device;
VkImageResolve vk_image_resolve;
TRACE("iface %p, dst_resource %p, dst_sub_resource_idx %u, src_resource %p, src_sub_resource_idx %u, "
"format %#x.\n", iface, dst, dst_sub_resource_idx, src, src_sub_resource_idx, format);
vk_procs = &list->device->vk_procs;
device = list->device;
vk_procs = &device->vk_procs;
dst_resource = unsafe_impl_from_ID3D12Resource(dst);
src_resource = unsafe_impl_from_ID3D12Resource(src);
@ -3416,12 +3422,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi
d3d12_command_list_end_current_render_pass(list);
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(device, &dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", dst_resource->desc.Format);
return;
}
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN)))
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(device, &src_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", src_resource->desc.Format);
return;
@ -3429,7 +3435,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi
if (dxgi_format_is_typeless(dst_resource->desc.Format) || dxgi_format_is_typeless(src_resource->desc.Format))
{
if (!(vk_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, format)))
if (!(vk_format = vkd3d_format_from_d3d12_resource_desc(device, &dst_resource->desc, format)))
{
WARN("Invalid format %#x.\n", format);
return;
@ -3736,7 +3742,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
const struct vkd3d_format *format;
VkImageMemoryBarrier vk_barrier;
if (!(format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, 0)))
if (!(format = vkd3d_format_from_d3d12_resource_desc(list->device, &resource->desc, 0)))
{
ERR("Resource %p has invalid format %#x.\n", resource, resource->desc.Format);
continue;

View File

@ -2631,7 +2631,7 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
if (info->Alignment < D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
{
if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0)))
if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
{
WARN("Invalid format %#x.\n", desc->Format);
goto invalid;
@ -2840,6 +2840,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
UINT64 base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts,
UINT *row_counts, UINT64 *row_sizes, UINT64 *total_bytes)
{
struct d3d12_device *device = impl_from_ID3D12Device(iface);
static const struct vkd3d_format vkd3d_format_unknown
= {DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED, 1, 1, 1, 1, 0};
@ -2866,7 +2867,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
{
format = &vkd3d_format_unknown;
}
else if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0)))
else if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
{
WARN("Invalid format %#x.\n", desc->Format);
return;

View File

@ -577,7 +577,7 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
VkImageCreateInfo image_info;
VkResult vr;
if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0)))
if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
{
WARN("Invalid DXGI format %#x.\n", desc->Format);
return E_INVALIDARG;
@ -1709,7 +1709,7 @@ static bool vkd3d_create_buffer_view(struct d3d12_device *device,
format = vkd3d_get_format(DXGI_FORMAT_R32_UINT, false);
element_size = structure_stride;
}
else if ((format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, view_format)))
else if ((format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format)))
{
element_size = format->byte_count;
}
@ -1888,7 +1888,9 @@ struct vkd3d_texture_view_desc
static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc,
struct d3d12_resource *resource, DXGI_FORMAT view_format)
{
if (!(desc->format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, view_format)))
const struct d3d12_device *device = resource->device;
if (!(desc->format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format)))
{
FIXME("Failed to find format (resource format %#x, view format %#x).\n",
resource->desc.Format, view_format);

View File

@ -1039,7 +1039,7 @@ const struct vkd3d_format *vkd3d_get_format(DXGI_FORMAT dxgi_format, bool depth_
bool dxgi_format_is_typeless(DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN;
static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc(
const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format)
const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format)
{
return vkd3d_get_format(view_format ? view_format : desc->Format,
desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);