Suggestion for a new OpenGL extension ?


I saw on twitter that some GL extension suggestions are actually being worked at so I had this interesting idea today and thought I’d share it in the hopes that it could end up in GL.

I have a slight problem with my reflection pass, as in I need to have code like :

if (pixel.y < reflection_plane)

and I know discards are really a bummer for performance, and I don’t want to make my projection matrix oblique either because the next step is to make full cubemap reflections and render from 6 sides.

So i thought about an optimization to this scenario, where I want to cut on the conditionals inside a pixel shader. If I could basically compare all 3 vertices Y with the reflection plane I could know at the start of the Pixel Shader that the conditional above is always false !

So in effect, you can use the vertex (or geometry) shader to cut down on pixel shader conditionals because you could determine if they’re always true or always false.

I thought about how I would implement this and only subroutines come to mind. But, I think that subroutines still keep all the instructions related to all code paths. I did a subroutine test a while ago and having separate shaders was faster than having 3-4 subroutines with 2 separate paths each with just a singe draw call (versus multiple draw calls and multiple shaders).

So the only way this could actually bring true performance benefits would be if you could select on a per vertex or per primitive basis the pixel shader. I think it could be done by just adding another type of uniform similar to the subroutines that could actually hold different shaders, you load them up with glUniform(Shaders), declare an array of them in the shader, and make new vertex/geometry shader outputs in which you can write what shader uniform should be executed.

I know it sounds like a GL 5 or DX13 feature but I really think it would enable a whole new array of rendering techniques and performance increases, not to mention the possiblity of rendering the entire scene while keeping a shader index per primitive.