libs/vkd3d: Check if device memory is CPU accessible in d3d12_resource_Map().

This commit is contained in:
Józef Kucia
2016-10-24 13:20:09 +02:00
parent 3161f346b6
commit e19e428ed0
3 changed files with 27 additions and 3 deletions

View File

@@ -460,11 +460,15 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n",
iface, sub_resource, read_range, data);
FIXME("Ignoring read range %p.\n", read_range);
device = resource->device;
vk_procs = &device->vk_procs;
if (!is_cpu_accessible_heap(&resource->heap_properties))
{
WARN("Resource is not CPU accessible.\n");
return E_INVALIDARG;
}
if (resource->desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER)
{
/* Textures seem to be mappable only on UMA adapters. */
@@ -478,6 +482,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
return E_NOTIMPL;
}
FIXME("Ignoring read range %p.\n", read_range);
if (!resource->map_count)
{
if ((vr = VK_CALL(vkMapMemory(device->vk_device, resource->vk_memory,
@@ -692,6 +698,8 @@ static HRESULT d3d12_committed_resource_init(struct d3d12_resource *resource, st
resource->map_count = 0;
resource->map_data = NULL;
resource->heap_properties = *heap_properties;
resource->device = device;
ID3D12Device_AddRef(&device->ID3D12Device_iface);
@@ -740,6 +748,8 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_D
object->external = true;
object->map_count = 0;
object->map_data = NULL;
memset(&object->heap_properties, 0, sizeof(object->heap_properties));
object->heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
object->device = d3d12_device;
ID3D12Device_AddRef(&d3d12_device->ID3D12Device_iface);