Re: [Mesa-dev] [PATCH 16/41] intel: Replace intel_texture_image::stencil_irb with intel_mipmap_tree::stencil_mt

2011-11-18 Thread Eric Anholt
On Thu, 17 Nov 2011 19:58:43 -0800, Chad Versace chad.vers...@linux.intel.com 
wrote:
 For depthstencil textures using separate stencil, we embedded a stencil
 buffer in intel_texture_image. The intention was that the embedded stencil
 buffer would be the golden copy of the texture's stencil bits. When
 necessary, we scattered/gathered the stencil bits between the texture
 miptree and the embedded stencil buffer.
 
 This approach had a serious deficiency for mipmapped or multi-layer
 textures. Any given moment the embedded stencil buffer was consistent with
 exactly one miptree slice, the most recent one to be scattered. This
 permitted tests of type A to pass, but broke tests of type B.
 
 Test A:
 1. Create a depthstencil texture.
 2. Upload data into (level=x1,layer=y1).
 3. Read and test stencil data at (level=x1, layer=y1).
 4. Upload data into (level=x2,layer=y2).
 5. Read and test stencil data at (level=x2, layer=y2).
 
 Test B:
 1. Create a depthstencil texture.
 2. Upload data into (level=x1,layer=y1).
 3. Upload data into (level=x2,layer=y2).
 4. Read and test stencil data at (level=x1, layer=y1).
 5. Read and test stencil data at (level=x2, layer=y2).
 
 Signed-off-by: Chad Versace chad.vers...@linux.intel.com
 ---
  src/mesa/drivers/dri/intel/intel_fbo.c |  116 +++--
  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |  134 
 +++-
  src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   37 +++
  src/mesa/drivers/dri/intel/intel_tex.c |   41 +++-
  src/mesa/drivers/dri/intel/intel_tex_image.c   |  128 --
  src/mesa/drivers/dri/intel/intel_tex_obj.h |   30 --
  6 files changed, 248 insertions(+), 238 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
 b/src/mesa/drivers/dri/intel/intel_fbo.c
 index a61c74c..7dc0c53 100644
 --- a/src/mesa/drivers/dri/intel/intel_fbo.c
 +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
  #ifdef I915
 (void) intel;
 if (intel-is_945)
 @@ -103,6 +116,23 @@ intel_miptree_create_internal(struct intel_context 
 *intel,
 brw_miptree_layout(intel, mt);
  #endif
  
 +   if (intel-has_separate_stencil 
 +   _mesa_is_depthstencil_format(_mesa_get_format_base_format(format))) {

Shouldn't this be must_have_separate_stencil until patch 39/41?

 +  mt-stencil_mt = intel_miptree_create(intel,
 +mt-target,
 +MESA_FORMAT_S8,
 +mt-first_level,
 +mt-last_level,
 +mt-width0,
 +mt-height0,
 +mt-depth0,
 +true);
 +  if (!mt-stencil_mt) {
 +  intel_miptree_release(mt);
 +  return NULL;
 +  }
 +   }
 +
 return mt;
  }


pgp6e1Am0F1Cv.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 16/41] intel: Replace intel_texture_image::stencil_irb with intel_mipmap_tree::stencil_mt

