2016-11-21 13:18:43 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
*
|
2017-01-03 23:11:36 +00:00
|
|
|
* gdkvulkancontextprivate.h: specific Vulkan wrappers
|
2016-11-21 13:18:43 +00:00
|
|
|
*
|
|
|
|
* Copyright © 2016 Benjamin Otte
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-03-31 19:11:10 +00:00
|
|
|
#pragma once
|
2016-11-21 13:18:43 +00:00
|
|
|
|
|
|
|
#include "gdkvulkancontext.h"
|
|
|
|
|
2022-09-24 03:11:41 +00:00
|
|
|
#include "gdkdebugprivate.h"
|
2023-10-19 11:34:40 +00:00
|
|
|
#include "gdkdmabufprivate.h"
|
|
|
|
#include "gdkdmabufdownloaderprivate.h"
|
2016-11-28 16:55:46 +00:00
|
|
|
#include "gdkdrawcontextprivate.h"
|
2021-10-25 00:14:18 +00:00
|
|
|
#include "gdkenums.h"
|
2016-11-21 13:18:43 +00:00
|
|
|
|
2016-12-09 19:11:37 +00:00
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
2016-11-21 13:18:43 +00:00
|
|
|
#include <vulkan/vulkan.h>
|
2016-12-09 19:05:26 +00:00
|
|
|
#endif
|
2016-11-21 13:18:43 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GDK_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_VULKAN_CONTEXT, GdkVulkanContextClass))
|
|
|
|
#define GDK_IS_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_VULKAN_CONTEXT))
|
|
|
|
#define GDK_VULKAN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_VULKAN_CONTEXT, GdkVulkanContextClass))
|
|
|
|
|
|
|
|
typedef struct _GdkVulkanContextClass GdkVulkanContextClass;
|
|
|
|
|
|
|
|
struct _GdkVulkanContext
|
|
|
|
{
|
2016-11-28 16:55:46 +00:00
|
|
|
GdkDrawContext parent_instance;
|
2016-11-21 13:18:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GdkVulkanContextClass
|
|
|
|
{
|
2016-11-28 16:55:46 +00:00
|
|
|
GdkDrawContextClass parent_class;
|
2016-11-28 15:34:01 +00:00
|
|
|
|
2016-12-09 19:21:18 +00:00
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
2016-11-28 15:34:01 +00:00
|
|
|
VkResult (* create_surface) (GdkVulkanContext *context,
|
|
|
|
VkSurfaceKHR *surface);
|
2016-12-09 19:21:18 +00:00
|
|
|
#endif
|
2016-11-21 13:18:43 +00:00
|
|
|
};
|
|
|
|
|
2016-12-09 19:11:37 +00:00
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
2016-11-21 13:18:43 +00:00
|
|
|
|
2024-01-07 08:39:21 +00:00
|
|
|
const char * gdk_vulkan_strerror (VkResult result);
|
|
|
|
|
2016-11-21 13:18:43 +00:00
|
|
|
static inline VkResult
|
|
|
|
gdk_vulkan_handle_result (VkResult res,
|
|
|
|
const char *called_function)
|
|
|
|
{
|
|
|
|
if (res != VK_SUCCESS)
|
2018-01-21 14:23:17 +00:00
|
|
|
{
|
2024-08-07 05:26:02 +00:00
|
|
|
g_warning ("%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
|
2018-01-21 14:23:17 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 13:18:43 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GDK_VK_CHECK(func, ...) gdk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
|
|
|
|
|
2023-11-09 04:42:58 +00:00
|
|
|
gboolean gdk_display_init_vulkan (GdkDisplay *display,
|
2023-06-20 14:35:55 +00:00
|
|
|
GError **error);
|
2023-11-09 04:42:58 +00:00
|
|
|
void gdk_display_ref_vulkan (GdkDisplay *display);
|
2023-06-20 14:35:55 +00:00
|
|
|
void gdk_display_unref_vulkan (GdkDisplay *display);
|
|
|
|
|
2024-09-15 09:38:30 +00:00
|
|
|
void gdk_vulkan_init_dmabuf (GdkDisplay *display);
|
2023-10-19 11:34:40 +00:00
|
|
|
|
2023-06-28 03:43:53 +00:00
|
|
|
VkShaderModule gdk_display_get_vk_shader_module (GdkDisplay *display,
|
|
|
|
const char *resource_name);
|
|
|
|
|
2023-11-20 03:54:26 +00:00
|
|
|
void gdk_display_vulkan_pipeline_cache_updated (GdkDisplay *display);
|
2023-06-26 03:10:16 +00:00
|
|
|
|
2024-01-07 08:39:21 +00:00
|
|
|
VkInstance gdk_vulkan_context_get_instance (GdkVulkanContext *context);
|
|
|
|
VkPhysicalDevice gdk_vulkan_context_get_physical_device (GdkVulkanContext *context);
|
|
|
|
VkDevice gdk_vulkan_context_get_device (GdkVulkanContext *context);
|
|
|
|
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
|
|
|
|
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
|
|
|
|
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
|
2024-06-09 15:28:00 +00:00
|
|
|
GdkMemoryFormat gdk_vulkan_context_get_memory_format (GdkVulkanContext *context);
|
2024-01-07 08:39:21 +00:00
|
|
|
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
|
|
|
|
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
|
|
|
|
guint id);
|
|
|
|
uint32_t gdk_vulkan_context_get_draw_index (GdkVulkanContext *context);
|
|
|
|
|
2024-07-17 20:13:04 +00:00
|
|
|
void gdk_vulkan_context_set_draw_semaphore (GdkVulkanContext *context,
|
|
|
|
VkSemaphore semaphore);
|
|
|
|
|
2016-12-09 19:11:37 +00:00
|
|
|
#else /* !GDK_RENDERING_VULKAN */
|
2016-11-21 13:18:43 +00:00
|
|
|
|
2018-01-15 13:01:01 +00:00
|
|
|
|
2016-11-21 13:18:43 +00:00
|
|
|
static inline gboolean
|
2016-11-28 15:34:01 +00:00
|
|
|
gdk_display_ref_vulkan (GdkDisplay *display,
|
|
|
|
GError **error)
|
2016-11-21 13:18:43 +00:00
|
|
|
{
|
2022-09-23 00:48:58 +00:00
|
|
|
GDK_DISPLAY_DEBUG (display, VULKAN, "Support for Vulkan disabled at compile-time");
|
2016-11-28 15:34:01 +00:00
|
|
|
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
|
2017-09-25 21:53:54 +00:00
|
|
|
"Vulkan support was not enabled at compile time.");
|
2016-11-28 15:34:01 +00:00
|
|
|
|
2016-11-21 13:18:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-12-09 19:11:37 +00:00
|
|
|
#endif /* !GDK_RENDERING_VULKAN */
|
2016-11-21 13:18:43 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|