[gtk+] meson: add vulkan bits



commit 95979f4d2f3961c5b06af84ed80e759894cfc78a
Author: Tim-Philipp Müller <tim centricular com>
Date:   Fri Mar 17 23:43:36 2017 +0000

    meson: add vulkan bits

 gdk/gdkconfig.h.meson |    2 +
 gdk/meson.build       |   15 ++++++---
 gsk/meson.build       |   82 ++++++++++++++++++++++++++++++++++++++----------
 meson.build           |   20 ++++++++++++
 meson_options.txt     |    1 +
 5 files changed, 98 insertions(+), 22 deletions(-)
---
diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson
index bb7416e..db09844 100644
--- a/gdk/gdkconfig.h.meson
+++ b/gdk/gdkconfig.h.meson
@@ -14,6 +14,8 @@ G_BEGIN_DECLS
 #mesondefine GDK_WINDOWING_BROADWAY
 #mesondefine GDK_WINDOWING_WAYLAND
 
+#mesondefine GDK_RENDERING_VULKAN
+
 G_END_DECLS
 
 #endif  /* __GDKCONFIG_H__ */
diff --git a/gdk/meson.build b/gdk/meson.build
index a7ee89f..ec1bc0f 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -114,6 +114,7 @@ gdk_x_sources = files([
   'x11/gdkscreen-x11.h',
   'x11/gdkselection-x11.c',
   'x11/gdkvisual-x11.c',
+  'x11/gdkvulkancontext-x11.c',
   'x11/gdkwindow-x11.c',
   'x11/gdkwindow-x11.h',
   'x11/gdkx.h',
@@ -169,6 +170,7 @@ gdk_wayland_sources = files([
   'wayland/gdkscreen-wayland.c',
   'wayland/gdkseat-wayland.h',
   'wayland/gdkselection-wayland.c',
+  'wayland/gdkvulkancontext-wayland.c',
   'wayland/gdkwayland.h',
   'wayland/gdkwaylanddevice.h',
   'wayland/gdkwaylanddisplay.h',
@@ -299,14 +301,16 @@ cdata.set('GTK_MINOR_VERSION', gtk_minor_version)
 cdata.set('GTK_MICRO_VERSION', gtk_micro_version)
 
 
+gdkconfig_cdata = configuration_data()
+gdkconfig_cdata.set('GDK_WINDOWING_X11', x11_enabled)
+gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled)
+gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled)
+gdkconfig_cdata.set('GDK_RENDERING_VULKAN', have_vulkan)
 
-if x11_enabled      cdata.set('GDK_WINDOWING_X11', '')      endif
-if wayland_enabled  cdata.set('GDK_WINDOWING_WAYLAND', '')  endif
-if broadway_enabled cdata.set('GDK_WINDOWING_BROADWAY', '') endif
 gdkconfig = configure_file(
   input  : 'gdkconfig.h.meson',
   output : 'gdkconfig.h',
-  configuration : cdata,
+  configuration : gdkconfig_cdata,
   install_dir: 'include/gtk-4.0/gdk/' # XXX ???
 )
 
@@ -331,7 +335,8 @@ gdk_deps = [
   epoxy_dep,
   fontconfig_dep,
   giounix_dep,
-  pangocairo_dep
+  pangocairo_dep,
+  vulkan_lib
 ]
 
 gdk_sources = [
diff --git a/gsk/meson.build b/gsk/meson.build
index 2a10643..5b2dddd 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -19,36 +19,84 @@ gsk_private_sources = files([
   'gskshaderbuilder.c',
 ])
 
-# FIXME: do we need this variable?
-gsk_sources = gsk_public_sources + gsk_private_sources
-
-gsk_headers = files([
+# FIXME: install gsk_public_headers ?
+gsk_public_headers = files([
   'gskenums.h',
   'gskrenderer.h',
   'gskrendernode.h',
+  'gskroundedrect.h',
+  'gsktexture.h',
   'gsktypes.h',
-  'gskcairorendererprivate.h',
-  'gskdebugprivate.h',
-  'gskgldriverprivate.h',
-  'gskglprofilerprivate.h',
-  'gskglrendererprivate.h',
-  'gskprivate.h',
-  'gskprofilerprivate.h',
-  'gskrendererprivate.h',
-  'gskrendernodeprivate.h',
-  'gskshaderbuilderprivate.h',
 ])
 
+if have_vulkan
+  gsk_private_sources += files([
+    'gskvulkanblendpipeline.c',
+    'gskvulkanborderpipeline.c',
+    'gskvulkanboxshadowpipeline.c',
+    'gskvulkanbuffer.c',
+    'gskvulkanclip.c',
+    'gskvulkancolorpipeline.c',
+    'gskvulkancommandpool.c',
+    'gskvulkaneffectpipeline.c',
+    'gskvulkanlineargradientpipeline.c',
+    'gskvulkanimage.c',
+    'gskvulkanmemory.c',
+    'gskvulkanpipeline.c',
+    'gskvulkanpushconstants.c',
+    'gskvulkanrender.c',
+    'gskvulkanrenderer.c',
+    'gskvulkanrenderpass.c',
+    'gskvulkanshader.c',
+  ])
+
+# FIXME: vulkan shaders
+#gsk_private_vulkan_include_shaders =',
+#  'resources/vulkan/clip.frag.glsl',
+#  'resources/vulkan/clip.vert.glsl',
+#  'resources/vulkan/constants.glsl',
+#  'resources/vulkan/rounded-rect.glsl
+#gsk_private_vulkan_fragment_shaders =',
+#  'resources/vulkan/blend.frag',
+#  'resources/vulkan/border.frag',
+#  'resources/vulkan/color.frag',
+#  'resources/vulkan/color-matrix.frag',
+#  'resources/vulkan/inset-shadow.frag',
+#  'resources/vulkan/linear.frag',
+#  'resources/vulkan/outset-shadow.frag
+#gsk_private_vulkan_vertex_shaders =',
+#  'resources/vulkan/blend.vert',
+#  'resources/vulkan/border.vert',
+#  'resources/vulkan/color.vert',
+#  'resources/vulkan/color-matrix.vert',
+#  'resources/vulkan/inset-shadow.vert',
+#  'resources/vulkan/linear.vert',
+#  'resources/vulkan/outset-shadow.vert
+#gsk_private_vulkan_shaders =',
+#  '$(gsk_private_vulkan_fragment_shaders)',
+#  '$(gsk_private_vulkan_vertex_shaders)
+#gsk_private_vulkan_compiled_shaders =',
+#  '$(gsk_private_vulkan_fragment_shaders:.frag=.frag.spv)',
+#  '$(gsk_private_vulkan_vertex_shaders:.vert=.vert.spv)',
+#  '$(gsk_private_vulkan_fragment_shaders:.frag=-clip.frag.spv)',
+#  '$(gsk_private_vulkan_vertex_shaders:.vert=-clip.vert.spv)',
+#  '$(gsk_private_vulkan_fragment_shaders:.frag=-clip-rounded.frag.spv)',
+#  '$(gsk_private_vulkan_vertex_shaders:.vert=-clip-rounded.vert.spv)
+endif
+
+# FIXME: do we need this variable?
+gsk_sources = gsk_public_sources + gsk_private_sources
+
 gskenum_h = custom_target(
   'gskenum_h',
   output  : 'gskenumtypes.h',
-  input   : gsk_headers,
+  input   : gsk_public_headers,
   command : [mkenum, perl, glib_mkenums, meson.current_source_dir() + '/gskenumtypes.h.template', 
'@OUTPUT@', '@INPUT@'])
 
 gskenum_c = custom_target(
   'gskenum_c',
   output  : 'gskenumtypes.c',
-  input   : gsk_headers,
+  input   : gsk_public_headers,
   depends : gskenum_h,
   command : [mkenum, perl, glib_mkenums, meson.current_source_dir() + '/gskenumtypes.c.template', 
'@OUTPUT@', '@INPUT@'])
 
@@ -74,7 +122,7 @@ libgsk = static_library(
   sources: [gsk_sources, gskenum_h, gskresources],
   dependencies: gsk_deps,
   include_directories: [confinc],
-  c_args: ['-DGSK_COMPILATION'],
+  c_args: ['-DGSK_COMPILATION', '-DG_LOG_DOMAIN="Gsk"'],
 )
 
 libgsk_dep = declare_dependency(
diff --git a/meson.build b/meson.build
index 195d7ed..e07391a 100644
--- a/meson.build
+++ b/meson.build
@@ -271,6 +271,26 @@ if mlib.found()
   cdata.set('HAVE_LIBM', 1)
 endif
 
+# Check for Vulkan support
+# TODO: move to gsk subfolder maybe? Or will it be used elsewhere too?
+have_vulkan = false
+vulkan_lib = []
+enable_vulkan = get_option('enable-vulkan')
+if enable_vulkan != 'no'
+  vulkan_lib = cc.find_library('vulkan', required : false)
+  if vulkan_lib.found() and cc.has_function('vkCreateInstance', dependencies : vulkan_lib) and 
cc.has_header('vulkan/vulkan.h')
+    glslc = find_program('glslc', required : false)
+    if glslc.found()
+      have_vulkan = true
+      # FIXME: -lvulkan needs to go into gtk+-4.0.pc (GDK_EXTRA_LIBS)
+    else
+      error('Need glslc for Vulkan support. See https://github.com/google/shaderc or compile with 
-Denable-vulkan=no')
+    endif
+  endif
+else
+  message('Vulkan support explicitly disabled')
+endif
+
 configure_file(
   input : 'config.h.meson',
   output: 'config.h',
diff --git a/meson_options.txt b/meson_options.txt
index e8f8ee6..ec04443 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,4 @@
 option('enable-x11-backend', type: 'boolean', value: 'true')
 option('enable-wayland-backend', type: 'boolean', value: 'true')
 option('enable-broadway-backend', type: 'boolean', value: 'false')
+option('enable-vulkan', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]