So, to begin with a bit of backstory, I’m building a graphics engine for a game engine that I am making via following some youtube video series. Upon getting to use of texture arrays and being able to use multiple textures at once/batch rendering textures this error occured. Originally this error manifested as Nvoglv32.dll requiring Nvoglv32.pdb to debug. However, after checking my uniforms I managed to discover that the issue was due to one of them. But, this left me with the current crashing issue. I’m certain theres something wrong with the array of samplers I am trying to use, but I’m unsure. The program only crashes upon a specific line in the shader, removal of this allows me to render a none textured sprite manually quite happily.
The exact line that the crash occurs is, texColor = texture(textures[tid], fs_in.uv);
As far as I can see the tid (texture ID) being passed in from my renderer is properly assigned to the textures that I’m trying to use. Using the tid value in the bottom color set also incurrs the same crash as trying to use the array of samplers. Any help into if I’m doing anything wrong would be greatly appreciated. Also, if I need to provide more code please say so.
Samplers aggregated into arrays within a shader (using square brackets [ ]) can only be indexed with integral constant expressions
For later versions, the restriction is relaxed somewhat (§4.1.7.1):
When aggregated into arrays within a shader, samplers can only be indexed with a dynamically uniform integral expression, otherwise results are undefined.
But this still doesn’t allow what you’re trying to do.
If the texture ID can vary between fragments within a single primitive, then you cannot use an array of samplers in this way; you need to use an array texture instead. If the texture ID is constant for each primitive, and you’re willing to limit yourself to more recent versions of GLSL, then you can add the “flat” qualifier to [var]tid[/var], which will make the expression dynamically-uniform.
Hm, I see. Heres a link to the video with the exact same shader as I’m using, that works (a bit later on after he fixes a couple of things). Also, from what I understand the idea of this is that one primitive gets one texture ID across all the fragments for the primitive.
I gave this a go and I still get crashes, however with the help of a friend I have narrowed it down to being within my flush() function that is in my batch renderer, the crash occurs at a call to glDrawElements() which is leaving me back at square one with no clue as to why it’s crashing.
(I attempted to include the flush() function here but kept getting told my post was denied)
You tried with putting your code between [ code] and [ /code] statements (without any spaces in between) ?
I guess you need few posts before you’re able to use all the tools this forums provides.
[QUOTE=Silence;1284397]You tried with putting your code between [ code] and [ /code] statements (without any spaces in between) ?
I guess you need few posts before you’re able to use all the tools this forums provides.[/QUOTE]
I did that in my first post. Not sure why it wouldn’t let me do it again.