[Mesa-dev] Re mesa/st: add tgsi-lowering code for depth-clamp

Gert Wollny gert.wollny at collabora.com
Fri Aug 2 17:25:40 UTC 2019


Am Donnerstag, den 01.08.2019, 07:22 -0400 schrieb Ilia Mirkin:
> Hey Gert,
> 
> I'm looking at 
> https://cgit.freedesktop.org/mesa/mesa/commit/?id=b048d8bf8f056759d1845a799d4ba2ac84bce30f
> , which attempts to implement depth clamping (rather than clipping)
> with shader tricks.
> 
> You're forcing the final vertex stage's position's depth to 0, and
> then making up for it in the frag shader with an extra varying.
> However won't this screw up the barycentric coordinates for
> perspective interpolation? i.e. won't you effectively always just get
> noperspective interp everywhere as a result?
That is probably true, I was following @kumas lead [1], in fact
he implemented the initial version of this code, and I only fixed it up
for ARB_clip_control and GS and TES shaders. 

One fix I could think is maybe clamp the z value to the clip range [-1, 
1] or [0,1] depending on the clip control z accuracy, so that the error
only happens only for the clamped areas where the result is distorted
anyway, what do you think? 

Best, 
Gert 
 

[1] 
https://stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv

> 
>   -ilia
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list