summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorGareth Hughes <gareth@valinux.com>2001-03-28 20:40:51 +0000
committerGareth Hughes <gareth@valinux.com>2001-03-28 20:40:51 +0000
commit38f28665bf9fb5b2464738ca5074848ec2777ae1 (patch)
treed7df29f52814f6cd466b3ad9c3252c744ee5071c /src/mesa/swrast
parent53933fe9dbfae168dce0688b406810462a6d577b (diff)
More texture format updates. Drivers now need only plug an appropriate
format into texImage->TexFormat, the rest is handled by core Mesa.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_texstore.c68
-rw-r--r--src/mesa/swrast/s_texture.c9
-rw-r--r--src/mesa/swrast/s_triangle.c8
3 files changed, 42 insertions, 43 deletions
diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c
index 5fd91ab649..92afecf91d 100644
--- a/src/mesa/swrast/s_texstore.c
+++ b/src/mesa/swrast/s_texstore.c
@@ -1,4 +1,4 @@
-/* $Id: s_texstore.c,v 1.1 2001/03/19 02:28:59 keithw Exp $ */
+/* $Id: s_texstore.c,v 1.2 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -266,30 +266,31 @@ _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
ASSERT(ctx->Driver.TexImage1D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, 1);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage1D to do the real work */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- GLchan *image = read_color_image(ctx, x, y, width, 1);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
return;
}
- /* now call glTexSubImage1D to do the real work */
+ /* call glTexSubImage1D to redefine the texture */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
@@ -317,33 +318,33 @@ _swrast_copy_texsubimage2d( GLcontext *ctx,
ASSERT(ctx->Driver.TexImage2D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage2D to do the real work */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
return;
}
- /* now call glTexSubImage2D to do the real work */
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
@@ -371,35 +372,34 @@ _swrast_copy_texsubimage3d( GLcontext *ctx,
ASSERT(ctx->Driver.TexImage3D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage3D to do the real work */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
return;
}
- /* now call glTexSubImage3D to do the real work */
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
}
-
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 220d3a4366..73e1b6718d 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.20 2001/03/26 19:42:40 brianp Exp $ */
+/* $Id: s_texture.c,v 1.21 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "macros.h"
#include "mmath.h"
#include "mem.h"
+#include "texformat.h"
#include "teximage.h"
#include "s_context.h"
@@ -1671,15 +1672,13 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
if (t->WrapS == GL_REPEAT &&
t->WrapT == GL_REPEAT &&
t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->Format == GL_RGB &&
- t->Image[baseLevel]->Type == CHAN_TYPE) {
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
swrast->TextureSample[texUnit] = opt_sample_rgb_2d;
}
else if (t->WrapS == GL_REPEAT &&
t->WrapT == GL_REPEAT &&
t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->Format==GL_RGBA &&
- t->Image[baseLevel]->Type == CHAN_TYPE) {
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
swrast->TextureSample[texUnit] = opt_sample_rgba_2d;
}
else
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index e46a7963b5..32022bb678 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.21 2001/03/22 04:54:08 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.22 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -28,7 +28,7 @@
/*
* When the device driver doesn't implement triangle rasterization it
* can hook in _swrast_Triangle, which eventually calls one of these
- * functions to draw triangles.
+ * functions to draw triangles.
*/
#include "glheader.h"
@@ -2284,7 +2284,7 @@ _swrast_choose_triangle( GLcontext *ctx )
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLboolean rgbmode = ctx->Visual.rgbMode;
- if (ctx->Polygon.CullFlag &&
+ if (ctx->Polygon.CullFlag &&
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
USE(nodraw_triangle);
return;
@@ -2333,7 +2333,7 @@ _swrast_choose_triangle( GLcontext *ctx )
&& texObj2D->WrapT==GL_REPEAT
&& texImg->Border==0
&& (format == GL_RGB || format == GL_RGBA)
- && texImg->Type == CHAN_TYPE
+ && texImg->TexFormat->Type == CHAN_TYPE
&& minFilter == magFilter
&& ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
&& ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) {