GPU shared parameter array size mismatch behavior is broken

Minor issues with the Ogre API that can be trivial to fix
Post Reply
User avatar
lunkhound
Gremlin
Posts: 169
Joined: Sun Apr 29, 2012 1:03 am
Location: Santa Monica, California
x 19

GPU shared parameter array size mismatch behavior is broken

Post by lunkhound »

Suppose I define some shared parameters in a material script like so:

Code: Select all

shared_params shadowParams
{
    // should probably construct this object in code to set the array lengths
    shared_param_named csmSplits float [9]
}
And I have some shader code that declares the parameter like:

Code: Select all

        uniform float csmSplits[4],
The current behavior is that because the array sizes don't match it will silently fail. The shader will see an array of all zeros. There is no exception raised, no warnings in the log, just silent broken-ness.
One obvious fix would be to either throw an exception or log a warning. However, I think an even better solution would be to just work as long as the destination array is less than or equal to the source array, and only throw an exception if the source array is too small.
This would be useful to me because I have a family of shaders which take arrays of different sizes (depending on how many shadow cascades are selected), and it is nice to be able to feed them all from a single set of shared parameters.
Any thoughts or opinions? I already have a patch for my preferred solution.
Post Reply