summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorEric Anholt <anholt@FreeBSD.org>2005-10-24 21:30:06 +0000
committerEric Anholt <anholt@FreeBSD.org>2005-10-24 21:30:06 +0000
commit81d3bf58ff2b143b7df16e5d7af8672b33626e40 (patch)
tree0814f998c98578d8683467126620817ce1f25ce3 /src/mesa/drivers
parent310f1551b45b190b52ee4c7a7a2beda4becfcf3f (diff)
Add support for GL_EXT_secondary_color, tested with seccolor test.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c2
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.h2
-rw-r--r--src/mesa/drivers/dri/sis/sis_reg.h12
-rw-r--r--src/mesa/drivers/dri/sis/sis_state.c27
-rw-r--r--src/mesa/drivers/dri/sis/sis_tris.c24
5 files changed, 50 insertions, 17 deletions
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index 8e2aa88ca3..642560a0d9 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -60,6 +60,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define need_GL_ARB_multisample
#define need_GL_ARB_texture_compression
+#define need_GL_EXT_secondary_color
#include "extension_helper.h"
#ifndef SIS_DEBUG
@@ -78,6 +79,7 @@ struct dri_extension card_extensions[] =
{ "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
{ "GL_ARB_texture_mirrored_repeat", NULL },
{ "GL_EXT_texture_lod_bias", NULL },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
{ "GL_EXT_stencil_wrap", NULL },
/*{ "GL_MESA_ycbcr_texture", NULL },*/ /* not working yet */
{ "GL_NV_blend_square", NULL },
diff --git a/src/mesa/drivers/dri/sis/sis_context.h b/src/mesa/drivers/dri/sis/sis_context.h
index 54c1f0458f..fb5908407c 100644
--- a/src/mesa/drivers/dri/sis/sis_context.h
+++ b/src/mesa/drivers/dri/sis/sis_context.h
@@ -265,6 +265,8 @@ struct sis_context
void *vb_agp_handle;
GLuint vb_agp_offset;
GLboolean using_agp;
+ GLint coloroffset; /* Offset in vertex format of current color */
+ GLint specoffset; /* Offset in vertex format of specular color */
GLuint NewGLState;
GLuint Fallback;
diff --git a/src/mesa/drivers/dri/sis/sis_reg.h b/src/mesa/drivers/dri/sis/sis_reg.h
index 1c245898a4..fcfa92f23c 100644
--- a/src/mesa/drivers/dri/sis/sis_reg.h
+++ b/src/mesa/drivers/dri/sis/sis_reg.h
@@ -234,12 +234,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* wrong, new names SiS_PS_* based off of the 4.3.0 driver and research are
* below.
*/
-#define SiS_PS_HAS_XYZ 0x08000000
-#define SiS_PS_HAS_W 0x04000000
-#define SiS_PS_HAS_SPECULAR 0x02000000 /* XXX ? */
-#define SiS_PS_HAS_DIFFUSE 0x01000000
-#define SiS_PS_HAS_UV0 0x00400000
-#define SiS_PS_HAS_UV1 0x00200000
+#define SiS_PS_HAS_XYZ MASK_PsVertex_HAS_RHW
+#define SiS_PS_HAS_W MASK_PsVertex_HAS_NORMALXYZ
+#define SiS_PS_HAS_DIFFUSE MASK_PsVertex_HAS_SPECULAR
+#define SiS_PS_HAS_SPECULAR MASK_PsVertex_HAS_DIFFUSE
+#define SiS_PS_HAS_UV0 MASK_PsVertex_HAS_UVSet2
+#define SiS_PS_HAS_UV1 MASK_PsVertex_HAS_UVSet3
#define MASK_PsVertex_HAS_RHW 0x08000000
#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000
#define MASK_PsVertex_HAS_DIFFUSE 0x02000000
diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c
index 01688c2fda..195a624b40 100644
--- a/src/mesa/drivers/dri/sis/sis_state.c
+++ b/src/mesa/drivers/dri/sis/sis_state.c
@@ -400,6 +400,25 @@ static void sisDDColorMask( GLcontext *ctx,
* Rendering attributes
*/
+static void sisUpdateSpecular(GLcontext *ctx)
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *current = &smesa->current;
+
+ if (NEED_SECONDARY_COLOR(ctx))
+ current->hwCapEnable |= MASK_SpecularEnable;
+ else
+ current->hwCapEnable &= ~MASK_SpecularEnable;
+}
+
+static void sisDDLightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ sisUpdateSpecular(ctx);
+ }
+}
+
static void sisDDShadeModel( GLcontext *ctx, GLenum mode )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
@@ -636,7 +655,11 @@ sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state )
MASK_StencilWriteEnable);
}
break;
- }
+ case GL_LIGHTING:
+ case GL_COLOR_SUM_EXT:
+ sisUpdateSpecular(ctx);
+ break;
+ }
}
@@ -694,7 +717,6 @@ void sisDDInitState( sisContextPtr smesa )
/* add Texture Perspective Enable */
prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable |
MASK_TexturePerspectiveEnable | MASK_DitherEnable;
- /*| MASK_SpecularEnable*/
/*
prev->hwCapEnable2 = 0x00aa0080;
@@ -829,6 +851,7 @@ void sisDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.RenderMode = NULL;
ctx->Driver.Scissor = sisDDScissor;
ctx->Driver.ShadeModel = sisDDShadeModel;
+ ctx->Driver.LightModelfv = sisDDLightModelfv;
ctx->Driver.Viewport = sisDDViewport;
/* Pixel path fallbacks. */
diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c
index de91268ee6..da1e1ee692 100644
--- a/src/mesa/drivers/dri/sis/sis_tris.c
+++ b/src/mesa/drivers/dri/sis/sis_tris.c
@@ -379,7 +379,7 @@ do { \
#define VERT_SET_SPEC( v0, c ) \
do { \
- if (havespec) { \
+ if (specoffset != 0) { \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
@@ -387,7 +387,7 @@ do { \
} while (0)
#define VERT_COPY_SPEC( v0, v1 ) \
do { \
- if (havespec) { \
+ if (specoffset != 0) { \
v0->v.specular.red = v1->v.specular.red; \
v0->v.specular.green = v1->v.specular.green; \
v0->v.specular.blue = v1->v.specular.blue; \
@@ -396,15 +396,15 @@ do { \
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
-#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
-#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+#define VERT_SAVE_SPEC( idx ) if (specoffset != 0) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset != 0) v[idx]->ui[specoffset] = spec[idx]
#define LOCAL_VARS(n) \
sisContextPtr smesa = SIS_CONTEXT(ctx); \
GLuint color[n], spec[n]; \
- GLuint coloroffset = (smesa->vertex_size == 4 ? 3 : 4); \
- GLboolean havespec = (smesa->vertex_size == 4 ? 0 : 1); \
- (void) color; (void) spec; (void) coloroffset; (void) havespec;
+ GLuint coloroffset = smesa->coloroffset; \
+ GLuint specoffset = smesa->specoffset; \
+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
/***********************************************************************
* Helpers for rendering unfilled primitives *
@@ -833,14 +833,17 @@ static void sisRenderStart( GLcontext *ctx )
if (index & _TNL_BITS_TEX_ANY) {
EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT);
AGPParseSet |= SiS_PS_HAS_W;
+ smesa->coloroffset = 4;
} else {
EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT);
+ smesa->coloroffset = 3;
}
EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA);
if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
AGPParseSet |= SiS_PS_HAS_SPECULAR;
+ smesa->specoffset = smesa->coloroffset + 1;
if (index & _TNL_BIT_COLOR1) {
EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR);
@@ -848,10 +851,13 @@ static void sisRenderStart( GLcontext *ctx )
EMIT_PAD(3);
}
- if (index & _TNL_BIT_FOG)
+ if (index & _TNL_BIT_FOG) {
EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F);
- else
+ } else {
EMIT_PAD(1);
+ }
+ } else {
+ smesa->specoffset = 0;
}
/* projective textures are not supported by the hardware */