libs/vkd3d: Add ID3D12Resource interface stub.

This commit is contained in:
Józef Kucia 2016-09-26 11:13:30 +02:00
parent 2a99c21534
commit 4175bec471
4 changed files with 272 additions and 1 deletions

View File

@ -23,6 +23,7 @@ libvkd3d_la_SOURCES = \
libs/vkd3d/command.c \
libs/vkd3d/debug.c \
libs/vkd3d/device.c \
libs/vkd3d/resource.c \
libs/vkd3d/utils.c \
libs/vkd3d/vkd3d_main.c

View File

@ -758,12 +758,21 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource(ID3D12Devi
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID riid, void **resource)
{
struct d3d12_device *device = impl_from_ID3D12Device(iface);
struct d3d12_resource *object;
HRESULT hr;
FIXME("iface %p, heap_properties %p, heap_flags %#x, desc %p, initial_state %#x, "
"optimized_clear_value %p, riid %s, resource %p stub!\n",
iface, heap_properties, heap_flags, desc, initial_state,
optimized_clear_value, debugstr_guid(riid), resource);
return E_NOTIMPL;
if (FAILED(hr = d3d12_committed_resource_create(device, heap_properties, heap_flags,
desc, initial_state, optimized_clear_value, &object)))
return hr;
return return_interface((IUnknown *)&object->ID3D12Resource_iface, &IID_ID3D12Resource,
riid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device *iface,

245
libs/vkd3d/resource.c Normal file
View File

@ -0,0 +1,245 @@
/*
* Copyright 2016 Józef Kucia for CodeWeavers
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "vkd3d_private.h"
/* ID3D12Resource */
static inline struct d3d12_resource *impl_from_ID3D12Resource(ID3D12Resource *iface)
{
return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource_iface);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource *iface,
REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_ID3D12Resource)
|| IsEqualGUID(riid, &IID_ID3D12Pageable)
|| IsEqualGUID(riid, &IID_ID3D12DeviceChild)
|| IsEqualGUID(riid, &IID_ID3D12Object)
|| IsEqualGUID(riid, &IID_IUnknown))
{
ID3D12Resource_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource *iface)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
ULONG refcount = InterlockedIncrement(&resource->refcount);
TRACE("%p increasing refcount to %u.\n", resource, refcount);
return refcount;
}
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource *iface)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
ULONG refcount = InterlockedDecrement(&resource->refcount);
TRACE("%p decreasing refcount to %u.\n", resource, refcount);
if (!refcount)
{
struct d3d12_device *device = resource->device;
vkd3d_free(resource);
ID3D12Device_Release(&device->ID3D12Device_iface);
}
return refcount;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource *iface,
REFGUID guid, UINT *data_size, void *data)
{
FIXME("iface %p, guid %s, data_size %p, data %p stub!", iface, debugstr_guid(guid), data_size, data);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource *iface,
REFGUID guid, UINT data_size, const void *data)
{
FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource *iface,
REFGUID guid, const IUnknown *data)
{
FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, const WCHAR *name)
{
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource *iface,
REFIID riid, void **device)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
return ID3D12Device_QueryInterface(&resource->device->ID3D12Device_iface, riid, device);
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT sub_resource,
const D3D12_RANGE *read_range, void **data)
{
FIXME("iface %p, sub_resource %u, read_range %p, data %p stub!\n",
iface, sub_resource, read_range, data);
return E_NOTIMPL;
}
static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT sub_resource,
const D3D12_RANGE *written_range)
{
FIXME("iface %p, sub_resource %u, written_range %p stub!\n",
iface, sub_resource, written_range);
}
static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource *iface,
D3D12_RESOURCE_DESC *resource_desc)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
*resource_desc = resource->desc;
return resource_desc;
}
static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource *iface)
{
FIXME("iface %p stub!\n", iface);
return 0;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource *iface,
UINT dst_sub_resource, const D3D12_BOX *dst_box, const void *src_data,
UINT src_row_pitch, UINT src_slice_pitch)
{
FIXME("iface %p, dst_sub_resource %u, dst_box %p, src_data %p, "
"src_row_pitch %u, src_slice_pitch %u stub!\n",
iface, dst_sub_resource, dst_box,
src_data, src_row_pitch, src_slice_pitch);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource *iface,
void *dst_data, UINT dst_row_pitch, UINT dst_slice_pitch,
UINT src_sub_resource, const D3D12_BOX *src_box)
{
FIXME("iface %p, dst_data %p, dst_row_pitch %u, dst_slice_pitch %u, "
"src_sub_resource %u, src_box %p stub!\n",
iface, dst_data, dst_row_pitch, dst_slice_pitch,
src_sub_resource, src_box);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource *iface,
D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
{
FIXME("iface %p, heap_properties %p, flags %p stub!\n",
iface, heap_properties, flags);
return E_NOTIMPL;
}
static const struct ID3D12ResourceVtbl d3d12_resource_vtbl =
{
/* IUnknown methods */
d3d12_resource_QueryInterface,
d3d12_resource_AddRef,
d3d12_resource_Release,
/* ID3D12Object methods */
d3d12_resource_GetPrivateData,
d3d12_resource_SetPrivateData,
d3d12_resource_SetPrivateDataInterface,
d3d12_resource_SetName,
/* ID3D12DeviceChild methods */
d3d12_resource_GetDevice,
/* ID3D12Resource methods */
d3d12_resource_Map,
d3d12_resource_Unmap,
d3d12_resource_GetDesc,
d3d12_resource_GetGPUVirtualAddress,
d3d12_resource_WriteToSubresource,
d3d12_resource_ReadFromSubresource,
d3d12_resource_GetHeapProperties,
};
static void d3d12_committed_resource_init(struct d3d12_resource *resource, struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value)
{
resource->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
resource->refcount = 1;
resource->desc = *desc;
resource->device = device;
ID3D12Device_AddRef(&device->ID3D12Device_iface);
}
HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
{
struct d3d12_resource *object;
if (!(object = vkd3d_malloc(sizeof(*object))))
return E_OUTOFMEMORY;
d3d12_committed_resource_init(object, device, heap_properties, heap_flags,
desc, initial_state, optimized_clear_value);
TRACE("Created committed resource %p.\n", object);
*resource = object;
return S_OK;
}

View File

@ -40,6 +40,22 @@ struct vkd3d_instance
struct vkd3d_vk_instance_procs vk_procs;
};
/* ID3D12Resource */
struct d3d12_resource
{
ID3D12Resource ID3D12Resource_iface;
ULONG refcount;
D3D12_RESOURCE_DESC desc;
struct d3d12_device *device;
};
HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
/* ID3D12CommandAllocator */
struct d3d12_command_allocator
{