2011-11-18 Thread Chad Versace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/18/2011 03:19 PM, Eric Anholt wrote:
 On Thu, 17 Nov 2011 19:58:43 -0800, Chad Versace 
 chad.vers...@linux.intel.com wrote:
 For depthstencil textures using separate stencil, we embedded a stencil
 buffer in intel_texture_image. The intention was that the embedded stencil
 buffer would be the golden copy of the texture's stencil bits. When
 necessary, we scattered/gathered the stencil bits between the texture
 miptree and the embedded stencil buffer.

 This approach had a serious deficiency for mipmapped or multi-layer
 textures. Any given moment the embedded stencil buffer was consistent with
 exactly one miptree slice, the most recent one to be scattered. This
 permitted tests of type A to pass, but broke tests of type B.

 Test A:
 1. Create a depthstencil texture.
 2. Upload data into (level=x1,layer=y1).
 3. Read and test stencil data at (level=x1, layer=y1).
 4. Upload data into (level=x2,layer=y2).
 5. Read and test stencil data at (level=x2, layer=y2).

 Test B:
 1. Create a depthstencil texture.
 2. Upload data into (level=x1,layer=y1).
 3. Upload data into (level=x2,layer=y2).
 4. Read and test stencil data at (level=x1, layer=y1).
 5. Read and test stencil data at (level=x2, layer=y2).

 Signed-off-by: Chad Versace chad.vers...@linux.intel.com
 ---
  src/mesa/drivers/dri/intel/intel_fbo.c |  116 +++--
  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |  134 
 +++-
  src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   37 +++
  src/mesa/drivers/dri/intel/intel_tex.c |   41 +++-
  src/mesa/drivers/dri/intel/intel_tex_image.c   |  128 --
  src/mesa/drivers/dri/intel/intel_tex_obj.h |   30 --
  6 files changed, 248 insertions(+), 238 deletions(-)

 diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
 b/src/mesa/drivers/dri/intel/intel_fbo.c
 index a61c74c..7dc0c53 100644
 --- a/src/mesa/drivers/dri/intel/intel_fbo.c
 +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
  #ifdef I915
 (void) intel;
 if (intel-is_945)
 @@ -103,6 +116,23 @@ intel_miptree_create_internal(struct intel_context 
 *intel,
 brw_miptree_layout(intel, mt);
  #endif
  
 +   if (intel-has_separate_stencil 
 +   _mesa_is_depthstencil_format(_mesa_get_format_base_format(format))) {
 
 Shouldn't this be must_have_separate_stencil until patch 39/41?

You're correct. Thanks for the sharp eye. I'll fix that in the final patch.

- 
Chad Versace
chad.vers...@linux.intel.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOxujHAAoJEAIvNt057x8iIM4P/jaFtwetRiv3r/sqpUPGq160
icpf3giCXwhFG3BpUgt8jU3neIftXsbC8eBS1TErrwtqtcu58otEGkqUDkQ1QiEz
9keLHmfbf/r9raJ8hvqbI/1WggSaiTEkYExkjX/USCr+WBzr8A/C90GarDWX/Up5
0mXuJrbcnITDwY4vh2iuh12JI+BOwBv+0RyYSfRM15N1fRwEvlsovasH3iEQzkWl
FOmqdg3qm4kWYVmhYZnu50dOpVgyT7J531gcbi3lBlVkKs5Wfzmrz8D130X6hlBV
+4s/r2Rou/KYzP8aqLfaygak34027lqyMF/aDC5MZnRDr9dfZ52zz0v2gXnJLrFQ
+Q+oLNBDLog82lLRo/yVxU0beaz9ywNdFhiqEATC2lQ3BLGJCW59j7Ygdd916reM
/TKj1AyXMcIKFHuCzmP18pFrHf7lOH7lE0HB/VWRl9LPpFmXzfnSC0Q0GD4+bP4P
043v67c7ZloJS8atBMvG7Gs24IeJDllwbh0lZrpAgWNjZiWq/f+x1Oxv9LcKmysL
x9i1G3DVHHj3rgw3jDU+L44n1B18CEaZ59e7W+JK+Fmnieih6u/FtrEva0/fiMNC
2jJ9e4buhj24yyz4O0L7XXjOFS2a0tfuvhXez26aIHBcVbemVbOFxldUeLs2xXwZ
2kipPUQrqvEc42TM7/6p
=tZBm
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 16/41] intel: Replace intel_texture_image::stencil_irb with intel_mipmap_tree::stencil_mt

2011-11-17 Thread Chad Versace
For depthstencil textures using separate stencil, we embedded a stencil
buffer in intel_texture_image. The intention was that the embedded stencil
buffer would be the golden copy of the texture's stencil bits. When
necessary, we scattered/gathered the stencil bits between the texture
miptree and the embedded stencil buffer.

This approach had a serious deficiency for mipmapped or multi-layer
textures. Any given moment the embedded stencil buffer was consistent with
exactly one miptree slice, the most recent one to be scattered. This
permitted tests of type A to pass, but broke tests of type B.

Test A:
1. Create a depthstencil texture.
2. Upload data into (level=x1,layer=y1).
3. Read and test stencil data at (level=x1, layer=y1).
4. Upload data into (level=x2,layer=y2).
5. Read and test stencil data at (level=x2, layer=y2).

Test B:
1. Create a depthstencil texture.
2. Upload data into (level=x1,layer=y1).
3. Upload data into (level=x2,layer=y2).
4. Read and test stencil data at (level=x1, layer=y1).
5. Read and test stencil data at (level=x2, layer=y2).

Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_fbo.c |  116 +++--
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |  134 +++-
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   37 +++
 src/mesa/drivers/dri/intel/intel_tex.c |   41 +++-
 src/mesa/drivers/dri/intel/intel_tex_image.c   |  128 --
 src/mesa/drivers/dri/intel/intel_tex_obj.h |   30 --
 6 files changed, 248 insertions(+), 238 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index a61c74c..7dc0c53 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -36,6 +36,8 @@
 #include main/renderbuffer.h
 #include main/context.h
 #include main/teximage.h
+#include main/image.h
+
 #include swrast/swrast.h
 #include drivers/common/meta.h
 
@@ -945,33 +947,36 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx,
intel_draw_buffer(ctx);
 }
 
