Re: [Mesa-dev] The ARB_shader_subroutine extension

2014-11-18 Thread Ian Romanick
On 11/16/2014 08:31 AM, Gustaw Smolarczyk wrote:
 Hello once again,
 
 This time, I would like to ask about the shader subroutine extension.
 I believe this extension is not very popular, but is still needed for
 GL4 compliance.
 
 What is the reason for its unpopularity?
 Is it because one needs to reset subroutine uniform values after any glUse*?
 Or it just didn't provide enough value?
 Wouldn't it be good to implement uber-shaders (especially using
 subroutine uniform array)?

It has a very strong negative affect on register allocation.  Basically,
the compiler has to, at the very least, allocate registers for the
worst subroutine.  This means that subroutines that use fewer
registers will often perform worse (on some GPUs much, much worse) than
they should.  On Intel GPUs this means that you might just get SIMD8 for
a shader that could have had SIMD16.  I've been told that on AMD GPUs it
means you have much fewer vertices or pixels executing in parallel
leading to dramatic performance hits.

 Is anybody actively working on it? I guess, there are changes needed
 in the GLSL compiler. It could be easily lowered to a
 switch-on-uniform-int thing, or something like that, if only
 compliance to the GL4 matters and not the performance.
 
 Regards,
 Gustaw
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] The ARB_shader_subroutine extension

2014-11-18 Thread Gustaw Smolarczyk
Yeah, I understand this concern. But this could be said about any
uber-shader approach. For cases when one cannot afford to change
shader program in between draw calls (using features like multi draw
indirect), it should be better to use shader subroutine arrays instead
of a switch. If the difference in register pressure between the
simplest and the most complex subroutine is not that large, the
problem you described wouldn't exist. One can always batch draw calls
with very simple subroutines separately.

It would be great if there was a possibility to change *the whole*
program for a given draw, so that renderings with simple shaders
wouldn't be penalized by the artificial register pressure caused by
the dynamically unused paths. But I guess, the hardware is unable to
implement such a feature.

2014-11-18 19:51 GMT+01:00 Ian Romanick i...@freedesktop.org:
 On 11/16/2014 08:31 AM, Gustaw Smolarczyk wrote:
 Hello once again,

 This time, I would like to ask about the shader subroutine extension.
 I believe this extension is not very popular, but is still needed for
 GL4 compliance.

 What is the reason for its unpopularity?
 Is it because one needs to reset subroutine uniform values after any glUse*?
 Or it just didn't provide enough value?
 Wouldn't it be good to implement uber-shaders (especially using
 subroutine uniform array)?

 It has a very strong negative affect on register allocation.  Basically,
 the compiler has to, at the very least, allocate registers for the
 worst subroutine.  This means that subroutines that use fewer
 registers will often perform worse (on some GPUs much, much worse) than
 they should.  On Intel GPUs this means that you might just get SIMD8 for
 a shader that could have had SIMD16.  I've been told that on AMD GPUs it
 means you have much fewer vertices or pixels executing in parallel
 leading to dramatic performance hits.

 Is anybody actively working on it? I guess, there are changes needed
 in the GLSL compiler. It could be easily lowered to a
 switch-on-uniform-int thing, or something like that, if only
 compliance to the GL4 matters and not the performance.

 Regards,
 Gustaw
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] The ARB_shader_subroutine extension

2014-11-16 Thread Chris Forbes
Hi Gustaw,

My understanding is that it's a combination of the awkward API, and
dubious value. It's certainly not something that everyone is screaming
for.

As far as mesa's implementation goes, I started on the parser changes
and tests a while ago; I believe Ian was going to pick it up. I'm not
sure whether he's had time to do much on it though.

-- Chris

On Mon, Nov 17, 2014 at 5:31 AM, Gustaw Smolarczyk wielkie...@gmail.com wrote:
 Hello once again,

 This time, I would like to ask about the shader subroutine extension.
 I believe this extension is not very popular, but is still needed for
 GL4 compliance.

 What is the reason for its unpopularity?
 Is it because one needs to reset subroutine uniform values after any glUse*?
 Or it just didn't provide enough value?
 Wouldn't it be good to implement uber-shaders (especially using
 subroutine uniform array)?

 Is anybody actively working on it? I guess, there are changes needed
 in the GLSL compiler. It could be easily lowered to a
 switch-on-uniform-int thing, or something like that, if only
 compliance to the GL4 matters and not the performance.

 Regards,
 Gustaw
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev