Hi.!
Using the GL3Plus render system and when looking at the GpuNamedConstants of various programs I can see there are unused uniforms that haven't been optimised out. So whats going on here is it something I've got wrong, or does this not happen yet in alpha?
glsl shader not optimised
-
- Gremlin
- Posts: 196
- Joined: Tue Aug 08, 2006 6:45 pm
- x 14
Re: glsl shader not optimised
Well I see now if I try a glsl in the old GL render system I get the same thing, unused uniform variables not optimised out, and appearing in the list of GpuNamedConstants. I was hoping to use those as a list and auto-magically set auto params and texture links based on texture unit state names matching shader values... but thats not going to work as things stand.
The solution is to only have the params you need and nothing but the params you need, but to do that I'm going to have to wrap them up with complicated and messy #if blah || blah, and those could change when I change a bit of shader code that ends up really confusing, if you do cg to glsl you get rid of any unused params, I was sort of expecting GLSL to do something similar, it doesn't sadly.
So I guess codes optimised but ogre doesn't get a peek at it? so if I did a texture lookup and didn't use the result it gets optimised out and it wouldn't end up in the assembly code but ogres got no way of knowing that, and that texture I didn't need appears in GpuNamedConstants, not an easy to solve problem.
if the ^ is accurate, what happens when I set uniform params that aren't actually used by the shader say I have a g_viewport_size and its not actually used anywhere but none the less appears in GpuNamedConstants and gets set, does just ... nothing happen?
I'm starting to think he uber shader approach I've been using in cg is flawed in glsl and I need to go the RTSS route and keep track of exactly which uniforms I use.
The solution is to only have the params you need and nothing but the params you need, but to do that I'm going to have to wrap them up with complicated and messy #if blah || blah, and those could change when I change a bit of shader code that ends up really confusing, if you do cg to glsl you get rid of any unused params, I was sort of expecting GLSL to do something similar, it doesn't sadly.
So I guess codes optimised but ogre doesn't get a peek at it? so if I did a texture lookup and didn't use the result it gets optimised out and it wouldn't end up in the assembly code but ogres got no way of knowing that, and that texture I didn't need appears in GpuNamedConstants, not an easy to solve problem.
if the ^ is accurate, what happens when I set uniform params that aren't actually used by the shader say I have a g_viewport_size and its not actually used anywhere but none the less appears in GpuNamedConstants and gets set, does just ... nothing happen?
I'm starting to think he uber shader approach I've been using in cg is flawed in glsl and I need to go the RTSS route and keep track of exactly which uniforms I use.