summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_renderbuffer.c96
-rw-r--r--src/mesa/swrast/s_span.c39
-rw-r--r--src/mesa/swrast/s_span.h1
-rw-r--r--src/mesa/swrast/s_texrender.c10
-rw-r--r--src/mesa/swrast/s_triangle.c6
5 files changed, 22 insertions, 130 deletions
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index 2ef3e030cc2..a78c6a191b9 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -40,98 +40,6 @@
#include "swrast/s_renderbuffer.h"
-
-/**
- * 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)
-{
- switch (rb->Format) {
- case MESA_FORMAT_RGB888:
- rb->DataType = GL_UNSIGNED_BYTE;
- break;
-
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_RGBA8888_REV:
- rb->DataType = GL_UNSIGNED_BYTE;
- break;
-
- case MESA_FORMAT_R8:
- rb->DataType = GL_UNSIGNED_BYTE;
-
- break;
-
- case MESA_FORMAT_GR88:
- rb->DataType = GL_UNSIGNED_BYTE;
- break;
-
- case MESA_FORMAT_R16:
- rb->DataType = GL_UNSIGNED_SHORT;
-
- break;
-
- case MESA_FORMAT_RG1616:
- rb->DataType = GL_UNSIGNED_SHORT;
- break;
-
- case MESA_FORMAT_SIGNED_RGBA_16:
- rb->DataType = GL_SHORT;
- break;
-
- case MESA_FORMAT_S8:
- rb->DataType = GL_UNSIGNED_BYTE;
- break;
-
- case MESA_FORMAT_Z16:
- rb->DataType = GL_UNSIGNED_SHORT;
- break;
-
- case MESA_FORMAT_Z32:
- case MESA_FORMAT_X8_Z24:
- case MESA_FORMAT_Z24_X8:
- rb->DataType = GL_UNSIGNED_INT;
- break;
-
- case MESA_FORMAT_Z24_S8:
- case MESA_FORMAT_S8_Z24:
- rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- break;
-
- case MESA_FORMAT_RGBA_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- case MESA_FORMAT_INTENSITY_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- case MESA_FORMAT_LUMINANCE_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- case MESA_FORMAT_ALPHA_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- case MESA_FORMAT_RG_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- case MESA_FORMAT_R_FLOAT32:
- rb->DataType = GL_FLOAT;
- break;
-
- default:
- break;
- }
-}
-
/**
* This is a software fallback for the gl_renderbuffer->AllocStorage
* function.
@@ -204,10 +112,6 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
- _swrast_set_renderbuffer_accessors(rb);
-
- ASSERT(rb->DataType);
-
/* free old buffer storage */
if (rb->Data) {
free(rb->Data);
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 157392a619a..1ad8396f55c 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1048,6 +1048,7 @@ 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)
{
@@ -1057,12 +1058,12 @@ put_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
if (mask[i]) {
GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]);
- if (rb->DataType == GL_UNSIGNED_BYTE) {
+ if (datatype == GL_UNSIGNED_BYTE) {
_mesa_pack_ubyte_rgba_row(rb->Format, 1,
(const GLubyte (*)[4]) values + i, dst);
}
else {
- assert(rb->DataType == GL_FLOAT);
+ assert(datatype == GL_FLOAT);
_mesa_pack_float_rgba_row(rb->Format, count,
(const GLfloat (*)[4]) values + i, dst);
}
@@ -1074,18 +1075,19 @@ put_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
/** 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 (rb->DataType == GL_UNSIGNED_BYTE) {
+ if (datatype == GL_UNSIGNED_BYTE) {
_mesa_pack_ubyte_rgba_row(rb->Format, count,
(const GLubyte (*)[4]) values, dst);
}
else {
- assert(rb->DataType == GL_FLOAT);
+ assert(datatype == GL_FLOAT);
_mesa_pack_float_rgba_row(rb->Format, count,
(const GLfloat (*)[4]) values, dst);
}
@@ -1107,13 +1109,13 @@ _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb,
if (!mask[i] || i == count - 1) {
/* might be the end of a run of pixels */
if (runLen > 0) {
- if (rb->DataType == GL_UNSIGNED_BYTE) {
+ if (datatype == GL_UNSIGNED_BYTE) {
_mesa_pack_ubyte_rgba_row(rb->Format, runLen,
(const GLubyte (*)[4]) values + runStart,
dst + runStart * bpp);
}
else {
- assert(rb->DataType == GL_FLOAT);
+ assert(datatype == GL_FLOAT);
_mesa_pack_float_rgba_row(rb->Format, runLen,
(const GLfloat (*)[4]) values + runStart,
dst + runStart * bpp);
@@ -1329,23 +1331,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) {
@@ -1373,13 +1365,16 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
if (span->arrayMask & SPAN_XY) {
/* array of pixel coords */
- put_values(ctx, rb, span->end,
+ 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 */
- _swrast_put_row(ctx, rb, span->end, span->x, span->y,
+ _swrast_put_row(ctx, rb,
+ span->array->ChanType,
+ span->end, span->x, span->y,
span->array->rgba,
span->writeAll ? NULL: span->array->mask);
}
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index 4d6eb7ec163..ff0fe6cd94c 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -205,6 +205,7 @@ _swrast_read_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
extern 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);
diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c
index 4a944310376..368fa98b214 100644
--- a/src/mesa/swrast/s_texrender.c
+++ b/src/mesa/swrast/s_texrender.c
@@ -146,47 +146,37 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
/* 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;
}
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 2b54cd13153..124aa5f8edd 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -157,7 +157,8 @@ _swrast_culltriangle( struct gl_context *ctx,
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
} \
- _swrast_put_row(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"
@@ -223,7 +224,8 @@ _swrast_culltriangle( struct gl_context *ctx,
span.intTex[1] += span.intTexStep[1]; \
span.z += span.zStep; \
} \
- _swrast_put_row(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"