intel: Fix stencil buffer to be W tiled
PATCH v2 1/1 intel: Fix stencil buffer to be W tiled
Patch 1 v2:
- Change buffer height from ALIGN(height / 2, 64) to
ALIGN((height + 1) / 2, 64).
Patch 2 v2:
- Change buffer height from ALIGN(height / 2, 64) to
ALIGN((height + 1) / 2, 64).
- Change return type of intel_offset_S8 changed to intptr_t.
- Improve performance of Y_FLIP.
- Remove XXX comment in intel_alloc_renderbuffer_storage.
xf86-video-intel
dri: Do not tile stencil buffer
src/intel_dri.c | 16 ++++++++++++----
mesa
intel: Fix stencil buffer to be W tiled
src/mesa/drivers/dri/intel/intel_clear.c | 6 ++
src/mesa/drivers/dri/intel/intel_context.c | 9 ++-
src/mesa/drivers/dri/intel/intel_fbo.c | 12 ++--
src/mesa/drivers/dri/intel/intel_screen.h | 9 ++-
src/mesa/drivers/dri/intel/intel_span.c | 88 +++++++++++++++++++++-------
5 files changed, 93 insertions(+), 31 deletions(-)
Signature · 1 line
1.7.6
PATCH 1/1 dri: Do not tile stencil buffer
Until now, the stencil buffer was allocated as a Y tiled buffer, because in several locations the PRM states that it is. However, it is actually W tiled. From the PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Format:
W-Major Tile Format is used for separate stencil.
The GTT is incapable of W fencing, so we allocate the stencil buffer with I915_TILING_NONE and decode the tile's layout in software.
This commit mutually depends on the mesa commit:
intel: Fix stencil buffer to be W tiled
Author: Chad Versace <[email protected]>
Date: Mon Jul 18 00:37:45 2011 -0700
--- src/intel_dri.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
src/intel_dri.c +12 -4
@@ -335,7 +335,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,switch (attachment) {case DRI2BufferDepth:case DRI2BufferDepthStencil: -case DRI2BufferStencil:case DRI2BufferHiz:if (SUPPORTS_YTILING (intel)) { hint |=INTEL_CREATE_PIXMAP_TILING_Y ;
@@ -350,6 +349,14 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,case DRI2BufferFrontRight: hint |=INTEL_CREATE_PIXMAP_TILING_X ;break ; +case DRI2BufferStencil: +/* +* The stencil buffer is W tiled. However, we +* request from the kernel a non-tiled buffer +* because the GTT is incapable of W fencing. +*/ + hint |=INTEL_CREATE_PIXMAP_TILING_NONE ; +break ;default :free (privates);free (buffer);
@@ -367,11 +374,12 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,* To accomplish this, we resort to the nasty hack of doubling * the drm region's cpp and halving its height. * -* If we neglect to double the pitch, then -* drm_intel_gem_bo_map_gtt() maps the memory incorrectly. +* If we neglect to double the pitch, then render corruption +* occurs. */ if (attachment == DRI2BufferStencil) { - pixmap_height /=2 ; + pixmap_width =ALIGN (pixmap_width,64 ); + pixmap_height =ALIGN ((pixmap_height +1 ) /2 ,64 ); pixmap_cpp *=2 ; }
Signature · 1 line
1.7.6
Re: [PATCH] dri: Do not tile stencil buffer
Quoted 14 lines · Chad Versace
Until now, the stencil buffer was allocated as a Y tiled buffer, because in several locations the PRM states that it is. However, it is actually W tiled. From the PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Format:
W-Major Tile Format is used for separate stencil.The GTT is incapable of W fencing, so we allocate the stencil buffer with
I915_TILING_NONEand decode the tile's layout in software.This commit mutually depends on the mesa commit:
intel: Fix stencil buffer to be W tiled
Author: Chad Versace <[email protected]>
Date: Mon Jul 18 00:37:45 2011 -0700
Quoted 7 lines
CC Eric Anholt <[email protected]>CC Kenneth Graunke <[email protected]>CC Ian Romancik <[email protected]>Signed-off-by Chad Versace <[email protected]>--- src/intel_dri.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
For the series:
(I would say Reviewed-by, but I haven't verified the math. That said, I don't think I need to...I've seen how rigorously you investigated this.)
Happy to see these go in whenever. We definitely need them in 7.11 and 2.16.
PATCH 1/1 intel: Fix stencil buffer to be W tiled
In reply to Chad VersaceUntil now, the stencil buffer was allocated as a Y tiled buffer, because in several locations the PRM states that it is. However, it is actually W tiled. From the PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Format:
W-Major Tile Format is used for separate stencil.
The GTT is incapable of W fencing, so we allocate the stencil buffer with I915_TILING_NONE and decode the tile's layout in software.
This fix touches the following portions of code:
- In intel_allocate_renderbuffer_storage(), allocate the stencil buffer with I915_TILING_NONE.
- In intel_verify_dri2_has_hiz(), verify that the stencil buffer is not tiled.
- In the stencil buffer's span functions, the tile's layout must be decoded in software.
This commit mutually depends on the xf86-video-intel commit
dri: Do not tile stencil buffer
Author: Chad Versace <[email protected]>
Date: Mon Jul 18 00:38:00 2011 -0700
On Gen6 with separate stencil enabled, fixes the following Piglit tests:
bugs/fdo23670-drawpix_stencil
general/stencil-drawpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX16-copypixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX16-drawpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX16-readpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX1-copypixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX1-drawpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX1-readpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX4-copypixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX4-drawpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX4-readpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX8-copypixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX8-drawpixels
spec/EXT_framebuffer_object/fbo-stencil-GL_STENCIL_INDEX8-readpixels
spec/EXT_packed_depth_stencil/fbo-stencil-GL_DEPTH24_STENCIL8-copypixels
spec/EXT_packed_depth_stencil/fbo-stencil-GL_DEPTH24_STENCIL8-readpixels
spec/EXT_packed_depth_stencil/readpixels-24_8Note: This is a candidate for the 7.11 branch.
--- src/mesa/drivers/dri/intel/intel_clear.c | 6 ++ src/mesa/drivers/dri/intel/intel_context.c | 9 ++- src/mesa/drivers/dri/intel/intel_fbo.c | 12 ++-- src/mesa/drivers/dri/intel/intel_screen.h | 9 ++- src/mesa/drivers/dri/intel/intel_span.c | 88 +++++++++++++++++++++------- 5 files changed, 93 insertions(+), 31 deletions(-)
src/mesa/drivers/dri/intel/intel_clear.c +6 -0
@@ -143,6 +143,12 @@ intelClear(struct gl_context *ctx, GLbitfield mask)*/ tri_mask |=BUFFER_BIT_STENCIL ; } +else if (intel->has_separate_stencil && + stencilRegion->tiling ==I915_TILING_NONE ) { +/* The stencil buffer is actually W tiled, which the hardware +* cannot blit to. */ + tri_mask |=BUFFER_BIT_STENCIL ; + }else {/* clearing all stencil bits, use blitting */ blit_mask |=BUFFER_BIT_STENCIL ;
src/mesa/drivers/dri/intel/intel_context.c +7 -2
@@ -1439,7 +1439,12 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,assert (stencil_rb->Base.Format ==MESA_FORMAT_S8 );assert (depth_rb && depth_rb->Base.Format ==MESA_FORMAT_X8_Z24 ); -if (stencil_rb->region->tiling ==I915_TILING_Y ) { +if (stencil_rb->region->tiling ==I915_TILING_NONE ) { +/* +* The stencil buffer is actually W tiled. The region's tiling is +* I915_TILING_NONE, however, because the GTT is incapable of W +* fencing. +*/ intel->intelScreen->dri2_has_hiz =INTEL_DRI2_HAS_HIZ_TRUE ;return ; }else {
@@ -1527,7 +1532,7 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,* Presently, however, no verification or clean up is necessary, and * execution should not reach here. If the framebuffer still has a hiz * region, then we have already set dri2_has_hiz to true after -* confirming above that the stencil buffer is Y tiled. +* confirming above that the stencil buffer is W tiled. */ assert (0 ); }
src/mesa/drivers/dri/intel/intel_fbo.c +7 -5
@@ -173,6 +173,9 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbufferif (irb->Base.Format ==MESA_FORMAT_S8 ) {/* +* The stencil buffer is W tiled. However, we request from the kernel a +* non-tiled buffer because the GTT is incapable of W fencing. +* * The stencil buffer has quirky pitch requirements. From Vol 2a, * 11.5.6.2.1 3DSTATE_STENCIL_BUFFER, field "Surface Pitch": * The pitch must be set to 2x the value computed based on width, as
@@ -180,14 +183,13 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer* To accomplish this, we resort to the nasty hack of doubling the drm * region's cpp and halving its height. * -* If we neglect to double the pitch, then drm_intel_gem_bo_map_gtt() -* maps the memory incorrectly. +* If we neglect to double the pitch, then render corruption occurs. */ irb->region =intel_region_alloc (intel->intelScreen, -I915_TILING_Y , +I915_TILING_NONE , cpp *2 , - width, - height /2 , +ALIGN (width,64 ), +ALIGN ((height +1 ) /2 ,64 ),GL_TRUE );if (!irb->region)return false;
src/mesa/drivers/dri/intel/intel_screen.h +6 -3
@@ -63,9 +63,12 @@* x8_z24 and s8). * * Eventually, intel_update_renderbuffers() makes a DRI2 request for -* DRI2BufferStencil and DRI2BufferHiz. If the returned buffers are Y tiled, -* then we joyfully set intel_screen.dri2_has_hiz to true and continue as if -* nothing happend. +* DRI2BufferStencil and DRI2BufferHiz. If the stencil buffer's tiling is +* I915_TILING_NONE [1], then we joyfully set intel_screen.dri2_has_hiz to +* true and continue as if nothing happend. +* +* [1] The stencil buffer is actually W tiled. However, we request from the +* kernel a non-tiled buffer because the GTT is incapable of W fencing. * * If the buffers are X tiled, however, the handshake has failed and we must * clean up.
src/mesa/drivers/dri/intel/intel_span.c +67 -21
105 lines not on this page · raw message
Signature · 1 line
1.7.6