Ok so premise to this question - I have been combing through my glsl code looking for ways to optimize it. I am exploring the potential of a bandwidth bottleneck vs a computational bottleneck, and am trying some things to see if anything helps. I feel like some of these are obvious questions to the seasoned graphics programmer, but I don’t know for sure so wanted to get some other input.
For the sake of simplicity, I’ll ignore shader MAT’s and just use a 10x10 glsl TOP as an example.
Also will assume that sampling a texture is done with texelFetch(). so no multi sample stuff is happening via texture().
First with Samplers - My understanding of them is that each fragment must sample an input texture even if the information is the same, or if the input texture is small with say only 1 pixel.
So, for a texture that is 10x10 pixels in size, a glsl shader performs 100 sampling calls.
Moving on to the Vectors page, we can specify a name, and up to a vec4 as an input.
My understanding here, is that a uniform value is much faster / more efficient because only 1 value is uploaded to the shader, and the shader does not need to sample from another texture 100 times, it already has this value in memory.
On the third tab, there are Arrays. Again, like Vectors my understanding here is that these are very efficient too because the data is uploaded once, and referenced many times once in memory. No sampling a bunch of times.
- Does this change when we switch the array type to Texture Buffer instead of Uniform Array?
Lastly, the Matricies tab - which is where most of my confusion lies, and where I think I am looking for clarity the most.
- Are these setup the same way as Vectors and Arrays, faster because everything is uploaded at once?
- Is there a difference between the plain Matrix input, vs the Xform from and To inputs?
- Is there a practical limit or hard limit to how many times the “+” button can be pressed adding more matricies?
- Are matrix inputs faster than supplying a sequence of 16 values via the Arrays tab?