Shader_Minifier
Shader_Minifier copied to clipboard
subroutine
I'm trying to get Shader_Minifier working with a GLSL 450 shader using subroutines. Simplified example:
#version 450
layout(location=0) out vec4 f_color;
subroutine float functionType(int i);
layout(location = 0) subroutine uniform functionType tbl[2];
layout(index = 1) subroutine (functionType) float func1(int i) {
return i * 1.0/255.0;
}
layout(index = 2) subroutine (functionType) float func2(int i) {
return 1.0 - i * 1.0/255.0;
}
void main() {
float a = tbl[0](64);
float b = tbl[1](64);
f_color = vec4(a, b, 0, 1);
}
This is the output after my little hack-fix (read below):
#version 450
layout(location=0)out vec4 f;
layout(location=0)subroutine uniform functionType v[2];
layout(index = 1) subroutine (functionType) float t(int f){return f/255.;}
layout(index = 2) subroutine (functionType) float s(int f){return 1.-f/255.;}
void main(){float i=v[0](64),n=v[1](64);f=vec4(i,n,0,1);}
- For functions,
subroutine (functionType)fails to parse. I managed to hack this into the parser, eventually. - Shader_Minifier drops the function type declaration.
I would have been happy to send a PR, but I've never written one line of F# ever before, so I'm a little lost here. :)