gpu = gst_vulkan_device_get_physical_device (device);
if (!gpu) {
- g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to retrieve physical device");
return FALSE;
}
break;
}
if (i >= device->n_queue_families) {
- g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to find a compatible queue family");
goto error;
}
VkResult result;
const char *str;
} vk_result_string_map[] = {
- {VK_ERROR_OUT_OF_HOST_MEMORY, "Out Of Host Memory"},
- {VK_ERROR_OUT_OF_DEVICE_MEMORY, "Out of Device Memory"},
- {VK_ERROR_INITIALIZATION_FAILED, "Initialization Failed"},
- {VK_ERROR_DEVICE_LOST, "Device Lost"},
- {VK_ERROR_MEMORY_MAP_FAILED, "Map Failed"},
- {VK_ERROR_LAYER_NOT_PRESENT, "Layer Not Present"},
- {VK_ERROR_EXTENSION_NOT_PRESENT, "Extension Not Present"},
- {VK_ERROR_INCOMPATIBLE_DRIVER, "Incompatible Driver"},
-};
-
-static const struct
-{
- VkResult result;
- GstVulkanError gst_enum;
-} vk_result_gst_error_map[] = {
- {VK_ERROR_OUT_OF_HOST_MEMORY, GST_VULKAN_ERROR_OUT_OF_HOST_MEMORY},
- {VK_ERROR_OUT_OF_DEVICE_MEMORY, VK_ERROR_OUT_OF_DEVICE_MEMORY},
- {VK_ERROR_INITIALIZATION_FAILED, GST_VULKAN_ERROR_INITIALIZATION_FAILED},
- {VK_ERROR_DEVICE_LOST, GST_VULKAN_ERROR_DEVICE_LOST},
- {VK_ERROR_MEMORY_MAP_FAILED, GST_VULKAN_ERROR_MEMORY_MAP_FAILED},
- {VK_ERROR_LAYER_NOT_PRESENT, GST_VULKAN_ERROR_LAYER_NOT_PRESENT},
- {VK_ERROR_EXTENSION_NOT_PRESENT, GST_VULKAN_ERROR_EXTENSION_NOT_PRESENT},
- {VK_ERROR_INCOMPATIBLE_DRIVER, GST_VULKAN_ERROR_INCOMPATIBLE_DRIVER},
+ {VK_ERROR_OUT_OF_HOST_MEMORY, "Out Of host memory"},
+ {VK_ERROR_OUT_OF_DEVICE_MEMORY, "Out of device memory"},
+ {VK_ERROR_INITIALIZATION_FAILED, "Initialization failed"},
+ {VK_ERROR_DEVICE_LOST, "Device lost"},
+ {VK_ERROR_MEMORY_MAP_FAILED, "Map failed"},
+ {VK_ERROR_LAYER_NOT_PRESENT, "Layer not present"},
+ {VK_ERROR_EXTENSION_NOT_PRESENT, "Extension not present"},
+ {VK_ERROR_FEATURE_NOT_PRESENT, "Feature not present"},
+ {VK_ERROR_INCOMPATIBLE_DRIVER, "Incompatible driver"},
+ {VK_ERROR_TOO_MANY_OBJECTS, "Too many objects"},
+ {VK_ERROR_FORMAT_NOT_SUPPORTED, "format not supported"},
+ {VK_ERROR_SURFACE_LOST_KHR, "Surface lost"},
+ {VK_ERROR_OUT_OF_DATE_KHR, "out of date"},
+ {VK_ERROR_INCOMPATIBLE_DISPLAY_KHR, "Incompatible display"},
+ {VK_ERROR_NATIVE_WINDOW_IN_USE_KHR, "Native window in use"},
};
/* *INDENT-ON* */
return "Unknown Error";
}
-static GstVulkanError
-_vk_result_to_g_error_enum (VkResult result)
-{
- int i;
-
- if (result >= 0)
- return 0;
- if (result < VK_RESULT_BEGIN_RANGE)
- return 0;
-
- for (i = 0; i < G_N_ELEMENTS (vk_result_gst_error_map); i++) {
- if (result == vk_result_gst_error_map[i].result)
- return vk_result_gst_error_map[i].gst_enum;
- }
-
- return GST_VULKAN_ERROR_FAILED;
-}
-
VkResult
gst_vulkan_error_to_g_error (VkResult result, GError ** error,
const char *format, ...)
{
- GstVulkanError gst_enum;
const char *result_str;
gchar *string;
va_list args;
if (result_str == NULL)
return result;
- gst_enum = _vk_result_to_g_error_enum (result);
-
va_start (args, format);
g_vasprintf (&string, format, args);
va_end (args);
- g_set_error (error, GST_VULKAN_ERROR, gst_enum, "%s: %s", result_str, string);
+ g_set_error (error, GST_VULKAN_ERROR, result, "%s: %s", result_str, string);
return result;
}
#define GST_VULKAN_ERROR (gst_vulkan_error_quark ())
GQuark gst_vulkan_error_quark (void);
-typedef enum
-{
- GST_VULKAN_ERROR_FAILED = 0,
- GST_VULKAN_ERROR_OUT_OF_HOST_MEMORY = -1,
- GST_VULKAN_ERROR_OUT_OF_DEVICE_MEMORY = -2,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED = -3,
- GST_VULKAN_ERROR_DEVICE_LOST = -4,
- GST_VULKAN_ERROR_MEMORY_MAP_FAILED = -5,
- GST_VULKAN_ERROR_LAYER_NOT_PRESENT = -6,
- GST_VULKAN_ERROR_EXTENSION_NOT_PRESENT = -7,
- GST_VULKAN_ERROR_INCOMPATIBLE_DRIVER = -8,
-} GstVulkanError;
-
/* only fills error iff error != NULL and result < 0 */
VkResult gst_vulkan_error_to_g_error (VkResult result, GError ** error, const char * format, ...) G_GNUC_PRINTF (3, 4);
instance->dbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback)
gst_vulkan_instance_get_proc_address (instance, "vkDbgCreateMsgCallback");
if (!instance->dbgCreateMsgCallback) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to retreive vkDbgCreateMsgCallback");
goto error;
}
gst_vulkan_instance_get_proc_address (instance,
"vkDbgDestroyMsgCallback");
if (!instance->dbgDestroyMsgCallback) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to retreive vkDbgDestroyMsgCallback");
goto error;
}
(PFN_vkDbgMsgCallback) gst_vulkan_instance_get_proc_address (instance,
"vkDbgBreakCallback");
if (!instance->dbgBreakCallback) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to retreive vkDbgBreakCallback");
goto error;
}
if (graphics_queue != present_queue) {
/* FIXME: add support for separate graphics/present queues */
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ VK_ERROR_INITIALIZATION_FAILED,
"Failed to find a compatible present/graphics queue");
return FALSE;
}
alpha_flags = VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
} else {
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ VK_ERROR_INITIALIZATION_FAILED,
"Incorrect alpha flags available for the swap images");
return FALSE;
}
usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
} else {
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ VK_ERROR_INITIALIZATION_FAILED,
"Incorrect usage flags available for the swap images");
return FALSE;
}
usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
} else {
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ VK_ERROR_INITIALIZATION_FAILED,
"Incorrect usage flags available for the swap images");
return FALSE;
}
{
if (!gst_video_info_from_caps (&swapper->v_info, caps)) {
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED,
+ VK_ERROR_INITIALIZATION_FAILED,
"Failed to geto GstVideoInfo from caps");
return FALSE;
}
return FALSE;
if (!gst_video_frame_map (&vframe, &swapper->v_info, buffer, GST_MAP_READ)) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_MEMORY_MAP_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_MEMORY_MAP_FAILED,
"Failed to map buffer");
return FALSE;
}
VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
if (!staging) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_MEMORY_MAP_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_MEMORY_MAP_FAILED,
"Failed to create staging memory");
gst_video_frame_unmap (&vframe);
return FALSE;
}
if (!gst_memory_map ((GstMemory *) staging, &staging_map_info, GST_MAP_WRITE)) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_MEMORY_MAP_FAILED,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_MEMORY_MAP_FAILED,
"Failed to map swap image");
gst_video_frame_unmap (&vframe);
gst_memory_unref ((GstMemory *) staging);
if (!buffer) {
g_set_error (error, GST_VULKAN_ERROR,
- GST_VULKAN_ERROR_INITIALIZATION_FAILED, "Invalid buffer");
+ VK_ERROR_INITIALIZATION_FAILED, "Invalid buffer");
goto error;
}
if (g_atomic_int_get (&swapper->to_quit)) {
- g_set_error (error, GST_VULKAN_ERROR, GST_VULKAN_ERROR_DEVICE_LOST,
+ g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_SURFACE_LOST_KHR,
"Output window was closed");
goto error;
}