vk/meta: Use glsl_scraper for our GLSL source
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 19 May 2015 18:28:08 +0000 (11:28 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 21 May 2015 18:39:54 +0000 (11:39 -0700)
We are not yet using SPIR-V for meta but this is a first step.

src/vulkan/Makefile.am
src/vulkan/glsl_helpers.h
src/vulkan/meta.c

index 1010863846a2e405d729c700bf6ae4b28ae82e71..291171d836a95e52e96a6f6d11815c0821c575f9 100644 (file)
@@ -70,7 +70,10 @@ libvulkan_la_SOURCES =                               \
        formats.c                               \
        compiler.cpp
 
-BUILT_SOURCES = entrypoints.h entrypoints.c
+BUILT_SOURCES =                                        \
+       entrypoints.h                           \
+       entrypoints.c                           \
+       meta-spirv.h
 
 entrypoints.h : vk_gen.py $(vulkan_include_HEADERS)
        $(AM_V_GEN)cat $(vulkan_include_HEADERS) | $(PYTHON2) $< header > $@
@@ -78,6 +81,9 @@ entrypoints.h : vk_gen.py $(vulkan_include_HEADERS)
 entrypoints.c : vk_gen.py $(vulkan_include_HEADERS)
        $(AM_V_GEN)cat $(vulkan_include_HEADERS) | $(PYTHON2) $< code > $@
 
+%-spirv.h: %.c glsl_scraper.py
+       $(AM_V_GEN) $(PYTHON2) $(srcdir)/glsl_scraper.py --glsl-only -o $@ $<
+
 CLEANFILES = entrypoints.h entrypoints.c
 
 bin_PROGRAMS = vk
index e6cd93298aca7cd9aa7d458383bbf3e4a2766fc5..2259f890ce13e1bd076724131aca0471f52ba090 100644 (file)
 
 #pragma once
 
+#define _GLSL_SRC_VAR2(_line) _glsl_helpers_shader ## _line ## _glsl_src
+#define _GLSL_SRC_VAR(_line) _GLSL_SRC_VAR2(_line)
+
 #define GLSL_VK_SHADER(device, stage, ...) ({                           \
    VkShader __shader;                                                   \
-   const char __src[] = "#version 330\n" #__VA_ARGS__;                  \
    VkShaderCreateInfo __shader_create_info = {                          \
       .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,                    \
-      .codeSize = sizeof(__src),                                        \
-      .pCode = __src,                                                   \
+      .codeSize = sizeof(_GLSL_SRC_VAR(__LINE__)),                      \
+      .pCode = _GLSL_SRC_VAR(__LINE__),                                 \
       .flags = (1 << 31) /* GLSL back-door hack */                      \
    };                                                                   \
    anv_CreateShader((VkDevice) device, &__shader_create_info, &__shader); \
index 976a0ee3b6a623873effd138edc2603a8d3ba232..77393e24694348c2fca4d2aa8df97b3427c834b0 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "private.h"
 #include "glsl_helpers.h"
+#include "meta-spirv.h"
 
 static void
 anv_device_init_meta_clear_state(struct anv_device *device)