[ 2020.20020 - x64 - Win10 ] Very specific lines of code seem to crash GLSL TOP with no errors

Beyond super weird, not getting errors in the info DAT with this bug, the glsl TOP just simply stops updating internally, even if there are parameters in uniforms causing the node itself to cook every frame.

Basically, the gist of what I’m doing is comparing two values to each other, value A sampled from a chop, value B sampled from a top input.

I then take that comparison (using ==) and convert it to a float(), then in some way write it out to the buffer.

The part that makes it even more strange, is there is several very specific edge cases that when also met either make it work, or make it not work.

For instance, if you disconnect one of the top inputs (the second one for instance, isn’t even being sampled) it begins to work again, or if you specify a texture input index via a variable vs a raw integer, etc. this causes it to stop working.

Here’s the entire code from the glsl:

uniform samplerBuffer Proj_Params;
uniform float selectionPulse;


out vec4 fragColor;
void main()
{

	// just initializing some things.
	vec4 color = vec4(0.0);
	float asdFloat = 0.2;

	// notice I'm providing the index to "sTD2DInputs" using this int. If you place an int, like 0 into
	// the brackets below.. the glsl code starts to work again.
	int inputID = 0;

	// all that's happening here is I'm sampling a value from a chop input, and another value from a top input,
	// then comparing the two using "==" and then converting that resulting boolean to a float.
	asdFloat = float( texelFetch( Proj_Params , 35 ).x == texture( sTD2DInputs[ inputID ], vec2( 0.5 , 0.5 ) ).x );
	///////////// try commenting out the above line, the glsl code will start working magically. ///////////////////


	// just writing stuff out so we can see it.
	color.r += selectionPulse *.5;
	color.g = asdFloat;
	fragColor = TDOutputSwizzle(color);
}

I’ve made ample notes, and attached a file.
theStrangestGLSLBug.2.toe (10.5 KB)

Hi, @lucasm
It’s very strange.
I’ve tried to solve inputID problem.
So I set inputID to uniform value.
Then it works.
Hmm, what’s happend.

theStrangestGLSLBug.2.toe (10.5 KB)

Hi and thank you @atsonic, ya the example I uploaded was maybe a little too simplified, as some of the constraints of my actual task was not obvious. inputID is an int that needed to be set dynamically in for loops and such. @timgerritsen had a similar suggestion to yours, but to make a uniform called ZERO, which is always set to 0, and just add it to the inputID, which forces the compiler to compile it differently I think. Smart move!

I would have not thought to try a uniform in the process of troubleshooting like this, as I didn’t know the compiler interpreted those differently. Thank you both for the suggestion, that is a good one to remember for future issues. :slight_smile:

I should say for the devs - this may not be a touchdesigner bug, but more a glsl bug.
Maybe a useful post for others who run across something similar though.

uniform samplerBuffer Proj_Params;
uniform float selectionPulse;
uniform int uZero;

out vec4 fragColor;
void main()
{

    // just initializing some things.
    vec4 color = vec4(0.0);
    float asdFloat = 0.2;

    // notice I'm providing the index to "sTD2DInputs" using this int. If you place an int, like 0 into
    // the brackets below.. the glsl code starts to work again.
    int inputID = 0;

    // all that's happening here is I'm sampling a value from a chop input, and another value from a top input,
    // then comparing the two using "==" and then converting that resulting boolean to a float.
    asdFloat = float( texelFetch( Proj_Params , 35 ).x == texture( sTD2DInputs[ inputID + uZero], vec2( 0.5 , 0.5 ) ).x );
    ///////////// try commenting out the above line, the glsl code will start working magically. ///////////////////


    // just writing stuff out so we can see it.
    color.r += selectionPulse *.5;
    color.g = asdFloat;
    fragColor = TDOutputSwizzle(color);
}
2 Likes