VK_EVENT_SET = 4,
VK_EVENT_RESET = 5,
VK_INCOMPLETE = 6,
- VK_ERROR_UNKNOWN = -1,
- VK_ERROR_UNAVAILABLE = -2,
+ VK_ERROR_OUT_OF_HOST_MEMORY = -1,
+ VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
VK_ERROR_INITIALIZATION_FAILED = -3,
- VK_ERROR_OUT_OF_HOST_MEMORY = -4,
- VK_ERROR_OUT_OF_DEVICE_MEMORY = -5,
- VK_ERROR_DEVICE_ALREADY_CREATED = -6,
- VK_ERROR_DEVICE_LOST = -7,
- VK_ERROR_INVALID_POINTER = -8,
- VK_ERROR_INVALID_VALUE = -9,
- VK_ERROR_INVALID_HANDLE = -10,
- VK_ERROR_INVALID_ORDINAL = -11,
- VK_ERROR_INVALID_MEMORY_SIZE = -12,
- VK_ERROR_INVALID_EXTENSION = -13,
- VK_ERROR_INVALID_FLAGS = -14,
- VK_ERROR_INVALID_ALIGNMENT = -15,
- VK_ERROR_INVALID_FORMAT = -16,
- VK_ERROR_INVALID_IMAGE = -17,
- VK_ERROR_INVALID_DESCRIPTOR_SET_DATA = -18,
- VK_ERROR_INVALID_QUEUE_TYPE = -19,
- VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION = -20,
- VK_ERROR_BAD_SHADER_CODE = -21,
- VK_ERROR_BAD_PIPELINE_DATA = -22,
- VK_ERROR_NOT_MAPPABLE = -23,
- VK_ERROR_MEMORY_MAP_FAILED = -24,
- VK_ERROR_MEMORY_UNMAP_FAILED = -25,
- VK_ERROR_INCOMPATIBLE_DEVICE = -26,
- VK_ERROR_INCOMPATIBLE_DRIVER = -27,
- VK_ERROR_INCOMPLETE_COMMAND_BUFFER = -28,
- VK_ERROR_BUILDING_COMMAND_BUFFER = -29,
- VK_ERROR_MEMORY_NOT_BOUND = -30,
- VK_ERROR_INCOMPATIBLE_QUEUE = -31,
- VK_ERROR_INVALID_LAYER = -32,
- VK_RESULT_BEGIN_RANGE = VK_ERROR_INVALID_LAYER,
+ VK_ERROR_DEVICE_LOST = -4,
+ VK_ERROR_MEMORY_MAP_FAILED = -5,
+ VK_ERROR_LAYER_NOT_PRESENT = -6,
+ VK_ERROR_EXTENSION_NOT_PRESENT = -7,
+ VK_ERROR_INCOMPATIBLE_DRIVER = -8,
+ VK_RESULT_BEGIN_RANGE = VK_ERROR_INCOMPATIBLE_DRIVER,
VK_RESULT_END_RANGE = VK_INCOMPLETE,
- VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INVALID_LAYER + 1),
+ VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INCOMPATIBLE_DRIVER + 1),
VK_RESULT_MAX_ENUM = 0x7FFFFFFF
} VkResult;
fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0)
- return vk_errorf(VK_ERROR_UNAVAILABLE, "failed to open %s: %m", path);
+ return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "failed to open %s: %m", path);
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = instance;
device->path = path;
-
+
device->chipset_id = anv_gem_get_param(fd, I915_PARAM_CHIPSET_ID);
if (!device->chipset_id) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get chipset id: %m");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get chipset id: %m");
goto fail;
}
device->name = brw_get_device_name(device->chipset_id);
device->info = brw_get_device_info(device->chipset_id, -1);
if (!device->info) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get device info");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get device info");
goto fail;
}
if (anv_gem_get_aperture(fd, &device->aperture_size) == -1) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get aperture size: %m");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get aperture size: %m");
goto fail;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing gem wait");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "kernel missing gem wait");
goto fail;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing execbuf2");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "kernel missing execbuf2");
goto fail;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_LLC)) {
- result = vk_errorf(VK_ERROR_UNAVAILABLE, "non-llc gpu");
+ result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ "non-llc gpu");
goto fail;
}
}
}
if (!found)
- return vk_error(VK_ERROR_INVALID_EXTENSION);
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
}
if (pCreateInfo->pAllocCb) {
}
}
if (!found)
- return vk_error(VK_ERROR_INVALID_EXTENSION);
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
}
anv_set_dispatch_gen(physical_device->info->gen);
fail_device:
anv_device_free(device, device);
- return vk_error(VK_ERROR_UNAVAILABLE);
+ return vk_error(VK_ERROR_INITIALIZATION_FAILED);
}
void anv_DestroyDevice(
}
/* None supported at this time */
- return vk_error(VK_ERROR_INVALID_LAYER);
+ return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
}
VkResult anv_EnumerateDeviceLayerProperties(
}
/* None supported at this time */
- return vk_error(VK_ERROR_INVALID_LAYER);
+ return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
}
VkResult anv_GetDeviceQueue(
assert(cmd_buffer->level == VK_CMD_BUFFER_LEVEL_PRIMARY);
ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf);
- if (ret != 0)
- return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+ if (ret != 0) {
+ /* We don't know the real error. */
+ return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "execbuf2 failed: %m");
+ }
if (fence) {
ret = anv_gem_execbuffer(device, &fence->execbuf);
- if (ret != 0)
- return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+ if (ret != 0) {
+ /* We don't know the real error. */
+ return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "execbuf2 failed: %m");
+ }
}
for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++)
ret = anv_gem_execbuffer(device, &execbuf);
if (ret != 0) {
- result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+ /* We don't know the real error. */
+ result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m");
goto fail;
}
timeout = INT64_MAX;
ret = anv_gem_wait(device, bo->gem_handle, &timeout);
if (ret != 0) {
- result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+ /* We don't know the real error. */
+ result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m");
goto fail;
}
assert(pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO);
- if (pAllocInfo->memoryTypeIndex != 0) {
- /* We support exactly one memory heap. */
- return vk_error(VK_ERROR_INVALID_VALUE);
- }
+ /* We support exactly one memory heap. */
+ assert(pAllocInfo->memoryTypeIndex == 0);
/* FINISHME: Fail if allocation request exceeds heap size. */
for (uint32_t i = 0; i < fenceCount; i++) {
ANV_FROM_HANDLE(anv_fence, fence, pFences[i]);
ret = anv_gem_wait(device, fence->bo.gem_handle, &t);
- if (ret == -1 && errno == ETIME)
+ if (ret == -1 && errno == ETIME) {
return VK_TIMEOUT;
- else if (ret == -1)
- return vk_errorf(VK_ERROR_UNKNOWN, "gem wait failed: %m");
+ } else if (ret == -1) {
+ /* We don't know the real error. */
+ return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "gem wait failed: %m");
+ }
}
return VK_SUCCESS;
int gen;
VkFormatFeatureFlags flags;
- if (format == NULL)
- return VK_ERROR_INVALID_VALUE;
+ assert(format != NULL);
gen = physical_device->info->gen * 10;
if (physical_device->info->is_haswell)
[WMAJOR] = { 128, 32, 4096 },
};
-/**
- * Return -1 on failure.
- */
-static int8_t
+static uint8_t
anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
{
if (anv_info->force_tile_mode)
switch (anv_info->vk_info->tiling) {
case VK_IMAGE_TILING_LINEAR:
- if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) {
- return -1;
- } else {
- return LINEAR;
- }
+ assert(anv_info->vk_info->format != VK_FORMAT_S8_UINT);
+ return LINEAR;
case VK_IMAGE_TILING_OPTIMAL:
if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) {
return WMAJOR;
const VkExtent3D *restrict extent = &create_info->vk_info->extent;
const uint32_t levels = create_info->vk_info->mipLevels;
const uint32_t array_size = create_info->vk_info->arraySize;
-
- const int8_t tile_mode = anv_image_choose_tile_mode(create_info);
- if (tile_mode == -1)
- return vk_error(VK_ERROR_INVALID_IMAGE);
+ const uint8_t tile_mode = anv_image_choose_tile_mode(create_info);
const struct anv_tile_info *tile_info =
&anv_tile_info_table[tile_mode];
const struct anv_surf_type_limits *limits =
&anv_surf_type_limits[surf_type];
- if (extent->width > limits->width ||
- extent->height > limits->height ||
- extent->depth > limits->depth) {
- /* TODO(chadv): What is the correct error? */
- return vk_errorf(VK_ERROR_INVALID_MEMORY_SIZE, "image extent is too large");
- }
+ /* Errors should be caught by VkImageFormatProperties. */
+ assert(extent->width <= limits->width);
+ assert(extent->height <= limits->height);
+ assert(extent->depth <= limits->depth);
image = anv_device_alloc(device, sizeof(*image), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (flags & VK_QUERY_RESULT_WAIT_BIT) {
ret = anv_gem_wait(device, pool->bo.gem_handle, &timeout);
- if (ret == -1)
- return vk_errorf(VK_ERROR_UNKNOWN, "gem_wait failed %m");
+ if (ret == -1) {
+ /* We don't know the real error. */
+ return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "gem_wait failed %m");
+ }
}
for (uint32_t i = 0; i < queryCount; i++) {
const char *error_str;
switch ((int32_t)error) {
- ERROR_CASE(VK_ERROR_UNKNOWN)
- ERROR_CASE(VK_ERROR_UNAVAILABLE)
- ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
+
+ /* Core errors */
ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
- ERROR_CASE(VK_ERROR_DEVICE_ALREADY_CREATED)
+ ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
ERROR_CASE(VK_ERROR_DEVICE_LOST)
- ERROR_CASE(VK_ERROR_INVALID_POINTER)
- ERROR_CASE(VK_ERROR_INVALID_VALUE)
- ERROR_CASE(VK_ERROR_INVALID_HANDLE)
- ERROR_CASE(VK_ERROR_INVALID_ORDINAL)
- ERROR_CASE(VK_ERROR_INVALID_MEMORY_SIZE)
- ERROR_CASE(VK_ERROR_INVALID_EXTENSION)
- ERROR_CASE(VK_ERROR_INVALID_FLAGS)
- ERROR_CASE(VK_ERROR_INVALID_ALIGNMENT)
- ERROR_CASE(VK_ERROR_INVALID_FORMAT)
- ERROR_CASE(VK_ERROR_INVALID_IMAGE)
- ERROR_CASE(VK_ERROR_INVALID_DESCRIPTOR_SET_DATA)
- ERROR_CASE(VK_ERROR_INVALID_QUEUE_TYPE)
- ERROR_CASE(VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION)
- ERROR_CASE(VK_ERROR_BAD_SHADER_CODE)
- ERROR_CASE(VK_ERROR_BAD_PIPELINE_DATA)
- ERROR_CASE(VK_ERROR_NOT_MAPPABLE)
ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
- ERROR_CASE(VK_ERROR_MEMORY_UNMAP_FAILED)
- ERROR_CASE(VK_ERROR_INCOMPATIBLE_DEVICE)
+ ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
+ ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
- ERROR_CASE(VK_ERROR_INCOMPLETE_COMMAND_BUFFER)
- ERROR_CASE(VK_ERROR_BUILDING_COMMAND_BUFFER)
- ERROR_CASE(VK_ERROR_MEMORY_NOT_BOUND)
- ERROR_CASE(VK_ERROR_INCOMPATIBLE_QUEUE)
- ERROR_CASE(VK_ERROR_INVALID_LAYER)
+
+ /* Extension errors */
ERROR_CASE(VK_ERROR_OUT_OF_DATE_WSI)
+
default:
assert(!"Unknown error");
error_str = "unknown error";
{
struct wsi_wayland *wsi = (struct wsi_wayland *)impl;
- if (pDataSize == NULL)
- return vk_error(VK_ERROR_INVALID_POINTER);
+ assert(pDataSize != NULL);
switch (infoType) {
+ default:
+ unreachable("bad VkSurfaceInfoTypeWSI");
case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
VkSurfacePropertiesWSI *props = pData;
memcpy(pData, present_modes, *pDataSize);
return VK_SUCCESS;
- default:
- return vk_error(VK_ERROR_INVALID_VALUE);
}
}
size_t size;
switch (infoType) {
+ default:
+ unreachable("bad VkSwapChainInfoTypeWSI");
case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: {
VkSwapChainImagePropertiesWSI *images = pData;
return VK_SUCCESS;
}
-
- default:
- return vk_error(VK_ERROR_INVALID_VALUE);
}
}
image->memory->bo.gem_handle,
surface->stride, I915_TILING_X);
if (ret) {
- result = vk_error(VK_ERROR_UNKNOWN);
+ /* FINISHME: Choose a better error. */
+ result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
goto fail_mem;
}
int fd = anv_gem_handle_to_fd(chain->base.device,
image->memory->bo.gem_handle);
if (fd == -1) {
- result = vk_error(VK_ERROR_UNKNOWN);
+ /* FINISHME: Choose a better error. */
+ result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
goto fail_mem;
}
int ret = pthread_mutex_init(&wsi->mutex, NULL);
if (ret != 0) {
- result = (ret == ENOMEM) ? VK_ERROR_OUT_OF_HOST_MEMORY :
- VK_ERROR_UNKNOWN;
+ if (ret == ENOMEM) {
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ } else {
+ /* FINISHME: Choose a better error. */
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
+
goto fail_alloc;
}
VkSurfaceInfoTypeWSI infoType,
size_t* pDataSize, void* pData)
{
- if (pDataSize == NULL)
- return vk_error(VK_ERROR_INVALID_POINTER);
+ assert(pDataSize != NULL);
switch (infoType) {
+ default:
+ unreachable("bad VkSurfaceInfoTypeWSI");
case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
VkSurfacePropertiesWSI *props = pData;
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(conn, cookie,
&err);
if (!geom) {
- if (err->error_code == XCB_DRAWABLE) {
- return vk_error(VK_ERROR_INVALID_HANDLE);
- } else {
- return vk_error(VK_ERROR_UNKNOWN);
- }
+ /* FINISHME: Choose a more accurate error. */
free(err);
+ return VK_ERROR_OUT_OF_DATE_WSI;
}
VkExtent2D extent = { geom->width, geom->height };
assert(*pDataSize >= sizeof(present_modes));
memcpy(pData, present_modes, *pDataSize);
-
return VK_SUCCESS;
- default:
- return vk_error(VK_ERROR_INVALID_VALUE);
}
}
size_t size;
switch (infoType) {
+ default:
+ unreachable("bad VkSwapChainInfoType");
case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: {
VkSwapChainImagePropertiesWSI *images = pData;
images[i].image = anv_image_to_handle(chain->images[i].image);
*pDataSize = size;
-
return VK_SUCCESS;
}
-
- default:
- return vk_error(VK_ERROR_INVALID_VALUE);
}
}
xcb_get_geometry_reply_t *geom =
xcb_get_geometry_reply(chain->conn, image->geom_cookie, &err);
if (!geom) {
- if (err->error_code == XCB_DRAWABLE) {
- /* Probably the best thing to do if our drawable goes away */
- return vk_error(VK_ERROR_OUT_OF_DATE_WSI);
- } else {
- return vk_error(VK_ERROR_UNKNOWN);
- }
+ /* Probably the best thing to do if our drawable goes away */
free(err);
+ return vk_error(VK_ERROR_OUT_OF_DATE_WSI);
}
if (geom->width != chain->extent.width ||
int ret = anv_gem_set_tiling(device, memory->bo.gem_handle,
surface->stride, I915_TILING_X);
if (ret) {
- result = vk_errorf(VK_ERROR_UNKNOWN, "set_tiling failed: %m");
+ /* FINISHME: Choose a better error. */
+ result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "set_tiling failed: %m");
goto fail;
}
int fd = anv_gem_handle_to_fd(device, memory->bo.gem_handle);
if (fd == -1) {
- result = vk_errorf(VK_ERROR_UNKNOWN, "handle_to_fd failed: %m");
+ /* FINISHME: Choose a better error. */
+ result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ "handle_to_fd failed: %m");
goto fail;
}
chain->gc = xcb_generate_id(chain->conn);
if (!chain->gc) {
- result = vk_error(VK_ERROR_UNKNOWN);
+ /* FINISHME: Choose a better error. */
+ result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail;
}
VkPipeline* pPipeline)
{
anv_finishme("primitive_id needs sbe swizzling setup");
-
- return vk_error(VK_ERROR_UNAVAILABLE);
+ abort();
}