vkd3d: Implement ID3D12Device8 and ID3D12Resource2.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
parent
d61f562a3e
commit
3b6a4ab988
|
@ -5605,7 +5605,7 @@ static void vk_image_subresource_layers_from_d3d12(VkImageSubresourceLayers *sub
|
|||
}
|
||||
|
||||
static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent,
|
||||
const D3D12_RESOURCE_DESC *resource_desc, unsigned int miplevel_idx)
|
||||
const D3D12_RESOURCE_DESC1 *resource_desc, unsigned int miplevel_idx)
|
||||
{
|
||||
extent->width = d3d12_resource_desc_get_width(resource_desc, miplevel_idx);
|
||||
extent->height = d3d12_resource_desc_get_height(resource_desc, miplevel_idx);
|
||||
|
@ -5614,7 +5614,7 @@ static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent,
|
|||
|
||||
static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy,
|
||||
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx,
|
||||
const D3D12_RESOURCE_DESC *image_desc, const struct vkd3d_format *src_format,
|
||||
const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *src_format,
|
||||
const struct vkd3d_format *dst_format, const D3D12_BOX *src_box, unsigned int dst_x,
|
||||
unsigned int dst_y, unsigned int dst_z)
|
||||
{
|
||||
|
@ -5657,7 +5657,7 @@ static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy,
|
|||
|
||||
static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy,
|
||||
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx,
|
||||
const D3D12_RESOURCE_DESC *image_desc,
|
||||
const D3D12_RESOURCE_DESC1 *image_desc,
|
||||
const struct vkd3d_format *src_format, const struct vkd3d_format *dst_format,
|
||||
const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
|
||||
{
|
||||
|
@ -5689,7 +5689,7 @@ static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy,
|
|||
|
||||
static void vk_image_copy_from_d3d12(VkImageCopy *image_copy,
|
||||
unsigned int src_sub_resource_idx, unsigned int dst_sub_resource_idx,
|
||||
const D3D12_RESOURCE_DESC *src_desc, const D3D12_RESOURCE_DESC *dst_desc,
|
||||
const D3D12_RESOURCE_DESC1 *src_desc, const D3D12_RESOURCE_DESC1 *dst_desc,
|
||||
const struct vkd3d_format *src_format, const struct vkd3d_format *dst_format,
|
||||
const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
|
||||
{
|
||||
|
|
|
@ -174,7 +174,7 @@ HRESULT vkd3d_shader_debug_ring_init(struct vkd3d_shader_debug_ring *ring,
|
|||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
D3D12_HEAP_PROPERTIES heap_properties;
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
D3D12_RESOURCE_DESC1 resource_desc;
|
||||
const char *env;
|
||||
|
||||
memset(ring, 0, sizeof(*ring));
|
||||
|
|
|
@ -2539,6 +2539,7 @@ HRESULT STDMETHODCALLTYPE d3d12_device_QueryInterface(d3d12_device_iface *iface,
|
|||
|| IsEqualGUID(riid, &IID_ID3D12Device5)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Device6)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Device7)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Device8)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Object)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
|
@ -4062,26 +4063,27 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(d3d12_device_iface *ifa
|
|||
return d3d12_device_CreateHeap1(iface, desc, NULL, iid, heap);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource1(d3d12_device_iface *iface,
|
||||
ID3D12Heap *heap, UINT64 heap_offset, const D3D12_RESOURCE_DESC1 *resource_desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
REFIID riid, void **resource);
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(d3d12_device_iface *iface,
|
||||
ID3D12Heap *heap, UINT64 heap_offset,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
|
||||
{
|
||||
struct d3d12_heap *heap_object = impl_from_ID3D12Heap(heap);
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_resource *object;
|
||||
HRESULT hr;
|
||||
D3D12_RESOURCE_DESC1 desc1;
|
||||
|
||||
TRACE("iface %p, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
|
||||
"optimized_clear_value %p, iid %s, resource %p.\n",
|
||||
"optimized_clear_value %p, riid %s, resource %p.\n",
|
||||
iface, heap, heap_offset, desc, initial_state,
|
||||
optimized_clear_value, debugstr_guid(iid), resource);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_placed(device, desc, heap_object,
|
||||
heap_offset, initial_state, optimized_clear_value, &object)))
|
||||
return hr;
|
||||
d3d12_resource_promote_desc(desc, &desc1);
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
return d3d12_device_CreatePlacedResource1(iface, heap, heap_offset, &desc1,
|
||||
initial_state, optimized_clear_value, iid, resource);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1(d3d12_device_iface *iface,
|
||||
|
@ -4170,108 +4172,27 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_GetDeviceRemovedReason(d3d12_devic
|
|||
return device->removed_reason;
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints1(d3d12_device_iface *iface,
|
||||
const D3D12_RESOURCE_DESC1 *desc, UINT first_sub_resource, UINT sub_resource_count,
|
||||
UINT64 base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, UINT *row_counts,
|
||||
UINT64 *row_sizes, UINT64 *total_bytes);
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(d3d12_device_iface *iface,
|
||||
const D3D12_RESOURCE_DESC *desc, UINT first_sub_resource, UINT sub_resource_count,
|
||||
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, 1};
|
||||
|
||||
unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch;
|
||||
unsigned int width, height, depth, num_planes, num_subresources;
|
||||
unsigned int num_subresources_per_plane, plane_idx;
|
||||
struct vkd3d_format_footprint plane_footprint;
|
||||
const struct vkd3d_format *format;
|
||||
uint64_t offset, size, total;
|
||||
D3D12_RESOURCE_DESC1 desc1;
|
||||
|
||||
TRACE("iface %p, desc %p, first_sub_resource %u, sub_resource_count %u, base_offset %#"PRIx64", "
|
||||
"layouts %p, row_counts %p, row_sizes %p, total_bytes %p.\n",
|
||||
iface, desc, first_sub_resource, sub_resource_count, base_offset,
|
||||
layouts, row_counts, row_sizes, total_bytes);
|
||||
|
||||
if (layouts)
|
||||
memset(layouts, 0xff, sizeof(*layouts) * sub_resource_count);
|
||||
if (row_counts)
|
||||
memset(row_counts, 0xff, sizeof(*row_counts) * sub_resource_count);
|
||||
if (row_sizes)
|
||||
memset(row_sizes, 0xff, sizeof(*row_sizes) * sub_resource_count);
|
||||
d3d12_resource_promote_desc(desc, &desc1);
|
||||
|
||||
total = ~(uint64_t)0;
|
||||
|
||||
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
format = &vkd3d_format_unknown;
|
||||
}
|
||||
else if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
|
||||
{
|
||||
WARN("Invalid format %#x.\n", desc->Format);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (FAILED(d3d12_resource_validate_desc(desc, device)))
|
||||
{
|
||||
WARN("Invalid resource desc.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
num_planes = format->plane_count;
|
||||
num_subresources_per_plane = d3d12_resource_desc_get_sub_resource_count_per_plane(desc);
|
||||
num_subresources = d3d12_resource_desc_get_sub_resource_count(device, desc);
|
||||
|
||||
if (first_sub_resource >= num_subresources
|
||||
|| sub_resource_count > num_subresources - first_sub_resource)
|
||||
{
|
||||
WARN("Invalid sub-resource range %u-%u for resource.\n", first_sub_resource, sub_resource_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
total = 0;
|
||||
for (i = 0; i < sub_resource_count; ++i)
|
||||
{
|
||||
sub_resource_idx = first_sub_resource + i;
|
||||
plane_idx = sub_resource_idx / num_subresources_per_plane;
|
||||
|
||||
plane_footprint = vkd3d_format_footprint_for_plane(format, plane_idx);
|
||||
|
||||
miplevel_idx = sub_resource_idx % desc->MipLevels;
|
||||
width = align(d3d12_resource_desc_get_width(desc, miplevel_idx), plane_footprint.block_width);
|
||||
height = align(d3d12_resource_desc_get_height(desc, miplevel_idx), plane_footprint.block_height);
|
||||
depth = d3d12_resource_desc_get_depth(desc, miplevel_idx);
|
||||
row_count = height / plane_footprint.block_height;
|
||||
row_size = (width / plane_footprint.block_width) * plane_footprint.block_byte_count;
|
||||
|
||||
/* For whatever reason, we need to use 512 bytes of alignment for depth-stencil formats.
|
||||
* This is not documented, but it is observed behavior on both NV and WARP drivers.
|
||||
* See test_get_copyable_footprints_planar(). */
|
||||
row_pitch = align(row_size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * num_planes);
|
||||
|
||||
if (layouts)
|
||||
{
|
||||
layouts[i].Offset = base_offset + offset;
|
||||
layouts[i].Footprint.Format = plane_footprint.dxgi_format;
|
||||
layouts[i].Footprint.Width = width;
|
||||
layouts[i].Footprint.Height = height;
|
||||
layouts[i].Footprint.Depth = depth;
|
||||
layouts[i].Footprint.RowPitch = row_pitch;
|
||||
}
|
||||
if (row_counts)
|
||||
row_counts[i] = row_count;
|
||||
if (row_sizes)
|
||||
row_sizes[i] = row_size;
|
||||
|
||||
size = max(0, row_count - 1) * row_pitch + row_size;
|
||||
size = max(0, depth - 1) * align(size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * num_planes) + size;
|
||||
|
||||
total = offset + size;
|
||||
offset = align(total, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
|
||||
}
|
||||
|
||||
end:
|
||||
if (total_bytes)
|
||||
*total_bytes = total;
|
||||
return d3d12_device_GetCopyableFootprints1(iface, &desc1, first_sub_resource,
|
||||
sub_resource_count, base_offset, layouts, row_counts, row_sizes, total_bytes);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateQueryHeap(d3d12_device_iface *iface,
|
||||
|
@ -4563,6 +4484,11 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateProtectedResourceSession(d3d
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource2(d3d12_device_iface *iface,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource);
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(d3d12_device_iface *iface,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
|
@ -4570,26 +4496,17 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(d3d12_dev
|
|||
ID3D12ProtectedResourceSession *protected_session,
|
||||
REFIID iid, void **resource)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_resource *object;
|
||||
HRESULT hr;
|
||||
D3D12_RESOURCE_DESC1 desc1;
|
||||
|
||||
TRACE("iface %p, heap_properties %p, heap_flags %#x, desc %p, initial_state %#x, "
|
||||
"optimized_clear_value %p, protected_session %p, iid %s, resource %p.\n",
|
||||
iface, heap_properties, heap_flags, desc, initial_state,
|
||||
optimized_clear_value, protected_session, debugstr_guid(iid), resource);
|
||||
|
||||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
d3d12_resource_promote_desc(desc, &desc1);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_committed(device, desc, heap_properties,
|
||||
heap_flags, initial_state, optimized_clear_value, &object)))
|
||||
{
|
||||
*resource = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
return d3d12_device_CreateCommittedResource2(iface, heap_properties, heap_flags, &desc1,
|
||||
initial_state, optimized_clear_value, protected_session, iid, resource);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(d3d12_device_iface *iface,
|
||||
|
@ -4621,6 +4538,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1(d3d12_devi
|
|||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_resource *object;
|
||||
D3D12_RESOURCE_DESC1 desc1;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, desc %p, initial_state %#x, optimized_clear_value %p, protected_session %p, iid %s, resource %p.\n",
|
||||
|
@ -4629,84 +4547,47 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1(d3d12_devi
|
|||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_reserved(device, desc,
|
||||
d3d12_resource_promote_desc(desc, &desc1);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_reserved(device, &desc1,
|
||||
initial_state, optimized_clear_value, &object)))
|
||||
return hr;
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
}
|
||||
|
||||
static D3D12_RESOURCE_ALLOCATION_INFO* STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo2(d3d12_device_iface *iface,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask, UINT count, const D3D12_RESOURCE_DESC1 *resource_descs,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO1 *resource_infos);
|
||||
|
||||
static D3D12_RESOURCE_ALLOCATION_INFO* STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo1(d3d12_device_iface *iface,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask, UINT count, const D3D12_RESOURCE_DESC *resource_descs,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO1 *resource_infos)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
uint64_t requested_alignment, resource_offset;
|
||||
D3D12_RESOURCE_ALLOCATION_INFO resource_info;
|
||||
bool hasMsaaResource = false;
|
||||
D3D12_RESOURCE_DESC1 local_descs[16];
|
||||
D3D12_RESOURCE_DESC1 *desc1;
|
||||
unsigned int i;
|
||||
|
||||
TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n",
|
||||
iface, info, visible_mask, count, resource_descs);
|
||||
TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p, resource_infos %p.\n",
|
||||
iface, info, visible_mask, count, resource_descs, resource_infos);
|
||||
|
||||
debug_ignored_node_mask(visible_mask);
|
||||
|
||||
info->SizeInBytes = 0;
|
||||
info->Alignment = 0;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if (count > ARRAY_SIZE(local_descs))
|
||||
desc1 = vkd3d_malloc(sizeof(*desc1) * count);
|
||||
else
|
||||
{
|
||||
const D3D12_RESOURCE_DESC *desc = &resource_descs[i];
|
||||
hasMsaaResource |= desc->SampleDesc.Count > 1;
|
||||
|
||||
if (FAILED(d3d12_resource_validate_desc(desc, device)))
|
||||
{
|
||||
WARN("Invalid resource desc.\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
resource_info.SizeInBytes = desc->Width;
|
||||
resource_info.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(vkd3d_get_image_allocation_info(device, desc, &resource_info)))
|
||||
{
|
||||
WARN("Failed to get allocation info for texture.\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
requested_alignment = desc->Alignment
|
||||
? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
resource_info.Alignment = max(resource_info.Alignment, requested_alignment);
|
||||
}
|
||||
|
||||
resource_info.SizeInBytes = align(resource_info.SizeInBytes, resource_info.Alignment);
|
||||
resource_offset = align(info->SizeInBytes, resource_info.Alignment);
|
||||
|
||||
if (resource_infos)
|
||||
{
|
||||
resource_infos[i].Offset = resource_offset;
|
||||
resource_infos[i].SizeInBytes = resource_info.SizeInBytes;
|
||||
resource_infos[i].Alignment = resource_info.Alignment;
|
||||
}
|
||||
|
||||
info->SizeInBytes = resource_offset + resource_info.SizeInBytes;
|
||||
info->Alignment = max(info->Alignment, resource_info.Alignment);
|
||||
/* Avoid a compiler warning */
|
||||
memset(local_descs, 0, sizeof(local_descs));
|
||||
desc1 = local_descs;
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
invalid:
|
||||
info->SizeInBytes = ~(uint64_t)0;
|
||||
for (i = 0; i < count; i++)
|
||||
d3d12_resource_promote_desc(&resource_descs[i], &desc1[i]);
|
||||
|
||||
/* FIXME: Should we support D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT for small MSSA resources? */
|
||||
if (hasMsaaResource)
|
||||
info->Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
else
|
||||
info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
d3d12_device_GetResourceAllocationInfo2(iface, info, visible_mask, count, desc1, resource_infos);
|
||||
|
||||
if (desc1 != local_descs)
|
||||
vkd3d_free(desc1);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -4849,7 +4730,242 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateProtectedResourceSession1(d3
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl =
|
||||
static D3D12_RESOURCE_ALLOCATION_INFO* STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo2(d3d12_device_iface *iface,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask, UINT count, const D3D12_RESOURCE_DESC1 *resource_descs,
|
||||
D3D12_RESOURCE_ALLOCATION_INFO1 *resource_infos)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
uint64_t requested_alignment, resource_offset;
|
||||
D3D12_RESOURCE_ALLOCATION_INFO resource_info;
|
||||
bool hasMsaaResource = false;
|
||||
unsigned int i;
|
||||
|
||||
TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n",
|
||||
iface, info, visible_mask, count, resource_descs);
|
||||
|
||||
debug_ignored_node_mask(visible_mask);
|
||||
|
||||
info->SizeInBytes = 0;
|
||||
info->Alignment = 0;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const D3D12_RESOURCE_DESC1 *desc = &resource_descs[i];
|
||||
hasMsaaResource |= desc->SampleDesc.Count > 1;
|
||||
|
||||
if (FAILED(d3d12_resource_validate_desc(desc, device)))
|
||||
{
|
||||
WARN("Invalid resource desc.\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
resource_info.SizeInBytes = desc->Width;
|
||||
resource_info.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(vkd3d_get_image_allocation_info(device, desc, &resource_info)))
|
||||
{
|
||||
WARN("Failed to get allocation info for texture.\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
requested_alignment = desc->Alignment
|
||||
? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
resource_info.Alignment = max(resource_info.Alignment, requested_alignment);
|
||||
}
|
||||
|
||||
resource_info.SizeInBytes = align(resource_info.SizeInBytes, resource_info.Alignment);
|
||||
resource_offset = align(info->SizeInBytes, resource_info.Alignment);
|
||||
|
||||
if (resource_infos)
|
||||
{
|
||||
resource_infos[i].Offset = resource_offset;
|
||||
resource_infos[i].SizeInBytes = resource_info.SizeInBytes;
|
||||
resource_infos[i].Alignment = resource_info.Alignment;
|
||||
}
|
||||
|
||||
info->SizeInBytes = resource_offset + resource_info.SizeInBytes;
|
||||
info->Alignment = max(info->Alignment, resource_info.Alignment);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
invalid:
|
||||
info->SizeInBytes = ~(uint64_t)0;
|
||||
|
||||
/* FIXME: Should we support D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT for small MSSA resources? */
|
||||
if (hasMsaaResource)
|
||||
info->Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
else
|
||||
info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource2(d3d12_device_iface *iface,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_resource *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, heap_properties %p, heap_flags %#x, desc %p, initial_state %#x, "
|
||||
"optimized_clear_value %p, protected_session %p, iid %s, resource %p.\n",
|
||||
iface, heap_properties, heap_flags, desc, initial_state,
|
||||
optimized_clear_value, protected_session, debugstr_guid(iid), resource);
|
||||
|
||||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_committed(device, desc, heap_properties,
|
||||
heap_flags, initial_state, optimized_clear_value, &object)))
|
||||
{
|
||||
*resource = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource1(d3d12_device_iface *iface,
|
||||
ID3D12Heap *heap, UINT64 heap_offset, const D3D12_RESOURCE_DESC1 *resource_desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
REFIID iid, void **resource)
|
||||
{
|
||||
struct d3d12_heap *heap_object = impl_from_ID3D12Heap(heap);
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_resource *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
|
||||
"optimized_clear_value %p, iid %s, resource %p.\n",
|
||||
iface, heap, heap_offset, resource_desc, initial_state,
|
||||
optimized_clear_value, debugstr_guid(iid), resource);
|
||||
|
||||
if (FAILED(hr = d3d12_resource_create_placed(device, resource_desc, heap_object,
|
||||
heap_offset, initial_state, optimized_clear_value, &object)))
|
||||
return hr;
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_device_CreateSamplerFeedbackUnorderedAccessView(d3d12_device_iface *iface,
|
||||
ID3D12Resource *target_resource, ID3D12Resource *feedback_resource, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
|
||||
{
|
||||
FIXME("iface %p, target_resource %p, feedback_resource %p, descriptor %#lx stub!\n",
|
||||
iface, target_resource, feedback_resource, descriptor);
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints1(d3d12_device_iface *iface,
|
||||
const D3D12_RESOURCE_DESC1 *desc, UINT first_sub_resource, UINT sub_resource_count,
|
||||
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, 1};
|
||||
|
||||
unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch;
|
||||
unsigned int width, height, depth, num_planes, num_subresources;
|
||||
unsigned int num_subresources_per_plane, plane_idx;
|
||||
struct vkd3d_format_footprint plane_footprint;
|
||||
const struct vkd3d_format *format;
|
||||
uint64_t offset, size, total;
|
||||
|
||||
TRACE("iface %p, desc %p, first_sub_resource %u, sub_resource_count %u, base_offset %#"PRIx64", "
|
||||
"layouts %p, row_counts %p, row_sizes %p, total_bytes %p.\n",
|
||||
iface, desc, first_sub_resource, sub_resource_count, base_offset,
|
||||
layouts, row_counts, row_sizes, total_bytes);
|
||||
|
||||
if (layouts)
|
||||
memset(layouts, 0xff, sizeof(*layouts) * sub_resource_count);
|
||||
if (row_counts)
|
||||
memset(row_counts, 0xff, sizeof(*row_counts) * sub_resource_count);
|
||||
if (row_sizes)
|
||||
memset(row_sizes, 0xff, sizeof(*row_sizes) * sub_resource_count);
|
||||
|
||||
total = ~(uint64_t)0;
|
||||
|
||||
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
format = &vkd3d_format_unknown;
|
||||
}
|
||||
else if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
|
||||
{
|
||||
WARN("Invalid format %#x.\n", desc->Format);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (FAILED(d3d12_resource_validate_desc(desc, device)))
|
||||
{
|
||||
WARN("Invalid resource desc.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
num_planes = format->plane_count;
|
||||
num_subresources_per_plane = d3d12_resource_desc_get_sub_resource_count_per_plane(desc);
|
||||
num_subresources = d3d12_resource_desc_get_sub_resource_count(device, desc);
|
||||
|
||||
if (first_sub_resource >= num_subresources
|
||||
|| sub_resource_count > num_subresources - first_sub_resource)
|
||||
{
|
||||
WARN("Invalid sub-resource range %u-%u for resource.\n", first_sub_resource, sub_resource_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
total = 0;
|
||||
for (i = 0; i < sub_resource_count; ++i)
|
||||
{
|
||||
sub_resource_idx = first_sub_resource + i;
|
||||
plane_idx = sub_resource_idx / num_subresources_per_plane;
|
||||
|
||||
plane_footprint = vkd3d_format_footprint_for_plane(format, plane_idx);
|
||||
|
||||
miplevel_idx = sub_resource_idx % desc->MipLevels;
|
||||
width = align(d3d12_resource_desc_get_width(desc, miplevel_idx), plane_footprint.block_width);
|
||||
height = align(d3d12_resource_desc_get_height(desc, miplevel_idx), plane_footprint.block_height);
|
||||
depth = d3d12_resource_desc_get_depth(desc, miplevel_idx);
|
||||
row_count = height / plane_footprint.block_height;
|
||||
row_size = (width / plane_footprint.block_width) * plane_footprint.block_byte_count;
|
||||
|
||||
/* For whatever reason, we need to use 512 bytes of alignment for depth-stencil formats.
|
||||
* This is not documented, but it is observed behavior on both NV and WARP drivers.
|
||||
* See test_get_copyable_footprints_planar(). */
|
||||
row_pitch = align(row_size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * num_planes);
|
||||
|
||||
if (layouts)
|
||||
{
|
||||
layouts[i].Offset = base_offset + offset;
|
||||
layouts[i].Footprint.Format = plane_footprint.dxgi_format;
|
||||
layouts[i].Footprint.Width = width;
|
||||
layouts[i].Footprint.Height = height;
|
||||
layouts[i].Footprint.Depth = depth;
|
||||
layouts[i].Footprint.RowPitch = row_pitch;
|
||||
}
|
||||
if (row_counts)
|
||||
row_counts[i] = row_count;
|
||||
if (row_sizes)
|
||||
row_sizes[i] = row_size;
|
||||
|
||||
size = max(0, row_count - 1) * row_pitch + row_size;
|
||||
size = max(0, depth - 1) * align(size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * num_planes) + size;
|
||||
|
||||
total = offset + size;
|
||||
offset = align(total, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
|
||||
}
|
||||
|
||||
end:
|
||||
if (total_bytes)
|
||||
*total_bytes = total;
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Device8Vtbl d3d12_device_vtbl =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
d3d12_device_QueryInterface,
|
||||
|
@ -4929,6 +5045,12 @@ CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl =
|
|||
/* ID3D12Device7 methods */
|
||||
d3d12_device_AddToStateObject,
|
||||
d3d12_device_CreateProtectedResourceSession1,
|
||||
/* ID3D12Device8 methods */
|
||||
d3d12_device_GetResourceAllocationInfo2,
|
||||
d3d12_device_CreateCommittedResource2,
|
||||
d3d12_device_CreatePlacedResource1,
|
||||
d3d12_device_CreateSamplerFeedbackUnorderedAccessView,
|
||||
d3d12_device_GetCopyableFootprints1,
|
||||
};
|
||||
|
||||
#ifdef VKD3D_ENABLE_PROFILING
|
||||
|
|
|
@ -215,7 +215,31 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePipelineState_profiled(d3d12
|
|||
DEVICE_PROFILED_CALL_HRESULT(CreatePipelineState, iface, desc, riid, pipeline_state);
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl_profiled =
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource2_profiled(d3d12_device_iface *iface,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource)
|
||||
{
|
||||
DEVICE_PROFILED_CALL_HRESULT(CreateCommittedResource2, iface, heap_properties, heap_flags,
|
||||
desc, initial_state, optimized_clear_value, protected_session, iid, resource);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource1_profiled(d3d12_device_iface *iface,
|
||||
ID3D12Heap *heap, UINT64 heap_offset, const D3D12_RESOURCE_DESC1 *desc,
|
||||
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
|
||||
REFIID iid, void **resource)
|
||||
{
|
||||
DEVICE_PROFILED_CALL_HRESULT(CreatePlacedResource1, iface, heap, heap_offset,
|
||||
desc, initial_state, optimized_clear_value, iid, resource);
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_device_CreateSamplerFeedbackUnorderedAccessView_profiled(d3d12_device_iface *iface,
|
||||
ID3D12Resource *target_resource, ID3D12Resource *feedback_resource, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
|
||||
{
|
||||
DEVICE_PROFILED_CALL(CreateSamplerFeedbackUnorderedAccessView, iface, target_resource, feedback_resource, descriptor);
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Device8Vtbl d3d12_device_vtbl_profiled =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
d3d12_device_QueryInterface,
|
||||
|
@ -295,6 +319,12 @@ CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl_profiled =
|
|||
/* ID3D12Device7 methods */
|
||||
d3d12_device_AddToStateObject,
|
||||
d3d12_device_CreateProtectedResourceSession1,
|
||||
/* ID3D12Device8 methods */
|
||||
d3d12_device_GetResourceAllocationInfo2,
|
||||
d3d12_device_CreateCommittedResource2_profiled,
|
||||
d3d12_device_CreatePlacedResource1_profiled,
|
||||
d3d12_device_CreateSamplerFeedbackUnorderedAccessView_profiled,
|
||||
d3d12_device_GetCopyableFootprints1,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -117,7 +117,7 @@ static HRESULT vkd3d_select_memory_flags(struct d3d12_device *device, const D3D1
|
|||
|
||||
static HRESULT vkd3d_create_global_buffer(struct d3d12_device *device, VkDeviceSize size, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkBuffer *vk_buffer)
|
||||
{
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
D3D12_RESOURCE_DESC1 resource_desc;
|
||||
|
||||
memset(&resource_desc, 0, sizeof(resource_desc));
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
|
|
|
@ -88,7 +88,7 @@ VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *d
|
|||
|
||||
HRESULT vkd3d_create_buffer(struct d3d12_device *device,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
|
||||
const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer)
|
||||
const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
VkExternalMemoryBufferCreateInfo external_info;
|
||||
|
@ -202,7 +202,7 @@ HRESULT vkd3d_create_buffer(struct d3d12_device *device,
|
|||
return hresult_from_vk_result(vr);
|
||||
}
|
||||
|
||||
static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC *desc)
|
||||
static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
unsigned int size = max(desc->Width, desc->Height);
|
||||
size = max(size, d3d12_resource_desc_get_depth(desc, 0));
|
||||
|
@ -263,7 +263,7 @@ static bool vkd3d_is_linear_tiling_supported(const struct d3d12_device *device,
|
|||
return supported;
|
||||
}
|
||||
|
||||
static VkImageLayout vk_common_image_layout_from_d3d12_desc(const D3D12_RESOURCE_DESC *desc)
|
||||
static VkImageLayout vk_common_image_layout_from_d3d12_desc(const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
/* We need aggressive decay and promotion into anything. */
|
||||
if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS)
|
||||
|
@ -281,7 +281,7 @@ static VkImageLayout vk_common_image_layout_from_d3d12_desc(const D3D12_RESOURCE
|
|||
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
|
||||
static bool vkd3d_sparse_image_may_have_mip_tail(const D3D12_RESOURCE_DESC *desc,
|
||||
static bool vkd3d_sparse_image_may_have_mip_tail(const D3D12_RESOURCE_DESC1 *desc,
|
||||
const VkSparseImageFormatProperties *sparse_info)
|
||||
{
|
||||
VkExtent3D mip_extent, block_extent = sparse_info->imageGranularity;
|
||||
|
@ -306,7 +306,7 @@ static bool vkd3d_sparse_image_may_have_mip_tail(const D3D12_RESOURCE_DESC *desc
|
|||
}
|
||||
|
||||
static bool vkd3d_resource_can_be_vrs(struct d3d12_device *device,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, const D3D12_RESOURCE_DESC *desc)
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
return device->device_info.fragment_shading_rate_features.attachmentFragmentShadingRate &&
|
||||
desc->Format == DXGI_FORMAT_R8_UINT &&
|
||||
|
@ -355,7 +355,7 @@ static HRESULT vkd3d_resource_make_vrs_view(struct d3d12_device *device,
|
|||
|
||||
static HRESULT vkd3d_create_image(struct d3d12_device *device,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
|
||||
const D3D12_RESOURCE_DESC *desc, struct d3d12_resource *resource, VkImage *vk_image)
|
||||
const D3D12_RESOURCE_DESC1 *desc, struct d3d12_resource *resource, VkImage *vk_image)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
const struct vkd3d_format_compatibility_list *compat_list;
|
||||
|
@ -612,11 +612,11 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
|
|||
}
|
||||
|
||||
HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info)
|
||||
const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info)
|
||||
{
|
||||
static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT};
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
D3D12_RESOURCE_DESC validated_desc;
|
||||
D3D12_RESOURCE_DESC1 validated_desc;
|
||||
VkMemoryRequirements requirements;
|
||||
VkDeviceSize target_alignment;
|
||||
VkImage vk_image;
|
||||
|
@ -1115,7 +1115,7 @@ static void d3d12_resource_get_tiling(struct d3d12_device *device, struct d3d12_
|
|||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
VkSparseImageMemoryRequirements *memory_requirements = NULL;
|
||||
unsigned int i, tile_count, packed_tiles, standard_mips;
|
||||
const D3D12_RESOURCE_DESC *desc = &resource->desc;
|
||||
const D3D12_RESOURCE_DESC1 *desc = &resource->desc;
|
||||
uint32_t memory_requirement_count = 0;
|
||||
VkExtent3D block_extent;
|
||||
|
||||
|
@ -1313,6 +1313,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(d3d12_resource_if
|
|||
|
||||
if (IsEqualGUID(riid, &IID_ID3D12Resource)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Resource1)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Resource2)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Pageable)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12DeviceChild)
|
||||
|| IsEqualGUID(riid, &IID_ID3D12Object)
|
||||
|
@ -1331,7 +1332,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(d3d12_resource_if
|
|||
|
||||
static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(d3d12_resource_iface *iface)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
ULONG refcount = InterlockedIncrement(&resource->refcount);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", resource, refcount);
|
||||
|
@ -1349,7 +1350,7 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(d3d12_resource_iface *iface
|
|||
|
||||
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(d3d12_resource_iface *iface)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
ULONG refcount = InterlockedDecrement(&resource->refcount);
|
||||
|
||||
TRACE("%p decreasing refcount to %u.\n", resource, refcount);
|
||||
|
@ -1363,7 +1364,7 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_Release(d3d12_resource_iface *ifac
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(d3d12_resource_iface *iface,
|
||||
REFGUID guid, UINT *data_size, void *data)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
||||
|
||||
|
@ -1373,7 +1374,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(d3d12_resource_if
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(d3d12_resource_iface *iface,
|
||||
REFGUID guid, UINT data_size, const void *data)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
||||
|
||||
|
@ -1384,7 +1385,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(d3d12_resource_if
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(d3d12_resource_iface *iface,
|
||||
REFGUID guid, const IUnknown *data)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
||||
|
||||
|
@ -1394,7 +1395,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(d3d12_re
|
|||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(d3d12_resource_iface *iface, REFIID iid, void **device)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
|
||||
|
||||
|
@ -1478,7 +1479,7 @@ static bool d3d12_resource_texture_validate_map(struct d3d12_resource *resource)
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(d3d12_resource_iface *iface, UINT sub_resource,
|
||||
const D3D12_RANGE *read_range, void **data)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
unsigned int sub_resource_count;
|
||||
|
||||
TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n",
|
||||
|
@ -1524,7 +1525,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(d3d12_resource_iface *iface,
|
|||
static void STDMETHODCALLTYPE d3d12_resource_Unmap(d3d12_resource_iface *iface, UINT sub_resource,
|
||||
const D3D12_RANGE *written_range)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
unsigned int sub_resource_count;
|
||||
|
||||
TRACE("iface %p, sub_resource %u, written_range %p.\n",
|
||||
|
@ -1543,17 +1544,26 @@ static void STDMETHODCALLTYPE d3d12_resource_Unmap(d3d12_resource_iface *iface,
|
|||
static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(d3d12_resource_iface *iface,
|
||||
D3D12_RESOURCE_DESC *resource_desc)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
|
||||
|
||||
*resource_desc = resource->desc;
|
||||
resource_desc->Dimension = resource->desc.Dimension;
|
||||
resource_desc->Alignment = resource->desc.Alignment;
|
||||
resource_desc->Width = resource->desc.Width;
|
||||
resource_desc->Height = resource->desc.Height;
|
||||
resource_desc->DepthOrArraySize = resource->desc.DepthOrArraySize;
|
||||
resource_desc->MipLevels = resource->desc.MipLevels;
|
||||
resource_desc->Format = resource->desc.Format;
|
||||
resource_desc->SampleDesc = resource->desc.SampleDesc;
|
||||
resource_desc->Layout = resource->desc.Layout;
|
||||
resource_desc->Flags = resource->desc.Flags;
|
||||
return resource_desc;
|
||||
}
|
||||
|
||||
static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(d3d12_resource_iface *iface)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
|
@ -1564,7 +1574,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(d3d12_resourc
|
|||
UINT dst_sub_resource, const D3D12_BOX *dst_box, const void *src_data,
|
||||
UINT src_row_pitch, UINT src_slice_pitch)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
const struct vkd3d_vk_device_procs *vk_procs;
|
||||
VkImageSubresource vk_sub_resource;
|
||||
VkSubresourceLayout vk_layout;
|
||||
|
@ -1643,7 +1653,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(d3d12_resour
|
|||
void *dst_data, UINT dst_row_pitch, UINT dst_slice_pitch,
|
||||
UINT src_sub_resource, const D3D12_BOX *src_box)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
const struct vkd3d_vk_device_procs *vk_procs;
|
||||
VkImageSubresource vk_sub_resource;
|
||||
VkSubresourceLayout vk_layout;
|
||||
|
@ -1721,7 +1731,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(d3d12_resour
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(d3d12_resource_iface *iface,
|
||||
D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, heap_properties %p, flags %p.\n",
|
||||
iface, heap_properties, flags);
|
||||
|
@ -1762,7 +1772,18 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(d3d1
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Resource1Vtbl d3d12_resource_vtbl =
|
||||
static D3D12_RESOURCE_DESC1 * STDMETHODCALLTYPE d3d12_resource_GetDesc1(d3d12_resource_iface *iface,
|
||||
D3D12_RESOURCE_DESC1 *resource_desc)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
|
||||
|
||||
TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
|
||||
|
||||
*resource_desc = resource->desc;
|
||||
return resource_desc;
|
||||
}
|
||||
|
||||
CONST_VTBL struct ID3D12Resource2Vtbl d3d12_resource_vtbl =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
d3d12_resource_QueryInterface,
|
||||
|
@ -1785,6 +1806,8 @@ CONST_VTBL struct ID3D12Resource1Vtbl d3d12_resource_vtbl =
|
|||
d3d12_resource_GetHeapProperties,
|
||||
/* ID3D12Resource1 methods */
|
||||
d3d12_resource_GetProtectedResourceSession,
|
||||
/* ID3D12Resource2 methods */
|
||||
d3d12_resource_GetDesc1,
|
||||
};
|
||||
|
||||
VkImageAspectFlags vk_image_aspect_flags_from_d3d12(
|
||||
|
@ -1865,7 +1888,7 @@ static HRESULT d3d12_validate_resource_flags(D3D12_RESOURCE_FLAGS flags)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC *desc,
|
||||
static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC1 *desc,
|
||||
const struct vkd3d_format *format)
|
||||
{
|
||||
if (!vkd3d_format_is_compressed(format))
|
||||
|
@ -1888,7 +1911,7 @@ static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC *de
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC *desc,
|
||||
static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC1 *desc,
|
||||
const struct vkd3d_format *format)
|
||||
{
|
||||
uint64_t estimated_size;
|
||||
|
@ -1923,7 +1946,24 @@ static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC
|
|||
return true;
|
||||
}
|
||||
|
||||
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device)
|
||||
void d3d12_resource_promote_desc(const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_DESC1 *desc1)
|
||||
{
|
||||
desc1->Dimension = desc->Dimension;
|
||||
desc1->Alignment = desc->Alignment;
|
||||
desc1->Width = desc->Width;
|
||||
desc1->Height = desc->Height;
|
||||
desc1->DepthOrArraySize = desc->DepthOrArraySize;
|
||||
desc1->MipLevels = desc->MipLevels;
|
||||
desc1->Format = desc->Format;
|
||||
desc1->SampleDesc = desc->SampleDesc;
|
||||
desc1->Layout = desc->Layout;
|
||||
desc1->Flags = desc->Flags;
|
||||
desc1->SamplerFeedbackMipRegion.Width = 0;
|
||||
desc1->SamplerFeedbackMipRegion.Height = 0;
|
||||
desc1->SamplerFeedbackMipRegion.Depth = 0;
|
||||
}
|
||||
|
||||
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device)
|
||||
{
|
||||
const struct vkd3d_format *format;
|
||||
|
||||
|
@ -1986,7 +2026,7 @@ HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d
|
|||
return d3d12_validate_resource_flags(desc->Flags);
|
||||
}
|
||||
|
||||
static HRESULT d3d12_resource_validate_heap_properties(const D3D12_RESOURCE_DESC *desc,
|
||||
static HRESULT d3d12_resource_validate_heap_properties(const D3D12_RESOURCE_DESC1 *desc,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_RESOURCE_STATES initial_state)
|
||||
{
|
||||
if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD
|
||||
|
@ -2052,7 +2092,7 @@ static HRESULT d3d12_resource_validate_heap_properties(const D3D12_RESOURCE_DESC
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT d3d12_resource_validate_create_info(const D3D12_RESOURCE_DESC *desc,
|
||||
static HRESULT d3d12_resource_validate_create_info(const D3D12_RESOURCE_DESC1 *desc,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_device *device)
|
||||
{
|
||||
|
@ -2423,7 +2463,7 @@ static HRESULT d3d12_resource_create_vk_resource(struct d3d12_resource *resource
|
|||
}
|
||||
|
||||
static HRESULT d3d12_resource_create(struct d3d12_device *device, uint32_t flags,
|
||||
const D3D12_RESOURCE_DESC *desc, const D3D12_HEAP_PROPERTIES *heap_properties,
|
||||
const D3D12_RESOURCE_DESC1 *desc, const D3D12_HEAP_PROPERTIES *heap_properties,
|
||||
D3D12_HEAP_FLAGS heap_flags, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
|
||||
{
|
||||
|
@ -2482,7 +2522,7 @@ static HRESULT d3d12_resource_create(struct d3d12_device *device, uint32_t flags
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT d3d12_resource_create_committed(struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc,
|
||||
HRESULT d3d12_resource_create_committed(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
|
||||
{
|
||||
|
@ -2597,7 +2637,7 @@ fail:
|
|||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT d3d12_resource_validate_heap(const D3D12_RESOURCE_DESC *resource_desc, struct d3d12_heap *heap)
|
||||
static HRESULT d3d12_resource_validate_heap(const D3D12_RESOURCE_DESC1 *resource_desc, struct d3d12_heap *heap)
|
||||
{
|
||||
D3D12_HEAP_FLAGS deny_flag;
|
||||
|
||||
|
@ -2624,7 +2664,7 @@ static HRESULT d3d12_resource_validate_heap(const D3D12_RESOURCE_DESC *resource_
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT d3d12_resource_create_placed(struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc,
|
||||
HRESULT d3d12_resource_create_placed(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc,
|
||||
struct d3d12_heap *heap, uint64_t heap_offset, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
|
||||
{
|
||||
|
@ -2719,7 +2759,7 @@ fail:
|
|||
}
|
||||
|
||||
HRESULT d3d12_resource_create_reserved(struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
|
||||
{
|
||||
struct d3d12_resource *object;
|
||||
|
@ -2781,7 +2821,6 @@ VKD3D_EXPORT HRESULT vkd3d_create_image_resource(ID3D12Device *device,
|
|||
object->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
|
||||
object->refcount = 1;
|
||||
object->internal_refcount = 1;
|
||||
object->desc = create_info->desc;
|
||||
object->res.vk_image = create_info->vk_image;
|
||||
object->flags = create_info->flags;
|
||||
object->flags |= VKD3D_RESOURCE_EXTERNAL;
|
||||
|
@ -2790,7 +2829,8 @@ VKD3D_EXPORT HRESULT vkd3d_create_image_resource(ID3D12Device *device,
|
|||
|
||||
memset(&object->sparse, 0, sizeof(object->sparse));
|
||||
|
||||
object->format = vkd3d_format_from_d3d12_resource_desc(d3d12_device, &create_info->desc, 0);
|
||||
d3d12_resource_promote_desc(&create_info->desc, &object->desc);
|
||||
object->format = vkd3d_format_from_d3d12_resource_desc(d3d12_device, &object->desc, 0);
|
||||
|
||||
if (FAILED(hr = vkd3d_view_map_init(&object->view_map)))
|
||||
{
|
||||
|
@ -5251,9 +5291,9 @@ static HRESULT d3d12_descriptor_heap_init_data_buffer(struct d3d12_descriptor_he
|
|||
VkDeviceSize raw_va_buffer_size = 0, offset_buffer_size = 0;
|
||||
VKD3D_UNUSED VkDeviceSize descriptor_heap_info_size = 0;
|
||||
VkMemoryPropertyFlags property_flags;
|
||||
D3D12_RESOURCE_DESC1 buffer_desc;
|
||||
VkDeviceSize buffer_size, offset;
|
||||
D3D12_HEAP_PROPERTIES heap_info;
|
||||
D3D12_RESOURCE_DESC buffer_desc;
|
||||
D3D12_HEAP_FLAGS heap_flags;
|
||||
VkResult vr;
|
||||
HRESULT hr;
|
||||
|
@ -5745,9 +5785,9 @@ HRESULT d3d12_query_heap_create(struct d3d12_device *device, const D3D12_QUERY_H
|
|||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
D3D12_HEAP_PROPERTIES heap_properties;
|
||||
D3D12_RESOURCE_DESC1 buffer_desc;
|
||||
struct d3d12_query_heap *object;
|
||||
VkQueryPoolCreateInfo pool_info;
|
||||
D3D12_RESOURCE_DESC buffer_desc;
|
||||
VkResult vr;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -5807,15 +5847,14 @@ HRESULT d3d12_query_heap_create(struct d3d12_device *device, const D3D12_QUERY_H
|
|||
memset(&heap_properties, 0, sizeof(heap_properties));
|
||||
heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
|
||||
memset(&buffer_desc, 0, sizeof(buffer_desc));
|
||||
buffer_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
buffer_desc.Alignment = 0;
|
||||
buffer_desc.Width = d3d12_query_heap_type_get_data_size(desc->Type) * desc->Count;
|
||||
buffer_desc.Height = 1;
|
||||
buffer_desc.DepthOrArraySize = 1;
|
||||
buffer_desc.MipLevels = 1;
|
||||
buffer_desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
buffer_desc.SampleDesc.Count = 1;
|
||||
buffer_desc.SampleDesc.Quality = 0;
|
||||
buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
buffer_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ static inline const struct vkd3d_vk_device_procs* d3d12_swapchain_procs(struct d
|
|||
return &swapchain->command_queue->device->vk_procs;
|
||||
}
|
||||
|
||||
static inline struct ID3D12Device7* d3d12_swapchain_device_iface(struct d3d12_swapchain* swapchain)
|
||||
static inline struct ID3D12Device8* d3d12_swapchain_device_iface(struct d3d12_swapchain* swapchain)
|
||||
{
|
||||
return &swapchain->command_queue->device->ID3D12Device_iface;
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ static HRESULT d3d12_swapchain_create_user_descriptors(struct d3d12_swapchain *s
|
|||
static HRESULT d3d12_swapchain_create_user_buffers(struct d3d12_swapchain *swapchain, VkFormat vk_format)
|
||||
{
|
||||
D3D12_HEAP_PROPERTIES heap_properties;
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
D3D12_RESOURCE_DESC1 resource_desc;
|
||||
struct d3d12_resource* object;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
@ -941,6 +941,7 @@ static HRESULT d3d12_swapchain_create_user_buffers(struct d3d12_swapchain *swapc
|
|||
heap_properties.CreationNodeMask = 1;
|
||||
heap_properties.VisibleNodeMask = 1;
|
||||
|
||||
memset(&resource_desc, 0, sizeof(resource_desc));
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
resource_desc.Alignment = 0;
|
||||
resource_desc.Width = swapchain->desc.Width;
|
||||
|
@ -1706,7 +1707,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetDevice(dxgi_swapchain_iface
|
|||
|
||||
TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
|
||||
|
||||
return ID3D12Device7_QueryInterface(d3d12_swapchain_device_iface(swapchain), iid, device);
|
||||
return ID3D12Device8_QueryInterface(d3d12_swapchain_device_iface(swapchain), iid, device);
|
||||
}
|
||||
|
||||
/* IDXGISwapChain methods */
|
||||
|
@ -2827,7 +2828,7 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IDXGIFact
|
|||
if (swapchain_desc->Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT)
|
||||
swapchain->frame_latency = 1;
|
||||
|
||||
if (FAILED(hr = ID3D12Device7_CreateFence(d3d12_swapchain_device_iface(swapchain), DXGI_MAX_SWAP_CHAIN_BUFFERS,
|
||||
if (FAILED(hr = ID3D12Device8_CreateFence(d3d12_swapchain_device_iface(swapchain), DXGI_MAX_SWAP_CHAIN_BUFFERS,
|
||||
0, &IID_ID3D12Fence, (void **)&swapchain->frame_latency_fence)))
|
||||
{
|
||||
WARN("Failed to create frame latency fence, hr %#x.\n", hr);
|
||||
|
|
|
@ -849,7 +849,7 @@ HRESULT vkd3d_view_map_init(struct vkd3d_view_map *view_map);
|
|||
void vkd3d_view_map_destroy(struct vkd3d_view_map *view_map, struct d3d12_device *device);
|
||||
|
||||
/* ID3D12Resource */
|
||||
typedef ID3D12Resource1 d3d12_resource_iface;
|
||||
typedef ID3D12Resource2 d3d12_resource_iface;
|
||||
|
||||
struct d3d12_resource
|
||||
{
|
||||
|
@ -857,7 +857,7 @@ struct d3d12_resource
|
|||
LONG refcount;
|
||||
LONG internal_refcount;
|
||||
|
||||
D3D12_RESOURCE_DESC desc;
|
||||
D3D12_RESOURCE_DESC1 desc;
|
||||
D3D12_HEAP_PROPERTIES heap_properties;
|
||||
D3D12_HEAP_FLAGS heap_flags;
|
||||
struct vkd3d_memory_allocation mem;
|
||||
|
@ -908,7 +908,8 @@ static inline VkImageLayout d3d12_resource_pick_layout(const struct d3d12_resour
|
|||
LONG64 vkd3d_allocate_cookie();
|
||||
|
||||
bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource);
|
||||
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device);
|
||||
void d3d12_resource_promote_desc(const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_DESC1 *desc1);
|
||||
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device);
|
||||
VkImageSubresource d3d12_resource_get_vk_subresource(const struct d3d12_resource *resource,
|
||||
uint32_t subresource_idx, bool all_aspects);
|
||||
VkImageAspectFlags vk_image_aspect_flags_from_d3d12(
|
||||
|
@ -918,19 +919,19 @@ VkImageSubresource vk_image_subresource_from_d3d12(
|
|||
unsigned int miplevel_count, unsigned int layer_count,
|
||||
bool all_aspects);
|
||||
|
||||
HRESULT d3d12_resource_create_committed(struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc,
|
||||
HRESULT d3d12_resource_create_committed(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
|
||||
HRESULT d3d12_resource_create_placed(struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc,
|
||||
HRESULT d3d12_resource_create_placed(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc,
|
||||
struct d3d12_heap *heap, uint64_t heap_offset, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
|
||||
HRESULT d3d12_resource_create_reserved(struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
|
||||
|
||||
static inline struct d3d12_resource *impl_from_ID3D12Resource1(ID3D12Resource1 *iface)
|
||||
static inline struct d3d12_resource *impl_from_ID3D12Resource2(ID3D12Resource2 *iface)
|
||||
{
|
||||
extern CONST_VTBL struct ID3D12Resource1Vtbl d3d12_resource_vtbl;
|
||||
extern CONST_VTBL struct ID3D12Resource2Vtbl d3d12_resource_vtbl;
|
||||
if (!iface)
|
||||
return NULL;
|
||||
assert(iface->lpVtbl == &d3d12_resource_vtbl);
|
||||
|
@ -939,7 +940,7 @@ static inline struct d3d12_resource *impl_from_ID3D12Resource1(ID3D12Resource1 *
|
|||
|
||||
static inline struct d3d12_resource *impl_from_ID3D12Resource(ID3D12Resource *iface)
|
||||
{
|
||||
return impl_from_ID3D12Resource1((ID3D12Resource1 *)iface);
|
||||
return impl_from_ID3D12Resource2((ID3D12Resource2 *)iface);
|
||||
}
|
||||
|
||||
HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device,
|
||||
|
@ -955,9 +956,9 @@ HRESULT vkd3d_allocate_image_memory(struct d3d12_device *device, VkImage vk_imag
|
|||
struct vkd3d_device_memory_allocation *allocation);
|
||||
HRESULT vkd3d_create_buffer(struct d3d12_device *device,
|
||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
|
||||
const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer);
|
||||
const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer);
|
||||
HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info);
|
||||
const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info);
|
||||
|
||||
enum vkd3d_view_type
|
||||
{
|
||||
|
@ -2778,7 +2779,7 @@ struct vkd3d_queue_family_info
|
|||
};
|
||||
|
||||
/* ID3D12Device */
|
||||
typedef ID3D12Device7 d3d12_device_iface;
|
||||
typedef ID3D12Device8 d3d12_device_iface;
|
||||
|
||||
struct vkd3d_descriptor_qa_global_info;
|
||||
struct vkd3d_descriptor_qa_heap_buffer_data;
|
||||
|
@ -2864,9 +2865,9 @@ void d3d12_device_mark_as_removed(struct d3d12_device *device, HRESULT reason,
|
|||
|
||||
static inline struct d3d12_device *impl_from_ID3D12Device(d3d12_device_iface *iface)
|
||||
{
|
||||
extern CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl;
|
||||
extern CONST_VTBL struct ID3D12Device8Vtbl d3d12_device_vtbl;
|
||||
#ifdef VKD3D_ENABLE_PROFILING
|
||||
extern CONST_VTBL struct ID3D12Device7Vtbl d3d12_device_vtbl_profiled;
|
||||
extern CONST_VTBL struct ID3D12Device8Vtbl d3d12_device_vtbl_profiled;
|
||||
#endif
|
||||
if (!iface)
|
||||
return NULL;
|
||||
|
@ -2918,23 +2919,23 @@ static inline const struct vkd3d_memory_info_domain *d3d12_device_get_memory_inf
|
|||
|
||||
static inline HRESULT d3d12_device_query_interface(struct d3d12_device *device, REFIID iid, void **object)
|
||||
{
|
||||
return ID3D12Device7_QueryInterface(&device->ID3D12Device_iface, iid, object);
|
||||
return ID3D12Device8_QueryInterface(&device->ID3D12Device_iface, iid, object);
|
||||
}
|
||||
|
||||
static inline ULONG d3d12_device_add_ref(struct d3d12_device *device)
|
||||
{
|
||||
return ID3D12Device7_AddRef(&device->ID3D12Device_iface);
|
||||
return ID3D12Device8_AddRef(&device->ID3D12Device_iface);
|
||||
}
|
||||
|
||||
static inline ULONG d3d12_device_release(struct d3d12_device *device)
|
||||
{
|
||||
return ID3D12Device7_Release(&device->ID3D12Device_iface);
|
||||
return ID3D12Device8_Release(&device->ID3D12Device_iface);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_device_get_descriptor_handle_increment_size(struct d3d12_device *device,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE descriptor_type)
|
||||
{
|
||||
return ID3D12Device7_GetDescriptorHandleIncrementSize(&device->ID3D12Device_iface, descriptor_type);
|
||||
return ID3D12Device8_GetDescriptorHandleIncrementSize(&device->ID3D12Device_iface, descriptor_type);
|
||||
}
|
||||
|
||||
static inline bool d3d12_device_use_ssbo_raw_buffer(struct d3d12_device *device)
|
||||
|
@ -3120,7 +3121,7 @@ HRESULT vkd3d_init_format_info(struct d3d12_device *device);
|
|||
void vkd3d_cleanup_format_info(struct d3d12_device *device);
|
||||
|
||||
static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc(
|
||||
const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format)
|
||||
const struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, DXGI_FORMAT view_format)
|
||||
{
|
||||
return vkd3d_get_format(device, view_format ? view_format : desc->Format,
|
||||
desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
|
||||
|
@ -3168,37 +3169,37 @@ static inline bool d3d12_box_is_empty(const D3D12_BOX *box)
|
|||
return box->right <= box->left || box->bottom <= box->top || box->back <= box->front;
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC *desc,
|
||||
static inline unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC1 *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
return max(1, desc->Width >> miplevel_idx);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC *desc,
|
||||
static inline unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC1 *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
return max(1, desc->Height >> miplevel_idx);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC *desc,
|
||||
static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC1 *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
unsigned int d = desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
|
||||
return max(1, d >> miplevel_idx);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC *desc)
|
||||
static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? desc->DepthOrArraySize : 1;
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_sub_resource_count_per_plane(const D3D12_RESOURCE_DESC *desc)
|
||||
static inline unsigned int d3d12_resource_desc_get_sub_resource_count_per_plane(const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
return d3d12_resource_desc_get_layer_count(desc) * desc->MipLevels;
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_sub_resource_count(const struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc)
|
||||
const D3D12_RESOURCE_DESC1 *desc)
|
||||
{
|
||||
const struct vkd3d_format *format = vkd3d_get_format(device, desc->Format, true);
|
||||
return d3d12_resource_desc_get_sub_resource_count_per_plane(desc) * (format ? format->plane_count : 1);
|
||||
|
|
Loading…
Reference in New Issue