vkd3d: Align d3d12_desc to 64 bytes.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
Hans-Kristian Arntzen 2021-02-22 11:11:42 +01:00
parent 3442d44649
commit 1586a75ada
2 changed files with 13 additions and 5 deletions

View File

@ -4625,7 +4625,7 @@ static ULONG STDMETHODCALLTYPE d3d12_descriptor_heap_Release(ID3D12DescriptorHea
d3d12_descriptor_heap_cleanup(heap);
vkd3d_private_store_destroy(&heap->private_store);
vkd3d_free(heap);
vkd3d_free_aligned(heap);
d3d12_device_release(device);
}
@ -5172,8 +5172,8 @@ HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device,
return E_OUTOFMEMORY;
}
if (!(object = vkd3d_malloc(offsetof(struct d3d12_descriptor_heap,
descriptors[descriptor_size * desc->NumDescriptors]))))
if (!(object = vkd3d_malloc_aligned(offsetof(struct d3d12_descriptor_heap,
descriptors[descriptor_size * desc->NumDescriptors]), D3D12_DESC_ALIGNMENT)))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d12_descriptor_heap_init(object, device, desc)))

View File

@ -837,9 +837,16 @@ struct vkd3d_descriptor_data
uint32_t flags;
};
#define D3D12_DESC_ALIGNMENT 64
struct d3d12_desc
{
struct vkd3d_descriptor_data metadata;
/* Align d3d12_desc to 64 bytes for two reasons.
* - We need a POT size when reporting GPU addresses.
* In DXR, we will need to handle app-placed VAs in a local root signature,
* and the fastest approach we can use is uint(VA) >> 6 to derive an index.
* - Can avoid false sharing on cache lines if multiple threads
* modify adjacent descriptors somehow. */
DECLSPEC_ALIGN(D3D12_DESC_ALIGNMENT) struct vkd3d_descriptor_data metadata;
struct d3d12_descriptor_heap *heap;
uint32_t heap_offset;
union
@ -848,6 +855,7 @@ struct d3d12_desc
struct vkd3d_view *view;
} info;
};
STATIC_ASSERT(sizeof(struct d3d12_desc) == 64);
static inline struct d3d12_desc *d3d12_desc_from_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
{
@ -937,7 +945,7 @@ struct d3d12_descriptor_heap
struct vkd3d_private_store private_store;
BYTE descriptors[];
DECLSPEC_ALIGN(D3D12_DESC_ALIGNMENT) BYTE descriptors[];
};
HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device,