<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 5, 2016 at 9:11 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Oct 5, 2016 at 7:05 PM, Xu, Randy <span dir="ltr"><<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi, Jason<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Do you want to add this assert in the patch? I did some test, no issue found, but I don’t see the case that we need override the texture target in brw_emit_surface_state,
 i.e. surf.dim_layout != dim_layout<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">How can we create this case?  And we may need another patch to solve the issue as it’s a new corner case.</span></p></span></div></div></blockquote><div><br></div><div>I believe we can only hit that case if we render to it and use a render target read.  You probably can hit that case but it'll be a bit tricky to trigger.  On second thought, I don't think an assert is right.  Instead, I think we probably need to get the tile_x/y from intel_miptree_get_tile_offsets and then add that to tile_x and tile_y.  I don't think we can ever end up in the case where we have tile offsets coming in from EGL *and* we have a non-zero base_level or base-array_layer.  In fact, we should probably assert as much.<span class="HOEnZb"><font color="#888888"><br></font></span></div></div></div></div></blockquote><div><br></div><div>Never mind... Now that I think about it, I don't think that case is possible.  I think the only time we'll have a tile offset coming in from outside via an EGL image is if the texture is 2D.  In that case, we won't hit the surf.dim_layout != dim_layout case and we should be fine.  I think just the assert that you have below will do.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><span class="HOEnZb"><font color="#888888"></font></span></div><span class="HOEnZb"><font color="#888888"><div>--Jason<br></div></font></span><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Randy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">index 3a5c573..d727526 100644<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">--- a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">+++ b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">@@ -109,6 +109,7 @@ brw_emit_surface_state(struct brw_context *brw,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">        */<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">       assert(brw->has_surface_tile_o<wbr>ffset);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">       assert(view.levels == 1 && view.array_len == 1);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">+      assert(tile_x == 0 && tile_y == 0);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">       offset += intel_miptree_get_tile_offsets<wbr>(mt, view.base_level,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                              <wbr>                  view.base_array_layer,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Jason Ekstrand [mailto:<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>]
<br>
<b>Sent:</b> Thursday, October 6, 2016 1:58 AM<br>
<b>To:</b> Xu, Randy <<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>><br>
<b>Cc:</b> Palli, Tapani <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>>; <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a></span></p><div><div><br>
<b>Subject:</b> Re: [Mesa-dev] [PATCH 1/3] i965: solve cubemap negative x/y/z faces buffer offset issue in dEQP.<u></u><u></u></div></div><p></p><div><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Randy,<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I hadn't realized that we could get images in from EGL where we have a non-zero tile_x and tile_y offset for layer 0 mip 0.  That explains things.  In that case, I believe this is the correct patch.  That said,
 I would like to see an "assert(tile_x == 0 && tile_y == 0)" right before we do the intel_miptree_get_tile_offset(<wbr>) in the case below.  I don't think those can ever happen at the same time, but if they do, I want to know.<u></u><u></u></p>
</div>
<p class="MsoNormal">--Jason<u></u><u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Oct 4, 2016 at 5:13 PM, Xu, Randy <<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi, Jason & Tapani</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks for your review, let me introduce the dEQP failure first.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">In dEQP-EGL.functional.image.crea<wbr>te.gles2_cubemap_negative_*_<wbr>texture, 2D textures are generated from
 all 6 faces of a Cubemap texture (64x64), and then rendered through glDrawXXX.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">In brw_miptree_get_vertical_slice<wbr>_pitch, the mt->qpitch is counted as 144.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">      return h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->valign;                             // 64+32+12*4
 = 144</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Take the face negative_x for example, the total offset in bo is 144(y)*64(x)*4(bpp) = 36864.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">It’s TILING_Y buffer, as the y (144) is not 32 aligned (mask_y = 31 from intel_region_get_tile_masks),
 the total bo offset is divided into two parts: 36864 =  32768 (offset 128*64*4) + 16(tile_y)*64*4</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">   case I915_TILING_Y:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">      *mask_x = 128 / cpp - 1;</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">      *mask_y = 31;</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Both the tile_y and offset are passed to texture2D in create_mt_for_dri_image, while the tile_y is
 not used to count the total offset in rendering path, that’s why I add this patch.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Please check and comment more.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Randy
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Jason Ekstrand [mailto:<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>]
<br>
<b>Sent:</b> Tuesday, October 4, 2016 11:59 PM<br>
<b>To:</b> Palli, Tapani <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>><br>
<b>Cc:</b> Xu, Randy <<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>>;
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><wbr>;
<a href="mailto:Xu@freedesktop.org" target="_blank">Xu@freedesktop.org</a><br>
<b>Subject:</b> Re: [Mesa-dev] [PATCH 1/3] i965: solve cubemap negative x/y/z faces buffer offset issue in dEQP.</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Oct 4, 2016 at 8:55 AM, Tapani Pälli <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<div>
<div>
<p class="MsoNormal">On 10/04/2016 06:09 PM, Jason Ekstrand wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal">On Thu, Sep 29, 2016 at 11:27 PM, Xu,Randy <<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">Add the miptree level/slice x/y_offset when count the surface offset<br>
in brw_emit_surface_state. The surface offset has two parts, one is<br>
from mt->offset, which should be 32 aligned in width/height for tiled<br>
buffer; another is from mt->level[current_level].slice<wbr>[current_slice].<br>
x/y_offset.<br>
<br>
This fix will solve 12 deqp failure<br>
dEQP-EGL.functional.image.crea<wbr>te.gles2_cubemap_negative_*_<wbr>texture<br>
<br>
Signed-off-by: Xu,Randy <<a href="mailto:randy.xu@intel.com" target="_blank">randy.xu@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw<wbr>_wm_surface_state.c | 3 ++-<br>
 1 file changed, 2 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
index 61a4b94..3a5c573 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
@@ -85,7 +85,8 @@ brw_emit_surface_state(struct brw_context *brw,<br>
                        unsigned read_domains, unsigned write_domains)<br>
 {<br>
    const struct surface_state_info ss_info = surface_state_infos[brw->gen];<br>
-   uint32_t tile_x = 0, tile_y = 0;<br>
+   uint32_t tile_x = mt->level[0].slice[0].x_offset<wbr>;<br>
+   uint32_t tile_y = mt->level[0].slice[0].y_offset<wbr>;<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">This isn't correct.  First off, there are some fairly strict restrictions on what we can do with tile_x and tile_y and we can't just shove x/y_offset in there.  We need to use intel_miptree_get_tile_offsets
 to get both a byte offset and an intratile offset.  Second, we should already be taking slices into account for cube maps via base_array_layer where needed.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Unfortunately, I'm not 100% sure what the correct patch is without a bit more information about what the test is doing that causes a problem.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">I did take a brief look and when running the set mentioned above (for example with ./deqp-egl --deqp-case=*<a href="http://EGL.functional.im">EGL.functional.im</a><wbr>age.create.gles2_cubemap_negat<wbr>ive_*_texture) what happens
 is that we never end up to the part of code calling intel_miptree_get_tile_offsets in that function (because surf.dim_layout != dim_layout condition does not trigger). This is just what I observed, should we just call intel_miptree_get_tile_offsets<wbr>() unconditionally
 then?<u></u><u></u></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">No.  Very much no.  The intel_miptree_get_tile_offsets<wbr>() stuff is a hack that lets us convert non-2D things to 2D things and it comes with piles of restrictions.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<div>
<p class="MsoNormal">--Jason<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">    uint32_t offset = mt->offset;<br>
<br>
    struct isl_surf surf;<br>
<span style="color:#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a></span><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <u></u><u></u></p>
<pre>______________________________<wbr>_________________<u></u><u></u></pre>
<pre>mesa-dev mailing list<u></u><u></u></pre>
<pre><a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><u></u><u></u></pre>
<pre><a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><u></u><u></u></pre>
</blockquote>
<p> <u></u><u></u></p>
</div>
</blockquote>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>

</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>