[Mesa-dev] [PATCH 02/13] st/mesa: remove st_renderbuffer::stride

Brian Paul brianp at vmware.com
Mon Feb 13 08:19:18 PST 2012


It was only used for software buffers and easily computed.
---
 src/mesa/state_tracker/st_cb_fbo.c |   13 ++++++-------
 src/mesa/state_tracker/st_cb_fbo.h |    1 -
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 85086bb..2e884a4 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -105,8 +105,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
       
       free(strb->data);
 
-      strb->stride = util_format_get_stride(format, width);
-      size = util_format_get_2d_size(format, strb->stride, height);
+      size = _mesa_format_image_size(strb->Base.Format, width, height, 1);
       
       strb->data = malloc(size);
       
@@ -640,12 +639,12 @@ st_MapRenderbuffer(struct gl_context *ctx,
 
    if (strb->software) {
       /* software-allocated renderbuffer (probably an accum buffer) */
-      GLubyte *map = (GLubyte *) strb->data;
       if (strb->data) {
-         map += strb->stride * y;
-         map += _mesa_get_format_bytes(strb->Base.Format) * x;
-         *mapOut = map;
-         *rowStrideOut = strb->stride;
+         GLint bpp = _mesa_get_format_bytes(strb->Base.Format);
+         GLint stride = _mesa_format_row_stride(strb->Base.Format,
+                                                strb->Base.Width);
+         *mapOut = (GLubyte *) strb->data + y * stride + x * bpp;
+         *rowStrideOut = stride;
       }
       else {
          *mapOut = NULL;
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 7a2d4d8..506fd06 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -56,7 +56,6 @@ struct st_renderbuffer
     * Used only when hardware accumulation buffers are not supported.
     */
    boolean software;
-   size_t stride;
    void *data;
 
    struct st_texture_object *rtt;  /**< GL render to texture's texture */
-- 
1.7.3.4



More information about the mesa-dev mailing list