Re: [Mesa-dev] [PATCH 08/13] mesa: implement depth/stencil renderbuffer wrapper accessors for Z32F_X24S8

2011-07-01 Thread Marek Olšák
On Fri, Jul 1, 2011 at 5:43 AM, Kenneth Graunke kenn...@whitecape.org wrote:
 On 06/30/2011 05:29 PM, Marek Olšák wrote:
 ---
  src/mesa/main/depthstencil.c |  322 
 +++---
  src/mesa/main/depthstencil.h |    5 +
  src/mesa/main/framebuffer.c  |   10 +-
  3 files changed, 313 insertions(+), 24 deletions(-)

 diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
 index ab62c97..f979045 100644
 --- a/src/mesa/main/depthstencil.c
 +++ b/src/mesa/main/depthstencil.c
 [snip]
 +static void
 +put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, 
 GLuint count,
 +                const GLint x[], const GLint y[],
 +                const void *values, const GLubyte *mask)
 +{
 +   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
 +   const GLfloat *src = (const GLfloat *) values;
 +   ASSERT(z32frb-DataType == GL_FLOAT);
 +   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 +   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 +   if (dsrb-GetPointer(ctx, dsrb, 0, 0)) {
 +      /* direct access */
 +      GLuint i;
 +      for (i = 0; i  count; i++) {
 +         if (!mask || mask[i]) {
 +            GLfloat *dst = (GLfloat *) dsrb-GetPointer(ctx, dsrb, x[i], 
 y[i]);
 +            dst[1] = src[i];

 Don't you mean dst[0] = src[i] here?  With dst[1], you'll be assigning
 to the stencil value...

Yes, that's right. Thanks for reviewing. I'll change that to *dst.

Marek


 +         }
 +      }
 +   }
 +   else {
 +      /* get, modify, put */
 +      GLfloat temp[MAX_WIDTH*2];
 +      GLuint i;
 +      dsrb-GetValues(ctx, dsrb, count, x, y, temp);
 +      for (i = 0; i  count; i++) {
 +         if (!mask || mask[i]) {
 +            temp[i*2] = src[i];

 ...when clearly this is assigning to the depth value.

 +         }
 +      }
 +      dsrb-PutValues(ctx, dsrb, count, x, y, temp, mask);
 +   }
 +}
 [snip]

 With that fixed, this patch is:

 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/13] mesa: implement depth/stencil renderbuffer wrapper accessors for Z32F_X24S8

2011-06-30 Thread Marek Olšák
---
 src/mesa/main/depthstencil.c |  322 +++---
 src/mesa/main/depthstencil.h |5 +
 src/mesa/main/framebuffer.c  |   10 +-
 3 files changed, 313 insertions(+), 24 deletions(-)

diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index ab62c97..f979045 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -393,6 +393,217 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
 }
 
 
