Cost of a simple texture-access

Hi there

In a shader i (theoretically) want to fetch a material-value from a texture. However some objects won´t have such a material, so that it´s value will always be 1 or 0.
Now, instead of writing another shader (and of course switching between lots of only slightly different shaders), i can also bind a “dummy”-texture, which is plain white or black.

Of course such a texture would only be 2x2, or so. So, how expensive is such texture-access ? Should i expect the same performance hit, as if i used a bigger texture, or should it be very fast ?

Thanks,
Jan.

Originally posted by Jan:
Of course such a texture would only be 2x2, or so. So, how expensive is such texture-access ? Should i expect the same performance hit, as if i used a bigger texture, or should it be very fast ?

If you use a very small texture (like 2x2) every access to it will go to the GPU’s caches so you won’t use much bandwidth. On the other hand you will still be consuming some fill-rate so depending on the hardware there will be a decrease in performance albeit small.

You know the answer Jan: benchmark it!

There’s no other way to know really. Unless your pixel shader limited and have many texture sampling instructions, I doubt it would make much difference to performance, but it’s impossible to know without testing. The shaders I’ve written are mostly math bound, not texture op bound, but this obviously varies depending on app.

Hi,
Texture binding can be a slow-down factor if you use many textures (thousands). But if you consolidate your 2x2 textures into a larger one, like 128x128, you wouldn’t spend much time with the binding.