D3D9 Shader Model 2 restricted the fog register to one component,
http://msdn.microsoft.com/en-us/library/windows/desktop/
bb172945.aspx ,
but that restriction no longer exists in Shader Model 3, and several
WHCK tests enforce that.
So this change:
- lifts the single-component restriction TGSI_SEMANTIC_FOG
from Gallium interface
- updates the Mesa state tracker to enforce output fog has (f, 0, 0, 1)
- draw module was updated to leave TGSI_SEMANTIC_FOG output registers
alone
Several gallium drivers that are going out of their way to clear
TGSI_SEMANTIC_FOG components could be simplified in the future.
Thanks to Si Chen and Michal Krol for identifying the problem.
Testing done: piglit fogcoord-*.vpfp tests
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
LLVMBuildStore(builder, out, outputs[attrib][chan]);
}
break;
- case TGSI_SEMANTIC_FOG:
- if (chan == 1 || chan == 2)
- LLVMBuildStore(builder, bld.zero, outputs[attrib][chan]);
- else if (chan == 3)
- LLVMBuildStore(builder, bld.one, outputs[attrib][chan]);
- break;
}
}
}
output[slot][2] = CLAMP(machine->Outputs[slot].xyzw[2].f[j], 0.0f, 1.0f);
output[slot][3] = CLAMP(machine->Outputs[slot].xyzw[3].f[j], 0.0f, 1.0f);
}
- else if (name == TGSI_SEMANTIC_FOG) {
- output[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
- output[slot][1] = 0;
- output[slot][2] = 0;
- output[slot][3] = 1;
- } else
+ else
{
output[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
output[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
Vertex shader inputs and outputs and fragment shader inputs may be
labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
-a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
-shader will use the fog coordinate to compute a fog blend factor which
-is used to blend the normal fragment color with a constant fog color.
-
-Only the first component matters when writing from the vertex shader;
-the driver will ensure that the coordinate is in this format when used
-as a fragment shader input.
+a fog coordinate. Typically, the fragment shader will use the fog coordinate
+to compute a fog blend factor which is used to blend the normal fragment color
+with a constant fog color. But fog coord really is just an ordinary vec4
+register like regular semantics.
TGSI_SEMANTIC_PSIZE
t->outputs[i] = ureg_DECL_output(ureg,
outputSemanticName[i],
outputSemanticIndex[i]);
+ if (outputSemanticName[i] == TGSI_SEMANTIC_FOG) {
+ /* force register to contain a fog coordinate in the form (F, 0, 0, 1). */
+ ureg_MOV(ureg,
+ ureg_writemask(t->outputs[i], TGSI_WRITEMASK_XYZW & ~TGSI_WRITEMASK_X),
+ ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 1.0f));
+ t->outputs[i] = ureg_writemask(t->outputs[i], TGSI_WRITEMASK_X);
+ }
}
if (passthrough_edgeflags)
emit_edgeflags(t);
t->outputs[i] = ureg_DECL_output( ureg,
outputSemanticName[i],
outputSemanticIndex[i] );
+ if (outputSemanticName[i] == TGSI_SEMANTIC_FOG) {
+ /* force register to contain a fog coordinate in the form (F, 0, 0, 1). */
+ ureg_MOV(ureg,
+ ureg_writemask(t->outputs[i], TGSI_WRITEMASK_XYZW & ~TGSI_WRITEMASK_X),
+ ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 1.0f));
+ t->outputs[i] = ureg_writemask(t->outputs[i], TGSI_WRITEMASK_X);
+ }
}
if (passthrough_edgeflags)
emit_edgeflags( t, program );