Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


GL_FRAGMENT_SHADER_DERIVATIVE_HINT Is this useful anymore?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 RenHoek   Members   -  Reputation: 119

Like
0Likes
Like

Posted 17 July 2013 - 10:01 PM

GL_FRAGMENT_SHADER_DERIVATIVE_HINT

This hint apparently enables high quality ( or low quality ) derivatives in fragement shaders.

 

Does anyone know if this actually does _anything_ on modern hardware?

( eg Nvidia cards etc... )

 

Anybody know anything about this hint?

I see very little discussion about it anywhere on the internet.  :(

 

Thanks!

Ren

 



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 32053

Like
2Likes
Like

Posted 18 July 2013 - 12:15 AM

In GPU Pro 2, there's a chapter called "Shader Amortization using Pixel Quad Message Passing", which explains how you can use the derivative functions to communicate between different instances of a pixel shader function, which allows for certain kinds of optimisations to be made.

I've personally used this technique to output to a R10_G10_B10_A2 render target, as if it was a full-resolution R10_G10_B10 target and a half-resolution A8 target, which was pretty useful.

 

Back to the point, this kind of inter-pixel communication is only possible with "high quality" derivatives. With "low quality" derivatives, only 3 out of every 4 pixels can communicate, with 1 out of 4 pixels being isolated and unable to talk to the others in it's "2x2 quad".

 

As far as I know, there's no way to query the hardware to see whether "low" or "high" quality derivatives are the default... You can only discover this by attempting to use one of these communication algorithms, and then reading the results to see if it worked or not.

I guess that if you wanted to use one of these techniques, you could first use the GL hint to kindly request "high" quality derivatives, and then test if your algorithm works, to increase your chances.

 

n.b. as of DX10/GL3 level hardware, all GPUs support both "low" and "high" quality modes (HLSL has different instructions for each, with the old "dFdx" type instructions being a "don't care" option).



#3 RenHoek   Members   -  Reputation: 119

Like
0Likes
Like

Posted 18 July 2013 - 02:43 AM


Back to the point, this kind of inter-pixel communication is only possible with "high quality" derivatives. With "low quality" derivatives, only 3 out of every 4 pixels can communicate, with 1 out of 4 pixels being isolated and unable to talk to the others in it's "2x2 quad".

 

Wow.   Ok.   Yes, this is was I was after.  :)

Acknowledgement that there actually _are_ different levels of derivative "quality" on modern hardware.

 

I help author a high-end tool which runs on the most modern of cards.  We're very quality concious ( rather than speed ).

So I'm going to set this hint to HighQuality regardless in our app from now on.

 

Question:

I know derivatives are used to select mip-map levels during texturing.

Do you know what happens if a polygon occupies only 1 pixel on screen?   ( or even 2x1 )

Any idea what the derivatives will give in that scenario?  And what mip-map level will be chosen?

 

Thanks!

Ren



#4 Hodgman   Moderators   -  Reputation: 32053

Like
0Likes
Like

Posted 18 July 2013 - 03:37 AM

Do you know what happens if a polygon occupies only 1 pixel on screen?   ( or even 2x1 )
Any idea what the derivatives will give in that scenario?  And what mip-map level will be chosen?
 

The hardware is designed to always run the shader on 2x2 "quads" of pixels. If a triangle only covers part of a "quad", e.g. 1 pixel, then the GPU will actually execute the shader 4 times so that derivatives are still valid, but not actually use the results for 3 pixels.
Due to this design, extremely tesselated models (which cause pixel-sized triangles) actually reduce your pixel shading efficiency.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS