Commit 38933c11 authored by Bas Nieuwenhuizen's avatar Bas Nieuwenhuizen
Browse files

radv: Add option to print errors even in optimized builds.



Errors are not that common of a case so we can eat a slight perf
hit in having to call a function and do a runtime check.

In turn this makes debugging random errors happening for end users
easier, because they don't have to have a debug build on hand.
Reviewed-by: default avatarTimothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: default avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
parent 729f7373
...@@ -122,7 +122,7 @@ radv_image_from_gralloc(VkDevice device_h, ...@@ -122,7 +122,7 @@ radv_image_from_gralloc(VkDevice device_h,
return result; return result;
if (gralloc_info->handle->numFds != 1) { if (gralloc_info->handle->numFds != 1) {
return vk_errorf(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR, return vk_errorf(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
"VkNativeBufferANDROID::handle::numFds is %d, " "VkNativeBufferANDROID::handle::numFds is %d, "
"expected 1", gralloc_info->handle->numFds); "expected 1", gralloc_info->handle->numFds);
} }
...@@ -233,7 +233,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID( ...@@ -233,7 +233,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID(
result = radv_GetPhysicalDeviceImageFormatProperties2(phys_dev_h, result = radv_GetPhysicalDeviceImageFormatProperties2(phys_dev_h,
&image_format_info, &image_format_props); &image_format_info, &image_format_props);
if (result != VK_SUCCESS) { if (result != VK_SUCCESS) {
return vk_errorf(result, return vk_errorf(device->instance, result,
"radv_GetPhysicalDeviceImageFormatProperties2 failed " "radv_GetPhysicalDeviceImageFormatProperties2 failed "
"inside %s", __func__); "inside %s", __func__);
} }
...@@ -252,7 +252,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID( ...@@ -252,7 +252,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID(
* gralloc swapchains. * gralloc swapchains.
*/ */
if (imageUsage != 0) { if (imageUsage != 0) {
return vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED, return vk_errorf(device->instance, VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkImageUsageFlags(0x%x) for gralloc " "unsupported VkImageUsageFlags(0x%x) for gralloc "
"swapchain", imageUsage); "swapchain", imageUsage);
} }
......
...@@ -226,7 +226,7 @@ static VkResult radv_create_cmd_buffer( ...@@ -226,7 +226,7 @@ static VkResult radv_create_cmd_buffer(
cmd_buffer = vk_zalloc(&pool->alloc, sizeof(*cmd_buffer), 8, cmd_buffer = vk_zalloc(&pool->alloc, sizeof(*cmd_buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (cmd_buffer == NULL) if (cmd_buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC; cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
cmd_buffer->device = device; cmd_buffer->device = device;
...@@ -250,7 +250,7 @@ static VkResult radv_create_cmd_buffer( ...@@ -250,7 +250,7 @@ static VkResult radv_create_cmd_buffer(
cmd_buffer->cs = device->ws->cs_create(device->ws, ring); cmd_buffer->cs = device->ws->cs_create(device->ws, ring);
if (!cmd_buffer->cs) { if (!cmd_buffer->cs) {
vk_free(&cmd_buffer->pool->alloc, cmd_buffer); vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
*pCommandBuffer = radv_cmd_buffer_to_handle(cmd_buffer); *pCommandBuffer = radv_cmd_buffer_to_handle(cmd_buffer);
...@@ -2413,7 +2413,7 @@ VkResult radv_EndCommandBuffer( ...@@ -2413,7 +2413,7 @@ VkResult radv_EndCommandBuffer(
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments); vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
if (!cmd_buffer->device->ws->cs_finalize(cmd_buffer->cs)) if (!cmd_buffer->device->ws->cs_finalize(cmd_buffer->cs))
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(cmd_buffer->device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
cmd_buffer->status = RADV_CMD_BUFFER_STATUS_EXECUTABLE; cmd_buffer->status = RADV_CMD_BUFFER_STATUS_EXECUTABLE;
...@@ -2767,7 +2767,7 @@ VkResult radv_CreateCommandPool( ...@@ -2767,7 +2767,7 @@ VkResult radv_CreateCommandPool(
pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8, pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL) if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
if (pAllocator) if (pAllocator)
pool->alloc = *pAllocator; pool->alloc = *pAllocator;
......
...@@ -46,6 +46,7 @@ enum { ...@@ -46,6 +46,7 @@ enum {
RADV_DEBUG_NO_DYNAMIC_BOUNDS = 0x10000, RADV_DEBUG_NO_DYNAMIC_BOUNDS = 0x10000,
RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000, RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000,
RADV_DEBUG_INFO = 0x40000, RADV_DEBUG_INFO = 0x40000,
RADV_DEBUG_ERRORS = 0x80000,
}; };
enum { enum {
......
...@@ -95,7 +95,7 @@ VkResult radv_CreateDescriptorSetLayout( ...@@ -95,7 +95,7 @@ VkResult radv_CreateDescriptorSetLayout(
set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8, set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set_layout) if (!set_layout)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
set_layout->flags = pCreateInfo->flags; set_layout->flags = pCreateInfo->flags;
...@@ -106,7 +106,7 @@ VkResult radv_CreateDescriptorSetLayout( ...@@ -106,7 +106,7 @@ VkResult radv_CreateDescriptorSetLayout(
pCreateInfo->bindingCount); pCreateInfo->bindingCount);
if (!bindings) { if (!bindings) {
vk_free2(&device->alloc, pAllocator, set_layout); vk_free2(&device->alloc, pAllocator, set_layout);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
set_layout->binding_count = max_binding + 1; set_layout->binding_count = max_binding + 1;
...@@ -340,7 +340,7 @@ VkResult radv_CreatePipelineLayout( ...@@ -340,7 +340,7 @@ VkResult radv_CreatePipelineLayout(
layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8, layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (layout == NULL) if (layout == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
layout->num_sets = pCreateInfo->setLayoutCount; layout->num_sets = pCreateInfo->setLayoutCount;
...@@ -412,7 +412,7 @@ radv_descriptor_set_create(struct radv_device *device, ...@@ -412,7 +412,7 @@ radv_descriptor_set_create(struct radv_device *device,
if (pool->host_memory_base) { if (pool->host_memory_base) {
if (pool->host_memory_end - pool->host_memory_ptr < mem_size) if (pool->host_memory_end - pool->host_memory_ptr < mem_size)
return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
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;
...@@ -421,7 +421,7 @@ radv_descriptor_set_create(struct radv_device *device, ...@@ -421,7 +421,7 @@ radv_descriptor_set_create(struct radv_device *device,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set) if (!set)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
memset(set, 0, mem_size); memset(set, 0, mem_size);
...@@ -437,7 +437,7 @@ radv_descriptor_set_create(struct radv_device *device, ...@@ -437,7 +437,7 @@ radv_descriptor_set_create(struct radv_device *device,
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->alloc, NULL, set);
return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
} }
/* try to allocate linearly first, so that we don't spend /* try to allocate linearly first, so that we don't spend
...@@ -466,7 +466,7 @@ radv_descriptor_set_create(struct radv_device *device, ...@@ -466,7 +466,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->alloc, NULL, set);
return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
} }
set->bo = pool->bo; set->bo = pool->bo;
set->mapped_ptr = (uint32_t*)(pool->mapped_ptr + offset); set->mapped_ptr = (uint32_t*)(pool->mapped_ptr + offset);
...@@ -478,7 +478,7 @@ radv_descriptor_set_create(struct radv_device *device, ...@@ -478,7 +478,7 @@ radv_descriptor_set_create(struct radv_device *device,
pool->entries[index].set = set; pool->entries[index].set = set;
pool->entry_count++; pool->entry_count++;
} else } else
return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR); return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
} }
if (layout->has_immutable_samplers) { if (layout->has_immutable_samplers) {
...@@ -580,7 +580,7 @@ VkResult radv_CreateDescriptorPool( ...@@ -580,7 +580,7 @@ VkResult radv_CreateDescriptorPool(
pool = vk_alloc2(&device->alloc, pAllocator, size, 8, pool = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!pool) if (!pool)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
memset(pool, 0, sizeof(*pool)); memset(pool, 0, sizeof(*pool));
...@@ -996,7 +996,7 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device, ...@@ -996,7 +996,7 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
templ = vk_alloc2(&device->alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); templ = vk_alloc2(&device->alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!templ) if (!templ)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
templ->entry_count = entry_count; templ->entry_count = entry_count;
templ->bind_point = pCreateInfo->pipelineBindPoint; templ->bind_point = pCreateInfo->pipelineBindPoint;
......
...@@ -228,12 +228,12 @@ radv_physical_device_init(struct radv_physical_device *device, ...@@ -228,12 +228,12 @@ radv_physical_device_init(struct radv_physical_device *device,
fd = open(path, O_RDWR | O_CLOEXEC); fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0) if (fd < 0)
return vk_error(VK_ERROR_INCOMPATIBLE_DRIVER); return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
version = drmGetVersion(fd); version = drmGetVersion(fd);
if (!version) { if (!version) {
close(fd); close(fd);
return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER, return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
"failed to get version %s: %m", path); "failed to get version %s: %m", path);
} }
...@@ -265,7 +265,7 @@ radv_physical_device_init(struct radv_physical_device *device, ...@@ -265,7 +265,7 @@ radv_physical_device_init(struct radv_physical_device *device,
if (radv_device_get_cache_uuid(device->rad_info.family, device->cache_uuid)) { if (radv_device_get_cache_uuid(device->rad_info.family, device->cache_uuid)) {
device->ws->destroy(device->ws); device->ws->destroy(device->ws);
result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
"cannot generate UUID"); "cannot generate UUID");
goto fail; goto fail;
} }
...@@ -392,6 +392,7 @@ static const struct debug_control radv_debug_options[] = { ...@@ -392,6 +392,7 @@ static const struct debug_control radv_debug_options[] = {
{"nodynamicbounds", RADV_DEBUG_NO_DYNAMIC_BOUNDS}, {"nodynamicbounds", RADV_DEBUG_NO_DYNAMIC_BOUNDS},
{"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER}, {"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER},
{"info", RADV_DEBUG_INFO}, {"info", RADV_DEBUG_INFO},
{"errors", RADV_DEBUG_ERRORS},
{NULL, 0} {NULL, 0}
}; };
...@@ -469,7 +470,7 @@ VkResult radv_CreateInstance( ...@@ -469,7 +470,7 @@ VkResult radv_CreateInstance(
instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8, instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!instance) if (!instance)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC; instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
...@@ -481,13 +482,19 @@ VkResult radv_CreateInstance( ...@@ -481,13 +482,19 @@ VkResult radv_CreateInstance(
instance->apiVersion = client_version; instance->apiVersion = client_version;
instance->physicalDeviceCount = -1; instance->physicalDeviceCount = -1;
instance->debug_flags = parse_debug_string(getenv("RADV_DEBUG"),
radv_debug_options);
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"),
radv_perftest_options);
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_instance_extension_index(ext_name); int index = radv_get_instance_extension_index(ext_name);
if (index < 0 || !radv_supported_instance_extensions.extensions[index]) { if (index < 0 || !radv_supported_instance_extensions.extensions[index]) {
vk_free2(&default_alloc, pAllocator, instance); vk_free2(&default_alloc, pAllocator, instance);
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); return vk_error(instance, VK_ERROR_EXTENSION_NOT_PRESENT);
} }
instance->enabled_extensions.extensions[index] = true; instance->enabled_extensions.extensions[index] = true;
...@@ -496,19 +503,13 @@ VkResult radv_CreateInstance( ...@@ -496,19 +503,13 @@ VkResult radv_CreateInstance(
result = vk_debug_report_instance_init(&instance->debug_report_callbacks); result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
if (result != VK_SUCCESS) { if (result != VK_SUCCESS) {
vk_free2(&default_alloc, pAllocator, instance); vk_free2(&default_alloc, pAllocator, instance);
return vk_error(result); return vk_error(instance, result);
} }
_mesa_locale_init(); _mesa_locale_init();
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false)); VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
instance->debug_flags = parse_debug_string(getenv("RADV_DEBUG"),
radv_debug_options);
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"),
radv_perftest_options);
radv_handle_per_app_options(instance, pCreateInfo->pApplicationInfo); radv_handle_per_app_options(instance, pCreateInfo->pApplicationInfo);
*pInstance = radv_instance_to_handle(instance); *pInstance = radv_instance_to_handle(instance);
...@@ -550,7 +551,7 @@ radv_enumerate_devices(struct radv_instance *instance) ...@@ -550,7 +551,7 @@ radv_enumerate_devices(struct radv_instance *instance)
max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices)); max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
if (max_devices < 1) if (max_devices < 1)
return vk_error(VK_ERROR_INCOMPATIBLE_DRIVER); return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
for (unsigned i = 0; i < (unsigned)max_devices; i++) { for (unsigned i = 0; i < (unsigned)max_devices; i++) {
if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER && if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER &&
...@@ -1247,7 +1248,7 @@ radv_queue_init(struct radv_device *device, struct radv_queue *queue, ...@@ -1247,7 +1248,7 @@ radv_queue_init(struct radv_device *device, struct radv_queue *queue,
queue->hw_ctx = device->ws->ctx_create(device->ws, queue->priority); queue->hw_ctx = device->ws->ctx_create(device->ws, queue->priority);
if (!queue->hw_ctx) if (!queue->hw_ctx)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS; return VK_SUCCESS;
} }
...@@ -1376,7 +1377,7 @@ VkResult radv_CreateDevice( ...@@ -1376,7 +1377,7 @@ VkResult radv_CreateDevice(
unsigned num_features = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32); unsigned num_features = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
for (uint32_t i = 0; i < num_features; i++) { for (uint32_t i = 0; i < num_features; i++) {
if (enabled_feature[i] && !supported_feature[i]) if (enabled_feature[i] && !supported_feature[i])
return vk_error(VK_ERROR_FEATURE_NOT_PRESENT); return vk_error(physical_device->instance, VK_ERROR_FEATURE_NOT_PRESENT);
} }
} }
...@@ -1384,7 +1385,7 @@ VkResult radv_CreateDevice( ...@@ -1384,7 +1385,7 @@ VkResult radv_CreateDevice(
sizeof(*device), 8, sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!device) if (!device)
return vk_error(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; device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = physical_device->instance; device->instance = physical_device->instance;
...@@ -1401,7 +1402,7 @@ VkResult radv_CreateDevice( ...@@ -1401,7 +1402,7 @@ VkResult radv_CreateDevice(
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->alloc, device);
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); return vk_error(physical_device->instance, VK_ERROR_EXTENSION_NOT_PRESENT);
} }
device->enabled_extensions.extensions[index] = true; device->enabled_extensions.extensions[index] = true;
...@@ -1613,7 +1614,7 @@ VkResult radv_EnumerateInstanceLayerProperties( ...@@ -1613,7 +1614,7 @@ VkResult radv_EnumerateInstanceLayerProperties(
} }
/* None supported at this time */ /* None supported at this time */
return vk_error(VK_ERROR_LAYER_NOT_PRESENT); return vk_error(NULL, VK_ERROR_LAYER_NOT_PRESENT);
} }
VkResult radv_EnumerateDeviceLayerProperties( VkResult radv_EnumerateDeviceLayerProperties(
...@@ -1627,7 +1628,7 @@ VkResult radv_EnumerateDeviceLayerProperties( ...@@ -1627,7 +1628,7 @@ VkResult radv_EnumerateDeviceLayerProperties(
} }
/* None supported at this time */ /* None supported at this time */
return vk_error(VK_ERROR_LAYER_NOT_PRESENT); return vk_error(NULL, VK_ERROR_LAYER_NOT_PRESENT);
} }
void radv_GetDeviceQueue2( void radv_GetDeviceQueue2(
...@@ -2281,10 +2282,11 @@ fail: ...@@ -2281,10 +2282,11 @@ fail:
queue->device->ws->buffer_destroy(gsvs_ring_bo); queue->device->ws->buffer_destroy(gsvs_ring_bo);
if (tess_rings_bo && tess_rings_bo != queue->tess_rings_bo) if (tess_rings_bo && tess_rings_bo != queue->tess_rings_bo)
queue->device->ws->buffer_destroy(tess_rings_bo); queue->device->ws->buffer_destroy(tess_rings_bo);
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(queue->device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
} }
static VkResult radv_alloc_sem_counts(struct radv_winsys_sem_counts *counts, static VkResult radv_alloc_sem_counts(struct radv_instance *instance,
struct radv_winsys_sem_counts *counts,
int num_sems, int num_sems,
const VkSemaphore *sems, const VkSemaphore *sems,
VkFence _fence, VkFence _fence,
...@@ -2313,14 +2315,14 @@ static VkResult radv_alloc_sem_counts(struct radv_winsys_sem_counts *counts, ...@@ -2313,14 +2315,14 @@ static VkResult radv_alloc_sem_counts(struct radv_winsys_sem_counts *counts,
if (counts->syncobj_count) { if (counts->syncobj_count) {
counts->syncobj = (uint32_t *)malloc(sizeof(uint32_t) * counts->syncobj_count); counts->syncobj = (uint32_t *)malloc(sizeof(uint32_t) * counts->syncobj_count);
if (!counts->syncobj) if (!counts->syncobj)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
if (counts->sem_count) { if (counts->sem_count) {
counts->sem = (struct radeon_winsys_sem **)malloc(sizeof(struct radeon_winsys_sem *) * counts->sem_count); counts->sem = (struct radeon_winsys_sem **)malloc(sizeof(struct radeon_winsys_sem *) * counts->sem_count);
if (!counts->sem) { if (!counts->sem) {
free(counts->syncobj); free(counts->syncobj);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
} }
} }
...@@ -2374,7 +2376,8 @@ static void radv_free_temp_syncobjs(struct radv_device *device, ...@@ -2374,7 +2376,8 @@ static void radv_free_temp_syncobjs(struct radv_device *device,
} }
static VkResult static VkResult
radv_alloc_sem_info(struct radv_winsys_sem_info *sem_info, radv_alloc_sem_info(struct radv_instance *instance,
struct radv_winsys_sem_info *sem_info,
int num_wait_sems, int num_wait_sems,
const VkSemaphore *wait_sems, const VkSemaphore *wait_sems,
int num_signal_sems, int num_signal_sems,
...@@ -2384,10 +2387,10 @@ radv_alloc_sem_info(struct radv_winsys_sem_info *sem_info, ...@@ -2384,10 +2387,10 @@ radv_alloc_sem_info(struct radv_winsys_sem_info *sem_info,
VkResult ret; VkResult ret;
memset(sem_info, 0, sizeof(*sem_info)); memset(sem_info, 0, sizeof(*sem_info));
ret = radv_alloc_sem_counts(&sem_info->wait, num_wait_sems, wait_sems, VK_NULL_HANDLE, true); ret = radv_alloc_sem_counts(instance, &sem_info->wait, num_wait_sems, wait_sems, VK_NULL_HANDLE, true);
if (ret) if (ret)
return ret; return ret;
ret = radv_alloc_sem_counts(&sem_info->signal, num_signal_sems, signal_sems, fence, false); ret = radv_alloc_sem_counts(instance, &sem_info->signal, num_signal_sems, signal_sems, fence, false);
if (ret) if (ret)
radv_free_sem_info(sem_info); radv_free_sem_info(sem_info);
...@@ -2405,7 +2408,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue, ...@@ -2405,7 +2408,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue,
VkResult result; VkResult result;
struct radv_winsys_sem_info sem_info; struct radv_winsys_sem_info sem_info;
result = radv_alloc_sem_info(&sem_info, 0, NULL, 0, NULL, result = radv_alloc_sem_info(queue->device->instance, &sem_info, 0, NULL, 0, NULL,
radv_fence_to_handle(fence)); radv_fence_to_handle(fence));
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
return result; return result;
...@@ -2418,7 +2421,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue, ...@@ -2418,7 +2421,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue,
/* TODO: find a better error */ /* TODO: find a better error */
if (ret) if (ret)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); return vk_error(queue->device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS; return VK_SUCCESS;
} }
...@@ -2475,7 +2478,8 @@ VkResult radv_QueueSubmit( ...@@ -2475,7 +2478,8 @@ VkResult radv_QueueSubmit(
uint32_t advance; uint32_t advance;
struct radv_winsys_sem_info sem_info; struct radv_winsys_sem_info sem_info;
result = radv_alloc_sem_info(&sem_info, result = radv_alloc_sem_info(queue->device->instance,
&sem_info,
pSubmits[i].waitSemaphoreCount, pSubmits[i].waitSemaphoreCount,
pSubmits[i].pWaitSemaphores, pSubmits[i].pWaitSemaphores,
pSubmits[i].signalSemaphoreCount, pSubmits[i].signalSemaphoreCount,
...@@ -2720,7 +2724,7 @@ static VkResult radv_alloc_memory(struct radv_device *device, ...@@ -2720,7 +2724,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8, mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL) if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
if (wsi_info && wsi_info->implicit_sync) if (wsi_info && wsi_info->implicit_sync)
flags |= RADEON_FLAG_IMPLICIT_SYNC; flags |= RADEON_FLAG_IMPLICIT_SYNC;
...@@ -2858,7 +2862,7 @@ VkResult radv_MapMemory( ...@@ -2858,7 +2862,7 @@ VkResult radv_MapMemory(
return VK_SUCCESS; return VK_SUCCESS;
} }
return vk_error(VK_ERROR_MEMORY_MAP_FAILED); return vk_error(device->instance, VK_ERROR_MEMORY_MAP_FAILED);
} }
void radv_UnmapMemory( void radv_UnmapMemory(
...@@ -3132,7 +3136,8 @@ radv_sparse_image_opaque_bind_memory(struct radv_device *device, ...@@ -3132,7 +3136,8 @@ radv_sparse_image_opaque_bind_memory(struct radv_device *device,
} }