Open devshgraphicsprogramming opened 3 years ago
should I open this against glslang instead?
It is likely a glslang issue.
You don't say what the problem is. I couldn't reproduce an issue.
Here's an example compute shader I tried
#version 450
#define MAXISH(X,Y)((X)<(Y)? (Y):(X))
void main() {
float f = MAXISH(12.0,1.0);
}
This is the output of glslc -E
#version 450
void main(){
float f =((12.0)<(1.0)?(1.0):(12.0));
}
And that compiles into this SPIR-V:
; SPIR-V
; Version: 1.0
; Generator: Google Shaderc over Glslang; 10
; Bound: 10
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
OpSourceExtension "GL_GOOGLE_include_directive"
OpName %main "main"
OpName %f "f"
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%float_12 = OpConstant %float 12
%main = OpFunction %void None %3
%5 = OpLabel
%f = OpVariable %_ptr_Function_float Function
OpStore %f %float_12
OpReturn
OpFunctionEnd
You don't say what the problem is. I couldn't reproduce an issue.
Here's an example compute shader I tried
#version 450 #define MAXISH(X,Y)((X)<(Y)? (Y):(X)) void main() { float f = MAXISH(12.0,1.0); }
This is the output of glslc -E
#version 450 void main(){ float f =((12.0)<(1.0)?(1.0):(12.0)); }
And that compiles into this SPIR-V:
; SPIR-V ; Version: 1.0 ; Generator: Google Shaderc over Glslang; 10 ; Bound: 10 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 OpSource GLSL 450 OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" OpSourceExtension "GL_GOOGLE_include_directive" OpName %main "main" OpName %f "f" %void = OpTypeVoid %3 = OpTypeFunction %void %float = OpTypeFloat 32 %_ptr_Function_float = OpTypePointer Function %float %float_12 = OpConstant %float 12 %main = OpFunction %void None %3 %5 = OpLabel %f = OpVariable %_ptr_Function_float Function OpStore %f %float_12 OpReturn OpFunctionEnd
it not about having the ?
in a macro its about using its results in preprocessing
#define MAXISH(X,Y)((X)<(Y)? (Y):(X))
#if 5==MAXISH(1,5)
#define PASSED
#endif
We're using the
v2020.3
tagI attach the file we're trying to feed into
shaderc
, it doesn't like ourIRR_GLSL_MAX
macro.GCC with the
-E
option consumes it and produces the expected output, feel free to check with godbolt.org postprocessed.comp.txt