libs/vkd3d: Implement d3d12_resource_Map() for committed buffers.

This commit is contained in:
Józef Kucia 2016-09-28 09:42:49 +02:00
parent fc1492766e
commit c078e79235
2 changed files with 43 additions and 2 deletions

View File

@ -441,10 +441,45 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource *iface,
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT sub_resource, static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT sub_resource,
const D3D12_RANGE *read_range, void **data) const D3D12_RANGE *read_range, void **data)
{ {
FIXME("iface %p, sub_resource %u, read_range %p, data %p stub!\n", struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
const struct vkd3d_vk_device_procs *vk_procs;
struct d3d12_device *device;
VkResult vr;
TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n",
iface, sub_resource, read_range, data); iface, sub_resource, read_range, data);
return E_NOTIMPL; FIXME("Ignoring read range %p.\n", read_range);
device = resource->device;
vk_procs = &device->vk_procs;
if (resource->desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER)
{
FIXME("Not implemented for textures.\n");
return E_NOTIMPL;
}
if (!resource->vk_memory)
{
FIXME("Not implemented for this resource type.\n");
return E_NOTIMPL;
}
if (!resource->map_count)
{
if ((vr = VK_CALL(vkMapMemory(device->vk_device, resource->vk_memory,
0, VK_WHOLE_SIZE, 0, &resource->map_data))))
{
WARN("Failed to map device memory, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
}
*data = resource->map_data;
++resource->map_count;
return S_OK;
} }
static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT sub_resource, static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT sub_resource,
@ -574,6 +609,9 @@ static HRESULT d3d12_committed_resource_init(struct d3d12_resource *resource, st
return E_INVALIDARG; return E_INVALIDARG;
} }
resource->map_count = 0;
resource->map_data = NULL;
resource->device = device; resource->device = device;
ID3D12Device_AddRef(&device->ID3D12Device_iface); ID3D12Device_AddRef(&device->ID3D12Device_iface);

View File

@ -57,6 +57,9 @@ struct d3d12_resource
} u; } u;
VkDeviceMemory vk_memory; VkDeviceMemory vk_memory;
unsigned int map_count;
void *map_data;
struct d3d12_device *device; struct d3d12_device *device;
}; };