vk/glsl_helpers: Fix GLSL_VK_SHADER with respect to commas
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 16 May 2015 05:17:05 +0000 (22:17 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 16 May 2015 05:17:07 +0000 (22:17 -0700)
Previously, the GLSL_VK_SHADER macro didn't work if the shader contained
commas outside of parentheses due to the way the C preprocessor works.
This commit fixes this by making it variadic again and doing it correctly
this time.

src/vulkan/glsl_helpers.h

index 76b0cbebcf457aa0513ca2ab378869d74008c1e8..3c72523586f626bdf1a91e2d1545ffb6b866a8f1 100644 (file)
@@ -23,9 +23,9 @@
 
 #pragma once
 
-#define GLSL_VK_SHADER(device, stage, source) ({                        \
+#define GLSL_VK_SHADER(device, stage, ...) ({                           \
    VkShader __shader;                                                   \
-   const char __src[] = "#version 330\n" #source;                       \
+   const char __src[] = "#version 330\n" #__VA_ARGS__;                  \
    VkShaderCreateInfo __shader_create_info = {                          \
       .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,                    \
       .codeSize = sizeof(__src),                                        \