vk/test: Use the glsl_scraper for building shaders
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 21 May 2015 18:59:29 +0000 (11:59 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 21 May 2015 19:24:02 +0000 (12:24 -0700)
src/vulkan/Makefile.am
src/vulkan/vk.c

index 291171d836a95e52e96a6f6d11815c0821c575f9..ec670c00f6a4926eacdcd3374aa36fdebe8ec0fe 100644 (file)
@@ -73,7 +73,8 @@ libvulkan_la_SOURCES =                                \
 BUILT_SOURCES =                                        \
        entrypoints.h                           \
        entrypoints.c                           \
-       meta-spirv.h
+       meta-spirv.h                            \
+       vk-spirv.h
 
 entrypoints.h : vk_gen.py $(vulkan_include_HEADERS)
        $(AM_V_GEN)cat $(vulkan_include_HEADERS) | $(PYTHON2) $< header > $@
index 8d112bba54a0ad3323b66398780f0102be9ca583..ea21ece78a809274a008c18a26f4a304b596458d 100644 (file)
@@ -13,6 +13,8 @@
 #include <poll.h>
 #include <libpng16/png.h>
 
+#include "vk-spirv.h"
+
 #define for_each_bit(b, dword)                          \
    for (uint32_t __dword = (dword);                     \
         (b) = __builtin_ffs(__dword) - 1, __dword;      \
@@ -100,7 +102,7 @@ create_pipeline(VkDevice device, VkPipeline *pipeline,
       .primitiveRestartIndex = 0
    };
 
-   static const char vs_source[] = GLSL(
+   VkShader vs = GLSL_VK_SHADER(device, VERTEX,
       layout(location = 0) in vec4 a_position;
       layout(location = 1) in vec4 a_color;
       layout(set = 0, binding = 0) uniform block1 {
@@ -117,36 +119,18 @@ create_pipeline(VkDevice device, VkPipeline *pipeline,
       {
         gl_Position = a_position;
         v_color = a_color + u1.color + u2.color + u3.color;
-      });
+      }
+   );
 
-   static const char fs_source[] = GLSL(
+   VkShader fs = GLSL_VK_SHADER(device, FRAGMENT,
       out vec4 f_color;
       in vec4 v_color;
       layout(set = 0, binding = 0) uniform sampler2D tex;
       void main()
       {
-         f_color = v_color + texture2D(tex, vec2(0.1, 0.1));
-      });
-
-   VkShader vs;
-   vkCreateShader(device,
-                  &(VkShaderCreateInfo) {
-                     .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
-                     .codeSize = sizeof(vs_source),
-                     .pCode = vs_source,
-                     .flags = 0
-                  },
-                  &vs);
-
-   VkShader fs;
-   vkCreateShader(device,
-                  &(VkShaderCreateInfo) {
-                     .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
-                     .codeSize = sizeof(fs_source),
-                     .pCode = fs_source,
-                     .flags = 0
-                  },
-                  &fs);
+         f_color = v_color + texture(tex, vec2(0.1, 0.1));
+      }
+   );
 
    VkPipelineShaderStageCreateInfo vs_create_info = {
       .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,