<div class="gmail_quote">On Thu, Sep 30, 2010 at 4:57 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 09/29/2010 07:34 PM, Dave Airlie wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
So I've been playing with stencil writing on r600, and it lead me to<br>
examine the depth writing.<br>
<br>
So at the moment in gallium if we are writing to depth via DrawPixels,<br>
we construct a fragment program that samples from a texture.<br>
<br>
TEX OUT[0].z, IN[1], SAMP[0], 2D<br>
<br>
Now from what I can see the format we pick to sample from is<br>
Z24_UNORM_S8_USCALED, which from the u_format.csv file seems to say it<br>
will put the results into X and Y components.<br>
</blockquote>
<br></div>
I think what the u_format.csv file says isn't totally consistant with what the table at the bottom of tgsi.rst says.<br>
<br>
We never did nail down the Z/Gallium cell in the later table.<br>
<br>
To be consistant with what the u_format.csv file says, I think the tgsi.rgs table needs to be updated to read:<br>
<br>
Texture Comps Gallium OpenGL Direct3D 9<br>
+--------------+--------------+--------------------+--------------+<br>
| Z | (Z, ?, ?, ?) | (z, z, z, 1)* | (0, z, 0, 1) |<br>
+--------------+--------------+--------------------+--------------+<br>
| ZS | (Z, S, ?, ?) | (z, z, z, 1)* | tbd |<br>
+--------------+--------------+--------------------+--------------+<br>
| S | (?, S, ?, ?) | undefined | tbd |<br>
+--------------+--------------+--------------------+--------------+<br>
<br>
What do people think about that?</blockquote><div><br>As was mentioned in the other thread, D3D doesn't allow reading both the
depth and stencil values at the same time. Is there any hardware which
supports that? I would rather split ZS into 2 views:<br><br> Texture Comps Gallium OpenGL Direct3D 9<br>+--------------+--------------+--------------------+--------------+<br>| Z24X8 | (Z, ?, ?, ?) | depth texture mode | tbd |<br>
+--------------+--------------+--------------------+--------------+<br>| X24S8 | (?, S, ?, ?) | undefined | tbd |<br><br>I think this is the case where the format member in pipe_sampler_view should come into play.<br>
<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Now if we sample from<br>
the X and Y components and the texture dest writemask is Z, I can't<br>
see how any value arrives in the right place. It seems to work but I'm<br>
a bit lost where the magic is.<br>
<br>
I'd have expected there to be swizzles in the sampler but I can't see<br>
them being set to anything special either.<br>
</blockquote>
<br></div>
I think we've just been getting lucky by the TEX instructions returning (Z,Z,Z,?).<br>
<br>
If we go with the table changes above, we need to either specify a sampler swizzle or do something like this in the shader:<br>
<br>
TEX TEMP[0].x, IN[1], SAMP[0], 2D<br>
MOV OUT[0].z, TEMP[0].xxxx;<br></blockquote><div><br></div></div>Since the depth texture modes were implemented in st/mesa, you may only get these swizzles in a sampler view for depth textures:<br>(X,X,X,1)<br>(X,X,X,X)<br>
(0,0,0,X)<br>being luminance, intensity, and alpha, respectively. So (Z,?,?,?) is already a valid swizzle for st/mesa, and nothing else uses depth texturing, I guess.<br><br>Marek<br>