radv: use the common base object type for VkDevice

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4886>
This commit is contained in:
Samuel Pitoiset 2020-04-29 10:16:32 +02:00
parent 2b535ac61b
commit 65458528fc
12 changed files with 87 additions and 90 deletions

View File

@ -4256,7 +4256,7 @@ VkResult radv_CreateCommandPool(
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_cmd_pool *pool; struct radv_cmd_pool *pool;
pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8, pool = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL) if (pool == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -4264,7 +4264,7 @@ VkResult radv_CreateCommandPool(
if (pAllocator) if (pAllocator)
pool->alloc = *pAllocator; pool->alloc = *pAllocator;
else else
pool->alloc = device->alloc; pool->alloc = device->vk.alloc;
list_inithead(&pool->cmd_buffers); list_inithead(&pool->cmd_buffers);
list_inithead(&pool->free_cmd_buffers); list_inithead(&pool->free_cmd_buffers);
@ -4298,7 +4298,7 @@ void radv_DestroyCommandPool(
radv_cmd_buffer_destroy(cmd_buffer); radv_cmd_buffer_destroy(cmd_buffer);
} }
vk_free2(&device->alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }
VkResult radv_ResetCommandPool( VkResult radv_ResetCommandPool(

View File

@ -109,7 +109,7 @@ VkResult radv_CreateDescriptorSetLayout(
size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion) + (max_binding + 1) * sizeof(uint32_t); size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion) + (max_binding + 1) * sizeof(uint32_t);
} }
set_layout = vk_zalloc2(&device->alloc, pAllocator, size, 8, set_layout = vk_zalloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set_layout) if (!set_layout)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -132,7 +132,7 @@ VkResult radv_CreateDescriptorSetLayout(
VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(pCreateInfo->pBindings, VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(pCreateInfo->pBindings,
pCreateInfo->bindingCount); pCreateInfo->bindingCount);
if (!bindings) { if (!bindings) {
vk_free2(&device->alloc, pAllocator, set_layout); vk_free2(&device->vk.alloc, pAllocator, set_layout);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
@ -295,7 +295,7 @@ void radv_DestroyDescriptorSetLayout(
if (!set_layout) if (!set_layout)
return; return;
vk_free2(&device->alloc, pAllocator, set_layout); vk_free2(&device->vk.alloc, pAllocator, set_layout);
} }
void radv_GetDescriptorSetLayoutSupport(VkDevice device, void radv_GetDescriptorSetLayoutSupport(VkDevice device,
@ -408,7 +408,7 @@ VkResult radv_CreatePipelineLayout(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8, layout = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*layout), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (layout == NULL) if (layout == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -462,7 +462,7 @@ void radv_DestroyPipelineLayout(
if (!pipeline_layout) if (!pipeline_layout)
return; return;
vk_free2(&device->alloc, pAllocator, pipeline_layout); vk_free2(&device->vk.alloc, pAllocator, pipeline_layout);
} }
#define EMPTY 1 #define EMPTY 1
@ -496,7 +496,7 @@ radv_descriptor_set_create(struct radv_device *device,
set = (struct radv_descriptor_set*)pool->host_memory_ptr; set = (struct radv_descriptor_set*)pool->host_memory_ptr;
pool->host_memory_ptr += mem_size; pool->host_memory_ptr += mem_size;
} else { } else {
set = vk_alloc2(&device->alloc, NULL, mem_size, 8, set = vk_alloc2(&device->vk.alloc, NULL, mem_size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set) if (!set)
@ -526,7 +526,7 @@ radv_descriptor_set_create(struct radv_device *device,
set->size = layout_size; set->size = layout_size;
if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) { if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) {
vk_free2(&device->alloc, NULL, set); vk_free2(&device->vk.alloc, NULL, set);
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
} }
@ -555,7 +555,7 @@ radv_descriptor_set_create(struct radv_device *device,
} }
if (pool->size - offset < layout_size) { if (pool->size - offset < layout_size) {
vk_free2(&device->alloc, NULL, set); vk_free2(&device->vk.alloc, NULL, set);
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
} }
set->bo = pool->bo; set->bo = pool->bo;
@ -612,7 +612,7 @@ radv_descriptor_set_destroy(struct radv_device *device,
} }
} }
} }
vk_free2(&device->alloc, NULL, set); vk_free2(&device->vk.alloc, NULL, set);
} }
VkResult radv_CreateDescriptorPool( VkResult radv_CreateDescriptorPool(
@ -684,7 +684,7 @@ VkResult radv_CreateDescriptorPool(
size += sizeof(struct radv_descriptor_pool_entry) * pCreateInfo->maxSets; size += sizeof(struct radv_descriptor_pool_entry) * pCreateInfo->maxSets;
} }
pool = vk_alloc2(&device->alloc, pAllocator, size, 8, pool = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!pool) if (!pool)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -732,7 +732,7 @@ void radv_DestroyDescriptorPool(
if (pool->bo) if (pool->bo)
device->ws->buffer_destroy(pool->bo); device->ws->buffer_destroy(pool->bo);
vk_free2(&device->alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }
VkResult radv_ResetDescriptorPool( VkResult radv_ResetDescriptorPool(
@ -1179,7 +1179,7 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
struct radv_descriptor_update_template *templ; struct radv_descriptor_update_template *templ;
uint32_t i; uint32_t i;
templ = vk_alloc2(&device->alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); templ = vk_alloc2(&device->vk.alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!templ) if (!templ)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -1266,7 +1266,7 @@ void radv_DestroyDescriptorUpdateTemplate(VkDevice _device,
if (!templ) if (!templ)
return; return;
vk_free2(&device->alloc, pAllocator, templ); vk_free2(&device->vk.alloc, pAllocator, templ);
} }
void radv_update_descriptor_set_with_template(struct radv_device *device, void radv_update_descriptor_set_with_template(struct radv_device *device,
@ -1362,7 +1362,7 @@ VkResult radv_CreateSamplerYcbcrConversion(VkDevice _device,
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_sampler_ycbcr_conversion *conversion = NULL; struct radv_sampler_ycbcr_conversion *conversion = NULL;
conversion = vk_zalloc2(&device->alloc, pAllocator, sizeof(*conversion), 8, conversion = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*conversion), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (conversion == NULL) if (conversion == NULL)
@ -1389,5 +1389,5 @@ void radv_DestroySamplerYcbcrConversion(VkDevice _device,
RADV_FROM_HANDLE(radv_sampler_ycbcr_conversion, ycbcr_conversion, ycbcrConversion); RADV_FROM_HANDLE(radv_sampler_ycbcr_conversion, ycbcr_conversion, ycbcrConversion);
if (ycbcr_conversion) if (ycbcr_conversion)
vk_free2(&device->alloc, pAllocator, ycbcr_conversion); vk_free2(&device->vk.alloc, pAllocator, ycbcr_conversion);
} }

View File

@ -2520,7 +2520,7 @@ static void run_secure_compile_device(struct radv_device *device, unsigned proce
struct radv_pipeline *pipeline; struct radv_pipeline *pipeline;
bool sc_read = true; bool sc_read = true;
pipeline = vk_zalloc2(&device->alloc, NULL, sizeof(*pipeline), 8, pipeline = vk_zalloc2(&device->vk.alloc, NULL, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
pipeline->device = device; pipeline->device = device;
@ -2646,7 +2646,7 @@ static void run_secure_compile_device(struct radv_device *device, unsigned proce
free((void *) pStages[i]); free((void *) pStages[i]);
} }
vk_free(&device->alloc, pipeline); vk_free(&device->vk.alloc, pipeline);
sc_type = RADV_SC_TYPE_COMPILE_PIPELINE_FINISHED; sc_type = RADV_SC_TYPE_COMPILE_PIPELINE_FINISHED;
write(fd_secure_output, &sc_type, sizeof(sc_type)); write(fd_secure_output, &sc_type, sizeof(sc_type));
@ -2761,7 +2761,7 @@ static void destroy_secure_compile_device(struct radv_device *device, unsigned p
static VkResult fork_secure_compile_idle_device(struct radv_device *device) static VkResult fork_secure_compile_idle_device(struct radv_device *device)
{ {
device->sc_state = vk_zalloc(&device->alloc, device->sc_state = vk_zalloc(&device->vk.alloc,
sizeof(struct radv_secure_compile_state), sizeof(struct radv_secure_compile_state),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@ -2788,7 +2788,7 @@ static VkResult fork_secure_compile_idle_device(struct radv_device *device)
} }
} }
device->sc_state->secure_compile_processes = vk_zalloc(&device->alloc, device->sc_state->secure_compile_processes = vk_zalloc(&device->vk.alloc,
sizeof(struct radv_secure_compile_process) * sc_threads, 8, sizeof(struct radv_secure_compile_process) * sc_threads, 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@ -2961,21 +2961,19 @@ VkResult radv_CreateDevice(
if (!device) if (!device)
return vk_error(physical_device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(physical_device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; vk_device_init(&device->vk, pCreateInfo,
&physical_device->instance->alloc, pAllocator);
device->instance = physical_device->instance; device->instance = physical_device->instance;
device->physical_device = physical_device; device->physical_device = physical_device;
device->ws = physical_device->ws; device->ws = physical_device->ws;
if (pAllocator)
device->alloc = *pAllocator;
else
device->alloc = physical_device->instance->alloc;
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i]; const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
int index = radv_get_device_extension_index(ext_name); int index = radv_get_device_extension_index(ext_name);
if (index < 0 || !physical_device->supported_extensions.extensions[index]) { if (index < 0 || !physical_device->supported_extensions.extensions[index]) {
vk_free(&device->alloc, device); vk_free(&device->vk.alloc, device);
return vk_error(physical_device->instance, VK_ERROR_EXTENSION_NOT_PRESENT); return vk_error(physical_device->instance, VK_ERROR_EXTENSION_NOT_PRESENT);
} }
@ -3013,7 +3011,7 @@ VkResult radv_CreateDevice(
assert(!global_priority || device->physical_device->rad_info.has_ctx_priority); assert(!global_priority || device->physical_device->rad_info.has_ctx_priority);
device->queues[qfi] = vk_alloc(&device->alloc, device->queues[qfi] = vk_alloc(&device->vk.alloc,
queue_create->queueCount * sizeof(struct radv_queue), 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); queue_create->queueCount * sizeof(struct radv_queue), 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!device->queues[qfi]) { if (!device->queues[qfi]) {
result = VK_ERROR_OUT_OF_HOST_MEMORY; result = VK_ERROR_OUT_OF_HOST_MEMORY;
@ -3197,10 +3195,10 @@ fail:
for (unsigned q = 0; q < device->queue_count[i]; q++) for (unsigned q = 0; q < device->queue_count[i]; q++)
radv_queue_finish(&device->queues[i][q]); radv_queue_finish(&device->queues[i][q]);
if (device->queue_count[i]) if (device->queue_count[i])
vk_free(&device->alloc, device->queues[i]); vk_free(&device->vk.alloc, device->queues[i]);
} }
vk_free(&device->alloc, device); vk_free(&device->vk.alloc, device);
return result; return result;
} }
@ -3223,7 +3221,7 @@ void radv_DestroyDevice(
for (unsigned q = 0; q < device->queue_count[i]; q++) for (unsigned q = 0; q < device->queue_count[i]; q++)
radv_queue_finish(&device->queues[i][q]); radv_queue_finish(&device->queues[i][q]);
if (device->queue_count[i]) if (device->queue_count[i])
vk_free(&device->alloc, device->queues[i]); vk_free(&device->vk.alloc, device->queues[i]);
if (device->empty_cs[i]) if (device->empty_cs[i])
device->ws->cs_destroy(device->empty_cs[i]); device->ws->cs_destroy(device->empty_cs[i]);
} }
@ -3247,10 +3245,10 @@ void radv_DestroyDevice(
if (device->sc_state) { if (device->sc_state) {
free(device->sc_state->uid); free(device->sc_state->uid);
vk_free(&device->alloc, device->sc_state->secure_compile_processes); vk_free(&device->vk.alloc, device->sc_state->secure_compile_processes);
} }
vk_free(&device->alloc, device->sc_state); vk_free(&device->vk.alloc, device->sc_state);
vk_free(&device->alloc, device); vk_free(&device->vk.alloc, device);
} }
VkResult radv_EnumerateInstanceLayerProperties( VkResult radv_EnumerateInstanceLayerProperties(
@ -5102,7 +5100,7 @@ static void radv_free_memory(struct radv_device *device,
mem->bo = NULL; mem->bo = NULL;
} }
vk_free2(&device->alloc, pAllocator, mem); vk_free2(&device->vk.alloc, pAllocator, mem);
} }
static VkResult radv_alloc_memory(struct radv_device *device, static VkResult radv_alloc_memory(struct radv_device *device,
@ -5139,7 +5137,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
return VK_SUCCESS; return VK_SUCCESS;
} }
mem = vk_zalloc2(&device->alloc, pAllocator, sizeof(*mem), 8, mem = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL) if (mem == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -5596,7 +5594,7 @@ VkResult radv_CreateFence(
VkExternalFenceHandleTypeFlags handleTypes = VkExternalFenceHandleTypeFlags handleTypes =
export ? export->handleTypes : 0; export ? export->handleTypes : 0;
struct radv_fence *fence = vk_alloc2(&device->alloc, pAllocator, struct radv_fence *fence = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*fence), 8, sizeof(*fence), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@ -5608,7 +5606,7 @@ VkResult radv_CreateFence(
if (device->always_use_syncobj || handleTypes) { if (device->always_use_syncobj || handleTypes) {
int ret = device->ws->create_syncobj(device->ws, &fence->syncobj); int ret = device->ws->create_syncobj(device->ws, &fence->syncobj);
if (ret) { if (ret) {
vk_free2(&device->alloc, pAllocator, fence); vk_free2(&device->vk.alloc, pAllocator, fence);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) { if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) {
@ -5618,7 +5616,7 @@ VkResult radv_CreateFence(
} else { } else {
fence->fence = device->ws->create_fence(); fence->fence = device->ws->create_fence();
if (!fence->fence) { if (!fence->fence) {
vk_free2(&device->alloc, pAllocator, fence); vk_free2(&device->vk.alloc, pAllocator, fence);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
fence->syncobj = 0; fence->syncobj = 0;
@ -5650,7 +5648,7 @@ void radv_DestroyFence(
device->ws->destroy_fence(fence->fence); device->ws->destroy_fence(fence->fence);
if (fence->fence_wsi) if (fence->fence_wsi)
fence->fence_wsi->destroy(fence->fence_wsi); fence->fence_wsi->destroy(fence->fence_wsi);
vk_free2(&device->alloc, pAllocator, fence); vk_free2(&device->vk.alloc, pAllocator, fence);
} }
@ -6062,7 +6060,7 @@ VkResult radv_CreateSemaphore(
uint64_t initial_value = 0; uint64_t initial_value = 0;
VkSemaphoreTypeKHR type = radv_get_semaphore_type(pCreateInfo->pNext, &initial_value); VkSemaphoreTypeKHR type = radv_get_semaphore_type(pCreateInfo->pNext, &initial_value);
struct radv_semaphore *sem = vk_alloc2(&device->alloc, pAllocator, struct radv_semaphore *sem = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*sem), 8, sizeof(*sem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sem) if (!sem)
@ -6078,14 +6076,14 @@ VkResult radv_CreateSemaphore(
assert (device->physical_device->rad_info.has_syncobj); assert (device->physical_device->rad_info.has_syncobj);
int ret = device->ws->create_syncobj(device->ws, &sem->permanent.syncobj); int ret = device->ws->create_syncobj(device->ws, &sem->permanent.syncobj);
if (ret) { if (ret) {
vk_free2(&device->alloc, pAllocator, sem); vk_free2(&device->vk.alloc, pAllocator, sem);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
sem->permanent.kind = RADV_SEMAPHORE_SYNCOBJ; sem->permanent.kind = RADV_SEMAPHORE_SYNCOBJ;
} else { } else {
sem->permanent.ws_sem = device->ws->create_sem(device->ws); sem->permanent.ws_sem = device->ws->create_sem(device->ws);
if (!sem->permanent.ws_sem) { if (!sem->permanent.ws_sem) {
vk_free2(&device->alloc, pAllocator, sem); vk_free2(&device->vk.alloc, pAllocator, sem);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
sem->permanent.kind = RADV_SEMAPHORE_WINSYS; sem->permanent.kind = RADV_SEMAPHORE_WINSYS;
@ -6107,7 +6105,7 @@ void radv_DestroySemaphore(
radv_destroy_semaphore_part(device, &sem->temporary); radv_destroy_semaphore_part(device, &sem->temporary);
radv_destroy_semaphore_part(device, &sem->permanent); radv_destroy_semaphore_part(device, &sem->permanent);
vk_free2(&device->alloc, pAllocator, sem); vk_free2(&device->vk.alloc, pAllocator, sem);
} }
VkResult VkResult
@ -6221,7 +6219,7 @@ VkResult radv_CreateEvent(
VkEvent* pEvent) VkEvent* pEvent)
{ {
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_event *event = vk_alloc2(&device->alloc, pAllocator, struct radv_event *event = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*event), 8, sizeof(*event), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@ -6233,7 +6231,7 @@ VkResult radv_CreateEvent(
RADEON_FLAG_VA_UNCACHED | RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_NO_INTERPROCESS_SHARING, RADEON_FLAG_VA_UNCACHED | RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_NO_INTERPROCESS_SHARING,
RADV_BO_PRIORITY_FENCE); RADV_BO_PRIORITY_FENCE);
if (!event->bo) { if (!event->bo) {
vk_free2(&device->alloc, pAllocator, event); vk_free2(&device->vk.alloc, pAllocator, event);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
@ -6255,7 +6253,7 @@ void radv_DestroyEvent(
if (!event) if (!event)
return; return;
device->ws->buffer_destroy(event->bo); device->ws->buffer_destroy(event->bo);
vk_free2(&device->alloc, pAllocator, event); vk_free2(&device->vk.alloc, pAllocator, event);
} }
VkResult radv_GetEventStatus( VkResult radv_GetEventStatus(
@ -6303,7 +6301,7 @@ VkResult radv_CreateBuffer(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8, buffer = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (buffer == NULL) if (buffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -6323,7 +6321,7 @@ VkResult radv_CreateBuffer(
4096, 0, RADEON_FLAG_VIRTUAL, 4096, 0, RADEON_FLAG_VIRTUAL,
RADV_BO_PRIORITY_VIRTUAL); RADV_BO_PRIORITY_VIRTUAL);
if (!buffer->bo) { if (!buffer->bo) {
vk_free2(&device->alloc, pAllocator, buffer); vk_free2(&device->vk.alloc, pAllocator, buffer);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
} }
@ -6347,7 +6345,7 @@ void radv_DestroyBuffer(
if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT)
device->ws->buffer_destroy(buffer->bo); device->ws->buffer_destroy(buffer->bo);
vk_free2(&device->alloc, pAllocator, buffer); vk_free2(&device->vk.alloc, pAllocator, buffer);
} }
VkDeviceAddress radv_GetBufferDeviceAddress( VkDeviceAddress radv_GetBufferDeviceAddress(
@ -6911,7 +6909,7 @@ VkResult radv_CreateFramebuffer(
size_t size = sizeof(*framebuffer); size_t size = sizeof(*framebuffer);
if (!imageless_create_info) if (!imageless_create_info)
size += sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount; size += sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount;
framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8, framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (framebuffer == NULL) if (framebuffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -6953,7 +6951,7 @@ void radv_DestroyFramebuffer(
if (!fb) if (!fb)
return; return;
vk_free2(&device->alloc, pAllocator, fb); vk_free2(&device->vk.alloc, pAllocator, fb);
} }
static unsigned radv_tex_wrap(VkSamplerAddressMode address_mode) static unsigned radv_tex_wrap(VkSamplerAddressMode address_mode)
@ -7169,7 +7167,7 @@ VkResult radv_CreateSampler(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
sampler = vk_alloc2(&device->alloc, pAllocator, sizeof(*sampler), 8, sampler = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*sampler), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler) if (!sampler)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -7192,7 +7190,7 @@ void radv_DestroySampler(
if (!sampler) if (!sampler)
return; return;
vk_free2(&device->alloc, pAllocator, sampler); vk_free2(&device->vk.alloc, pAllocator, sampler);
} }
/* vk_icd.h does not declare this function, so we declare it here to /* vk_icd.h does not declare this function, so we declare it here to

View File

@ -1444,7 +1444,7 @@ radv_image_create(VkDevice _device,
radv_assert(pCreateInfo->extent.height > 0); radv_assert(pCreateInfo->extent.height > 0);
radv_assert(pCreateInfo->extent.depth > 0); radv_assert(pCreateInfo->extent.depth > 0);
image = vk_zalloc2(&device->alloc, alloc, image_struct_size, 8, image = vk_zalloc2(&device->vk.alloc, alloc, image_struct_size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!image) if (!image)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -1508,7 +1508,7 @@ radv_image_create(VkDevice _device,
image->bo = device->ws->buffer_create(device->ws, image->size, image->alignment, image->bo = device->ws->buffer_create(device->ws, image->size, image->alignment,
0, RADEON_FLAG_VIRTUAL, RADV_BO_PRIORITY_VIRTUAL); 0, RADEON_FLAG_VIRTUAL, RADV_BO_PRIORITY_VIRTUAL);
if (!image->bo) { if (!image->bo) {
vk_free2(&device->alloc, alloc, image); vk_free2(&device->vk.alloc, alloc, image);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
} }
@ -1844,7 +1844,7 @@ radv_DestroyImage(VkDevice _device, VkImage _image,
if (image->owned_memory != VK_NULL_HANDLE) if (image->owned_memory != VK_NULL_HANDLE)
radv_FreeMemory(_device, image->owned_memory, pAllocator); radv_FreeMemory(_device, image->owned_memory, pAllocator);
vk_free2(&device->alloc, pAllocator, image); vk_free2(&device->vk.alloc, pAllocator, image);
} }
void radv_GetImageSubresourceLayout( void radv_GetImageSubresourceLayout(
@ -1908,7 +1908,7 @@ radv_CreateImageView(VkDevice _device,
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_image_view *view; struct radv_image_view *view;
view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8, view = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*view), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (view == NULL) if (view == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -1929,7 +1929,7 @@ radv_DestroyImageView(VkDevice _device, VkImageView _iview,
if (!iview) if (!iview)
return; return;
vk_free2(&device->alloc, pAllocator, iview); vk_free2(&device->vk.alloc, pAllocator, iview);
} }
void radv_buffer_view_init(struct radv_buffer_view *view, void radv_buffer_view_init(struct radv_buffer_view *view,
@ -1956,7 +1956,7 @@ radv_CreateBufferView(VkDevice _device,
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_buffer_view *view; struct radv_buffer_view *view;
view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8, view = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*view), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!view) if (!view)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -1978,5 +1978,5 @@ radv_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
if (!view) if (!view)
return; return;
vk_free2(&device->alloc, pAllocator, view); vk_free2(&device->vk.alloc, pAllocator, view);
} }

View File

@ -219,7 +219,7 @@ meta_alloc(void* _device, size_t size, size_t alignment,
VkSystemAllocationScope allocationScope) VkSystemAllocationScope allocationScope)
{ {
struct radv_device *device = _device; struct radv_device *device = _device;
return device->alloc.pfnAllocation(device->alloc.pUserData, size, alignment, return device->vk.alloc.pfnAllocation(device->vk.alloc.pUserData, size, alignment,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
} }
@ -228,7 +228,7 @@ meta_realloc(void* _device, void *original, size_t size, size_t alignment,
VkSystemAllocationScope allocationScope) VkSystemAllocationScope allocationScope)
{ {
struct radv_device *device = _device; struct radv_device *device = _device;
return device->alloc.pfnReallocation(device->alloc.pUserData, original, return device->vk.alloc.pfnReallocation(device->vk.alloc.pUserData, original,
size, alignment, size, alignment,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
} }
@ -237,7 +237,7 @@ static void
meta_free(void* _device, void *data) meta_free(void* _device, void *data)
{ {
struct radv_device *device = _device; struct radv_device *device = _device;
return device->alloc.pfnFree(device->alloc.pUserData, data); return device->vk.alloc.pfnFree(device->vk.alloc.pUserData, data);
} }
static bool static bool

View File

@ -319,7 +319,7 @@ VkResult radv_CreateRenderPass(
attachments_offset = size; attachments_offset = size;
size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]); size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]);
pass = vk_alloc2(&device->alloc, pAllocator, size, 8, pass = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass == NULL) if (pass == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -362,11 +362,11 @@ VkResult radv_CreateRenderPass(
if (subpass_attachment_count) { if (subpass_attachment_count) {
pass->subpass_attachments = pass->subpass_attachments =
vk_alloc2(&device->alloc, pAllocator, vk_alloc2(&device->vk.alloc, pAllocator,
subpass_attachment_count * sizeof(struct radv_subpass_attachment), 8, subpass_attachment_count * sizeof(struct radv_subpass_attachment), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass->subpass_attachments == NULL) { if (pass->subpass_attachments == NULL) {
vk_free2(&device->alloc, pAllocator, pass); vk_free2(&device->vk.alloc, pAllocator, pass);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
} else } else
@ -501,7 +501,7 @@ VkResult radv_CreateRenderPass2(
attachments_offset = size; attachments_offset = size;
size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]); size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]);
pass = vk_alloc2(&device->alloc, pAllocator, size, 8, pass = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass == NULL) if (pass == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -541,11 +541,11 @@ VkResult radv_CreateRenderPass2(
if (subpass_attachment_count) { if (subpass_attachment_count) {
pass->subpass_attachments = pass->subpass_attachments =
vk_alloc2(&device->alloc, pAllocator, vk_alloc2(&device->vk.alloc, pAllocator,
subpass_attachment_count * sizeof(struct radv_subpass_attachment), 8, subpass_attachment_count * sizeof(struct radv_subpass_attachment), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass->subpass_attachments == NULL) { if (pass->subpass_attachments == NULL) {
vk_free2(&device->alloc, pAllocator, pass); vk_free2(&device->vk.alloc, pAllocator, pass);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
} else } else
@ -681,8 +681,8 @@ void radv_DestroyRenderPass(
if (!_pass) if (!_pass)
return; return;
vk_free2(&device->alloc, pAllocator, pass->subpass_attachments); vk_free2(&device->vk.alloc, pAllocator, pass->subpass_attachments);
vk_free2(&device->alloc, pAllocator, pass); vk_free2(&device->vk.alloc, pAllocator, pass);
} }
void radv_GetRenderAreaGranularity( void radv_GetRenderAreaGranularity(

View File

@ -191,7 +191,7 @@ radv_pipeline_destroy(struct radv_device *device,
if(pipeline->cs.buf) if(pipeline->cs.buf)
free(pipeline->cs.buf); free(pipeline->cs.buf);
vk_free2(&device->alloc, allocator, pipeline); vk_free2(&device->vk.alloc, allocator, pipeline);
} }
void radv_DestroyPipeline( void radv_DestroyPipeline(
@ -5260,7 +5260,7 @@ radv_graphics_pipeline_create(
struct radv_pipeline *pipeline; struct radv_pipeline *pipeline;
VkResult result; VkResult result;
pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL) if (pipeline == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -5398,7 +5398,7 @@ static VkResult radv_compute_pipeline_create(
struct radv_pipeline *pipeline; struct radv_pipeline *pipeline;
VkResult result; VkResult result;
pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL) if (pipeline == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);

View File

@ -572,7 +572,7 @@ VkResult radv_CreatePipelineCache(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);
assert(pCreateInfo->flags == 0); assert(pCreateInfo->flags == 0);
cache = vk_alloc2(&device->alloc, pAllocator, cache = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*cache), 8, sizeof(*cache), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (cache == NULL) if (cache == NULL)
@ -581,7 +581,7 @@ VkResult radv_CreatePipelineCache(
if (pAllocator) if (pAllocator)
cache->alloc = *pAllocator; cache->alloc = *pAllocator;
else else
cache->alloc = device->alloc; cache->alloc = device->vk.alloc;
radv_pipeline_cache_init(cache, device); radv_pipeline_cache_init(cache, device);
@ -608,7 +608,7 @@ void radv_DestroyPipelineCache(
return; return;
radv_pipeline_cache_finish(cache); radv_pipeline_cache_finish(cache);
vk_free2(&device->alloc, pAllocator, cache); vk_free2(&device->vk.alloc, pAllocator, cache);
} }
VkResult radv_GetPipelineCacheData( VkResult radv_GetPipelineCacheData(

View File

@ -51,6 +51,7 @@
#include "util/xmlconfig.h" #include "util/xmlconfig.h"
#include "vk_alloc.h" #include "vk_alloc.h"
#include "vk_debug_report.h" #include "vk_debug_report.h"
#include "vk_object.h"
#include "radv_radeon_winsys.h" #include "radv_radeon_winsys.h"
#include "ac_binary.h" #include "ac_binary.h"
@ -780,9 +781,7 @@ struct radv_secure_compile_state {
}; };
struct radv_device { struct radv_device {
VK_LOADER_DATA _loader_data; struct vk_device vk;
VkAllocationCallbacks alloc;
struct radv_instance * instance; struct radv_instance * instance;
struct radeon_winsys *ws; struct radeon_winsys *ws;

View File

@ -1276,7 +1276,7 @@ VkResult radv_CreateQueryPool(
VkQueryPool* pQueryPool) VkQueryPool* pQueryPool)
{ {
RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_query_pool *pool = vk_alloc2(&device->alloc, pAllocator, struct radv_query_pool *pool = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*pool), 8, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@ -1313,7 +1313,7 @@ VkResult radv_CreateQueryPool(
RADV_BO_PRIORITY_QUERY_POOL); RADV_BO_PRIORITY_QUERY_POOL);
if (!pool->bo) { if (!pool->bo) {
vk_free2(&device->alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
@ -1321,7 +1321,7 @@ VkResult radv_CreateQueryPool(
if (!pool->ptr) { if (!pool->ptr) {
device->ws->buffer_destroy(pool->bo); device->ws->buffer_destroy(pool->bo);
vk_free2(&device->alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
@ -1341,7 +1341,7 @@ void radv_DestroyQueryPool(
return; return;
device->ws->buffer_destroy(pool->bo); device->ws->buffer_destroy(pool->bo);
vk_free2(&device->alloc, pAllocator, pool); vk_free2(&device->vk.alloc, pAllocator, pool);
} }
VkResult radv_GetQueryPoolResults( VkResult radv_GetQueryPoolResults(

View File

@ -160,7 +160,7 @@ VkResult radv_CreateShaderModule(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
assert(pCreateInfo->flags == 0); assert(pCreateInfo->flags == 0);
module = vk_alloc2(&device->alloc, pAllocator, module = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*module) + pCreateInfo->codeSize, 8, sizeof(*module) + pCreateInfo->codeSize, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (module == NULL) if (module == NULL)
@ -188,7 +188,7 @@ void radv_DestroyShaderModule(
if (!module) if (!module)
return; return;
vk_free2(&device->alloc, pAllocator, module); vk_free2(&device->vk.alloc, pAllocator, module);
} }
void void

View File

@ -186,7 +186,7 @@ VkResult radv_CreateSwapchainKHR(
if (pAllocator) if (pAllocator)
alloc = pAllocator; alloc = pAllocator;
else else
alloc = &device->alloc; alloc = &device->vk.alloc;
return wsi_common_create_swapchain(&device->physical_device->wsi_device, return wsi_common_create_swapchain(&device->physical_device->wsi_device,
radv_device_to_handle(device), radv_device_to_handle(device),
@ -206,7 +206,7 @@ void radv_DestroySwapchainKHR(
if (pAllocator) if (pAllocator)
alloc = pAllocator; alloc = pAllocator;
else else
alloc = &device->alloc; alloc = &device->vk.alloc;
wsi_common_destroy_swapchain(_device, swapchain, alloc); wsi_common_destroy_swapchain(_device, swapchain, alloc);
} }