diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/swrast/s_context.h | 7 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_depth.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_renderbuffer.c | 40 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_stencil.c | 5 | ||||
-rw-r--r-- | src/mesa/swrast/s_texrender.c | 5 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 20 |
9 files changed, 62 insertions, 41 deletions
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index f03f0485bcd..2fb61eaee5a 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -453,8 +453,9 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx); static inline GLubyte * _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; assert(x >= 0); assert(y >= 0); /* NOTE: using <= only because of s_tritemp.h which gets a pixel @@ -462,8 +463,8 @@ _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y) */ assert(x <= (GLint) rb->Width); assert(y <= (GLint) rb->Height); - assert(rb->Map); - return (GLubyte *) rb->Map + y * rowStride + x * bpp; + assert(srb->Map); + return (GLubyte *) srb->Map + y * rowStride + x * bpp; } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 91541d2c93c..592d35a9898 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -567,6 +567,7 @@ map_readbuffer(struct gl_context *ctx, GLenum type) { struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_renderbuffer *rb; + struct swrast_renderbuffer *srb; switch (type) { case GL_COLOR: @@ -583,7 +584,9 @@ map_readbuffer(struct gl_context *ctx, GLenum type) return NULL; } - if (!rb || rb->Map) { + srb = swrast_renderbuffer(rb); + + if (!srb || srb->Map) { /* no buffer, or buffer is mapped already, we're done */ return NULL; } @@ -591,7 +594,7 @@ map_readbuffer(struct gl_context *ctx, GLenum type) ctx->Driver.MapRenderbuffer(ctx, rb, 0, 0, rb->Width, rb->Height, GL_MAP_READ_BIT, - &rb->Map, &rb->RowStrideBytes); + &srb->Map, &srb->RowStride); return rb; } @@ -650,7 +653,8 @@ _swrast_CopyPixels( struct gl_context *ctx, swrast_render_finish(ctx); if (rb) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); ctx->Driver.UnmapRenderbuffer(ctx, rb); - rb->Map = NULL; + srb->Map = NULL; } } diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 0788644b76d..1336407c4b7 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -212,12 +212,13 @@ get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], GLuint zbuffer[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; const GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_Z32) { - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { zbuffer[i] = *((GLuint *) (map + y[i] * rowStride + x[i] * 4)); @@ -226,7 +227,7 @@ get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { const GLubyte *src = map + y[i] * rowStride+ x[i] * bpp; @@ -246,12 +247,13 @@ put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const GLuint zvalues[], const GLubyte mask[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_Z32) { - const GLuint rowStride = rb->RowStrideBytes; + const GLuint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { GLuint *dst = (GLuint *) (map + y[i] * rowStride + x[i] * 4); @@ -262,7 +264,7 @@ put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, else { gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format); const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { void *dst = map + y[i] * rowStride + x[i] * bpp; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 5050ad92c23..c5466ddbd72 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -513,6 +513,7 @@ fast_draw_depth_stencil(struct gl_context *ctx, GLint x, GLint y, const GLenum type = GL_UNSIGNED_INT_24_8; struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); GLubyte *src, *dst; GLint srcRowStride, dstRowStride; GLint i; @@ -522,7 +523,7 @@ fast_draw_depth_stencil(struct gl_context *ctx, GLint x, GLint y, srcRowStride = _mesa_image_row_stride(unpack, width, format, type); dst = _swrast_pixel_address(rb, x, y); - dstRowStride = rb->RowStrideBytes; + dstRowStride = srb->RowStride; for (i = 0; i < height; i++) { _mesa_pack_uint_24_8_depth_stencil_row(rb->Format, width, diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c index af02b02f1ba..f0dbb012bdf 100644 --- a/src/mesa/swrast/s_renderbuffer.c +++ b/src/mesa/swrast/s_renderbuffer.c @@ -37,6 +37,7 @@ #include "main/formats.h" #include "main/mtypes.h" #include "main/renderbuffer.h" +#include "swrast/s_context.h" #include "swrast/s_renderbuffer.h" @@ -56,6 +57,8 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + switch (internalFormat) { case GL_RGB: case GL_R3_G3_B2: @@ -113,18 +116,19 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, } /* free old buffer storage */ - if (rb->Buffer) { - free(rb->Buffer); - rb->Buffer = NULL; + if (srb->Buffer) { + free(srb->Buffer); + srb->Buffer = NULL; } - rb->RowStrideBytes = width * _mesa_get_format_bytes(rb->Format); + srb->RowStride = width * _mesa_get_format_bytes(rb->Format); if (width > 0 && height > 0) { /* allocate new buffer storage */ - rb->Buffer = malloc(width * height * _mesa_get_format_bytes(rb->Format)); + srb->Buffer = malloc(width * height + * _mesa_get_format_bytes(rb->Format)); - if (rb->Buffer == NULL) { + if (srb->Buffer == NULL) { rb->Width = 0; rb->Height = 0; _mesa_error(ctx, GL_OUT_OF_MEMORY, @@ -162,11 +166,13 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, static void soft_renderbuffer_delete(struct gl_renderbuffer *rb) { - if (rb->Buffer) { - free(rb->Buffer); - rb->Buffer = NULL; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (srb->Buffer) { + free(srb->Buffer); + srb->Buffer = NULL; } - free(rb); + free(srb); } @@ -178,7 +184,8 @@ _swrast_map_soft_renderbuffer(struct gl_context *ctx, GLubyte **out_map, GLint *out_stride) { - GLubyte *map = rb->Buffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + GLubyte *map = srb->Buffer; int cpp = _mesa_get_format_bytes(rb->Format); int stride = rb->Width * cpp; @@ -212,12 +219,13 @@ _swrast_unmap_soft_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer * _swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) { - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); - if (rb) { - rb->AllocStorage = soft_renderbuffer_storage; - rb->Delete = soft_renderbuffer_delete; + struct swrast_renderbuffer *srb = CALLOC_STRUCT(swrast_renderbuffer); + if (srb) { + _mesa_init_renderbuffer(&srb->Base, name); + srb->Base.AllocStorage = soft_renderbuffer_storage; + srb->Base.Delete = soft_renderbuffer_delete; } - return rb; + return &srb->Base; } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index fa63ade89ce..8fbd32276cd 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1414,6 +1414,7 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLvoid *rgba) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); GLenum dstType = GL_FLOAT; const GLint bufWidth = (GLint) rb->Width; const GLint bufHeight = (GLint) rb->Height; @@ -1464,7 +1465,7 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, rb->_BaseFormat == GL_LUMINANCE_ALPHA || rb->_BaseFormat == GL_ALPHA); - assert(rb->Map); + assert(srb->Map); src = _swrast_pixel_address(rb, x + skip, y); diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index 9aa7ffc8598..bbfbf44cce2 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -292,12 +292,13 @@ get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], GLubyte stencil[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; const GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_S8) { - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { stencil[i] = *(map + y[i] * rowStride + x[i]); @@ -306,7 +307,7 @@ get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStrideBytes; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { const GLubyte *src = map + y[i] * rowStride + x[i] * bpp; diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c index 23a7388c0d2..140e4b50f71 100644 --- a/src/mesa/swrast/s_texrender.c +++ b/src/mesa/swrast/s_texrender.c @@ -62,6 +62,7 @@ static void update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) { struct gl_renderbuffer *rb = att->Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); struct swrast_texture_image *swImage; gl_format format; GLuint zOffset; @@ -93,11 +94,11 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) */ if (att->Texture->Target == GL_TEXTURE_3D || att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) { - rb->Buffer = swImage->Buffer + + srb->Buffer = swImage->Buffer + swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format); } else { - rb->Buffer = swImage->Buffer; + srb->Buffer = swImage->Buffer; } } diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 0453640c0df..0a87b7327e0 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -322,6 +322,7 @@ map_attachment(struct gl_context *ctx, { struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); if (texObj) { const GLuint level = fb->Attachment[buffer].TextureLevel; @@ -333,20 +334,20 @@ map_attachment(struct gl_context *ctx, /* XXX we'll eventually call _swrast_map_teximage() here */ swImage->Map = swImage->Buffer; - if (rb) { - rb->Map = swImage->Buffer; - rb->RowStrideBytes = swImage->RowStride * + if (srb) { + srb->Map = swImage->Buffer; + srb->RowStride = swImage->RowStride * _mesa_get_format_bytes(swImage->Base.TexFormat); } } } else if (rb) { /* Map ordinary renderbuffer */ - ctx->Driver.MapRenderbuffer(ctx, rb, - 0, 0, rb->Width, rb->Height, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, - &rb->Map, &rb->RowStrideBytes); - assert(rb->Map); + ctx->Driver.MapRenderbuffer(ctx, rb, + 0, 0, rb->Width, rb->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &srb->Map, &srb->RowStride); + assert(srb->Map); } } @@ -358,6 +359,7 @@ unmap_attachment(struct gl_context *ctx, { struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); if (texObj) { const GLuint level = fb->Attachment[buffer].TextureLevel; @@ -373,7 +375,7 @@ unmap_attachment(struct gl_context *ctx, ctx->Driver.UnmapRenderbuffer(ctx, rb); } - rb->Map = NULL; + srb->Map = NULL; } |