You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However when I do this I realise the behaviour is inconsistent: sometimes my glsl functions are suffixed with their types (for example vec2 getPosition(float index, float length) gets renamed to getPosition_float_float in the emitted Javascript) and sometimes they are not (they are not overloaded, at least not the ones I am currently testing). Whether they are renamed or not depends on evaluation order: the first compilation has no suffixes and subsequent compilations have some, at least from what I have seen.
As a workaround I simply call GLSL each time I want to compile, then my glsl functions are never renamed, but I don't know if this is the intended behaviour.
I usually run the same shader with different static variables (to be used in loops for example) which I inject with a simple template and find/replace logic, so the same functions are compiled multiple times:
// with the aforementioned workaroundexportconstcompile=(shaderStr,map={})=>GLSL({uniform: name=>`uniforms.${name}`,attribute: name=>`attributes.${name}`})(replaceMap(shaderStr,map))constreplaceMap=(str,map)=>{returnstr.replace(newRegExp(Object.keys(map).join("|"),"gi"),function(match){returnString(map[match]);});}
Hope this is useful to you. Even without reusing the compile function I don't have to complain about performance, so this is not a pressing issue but it's a little weird.
tchuss
The text was updated successfully, but these errors were encountered:
Hi @geoffreytools!
The thing is all 500+ tests are using single GLSL instance and never produce artifacts that you mention, and tbh I don't know where that may be coming from, so I am afraid without more specific reproduction case I won't be able to help.
I just tested what you showed and it works fine:
Hey,
I am using glsl_transpiler with great effect to unit test my shaders and something puzzles me.
After reading the readme I got this impression that I could reuse the function
compile
that is returned by GLSL, like so:However when I do this I realise the behaviour is inconsistent: sometimes my glsl functions are suffixed with their types (for example
vec2 getPosition(float index, float length)
gets renamed togetPosition_float_float
in the emitted Javascript) and sometimes they are not (they are not overloaded, at least not the ones I am currently testing). Whether they are renamed or not depends on evaluation order: the first compilation has no suffixes and subsequent compilations have some, at least from what I have seen.As a workaround I simply call
GLSL
each time I want to compile, then my glsl functions are never renamed, but I don't know if this is the intended behaviour.I usually run the same shader with different static variables (to be used in loops for example) which I inject with a simple template and find/replace logic, so the same functions are compiled multiple times:
Hope this is useful to you. Even without reusing the compile function I don't have to complain about performance, so this is not a pressing issue but it's a little weird.
tchuss
The text was updated successfully, but these errors were encountered: