#define need_GL_ARB_multisample
#define need_GL_ARB_texture_compression
+#define need_GL_EXT_secondary_color
#include "extension_helper.h"
#ifndef SIS_DEBUG
{ "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 },
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;
* 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
* 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);
MASK_StencilWriteEnable);
}
break;
- }
+ case GL_LIGHTING:
+ case GL_COLOR_SUM_EXT:
+ sisUpdateSpecular(ctx);
+ break;
+ }
}
/* add Texture Perspective Enable */
prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable |
MASK_TexturePerspectiveEnable | MASK_DitherEnable;
- /*| MASK_SpecularEnable*/
/*
prev->hwCapEnable2 = 0x00aa0080;
ctx->Driver.RenderMode = NULL;
ctx->Driver.Scissor = sisDDScissor;
ctx->Driver.ShadeModel = sisDDShadeModel;
+ ctx->Driver.LightModelfv = sisDDLightModelfv;
ctx->Driver.Viewport = sisDDViewport;
/* Pixel path fallbacks. */
#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]); \
} 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; \
#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 *
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);
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 */