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

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,
return result;
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, "
"expected 1", gralloc_info->handle->numFds);
}
......@@ -233,7 +233,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID(
result = radv_GetPhysicalDeviceImageFormatProperties2(phys_dev_h,
&image_format_info, &image_format_props);
if (result != VK_SUCCESS) {
return vk_errorf(result,
return vk_errorf(device->instance, result,
"radv_GetPhysicalDeviceImageFormatProperties2 failed "
"inside %s", __func__);
}
......@@ -252,7 +252,7 @@ VkResult radv_GetSwapchainGrallocUsageANDROID(
* gralloc swapchains.
*/
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 "
"swapchain", imageUsage);
}
......
......@@ -226,7 +226,7 @@ static VkResult radv_create_cmd_buffer(
cmd_buffer = vk_zalloc(&pool->alloc, sizeof(*cmd_buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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->device = device;
......@@ -250,7 +250,7 @@ static VkResult radv_create_cmd_buffer(
cmd_buffer->cs = device->ws->cs_create(device->ws, ring);
if (!cmd_buffer->cs) {
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);
......@@ -2413,7 +2413,7 @@ VkResult radv_EndCommandBuffer(
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
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;
......@@ -2767,7 +2767,7 @@ VkResult radv_CreateCommandPool(
pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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)
pool->alloc = *pAllocator;
......
......@@ -46,6 +46,7 @@ enum {
RADV_DEBUG_NO_DYNAMIC_BOUNDS = 0x10000,
RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000,
RADV_DEBUG_INFO = 0x40000,
RADV_DEBUG_ERRORS = 0x80000,
};
enum {
......
......@@ -95,7 +95,7 @@ VkResult radv_CreateDescriptorSetLayout(
set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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;
......@@ -106,7 +106,7 @@ VkResult radv_CreateDescriptorSetLayout(
pCreateInfo->bindingCount);
if (!bindings) {
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;
......@@ -340,7 +340,7 @@ VkResult radv_CreatePipelineLayout(
layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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;
......@@ -412,7 +412,7 @@ radv_descriptor_set_create(struct radv_device *device,
if (pool->host_memory_base) {
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;
pool->host_memory_ptr += mem_size;
......@@ -421,7 +421,7 @@ radv_descriptor_set_create(struct radv_device *device,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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);
......@@ -437,7 +437,7 @@ radv_descriptor_set_create(struct radv_device *device,
if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) {
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
......@@ -466,7 +466,7 @@ radv_descriptor_set_create(struct radv_device *device,
if (pool->size - offset < layout_size) {
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->mapped_ptr = (uint32_t*)(pool->mapped_ptr + offset);
......@@ -478,7 +478,7 @@ radv_descriptor_set_create(struct radv_device *device,
pool->entries[index].set = set;
pool->entry_count++;
} 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) {
......@@ -580,7 +580,7 @@ VkResult radv_CreateDescriptorPool(
pool = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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));
......@@ -996,7 +996,7 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
templ = vk_alloc2(&device->alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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->bind_point = pCreateInfo->pipelineBindPoint;
......
......@@ -228,12 +228,12 @@ radv_physical_device_init(struct radv_physical_device *device,
fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0)
return vk_error(VK_ERROR_INCOMPATIBLE_DRIVER);
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
version = drmGetVersion(fd);
if (!version) {
close(fd);
return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
"failed to get version %s: %m", path);
}
......@@ -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)) {
device->ws->destroy(device->ws);
result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
"cannot generate UUID");
goto fail;
}
......@@ -392,6 +392,7 @@ static const struct debug_control radv_debug_options[] = {
{"nodynamicbounds", RADV_DEBUG_NO_DYNAMIC_BOUNDS},
{"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER},
{"info", RADV_DEBUG_INFO},
{"errors", RADV_DEBUG_ERRORS},
{NULL, 0}
};
......@@ -469,7 +470,7 @@ VkResult radv_CreateInstance(
instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_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;
......@@ -481,13 +482,19 @@ VkResult radv_CreateInstance(
instance->apiVersion = client_version;
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++) {
const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
int index = radv_get_instance_extension_index(ext_name);
if (index < 0 || !radv_supported_instance_extensions.extensions[index]) {
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;
......@@ -496,19 +503,13 @@ VkResult radv_CreateInstance(
result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
if (result != VK_SUCCESS) {
vk_free2(&default_alloc, pAllocator, instance);
return vk_error(result);
return vk_error(instance, result);
}
_mesa_locale_init();
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);
*pInstance = radv_instance_to_handle(instance);
......@@ -550,7 +551,7 @@ radv_enumerate_devices(struct radv_instance *instance)
max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
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++) {
if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER &&
......@@ -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);
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;
}
......@@ -1376,7 +1377,7 @@ VkResult radv_CreateDevice(
unsigned num_features = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
for (uint32_t i = 0; i < num_features; 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(
sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_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->instance = physical_device->instance;
......@@ -1401,7 +1402,7 @@ VkResult radv_CreateDevice(
int index = radv_get_device_extension_index(ext_name);
if (index < 0 || !physical_device->supported_extensions.extensions[index]) {
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;
......@@ -1613,7 +1614,7 @@ VkResult radv_EnumerateInstanceLayerProperties(
}
/* 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(
......@@ -1627,7 +1628,7 @@ VkResult radv_EnumerateDeviceLayerProperties(
}
/* 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(
......@@ -2281,10 +2282,11 @@ fail:
queue->device->ws->buffer_destroy(gsvs_ring_bo);
if (tess_rings_bo && tess_rings_bo != queue->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,
const VkSemaphore *sems,
VkFence _fence,
......@@ -2313,14 +2315,14 @@ static VkResult radv_alloc_sem_counts(struct radv_winsys_sem_counts *counts,
if (counts->syncobj_count) {
counts->syncobj = (uint32_t *)malloc(sizeof(uint32_t) * counts->syncobj_count);
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) {
counts->sem = (struct radeon_winsys_sem **)malloc(sizeof(struct radeon_winsys_sem *) * counts->sem_count);
if (!counts->sem) {
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,
}
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,
const VkSemaphore *wait_sems,
int num_signal_sems,
......@@ -2384,10 +2387,10 @@ radv_alloc_sem_info(struct radv_winsys_sem_info *sem_info,
VkResult ret;
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)
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)
radv_free_sem_info(sem_info);
......@@ -2405,7 +2408,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue,
VkResult result;
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));
if (result != VK_SUCCESS)
return result;
......@@ -2418,7 +2421,7 @@ static VkResult radv_signal_fence(struct radv_queue *queue,
/* TODO: find a better error */
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;
}
......@@ -2475,7 +2478,8 @@ VkResult radv_QueueSubmit(
uint32_t advance;
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].pWaitSemaphores,
pSubmits[i].signalSemaphoreCount,
......@@ -2720,7 +2724,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
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)
flags |= RADEON_FLAG_IMPLICIT_SYNC;
......@@ -2858,7 +2862,7 @@ VkResult radv_MapMemory(
return VK_SUCCESS;
}
return vk_error(VK_ERROR_MEMORY_MAP_FAILED);
return vk_error(device->instance, VK_ERROR_MEMORY_MAP_FAILED);
}
void radv_UnmapMemory(
......@@ -3132,7 +3136,8 @@ radv_sparse_image_opaque_bind_memory(struct radv_device *device,
}
VkResult result;
result = radv_alloc_sem_info(&sem_info,
result = radv_alloc_sem_info(queue->device->instance,
&sem_info,
pBindInfo[i].waitSemaphoreCount,
pBindInfo[i].pWaitSemaphores,
pBindInfo[i].signalSemaphoreCount,
......@@ -3183,7 +3188,7 @@ VkResult radv_CreateFence(
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!fence)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
fence->submitted = false;
fence->signalled = !!(pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT);
......@@ -3192,7 +3197,7 @@ VkResult radv_CreateFence(
int ret = device->ws->create_syncobj(device->ws, &fence->syncobj);
if (ret) {
vk_free2(&device->alloc, pAllocator, fence);
return vk_error(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) {
device->ws->signal_syncobj(device->ws, fence->syncobj);
......@@ -3202,7 +3207,7 @@ VkResult radv_CreateFence(
fence->fence = device->ws->create_fence();
if (!fence->fence) {
vk_free2(&device->alloc, pAllocator, fence);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
fence->syncobj = 0;
}
......@@ -3273,7 +3278,7 @@ VkResult radv_WaitForFences(
if (device->always_use_syncobj) {
uint32_t *handles = malloc(sizeof(uint32_t) * fenceCount);
if (!handles)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
for (uint32_t i = 0; i < fenceCount; ++i) {
RADV_FROM_HANDLE(radv_fence, fence, pFences[i]);
......@@ -3292,7 +3297,7 @@ VkResult radv_WaitForFences(
uint32_t wait_count = 0;
struct radeon_winsys_fence **fences = malloc(sizeof(struct radeon_winsys_fence *) * fenceCount);
if (!fences)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
for (uint32_t i = 0; i < fenceCount; ++i) {
RADV_FROM_HANDLE(radv_fence, fence, pFences[i]);
......@@ -3431,7 +3436,7 @@ VkResult radv_CreateSemaphore(
sizeof(*sem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sem)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
sem->temp_syncobj = 0;
/* create a syncobject if we are going to export this semaphore */
......@@ -3440,14 +3445,14 @@ VkResult radv_CreateSemaphore(
int ret = device->ws->create_syncobj(device->ws, &sem->syncobj);
if (ret) {
vk_free2(&device->alloc, pAllocator, sem);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
sem->sem = NULL;
} else {
sem->sem = device->ws->create_sem(device->ws);
if (!sem->sem) {
vk_free2(&device->alloc, pAllocator, sem);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
sem->syncobj = 0;
}
......@@ -3485,14 +3490,14 @@ VkResult radv_CreateEvent(
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!event)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
event->bo = device->ws->buffer_create(device->ws, 8, 8,
RADEON_DOMAIN_GTT,
RADEON_FLAG_VA_UNCACHED | RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_NO_INTERPROCESS_SHARING);
if (!event->bo) {
vk_free2(&device->alloc, pAllocator, event);
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
event->map = (uint64_t*)device->ws->buffer_map(event->bo);
......@@ -3561,7 +3566,7 @@ VkResult radv_CreateBuffer(
buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
buffer->size = pCreateInfo->size;
buffer->usage = pCreateInfo->usage;
......@@ -3578,7 +3583,7 @@ VkResult radv_CreateBuffer(
4096, 0, RADEON_FLAG_VIRTUAL);
if (!buffer->bo) {
vk_free2(&device->alloc, pAllocator, buffer);
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
}
......@@ -4065,7 +4070,7 @@ VkResult radv_CreateFramebuffer(
framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (framebuffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
framebuffer->attachment_count = pCreateInfo->attachmentCount;
framebuffer->width = pCreateInfo->width;
......@@ -4283,7 +4288,7 @@ VkResult radv_CreateSampler(
sampler = vk_alloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
radv_init_sampler(device, sampler, pCreateInfo);
*pSampler = radv_sampler_to_handle(sampler);
......@@ -4365,7 +4370,7 @@ VkResult radv_GetMemoryFdKHR(VkDevice _device,
bool ret = radv_get_memory_fd(device, memory, pFD);
if (ret == false)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
}
......@@ -4374,6 +4379,8 @@ VkResult radv_GetMemoryFdPropertiesKHR(VkDevice _device,
int fd,
VkMemoryFdPropertiesKHR *pMemoryFdProperties)
{
RADV_FROM_HANDLE(radv_device, device, _device);
switch (handleType) {
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
pMemoryFdProperties->memoryTypeBits = (1 << RADV_MEM_TYPE_COUNT) - 1;
......@@ -4387,7 +4394,7 @@ VkResult radv_GetMemoryFdPropertiesKHR(VkDevice _device,
*
* So opaque handle types fall into the default "unsupported" case.
*/
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
}
}
......@@ -4398,7 +4405,7 @@ static VkResult radv_import_opaque_fd(struct radv_device *device,
uint32_t syncobj_handle = 0;
int ret = device->ws->import_syncobj(device->ws, fd, &syncobj_handle);
if (ret != 0)
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
if (*syncobj)
device->ws->destroy_syncobj(device->ws, *syncobj);
......@@ -4419,7 +4426,7 @@ static VkResult radv_import_sync_fd(struct radv_device *device,
if (!syncobj_handle) {
int ret = device->ws->create_syncobj(device->ws, &syncobj_handle);
if (ret) {
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
}
}
......@@ -4428,7 +4435,7 @@ static VkResult radv_import_sync_fd(struct radv_device *device,
} else {
int ret = device->ws->import_syncobj_from_sync_file(device->ws, syncobj_handle, fd);
if (ret != 0)
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
}
*syncobj = syncobj_handle;
......@@ -4495,7 +4502,7 @@ VkResult radv_GetSemaphoreFdKHR(VkDevice _device,
}
if (ret)
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return VK_SUCCESS;
}
......@@ -4584,7 +4591,7 @@ VkResult radv_GetFenceFdKHR(VkDevice _device,
}
if (ret)
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
return VK_SUCCESS;
}
......
......@@ -1327,7 +1327,7 @@ VkResult radv_GetPhysicalDeviceImageFormatProperties2(
* vkGetPhysicalDeviceImageFormatProperties2KHR returns
* VK_ERROR_FORMAT_NOT_SUPPORTED.
*/
result = vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED,
result = vk_errorf(physical_device->instance, VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkExternalMemoryTypeFlagBitsKHR 0x%x",
external_info->handleType);
goto fail;
......
......@@ -930,7 +930,7 @@ radv_image_create(VkDevice _device,
image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!image)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
image->type = pCreateInfo->imageType;
image->info.width = pCreateInfo->extent.width;
......@@ -1015,7 +1015,7 @@ radv_image_create(VkDevice _device,
0, RADEON_FLAG_VIRTUAL);
if (!image->bo) {
vk_free2(&device->alloc, alloc, image);
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}