From f17e835c260e1f49d59d78089c30ab9de87c5278 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 19 May 2015 11:28:08 -0700 Subject: [PATCH] vk/meta: Use glsl_scraper for our GLSL source We are not yet using SPIR-V for meta but this is a first step. --- src/vulkan/Makefile.am | 8 +++++++- src/vulkan/glsl_helpers.h | 8 +++++--- src/vulkan/meta.c | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am index 1010863846a..291171d836a 100644 --- a/src/vulkan/Makefile.am +++ b/src/vulkan/Makefile.am @@ -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 diff --git a/src/vulkan/glsl_helpers.h b/src/vulkan/glsl_helpers.h index e6cd93298ac..2259f890ce1 100644 --- a/src/vulkan/glsl_helpers.h +++ b/src/vulkan/glsl_helpers.h @@ -23,13 +23,15 @@ #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); \ diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index 976a0ee3b6a..77393e24694 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -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) -- 2.30.2