From 58c318a4dc7a5aa4c1cd2e37be57b19b350d406e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 3 Jul 2023 15:57:30 +0200 Subject: [PATCH] vulkan: Add gskvulkanprivate.h It's the new place for all the common stuff. Because the old place is about to go away. --- gsk/vulkan/gskvulkanblendmodeop.c | 2 + gsk/vulkan/gskvulkanblurop.c | 2 + gsk/vulkan/gskvulkanborderop.c | 5 ++- gsk/vulkan/gskvulkanbuffer.c | 3 +- gsk/vulkan/gskvulkancolormatrixop.c | 2 + gsk/vulkan/gskvulkancommandpool.c | 2 +- gsk/vulkan/gskvulkancrossfadeop.c | 2 + gsk/vulkan/gskvulkanglyphop.c | 2 + gsk/vulkan/gskvulkanimage.c | 2 +- gsk/vulkan/gskvulkaninsetshadowop.c | 5 ++- gsk/vulkan/gskvulkanlineargradientop.c | 2 + gsk/vulkan/gskvulkanmemory.c | 3 +- gsk/vulkan/gskvulkanopprivate.h | 40 ----------------- gsk/vulkan/gskvulkanoutsetshadowop.c | 5 ++- gsk/vulkan/gskvulkanpipelineprivate.h | 15 ------- gsk/vulkan/gskvulkanprivate.h | 60 ++++++++++++++++++++++++++ gsk/vulkan/gskvulkanrender.c | 1 + gsk/vulkan/gskvulkanrenderer.c | 2 +- gsk/vulkan/gskvulkanrenderpass.c | 1 + gsk/vulkan/gskvulkanrenderprivate.h | 1 - gsk/vulkan/gskvulkantextureop.c | 2 + 21 files changed, 92 insertions(+), 67 deletions(-) create mode 100644 gsk/vulkan/gskvulkanprivate.h diff --git a/gsk/vulkan/gskvulkanblendmodeop.c b/gsk/vulkan/gskvulkanblendmodeop.c index a8d0930614..ee50ca26e6 100644 --- a/gsk/vulkan/gskvulkanblendmodeop.c +++ b/gsk/vulkan/gskvulkanblendmodeop.c @@ -2,6 +2,8 @@ #include "gskvulkanblendmodeopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/blend-mode.vert.h" typedef struct _GskVulkanBlendModeOp GskVulkanBlendModeOp; diff --git a/gsk/vulkan/gskvulkanblurop.c b/gsk/vulkan/gskvulkanblurop.c index 84cd66b97d..df2eb427bf 100644 --- a/gsk/vulkan/gskvulkanblurop.c +++ b/gsk/vulkan/gskvulkanblurop.c @@ -2,6 +2,8 @@ #include "gskvulkanbluropprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/blur.vert.h" typedef struct _GskVulkanBlurOp GskVulkanBlurOp; diff --git a/gsk/vulkan/gskvulkanborderop.c b/gsk/vulkan/gskvulkanborderop.c index 9f1f312096..0855ea485d 100644 --- a/gsk/vulkan/gskvulkanborderop.c +++ b/gsk/vulkan/gskvulkanborderop.c @@ -2,10 +2,11 @@ #include "gskvulkanborderopprivate.h" -#include "vulkan/resources/border.vert.h" - +#include "gskvulkanprivate.h" #include "gsk/gskroundedrectprivate.h" +#include "vulkan/resources/border.vert.h" + typedef struct _GskVulkanBorderOp GskVulkanBorderOp; struct _GskVulkanBorderOp diff --git a/gsk/vulkan/gskvulkanbuffer.c b/gsk/vulkan/gskvulkanbuffer.c index cd7b8a01cb..a2e850da22 100644 --- a/gsk/vulkan/gskvulkanbuffer.c +++ b/gsk/vulkan/gskvulkanbuffer.c @@ -1,8 +1,9 @@ #include "config.h" #include "gskvulkanbufferprivate.h" + #include "gskvulkanmemoryprivate.h" -#include "gskvulkanpipelineprivate.h" +#include "gskvulkanprivate.h" struct _GskVulkanBuffer { diff --git a/gsk/vulkan/gskvulkancolormatrixop.c b/gsk/vulkan/gskvulkancolormatrixop.c index 1e7972272e..f04e96e9e1 100644 --- a/gsk/vulkan/gskvulkancolormatrixop.c +++ b/gsk/vulkan/gskvulkancolormatrixop.c @@ -2,6 +2,8 @@ #include "gskvulkancolormatrixopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/color-matrix.vert.h" typedef struct _GskVulkanColorMatrixOp GskVulkanColorMatrixOp; diff --git a/gsk/vulkan/gskvulkancommandpool.c b/gsk/vulkan/gskvulkancommandpool.c index 8adb6c5bf4..197e0aec2a 100644 --- a/gsk/vulkan/gskvulkancommandpool.c +++ b/gsk/vulkan/gskvulkancommandpool.c @@ -1,7 +1,7 @@ #include "config.h" #include "gskvulkancommandpoolprivate.h" -#include "gskvulkanpipelineprivate.h" +#include "gskvulkanprivate.h" struct _GskVulkanCommandPool { diff --git a/gsk/vulkan/gskvulkancrossfadeop.c b/gsk/vulkan/gskvulkancrossfadeop.c index 1967d13254..6a229b2281 100644 --- a/gsk/vulkan/gskvulkancrossfadeop.c +++ b/gsk/vulkan/gskvulkancrossfadeop.c @@ -2,6 +2,8 @@ #include "gskvulkancrossfadeopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/cross-fade.vert.h" typedef struct _GskVulkanCrossFadeOp GskVulkanCrossFadeOp; diff --git a/gsk/vulkan/gskvulkanglyphop.c b/gsk/vulkan/gskvulkanglyphop.c index 4617806928..8f9b0c3afb 100644 --- a/gsk/vulkan/gskvulkanglyphop.c +++ b/gsk/vulkan/gskvulkanglyphop.c @@ -2,6 +2,8 @@ #include "gskvulkanglyphopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/glyph.vert.h" typedef struct _GskVulkanGlyphOp GskVulkanGlyphOp; diff --git a/gsk/vulkan/gskvulkanimage.c b/gsk/vulkan/gskvulkanimage.c index bd31143b93..cee0cb8764 100644 --- a/gsk/vulkan/gskvulkanimage.c +++ b/gsk/vulkan/gskvulkanimage.c @@ -4,7 +4,7 @@ #include "gskvulkanbufferprivate.h" #include "gskvulkanmemoryprivate.h" -#include "gskvulkanpipelineprivate.h" +#include "gskvulkanprivate.h" #include "gdk/gdkmemoryformatprivate.h" diff --git a/gsk/vulkan/gskvulkaninsetshadowop.c b/gsk/vulkan/gskvulkaninsetshadowop.c index 78958852eb..fa0ceae503 100644 --- a/gsk/vulkan/gskvulkaninsetshadowop.c +++ b/gsk/vulkan/gskvulkaninsetshadowop.c @@ -2,10 +2,11 @@ #include "gskvulkaninsetshadowopprivate.h" -#include "vulkan/resources/inset-shadow.vert.h" - +#include "gskvulkanprivate.h" #include "gsk/gskroundedrectprivate.h" +#include "vulkan/resources/inset-shadow.vert.h" + typedef struct _GskVulkanInsetShadowOp GskVulkanInsetShadowOp; struct _GskVulkanInsetShadowOp diff --git a/gsk/vulkan/gskvulkanlineargradientop.c b/gsk/vulkan/gskvulkanlineargradientop.c index 22aca43614..c680348190 100644 --- a/gsk/vulkan/gskvulkanlineargradientop.c +++ b/gsk/vulkan/gskvulkanlineargradientop.c @@ -2,6 +2,8 @@ #include "gskvulkanlineargradientopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/linear.vert.h" typedef struct _GskVulkanLinearGradientOp GskVulkanLinearGradientOp; diff --git a/gsk/vulkan/gskvulkanmemory.c b/gsk/vulkan/gskvulkanmemory.c index d5cced20a1..26d08e807d 100644 --- a/gsk/vulkan/gskvulkanmemory.c +++ b/gsk/vulkan/gskvulkanmemory.c @@ -1,8 +1,9 @@ #include "config.h" -#include "gskvulkanpipelineprivate.h" #include "gskvulkanmemoryprivate.h" +#include "gskvulkanprivate.h" + struct _GskVulkanMemory { GdkVulkanContext *vulkan; diff --git a/gsk/vulkan/gskvulkanopprivate.h b/gsk/vulkan/gskvulkanopprivate.h index 8e8bf8e52f..1d1a7bbdb1 100644 --- a/gsk/vulkan/gskvulkanopprivate.h +++ b/gsk/vulkan/gskvulkanopprivate.h @@ -69,45 +69,5 @@ void gsk_vulkan_op_command (GskVulk VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer); -static inline void -gsk_vulkan_normalize_tex_coords (graphene_rect_t *tex_coords, - const graphene_rect_t *rect, - const graphene_rect_t *tex) -{ - graphene_rect_init (tex_coords, - (rect->origin.x - tex->origin.x) / tex->size.width, - (rect->origin.y - tex->origin.y) / tex->size.height, - rect->size.width / tex->size.width, - rect->size.height / tex->size.height); -} - -static inline void -gsk_vulkan_rect_to_float (const graphene_rect_t *rect, - float values[4]) -{ - values[0] = rect->origin.x; - values[1] = rect->origin.y; - values[2] = rect->size.width; - values[3] = rect->size.height; -} - -static inline void -gsk_vulkan_rgba_to_float (const GdkRGBA *rgba, - float values[4]) -{ - values[0] = rgba->red; - values[1] = rgba->green; - values[2] = rgba->blue; - values[3] = rgba->alpha; -} - -static inline void -gsk_vulkan_point_to_float (const graphene_point_t *point, - float values[2]) -{ - values[0] = point->x; - values[1] = point->y; -} - G_END_DECLS diff --git a/gsk/vulkan/gskvulkanoutsetshadowop.c b/gsk/vulkan/gskvulkanoutsetshadowop.c index 95ac7e3836..0cb29cc2e3 100644 --- a/gsk/vulkan/gskvulkanoutsetshadowop.c +++ b/gsk/vulkan/gskvulkanoutsetshadowop.c @@ -2,10 +2,11 @@ #include "gskvulkanoutsetshadowopprivate.h" -#include "vulkan/resources/outset-shadow.vert.h" - +#include "gskvulkanprivate.h" #include "gsk/gskroundedrectprivate.h" +#include "vulkan/resources/outset-shadow.vert.h" + typedef struct _GskVulkanOutsetShadowOp GskVulkanOutsetShadowOp; struct _GskVulkanOutsetShadowOp diff --git a/gsk/vulkan/gskvulkanpipelineprivate.h b/gsk/vulkan/gskvulkanpipelineprivate.h index 067a6546c0..771b6afb9f 100644 --- a/gsk/vulkan/gskvulkanpipelineprivate.h +++ b/gsk/vulkan/gskvulkanpipelineprivate.h @@ -2,8 +2,6 @@ #include -#include "gskdebugprivate.h" - G_BEGIN_DECLS #define GSK_TYPE_VULKAN_PIPELINE (gsk_vulkan_pipeline_get_type ()) @@ -18,19 +16,6 @@ struct _GskVulkanPipelineClass (* get_input_state_create_info) (GskVulkanPipeline *self); }; -static inline VkResult -gsk_vulkan_handle_result (VkResult res, - const char *called_function) -{ - if (res != VK_SUCCESS) - { - GSK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res); - } - return res; -} - -#define GSK_VK_CHECK(func, ...) gsk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func)) - GskVulkanPipeline * gsk_vulkan_pipeline_new (GType pipeline_type, GdkVulkanContext *context, VkPipelineLayout layout, diff --git a/gsk/vulkan/gskvulkanprivate.h b/gsk/vulkan/gskvulkanprivate.h new file mode 100644 index 0000000000..5cad3ac144 --- /dev/null +++ b/gsk/vulkan/gskvulkanprivate.h @@ -0,0 +1,60 @@ +#pragma once + +#include "gskdebugprivate.h" + +#include +#include + +static inline VkResult +gsk_vulkan_handle_result (VkResult res, + const char *called_function) +{ + if (res != VK_SUCCESS) + { + GSK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res); + } + return res; +} + +#define GSK_VK_CHECK(func, ...) gsk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func)) + +static inline void +gsk_vulkan_normalize_tex_coords (graphene_rect_t *tex_coords, + const graphene_rect_t *rect, + const graphene_rect_t *tex) +{ + graphene_rect_init (tex_coords, + (rect->origin.x - tex->origin.x) / tex->size.width, + (rect->origin.y - tex->origin.y) / tex->size.height, + rect->size.width / tex->size.width, + rect->size.height / tex->size.height); +} + +static inline void +gsk_vulkan_rect_to_float (const graphene_rect_t *rect, + float values[4]) +{ + values[0] = rect->origin.x; + values[1] = rect->origin.y; + values[2] = rect->size.width; + values[3] = rect->size.height; +} + +static inline void +gsk_vulkan_rgba_to_float (const GdkRGBA *rgba, + float values[4]) +{ + values[0] = rgba->red; + values[1] = rgba->green; + values[2] = rgba->blue; + values[3] = rgba->alpha; +} + +static inline void +gsk_vulkan_point_to_float (const graphene_point_t *point, + float values[2]) +{ + values[0] = point->x; + values[1] = point->y; +} + diff --git a/gsk/vulkan/gskvulkanrender.c b/gsk/vulkan/gskvulkanrender.c index 1714b0815c..1aa35f258d 100644 --- a/gsk/vulkan/gskvulkanrender.c +++ b/gsk/vulkan/gskvulkanrender.c @@ -9,6 +9,7 @@ #include "gskvulkancommandpoolprivate.h" #include "gskvulkanglyphcacheprivate.h" #include "gskvulkanpipelineprivate.h" +#include "gskvulkanprivate.h" #include "gskvulkanpushconstantsopprivate.h" #include "gskvulkanrendererprivate.h" #include "gskvulkanrenderpassprivate.h" diff --git a/gsk/vulkan/gskvulkanrenderer.c b/gsk/vulkan/gskvulkanrenderer.c index e7dac98bb5..10b629fab6 100644 --- a/gsk/vulkan/gskvulkanrenderer.c +++ b/gsk/vulkan/gskvulkanrenderer.c @@ -8,7 +8,7 @@ #include "gskrendernodeprivate.h" #include "gskvulkanbufferprivate.h" #include "gskvulkanimageprivate.h" -#include "gskvulkanpipelineprivate.h" +#include "gskvulkanprivate.h" #include "gskvulkanrenderprivate.h" #include "gskvulkanglyphcacheprivate.h" diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 442a96e277..92d3060fed 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -20,6 +20,7 @@ #include "gskvulkaninsetshadowopprivate.h" #include "gskvulkanlineargradientopprivate.h" #include "gskvulkanopprivate.h" +#include "gskvulkanprivate.h" #include "gskvulkanrendererprivate.h" #include "gskvulkanimageprivate.h" #include "gskvulkanoffscreenopprivate.h" diff --git a/gsk/vulkan/gskvulkanrenderprivate.h b/gsk/vulkan/gskvulkanrenderprivate.h index 41023d5ad8..aa02b6760a 100644 --- a/gsk/vulkan/gskvulkanrenderprivate.h +++ b/gsk/vulkan/gskvulkanrenderprivate.h @@ -4,7 +4,6 @@ #include #include "gskvulkanimageprivate.h" -#include "gskvulkanpipelineprivate.h" #include "gskvulkanrenderpassprivate.h" #include "gsk/gskprivate.h" diff --git a/gsk/vulkan/gskvulkantextureop.c b/gsk/vulkan/gskvulkantextureop.c index 972f692502..a68ad977d4 100644 --- a/gsk/vulkan/gskvulkantextureop.c +++ b/gsk/vulkan/gskvulkantextureop.c @@ -2,6 +2,8 @@ #include "gskvulkantextureopprivate.h" +#include "gskvulkanprivate.h" + #include "vulkan/resources/texture.vert.h" typedef struct _GskVulkanTextureOp GskVulkanTextureOp;