+static void
+get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint 
count,
+ GLint x, GLint y, void *values)
+{
+   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
+   GLfloat temp[MAX_WIDTH*2];
+   GLfloat *dst = (GLfloat *) values;
+   const GLfloat *src = (const GLfloat *) dsrb-GetPointer(ctx, dsrb, x, y);
+   GLuint i;
+   ASSERT(z32frb-DataType == GL_FLOAT);
+   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (!src) {
+  dsrb-GetRow(ctx, dsrb, count, x, y, temp);
+  src = temp;
+   }
+   for (i = 0; i  count; i++) {
+  dst[i] = src[i*2];
+   }
+}
+
+static void
+get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint 
count,
+const GLint x[], const GLint y[], void *values)
+{
+   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
+   GLfloat temp[MAX_WIDTH*2];
+   GLfloat *dst = (GLfloat *) values;
+   GLuint i;
+   ASSERT(z32frb-DataType == GL_FLOAT);
+   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   ASSERT(count = MAX_WIDTH);
+   /* don't bother trying direct access */
+   dsrb-GetValues(ctx, dsrb, count, x, y, temp);
+   for (i = 0; i  count; i++) {
+  dst[i] = temp[i*2];
+   }
+}
+
+static void
+put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint 
count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
+   const GLfloat *src = (const GLfloat *) values;
+   GLfloat *dst = (GLfloat *) dsrb-GetPointer(ctx, dsrb, x, y);
+   ASSERT(z32frb-DataType == GL_FLOAT);
+   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dst) {
+  /* direct access */
+  GLuint i;
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+dst[i*2] = src[i];
+ }
+  }
+   }
+   else {
+  /* get, modify, put */
+  GLfloat temp[MAX_WIDTH*2];
+  GLuint i;
+  dsrb-GetRow(ctx, dsrb, count, x, y, temp);
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+temp[i*2] = src[i];
+ }
+  }
+  dsrb-PutRow(ctx, dsrb, count, x, y, temp, mask);
+   }
+}
+
+static void
+put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, 
GLuint count,
+  GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
+   GLfloat *dst = (GLfloat *) dsrb-GetPointer(ctx, dsrb, x, y);
+   ASSERT(z32frb-DataType == GL_FLOAT);
+   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dst) {
+  /* direct access */
+  GLuint i;
+  const GLfloat val = *(GLfloat*)value;
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+dst[i*2] = val;
+ }
+  }
+   }
+   else {
+  /* get, modify, put */
+  GLfloat temp[MAX_WIDTH*2];
+  GLuint i;
+  const GLfloat val = *(GLfloat *)value;
+  dsrb-GetRow(ctx, dsrb, count, x, y, temp);
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+temp[i*2] = val;
+ }
+  }
+  dsrb-PutRow(ctx, dsrb, count, x, y, temp, mask);
+   }
+}
+
+static void
+put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint 
count,
+const GLint x[], const GLint y[],
+const void *values, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
+   const GLfloat *src = (const GLfloat *) values;
+   ASSERT(z32frb-DataType == GL_FLOAT);
+   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dsrb-GetPointer(ctx, dsrb, 0, 0)) {
+  /* direct access */
+  GLuint i;
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+GLfloat *dst = (GLfloat *) dsrb-GetPointer(ctx, dsrb, x[i], y[i]);
+dst[1] = src[i];
+ }
+  }
+   }
+   else {
+  /* get, modify, put */
+  GLfloat temp[MAX_WIDTH*2];
+  GLuint i;
+  dsrb-GetValues(ctx, dsrb, count, x, y, temp);
+  for (i = 0; i  count; i++) {
+ if (!mask || mask[i]) {
+temp[i*2] = src[i];
+ }
+  }
+  dsrb-PutValues(ctx, dsrb, count, x, y, 

Re: [Mesa-dev] [PATCH 08/13] mesa: implement depth/stencil renderbuffer wrapper accessors for Z32F_X24S8

2011-06-30 Thread Kenneth Graunke
On 06/30/2011 05:29 PM, Marek Olšák wrote:
 ---
  src/mesa/main/depthstencil.c |  322 
 +++---
  src/mesa/main/depthstencil.h |5 +
  src/mesa/main/framebuffer.c  |   10 +-
  3 files changed, 313 insertions(+), 24 deletions(-)
 
 diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
 index ab62c97..f979045 100644
 --- a/src/mesa/main/depthstencil.c
 +++ b/src/mesa/main/depthstencil.c
[snip]
 +static void
 +put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, 
 GLuint count,
 +const GLint x[], const GLint y[],
 +const void *values, const GLubyte *mask)
 +{
 +   struct gl_renderbuffer *dsrb = z32frb-Wrapped;
 +   const GLfloat *src = (const GLfloat *) values;
 +   ASSERT(z32frb-DataType == GL_FLOAT);
 +   ASSERT(dsrb-DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 +   ASSERT(dsrb-Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 +   if (dsrb-GetPointer(ctx, dsrb, 0, 0)) {
 +  /* direct access */
 +  GLuint i;
 +  for (i = 0; i  count; i++) {
 + if (!mask || mask[i]) {
 +GLfloat *dst = (GLfloat *) dsrb-GetPointer(ctx, dsrb, x[i], 
 y[i]);
 +dst[1] = src[i];

Don't you mean dst[0] = src[i] here?  With dst[1], you'll be assigning
to the stencil value...

 + }
 +  }
 +   }
 +   else {
 +  /* get, modify, put */
 +  GLfloat temp[MAX_WIDTH*2];
 +  GLuint i;
 +  dsrb-GetValues(ctx, dsrb, count, x, y, temp);
 +  for (i = 0; i  count; i++) {
 + if (!mask || mask[i]) {
 +temp[i*2] = src[i];

...when clearly this is assigning to the depth value.

 + }
 +  }
 +  dsrb-PutValues(ctx, dsrb, count, x, y, temp, mask);
 +   }
 +}
[snip]

With that fixed, this patch is:

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev