From e6432710d8a586386b3c7025e845cf4f80830da3 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 25 Jan 2012 08:24:51 +0100 Subject: mesa git update 25 jan 2012 --- mesalib/src/mesa/swrast/s_context.h | 47 ++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'mesalib/src/mesa/swrast/s_context.h') diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index 0a383aa3b..ae239a9a8 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -120,14 +120,10 @@ typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage, GLfloat *texelOut); -typedef void (*StoreTexelFunc)(struct swrast_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel); - /** * Subclass of gl_texture_image. * We need extra fields/info to keep tracking of mapped texture buffers, - * strides and Fetch/Store functions. + * strides and Fetch functions. */ struct swrast_texture_image { @@ -142,13 +138,12 @@ struct swrast_texture_image GLint RowStride; /**< Padded width in units of texels */ GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to each 2D slice in 'Data', in texels */ - GLubyte *Data; /**< Image data, accessed via FetchTexel() */ + GLubyte *Map; /**< Pointer to mapped image memory */ /** Malloc'd texture memory */ GLubyte *Buffer; FetchTexelFunc FetchTexel; - StoreTexelFunc Store; }; @@ -167,6 +162,31 @@ swrast_texture_image_const(const struct gl_texture_image *img) } +/** + * Subclass of gl_renderbuffer with extra fields needed for software + * rendering. + */ +struct swrast_renderbuffer +{ + struct gl_renderbuffer Base; + + GLubyte *Buffer; /**< The malloc'd memory for buffer */ + + /** These fields are only valid while buffer is mapped for rendering */ + GLubyte *Map; + GLint RowStride; /**< in bytes */ +}; + + +/** cast wrapper */ +static inline struct swrast_renderbuffer * +swrast_renderbuffer(struct gl_renderbuffer *img) +{ + return (struct swrast_renderbuffer *) img; +} + + + /** * \struct SWcontext * \brief Per-context state that's private to the software rasterizer module. @@ -428,9 +448,18 @@ _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->RowStride * bpp; - return (GLubyte *) rb->Data + y * rowStride + x * bpp; + const GLint rowStride = srb->RowStride; + assert(x >= 0); + assert(y >= 0); + /* NOTE: using <= only because of s_tritemp.h which gets a pixel + * address but doesn't necessarily access it. + */ + assert(x <= (GLint) rb->Width); + assert(y <= (GLint) rb->Height); + assert(srb->Map); + return (GLubyte *) srb->Map + y * rowStride + x * bpp; } -- cgit v1.2.3