Closed
Description
Hi,
Blender developer here. Currently we are developing our Vulkan back-end. We use intensively macros to be able to cross compile between OpenGL/Vulkan/Metal and also for migrating between internal feature sets.
When compiling the next vertex shader using glslc fails. For now we are using
shaderc v2021.3 v2021.3
spirv-tools v2021.4 v2021.4
glslang 11.1.0-316-g600c5037
To reproduce you can use glslc -fshader-stage=vertex ./vertex.glsl to validate the error.
./vertex.glsl:68: error: '' : syntax error, unexpected LEFT_PAREN, expecting IDENTIFIER
I did search for similar issues, but didn't see them. Sorry if I added a new one by mistake or has already been resolved up-stream.
#version 450
#define drw_view drw_view_[drw_view_id]
/* Single-view case (default). */
#define drw_view_id 0
#define DRW_VIEW_LEN 1
#define DRW_VIEW_SHIFT 0
struct ViewMatrices {
mat4 viewmat;
mat4 winmat;
};
#define ViewMatrix drw_view.viewmat
#define ProjectionMatrix drw_view.winmat
/** \} */
/* Pass Resources. */
layout(binding = 0, std140) uniform drw_view_ {
ViewMatrices _drw_view_[DRW_VIEW_LEN];
};
#define drw_view_ (_drw_view_)
/* Push Constants. */
layout(push_constant) uniform constants {
vec3 pPosition;
float pSize;
vec4 pColor;
}
PushConstants;
#define pPosition (PushConstants.pPosition)
#define pSize (PushConstants.pSize)
#define pColor (PushConstants.pColor)
/* Inputs. */
layout(location = 0) in vec3 pos;
/* Interfaces. */
layout(location = 0) out flat vec4 finalColor;
/** Transform shortcuts. */
/* Rule of thumb: Try to reuse world positions and normals because converting
* through viewspace will always be decomposed in at least 2 matrix operation.
*/
#define point_world_to_ndc(p) (ProjectionMatrix * (ViewMatrix * vec4(p, 1.0)))
void main() {
#if 0
/* Use local variable to workaround macro unrolling issue in Spir-V. */
vec3 pos = pPosition;
gl_Position = point_world_to_ndc(pos);
#else
/* Unrolling fails when unrolling with
./vertex.glsl:69: error: '' : syntax error, unexpected LEFT_PAREN, expecting
IDENTIFIER.
shaderc v2021.3 v2021.3
spirv-tools v2021.4 v2021.4
glslang 11.1.0-316-g600c5037
Target: SPIR-V 1.0
*/
gl_Position = point_world_to_ndc(pPosition);
#endif
finalColor = pColor;
gl_PointSize = pSize;
}Metadata
Assignees
Labels
No labels