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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GDK_VULKAN_CONTEXT_PRIVATE__
|
|
|
|
#define __GDK_VULKAN_CONTEXT_PRIVATE__
|
|
|
|
|
|
|
|
#include "gdkvulkancontext.h"
|
|
|
|
|
2016-11-28 16:55:46 +00:00
|
|
|
#include "gdkdrawcontextprivate.h"
|
2016-11-21 13:18:43 +00:00
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
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
|
|
|
|
|
|
|
static inline VkResult
|
|
|
|
gdk_vulkan_handle_result (VkResult res,
|
|
|
|
const char *called_function)
|
|
|
|
{
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2016-11-29 02:20:31 +00:00
|
|
|
GDK_NOTE (VULKAN,g_printerr ("%s(): %s (%d)\n", called_function, gdk_vulkan_strerror (res), res));
|
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))
|
|
|
|
|
|
|
|
gboolean gdk_display_ref_vulkan (GdkDisplay *display,
|
2016-11-28 15:34:01 +00:00
|
|
|
GError **error);
|
2016-11-21 13:18:43 +00:00
|
|
|
void gdk_display_unref_vulkan (GdkDisplay *display);
|
|
|
|
|
2016-12-09 19:11:37 +00:00
|
|
|
#else /* !GDK_RENDERING_VULKAN */
|
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
|
|
|
{
|
|
|
|
GDK_NOTE (VULKAN, g_print ("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,
|
|
|
|
"Vulkan support was not enabled at compie time.");
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#endif /* __GDK__VULKAN_CONTEXT_PRIVATE__ */
|