aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-25 08:24:51 +0100
committermarha <marha@users.sourceforge.net>2012-01-25 08:24:51 +0100
commite6432710d8a586386b3c7025e845cf4f80830da3 (patch)
treea403fa86779a287c97f5605f9b4d455d662ece66 /mesalib/src/mesa/swrast
parentd3f0fe49b8cb29295f3e529cc699a2abde1515a1 (diff)
downloadvcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.gz
vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.bz2
vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.zip
mesa git update 25 jan 2012
Diffstat (limited to 'mesalib/src/mesa/swrast')
-rw-r--r--mesalib/src/mesa/swrast/s_blend.c1
-rw-r--r--mesalib/src/mesa/swrast/s_context.c8
-rw-r--r--mesalib/src/mesa/swrast/s_context.h47
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c55
-rw-r--r--mesalib/src/mesa/swrast/s_depth.c30
-rw-r--r--mesalib/src/mesa/swrast/s_drawpix.c16
-rw-r--r--mesalib/src/mesa/swrast/s_logic.c1
-rw-r--r--mesalib/src/mesa/swrast/s_masking.c205
-rw-r--r--mesalib/src/mesa/swrast/s_renderbuffer.c1241
-rw-r--r--mesalib/src/mesa/swrast/s_span.c291
-rw-r--r--mesalib/src/mesa/swrast/s_span.h16
-rw-r--r--mesalib/src/mesa/swrast/s_spantemp.h149
-rw-r--r--mesalib/src/mesa/swrast/s_stencil.c11
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c369
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.h3
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h997
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c4
-rw-r--r--mesalib/src/mesa/swrast/s_texrender.c407
-rw-r--r--mesalib/src/mesa/swrast/s_texture.c57
-rw-r--r--mesalib/src/mesa/swrast/s_triangle.c14
20 files changed, 813 insertions, 3109 deletions
diff --git a/mesalib/src/mesa/swrast/s_blend.c b/mesalib/src/mesa/swrast/s_blend.c
index be5010b13..cd6e6f036 100644
--- a/mesalib/src/mesa/swrast/s_blend.c
+++ b/mesalib/src/mesa/swrast/s_blend.c
@@ -1000,7 +1000,6 @@ _swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *s
ASSERT(span->end <= MAX_WIDTH);
ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(rb->DataType == span->array->ChanType);
ASSERT(!ctx->Color.ColorLogicOpEnabled);
rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 06824ea2c..14cb9b180 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -752,9 +752,6 @@ _swrast_CreateContext( struct gl_context *ctx )
swrast->Driver.SpanRenderStart = _swrast_span_render_start;
swrast->Driver.SpanRenderFinish = _swrast_span_render_finish;
- ctx->Driver.MapTexture = _swrast_map_texture;
- ctx->Driver.UnmapTexture = _swrast_unmap_texture;
-
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
swrast->TextureSample[i] = NULL;
@@ -872,10 +869,11 @@ void
_swrast_render_finish( struct gl_context *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- if (swrast->Driver.SpanRenderFinish)
- swrast->Driver.SpanRenderFinish( ctx );
_swrast_flush(ctx);
+
+ if (swrast->Driver.SpanRenderFinish)
+ swrast->Driver.SpanRenderFinish( ctx );
}
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;
};
@@ -168,6 +163,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;
}
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index 1e0f9fe7d..592d35a98 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/src/mesa/swrast/s_copypix.c
@@ -148,7 +148,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
p = tmpImage;
for (row = 0; row < height; row++) {
_swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, sy + row, GL_FLOAT, p );
+ width, srcx, sy + row, p );
p += width * 4;
}
p = tmpImage;
@@ -172,7 +172,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
else {
/* get from framebuffer */
_swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, sy, GL_FLOAT, rgba );
+ width, srcx, sy, rgba );
}
if (transferOps) {
@@ -558,6 +558,49 @@ swrast_fast_copy_pixels(struct gl_context *ctx,
/**
+ * Find/map the renderbuffer that we'll be reading from.
+ * The swrast_render_start() function only maps the drawing buffers,
+ * not the read buffer.
+ */
+static struct gl_renderbuffer *
+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:
+ rb = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer;
+ break;
+ case GL_DEPTH:
+ case GL_DEPTH_STENCIL:
+ rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ break;
+ case GL_STENCIL:
+ rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ break;
+ default:
+ return NULL;
+ }
+
+ srb = swrast_renderbuffer(rb);
+
+ if (!srb || srb->Map) {
+ /* no buffer, or buffer is mapped already, we're done */
+ return NULL;
+ }
+
+ ctx->Driver.MapRenderbuffer(ctx, rb,
+ 0, 0, rb->Width, rb->Height,
+ GL_MAP_READ_BIT,
+ &srb->Map, &srb->RowStride);
+
+ return rb;
+}
+
+
+/**
* Do software-based glCopyPixels.
* By time we get here, all parameters will have been error-checked.
*/
@@ -567,6 +610,7 @@ _swrast_CopyPixels( struct gl_context *ctx,
GLint destx, GLint desty, GLenum type )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb;
if (!_mesa_check_conditional_render(ctx))
return; /* don't copy */
@@ -585,6 +629,7 @@ _swrast_CopyPixels( struct gl_context *ctx,
}
swrast_render_start(ctx);
+ rb = map_readbuffer(ctx, type);
switch (type) {
case GL_COLOR:
@@ -606,4 +651,10 @@ _swrast_CopyPixels( struct gl_context *ctx,
}
swrast_render_finish(ctx);
+
+ if (rb) {
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ ctx->Driver.UnmapRenderbuffer(ctx, rb);
+ srb->Map = NULL;
+ }
}
diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c
index 42724c72b..c90388209 100644
--- a/mesalib/src/mesa/swrast/s_depth.c
+++ b/mesalib/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 = (const GLubyte *) rb->Data;
+ const GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_Z32) {
- const GLint rowStride = rb->RowStride * 4;
+ 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->RowStride * bpp;
+ 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 = (GLubyte *) rb->Data;
+ GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_Z32) {
- const GLuint rowStride = rb->RowStride * 4;
+ 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) {
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->RowStride * bpp;
+ 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;
@@ -283,7 +285,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 = _swrast_pixel_address(rb, span->x, span->y);
+ void *zStart;
const GLuint count = span->end;
const GLuint *fragZ = span->array->z;
GLubyte *mask = span->array->mask;
@@ -293,6 +295,11 @@ _swrast_depth_test_span(struct gl_context *ctx, SWspan *span)
GLuint zBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS);
GLboolean ztest16 = GL_FALSE;
+ if (span->arrayMask & SPAN_XY)
+ zStart = NULL;
+ else
+ zStart = _swrast_pixel_address(rb, span->x, span->y);
+
if (rb->Format == MESA_FORMAT_Z16 && !(span->arrayMask & SPAN_XY)) {
/* directly read/write row of 16-bit Z values */
zBufferVals = zStart;
@@ -405,9 +412,7 @@ _swrast_depth_bounds_test( 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);
- const GLint rowStride = rb->RowStride * bpp;
- GLubyte *zStart = (GLubyte*) rb->Data + span->y * rowStride + span->x * bpp;
+ GLubyte *zStart;
GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F);
GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F);
GLubyte *mask = span->array->mask;
@@ -417,6 +422,11 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span )
GLuint zBufferTemp[MAX_WIDTH];
const GLuint *zBufferVals;
+ if (span->arrayMask & SPAN_XY)
+ zStart = NULL;
+ else
+ zStart = _swrast_pixel_address(rb, span->x, span->y);
+
if (rb->Format == MESA_FORMAT_Z32 && !(span->arrayMask & SPAN_XY)) {
/* directly access 32-bit values in the depth buffer */
zBufferVals = (const GLuint *) zStart;
diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c
index 4231bb4bd..c5466ddbd 100644
--- a/mesalib/src/mesa/swrast/s_drawpix.c
+++ b/mesalib/src/mesa/swrast/s_drawpix.c
@@ -429,11 +429,14 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
span.arrayMask = SPAN_RGBA;
span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */
- if (ctx->DrawBuffer->_NumColorDrawBuffers > 0 &&
- ctx->DrawBuffer->_ColorDrawBuffers[0]->DataType != GL_FLOAT &&
- ctx->Color.ClampFragmentColor != GL_FALSE) {
- /* need to clamp colors before applying fragment ops */
- transferOps |= IMAGE_CLAMP_BIT;
+ if (ctx->DrawBuffer->_NumColorDrawBuffers > 0) {
+ GLenum datatype = _mesa_get_format_datatype(
+ ctx->DrawBuffer->_ColorDrawBuffers[0]->Format);
+ if (datatype != GL_FLOAT &&
+ ctx->Color.ClampFragmentColor != GL_FALSE) {
+ /* need to clamp colors before applying fragment ops */
+ transferOps |= IMAGE_CLAMP_BIT;
+ }
}
/*
@@ -510,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;
@@ -519,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->RowStride * 4;
+ dstRowStride = srb->RowStride;
for (i = 0; i < height; i++) {
_mesa_pack_uint_24_8_depth_stencil_row(rb->Format, width,
diff --git a/mesalib/src/mesa/swrast/s_logic.c b/mesalib/src/mesa/swrast/s_logic.c
index 80ee46c24..e908a0efe 100644
--- a/mesalib/src/mesa/swrast/s_logic.c
+++ b/mesalib/src/mesa/swrast/s_logic.c
@@ -195,7 +195,6 @@ _swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
ASSERT(span->end < MAX_WIDTH);
ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(rb->DataType == span->array->ChanType);
rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
diff --git a/mesalib/src/mesa/swrast/s_masking.c b/mesalib/src/mesa/swrast/s_masking.c
index 6ee29d4b3..2d962ebc5 100644
--- a/mesalib/src/mesa/swrast/s_masking.c
+++ b/mesalib/src/mesa/swrast/s_masking.c
@@ -1,103 +1,102 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.2
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/*
- * Implement the effect of glColorMask and glIndexMask in software.
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "s_context.h"
-#include "s_masking.h"
-#include "s_span.h"
-
-
-/**
- * Apply the color mask to a span of rgba values.
- */
-void
-_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
- SWspan *span, GLuint buf)
-{
- const GLuint n = span->end;
- void *rbPixels;
-
- ASSERT(n < MAX_WIDTH);
- ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(rb->DataType == span->array->ChanType);
-
- rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
-
- /*
- * Do component masking.
- * Note that we're not using span->array->mask[] here. We could...
- */
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- /* treat 4xGLubyte as 1xGLuint */
- const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
- const GLuint dstMask = ~srcMask;
- const GLuint *dst = (const GLuint *) rbPixels;
- GLuint *src = (GLuint *) span->array->rgba8;
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i] = (src[i] & srcMask) | (dst[i] & dstMask);
- }
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- /* 2-byte components */
- /* XXX try to use 64-bit arithmetic someday */
- const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0;
- const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0;
- const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0;
- const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0;
- const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
- GLushort (*src)[4] = span->array->rgba16;
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
- src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
- src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
- src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
- }
- }
- else {
- /* 4-byte components */
- const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0;
- const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0;
- const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0;
- const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0;
- const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
- GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
- src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
- src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
- src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
- }
- }
-}
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5.2
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Implement the effect of glColorMask and glIndexMask in software.
+ */
+
+
+#include "main/glheader.h"
+#include "main/macros.h"
+
+#include "s_context.h"
+#include "s_masking.h"
+#include "s_span.h"
+
+
+/**
+ * Apply the color mask to a span of rgba values.
+ */
+void
+_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ SWspan *span, GLuint buf)
+{
+ const GLuint n = span->end;
+ void *rbPixels;
+
+ ASSERT(n < MAX_WIDTH);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+
+ rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
+
+ /*
+ * Do component masking.
+ * Note that we're not using span->array->mask[] here. We could...
+ */
+ if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ /* treat 4xGLubyte as 1xGLuint */
+ const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
+ const GLuint dstMask = ~srcMask;
+ const GLuint *dst = (const GLuint *) rbPixels;
+ GLuint *src = (GLuint *) span->array->rgba8;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ src[i] = (src[i] & srcMask) | (dst[i] & dstMask);
+ }
+ }
+ else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
+ /* 2-byte components */
+ /* XXX try to use 64-bit arithmetic someday */
+ const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0;
+ const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0;
+ const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0;
+ const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0;
+ const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
+ GLushort (*src)[4] = span->array->rgba16;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
+ src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
+ src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
+ src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
+ }
+ }
+ else {
+ /* 4-byte components */
+ const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0;
+ const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0;
+ const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0;
+ const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0;
+ const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
+ GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
+ src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
+ src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
+ src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
+ }
+ }
+}
diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c
index 1a7cb36d9..637a7b6dc 100644
--- a/mesalib/src/mesa/swrast/s_renderbuffer.c
+++ b/mesalib/src/mesa/swrast/s_renderbuffer.c
@@ -37,1048 +37,10 @@
#include "main/formats.h"
#include "main/mtypes.h"
#include "main/renderbuffer.h"
+#include "swrast/s_context.h"
#include "swrast/s_renderbuffer.h"
-/*
- * Routines for get/put values in common buffer formats follow.
- */
-
-/* Returns a bytes per pixel of the DataType in the get/put span
- * functions for at least a subset of the available combinations a
- * renderbuffer can have.
- *
- * It would be nice to see gl_renderbuffer start talking about a
- * gl_format instead of a GLenum DataType.
- */
-static int
-get_datatype_bytes(struct gl_renderbuffer *rb)
-{
- int component_size;
-
- switch (rb->DataType) {
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- component_size = 8;
- break;
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_24_8_EXT:
- component_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- component_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- component_size = 1;
- break;
- default:
- component_size = 1;
- assert(0);
- }
-
- switch (rb->_BaseFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL:
- return component_size;
- default:
- return 4 * component_size;
- }
-}
-
-/* This is commonly used by most of the accessors. */
-static void *
-get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
-
- return ((char *) rb->Data +
- (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format));
-}
-
-/* GetRow() implementation for formats where DataType matches the rb->Format.
- */
-static void
-get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- void *src = rb->GetPointer(ctx, rb, x, y);
- memcpy(values, src, count * _mesa_get_format_bytes(rb->Format));
-}
-
-/* Only used for float textures currently, but might also be used for
- * RGBA8888, RGBA16, etc.
- */
-static void
-get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const void *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- char *dst = (char *) values + i * format_bytes;
- memcpy(dst, src, format_bytes);
- }
-}
-
-/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and
- * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of
- * storing those initial components of the value per pixel into the
- * destination.
- */
-static void
-put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *values, const GLubyte *mask)
-{
- void *row = rb->GetPointer(ctx, rb, x, y);
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- int datatype_bytes = get_datatype_bytes(rb);
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- const char *src = (const char *) values + i * datatype_bytes;
-
- if (mask[i]) {
- memcpy(dst, src, format_bytes);
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- const char *src = (const char *) values + i * datatype_bytes;
- memcpy(dst, src, format_bytes);
- }
- }
-}
-
-
-static void
-put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- int datatype_bytes = get_datatype_bytes(rb);
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- const char *src = (const char *) values + i * datatype_bytes;
- memcpy(dst, src, format_bytes);
- }
- }
-}
-
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLubyte values.
- * Typically stencil.
- */
-
-static void
-get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, values, count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLushort values.
- * Typically depth/Z.
- */
-
-static void
-get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLuint values.
- * Typically depth/Z or color index.
- */
-
-static void
-get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLuint));
- }
-}
-
-
-static void
-put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 3 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
- * alpha values and return 255 for outgoing alpha values.
- */
-
-static void *
-get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- /* No direct access since this buffer is RGB but caller will be
- * treating it as if it were RGBA.
- */
- return NULL;
-}
-
-
-static void
-get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = ((const GLubyte *) rb->Data) +
- 3 * (y * rb->RowStride + x);
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src
- = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
- dst[i * 4 + 0] = src[0];
- dst[i * 4 + 1] = src[1];
- dst[i * 4 + 2] = src[2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = src[i * 4 + 0];
- dst[i * 3 + 1] = src[i * 4 + 1];
- dst[i * 3 + 2] = src[i * 4 + 2];
- }
- }
-}
-
-
-static void
-put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- */
-
-static void
-get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- /* treat 4*GLubyte as 1*GLuint */
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- *dst = src[i];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLushort (or GLshort) values.
- * Typically accum buffer.
- */
-
-static void
-get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src
- = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i * 4 + 0] = src[i * 4 + 0];
- dst[i * 4 + 1] = src[i * 4 + 1];
- dst[i * 4 + 2] = src[i * 4 + 2];
- dst[i * 4 + 3] = src[i * 4 + 3];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst =
- ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- dst[3] = src[i * 4 + 3];
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R8.
- */
-static void
-get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = rb->GetPointer(ctx, rb, x, y);
- GLuint *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i] = 0xff000000 | src[i];
- }
-}
-
-static void
-get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i] = 0xff000000 | *src;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_GR88.
- */
-static void
-get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLuint *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i] = 0xff000000 | src[i];
- }
-}
-
-static void
-get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i] = 0xff000000 | *src;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R16.
- */
-static void
-get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i];
- dst[i * 4 + GCOMP] = 0;
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-static void
-get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = *src;
- dst[i * 4 + GCOMP] = 0;
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_RG1616.
- */
-static void
-get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLushort *src = rb->GetPointer(ctx, rb, x, y);
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i * 2];
- dst[i * 4 + GCOMP] = src[i * 2 + 1];
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-static void
-get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = src[1];
- dst[i * 4 + BCOMP] = 0;
- dst[i * 4 + ACOMP] = 0xffff;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_INTENSITY_FLOAT32.
- */
-static void
-get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] =
- dst[i * 4 + ACOMP] = src[i];
- }
-}
-
-static void
-get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] =
- dst[i * 4 + ACOMP] = src[0];
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_LUMINANCE_FLOAT32.
- */
-static void
-get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] = src[i];
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] =
- dst[i * 4 + GCOMP] =
- dst[i * 4 + BCOMP] = src[0];
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_ALPHA_FLOAT32.
- */
-static void
-get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = 0.0;
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = src[i];
- }
-}
-
-static void
-get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = 0.0;
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = src[0];
- }
-}
-
-static void
-put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *values, const GLubyte *mask)
-{
- float *dst = rb->GetPointer(ctx, rb, x, y);
- const float *src = values;
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i * 4 + ACOMP];
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- dst[i] = src[i * 4 + ACOMP];
- }
- }
-}
-
-static void
-put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const float *src = values;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
-
- *dst = src[i * 4 + ACOMP];
- }
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_R_FLOAT32.
- */
-static void
-get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i];
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = 0.0;
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**********************************************************************
- * Functions for MESA_FORMAT_RG_FLOAT32.
- */
-static void
-get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values)
-{
- const GLfloat *src = rb->GetPointer(ctx, rb, x, y);
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- dst[i * 4 + RCOMP] = src[i * 2 + 0];
- dst[i * 4 + GCOMP] = src[i * 2 + 1];
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-static void
-get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values)
-{
- GLfloat *dst = values;
- GLuint i;
-
- for (i = 0; i < count; i++) {
- const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]);
- dst[i * 4 + RCOMP] = src[0];
- dst[i * 4 + GCOMP] = src[1];
- dst[i * 4 + BCOMP] = 0.0;
- dst[i * 4 + ACOMP] = 1.0;
- }
-}
-
-/**
- * This is the default software fallback for gl_renderbuffer's span
- * access functions.
- *
- * The assumptions are that rb->Data will be a pointer to (0,0), that pixels
- * are packed in the type of rb->Format, and that subsequent rows appear
- * rb->RowStride pixels later.
- */
-void
-_swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
-{
- rb->GetPointer = get_pointer_generic;
- rb->GetRow = get_row_generic;
-
- switch (rb->Format) {
- case MESA_FORMAT_RGB888:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_ubyte3;
- rb->GetRow = get_row_ubyte3;
- rb->GetValues = get_values_ubyte3;
- rb->PutRow = put_row_ubyte3;
- rb->PutValues = put_values_ubyte3;
- break;
-
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_RGBA8888_REV:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_ubyte4;
- rb->PutRow = put_row_ubyte4;
- rb->PutValues = put_values_ubyte4;
- break;
-
- case MESA_FORMAT_R8:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_r8;
- rb->GetRow = get_row_r8;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_GR88:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_rg88;
- rb->GetRow = get_row_rg88;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_R16:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_r16;
- rb->GetRow = get_row_r16;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_RG1616:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_rg1616;
- rb->GetRow = get_row_rg1616;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_SIGNED_RGBA_16:
- rb->DataType = GL_SHORT;
- rb->GetValues = get_values_ushort4;
- rb->PutRow = put_row_ushort4;
- rb->PutValues = put_values_ushort4;
- break;
-
- case MESA_FORMAT_S8:
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetValues = get_values_ubyte;
- rb->PutRow = put_row_ubyte;
- rb->PutValues = put_values_ubyte;
- break;
-
- case MESA_FORMAT_Z16:
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetValues = get_values_ushort;
- rb->PutRow = put_row_ushort;
- rb->PutValues = put_values_ushort;
- break;
-
- case MESA_FORMAT_Z32:
- case MESA_FORMAT_X8_Z24:
- case MESA_FORMAT_Z24_X8:
- rb->DataType = GL_UNSIGNED_INT;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutValues = put_values_uint;
- break;
-
- case MESA_FORMAT_Z24_S8:
- case MESA_FORMAT_S8_Z24:
- rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutValues = put_values_uint;
- break;
-
- case MESA_FORMAT_RGBA_FLOAT32:
- rb->GetRow = get_row_generic;
- rb->GetValues = get_values_generic;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_INTENSITY_FLOAT32:
- rb->GetRow = get_row_i_float32;
- rb->GetValues = get_values_i_float32;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_LUMINANCE_FLOAT32:
- rb->GetRow = get_row_l_float32;
- rb->GetValues = get_values_l_float32;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_ALPHA_FLOAT32:
- rb->GetRow = get_row_a_float32;
- rb->GetValues = get_values_a_float32;
- rb->PutRow = put_row_a_float32;
- rb->PutValues = put_values_a_float32;
- break;
-
- case MESA_FORMAT_RG_FLOAT32:
- rb->GetRow = get_row_rg_float32;
- rb->GetValues = get_values_rg_float32;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- case MESA_FORMAT_R_FLOAT32:
- rb->GetRow = get_row_r_float32;
- rb->GetValues = get_values_r_float32;
- rb->PutRow = put_row_generic;
- rb->PutValues = put_values_generic;
- break;
-
- default:
- break;
- }
-}
-
/**
* This is a software fallback for the gl_renderbuffer->AllocStorage
* function.
@@ -1089,15 +51,15 @@ _swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
*
* This one multi-purpose function can allocate stencil, depth, accum, color
* or color-index buffers!
- *
- * This function also plugs in the appropriate GetPointer, Get/PutRow and
- * Get/PutValues functions.
*/
static GLboolean
soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ GLuint bpp;
+
switch (internalFormat) {
case GL_RGB:
case GL_R3_G3_B2:
@@ -1154,34 +116,26 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
- _swrast_set_renderbuffer_accessors(rb);
-
- ASSERT(rb->DataType);
- ASSERT(rb->GetPointer);
- ASSERT(rb->GetRow);
- ASSERT(rb->GetValues);
- ASSERT(rb->PutRow);
- ASSERT(rb->PutValues);
+ bpp = _mesa_get_format_bytes(rb->Format);
/* free old buffer storage */
- if (rb->Data) {
- free(rb->Data);
- rb->Data = NULL;
+ if (srb->Buffer) {
+ free(srb->Buffer);
+ srb->Buffer = NULL;
}
- rb->RowStride = width;
+ srb->RowStride = width * bpp;
if (width > 0 && height > 0) {
/* allocate new buffer storage */
- rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format));
+ srb->Buffer = malloc(srb->RowStride * height);
- if (rb->Data == NULL) {
+ if (srb->Buffer == NULL) {
rb->Width = 0;
rb->Height = 0;
- rb->RowStride = 0;
_mesa_error(ctx, GL_OUT_OF_MEMORY,
"software renderbuffer allocation (%d x %d x %d)",
- width, height, _mesa_get_format_bytes(rb->Format));
+ width, height, bpp);
return GL_FALSE;
}
}
@@ -1208,6 +162,22 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
+/**
+ * Called via gl_renderbuffer::Delete()
+ */
+static void
+soft_renderbuffer_delete(struct gl_renderbuffer *rb)
+{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+
+ if (srb->Buffer) {
+ free(srb->Buffer);
+ srb->Buffer = NULL;
+ }
+ free(srb);
+}
+
+
void
_swrast_map_soft_renderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb,
@@ -1216,11 +186,15 @@ _swrast_map_soft_renderbuffer(struct gl_context *ctx,
GLubyte **out_map,
GLint *out_stride)
{
- GLubyte *map = rb->Data;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ GLubyte *map = srb->Buffer;
int cpp = _mesa_get_format_bytes(rb->Format);
- int stride = rb->RowStride * cpp;
+ int stride = rb->Width * cpp;
- ASSERT(rb->Data);
+ if (!map) {
+ *out_map = NULL;
+ *out_stride = 0;
+ }
map += y * stride;
map += x * cpp;
@@ -1247,15 +221,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;
- /* Normally, one would setup the PutRow, GetRow, etc functions here.
- * But we're doing that in the soft_renderbuffer_storage() function
- * instead.
- */
+ 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;
}
@@ -1297,7 +269,7 @@ add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
assert(fb->Attachment[b].Renderbuffer == NULL);
- rb = _mesa_new_renderbuffer(ctx, 0);
+ rb = ctx->Driver.NewRenderbuffer(ctx, 0);
if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
return GL_FALSE;
@@ -1335,7 +307,7 @@ add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
- rb = _mesa_new_renderbuffer(ctx, 0);
+ rb = _swrast_new_soft_renderbuffer(ctx, 0);
if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
return GL_FALSE;
@@ -1380,7 +352,7 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
- rb = _mesa_new_renderbuffer(ctx, 0);
+ rb = _swrast_new_soft_renderbuffer(ctx, 0);
if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
return GL_FALSE;
@@ -1405,7 +377,7 @@ add_depth_stencil_renderbuffer(struct gl_context *ctx,
assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
- rb = _mesa_new_renderbuffer(ctx, 0);
+ rb = _swrast_new_soft_renderbuffer(ctx, 0);
if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth+stencil buffer");
return GL_FALSE;
@@ -1444,7 +416,7 @@ add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
- rb = _mesa_new_renderbuffer(ctx, 0);
+ rb = _swrast_new_soft_renderbuffer(ctx, 0);
if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
return GL_FALSE;
@@ -1484,7 +456,7 @@ add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
assert(numBuffers <= MAX_AUX_BUFFERS);
for (i = 0; i < numBuffers; i++) {
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
+ struct gl_renderbuffer *rb = _swrast_new_soft_renderbuffer(ctx, 0);
assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
@@ -1580,3 +552,122 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer *fb,
}
#endif
}
+
+
+
+static void
+map_attachment(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ gl_buffer_index buffer)
+{
+ 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) {
+ /* map texture image (render to texture) */
+ const GLuint level = fb->Attachment[buffer].TextureLevel;
+ const GLuint face = fb->Attachment[buffer].CubeMapFace;
+ const GLuint slice = fb->Attachment[buffer].Zoffset;
+ struct gl_texture_image *texImage = texObj->Image[face][level];
+ if (texImage) {
+ ctx->Driver.MapTextureImage(ctx, texImage, slice,
+ 0, 0, texImage->Width, texImage->Height,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+ &srb->Map, &srb->RowStride);
+ }
+ }
+ 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,
+ &srb->Map, &srb->RowStride);
+ }
+
+ assert(srb->Map);
+}
+
+
+static void
+unmap_attachment(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ gl_buffer_index buffer)
+{
+ 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) {
+ /* unmap texture image (render to texture) */
+ const GLuint level = fb->Attachment[buffer].TextureLevel;
+ const GLuint face = fb->Attachment[buffer].CubeMapFace;
+ const GLuint slice = fb->Attachment[buffer].Zoffset;
+ struct gl_texture_image *texImage = texObj->Image[face][level];
+ if (texImage) {
+ ctx->Driver.UnmapTextureImage(ctx, texImage, slice);
+ }
+ }
+ else if (rb) {
+ /* unmap ordinary renderbuffer */
+ ctx->Driver.UnmapRenderbuffer(ctx, rb);
+ }
+
+ srb->Map = NULL;
+}
+
+
+/**
+ * Map the renderbuffers we'll use for tri/line/point rendering.
+ */
+void
+_swrast_map_renderbuffers(struct gl_context *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *depthRb, *stencilRb;
+ GLuint buf;
+
+ depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ if (depthRb) {
+ /* map depth buffer */
+ map_attachment(ctx, fb, BUFFER_DEPTH);
+ }
+
+ stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ if (stencilRb && stencilRb != depthRb) {
+ /* map stencil buffer */
+ map_attachment(ctx, fb, BUFFER_STENCIL);
+ }
+
+ for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
+ map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
+ }
+}
+
+
+/**
+ * Unmap renderbuffers after rendering.
+ */
+void
+_swrast_unmap_renderbuffers(struct gl_context *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *depthRb, *stencilRb;
+ GLuint buf;
+
+ depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ if (depthRb) {
+ /* map depth buffer */
+ unmap_attachment(ctx, fb, BUFFER_DEPTH);
+ }
+
+ stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ if (stencilRb && stencilRb != depthRb) {
+ /* map stencil buffer */
+ unmap_attachment(ctx, fb, BUFFER_STENCIL);
+ }
+
+ for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
+ unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
+ }
+}
diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c
index e89930353..7ab60b1e5 100644
--- a/mesalib/src/mesa/swrast/s_span.c
+++ b/mesalib/src/mesa/swrast/s_span.c
@@ -33,6 +33,8 @@
#include "main/glheader.h"
#include "main/colormac.h"
+#include "main/format_pack.h"
+#include "main/format_unpack.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/image.h"
@@ -50,6 +52,7 @@
#include "s_stencil.h"
#include "s_texcombine.h"
+#include <stdbool.h>
/**
* Set default fragment attributes for the span using the
@@ -968,7 +971,25 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output)
static inline void
shade_texture_span(struct gl_context *ctx, SWspan *span)
{
- if (ctx->FragmentProgram._Current ||
+ /* This is a hack to work around drivers such as i965 that:
+ *
+ * - Set _MaintainTexEnvProgram to generate GLSL IR for
+ * fixed-function fragment processing.
+ * - Don't call _mesa_ir_link_shader to generate Mesa IR from
+ * the GLSL IR.
+ * - May use swrast to handle glDrawPixels.
+ *
+ * Since _mesa_ir_link_shader is never called, there is no Mesa IR
+ * to execute. Instead do regular fixed-function processing.
+ *
+ * It is also worth noting that the software fixed-function path is
+ * much faster than the software shader path.
+ */
+ const bool use_fragment_program =
+ ctx->FragmentProgram._Current
+ && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram;
+
+ if (use_fragment_program ||
ctx->ATIFragmentShader._Enabled) {
/* programmable shading */
if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
@@ -997,7 +1018,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
interpolate_wpos(ctx, span);
/* Run fragment program/shader now */
- if (ctx->FragmentProgram._Current) {
+ if (use_fragment_program) {
_swrast_exec_fragment_program(ctx, span);
}
else {
@@ -1024,6 +1045,94 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
}
+/** Put colors at x/y locations into a renderbuffer */
+static void
+put_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum datatype,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ gl_pack_ubyte_rgba_func pack_ubyte;
+ gl_pack_float_rgba_func pack_float;
+ GLuint i;
+
+ if (datatype == GL_UNSIGNED_BYTE)
+ pack_ubyte = _mesa_get_pack_ubyte_rgba_function(rb->Format);
+ else
+ pack_float = _mesa_get_pack_float_rgba_function(rb->Format);
+
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]);
+
+ if (datatype == GL_UNSIGNED_BYTE) {
+ pack_ubyte((const GLubyte *) values + 4 * i, dst);
+ }
+ else {
+ assert(datatype == GL_FLOAT);
+ pack_float((const GLfloat *) values + 4 * i, dst);
+ }
+ }
+ }
+}
+
+
+/** Put row of colors into renderbuffer */
+void
+_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum datatype,
+ GLuint count, GLint x, GLint y,
+ const void *values, const GLubyte *mask)
+{
+ GLubyte *dst = _swrast_pixel_address(rb, x, y);
+
+ if (!mask) {
+ if (datatype == GL_UNSIGNED_BYTE) {
+ _mesa_pack_ubyte_rgba_row(rb->Format, count,
+ (const GLubyte (*)[4]) values, dst);
+ }
+ else {
+ assert(datatype == GL_FLOAT);
+ _mesa_pack_float_rgba_row(rb->Format, count,
+ (const GLfloat (*)[4]) values, dst);
+ }
+ }
+ else {
+ const GLuint bpp = _mesa_get_format_bytes(rb->Format);
+ GLuint i, runLen, runStart;
+ /* We can't pass a 'mask' array to the _mesa_pack_rgba_row() functions
+ * so look for runs where mask=1...
+ */
+ runLen = runStart = 0;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ if (runLen == 0)
+ runStart = i;
+ runLen++;
+ }
+
+ if (!mask[i] || i == count - 1) {
+ /* might be the end of a run of pixels */
+ if (runLen > 0) {
+ if (datatype == GL_UNSIGNED_BYTE) {
+ _mesa_pack_ubyte_rgba_row(rb->Format, runLen,
+ (const GLubyte (*)[4]) values + runStart,
+ dst + runStart * bpp);
+ }
+ else {
+ assert(datatype == GL_FLOAT);
+ _mesa_pack_float_rgba_row(rb->Format, runLen,
+ (const GLfloat (*)[4]) values + runStart,
+ dst + runStart * bpp);
+ }
+ runLen = 0;
+ }
+ }
+ }
+ }
+}
+
+
/**
* Apply all the per-fragment operations to a span.
@@ -1227,23 +1336,13 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
if (rb) {
GLchan rgbaSave[MAX_WIDTH][4];
- const GLuint fragOutput = multiFragOutputs ? buf : 0;
- /* set span->array->rgba to colors for render buffer's datatype */
- if (rb->DataType != span->array->ChanType || fragOutput > 0) {
- convert_color_type(span, rb->DataType, fragOutput);
+ if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ span->array->rgba = span->array->rgba8;
}
else {
- if (rb->DataType == GL_UNSIGNED_BYTE) {
- span->array->rgba = span->array->rgba8;
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- span->array->rgba = (void *) span->array->rgba16;
- }
- else {
- span->array->rgba = (void *)
- span->array->attribs[FRAG_ATTRIB_COL0];
- }
+ span->array->rgba = (void *)
+ span->array->attribs[FRAG_ATTRIB_COL0];
}
if (!multiFragOutputs && numBuffers > 1) {
@@ -1271,17 +1370,18 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
if (span->arrayMask & SPAN_XY) {
/* array of pixel coords */
- ASSERT(rb->PutValues);
- rb->PutValues(ctx, rb, span->end,
- span->array->x, span->array->y,
- span->array->rgba, span->array->mask);
+ put_values(ctx, rb,
+ span->array->ChanType, span->end,
+ span->array->x, span->array->y,
+ span->array->rgba, span->array->mask);
}
else {
/* horizontal run of pixels */
- ASSERT(rb->PutRow);
- rb->PutRow(ctx, rb, span->end, span->x, span->y,
- span->array->rgba,
- span->writeAll ? NULL: span->array->mask);
+ _swrast_put_row(ctx, rb,
+ span->array->ChanType,
+ span->end, span->x, span->y,
+ span->array->rgba,
+ span->writeAll ? NULL: span->array->mask);
}
if (!multiFragOutputs && numBuffers > 1) {
@@ -1305,16 +1405,17 @@ end:
/**
- * Read RGBA pixels from a renderbuffer. Clipping will be done to prevent
- * reading ouside the buffer's boundaries.
- * \param dstType datatype for returned colors
+ * Read float RGBA pixels from a renderbuffer. Clipping will be done to
+ * prevent reading ouside the buffer's boundaries.
* \param rgba the returned colors
*/
void
_swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y, GLenum dstType,
+ 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;
@@ -1325,6 +1426,8 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb,
}
else {
GLint skip, length;
+ GLubyte *src;
+
if (x < 0) {
/* left edge clipping */
skip = -x;
@@ -1353,7 +1456,6 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb,
}
ASSERT(rb);
- ASSERT(rb->GetRow);
ASSERT(rb->_BaseFormat == GL_RGBA ||
rb->_BaseFormat == GL_RGB ||
rb->_BaseFormat == GL_RG ||
@@ -1363,70 +1465,69 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb,
rb->_BaseFormat == GL_LUMINANCE_ALPHA ||
rb->_BaseFormat == GL_ALPHA);
- if (rb->DataType == dstType) {
- rb->GetRow(ctx, rb, length, x + skip, y,
- (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(rb->DataType));
+ assert(srb->Map);
+
+ src = _swrast_pixel_address(rb, x + skip, y);
+
+ if (dstType == GL_UNSIGNED_BYTE) {
+ _mesa_unpack_ubyte_rgba_row(rb->Format, length, src,
+ (GLubyte (*)[4]) rgba + skip);
+ }
+ else if (dstType == GL_FLOAT) {
+ _mesa_unpack_rgba_row(rb->Format, length, src,
+ (GLfloat (*)[4]) rgba + skip);
}
else {
- GLuint temp[MAX_WIDTH * 4];
- rb->GetRow(ctx, rb, length, x + skip, y, temp);
- _mesa_convert_colors(rb->DataType, temp,
- dstType, (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(dstType),
- length, NULL);
+ _mesa_problem(ctx, "unexpected type in _swrast_read_rgba_span()");
}
}
}
/**
- * Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid
- * reading values outside the buffer bounds.
- * We can use this for reading any format/type of renderbuffer.
- * \param valueSize is the size in bytes of each value (pixel) put into the
- * values array.
+ * Get colors at x/y positions with clipping.
+ * \param type type of values to return
*/
-void
-_swrast_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values, GLuint valueSize)
+static void
+get_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values, GLenum type)
{
- GLuint i, inCount = 0, inStart = 0;
+ GLuint i;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 &&
x[i] < (GLint) rb->Width && y[i] < (GLint) rb->Height) {
/* inside */
- if (inCount == 0)
- inStart = i;
- inCount++;
- }
- else {
- if (inCount > 0) {
- /* read [inStart, inStart + inCount) */
- rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart,
- (GLubyte *) values + inStart * valueSize);
- inCount = 0;
+ const GLubyte *src = _swrast_pixel_address(rb, x[i], y[i]);
+
+ if (type == GL_UNSIGNED_BYTE) {
+ _mesa_unpack_ubyte_rgba_row(rb->Format, 1, src,
+ (GLubyte (*)[4]) values + i);
+ }
+ else if (type == GL_FLOAT) {
+ _mesa_unpack_rgba_row(rb->Format, 1, src,
+ (GLfloat (*)[4]) values + i);
+ }
+ else {
+ _mesa_problem(ctx, "unexpected type in get_values()");
}
}
}
- if (inCount > 0) {
- /* read last values */
- rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart,
- (GLubyte *) values + inStart * valueSize);
- }
}
/**
- * Wrapper for gl_renderbuffer::PutRow() which does clipping.
- * \param valueSize size of each value (pixel) in bytes
+ * Get row of colors with clipping.
+ * \param type type of values to return
*/
-void
-_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const GLvoid *values, GLuint valueSize)
+static void
+get_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ GLvoid *values, GLenum type)
{
GLint skip = 0;
+ GLubyte *src;
if (y < 0 || y >= (GLint) rb->Height)
return; /* above or below */
@@ -1434,7 +1535,7 @@ _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
if (x + (GLint) count <= 0 || x >= (GLint) rb->Width)
return; /* entirely left or right */
- if ((GLint) (x + count) > (GLint) rb->Width) {
+ if (x + count > rb->Width) {
/* right clip */
GLint clip = x + count - rb->Width;
count -= clip;
@@ -1447,42 +1548,19 @@ _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
count -= skip;
}
- rb->PutRow(ctx, rb, count, x, y,
- (const GLubyte *) values + skip * valueSize, NULL);
-}
+ src = _swrast_pixel_address(rb, x, y);
-
-/**
- * Wrapper for gl_renderbuffer::GetRow() which does clipping.
- * \param valueSize size of each value (pixel) in bytes
- */
-void
-_swrast_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- GLvoid *values, GLuint valueSize)
-{
- GLint skip = 0;
-
- if (y < 0 || y >= (GLint) rb->Height)
- return; /* above or below */
-
- if (x + (GLint) count <= 0 || x >= (GLint) rb->Width)
- return; /* entirely left or right */
-
- if (x + count > rb->Width) {
- /* right clip */
- GLint clip = x + count - rb->Width;
- count -= clip;
+ if (type == GL_UNSIGNED_BYTE) {
+ _mesa_unpack_ubyte_rgba_row(rb->Format, count, src,
+ (GLubyte (*)[4]) values + skip);
}
-
- if (x < 0) {
- /* left clip */
- skip = -x;
- x = 0;
- count -= skip;
+ else if (type == GL_FLOAT) {
+ _mesa_unpack_rgba_row(rb->Format, count, src,
+ (GLfloat (*)[4]) values + skip);
+ }
+ else {
+ _mesa_problem(ctx, "unexpected type in get_row()");
}
-
- rb->GetRow(ctx, rb, count, x, y, (GLubyte *) values + skip * valueSize);
}
@@ -1495,7 +1573,6 @@ void *
_swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb,
SWspan *span)
{
- const GLuint pixelSize = RGBA_PIXEL_SIZE(span->array->ChanType);
void *rbPixels;
/* Point rbPixels to a temporary space */
@@ -1503,12 +1580,12 @@ _swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb,
/* Get destination values from renderbuffer */
if (span->arrayMask & SPAN_XY) {
- _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
- rbPixels, pixelSize);
+ get_values(ctx, rb, span->end, span->array->x, span->array->y,
+ rbPixels, span->array->ChanType);
}
else {
- _swrast_get_row(ctx, rb, span->end, span->x, span->y,
- rbPixels, pixelSize);
+ get_row(ctx, rb, span->end, span->x, span->y,
+ rbPixels, span->array->ChanType);
}
return rbPixels;
diff --git a/mesalib/src/mesa/swrast/s_span.h b/mesalib/src/mesa/swrast/s_span.h
index f4d32dd87..ff0fe6cd9 100644
--- a/mesalib/src/mesa/swrast/s_span.h
+++ b/mesalib/src/mesa/swrast/s_span.h
@@ -201,23 +201,13 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span);
extern void
_swrast_read_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y, GLenum type, GLvoid *rgba);
-
-extern void
-_swrast_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- void *values, GLuint valueSize);
+ GLuint n, GLint x, GLint y, GLvoid *rgba);
extern void
_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum datatype,
GLuint count, GLint x, GLint y,
- const GLvoid *values, GLuint valueSize);
-
-extern void
-_swrast_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- GLvoid *values, GLuint valueSize);
-
+ const void *values, const GLubyte *mask);
extern void *
_swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb,
diff --git a/mesalib/src/mesa/swrast/s_spantemp.h b/mesalib/src/mesa/swrast/s_spantemp.h
deleted file mode 100644
index 2d2561b6f..000000000
--- a/mesalib/src/mesa/swrast/s_spantemp.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/*
- * Templates for the span/pixel-array write/read functions called via
- * the gl_renderbuffer's GetRow, GetValues, PutRow, and PutValues.
- *
- * Define the following macros before including this file:
- * NAME(BASE) to generate the function name (i.e. add prefix or suffix)
- * RB_TYPE the renderbuffer DataType
- * SPAN_VARS to declare any local variables
- * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel
- * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel
- * STORE_PIXEL(DST, X, Y, VALUE) to store pixel values in buffer
- * FETCH_PIXEL(DST, SRC) to fetch pixel values from buffer
- *
- * Note that in the STORE_PIXEL macros, we also pass in the (X,Y) coordinates
- * for the pixels to be stored. This is useful when dithering and probably
- * ignored otherwise.
- */
-
-#include "main/macros.h"
-
-
-#if !defined(RB_COMPONENTS)
-#define RB_COMPONENTS 4
-#endif
-
-
-static void
-NAME(get_row)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y, void *values )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values;
- GLuint i;
- INIT_PIXEL_PTR(pixel, x, y);
- for (i = 0; i < count; i++) {
- FETCH_PIXEL(dest[i], pixel);
- INC_PIXEL_PTR(pixel);
- }
- (void) rb;
- (void) ctx;
-}
-
-
-static void
-NAME(get_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[], void *values )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values;
- GLuint i;
- for (i = 0; i < count; i++) {
- INIT_PIXEL_PTR(pixel, x[i], y[i]);
- FETCH_PIXEL(dest[i], pixel);
- }
- (void) rb;
- (void) ctx;
-}
-
-
-static void
-NAME(put_row)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *values, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values;
- GLuint i;
- INIT_PIXEL_PTR(pixel, x, y);
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- STORE_PIXEL(pixel, x + i, y, src[i]);
- }
- INC_PIXEL_PTR(pixel);
- }
- }
- else {
- for (i = 0; i < count; i++) {
- STORE_PIXEL(pixel, x + i, y, src[i]);
- INC_PIXEL_PTR(pixel);
- }
- }
- (void) rb;
- (void) ctx;
-}
-
-
-static void
-NAME(put_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *values, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values;
- GLuint i;
- ASSERT(mask);
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- INIT_PIXEL_PTR(pixel, x[i], y[i]);
- STORE_PIXEL(pixel, x[i], y[i], src[i]);
- }
- }
- (void) rb;
- (void) ctx;
-}
-
-
-#undef NAME
-#undef RB_TYPE
-#undef RB_COMPONENTS
-#undef SPAN_VARS
-#undef INIT_PIXEL_PTR
-#undef INC_PIXEL_PTR
-#undef STORE_PIXEL
-#undef STORE_PIXEL_RGB
-#undef FETCH_PIXEL
diff --git a/mesalib/src/mesa/swrast/s_stencil.c b/mesalib/src/mesa/swrast/s_stencil.c
index fb95ef14d..bbfbf44cc 100644
--- a/mesalib/src/mesa/swrast/s_stencil.c
+++ b/mesalib/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 = (const GLubyte *) rb->Data;
+ const GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_S8) {
- const GLint rowStride = rb->RowStride;
+ 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->RowStride * bpp;
+ 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;
@@ -326,12 +327,14 @@ put_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
const GLubyte stencil[])
{
const GLint w = rb->Width, h = rb->Height;
+ gl_pack_ubyte_stencil_func pack_stencil =
+ _mesa_get_pack_ubyte_stencil_func(rb->Format);
GLuint i;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]);
- _mesa_pack_ubyte_stencil_row(rb->Format, 1, &stencil[i], dst);
+ pack_stencil(&stencil[i], dst);
}
}
}
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 7cb6e68b1..8529ff08d 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -103,18 +103,6 @@ static void fetch_null_texelf( const struct swrast_texture_image *texImage,
_mesa_warning(NULL, "fetch_null_texelf() called!");
}
-static void store_null_texel(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* no-op */
-}
-
-
/**
* Table to map MESA_FORMAT_ to texel fetch/store funcs.
@@ -125,7 +113,6 @@ static struct {
FetchTexelFunc Fetch1D;
FetchTexelFunc Fetch2D;
FetchTexelFunc Fetch3D;
- StoreTexelFunc StoreTexel;
}
texfetch_funcs[MESA_FORMAT_COUNT] =
{
@@ -133,386 +120,331 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_NONE,
fetch_null_texelf,
fetch_null_texelf,
- fetch_null_texelf,
- store_null_texel
+ fetch_null_texelf
},
{
MESA_FORMAT_RGBA8888,
fetch_texel_1d_f_rgba8888,
fetch_texel_2d_f_rgba8888,
- fetch_texel_3d_f_rgba8888,
- store_texel_rgba8888
+ fetch_texel_3d_f_rgba8888
},
{
MESA_FORMAT_RGBA8888_REV,
fetch_texel_1d_f_rgba8888_rev,
fetch_texel_2d_f_rgba8888_rev,
- fetch_texel_3d_f_rgba8888_rev,
- store_texel_rgba8888_rev
+ fetch_texel_3d_f_rgba8888_rev
},
{
MESA_FORMAT_ARGB8888,
fetch_texel_1d_f_argb8888,
fetch_texel_2d_f_argb8888,
- fetch_texel_3d_f_argb8888,
- store_texel_argb8888
+ fetch_texel_3d_f_argb8888
},
{
MESA_FORMAT_ARGB8888_REV,
fetch_texel_1d_f_argb8888_rev,
fetch_texel_2d_f_argb8888_rev,
- fetch_texel_3d_f_argb8888_rev,
- store_texel_argb8888_rev
+ fetch_texel_3d_f_argb8888_rev
},
{
MESA_FORMAT_RGBX8888,
fetch_texel_1d_f_rgbx8888,
fetch_texel_2d_f_rgbx8888,
- fetch_texel_3d_f_rgbx8888,
- store_texel_rgbx8888
+ fetch_texel_3d_f_rgbx8888
},
{
MESA_FORMAT_RGBX8888_REV,
fetch_texel_1d_f_rgbx8888_rev,
fetch_texel_2d_f_rgbx8888_rev,
- fetch_texel_3d_f_rgbx8888_rev,
- store_texel_rgbx8888_rev,
+ fetch_texel_3d_f_rgbx8888_rev
},
{
MESA_FORMAT_XRGB8888,
fetch_texel_1d_f_xrgb8888,
fetch_texel_2d_f_xrgb8888,
- fetch_texel_3d_f_xrgb8888,
- store_texel_xrgb8888
+ fetch_texel_3d_f_xrgb8888
},
{
MESA_FORMAT_XRGB8888_REV,
fetch_texel_1d_f_xrgb8888_rev,
fetch_texel_2d_f_xrgb8888_rev,
- fetch_texel_3d_f_xrgb8888_rev,
- store_texel_xrgb8888_rev,
+ fetch_texel_3d_f_xrgb8888_rev
},
{
MESA_FORMAT_RGB888,
fetch_texel_1d_f_rgb888,
fetch_texel_2d_f_rgb888,
- fetch_texel_3d_f_rgb888,
- store_texel_rgb888
+ fetch_texel_3d_f_rgb888
},
{
MESA_FORMAT_BGR888,
fetch_texel_1d_f_bgr888,
fetch_texel_2d_f_bgr888,
- fetch_texel_3d_f_bgr888,
- store_texel_bgr888
+ fetch_texel_3d_f_bgr888
},
{
MESA_FORMAT_RGB565,
fetch_texel_1d_f_rgb565,
fetch_texel_2d_f_rgb565,
- fetch_texel_3d_f_rgb565,
- store_texel_rgb565
+ fetch_texel_3d_f_rgb565
},
{
MESA_FORMAT_RGB565_REV,
fetch_texel_1d_f_rgb565_rev,
fetch_texel_2d_f_rgb565_rev,
- fetch_texel_3d_f_rgb565_rev,
- store_texel_rgb565_rev
+ fetch_texel_3d_f_rgb565_rev
},
{
MESA_FORMAT_ARGB4444,
fetch_texel_1d_f_argb4444,
fetch_texel_2d_f_argb4444,
- fetch_texel_3d_f_argb4444,
- store_texel_argb4444
+ fetch_texel_3d_f_argb4444
},
{
MESA_FORMAT_ARGB4444_REV,
fetch_texel_1d_f_argb4444_rev,
fetch_texel_2d_f_argb4444_rev,
- fetch_texel_3d_f_argb4444_rev,
- store_texel_argb4444_rev
+ fetch_texel_3d_f_argb4444_rev
},
{
MESA_FORMAT_RGBA5551,
fetch_texel_1d_f_rgba5551,
fetch_texel_2d_f_rgba5551,
- fetch_texel_3d_f_rgba5551,
- store_texel_rgba5551
+ fetch_texel_3d_f_rgba5551
},
{
MESA_FORMAT_ARGB1555,
fetch_texel_1d_f_argb1555,
fetch_texel_2d_f_argb1555,
- fetch_texel_3d_f_argb1555,
- store_texel_argb1555
+ fetch_texel_3d_f_argb1555
},
{
MESA_FORMAT_ARGB1555_REV,
fetch_texel_1d_f_argb1555_rev,
fetch_texel_2d_f_argb1555_rev,
- fetch_texel_3d_f_argb1555_rev,
- store_texel_argb1555_rev
+ fetch_texel_3d_f_argb1555_rev
},
{
MESA_FORMAT_AL44,
fetch_texel_1d_f_al44,
fetch_texel_2d_f_al44,
- fetch_texel_3d_f_al44,
- store_texel_al44
+ fetch_texel_3d_f_al44
},
{
MESA_FORMAT_AL88,
fetch_texel_1d_f_al88,
fetch_texel_2d_f_al88,
- fetch_texel_3d_f_al88,
- store_texel_al88
+ fetch_texel_3d_f_al88
},
{
MESA_FORMAT_AL88_REV,
fetch_texel_1d_f_al88_rev,
fetch_texel_2d_f_al88_rev,
- fetch_texel_3d_f_al88_rev,
- store_texel_al88_rev
+ fetch_texel_3d_f_al88_rev
},
{
MESA_FORMAT_AL1616,
fetch_texel_1d_f_al1616,
fetch_texel_2d_f_al1616,
- fetch_texel_3d_f_al1616,
- store_texel_al1616
+ fetch_texel_3d_f_al1616
},
{
MESA_FORMAT_AL1616_REV,
fetch_texel_1d_f_al1616_rev,
fetch_texel_2d_f_al1616_rev,
- fetch_texel_3d_f_al1616_rev,
- store_texel_al1616_rev
+ fetch_texel_3d_f_al1616_rev
},
{
MESA_FORMAT_RGB332,
fetch_texel_1d_f_rgb332,
fetch_texel_2d_f_rgb332,
- fetch_texel_3d_f_rgb332,
- store_texel_rgb332
+ fetch_texel_3d_f_rgb332
},
{
MESA_FORMAT_A8,
fetch_texel_1d_f_a8,
fetch_texel_2d_f_a8,
- fetch_texel_3d_f_a8,
- store_texel_a8
+ fetch_texel_3d_f_a8
},
{
MESA_FORMAT_A16,
fetch_texel_1d_f_a16,
fetch_texel_2d_f_a16,
- fetch_texel_3d_f_a16,
- store_texel_a16
+ fetch_texel_3d_f_a16
},
{
MESA_FORMAT_L8,
fetch_texel_1d_f_l8,
fetch_texel_2d_f_l8,
- fetch_texel_3d_f_l8,
- store_texel_l8
+ fetch_texel_3d_f_l8
},
{
MESA_FORMAT_L16,
fetch_texel_1d_f_l16,
fetch_texel_2d_f_l16,
- fetch_texel_3d_f_l16,
- store_texel_l16
+ fetch_texel_3d_f_l16
},
{
MESA_FORMAT_I8,
fetch_texel_1d_f_i8,
fetch_texel_2d_f_i8,
- fetch_texel_3d_f_i8,
- store_texel_i8
+ fetch_texel_3d_f_i8
},
{
MESA_FORMAT_I16,
fetch_texel_1d_f_i16,
fetch_texel_2d_f_i16,
- fetch_texel_3d_f_i16,
- store_texel_i16
+ fetch_texel_3d_f_i16
},
{
MESA_FORMAT_YCBCR,
fetch_texel_1d_f_ycbcr,
fetch_texel_2d_f_ycbcr,
- fetch_texel_3d_f_ycbcr,
- store_texel_ycbcr
+ fetch_texel_3d_f_ycbcr
},
{
MESA_FORMAT_YCBCR_REV,
fetch_texel_1d_f_ycbcr_rev,
fetch_texel_2d_f_ycbcr_rev,
- fetch_texel_3d_f_ycbcr_rev,
- store_texel_ycbcr_rev
+ fetch_texel_3d_f_ycbcr_rev
},
{
MESA_FORMAT_R8,
fetch_texel_1d_f_r8,
fetch_texel_2d_f_r8,
- fetch_texel_3d_f_r8,
- store_texel_r8,
+ fetch_texel_3d_f_r8
},
{
MESA_FORMAT_GR88,
fetch_texel_1d_f_gr88,
fetch_texel_2d_f_gr88,
- fetch_texel_3d_f_gr88,
- store_texel_gr88,
+ fetch_texel_3d_f_gr88
},
{
MESA_FORMAT_RG88,
fetch_texel_1d_f_rg88,
fetch_texel_2d_f_rg88,
- fetch_texel_3d_f_rg88,
- store_texel_rg88,
+ fetch_texel_3d_f_rg88
},
{
MESA_FORMAT_R16,
fetch_texel_1d_f_r16,
fetch_texel_2d_f_r16,
- fetch_texel_3d_f_r16,
- store_texel_r16,
+ fetch_texel_3d_f_r16
},
{
MESA_FORMAT_RG1616,
fetch_texel_1d_f_rg1616,
fetch_texel_2d_f_rg1616,
- fetch_texel_3d_f_rg1616,
- store_texel_rg1616,
+ fetch_texel_3d_f_rg1616
},
{
MESA_FORMAT_RG1616_REV,
fetch_texel_1d_f_rg1616_rev,
fetch_texel_2d_f_rg1616_rev,
- fetch_texel_3d_f_rg1616_rev,
- store_texel_rg1616_rev,
+ fetch_texel_3d_f_rg1616_rev
},
{
MESA_FORMAT_ARGB2101010,
fetch_texel_1d_f_argb2101010,
fetch_texel_2d_f_argb2101010,
- fetch_texel_3d_f_argb2101010,
- store_texel_argb2101010
+ fetch_texel_3d_f_argb2101010
},
{
MESA_FORMAT_Z24_S8,
fetch_texel_1d_f_z24_s8,
fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
+ fetch_texel_3d_f_z24_s8
},
{
MESA_FORMAT_S8_Z24,
fetch_texel_1d_f_s8_z24,
fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
+ fetch_texel_3d_f_s8_z24
},
{
MESA_FORMAT_Z16,
fetch_texel_1d_f_z16,
fetch_texel_2d_f_z16,
- fetch_texel_3d_f_z16,
- store_texel_z16
+ fetch_texel_3d_f_z16
},
{
MESA_FORMAT_X8_Z24,
fetch_texel_1d_f_s8_z24,
fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
+ fetch_texel_3d_f_s8_z24
},
{
MESA_FORMAT_Z24_X8,
fetch_texel_1d_f_z24_s8,
fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
+ fetch_texel_3d_f_z24_s8
},
{
MESA_FORMAT_Z32,
fetch_texel_1d_f_z32,
fetch_texel_2d_f_z32,
- fetch_texel_3d_f_z32,
- store_texel_z32
+ fetch_texel_3d_f_z32
},
{
MESA_FORMAT_S8,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_SRGB8,
fetch_texel_1d_srgb8,
fetch_texel_2d_srgb8,
- fetch_texel_3d_srgb8,
- store_texel_srgb8
+ fetch_texel_3d_srgb8
},
{
MESA_FORMAT_SRGBA8,
fetch_texel_1d_srgba8,
fetch_texel_2d_srgba8,
- fetch_texel_3d_srgba8,
- store_texel_srgba8
+ fetch_texel_3d_srgba8
},
{
MESA_FORMAT_SARGB8,
fetch_texel_1d_sargb8,
fetch_texel_2d_sargb8,
- fetch_texel_3d_sargb8,
- store_texel_sargb8
+ fetch_texel_3d_sargb8
},
{
MESA_FORMAT_SL8,
fetch_texel_1d_sl8,
fetch_texel_2d_sl8,
- fetch_texel_3d_sl8,
- store_texel_sl8
+ fetch_texel_3d_sl8
},
{
MESA_FORMAT_SLA8,
fetch_texel_1d_sla8,
fetch_texel_2d_sla8,
- fetch_texel_3d_sla8,
- store_texel_sla8
+ fetch_texel_3d_sla8
},
{
MESA_FORMAT_SRGB_DXT1,
NULL,
_mesa_fetch_texel_2d_f_srgb_dxt1,
- NULL,
NULL
},
{
MESA_FORMAT_SRGBA_DXT1,
NULL,
_mesa_fetch_texel_2d_f_srgba_dxt1,
- NULL,
NULL
},
{
MESA_FORMAT_SRGBA_DXT3,
NULL,
_mesa_fetch_texel_2d_f_srgba_dxt3,
- NULL,
NULL
},
{
MESA_FORMAT_SRGBA_DXT5,
NULL,
_mesa_fetch_texel_2d_f_srgba_dxt5,
- NULL,
NULL
},
@@ -520,162 +452,139 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_RGB_FXT1,
NULL,
_mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_FXT1,
NULL,
_mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_DXT1,
NULL,
_mesa_fetch_texel_2d_f_rgb_dxt1,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_DXT1,
NULL,
_mesa_fetch_texel_2d_f_rgba_dxt1,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_DXT3,
NULL,
_mesa_fetch_texel_2d_f_rgba_dxt3,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_DXT5,
NULL,
_mesa_fetch_texel_2d_f_rgba_dxt5,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_FLOAT32,
fetch_texel_1d_f_rgba_f32,
fetch_texel_2d_f_rgba_f32,
- fetch_texel_3d_f_rgba_f32,
- store_texel_rgba_f32
+ fetch_texel_3d_f_rgba_f32
},
{
MESA_FORMAT_RGBA_FLOAT16,
fetch_texel_1d_f_rgba_f16,
fetch_texel_2d_f_rgba_f16,
- fetch_texel_3d_f_rgba_f16,
- store_texel_rgba_f16
+ fetch_texel_3d_f_rgba_f16
},
{
MESA_FORMAT_RGB_FLOAT32,
fetch_texel_1d_f_rgb_f32,
fetch_texel_2d_f_rgb_f32,
- fetch_texel_3d_f_rgb_f32,
- store_texel_rgb_f32
+ fetch_texel_3d_f_rgb_f32
},
{
MESA_FORMAT_RGB_FLOAT16,
fetch_texel_1d_f_rgb_f16,
fetch_texel_2d_f_rgb_f16,
- fetch_texel_3d_f_rgb_f16,
- store_texel_rgb_f16
+ fetch_texel_3d_f_rgb_f16
},
{
MESA_FORMAT_ALPHA_FLOAT32,
fetch_texel_1d_f_alpha_f32,
fetch_texel_2d_f_alpha_f32,
- fetch_texel_3d_f_alpha_f32,
- store_texel_alpha_f32
+ fetch_texel_3d_f_alpha_f32
},
{
MESA_FORMAT_ALPHA_FLOAT16,
fetch_texel_1d_f_alpha_f16,
fetch_texel_2d_f_alpha_f16,
- fetch_texel_3d_f_alpha_f16,
- store_texel_alpha_f16
+ fetch_texel_3d_f_alpha_f16
},
{
MESA_FORMAT_LUMINANCE_FLOAT32,
fetch_texel_1d_f_luminance_f32,
fetch_texel_2d_f_luminance_f32,
- fetch_texel_3d_f_luminance_f32,
- store_texel_luminance_f32
+ fetch_texel_3d_f_luminance_f32
},
{
MESA_FORMAT_LUMINANCE_FLOAT16,
fetch_texel_1d_f_luminance_f16,
fetch_texel_2d_f_luminance_f16,
- fetch_texel_3d_f_luminance_f16,
- store_texel_luminance_f16
+ fetch_texel_3d_f_luminance_f16
},
{
MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
fetch_texel_1d_f_luminance_alpha_f32,
fetch_texel_2d_f_luminance_alpha_f32,
- fetch_texel_3d_f_luminance_alpha_f32,
- store_texel_luminance_alpha_f32
+ fetch_texel_3d_f_luminance_alpha_f32
},
{
MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
fetch_texel_1d_f_luminance_alpha_f16,
fetch_texel_2d_f_luminance_alpha_f16,
- fetch_texel_3d_f_luminance_alpha_f16,
- store_texel_luminance_alpha_f16
+ fetch_texel_3d_f_luminance_alpha_f16
},
{
MESA_FORMAT_INTENSITY_FLOAT32,
fetch_texel_1d_f_intensity_f32,
fetch_texel_2d_f_intensity_f32,
- fetch_texel_3d_f_intensity_f32,
- store_texel_intensity_f32
+ fetch_texel_3d_f_intensity_f32
},
{
MESA_FORMAT_INTENSITY_FLOAT16,
fetch_texel_1d_f_intensity_f16,
fetch_texel_2d_f_intensity_f16,
- fetch_texel_3d_f_intensity_f16,
- store_texel_intensity_f16
+ fetch_texel_3d_f_intensity_f16
},
{
MESA_FORMAT_R_FLOAT32,
fetch_texel_1d_f_r_f32,
fetch_texel_2d_f_r_f32,
- fetch_texel_3d_f_r_f32,
- store_texel_r_f32
+ fetch_texel_3d_f_r_f32
},
{
MESA_FORMAT_R_FLOAT16,
fetch_texel_1d_f_r_f16,
fetch_texel_2d_f_r_f16,
- fetch_texel_3d_f_r_f16,
- store_texel_r_f16
+ fetch_texel_3d_f_r_f16
},
{
MESA_FORMAT_RG_FLOAT32,
fetch_texel_1d_f_rg_f32,
fetch_texel_2d_f_rg_f32,
- fetch_texel_3d_f_rg_f32,
- store_texel_rg_f32
+ fetch_texel_3d_f_rg_f32
},
{
MESA_FORMAT_RG_FLOAT16,
fetch_texel_1d_f_rg_f16,
fetch_texel_2d_f_rg_f16,
- fetch_texel_3d_f_rg_f16,
- store_texel_rg_f16
+ fetch_texel_3d_f_rg_f16
},
{
MESA_FORMAT_ALPHA_UINT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -683,7 +592,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_ALPHA_UINT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -691,7 +599,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_ALPHA_UINT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -699,7 +606,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_ALPHA_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -707,7 +613,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_ALPHA_INT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -715,7 +620,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_ALPHA_INT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -724,7 +628,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_UINT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -732,7 +635,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_UINT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -740,7 +642,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_UINT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -748,7 +649,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -756,7 +656,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_INT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -764,7 +663,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_INTENSITY_INT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -773,7 +671,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_UINT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -781,7 +678,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_UINT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -789,7 +685,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_UINT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -797,7 +692,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -805,7 +699,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_INT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -813,7 +706,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_INT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -822,7 +714,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_UINT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -830,7 +721,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_UINT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -838,7 +728,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_UINT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -846,7 +735,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -854,7 +742,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_INT16,
NULL,
NULL,
- NULL,
NULL
},
@@ -862,7 +749,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_LUMINANCE_ALPHA_INT32,
NULL,
NULL,
- NULL,
NULL
},
@@ -871,7 +757,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_R_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -879,7 +764,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_RG_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -887,7 +771,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_RGB_INT8,
NULL,
NULL,
- NULL,
NULL
},
@@ -896,64 +779,55 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_RGBA_INT8,
fetch_texel_1d_rgba_int8,
fetch_texel_2d_rgba_int8,
- fetch_texel_3d_rgba_int8,
- store_texel_rgba_int8
+ fetch_texel_3d_rgba_int8
},
{
MESA_FORMAT_R_INT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RG_INT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_INT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_INT16,
fetch_texel_1d_rgba_int16,
fetch_texel_2d_rgba_int16,
- fetch_texel_3d_rgba_int16,
- store_texel_rgba_int16
+ fetch_texel_3d_rgba_int16
},
{
MESA_FORMAT_R_INT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RG_INT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_INT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_INT32,
fetch_texel_1d_rgba_int32,
fetch_texel_2d_rgba_int32,
- fetch_texel_3d_rgba_int32,
- store_texel_rgba_int32
+ fetch_texel_3d_rgba_int32
},
/* non-normalized, unsigned int */
@@ -961,85 +835,73 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_R_UINT8,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RG_UINT8,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_UINT8,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_UINT8,
fetch_texel_1d_rgba_uint8,
fetch_texel_2d_rgba_uint8,
- fetch_texel_3d_rgba_uint8,
- store_texel_rgba_uint8
+ fetch_texel_3d_rgba_uint8
},
{
MESA_FORMAT_R_UINT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RG_UINT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_UINT16,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_UINT16,
fetch_texel_1d_rgba_uint16,
fetch_texel_2d_rgba_uint16,
- fetch_texel_3d_rgba_uint16,
- store_texel_rgba_uint16
+ fetch_texel_3d_rgba_uint16
},
{
MESA_FORMAT_R_UINT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RG_UINT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGB_UINT32,
NULL,
NULL,
- NULL,
NULL
},
{
MESA_FORMAT_RGBA_UINT32,
fetch_texel_1d_rgba_uint32,
fetch_texel_2d_rgba_uint32,
- fetch_texel_3d_rgba_uint32,
- store_texel_rgba_uint32
+ fetch_texel_3d_rgba_uint32
},
/* dudv */
@@ -1047,8 +909,7 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_DUDV8,
fetch_texel_1d_dudv8,
fetch_texel_2d_dudv8,
- fetch_texel_3d_dudv8,
- NULL
+ fetch_texel_3d_dudv8
},
/* signed, normalized */
@@ -1056,224 +917,192 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
MESA_FORMAT_SIGNED_R8,
fetch_texel_1d_signed_r8,
fetch_texel_2d_signed_r8,
- fetch_texel_3d_signed_r8,
- store_texel_signed_r8
+ fetch_texel_3d_signed_r8
},
{
MESA_FORMAT_SIGNED_RG88_REV,
fetch_texel_1d_signed_rg88_rev,
fetch_texel_2d_signed_rg88_rev,
- fetch_texel_3d_signed_rg88_rev,
- store_texel_signed_rg88_rev
+ fetch_texel_3d_signed_rg88_rev
},
{
MESA_FORMAT_SIGNED_RGBX8888,
fetch_texel_1d_signed_rgbx8888,
fetch_texel_2d_signed_rgbx8888,
- fetch_texel_3d_signed_rgbx8888,
- store_texel_signed_rgbx8888
+ fetch_texel_3d_signed_rgbx8888
},
{
MESA_FORMAT_SIGNED_RGBA8888,
fetch_texel_1d_signed_rgba8888,
fetch_texel_2d_signed_rgba8888,
- fetch_texel_3d_signed_rgba8888,
- store_texel_signed_rgba8888
+ fetch_texel_3d_signed_rgba8888
},
{
MESA_FORMAT_SIGNED_RGBA8888_REV,
fetch_texel_1d_signed_rgba8888_rev,
fetch_texel_2d_signed_rgba8888_rev,
- fetch_texel_3d_signed_rgba8888_rev,
- store_texel_signed_rgba8888_rev
+ fetch_texel_3d_signed_rgba8888_rev
},
{
MESA_FORMAT_SIGNED_R16,
fetch_texel_1d_signed_r16,
fetch_texel_2d_signed_r16,
- fetch_texel_3d_signed_r16,
- store_texel_signed_r16
+ fetch_texel_3d_signed_r16
},
{
MESA_FORMAT_SIGNED_GR1616,
fetch_texel_1d_signed_rg1616,
fetch_texel_2d_signed_rg1616,
- fetch_texel_3d_signed_rg1616,
- store_texel_signed_rg1616
+ fetch_texel_3d_signed_rg1616
},
{
MESA_FORMAT_SIGNED_RGB_16,
fetch_texel_1d_signed_rgb_16,
fetch_texel_2d_signed_rgb_16,
- fetch_texel_3d_signed_rgb_16,
- store_texel_signed_rgb_16
+ fetch_texel_3d_signed_rgb_16
},
{
MESA_FORMAT_SIGNED_RGBA_16,
fetch_texel_1d_signed_rgba_16,
fetch_texel_2d_signed_rgba_16,
- fetch_texel_3d_signed_rgba_16,
- store_texel_signed_rgba_16
+ fetch_texel_3d_signed_rgba_16
},
{
MESA_FORMAT_RGBA_16,
fetch_texel_1d_rgba_16,
fetch_texel_2d_rgba_16,
- fetch_texel_3d_rgba_16,
- store_texel_rgba_16
+ fetch_texel_3d_rgba_16
},
{
MESA_FORMAT_RED_RGTC1,
NULL,
_mesa_fetch_texel_2d_f_red_rgtc1,
- NULL,
NULL
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
NULL,
_mesa_fetch_texel_2d_f_signed_red_rgtc1,
- NULL,
NULL
},
{
MESA_FORMAT_RG_RGTC2,
NULL,
_mesa_fetch_texel_2d_f_rg_rgtc2,
- NULL,
NULL
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
NULL,
_mesa_fetch_texel_2d_f_signed_rg_rgtc2,
- NULL,
NULL
},
{
MESA_FORMAT_L_LATC1,
NULL,
_mesa_fetch_texel_2d_f_l_latc1,
- NULL,
NULL
},
{
MESA_FORMAT_SIGNED_L_LATC1,
NULL,
_mesa_fetch_texel_2d_f_signed_l_latc1,
- NULL,
NULL
},
{
MESA_FORMAT_LA_LATC2,
NULL,
_mesa_fetch_texel_2d_f_la_latc2,
- NULL,
NULL
},
{
MESA_FORMAT_SIGNED_LA_LATC2,
NULL,
_mesa_fetch_texel_2d_f_signed_la_latc2,
- NULL,
NULL
},
{
MESA_FORMAT_ETC1_RGB8,
NULL,
_mesa_fetch_texel_2d_f_etc1_rgb8,
- NULL,
NULL
},
{
MESA_FORMAT_SIGNED_A8,
fetch_texel_1d_signed_a8,
fetch_texel_2d_signed_a8,
- fetch_texel_3d_signed_a8,
- store_texel_signed_a8
+ fetch_texel_3d_signed_a8
},
{
MESA_FORMAT_SIGNED_L8,
fetch_texel_1d_signed_l8,
fetch_texel_2d_signed_l8,
- fetch_texel_3d_signed_l8,
- store_texel_signed_l8
+ fetch_texel_3d_signed_l8
},
{
MESA_FORMAT_SIGNED_AL88,
fetch_texel_1d_signed_al88,
fetch_texel_2d_signed_al88,
- fetch_texel_3d_signed_al88,
- store_texel_signed_al88
+ fetch_texel_3d_signed_al88
},
{
MESA_FORMAT_SIGNED_I8,
fetch_texel_1d_signed_i8,
fetch_texel_2d_signed_i8,
- fetch_texel_3d_signed_i8,
- store_texel_signed_i8
+ fetch_texel_3d_signed_i8
},
{
MESA_FORMAT_SIGNED_A16,
fetch_texel_1d_signed_a16,
fetch_texel_2d_signed_a16,
- fetch_texel_3d_signed_a16,
- store_texel_signed_a16
+ fetch_texel_3d_signed_a16
},
{
MESA_FORMAT_SIGNED_L16,
fetch_texel_1d_signed_l16,
fetch_texel_2d_signed_l16,
- fetch_texel_3d_signed_l16,
- store_texel_signed_l16
+ fetch_texel_3d_signed_l16
},
{
MESA_FORMAT_SIGNED_AL1616,
fetch_texel_1d_signed_al1616,
fetch_texel_2d_signed_al1616,
- fetch_texel_3d_signed_al1616,
- store_texel_signed_al1616
+ fetch_texel_3d_signed_al1616
},
{
MESA_FORMAT_SIGNED_I16,
fetch_texel_1d_signed_i16,
fetch_texel_2d_signed_i16,
- fetch_texel_3d_signed_i16,
- store_texel_signed_i16
+ fetch_texel_3d_signed_i16
},
{
MESA_FORMAT_RGB9_E5_FLOAT,
fetch_texel_1d_rgb9_e5,
fetch_texel_2d_rgb9_e5,
- fetch_texel_3d_rgb9_e5,
- store_texel_rgb9_e5
+ fetch_texel_3d_rgb9_e5
},
{
MESA_FORMAT_R11_G11_B10_FLOAT,
fetch_texel_1d_r11_g11_b10f,
fetch_texel_2d_r11_g11_b10f,
- fetch_texel_3d_r11_g11_b10f,
- store_texel_r11_g11_b10f
+ fetch_texel_3d_r11_g11_b10f
},
{
MESA_FORMAT_Z32_FLOAT,
fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */
fetch_texel_2d_f_r_f32,
- fetch_texel_3d_f_r_f32,
- store_texel_r_f32
+ fetch_texel_3d_f_r_f32
},
{
MESA_FORMAT_Z32_FLOAT_X24S8,
fetch_texel_1d_z32f_x24s8,
fetch_texel_2d_z32f_x24s8,
- fetch_texel_3d_z32f_x24s8,
- store_texel_z32f_x24s8
+ fetch_texel_3d_z32f_x24s8
},
{
MESA_FORMAT_ARGB2101010_UINT,
NULL,
NULL,
- NULL,
NULL
}
};
@@ -1308,14 +1137,6 @@ _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
}
-StoreTexelFunc
-_mesa_get_texel_store_func(gl_format format)
-{
- assert(format < MESA_FORMAT_COUNT);
- return texfetch_funcs[format].StoreTexel;
-}
-
-
/**
* Initialize the texture image's FetchTexel methods.
*/
diff --git a/mesalib/src/mesa/swrast/s_texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h
index c98aa5c5a..1aa7ce573 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.h
+++ b/mesalib/src/mesa/swrast/s_texfetch.h
@@ -29,9 +29,6 @@
#include "swrast/s_context.h"
-extern StoreTexelFunc
-_mesa_get_texel_store_func(gl_format format);
-
extern FetchTexelFunc
_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index 877c29c9b..b65d33f04 100644
--- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -43,7 +43,7 @@
#if DIM == 1
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
+ ((void) (j), (void) (k), ((type *)(image)->Map + (i) * (size)))
#define FETCH(x) fetch_texel_1d_##x
@@ -51,14 +51,14 @@
#define TEXEL_ADDR( type, image, i, j, k, size ) \
((void) (k), \
- ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
+ ((type *)(image)->Map + ((image)->RowStride * (j) + (i)) * (size)))
#define FETCH(x) fetch_texel_2d_##x
#elif DIM == 3
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((type *)(image)->Data + ((image)->ImageOffsets[k] \
+ ((type *)(image)->Map + ((image)->ImageOffsets[k] \
+ (image)->RowStride * (j) + (i)) * (size))
#define FETCH(x) fetch_texel_3d_##x
@@ -81,16 +81,6 @@ static void FETCH(f_z32)( const struct swrast_texture_image *texImage,
texel[0] = src[0] * (1.0F / 0xffffffff);
}
-#if DIM == 3
-static void store_texel_z32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLuint *depth = (const GLuint *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- dst[0] = *depth;
-}
-#endif
-
/* MESA_FORMAT_Z16 ***********************************************************/
@@ -105,15 +95,6 @@ static void FETCH(f_z16)(const struct swrast_texture_image *texImage,
texel[0] = src[0] * (1.0F / 65535.0F);
}
-#if DIM == 3
-static void store_texel_z16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *depth = (const GLushort *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = *depth;
-}
-#endif
/* MESA_FORMAT_RGBA_F32 ******************************************************/
@@ -130,18 +111,7 @@ static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = src[3];
}
-#if DIM == 3
-static void store_texel_rgba_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *depth = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
- dst[0] = depth[RCOMP];
- dst[1] = depth[GCOMP];
- dst[2] = depth[BCOMP];
- dst[3] = depth[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_F16 ******************************************************/
@@ -159,18 +129,7 @@ static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = _mesa_half_to_float(src[3]);
}
-#if DIM == 3
-static void store_texel_rgba_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
- dst[0] = _mesa_float_to_half(src[RCOMP]);
- dst[1] = _mesa_float_to_half(src[GCOMP]);
- dst[2] = _mesa_float_to_half(src[BCOMP]);
- dst[3] = _mesa_float_to_half(src[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_RGB_F32 *******************************************************/
@@ -187,17 +146,7 @@ static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
- dst[0] = src[RCOMP];
- dst[1] = src[GCOMP];
- dst[2] = src[BCOMP];
-}
-#endif
+
/* MESA_FORMAT_RGB_F16 *******************************************************/
@@ -215,17 +164,7 @@ static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
- dst[0] = _mesa_float_to_half(src[RCOMP]);
- dst[1] = _mesa_float_to_half(src[GCOMP]);
- dst[2] = _mesa_float_to_half(src[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_ALPHA_F32 *****************************************************/
@@ -243,15 +182,7 @@ static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = src[0];
}
-#if DIM == 3
-static void store_texel_alpha_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_ALPHA_F32 *****************************************************/
@@ -269,15 +200,7 @@ static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = _mesa_half_to_float(src[0]);
}
-#if DIM == 3
-static void store_texel_alpha_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
@@ -295,15 +218,7 @@ static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_luminance_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
@@ -321,15 +236,7 @@ static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_luminance_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
@@ -347,16 +254,7 @@ static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *tex
texel[ACOMP] = src[1];
}
-#if DIM == 3
-static void store_texel_luminance_alpha_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
@@ -374,16 +272,7 @@ static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *tex
texel[ACOMP] = _mesa_half_to_float(src[1]);
}
-#if DIM == 3
-static void store_texel_luminance_alpha_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
- dst[1] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_INTENSITY_F32 *************************************************/
@@ -401,15 +290,7 @@ static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = src[0];
}
-#if DIM == 3
-static void store_texel_intensity_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_INTENSITY_F16 *************************************************/
@@ -427,15 +308,7 @@ static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = _mesa_half_to_float(src[0]);
}
-#if DIM == 3
-static void store_texel_intensity_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_R_FLOAT32 *****************************************************/
@@ -453,15 +326,7 @@ static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_r_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_R_FLOAT16 *****************************************************/
@@ -479,15 +344,7 @@ static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_r_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_RG_FLOAT32 ****************************************************/
@@ -505,16 +362,7 @@ static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rg_f32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
-}
-#endif
+
/* MESA_FORMAT_RG_FLOAT16 ****************************************************/
@@ -532,16 +380,7 @@ static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rg_f16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
- dst[1] = _mesa_float_to_half(rgba[GCOMP]);
-}
-#endif
+
/*
@@ -563,15 +402,7 @@ static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage,
-#if DIM == 3
-static void store_texel_rgba8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_RGBA888_REV ***************************************************/
@@ -587,15 +418,7 @@ static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
-#if DIM == 3
-static void store_texel_rgba8888_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_ARGB8888 ******************************************************/
@@ -611,15 +434,7 @@ static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
-#if DIM == 3
-static void store_texel_argb8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_ARGB8888_REV **************************************************/
@@ -635,15 +450,7 @@ static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
}
-#if DIM == 3
-static void store_texel_argb8888_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_RGBX8888 ******************************************************/
@@ -659,15 +466,7 @@ static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-#if DIM == 3
-static void store_texel_rgbx8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff);
-}
-#endif
+
/* MESA_FORMAT_RGBX888_REV ***************************************************/
@@ -683,15 +482,7 @@ static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-#if DIM == 3
-static void store_texel_rgbx8888_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff);
-}
-#endif
+
/* MESA_FORMAT_XRGB8888 ******************************************************/
@@ -707,15 +498,7 @@ static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-#if DIM == 3
-static void store_texel_xrgb8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_XRGB8888_REV **************************************************/
@@ -731,15 +514,7 @@ static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-#if DIM == 3
-static void store_texel_xrgb8888_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff);
-}
-#endif
+
/* MESA_FORMAT_RGB888 ********************************************************/
@@ -755,17 +530,7 @@ static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[BCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_BGR888 ********************************************************/
@@ -781,17 +546,7 @@ static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_bgr888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
-}
-#endif
+
/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
@@ -811,15 +566,7 @@ static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb565(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_RGB565_REV ****************************************************/
@@ -836,18 +583,7 @@ static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb565_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- GLushort p = PACK_COLOR_565(CHAN_TO_UBYTE(rgba[RCOMP]),
- CHAN_TO_UBYTE(rgba[GCOMP]),
- CHAN_TO_UBYTE(rgba[BCOMP]));
- *dst = (p >> 8) | (p << 8); /* byte swap */
-}
-#endif
+
/* MESA_FORMAT_ARGB4444 ******************************************************/
@@ -864,18 +600,7 @@ static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
}
-#if DIM == 3
-static void store_texel_argb4444(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[ACOMP]),
- CHAN_TO_UBYTE(rgba[RCOMP]),
- CHAN_TO_UBYTE(rgba[GCOMP]),
- CHAN_TO_UBYTE(rgba[BCOMP]));
-}
-#endif
+
/* MESA_FORMAT_ARGB4444_REV **************************************************/
@@ -891,18 +616,7 @@ static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
}
-#if DIM == 3
-static void store_texel_argb4444_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[GCOMP]),
- CHAN_TO_UBYTE(rgba[BCOMP]),
- CHAN_TO_UBYTE(rgba[ACOMP]),
- CHAN_TO_UBYTE(rgba[RCOMP]));
-}
-#endif
+
/* MESA_FORMAT_RGBA5551 ******************************************************/
@@ -918,15 +632,7 @@ static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s ) & 0x01) * 1.0F;
}
-#if DIM == 3
-static void store_texel_rgba5551(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_ARGB1555 ******************************************************/
@@ -942,15 +648,7 @@ static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
}
-#if DIM == 3
-static void store_texel_argb1555(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_ARGB1555_REV **************************************************/
@@ -967,15 +665,7 @@ static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
}
-#if DIM == 3
-static void store_texel_argb1555_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_ARGB2101010 ***************************************************/
@@ -992,19 +682,7 @@ static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
}
-#if DIM == 3
-static void store_texel_argb2101010(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
- GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
- GLushort b = CHAN_TO_USHORT(rgba[BCOMP]);
- GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
- *dst = PACK_COLOR_2101010_US(a, r, g, b);
-}
-#endif
+
/* MESA_FORMAT_GR88 **********************************************************/
@@ -1020,17 +698,7 @@ static void FETCH(f_gr88)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_gr88(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- GLubyte r = CHAN_TO_UBYTE(rgba[RCOMP]);
- GLubyte g = CHAN_TO_UBYTE(rgba[GCOMP]);
- *dst = PACK_COLOR_88(g, r);
-}
-#endif
+
/* MESA_FORMAT_RG88 ******************************************************/
@@ -1046,15 +714,7 @@ static void FETCH(f_rg88)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_rg88(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
-}
-#endif
+
/* MESA_FORMAT_AL44 **********************************************************/
@@ -1070,15 +730,7 @@ static void FETCH(f_al44)( const struct swrast_texture_image *texImage,
texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
}
-#if DIM == 3
-static void store_texel_al44(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = PACK_COLOR_44(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_AL88 **********************************************************/
@@ -1094,15 +746,7 @@ static void FETCH(f_al88)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
}
-#if DIM == 3
-static void store_texel_al88(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_R8 ************************************************************/
@@ -1118,15 +762,7 @@ static void FETCH(f_r8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_r8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_R16 ***********************************************************/
@@ -1142,15 +778,7 @@ static void FETCH(f_r16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_r16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = CHAN_TO_USHORT(rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_AL88_REV ******************************************************/
@@ -1166,15 +794,7 @@ static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
}
-#if DIM == 3
-static void store_texel_al88_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_RG1616 ********************************************************/
@@ -1190,17 +810,7 @@ static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_rg1616(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
- GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
- *dst = PACK_COLOR_1616(g, r);
-}
-#endif
+
/* MESA_FORMAT_RG1616_REV ****************************************************/
@@ -1216,15 +826,7 @@ static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0;
}
-#if DIM == 3
-static void store_texel_rg1616_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_AL1616 ********************************************************/
@@ -1240,17 +842,7 @@ static void FETCH(f_al1616)( const struct swrast_texture_image *texImage,
texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
}
-#if DIM == 3
-static void store_texel_al1616(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLushort l = CHAN_TO_USHORT(rgba[RCOMP]);
- GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
- *dst = PACK_COLOR_1616(a, l);
-}
-#endif
+
/* MESA_FORMAT_AL1616_REV ****************************************************/
@@ -1266,15 +858,7 @@ static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
}
-#if DIM == 3
-static void store_texel_al1616_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *rgba = (const GLushort *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_RGB332 ********************************************************/
@@ -1291,15 +875,7 @@ static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb332(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_A8 ************************************************************/
@@ -1315,15 +891,7 @@ static void FETCH(f_a8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
}
-#if DIM == 3
-static void store_texel_a8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_A16 ************************************************************/
@@ -1339,15 +907,7 @@ static void FETCH(f_a16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
}
-#if DIM == 3
-static void store_texel_a16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = CHAN_TO_USHORT(rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_L8 ************************************************************/
@@ -1363,15 +923,7 @@ static void FETCH(f_l8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_l8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_L16 ***********************************************************/
@@ -1387,15 +939,7 @@ static void FETCH(f_l16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_l16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = CHAN_TO_USHORT(rgba[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_I8 ************************************************************/
@@ -1411,15 +955,7 @@ static void FETCH(f_i8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
}
-#if DIM == 3
-static void store_texel_i8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_I16 ***********************************************************/
@@ -1435,15 +971,7 @@ static void FETCH(f_i16)( const struct swrast_texture_image *texImage,
texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
}
-#if DIM == 3
-static void store_texel_i16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = CHAN_TO_USHORT(rgba[RCOMP]);
-}
-#endif
+
/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
@@ -1458,17 +986,7 @@ static void FETCH(srgb8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_srgb8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[BCOMP]; /* no conversion */
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[RCOMP];
-}
-#endif
+
/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
static void FETCH(srgba8)(const struct swrast_texture_image *texImage,
@@ -1481,15 +999,7 @@ static void FETCH(srgba8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
}
-#if DIM == 3
-static void store_texel_srgba8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
static void FETCH(sargb8)(const struct swrast_texture_image *texImage,
@@ -1502,15 +1012,7 @@ static void FETCH(sargb8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
}
-#if DIM == 3
-static void store_texel_sargb8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
+
/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
static void FETCH(sl8)(const struct swrast_texture_image *texImage,
@@ -1523,15 +1025,7 @@ static void FETCH(sl8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_sl8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
+
/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
static void FETCH(sla8)(const struct swrast_texture_image *texImage,
@@ -1544,16 +1038,7 @@ static void FETCH(sla8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
}
-#if DIM == 3
-static void store_texel_sla8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_INT8 **************************************************/
@@ -1569,19 +1054,7 @@ FETCH(rgba_int8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_int8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_INT16 **************************************************/
@@ -1597,19 +1070,7 @@ FETCH(rgba_int16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_int16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_INT32 **************************************************/
@@ -1625,19 +1086,7 @@ FETCH(rgba_int32)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_int32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLint *rgba = (const GLint *) texel;
- GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_UINT8 **************************************************/
@@ -1653,19 +1102,7 @@ FETCH(rgba_uint8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_uint8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_UINT16 **************************************************/
@@ -1681,19 +1118,7 @@ FETCH(rgba_uint16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_uint16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *rgba = (const GLushort *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_RGBA_UINT32 **************************************************/
@@ -1709,19 +1134,7 @@ FETCH(rgba_uint32)(const struct swrast_texture_image *texImage,
texel[ACOMP] = (GLfloat) src[3];
}
-#if DIM == 3
-static void
-store_texel_rgba_uint32(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLuint *rgba = (const GLuint *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_DUDV8 ********************************************************/
@@ -1751,15 +1164,7 @@ static void FETCH(signed_r8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_signed_r8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_A8 ***********************************************/
@@ -1774,15 +1179,7 @@ static void FETCH(signed_a8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
}
-#if DIM == 3
-static void store_texel_signed_a8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_L8 ***********************************************/
@@ -1797,15 +1194,7 @@ static void FETCH(signed_l8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_signed_l8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_I8 ***********************************************/
@@ -1820,15 +1209,7 @@ static void FETCH(signed_i8)( const struct swrast_texture_image *texImage,
texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
}
-#if DIM == 3
-static void store_texel_signed_i8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
@@ -1843,15 +1224,7 @@ static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_signed_rg88_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rg = (const GLbyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = PACK_COLOR_88(rg[GCOMP], rg[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
@@ -1866,15 +1239,7 @@ static void FETCH(signed_al88)( const struct swrast_texture_image *texImage,
texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
}
-#if DIM == 3
-static void store_texel_signed_al88(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rg = (const GLbyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = PACK_COLOR_88(rg[ACOMP], rg[RCOMP]);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
@@ -1889,15 +1254,7 @@ static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-#if DIM == 3
-static void store_texel_signed_rgbx8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
@@ -1912,15 +1269,7 @@ static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage,
texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
}
-#if DIM == 3
-static void store_texel_signed_rgba8888(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
@@ -1932,15 +1281,7 @@ static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texIm
texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
}
-#if DIM == 3
-static void store_texel_signed_rgba8888_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
+
@@ -1957,16 +1298,7 @@ FETCH(signed_r16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void
-store_texel_signed_r16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[0];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_A16 ***********************************************/
@@ -1982,16 +1314,7 @@ FETCH(signed_a16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
}
-#if DIM == 3
-static void
-store_texel_signed_a16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_L16 ***********************************************/
@@ -2007,16 +1330,7 @@ FETCH(signed_l16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void
-store_texel_signed_l16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_I16 ***********************************************/
@@ -2032,16 +1346,7 @@ FETCH(signed_i16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
}
-#if DIM == 3
-static void
-store_texel_signed_i16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
@@ -2057,17 +1362,7 @@ FETCH(signed_rg1616)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void
-store_texel_signed_rg1616(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
- dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
@@ -2083,17 +1378,7 @@ FETCH(signed_al1616)(const struct swrast_texture_image *texImage,
texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
}
-#if DIM == 3
-static void
-store_texel_signed_al1616(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
- dst[1] = CHAN_TO_SHORT(rgba[ACOMP]);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
@@ -2109,18 +1394,7 @@ FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void
-store_texel_signed_rgb_16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
- dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
- dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
- dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
-}
-#endif
+
/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
@@ -2136,19 +1410,7 @@ FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
}
-#if DIM == 3
-static void
-store_texel_signed_rgba_16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
- dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
- dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
- dst[3] = CHAN_TO_SHORT(rgba[ACOMP]);
-}
-#endif
+
@@ -2165,19 +1427,7 @@ FETCH(rgba_16)(const struct swrast_texture_image *texImage,
texel[ACOMP] = USHORT_TO_FLOAT( s[3] );
}
-#if DIM == 3
-static void
-store_texel_rgba_16(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLchan *rgba = (const GLchan *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- dst[0] = CHAN_TO_USHORT(rgba[RCOMP]);
- dst[1] = CHAN_TO_USHORT(rgba[GCOMP]);
- dst[2] = CHAN_TO_USHORT(rgba[BCOMP]);
- dst[3] = CHAN_TO_USHORT(rgba[ACOMP]);
-}
-#endif
+
@@ -2208,18 +1458,7 @@ static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_ycbcr(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* XXX to do */
-}
-#endif
+
/* MESA_FORMAT_YCBCR_REV *****************************************************/
@@ -2249,18 +1488,7 @@ static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_ycbcr_rev(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* XXX to do */
-}
-#endif
+
/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
@@ -2278,17 +1506,7 @@ static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage,
ASSERT(texel[0] <= 1.0F);
}
-#if DIM == 3
-static void store_texel_z24_s8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- /* only store Z, not stencil */
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLfloat depth = *((GLfloat *) texel);
- GLuint zi = ((GLuint) (depth * 0xffffff)) << 8;
- *dst = zi | (*dst & 0xff);
-}
-#endif
+
/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
@@ -2306,17 +1524,7 @@ static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage,
ASSERT(texel[0] <= 1.0F);
}
-#if DIM == 3
-static void store_texel_s8_z24(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- /* only store Z, not stencil */
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLfloat depth = *((GLfloat *) texel);
- GLuint zi = (GLuint) (depth * 0xffffff);
- *dst = zi | (*dst & 0xff000000);
-}
-#endif
+
/* MESA_FORMAT_RGB9_E5 ******************************************************/
@@ -2329,15 +1537,7 @@ static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_rgb9_e5(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = float3_to_rgb9e5(src);
-}
-#endif
+
/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
@@ -2350,15 +1550,7 @@ static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_r11_g11_b10f(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = float3_to_r11g11b10f(src);
-}
-#endif
+
/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
@@ -2373,15 +1565,6 @@ static void FETCH(z32f_x24s8)(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
-#if DIM == 3
-static void store_texel_z32f_x24s8(struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- dst[0] = src[0];
-}
-#endif
#undef TEXEL_ADDR
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index 21b55a801..d142d3d07 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -1380,7 +1380,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
GLint pos = (j << shift) | i;
- GLubyte *texel = swImg->Data + 3 * pos;
+ GLubyte *texel = swImg->Map + 3 * pos;
rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
@@ -1424,7 +1424,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
const GLint pos = (row << shift) | col;
- const GLuint texel = *((GLuint *) swImg->Data + pos);
+ const GLuint texel = *((GLuint *) swImg->Map + pos);
rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) );
rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff );
rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff );
diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c
index 523420205..140e4b50f 100644
--- a/mesalib/src/mesa/swrast/s_texrender.c
+++ b/mesalib/src/mesa/swrast/s_texrender.c
@@ -15,293 +15,6 @@
*/
-/**
- * Derived from gl_renderbuffer class
- */
-struct texture_renderbuffer
-{
- struct gl_renderbuffer Base; /**< Base class object */
- struct swrast_texture_image *TexImage;
- StoreTexelFunc Store;
- FetchTexelFunc Fetch;
- GLint Yoffset; /**< Layer for 1D array textures. */
- GLint Zoffset; /**< Layer for 2D array textures, or slice
- * for 3D textures
- */
-};
-
-
-/** cast wrapper */
-static inline struct texture_renderbuffer *
-texture_renderbuffer(struct gl_renderbuffer *rb)
-{
- return (struct texture_renderbuffer *) rb;
-}
-
-
-
-/**
- * Get row of values from the renderbuffer that wraps a texture image.
- */
-static void
-texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- ASSERT(trb->TexImage->Base.Width == rb->Width);
- ASSERT(trb->TexImage->Base.Height == rb->Height);
-
- y += trb->Yoffset;
-
- if (rb->DataType == CHAN_TYPE) {
- GLchan *rgbaOut = (GLchan *) values;
- for (i = 0; i < count; i++) {
- GLfloat rgba[4];
- trb->Fetch(trb->TexImage, x + i, y, z, rgba);
- UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- GLushort *zValues = (GLushort *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x + i, y, z, &flt);
- zValues[i] = (GLushort) (flt * 0xffff);
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- GLuint *zValues = (GLuint *) values;
- /*
- const GLdouble scale = (GLdouble) 0xffffffff;
- */
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x + i, y, z, &flt);
-#if 0
- /* this should work, but doesn't (overflow due to low precision) */
- zValues[i] = (GLuint) (flt * scale);
-#else
- /* temporary hack */
- zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
-#endif
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- GLuint *zValues = (GLuint *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x + i, y, z, &flt);
- zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- GLuint *zValues = (GLuint *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x + i, y, z, &flt);
- zValues[i] = (GLuint) (flt * 0xffffff);
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_get_row");
- }
-}
-
-
-static void
-texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- if (rb->DataType == CHAN_TYPE) {
- GLchan *rgbaOut = (GLchan *) values;
- for (i = 0; i < count; i++) {
- GLfloat rgba[4];
- trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
- z, rgba);
- UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- GLushort *zValues = (GLushort *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
- z, &flt);
- zValues[i] = (GLushort) (flt * 0xffff);
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- GLuint *zValues = (GLuint *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
- z, &flt);
-#if 0
- zValues[i] = (GLuint) (flt * 0xffffffff);
-#else
- zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
-#endif
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- GLuint *zValues = (GLuint *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
- z, &flt);
- zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- GLuint *zValues = (GLuint *) values;
- for (i = 0; i < count; i++) {
- GLfloat flt;
- trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
- z, &flt);
- zValues[i] = (GLuint) (flt * 0xffffff);
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_get_values");
- }
-}
-
-
-/**
- * Put row of values into a renderbuffer that wraps a texture image.
- */
-static void
-texture_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- y += trb->Yoffset;
-
- if (rb->DataType == CHAN_TYPE) {
- const GLchan *rgba = (const GLchan *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, rgba);
- }
- rgba += 4;
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- const GLushort *zValues = (const GLushort *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, zValues + i);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, zValues + i);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff));
- trb->Store(trb->TexImage, x + i, y, z, &flt);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff));
- trb->Store(trb->TexImage, x + i, y, z, &flt);
- }
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_put_row");
- }
-}
-
-
-static void
-texture_put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- if (rb->DataType == CHAN_TYPE) {
- const GLchan *rgba = (const GLchan *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba);
- }
- rgba += 4;
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- const GLushort *zValues = (const GLushort *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff));
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- const GLuint *zValues = (const GLuint *) values;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff));
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
- }
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_put_values");
- }
-}
-
-
-static void
-store_nop(struct swrast_texture_image *texImage,
- GLint col, GLint row, GLint img,
- const void *texel)
-{
-}
-
-
static void
delete_texture_wrapper(struct gl_renderbuffer *rb)
{
@@ -318,30 +31,26 @@ delete_texture_wrapper(struct gl_renderbuffer *rb)
static void
wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
{
- struct texture_renderbuffer *trb;
+ struct gl_renderbuffer *rb;
const GLuint name = 0;
ASSERT(att->Type == GL_TEXTURE);
ASSERT(att->Renderbuffer == NULL);
- trb = CALLOC_STRUCT(texture_renderbuffer);
- if (!trb) {
+ rb = ctx->Driver.NewRenderbuffer(ctx, name);
+ if (!rb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture");
return;
}
/* init base gl_renderbuffer fields */
- _mesa_init_renderbuffer(&trb->Base, name);
+ _mesa_init_renderbuffer(rb, name);
/* plug in our texture_renderbuffer-specific functions */
- trb->Base.Delete = delete_texture_wrapper;
- trb->Base.AllocStorage = NULL; /* illegal! */
- trb->Base.GetRow = texture_get_row;
- trb->Base.GetValues = texture_get_values;
- trb->Base.PutRow = texture_put_row;
- trb->Base.PutValues = texture_put_values;
+ rb->Delete = delete_texture_wrapper;
+ rb->AllocStorage = NULL; /* illegal! */
/* update attachment point */
- _mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base));
+ _mesa_reference_renderbuffer(&att->Renderbuffer, rb);
}
/**
@@ -352,100 +61,44 @@ wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
static void
update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
{
- struct texture_renderbuffer *trb
- = (struct texture_renderbuffer *) att->Renderbuffer;
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ struct swrast_texture_image *swImage;
+ gl_format format;
+ GLuint zOffset;
(void) ctx;
- ASSERT(trb);
-
- trb->TexImage = swrast_texture_image(_mesa_get_attachment_teximage(att));
- ASSERT(trb->TexImage);
- trb->Store = _mesa_get_texel_store_func(trb->TexImage->Base.TexFormat);
- if (!trb->Store) {
- /* we'll never draw into some textures (compressed formats) */
- trb->Store = store_nop;
- }
+ swImage = swrast_texture_image(_mesa_get_attachment_teximage(att));
+ assert(swImage);
- if (!trb->TexImage->FetchTexel) {
- _mesa_update_fetch_functions(trb->TexImage->Base.TexObject);
- }
- trb->Fetch = trb->TexImage->FetchTexel;
- assert(trb->Fetch);
+ format = swImage->Base.TexFormat;
if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) {
- trb->Yoffset = att->Zoffset;
- trb->Zoffset = 0;
+ zOffset = 0;
}
else {
- trb->Yoffset = 0;
- trb->Zoffset = att->Zoffset;
+ zOffset = att->Zoffset;
}
- trb->Base.Width = trb->TexImage->Base.Width;
- trb->Base.Height = trb->TexImage->Base.Height;
- trb->Base.RowStride = trb->TexImage->RowStride;
- trb->Base.InternalFormat = trb->TexImage->Base.InternalFormat;
- trb->Base.Format = trb->TexImage->Base.TexFormat;
+ rb->Width = swImage->Base.Width;
+ rb->Height = swImage->Base.Height;
+ rb->InternalFormat = swImage->Base.InternalFormat;
+ rb->_BaseFormat = _mesa_get_format_base_format(format);
- /* Set the gl_renderbuffer::Data field so that mapping the buffer
- * in renderbuffer.c succeeds.
- */
+ /* Want to store linear values, not sRGB */
+ rb->Format = _mesa_get_srgb_format_linear(format);
+
+ /* Set the gl_renderbuffer::Buffer field so that mapping the buffer
+ * succeeds.
+ */
if (att->Texture->Target == GL_TEXTURE_3D ||
att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) {
- trb->Base.Data = trb->TexImage->Buffer +
- trb->TexImage->ImageOffsets[trb->Zoffset] *
- _mesa_get_format_bytes(trb->TexImage->Base.TexFormat);
+ srb->Buffer = swImage->Buffer +
+ swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format);
}
else {
- trb->Base.Data = trb->TexImage->Buffer;
- }
-
- /* XXX may need more special cases here */
- switch (trb->TexImage->Base.TexFormat) {
- case MESA_FORMAT_Z24_S8:
- trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
- trb->Base._BaseFormat = GL_DEPTH_STENCIL;
- break;
- case MESA_FORMAT_S8_Z24:
- trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA;
- trb->Base._BaseFormat = GL_DEPTH_STENCIL;
- break;
- case MESA_FORMAT_Z24_X8:
- trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
- trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- break;
- case MESA_FORMAT_X8_Z24:
- trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA;
- trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- break;
- case MESA_FORMAT_Z16:
- trb->Base.DataType = GL_UNSIGNED_SHORT;
- trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- break;
- case MESA_FORMAT_Z32:
- trb->Base.DataType = GL_UNSIGNED_INT;
- trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- break;
- /* SRGB formats pre EXT_framebuffer_sRGB don't do sRGB translations on FBO readback */
- case MESA_FORMAT_SRGB8:
- trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGB888, _mesa_get_texture_dimensions(att->Texture->Target));
- trb->Base.DataType = CHAN_TYPE;
- trb->Base._BaseFormat = GL_RGBA;
- break;
- case MESA_FORMAT_SRGBA8:
- trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGBA8888, _mesa_get_texture_dimensions(att->Texture->Target));
- trb->Base.DataType = CHAN_TYPE;
- trb->Base._BaseFormat = GL_RGBA;
- break;
- case MESA_FORMAT_SARGB8:
- trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_ARGB8888, _mesa_get_texture_dimensions(att->Texture->Target));
- trb->Base.DataType = CHAN_TYPE;
- trb->Base._BaseFormat = GL_RGBA;
- break;
- default:
- trb->Base.DataType = CHAN_TYPE;
- trb->Base._BaseFormat = GL_RGBA;
+ srb->Buffer = swImage->Buffer;
}
}
diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c
index 337a52f32..72d309300 100644
--- a/mesalib/src/mesa/swrast/s_texture.c
+++ b/mesalib/src/mesa/swrast/s_texture.c
@@ -247,7 +247,7 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
swrast_texture_image(texImage);
/* XXX we'll eventually call _swrast_map_teximage() here */
- swImage->Data = swImage->Buffer;
+ swImage->Map = swImage->Buffer;
}
}
}
@@ -268,7 +268,7 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
= swrast_texture_image(texImage);
/* XXX we'll eventually call _swrast_unmap_teximage() here */
- swImage->Data = NULL;
+ swImage->Map = NULL;
}
}
}
@@ -316,59 +316,6 @@ _swrast_unmap_textures(struct gl_context *ctx)
/**
- * Map or unmap any textures that we may be rendering to as renderbuffers.
- */
-static void
-map_unmap_renderbuffers(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLboolean map)
-{
- GLuint i;
-
- for (i = 0; i < Elements(fb->Attachment); i++) {
- struct gl_texture_object *texObj = fb->Attachment[i].Texture;
- if (texObj) {
- const GLuint level = fb->Attachment[i].TextureLevel;
- const GLuint face = fb->Attachment[i].CubeMapFace;
- struct gl_texture_image *texImage = texObj->Image[face][level];
- if (texImage) {
- struct swrast_texture_image *swImage
- = swrast_texture_image(texImage);
-
- if (map) {
- /* XXX we'll eventually call _swrast_map_teximage() here */
- swImage->Data = swImage->Buffer;
- }
- else {
- /* XXX we'll eventually call _swrast_unmap_teximage() here */
- swImage->Data = NULL;
- }
- }
- }
- }
-}
-
-
-void
-_swrast_map_renderbuffers(struct gl_context *ctx)
-{
- map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_TRUE);
- if (ctx->ReadBuffer != ctx->DrawBuffer)
- map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_TRUE);
-}
-
-
-void
-_swrast_unmap_renderbuffers(struct gl_context *ctx)
-{
- map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_FALSE);
- if (ctx->ReadBuffer != ctx->DrawBuffer)
- map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_FALSE);
-}
-
-
-
-/**
* Called via ctx->Driver.AllocTextureStorage()
* Just have to allocate memory for the texture images.
*/
diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c
index 43deaf47b..124aa5f8e 100644
--- a/mesalib/src/mesa/swrast/s_triangle.c
+++ b/mesalib/src/mesa/swrast/s_triangle.c
@@ -132,7 +132,7 @@ _swrast_culltriangle( struct gl_context *ctx,
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) swImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->Map; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
@@ -157,7 +157,8 @@ _swrast_culltriangle( struct gl_context *ctx,
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
} \
- rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, NULL);
+ _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, span.end, \
+ span.x, span.y, rgba, NULL);
#include "s_tritemp.h"
@@ -189,7 +190,7 @@ _swrast_culltriangle( struct gl_context *ctx,
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) swImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->Map; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
@@ -223,7 +224,8 @@ _swrast_culltriangle( struct gl_context *ctx,
span.intTex[1] += span.intTexStep[1]; \
span.z += span.zStep; \
} \
- rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, span.array->mask);
+ _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, \
+ span.end, span.x, span.y, rgba, span.array->mask);
#include "s_tritemp.h"
@@ -543,7 +545,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
- info.texture = (const GLchan *) swImg->Data; \
+ info.texture = (const GLchan *) swImg->Map; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \
@@ -810,7 +812,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
obj->Image[0][obj->BaseLevel]; \
const struct swrast_texture_image *swImg = \
swrast_texture_image_const(texImg); \
- info.texture = (const GLchan *) swImg->Data; \
+ info.texture = (const GLchan *) swImg->Map; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \