vkd3d: Use new resource and heap implementations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
parent
8437eea2c0
commit
db1b425d2a
|
@ -5975,7 +5975,7 @@ static bool d3d12_resource_may_alias_other_resources(struct d3d12_resource *reso
|
|||
return true;
|
||||
|
||||
/* Cannot alias if the resource is allocated in a dedicated heap. */
|
||||
if (resource->flags & VKD3D_RESOURCE_DEDICATED_HEAP)
|
||||
if (resource->flags & VKD3D_RESOURCE_ALLOCATION)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -6364,7 +6364,7 @@ static void d3d12_command_list_set_push_descriptor_info(struct d3d12_command_lis
|
|||
const struct vkd3d_vulkan_info *vk_info = &list->device->vk_info;
|
||||
const struct vkd3d_shader_root_parameter *root_parameter;
|
||||
struct vkd3d_root_descriptor_info *descriptor;
|
||||
struct d3d12_resource *resource;
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
VkBufferView vk_buffer_view;
|
||||
bool null_descriptors, ssbo;
|
||||
VkDeviceSize max_range;
|
||||
|
@ -6385,10 +6385,10 @@ static void d3d12_command_list_set_push_descriptor_info(struct d3d12_command_lis
|
|||
? vk_info->device_limits.maxUniformBufferRange
|
||||
: vk_info->device_limits.maxStorageBufferRange;
|
||||
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, gpu_address);
|
||||
resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, gpu_address);
|
||||
descriptor->info.buffer.buffer = resource->vk_buffer;
|
||||
descriptor->info.buffer.offset = gpu_address - resource->gpu_address;
|
||||
descriptor->info.buffer.range = min(resource->desc.Width - descriptor->info.buffer.offset, max_range);
|
||||
descriptor->info.buffer.offset = gpu_address - resource->va;
|
||||
descriptor->info.buffer.range = min(resource->size - descriptor->info.buffer.offset, max_range);
|
||||
}
|
||||
else if (null_descriptors)
|
||||
{
|
||||
|
@ -6441,18 +6441,8 @@ static void d3d12_command_list_set_push_descriptor_info(struct d3d12_command_lis
|
|||
static void d3d12_command_list_set_root_descriptor_va(struct d3d12_command_list *list,
|
||||
struct vkd3d_root_descriptor_info *descriptor, D3D12_GPU_VIRTUAL_ADDRESS gpu_address)
|
||||
{
|
||||
const struct d3d12_resource *resource;
|
||||
VkDeviceAddress va = 0;
|
||||
|
||||
if (gpu_address)
|
||||
{
|
||||
/* We're not actually passing real VAs to the app, so we need to remap the address */
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, gpu_address);
|
||||
va = vkd3d_get_buffer_device_address(list->device, resource->vk_buffer) + gpu_address - resource->gpu_address;
|
||||
}
|
||||
|
||||
descriptor->vk_descriptor_type = VK_DESCRIPTOR_TYPE_MAX_ENUM;
|
||||
descriptor->info.va = va;
|
||||
descriptor->info.va = gpu_address;
|
||||
}
|
||||
|
||||
static void d3d12_command_list_set_root_descriptor(struct d3d12_command_list *list,
|
||||
|
@ -6546,8 +6536,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(d3d12_command_
|
|||
const D3D12_INDEX_BUFFER_VIEW *view)
|
||||
{
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
const struct vkd3d_vk_device_procs *vk_procs;
|
||||
struct d3d12_resource *resource;
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
enum VkIndexType index_type;
|
||||
|
||||
TRACE("iface %p, view %p.\n", iface, view);
|
||||
|
@ -6559,8 +6549,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(d3d12_command_
|
|||
return;
|
||||
}
|
||||
|
||||
vk_procs = &list->device->vk_procs;
|
||||
|
||||
switch (view->Format)
|
||||
{
|
||||
case DXGI_FORMAT_R16_UINT:
|
||||
|
@ -6580,9 +6568,9 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(d3d12_command_
|
|||
list->has_valid_index_buffer = view->BufferLocation != 0;
|
||||
if (list->has_valid_index_buffer)
|
||||
{
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, view->BufferLocation);
|
||||
resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, view->BufferLocation);
|
||||
VK_CALL(vkCmdBindIndexBuffer(list->vk_command_buffer, resource->vk_buffer,
|
||||
view->BufferLocation - resource->gpu_address, index_type));
|
||||
view->BufferLocation - resource->va, index_type));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6592,8 +6580,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(d3d12_comman
|
|||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
struct vkd3d_dynamic_state *dyn_state = &list->dynamic_state;
|
||||
const struct vkd3d_null_resources *null_resources;
|
||||
struct vkd3d_gpu_va_allocator *gpu_va_allocator;
|
||||
struct d3d12_resource *resource;
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
uint32_t vbo_invalidate_mask;
|
||||
bool invalidate = false;
|
||||
unsigned int i;
|
||||
|
@ -6601,7 +6588,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(d3d12_comman
|
|||
TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
|
||||
|
||||
null_resources = &list->device->null_resources;
|
||||
gpu_va_allocator = &list->device->gpu_va_allocator;
|
||||
|
||||
if (start_slot >= ARRAY_SIZE(dyn_state->vertex_strides) ||
|
||||
view_count > ARRAY_SIZE(dyn_state->vertex_strides) - start_slot)
|
||||
|
@ -6620,11 +6606,10 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(d3d12_comman
|
|||
|
||||
if (views[i].BufferLocation)
|
||||
{
|
||||
resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferLocation);
|
||||
if (resource)
|
||||
if ((resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, views[i].BufferLocation)))
|
||||
{
|
||||
buffer = resource->vk_buffer;
|
||||
offset = views[i].BufferLocation - resource->gpu_address;
|
||||
offset = views[i].BufferLocation - resource->va;
|
||||
stride = views[i].StrideInBytes;
|
||||
size = views[i].SizeInBytes;
|
||||
}
|
||||
|
@ -6667,12 +6652,11 @@ static void STDMETHODCALLTYPE d3d12_command_list_SOSetTargets(d3d12_command_list
|
|||
UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views)
|
||||
{
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
VkDeviceSize offsets[ARRAY_SIZE(list->so_counter_buffers)];
|
||||
VkDeviceSize sizes[ARRAY_SIZE(list->so_counter_buffers)];
|
||||
VkBuffer buffers[ARRAY_SIZE(list->so_counter_buffers)];
|
||||
struct vkd3d_gpu_va_allocator *gpu_va_allocator;
|
||||
const struct vkd3d_vk_device_procs *vk_procs;
|
||||
struct d3d12_resource *resource;
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
unsigned int i, first, count;
|
||||
|
||||
TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
|
||||
|
@ -6691,23 +6675,20 @@ static void STDMETHODCALLTYPE d3d12_command_list_SOSetTargets(d3d12_command_list
|
|||
return;
|
||||
}
|
||||
|
||||
vk_procs = &list->device->vk_procs;
|
||||
gpu_va_allocator = &list->device->gpu_va_allocator;
|
||||
|
||||
count = 0;
|
||||
first = start_slot;
|
||||
for (i = 0; i < view_count; ++i)
|
||||
{
|
||||
if (views[i].BufferLocation && views[i].SizeInBytes)
|
||||
{
|
||||
resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferLocation);
|
||||
resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, views[i].BufferLocation);
|
||||
buffers[count] = resource->vk_buffer;
|
||||
offsets[count] = views[i].BufferLocation - resource->gpu_address;
|
||||
offsets[count] = views[i].BufferLocation - resource->va;
|
||||
sizes[count] = views[i].SizeInBytes;
|
||||
|
||||
resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferFilledSizeLocation);
|
||||
resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, views[i].BufferFilledSizeLocation);
|
||||
list->so_counter_buffers[start_slot + i] = resource->vk_buffer;
|
||||
list->so_counter_buffer_offsets[start_slot + i] = views[i].BufferFilledSizeLocation - resource->gpu_address;
|
||||
list->so_counter_buffer_offsets[start_slot + i] = views[i].BufferFilledSizeLocation - resource->va;
|
||||
++count;
|
||||
}
|
||||
else
|
||||
|
@ -8024,7 +8005,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_WriteBufferImmediate(d3d12_comm
|
|||
VkPipelineStageFlags wait_stage_mask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
VkPipelineStageFlagBits stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||
struct d3d12_resource *resource;
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
VkDeviceSize offset;
|
||||
unsigned int i;
|
||||
|
||||
|
@ -8032,13 +8013,13 @@ static void STDMETHODCALLTYPE d3d12_command_list_WriteBufferImmediate(d3d12_comm
|
|||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
if (!(resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, parameters[i].Dest)))
|
||||
if (!(resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, parameters[i].Dest)))
|
||||
{
|
||||
d3d12_command_list_mark_as_invalid(list, "Invalid target address %p.\n", parameters[i].Dest);
|
||||
return;
|
||||
}
|
||||
|
||||
offset = parameters[i].Dest - resource->gpu_address;
|
||||
offset = parameters[i].Dest - resource->va;
|
||||
|
||||
if (modes && !vk_pipeline_stage_from_wbi_mode(modes[i], &stage))
|
||||
{
|
||||
|
@ -8552,7 +8533,7 @@ static void STDMETHODCALLTYPE d3d12_command_queue_UpdateTileMappings(ID3D12Comma
|
|||
struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
|
||||
unsigned int region_tile = 0, region_idx = 0, range_tile = 0, range_idx = 0;
|
||||
struct d3d12_resource *res = unsafe_impl_from_ID3D12Resource(resource);
|
||||
struct d3d12_heap *memory_heap = unsafe_impl_from_ID3D12Heap(heap);
|
||||
struct d3d12_heap_2 *memory_heap = unsafe_impl_from_ID3D12Heap_2(heap);
|
||||
struct vkd3d_sparse_memory_bind *bind, **bound_tiles;
|
||||
struct d3d12_sparse_info *sparse = &res->sparse;
|
||||
D3D12_TILED_RESOURCE_COORDINATE region_coord;
|
||||
|
@ -8638,8 +8619,8 @@ static void STDMETHODCALLTYPE d3d12_command_queue_UpdateTileMappings(ID3D12Comma
|
|||
}
|
||||
else
|
||||
{
|
||||
bind->vk_memory = memory_heap->vk_memory;
|
||||
bind->vk_offset = VKD3D_TILE_SIZE * range_offset;
|
||||
bind->vk_memory = memory_heap->allocation.vk_memory;
|
||||
bind->vk_offset = memory_heap->allocation.offset + VKD3D_TILE_SIZE * range_offset;
|
||||
|
||||
if (range_flag != D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE)
|
||||
bind->vk_offset += VKD3D_TILE_SIZE * range_tile;
|
||||
|
|
|
@ -3832,8 +3832,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(d3d12_device_
|
|||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
|
||||
{
|
||||
struct d3d12_heap_2 *heap_object = unsafe_impl_from_ID3D12Heap_2(heap);
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_heap *heap_object;
|
||||
struct d3d12_resource *object;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -3842,10 +3842,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(d3d12_device_
|
|||
iface, heap, heap_offset, desc, initial_state,
|
||||
optimized_clear_value, debugstr_guid(iid), resource);
|
||||
|
||||
heap_object = unsafe_impl_from_ID3D12Heap(heap);
|
||||
|
||||
if (FAILED(hr = d3d12_placed_resource_create(device, heap_object, heap_offset,
|
||||
desc, initial_state, optimized_clear_value, &object)))
|
||||
if (FAILED(hr = d3d12_resource_create_placed_2(device, desc, heap_object,
|
||||
heap_offset, initial_state, optimized_clear_value, &object)))
|
||||
return hr;
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
|
@ -4174,7 +4172,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_OpenExistingHeapFromAddress(d3d12_
|
|||
#ifdef _WIN32
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
struct d3d12_device *device;
|
||||
struct d3d12_heap *object;
|
||||
struct d3d12_heap_2 *object;
|
||||
D3D12_HEAP_DESC heap_desc;
|
||||
size_t allocation_size;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -4209,7 +4208,18 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_OpenExistingHeapFromAddress(d3d12_
|
|||
|
||||
device = impl_from_ID3D12Device(iface);
|
||||
|
||||
if (FAILED(hr = d3d12_heap_create_from_host_pointer(device, address, allocation_size, &object)))
|
||||
memset(&heap_desc, 0, sizeof(heap_desc));
|
||||
heap_desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS |
|
||||
(address ? (D3D12_HEAP_FLAG_SHARED | D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER) : 0);
|
||||
heap_desc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
|
||||
heap_desc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
|
||||
heap_desc.Properties.Type = D3D12_HEAP_TYPE_CUSTOM;
|
||||
heap_desc.Properties.CreationNodeMask = 1;
|
||||
heap_desc.Properties.VisibleNodeMask = 1;
|
||||
heap_desc.SizeInBytes = allocation_size;
|
||||
|
||||
if (FAILED(hr = d3d12_heap_create_2(device, &heap_desc, address, &object)))
|
||||
{
|
||||
*heap = NULL;
|
||||
return hr;
|
||||
|
@ -4301,8 +4311,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(d3d12_dev
|
|||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
|
||||
if (FAILED(hr = d3d12_committed_resource_create(device, heap_properties, heap_flags,
|
||||
desc, initial_state, optimized_clear_value, &object)))
|
||||
if (FAILED(hr = d3d12_resource_create_committed_2(device, desc, heap_properties,
|
||||
heap_flags, initial_state, optimized_clear_value, &object)))
|
||||
{
|
||||
*resource = NULL;
|
||||
return hr;
|
||||
|
@ -4316,7 +4326,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(d3d12_device_iface *if
|
|||
REFIID iid, void **heap)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
struct d3d12_heap *object;
|
||||
struct d3d12_heap_2 *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, desc %p, protected_session %p, iid %s, heap %p.\n",
|
||||
|
@ -4325,7 +4335,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(d3d12_device_iface *if
|
|||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
|
||||
if (FAILED(hr = d3d12_heap_create(device, desc, NULL, &object)))
|
||||
if (FAILED(hr = d3d12_heap_create_2(device, desc, NULL, &object)))
|
||||
{
|
||||
*heap = NULL;
|
||||
return hr;
|
||||
|
@ -4348,8 +4358,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1(d3d12_devi
|
|||
if (protected_session)
|
||||
FIXME("Ignoring protected session %p.\n", protected_session);
|
||||
|
||||
if (FAILED(hr = d3d12_reserved_resource_create(device,
|
||||
desc, initial_state, optimized_clear_value, &object)))
|
||||
if (FAILED(hr = d3d12_resource_create_reserved_2(device, desc,
|
||||
initial_state, optimized_clear_value, &object)))
|
||||
return hr;
|
||||
|
||||
return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
|
||||
|
|
|
@ -1978,6 +1978,8 @@ static void d3d12_resource_get_tiling(struct d3d12_device *device, struct d3d12_
|
|||
}
|
||||
}
|
||||
|
||||
static void d3d12_resource_destroy_2(struct d3d12_resource *resource, struct d3d12_device *device);
|
||||
|
||||
static void d3d12_resource_destroy(struct d3d12_resource *resource, struct d3d12_device *device)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
|
@ -2030,18 +2032,15 @@ static ULONG d3d12_resource_decref(struct d3d12_resource *resource)
|
|||
TRACE("%p decreasing refcount to %u.\n", resource, refcount);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
vkd3d_private_store_destroy(&resource->private_store);
|
||||
d3d12_resource_destroy(resource, resource->device);
|
||||
vkd3d_free(resource);
|
||||
}
|
||||
d3d12_resource_destroy_2(resource, resource->device);
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource)
|
||||
{
|
||||
return resource->heap && is_cpu_accessible_heap(&resource->heap->desc.Properties);
|
||||
return !(resource->flags & VKD3D_RESOURCE_SPARSE) &&
|
||||
is_cpu_accessible_heap(&resource->heap_properties);
|
||||
}
|
||||
|
||||
static bool d3d12_resource_validate_box(const struct d3d12_resource *resource,
|
||||
|
@ -2133,14 +2132,8 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_Release(d3d12_resource_iface *ifac
|
|||
TRACE("%p decreasing refcount to %u.\n", resource, refcount);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
struct d3d12_device *device = resource->device;
|
||||
|
||||
d3d12_resource_decref(resource);
|
||||
|
||||
d3d12_device_release(device);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
@ -2177,22 +2170,19 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(d3d12_re
|
|||
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(d3d12_resource_iface *iface, const WCHAR *name)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, name %s.\n", iface, debugstr_w(name));
|
||||
|
||||
if (resource->flags & VKD3D_RESOURCE_DEDICATED_HEAP)
|
||||
{
|
||||
if (FAILED(hr = d3d12_heap_SetName(&resource->heap->ID3D12Heap_iface, name)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (d3d12_resource_is_buffer(resource))
|
||||
/* Multiple committed and placed buffers may refer to the same VkBuffer,
|
||||
* which may cause race conditions if the app calls this concurrently */
|
||||
if (d3d12_resource_is_buffer(resource) && (resource->flags & VKD3D_RESOURCE_SPARSE))
|
||||
return vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->vk_buffer,
|
||||
VK_OBJECT_TYPE_BUFFER, name);
|
||||
else
|
||||
else if (d3d12_resource_is_texture(resource))
|
||||
return vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->vk_image,
|
||||
VK_OBJECT_TYPE_IMAGE, name);
|
||||
else
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(d3d12_resource_iface *iface, REFIID iid, void **device)
|
||||
|
@ -2208,17 +2198,16 @@ static bool d3d12_resource_get_mapped_memory_range(struct d3d12_resource *resour
|
|||
UINT subresource, const D3D12_RANGE *range, VkMappedMemoryRange *vk_mapped_range)
|
||||
{
|
||||
const struct d3d12_device *device = resource->device;
|
||||
const struct d3d12_heap *heap = resource->heap;
|
||||
|
||||
if (range && range->End <= range->Begin)
|
||||
return false;
|
||||
|
||||
if (device->memory_properties.memoryTypes[heap->vk_memory_type].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
|
||||
if (device->memory_properties.memoryTypes[resource->mem.vk_memory_type].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
|
||||
return false;
|
||||
|
||||
vk_mapped_range->sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||
vk_mapped_range->pNext = NULL;
|
||||
vk_mapped_range->memory = heap->vk_memory;
|
||||
vk_mapped_range->memory = resource->mem.vk_memory;
|
||||
|
||||
if (resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
|
@ -2266,8 +2255,8 @@ static void d3d12_resource_flush_range(struct d3d12_resource *resource,
|
|||
|
||||
static void d3d12_resource_get_map_ptr(struct d3d12_resource *resource, void **data)
|
||||
{
|
||||
assert(resource->heap->map_ptr);
|
||||
*data = (BYTE *)resource->heap->map_ptr + resource->heap_offset;
|
||||
assert(resource->mem.cpu_address);
|
||||
*data = resource->mem.cpu_address;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(d3d12_resource_iface *iface, UINT sub_resource,
|
||||
|
@ -2299,7 +2288,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(d3d12_resource_iface *iface,
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!resource->heap)
|
||||
if (resource->flags & VKD3D_RESOURCE_SPARSE)
|
||||
{
|
||||
FIXME("Not implemented for this resource type.\n");
|
||||
return E_NOTIMPL;
|
||||
|
@ -2516,7 +2505,6 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(d3d12_resource
|
|||
D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
|
||||
struct d3d12_heap *heap;
|
||||
|
||||
TRACE("iface %p, heap_properties %p, flags %p.\n",
|
||||
iface, heap_properties, flags);
|
||||
|
@ -2535,16 +2523,16 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(d3d12_resource
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
if (!(heap = resource->heap))
|
||||
if (resource->flags & VKD3D_RESOURCE_SPARSE)
|
||||
{
|
||||
WARN("Cannot get heap properties for reserved resources.\n");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (heap_properties)
|
||||
*heap_properties = heap->desc.Properties;
|
||||
*heap_properties = resource->heap_properties;
|
||||
if (flags)
|
||||
*flags = heap->desc.Flags;
|
||||
*flags = resource->mem.heap_flags;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -4390,8 +4378,8 @@ void d3d12_desc_create_cbv(struct d3d12_desc *descriptor,
|
|||
struct d3d12_device *device, const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
const struct vkd3d_unique_resource *resource = NULL;
|
||||
union vkd3d_descriptor_info descriptor_info;
|
||||
struct d3d12_resource *resource = NULL;
|
||||
VkDescriptorType vk_descriptor_type;
|
||||
VkWriteDescriptorSet vk_write;
|
||||
uint32_t info_index;
|
||||
|
@ -4410,10 +4398,10 @@ void d3d12_desc_create_cbv(struct d3d12_desc *descriptor,
|
|||
|
||||
if (desc->BufferLocation)
|
||||
{
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, desc->BufferLocation);
|
||||
resource = vkd3d_va_map_deref(&device->memory_allocator.va_map, desc->BufferLocation);
|
||||
descriptor_info.buffer.buffer = resource->vk_buffer;
|
||||
descriptor_info.buffer.offset = desc->BufferLocation - resource->gpu_address;
|
||||
descriptor_info.buffer.range = min(desc->SizeInBytes, resource->desc.Width - descriptor_info.buffer.offset);
|
||||
descriptor_info.buffer.offset = desc->BufferLocation - resource->va;
|
||||
descriptor_info.buffer.range = min(desc->SizeInBytes, resource->size - descriptor_info.buffer.offset);
|
||||
}
|
||||
else if (device->device_info.robustness2_features.nullDescriptor)
|
||||
{
|
||||
|
@ -5232,17 +5220,17 @@ void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *d
|
|||
bool vkd3d_create_raw_buffer_view(struct d3d12_device *device,
|
||||
D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view)
|
||||
{
|
||||
const struct vkd3d_unique_resource *resource;
|
||||
const struct vkd3d_format *format;
|
||||
struct d3d12_resource *resource;
|
||||
uint64_t range;
|
||||
uint64_t offset;
|
||||
|
||||
format = vkd3d_get_format(device, DXGI_FORMAT_R32_UINT, false);
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, gpu_address);
|
||||
assert(d3d12_resource_is_buffer(resource));
|
||||
resource = vkd3d_va_map_deref(&device->memory_allocator.va_map, gpu_address);
|
||||
assert(resource && resource->va && resource->size);
|
||||
|
||||
offset = gpu_address - resource->gpu_address;
|
||||
range = min(resource->desc.Width - offset, device->vk_info.device_limits.maxStorageBufferRange);
|
||||
offset = gpu_address - resource->va;
|
||||
range = min(resource->size - offset, device->vk_info.device_limits.maxStorageBufferRange);
|
||||
|
||||
return vkd3d_create_vk_buffer_view(device, resource->vk_buffer, format,
|
||||
offset, range, vk_buffer_view);
|
||||
|
|
|
@ -944,8 +944,8 @@ static HRESULT d3d12_swapchain_create_user_buffers(struct d3d12_swapchain *swapc
|
|||
|
||||
for (i = 0; i < swapchain->desc.BufferCount; i++)
|
||||
{
|
||||
if (FAILED(hr = d3d12_committed_resource_create(d3d12_swapchain_device(swapchain),
|
||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
|
||||
if (FAILED(hr = d3d12_resource_create_committed_2(d3d12_swapchain_device(swapchain),
|
||||
&resource_desc, &heap_properties, D3D12_HEAP_FLAG_NONE,
|
||||
D3D12_RESOURCE_STATE_PRESENT, NULL, &object)))
|
||||
{
|
||||
ERR("Failed to create image for swapchain buffer");
|
||||
|
|
Loading…
Reference in New Issue