<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Woah, wall of e-mails. :-)<br></div><div class="gmail_quote"><br>On Tue, May 9, 2017 at 5:02 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, May 09, 2017 at 02:44:35PM +0300, Pohjolainen, Topi wrote:<br>
> On Tue, May 09, 2017 at 02:36:47PM +0300, Pohjolainen, Topi wrote:<br>
> > On Tue, May 09, 2017 at 02:29:13PM +0300, Pohjolainen, Topi wrote:<br>
> > > On Tue, May 09, 2017 at 08:25:28AM +0300, Pohjolainen, Topi wrote:<br>
> > > > On Mon, May 08, 2017 at 03:31:55PM -0700, Jason Ekstrand wrote:<br>
> > > > > On Wed, May 3, 2017 at 2:22 AM, Topi Pohjolainen <<a href="mailto:topi.pohjolainen@gmail.com">topi.pohjolainen@gmail.com</a><br>
> > > > > > wrote:<br>
> > > > ><br>
> > > > > > Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> > > > > > ---<br>
> > > > > > src/intel/isl/isl_gen7.c | 6 +++++-<br>
> > > > > > 1 file changed, 5 insertions(+), 1 deletion(-)<br>
> > > > > ><br>
> > > > > > diff --git a/src/intel/isl/isl_gen7.c b/src/intel/isl/isl_gen7.c<br>
> > > > > > index 18687b5..cf5b377 100644<br>
> > > > > > --- a/src/intel/isl/isl_gen7.c<br>
> > > > > > +++ b/src/intel/isl/isl_gen7.c<br>
> > > > > > @@ -375,7 +375,11 @@ gen7_choose_valign_el(const struct isl_device *dev,<br>
> > > > > > * FINISHME(chadv): Decide to set valign=4 or valign=8 after isl's<br>
> > > > > > API<br>
> > > > > > * is more polished.<br>
> > > > > > */<br>
> > > > > > - require_valign4 = true;<br>
> > > > > > +<br>
> > > > > > + /* Using valign 4 upsets all depthstencil-render-miplevels on IVB<br>
> > > > > > and<br>
> > > > > > + * HSW. Use alignment 8 instead.<br>
> > > > > > + */<br>
> > > > > > + return 8;<br>
> > > > > ><br>
> > > > ><br>
> > > > > I'm confused. This seems to contradict the documentation which says that<br>
> > > > > valign for depth is hard-coded to 4 in the hardware.<br>
> > > ><br>
> > > > Just as I am. It took me a while to actually try increasing the alignment - it<br>
> > > > was just after I compared what the current logic in i965 does. The thing here<br>
> > > > is not the alignment itself but the amount of space that gets allocated. I'll<br>
> > > > get back with more details shortly.<br>
> > ><br>
> > > In intel_miptree_set_alignment() we have:<br>
> > ><br>
> > > } else if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > > mt->halign = 8;<br>
> > > mt->valign = brw->gen >= 7 ? 8 : 4;<br>
> > > } else {<br>
> > ><br>
> > > There are a few refactors it seems but I'll try to find the original commit.<br>
> ><br>
> > Well that looks to go a long way back to a file named intel_tex_layout.c.<br>
> > Some documentation is still left:<br>
> ><br>
> > /**<br>
> > * +-----------------------------<wbr>------------------------------<wbr>-----------+<br>
> > * | | alignment unit height ("j") |<br>
> > * | Surface Property |-----------------------------<wbr>|<br>
> > * | | 915 | 965 | ILK | SNB | IVB |<br>
> > * +-----------------------------<wbr>------------------------------<wbr>-----------+<br>
> > * | BC1-5 compressed format (DXTn/S3TC) | 4 | 4 | 4 | 4 | 4 |<br>
> > * | FXT1 compressed format | 4 | 4 | 4 | 4 | 4 |<br>
> > * | Depth Buffer | 2 | 2 | 2 | 4 | 4 |<br>
> > * | Separate Stencil Buffer | N/A | N/A | N/A | 4 | 8 |<br>
> > * | Multisampled (4x or 8x) render target | N/A | N/A | N/A | 4 | 4 |<br>
> > * | All Others | 2 | 2 | 2 | * | * |<br>
> > * +-----------------------------<wbr>------------------------------<wbr>-----------+<br>
> > *<br>
> > * Where "*" means either VALIGN_2 or VALIGN_4 depending on the setting of<br>
> > * the SURFACE_STATE "Surface Vertical Alignment" field.<br>
> > */<br>
> ><br>
> > Original included also a reference to bspec:<br>
> ><br>
> > * From the "Alignment Unit Size" section of various specs, namely:<br>
> > * - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4<br>
> > * - i965 and G45 PRMs: Volume 1, Section 6.17.3.4.<br>
> > * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4<br>
> > * - BSpec (for Ivybridge and slight variations in separate stencil)<br>
> ><br>
> ><br>
><br>
> Original commit:<br>
><br>
> commit e7e81714f3ecf67a975d35e74bdb7f<wbr>d15d924e4d<br>
> Author: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> Date: Mon Nov 7 15:58:43 2011 -0800<br>
><br>
> i965: Implement the actual tables for texture alignment units [v2]<br>
><br>
> I implemented functions for horizontal/vertical alignment units separately<br>
> because I find it easier to read that way...especially with all the<br>
> corner-cases.<br>
><br>
> [chad] Corrected the vertical alignment calculation by checking for<br>
> depthstencil formats.<br>
><br>
> v2:<br>
> - Fix typos in intel_horizontal_texture_<wbr>alignment_unit():<br>
> s/height/width/ and s/VALIGN/HALIGN.<br>
> - Remove special case for compressed formats in<br>
> intel_get_texture_alignment unit(). Compressed formats are already<br>
> handled in the halign and valign functions.<br>
> - Replace check ``_mesa_is_depth_format(...) ||<br>
> _mesa_is_depthstencil_format(.<wbr>..)`` with explcitit checks against<br>
> GL_DEPTH_COMPONENT and GL_DEPTH_STENCIL.<br>
><br>
> Reviewed-by: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
> Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> Signed-off-by: Chad Versace <<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>><br>
><br>
<br>
</div></div>And digging PRMs:<br>
<br>
<a href="https://01.org/sites/default/files/documentation/ivb_ihd_os_vol1_part1.pdf" rel="noreferrer" target="_blank">https://01.org/sites/default/<wbr>files/documentation/ivb_ihd_<wbr>os_vol1_part1.pdf</a><br>
<br>
6.18.4.4 Alignment Unit Size<br>
<br>
This section documents the alignment parameters i and j that are used<br>
depending on the surface.<br>
<br>
surface defined by surface format unit width “i” unit height “j”<br>
<br>
3DSTATE_STENCIL_BUFFER N/A 8 8<br>
</blockquote></div><br></div><div class="gmail_extra">Reading things a bit more, chad's comment there is entirely bunk. The fact that you have to multiply pitch by 2 is, in my understanding, completely unrelated to the halign/valign parameters used for texture layout. Well, not completely unrelated. W-tiling is just Y-tiling with a bit of extra swizzling which turns 8x8 W-tiled chunks into 16x4 y-tiled chunks so it makes everything easier in hardware if miplevels are always aligned to 8x8. The fact that RENDER_SURFACE_STATE::SurfaceVerticalAlignmet doesn't have a VALIGN_8 option doesn't matter since this is SNB and you can't do stencil texturing anyway.<br><br></div><div class="gmail_extra">Let's believe the docs and call it 8. We should also delete most of chad's comment while we're at it. Better yet, for gen8 I copied the table out of the PRM and made it a nicely formatted comment. Maybe we should do the same for gen7 and get rid of Chad's comment entirely?<br><br></div><div class="gmail_extra">As a further side-note, I don't think I like the way the alignment getter fuctions work today all that much. I'll send out an RFC patch that I think makes things better.<br><br></div><div class="gmail_extra">--Jason<br></div></div>