Hi Aapo,
Sorry for the late response ...
[...]
> What about vertex fog?
> Could there be a way to route interpolated fog coords to the fog hardware
> somehow? I dont mind about doing it with fragment programs but that might
I've tried to implement this, but it remains a bit buggy. The problem seems to
be related to secondary color handling, which is broken even without using
fog.
Attached is the result of my findings. It uses the alpha component of the
secondary color for fog, which I assume to be similar to what fglrx does from
examining the command stream packets using 'check_maps()'.
bye,
Ewald
diff -ur Mesa.orig/src/mesa/drivers/dri/r300/r300_context.c Mesa/src/mesa/drivers/dri/r300/r300_context.c
--- Mesa.orig/src/mesa/drivers/dri/r300/r300_context.c 2006-04-23 11:16:42.0 +0200
+++ Mesa/src/mesa/drivers/dri/r300/r300_context.c 2006-04-23 22:40:40.0 +0200
@@ -77,7 +77,7 @@
#define need_GL_ARB_vertex_buffer_object
#define need_GL_ARB_vertex_program
#define need_GL_EXT_blend_minmax
-//#define need_GL_EXT_fog_coord
+#define need_GL_EXT_fog_coord
#define need_GL_EXT_secondary_color
#define need_GL_EXT_blend_equation_separate
#define need_GL_EXT_blend_func_separate
@@ -102,7 +102,7 @@
{"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
{"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
{"GL_EXT_blend_subtract", NULL},
-// {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
{"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
{"GL_EXT_stencil_wrap", NULL},
{"GL_EXT_texture_edge_clamp", NULL},
diff -ur Mesa.orig/src/mesa/drivers/dri/r300/r300_fragprog.c Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c
--- Mesa.orig/src/mesa/drivers/dri/r300/r300_fragprog.c 2006-03-29 18:51:25.0 +0200
+++ Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c 2006-04-23 22:41:11.0 +0200
@@ -1411,6 +1411,21 @@
if (InputsRead & FRAG_BIT_COL1) {
cs->inputs[FRAG_ATTRIB_COL1].refcount = 0;
cs->inputs[FRAG_ATTRIB_COL1].reg = get_hw_temp(rp);
+/* Patch instructions to split the secondary color register */
+ for (fpi=mp->Base.Instructions;fpi->Opcode != OPCODE_END; fpi++) {
+ for (i=0;i<3;i++) {
+if (fpi->SrcReg[i].Index == FRAG_ATTRIB_COL1) {
+ int ws[4];
+ for (j=0;j<4;j++) {
+ ws[j] = GET_SWZ(fpi->SrcReg[i].Swizzle, j);
+ if (ws[j] == SWIZZLE_W)
+ ws[j] = SWIZZLE_ZERO;
+ }
+ fpi->SrcReg[i].Swizzle = MAKE_SWIZZLE4(ws[0], ws[1], ws[2], ws[3]);
+}
+ }
+}
+
}
InputsRead &= ~FRAG_BIT_COL1;
diff -ur Mesa.orig/src/mesa/drivers/dri/r300/r300_maos.c Mesa/src/mesa/drivers/dri/r300/r300_maos.c
--- Mesa.orig/src/mesa/drivers/dri/r300/r300_maos.c 2006-04-23 11:16:42.0 +0200
+++ Mesa/src/mesa/drivers/dri/r300/r300_maos.c 2006-04-23 22:40:40.0 +0200
@@ -581,8 +581,8 @@
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
if(OutputsWritten & (1hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR1 ))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
+ if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_FOG ))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) ))
diff -ur Mesa.orig/src/mesa/drivers/dri/r300/r300_state.c Mesa/src/mesa/drivers/dri/r300/r300_state.c
--- Mesa.orig/src/mesa/drivers/dri/r300/r300_state.c 2006-04-20 23:01:42.0 +0200
+++ Mesa/src/mesa/drivers/dri/r300/r300_state.c 2006-04-23 22:40:55.0 +0200
@@ -679,15 +679,8 @@
R300_STATECHANGE(r300, fogs);
r300->hw.fogs.cmd[R300_FOGS_STATE] =
(r300->hw.fogs.cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) | R300_FOG_MODE_LINEAR;
-
- if (ctx->Fog.Start == ctx->Fog.End) {
-fogScale.f = -1.0;
-fogStart.f = 1.0;
- }
- else {
-fogScale.f = 1.0 / (ctx->Fog.End-ctx->Fog.Start);
-fogStart.f = -ctx->Fog.Start / (ctx->Fog.End-ctx->Fog.Start);
- }
+ fogScale.f = -1.0;
+ fogStart.f = 1.0;
break;
case GL_EXP:
R300_STATECHANGE(r300, fogs);
@@ -722,14 +715,8 @@
case GL_FOG_START:
case GL_FOG_END:
if (ctx->Fog.Mode == GL_LINEAR) {
- if (ctx->Fog.Start == ctx->Fog.End) {
-fogScale.f = -1.0;
-fogStart.f = 1.0;
- }
- else {
-fogScale.f = 1.0 / (ctx->Fog.End-ctx->Fog.Start);
-fogStart.f = -ctx->Fog.Start / (ctx->Fog.End-ctx->Fog.Start);
- }
+ fogScale.f = -1.0;
+ fo