mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Use uint64_t for the size in vkd3d_gpu_va_allocator_allocate.
Avoids value truncation in 32-bit builds.
This commit is contained in:
parent
eae4b7b4a2
commit
2ae9f18a3a
Notes:
Alexandre Julliard
2024-02-01 23:07:59 +01:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/621
@ -71,7 +71,7 @@
|
||||
#define TAG_XNAP VKD3D_MAKE_TAG('X', 'N', 'A', 'P')
|
||||
#define TAG_XNAS VKD3D_MAKE_TAG('X', 'N', 'A', 'S')
|
||||
|
||||
static inline size_t align(size_t addr, size_t alignment)
|
||||
static inline uint64_t align(uint64_t addr, size_t alignment)
|
||||
{
|
||||
return (addr + (alignment - 1)) & ~(alignment - 1);
|
||||
}
|
||||
|
@ -2133,7 +2133,7 @@ static void d3d12_device_destroy_pipeline_cache(struct d3d12_device *device)
|
||||
#define VKD3D_VA_SLAB_COUNT (64 * 1024)
|
||||
|
||||
static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_slab(struct vkd3d_gpu_va_allocator *allocator,
|
||||
size_t aligned_size, void *ptr)
|
||||
uint64_t aligned_size, void *ptr)
|
||||
{
|
||||
struct vkd3d_gpu_va_slab *slab;
|
||||
D3D12_GPU_VIRTUAL_ADDRESS address;
|
||||
@ -2149,13 +2149,13 @@ static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_slab(struct vkd
|
||||
slab_idx = slab - allocator->slabs;
|
||||
address = VKD3D_VA_SLAB_BASE + slab_idx * VKD3D_VA_SLAB_SIZE;
|
||||
|
||||
TRACE("Allocated address %#"PRIx64", slab %u, size %zu.\n", address, slab_idx, aligned_size);
|
||||
TRACE("Allocated address %#"PRIx64", slab %u, size %"PRIu64".\n", address, slab_idx, aligned_size);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_fallback(struct vkd3d_gpu_va_allocator *allocator,
|
||||
size_t alignment, size_t aligned_size, void *ptr)
|
||||
size_t alignment, uint64_t aligned_size, void *ptr)
|
||||
{
|
||||
struct vkd3d_gpu_va_allocation *allocation;
|
||||
D3D12_GPU_VIRTUAL_ADDRESS base, ceiling;
|
||||
@ -2181,17 +2181,17 @@ static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_fallback(struct
|
||||
* only fail once we have exhausted 63 bits of address space. */
|
||||
allocator->fallback_floor = base + aligned_size;
|
||||
|
||||
TRACE("Allocated address %#"PRIx64", size %zu.\n", base, aligned_size);
|
||||
TRACE("Allocated address %#"PRIx64", size %"PRIu64".\n", base, aligned_size);
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator,
|
||||
size_t alignment, size_t size, void *ptr)
|
||||
size_t alignment, uint64_t size, void *ptr)
|
||||
{
|
||||
D3D12_GPU_VIRTUAL_ADDRESS address;
|
||||
|
||||
if (size > ~(size_t)0 - (alignment - 1))
|
||||
if (size > ~(uint64_t)0 - (alignment - 1))
|
||||
return 0;
|
||||
size = align(size, alignment);
|
||||
|
||||
@ -2227,7 +2227,7 @@ static void *vkd3d_gpu_va_allocator_dereference_slab(struct vkd3d_gpu_va_allocat
|
||||
base_offset -= slab_idx * VKD3D_VA_SLAB_SIZE;
|
||||
if (base_offset >= slab->size)
|
||||
{
|
||||
ERR("Address %#"PRIx64" is %#"PRIx64" bytes into slab %u of size %zu.\n",
|
||||
ERR("Address %#"PRIx64" is %#"PRIx64" bytes into slab %u of size %"PRIu64".\n",
|
||||
address, base_offset, slab_idx, slab->size);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -493,13 +493,13 @@ struct vkd3d_fence_worker
|
||||
struct vkd3d_gpu_va_allocation
|
||||
{
|
||||
D3D12_GPU_VIRTUAL_ADDRESS base;
|
||||
size_t size;
|
||||
uint64_t size;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
struct vkd3d_gpu_va_slab
|
||||
{
|
||||
size_t size;
|
||||
uint64_t size;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
@ -517,7 +517,7 @@ struct vkd3d_gpu_va_allocator
|
||||
};
|
||||
|
||||
D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator,
|
||||
size_t alignment, size_t size, void *ptr);
|
||||
size_t alignment, uint64_t size, void *ptr);
|
||||
void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address);
|
||||
void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user