1/* GDK - The GIMP Drawing Kit
2 *
3 * gdkvulkancontextprivate.h: specific Vulkan wrappers
4 *
5 * Copyright © 2016 Benjamin Otte
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __GDK_VULKAN_CONTEXT_PRIVATE__
22#define __GDK_VULKAN_CONTEXT_PRIVATE__
23
24#include "gdkvulkancontext.h"
25
26#include "gdkdebug.h"
27#include "gdkdrawcontextprivate.h"
28#include "gdkenums.h"
29
30#ifdef GDK_RENDERING_VULKAN
31#include <vulkan/vulkan.h>
32#endif
33
34G_BEGIN_DECLS
35
36#define GDK_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_VULKAN_CONTEXT, GdkVulkanContextClass))
37#define GDK_IS_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_VULKAN_CONTEXT))
38#define GDK_VULKAN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_VULKAN_CONTEXT, GdkVulkanContextClass))
39
40typedef struct _GdkVulkanContextClass GdkVulkanContextClass;
41
42struct _GdkVulkanContext
43{
44 GdkDrawContext parent_instance;
45};
46
47struct _GdkVulkanContextClass
48{
49 GdkDrawContextClass parent_class;
50
51#ifdef GDK_RENDERING_VULKAN
52 VkResult (* create_surface) (GdkVulkanContext *context,
53 VkSurfaceKHR *surface);
54#endif
55};
56
57#ifdef GDK_RENDERING_VULKAN
58
59static inline VkResult
60gdk_vulkan_handle_result (VkResult res,
61 const char *called_function)
62{
63 if (res != VK_SUCCESS)
64 {
65 GDK_NOTE (VULKAN, g_printerr ("%s(): %s (%d)\n", called_function, gdk_vulkan_strerror (res), res));
66 }
67
68 return res;
69}
70
71#define GDK_VK_CHECK(func, ...) gdk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
72
73gboolean gdk_display_ref_vulkan (GdkDisplay *display,
74 GError **error);
75void gdk_display_unref_vulkan (GdkDisplay *display);
76
77#else /* !GDK_RENDERING_VULKAN */
78
79
80static inline gboolean
81gdk_display_ref_vulkan (GdkDisplay *display,
82 GError **error)
83{
84 GDK_DISPLAY_NOTE (display, VULKAN, g_message ("Support for Vulkan disabled at compile-time"));
85 g_set_error_literal (err: error, GDK_VULKAN_ERROR, code: GDK_VULKAN_ERROR_UNSUPPORTED,
86 message: "Vulkan support was not enabled at compile time.");
87
88 return FALSE;
89}
90
91#endif /* !GDK_RENDERING_VULKAN */
92
93G_END_DECLS
94
95#endif /* __GDK__VULKAN_CONTEXT_PRIVATE__ */
96

source code of gtk/gdk/gdkvulkancontextprivate.h