Skip to contentSkip to conversation

i965: Make intel_emit_linear_blit handle Gen8+ alignment restrictions.

PATCH Daniel Vetter 4 participants 4 messages May 6, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Kenneth Graunke

The BLT engine on Gen8+ requires linear surfaces to be cacheline aligned. This restriction was added as part of converting the BLT to use 48-bit addressing.

intel_emit_linear_blit needs to handle blits that are not cacheline aligned, as we use it for arbitrary glBufferSubData calls and subrange mappings.

Quoted 7 lines

Since intel_emit_linear_blit uses 1 byte per pixel, we can use the src/dst pixel X offset field to represent the unaligned portion, and subtract that from the address so it's cacheline aligned.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88521

s/cacheline/page/ afaik, and nope it's not documented. Chris&Mika learned that the hard way. Adding them to correct me in case I make a mess again. -Daniel

Quoted 64 lines
---
 src/mesa/drivers/dri/i965/intel_blit.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
src/mesa/drivers/dri/i965/intel_blit.c +14 -8
index 4993f60..98d414c 100644
@@ -524,6 +524,7 @@ intel_emit_linear_blit(struct brw_context *brw,
 {
    struct gl_context *ctx = &brw->ctx;
    GLuint pitch, height;
+   int16_t src_x, dst_x;
    bool ok;
 
    /* The pitch given to the GPU must be DWORD aligned, and
@@ -532,11 +533,13 @@ intel_emit_linear_blit(struct brw_context *brw,
     */
    pitch = ROUND_DOWN_TO(MIN2(size, (1 << 15) - 1), 4);
    height = (pitch == 0) ? 1 : size / pitch;
+   src_x = src_offset % 64;
+   dst_x = dst_offset % 64;
    ok = intelEmitCopyBlit(brw, 1,
-			  pitch, src_bo, src_offset, I915_TILING_NONE,
-			  pitch, dst_bo, dst_offset, I915_TILING_NONE,
-			  0, 0, /* src x/y */
-			  0, 0, /* dst x/y */
+			  pitch, src_bo, src_offset - src_x, I915_TILING_NONE,
+			  pitch, dst_bo, dst_offset - dst_x, I915_TILING_NONE,
+			  src_x, 0, /* src x/y */
+			  dst_x, 0, /* dst x/y */
 			  pitch, height, /* w, h */
 			  GL_COPY);
    if (!ok)
@@ -544,15 +547,18 @@ intel_emit_linear_blit(struct brw_context *brw,
 
    src_offset += pitch * height;
    dst_offset += pitch * height;
+   src_x = src_offset % 64;
+   dst_x = dst_offset % 64;
    size -= pitch * height;
    assert (size < (1 << 15));
    pitch = ALIGN(size, 4);
+
    if (size != 0) {
       ok = intelEmitCopyBlit(brw, 1,
-			     pitch, src_bo, src_offset, I915_TILING_NONE,
-			     pitch, dst_bo, dst_offset, I915_TILING_NONE,
-			     0, 0, /* src x/y */
-			     0, 0, /* dst x/y */
+			     pitch, src_bo, src_offset - src_x, I915_TILING_NONE,
+			     pitch, dst_bo, dst_offset - dst_x, I915_TILING_NONE,
+			     src_x, 0, /* src x/y */
+			     dst_x, 0, /* dst x/y */
 			     size, 1, /* w, h */
 			     GL_COPY);
       if (!ok)
Signature · 6 lines
2.3.5

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Kenneth Graunke

The BLT engine on Gen8+ requires linear surfaces to be cacheline aligned. This restriction was added as part of converting the BLT to use 48-bit addressing.

intel_emit_linear_blit needs to handle blits that are not cacheline aligned, as we use it for arbitrary glBufferSubData calls and subrange mappings.

Since intel_emit_linear_blit uses 1 byte per pixel, we can use the src/dst pixel X offset field to represent the unaligned portion, and subtract that from the address so it's cacheline aligned.

Quoted 6 lines
Quoted 3 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88521

s/cacheline/page/ afaik, and nope it's not documented. Chris&Mika learned that the hard way. Adding them to correct me in case I make a mess again.

It's cacheline.

Issue: if the 1st pixel in XY_SRC_COPY is not CL aligned when SRC or DST are linear that will cause failure.

https://vthsd.fm.intel.com/hsd/bdwgfx/bug_de/default.aspx?bug_de_id=1912704
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 21 lines · Chris Wilson
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Kenneth Graunke

The BLT engine on Gen8+ requires linear surfaces to be cacheline aligned. This restriction was added as part of converting the BLT to use 48-bit addressing.

intel_emit_linear_blit needs to handle blits that are not cacheline aligned, as we use it for arbitrary glBufferSubData calls and subrange mappings.

Since intel_emit_linear_blit uses 1 byte per pixel, we can use the src/dst pixel X offset field to represent the unaligned portion, and subtract that from the address so it's cacheline aligned.

Quoted 6 lines
Quoted 3 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88521

s/cacheline/page/ afaik, and nope it's not documented. Chris&Mika learned that the hard way. Adding them to correct me in case I make a mess again.

Quoted 8 lines

It's cacheline.

Issue: if the 1st pixel in XY_SRC_COPY is not CL aligned when SRC or DST are linear that will cause failure.

https://vthsd.fm.intel.com/hsd/bdwgfx/bug_de/default.aspx?bug_de_id=1912704
-Chris

FWIF, I ended up doing it like this in igt:

http://lists.freedesktop.org/archives/intel-gfx/2015-January/059191.html

And I think the documentation was updated on the restrictions.

-Mika
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 32 lines · Mika Kuoppala
Quoted 21 lines · Chris Wilson
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Kenneth Graunke

The BLT engine on Gen8+ requires linear surfaces to be cacheline aligned. This restriction was added as part of converting the BLT to use 48-bit addressing.

intel_emit_linear_blit needs to handle blits that are not cacheline aligned, as we use it for arbitrary glBufferSubData calls and subrange mappings.

Since intel_emit_linear_blit uses 1 byte per pixel, we can use the src/dst pixel X offset field to represent the unaligned portion, and subtract that from the address so it's cacheline aligned.

Quoted 6 lines
Quoted 3 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88521

s/cacheline/page/ afaik, and nope it's not documented. Chris&Mika learned that the hard way. Adding them to correct me in case I make a mess again.

Quoted 8 lines

It's cacheline.

Issue: if the 1st pixel in XY_SRC_COPY is not CL aligned when SRC or DST are linear that will cause failure.

https://vthsd.fm.intel.com/hsd/bdwgfx/bug_de/default.aspx?bug_de_id=1912704
-Chris

Quoted 7 lines

FWIF, I ended up doing it like this in igt:

http://lists.freedesktop.org/archives/intel-gfx/2015-January/059191.html

And I think the documentation was updated on the restrictions.

-Mika

Yeah, I saw the updated documentation, remembered that Chris warned me about this a while back (I think I just said "ugh" and promptly forgot about it), and finally fixed Mesa. It's all upstream and working now.

Huge thanks for tracking this down and getting it documented!

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx