summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-05-21 11:59:29 -0700
committerJason Ekstrand <[email protected]>2015-05-21 12:24:02 -0700
commitccf2bf9b99573e0091b956fd0e3a23991f11e86c (patch)
tree34abb0adf9ab73946a4fb998ffbb9a3045be6748 /src/vulkan
parentf3d70e4165d34cb4306a1205fcee41e1ed17635c (diff)
vk/test: Use the glsl_scraper for building shaders
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/Makefile.am3
-rw-r--r--src/vulkan/vk.c34
2 files changed, 11 insertions, 26 deletions
diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am
index 291171d836a..ec670c00f6a 100644
--- a/src/vulkan/Makefile.am
+++ b/src/vulkan/Makefile.am
@@ -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 > $@
diff --git a/src/vulkan/vk.c b/src/vulkan/vk.c
index 8d112bba54a..ea21ece78a8 100644
--- a/src/vulkan/vk.c
+++ b/src/vulkan/vk.c
@@ -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,