-/**
- * NOTE: The 'att' parameter is a kludge that will soon be removed. Its
- * presence allows us to refactor the wrapping of depthstencil textures that
- * use separate stencil in two easily manageable steps, rather than in one
- * large, hairy step. First, refactor the common wrapping code used by all
- * texture formats. Second, refactor the separate stencil code paths.
- */
+static struct intel_renderbuffer*
+intel_renderbuffer_wrap_miptree(struct intel_context *intel,
+struct intel_mipmap_tree *mt,
+uint32_t level,
+uint32_t layer,
+GLenum internal_format);
+
 static bool
 intel_renderbuffer_update_wrapper(struct intel_context *intel,
   struct intel_renderbuffer *irb,
   struct intel_mipmap_tree *mt,
   uint32_t level,
   uint32_t layer,
-  GLenum internal_format,
-  struct gl_renderbuffer_attachment *att)
+  GLenum internal_format)
 {
struct gl_context *ctx = intel-ctx;
struct gl_renderbuffer *rb = irb-Base;
 
-   /* The image variables are a kludge. See the note above for the att
-* parameter.
-*/
-   struct gl_texture_image *texImage = _mesa_get_attachment_teximage(att);
-   struct intel_texture_image *intel_image = intel_texture_image(texImage);
-
-   irb-Base.Format = ctx-Driver.ChooseTextureFormat(ctx, internal_format,
-  GL_NONE, GL_NONE);
+   switch (internal_format) {
+   case GL_STENCIL_INDEX:
+   case GL_STENCIL_INDEX1:
+   case GL_STENCIL_INDEX4:
+   case GL_STENCIL_INDEX8:
+  rb-Format = MESA_FORMAT_S8;
+  break;
+   default:
+  rb-Format = intel-ctx.Driver.ChooseTextureFormat(ctx, internal_format,
+ GL_NONE, GL_NONE);
+  break;
+   }
 
if (!intel_span_supports_format(rb-Format)) {
   DBG(Render to texture BAD FORMAT %s\n,
@@ -994,35 +999,46 @@ intel_renderbuffer_update_wrapper(struct intel_context 
*intel,
irb-mt_level = level;
irb-mt_layer = layer;
 
-   if (intel_image-stencil_rb) {
-  /*  The tex image has packed depth/stencil format, but is using separate
-   *  stencil. It shares its embedded depth and stencil renderbuffers with
-   *  the renderbuffer wrapper.
-   *
-   *  FIXME: glFramebufferTexture*() is broken for depthstencil textures
-   *  FIXME: with separate stencil. To fix this, we must create a separate
-   *  FIXME: pair of depth/stencil renderbuffers for each attached slice
-   *  FIXME: of the miptree.
-   */
+