vkd3d: Add support for the ID3D12Resource1 interface.

This commit is contained in:
Henri Verbeet 2023-08-07 11:57:10 +00:00 committed by Alexandre Julliard
parent 557b32a504
commit 2252f012ea
Notes: Alexandre Julliard 2023-11-10 00:09:14 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/456
3 changed files with 60 additions and 44 deletions

View File

@ -3639,7 +3639,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource(ID3D12Devi
return hr;
}
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device5 *iface,
@ -3682,7 +3682,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device5
desc, initial_state, optimized_clear_value, &object)))
return hr;
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Device5 *iface,
@ -3700,7 +3700,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Devic
desc, initial_state, optimized_clear_value, &object)))
return hr;
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateSharedHandle(ID3D12Device5 *iface,
@ -4035,7 +4035,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(ID3D12Dev
return hr;
}
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(ID3D12Device5 *iface,

View File

@ -1258,12 +1258,13 @@ static bool d3d12_resource_init_tiles(struct d3d12_resource *resource, struct d3
}
/* ID3D12Resource */
static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource1 *iface,
REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_ID3D12Resource)
if (IsEqualGUID(riid, &IID_ID3D12Resource1)
|| IsEqualGUID(riid, &IID_ID3D12Resource)
|| IsEqualGUID(riid, &IID_ID3D12Pageable)
|| IsEqualGUID(riid, &IID_ID3D12DeviceChild)
|| IsEqualGUID(riid, &IID_ID3D12Object)
@ -1280,9 +1281,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource *i
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource *iface)
static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource1 *iface)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
ULONG refcount = InterlockedIncrement(&resource->refcount);
TRACE("%p increasing refcount to %u.\n", resource, refcount);
@ -1298,9 +1299,9 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource *iface)
return refcount;
}
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource *iface)
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource1 *iface)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
ULONG refcount = InterlockedDecrement(&resource->refcount);
TRACE("%p decreasing refcount to %u.\n", resource, refcount);
@ -1317,39 +1318,39 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource *iface)
return refcount;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource1 *iface,
REFGUID guid, UINT *data_size, void *data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_get_private_data(&resource->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource1 *iface,
REFGUID guid, UINT data_size, const void *data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_set_private_data(&resource->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource1 *iface,
REFGUID guid, const IUnknown *data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return vkd3d_set_private_data_interface(&resource->private_store, guid, data);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, const WCHAR *name)
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource1 *iface, const WCHAR *name)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
HRESULT hr;
TRACE("iface %p, name %s.\n", iface, debugstr_w(name, resource->device->wchar_size));
@ -1368,9 +1369,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, c
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, name);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource *iface, REFIID iid, void **device)
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource1 *iface, REFIID iid, void **device)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
@ -1421,10 +1422,10 @@ static void d3d12_resource_flush(struct d3d12_resource *resource, uint64_t offse
ERR("Failed to flush memory, vr %d.\n", vr);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT sub_resource,
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource1 *iface, UINT sub_resource,
const D3D12_RANGE *read_range, void **data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
unsigned int sub_resource_count;
TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n",
@ -1470,10 +1471,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
return S_OK;
}
static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT sub_resource,
static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource1 *iface, UINT sub_resource,
const D3D12_RANGE *written_range)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
unsigned int sub_resource_count;
TRACE("iface %p, sub_resource %u, written_range %p.\n",
@ -1492,10 +1493,10 @@ static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT s
d3d12_resource_flush(resource, written_range->Begin, written_range->End - written_range->Begin);
}
static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource *iface,
static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource1 *iface,
D3D12_RESOURCE_DESC *resource_desc)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
@ -1503,20 +1504,20 @@ static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Reso
return resource_desc;
}
static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource *iface)
static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource1 *iface)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
TRACE("iface %p.\n", iface);
return resource->gpu_address;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource1 *iface,
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_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
const struct vkd3d_vk_device_procs *vk_procs;
VkImageSubresource vk_sub_resource;
const struct vkd3d_format *format;
@ -1597,11 +1598,11 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resourc
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource1 *iface,
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_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
const struct vkd3d_vk_device_procs *vk_procs;
VkImageSubresource vk_sub_resource;
const struct vkd3d_format *format;
@ -1682,10 +1683,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resour
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource1 *iface,
D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface);
struct d3d12_heap *heap;
TRACE("iface %p, heap_properties %p, flags %p.\n",
@ -1719,7 +1720,15 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource
return S_OK;
}
static const struct ID3D12ResourceVtbl d3d12_resource_vtbl =
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource1 *iface,
REFIID iid, void **session)
{
FIXME("iface %p, iid %s, session %p stub!\n", iface, debugstr_guid(iid), session);
return E_NOTIMPL;
}
static const struct ID3D12Resource1Vtbl d3d12_resource_vtbl =
{
/* IUnknown methods */
d3d12_resource_QueryInterface,
@ -1740,13 +1749,15 @@ static const struct ID3D12ResourceVtbl d3d12_resource_vtbl =
d3d12_resource_WriteToSubresource,
d3d12_resource_ReadFromSubresource,
d3d12_resource_GetHeapProperties,
/* ID3D12Resource1 methods */
d3d12_resource_GetProtectedResourceSession,
};
struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d12_resource_vtbl);
assert(iface->lpVtbl == (ID3D12ResourceVtbl *)&d3d12_resource_vtbl);
return impl_from_ID3D12Resource(iface);
}
@ -1944,7 +1955,7 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12
{
HRESULT hr;
resource->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
resource->ID3D12Resource1_iface.lpVtbl = &d3d12_resource_vtbl;
resource->refcount = 1;
resource->internal_refcount = 1;
@ -2097,7 +2108,7 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
if (FAILED(hr = vkd3d_allocate_resource_memory(device, object, heap_properties, heap_flags)))
{
d3d12_resource_Release(&object->ID3D12Resource_iface);
d3d12_resource_Release(&object->ID3D12Resource1_iface);
return hr;
}
@ -2190,7 +2201,7 @@ HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_h
if (FAILED(hr = vkd3d_bind_heap_memory(device, object, heap, heap_offset)))
{
d3d12_resource_Release(&object->ID3D12Resource_iface);
d3d12_resource_Release(&object->ID3D12Resource1_iface);
return hr;
}
@ -2214,7 +2225,7 @@ HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
if (!d3d12_resource_init_tiles(object, device))
{
d3d12_resource_Release(&object->ID3D12Resource_iface);
d3d12_resource_Release(&object->ID3D12Resource1_iface);
return E_OUTOFMEMORY;
}
@ -2249,7 +2260,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
memset(object, 0, sizeof(*object));
object->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
object->ID3D12Resource1_iface.lpVtbl = &d3d12_resource_vtbl;
object->refcount = 1;
object->internal_refcount = 1;
object->desc = create_info->desc;
@ -2273,7 +2284,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
TRACE("Created resource %p.\n", object);
*resource = &object->ID3D12Resource_iface;
*resource = (ID3D12Resource *)&object->ID3D12Resource1_iface;
return S_OK;
}

View File

@ -718,7 +718,7 @@ struct d3d12_resource_tile_info
/* ID3D12Resource */
struct d3d12_resource
{
ID3D12Resource ID3D12Resource_iface;
ID3D12Resource1 ID3D12Resource1_iface;
LONG refcount;
LONG internal_refcount;
@ -750,7 +750,12 @@ struct d3d12_resource
static inline struct d3d12_resource *impl_from_ID3D12Resource(ID3D12Resource *iface)
{
return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource_iface);
return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource1_iface);
}
static inline struct d3d12_resource *impl_from_ID3D12Resource1(ID3D12Resource1 *iface)
{
return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource1_iface);
}
static inline bool d3d12_resource_is_buffer(const struct d3d12_resource *resource)