[Mesa-dev] [PATCH 11/22] swrast: use _swrast_pixel_address() helper function
Brian Paul
brianp at vmware.com
Sun Dec 18 19:08:16 PST 2011
---
src/mesa/swrast/s_context.h | 12 ++++++++++++
src/mesa/swrast/s_depth.c | 18 ++++--------------
src/mesa/swrast/s_stencil.c | 18 +++---------------
3 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 446b990..af9e49e 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -422,5 +422,17 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx);
#define ATTRIB_LOOP_END } }
+/**
+ * Return the address of a pixel value in a mapped renderbuffer.
+ */
+static inline GLubyte *
+_swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y)
+{
+ const GLint bpp = _mesa_get_format_bytes(rb->Format);
+ const GLint rowStride = rb->RowStride * bpp;
+ return (GLubyte *) rb->Data + y * rowStride + x * bpp;
+}
+
+
#endif
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 806e62b..f87adaa 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -31,6 +31,7 @@
#include "main/macros.h"
#include "main/imports.h"
+#include "s_context.h"
#include "s_depth.h"
#include "s_span.h"
@@ -267,18 +268,6 @@ put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
/**
- * Return the address of a Z value in a renderbuffer.
- */
-static INLINE void *
-get_z_address(struct gl_renderbuffer *rb, GLint x, GLint y)
-{
- const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStride * bpp;
- return (GLubyte *) rb->Data + y * rowStride + x * bpp;
-}
-
-
-/**
* Apply depth (Z) buffer testing to the span.
* \return approx number of pixels that passed (only zero is reliable)
*/
@@ -288,7 +277,7 @@ _swrast_depth_test_span(struct gl_context *ctx, SWspan *span)
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
const GLint bpp = _mesa_get_format_bytes(rb->Format);
- void *zStart = get_z_address(rb, span->x, span->y);
+ void *zStart = _swrast_pixel_address(rb, span->x, span->y);
const GLuint count = span->end;
const GLuint *fragZ = span->array->z;
GLubyte *mask = span->array->mask;
@@ -486,7 +475,8 @@ _swrast_read_depth_span_float(struct gl_context *ctx,
return;
}
- _mesa_unpack_float_z_row(rb->Format, n, get_z_address(rb, x, y), depth);
+ _mesa_unpack_float_z_row(rb->Format, n, _swrast_pixel_address(rb, x, y),
+ depth);
}
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 41aff9b..c2d5edf 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -52,18 +52,6 @@ ENDIF
*/
-/**
- * Return the address of a stencil value in a renderbuffer.
- */
-static inline GLubyte *
-get_stencil_address(struct gl_renderbuffer *rb, GLint x, GLint y)
-{
- const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStride * bpp;
- assert(rb->Data);
- return (GLubyte *) rb->Data + y * rowStride + x * bpp;
-}
-
/**
* Compute/return the offset of the stencil value in a pixel.
@@ -342,7 +330,7 @@ put_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
- GLubyte *dst = get_stencil_address(rb, x[i], y[i]);
+ GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]);
_mesa_pack_ubyte_stencil_row(rb->Format, 1, &stencil[i], dst);
}
}
@@ -377,7 +365,7 @@ _swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span)
* 8 bits for all MESA_FORMATs, we just need to use the right offset
* and stride to access them.
*/
- stencilBuf = get_stencil_address(rb, span->x, span->y) + stencilOffset;
+ stencilBuf = _swrast_pixel_address(rb, span->x, span->y) + stencilOffset;
}
/*
@@ -524,7 +512,7 @@ _swrast_write_stencil_span(struct gl_context *ctx, GLint n, GLint x, GLint y,
return;
}
- stencilBuf = get_stencil_address(rb, x, y);
+ stencilBuf = _swrast_pixel_address(rb, x, y);
if ((stencilMask & stencilMax) != stencilMax) {
/* need to apply writemask */
--
1.7.3.4
More information about the mesa-dev
mailing list