On 22 May 2012 10:15, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 05/21/2012 07:16 PM, Paul Berry wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
On 21 May 2012 18:00, Ian Romanick <<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a><br></div><div>
<mailto:<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>>> wrote:<br>
<br>
On 05/11/2012 11:03 AM, Paul Berry wrote:<br>
<br>
This patch modifies the "blorp" WM program so that it can be run in<br>
MSDISPMODE_PERSAMPLE (which means that every single sample of a<br>
multisampled render target is dispatched to the WM program, not just<br>
every pixel).<br>
<br>
Previously we were using the ugly hack of configuring multisampled<br>
destination surfaces as single-sampled, and generating sample<br>
indices<br>
other than zero by swizzling the pixel coordinates in the WM<br>
program.<br>
---<br></div>
src/mesa/drivers/dri/i965/brw_<u></u>__blorp.h | 12 ++++<br>
src/mesa/drivers/dri/i965/brw_<u></u>__blorp_blit.cpp | 87<br>
+++++++++++++++++++-------<br>
src/mesa/drivers/dri/i965/__<u></u>gen6_blorp.cpp | 5 +-<br>
src/mesa/drivers/dri/i965/__<u></u>gen7_blorp.cpp | 10 ++-<div><br>
4 files changed, 87 insertions(+), 27 deletions(-)<br>
<br></div>
diff --git a/src/mesa/drivers/dri/i965/__<u></u>brw_blorp.h<br>
b/src/mesa/drivers/dri/i965/__<u></u>brw_blorp.h<br>
index f14a5c7..b911356 100644<br>
--- a/src/mesa/drivers/dri/i965/__<u></u>brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/__<u></u>brw_blorp.h<div><div><br>
@@ -132,6 +132,12 @@ const unsigned int<br>
BRW_BLORP_NUM_PUSH_CONST_REGS =<br>
struct brw_blorp_prog_data<br>
{<br>
unsigned int first_curbe_grf;<br>
+<br>
+ /**<br>
+ * True if the WM program should be run in<br>
MSDISPMODE_PERSAMPLE with more<br>
+ * than one sample per pixel.<br>
+ */<br>
+ bool persample_msaa_dispatch;<br>
<br>
<br>
(Forgive my ignorance about this general area of the code.)<br>
Per-sample shading is also a feature of some later OpenGL version.<br>
Is the low-level infrastructure architected so that we could<br>
enable this for general use?<br>
<br>
<br>
This patch wouldn't get in the way of enabling per-sample shading for<br>
general use, but it wouldn't really facilitate it either, since this is<br>
just using per-sample shading for blits.<br>
<br>
Enabling per-sample shading for general use should be pretty<br>
straightforward. If I'm not mistaken, all we will need to do is:<br>
<br>
- Add the front-end API to allow the client to request per-sample<br>
shading (I assume it's glEnable(GL_HAM_SANDWICH) or something like that,<br>
in which case it should be easy)<br>
<br>
- Set the MSDISPMODE_PERSAMPLE bit gen{6,7}_wm_state.c (easy).<br>
<br>
- Modify the code that configures barycentric interpolation modes so<br>
that we can interpolate smooth and noperspective varyings to the sample<br>
location rather than to the pixel center or the centroid. This will be<br>
the hardest part, because it will require modifying the fragment shader<br>
back-end interpolation code to point to the appropriate barycentric<br>
coordinates depending whether per-sample shading is enabled or not. But<br>
I already had to make a similar change to implement the "flat" keyword,<br>
and I'll have to do something similar very soon for "centroid", so I'm<br>
not terribly worried. I'll try to keep this feature in mind when I'm<br>
implementing "centroid" so that I don't paint us into a corner.<br>
<br>
If time allows, I might could roll this feature in with implementing<br>
"centroid", but I won't make any guarantees because I don't want to<br>
delay centroid interpolation at the expense of a future feature. Would<br>
you mind pointing me to the relevant text in the GL spec so that I can<br>
read up on it and make sure I'm not missing any subtleties?<br>
</div></div></blockquote>
<br>
Olivier hit most of the high points. The spec is:<br>
<br>
<a href="http://www.opengl.org/registry/specs/ARB/sample_shading.txt" target="_blank">http://www.opengl.org/<u></u>registry/specs/ARB/sample_<u></u>shading.txt</a><br>
</blockquote></div><br>Thanks for the ref. Looking at the spec, it looks like there would be a bit more work to do to fully implement the extension:<br><br>- Add the gl_SampleID variable to GLSL, and write back-end code to populate it (should be fairly straightforward)<br>
- Add the gl_SamplePosition variable to GLSL, and write back-end code to populate it (a bit more work; I think we have to set some additional flags in 3DSTATE_WM to get this info)<br>- Add the gl_SampleMask[] variable to GLSL, and write back-end support for it (ugh, this is going to require some tricky bit swizzling I think*)<br>
- Add the gl_NumSamples mask to GLSL, and write back-end support for it (a bit of work since I'm less familiar with how uniforms work)<br><br>*However, it's possible that I'm going to need to do a lot of this work anyway to implement the alpha-to-coverage stuff.<br>
<br>On balance I no longer think it's worth trying to roll this extension in with the initial MSAA implementation. There's just a bit too much work to do.<br><br>Also, this extension will be *a lot* easier to test after we've implemented ARB_texture_multisample, because ARB_texture_multisample gives the ability for client programs to directly query individual samples.<br>
<br>So I'm going to back burner ARB_sample_shading for now.<br>