if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
-/* ================================================================
- * Texture combine functions
- */
-#define VIA_DISABLE 0
-#define VIA_PASSTHRU 1
-#define VIA_REPLACE 2
-#define VIA_MODULATE 3
-#define VIA_DECAL 4
-#define VIA_BLEND 5
-#define VIA_ALPHA_BLEND 6
-#define VIA_ADD 7
-#define VIA_MAX_COMBFUNC 8
-
-static GLuint via_color_combine[][VIA_MAX_COMBFUNC] =
-{
- /* Unit 0:
- */
- {
- /* Disable combiner stage
- */
- 0,
-
- /* Passthru
- */
- 1,
-
- /* GL_REPLACE
- */
- 2,
-
- /* GL_MODULATE
- */
- 3,
-
- /* GL_DECAL
- */
- 4,
-
- /* GL_BLEND
- */
- 5,
-
- /* GL_BLEND according to alpha
- */
- 6,
-
- /* GL_ADD
- */
- 7,
- },
-
- /* Unit 1:
- */
- {
- /* Disable combiner stage (Note: disables all subsequent stages)
- */
- 0,
-
- /* Passthru
- */
- 1,
-
- /* GL_REPLACE
- */
- 2,
- /* GL_MODULATE
- */
- 3,
-
- /* GL_DECAL
- */
- 4,
-
- /* GL_BLEND
- */
- 5,
-
- /* GL_BLEND according to alpha
- */
- 6,
-
- /* GL_ADD
- */
- 7,
- }
-};
-
-static GLuint via_alpha_combine[][VIA_MAX_COMBFUNC] =
-{
- /* Unit 0:
- */
- {
- /* Disable combiner stage
- */
- 0,
-
- /* Passthru
- */
- 1,
-
- /* GL_REPLACE
- */
- 2,
-
- /* GL_MODULATE
- */
- 3,
-
- /* GL_DECAL
- */
- 4,
-
- /* GL_BLEND
- */
- 5,
-
- /* GL_BLEND according to alpha (same as above)
- */
- 6,
-
- /* GL_ADD
- */
- 7,
- },
-
- /* Unit 1:
- */
- {
- /* Disable combiner stage
- */
- 0,
-
- /* Passthru
- */
- 1,
-
- /* GL_REPLACE
- */
- 2,
-
- /* GL_MODULATE
- */
- 3,
-
- /* GL_DECAL
- */
- 4,
-
- /* GL_BLEND
- */
- 5,
-
- /* GL_BLEND according to alpha (same as above)
- */
- 6,
-
- /* GL_ADD
- */
- 7,
- }
-};
-
-static void viaUpdateTexEnv(GLcontext *ctx, GLuint unit)
-{
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- const struct gl_texture_object *tObj = texUnit->_Current;
- const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
- GLuint color_combine, alpha_combine;
- if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
- switch (texUnit->EnvMode) {
- case GL_REPLACE:
- if (format == GL_ALPHA) {
- color_combine = via_color_combine[unit][VIA_PASSTHRU];
- alpha_combine = via_alpha_combine[unit][VIA_REPLACE];
- }
- else if (format == GL_LUMINANCE || format == GL_RGB) {
- color_combine = via_color_combine[unit][VIA_REPLACE];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- }
- else {
- color_combine = via_color_combine[unit][VIA_REPLACE];
- alpha_combine = via_alpha_combine[unit][VIA_REPLACE];
- }
- break;
-
- case GL_MODULATE:
- if (format == GL_ALPHA) {
- color_combine = via_color_combine[unit][VIA_PASSTHRU];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- }
- else {
- color_combine = via_color_combine[unit][VIA_MODULATE];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- }
- break;
-
- case GL_DECAL:
- switch (format) {
- case GL_RGBA:
- color_combine = via_color_combine[unit][VIA_ALPHA_BLEND];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- break;
- case GL_RGB:
- color_combine = via_color_combine[unit][VIA_REPLACE];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- break;
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- color_combine = via_color_combine[unit][VIA_PASSTHRU];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_BLEND:
- switch (format) {
- case GL_RGB:
- case GL_LUMINANCE:
- color_combine = via_color_combine[unit][VIA_BLEND];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- break;
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- color_combine = via_color_combine[unit][VIA_BLEND];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- break;
- case GL_ALPHA:
- color_combine = via_color_combine[unit][VIA_PASSTHRU];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- break;
- case GL_INTENSITY:
- color_combine = via_color_combine[unit][VIA_BLEND];
- alpha_combine = via_alpha_combine[unit][VIA_BLEND];
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_ADD:
- switch (format) {
- case GL_RGB:
- case GL_LUMINANCE:
- color_combine = via_color_combine[unit][VIA_ADD];
- alpha_combine = via_alpha_combine[unit][VIA_PASSTHRU];
- break;
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- color_combine = via_color_combine[unit][VIA_ADD];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- break;
- case GL_ALPHA:
- color_combine = via_color_combine[unit][VIA_PASSTHRU];
- alpha_combine = via_alpha_combine[unit][VIA_MODULATE];
- break;
- case GL_INTENSITY:
- color_combine = via_color_combine[unit][VIA_ADD];
- alpha_combine = via_alpha_combine[unit][VIA_ADD];
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- default:
- return;
- }
- if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
-}
static GLboolean viaUpdateTexUnit(GLcontext *ctx, GLuint unit)
{
viaUpdateTexLRU(vmesa, t); /* done too often */
}
- /* Update texture environment if texture object image format or
- * texture environment state has changed.
- */
- if (tObj->Image[0][tObj->BaseLevel]->Format != vmesa->TexEnvImageFmt[unit]) {
- vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
- viaUpdateTexEnv(ctx, unit);
- }
-
return GL_TRUE;
}
else if (texUnit->_ReallyEnabled) {
}
else {
vmesa->CurrentTexObj[unit] = 0;
- vmesa->TexEnvImageFmt[unit] = 0;
VIA_FLUSH_DMA(vmesa);
return GL_TRUE;
}