ubyte num_inputs;
ubyte num_outputs;
- uint outputs_written; /**< bitmask */
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
const float fx = (float) quad->x0;
const float fy = (float) quad->y0;
struct tgsi_exec_machine *machine = &qss->machine;
+ uint colorOut;
/* Consts does not require 16 byte alignment. */
machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT];
quad->mask &= tgsi_exec_machine_run( machine );
}
- /* store result color (always in output[1]) */
- memcpy(
- quad->outputs.color,
- &machine->Outputs[1].xyzw[0].f[0],
- sizeof( quad->outputs.color ) );
-
- /* Z */
- if (qss->stage.softpipe->fs->outputs_written & 0x1) {
+ if (qss->stage.softpipe->fs->output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
/* output[0] is new Z */
uint i;
for (i = 0; i < 4; i++) {
quad->outputs.depth[i] = machine->Outputs[0].xyzw[2].f[i];
}
+ colorOut = 1;
}
else {
- /* pass input Z to output Z */
+ /* pass input Z (which was interpolated by the executor) to output Z */
uint i;
for (i = 0; i < 4; i++) {
quad->outputs.depth[i] = machine->Inputs[0].xyzw[2].f[i];
}
+ colorOut = 0;
}
+ /* store result color */
+ /* XXX need to handle multiple color outputs someday */
+ assert(qss->stage.softpipe->fs->output_semantic_name[colorOut]
+ == TGSI_SEMANTIC_COLOR);
+ memcpy(
+ quad->outputs.color,
+ &machine->Outputs[colorOut].xyzw[0].f[0],
+ sizeof( quad->outputs.color ) );
+
/* shader may cull fragments */
if( quad->mask ) {
qs->next->run( qs->next, quad );
*/\r
static GLuint\r
map_register_file_index(\r
- GLuint processor,\r
GLuint file,\r
GLuint index,\r
const GLuint inputMapping[],\r
const GLuint outputMapping[])\r
{\r
- GLuint mapped_index;\r
-\r
- assert(processor == TGSI_PROCESSOR_FRAGMENT\r
- || processor == TGSI_PROCESSOR_VERTEX);\r
-\r
switch( file ) {\r
case TGSI_FILE_INPUT:\r
/* inputs are mapped according to the user-defined map */\r
return inputMapping[index];\r
\r
case TGSI_FILE_OUTPUT:\r
- if( processor == TGSI_PROCESSOR_FRAGMENT ) {\r
- /* fragment program outputs are hard-coded:\r
- * depth result -> index 0\r
- * color results -> index 1, 2, ...\r
- */\r
- if( index == FRAG_RESULT_DEPR ) {\r
- mapped_index = 0; /**TGSI_ATTRIB_POS;**/\r
- }\r
- else {\r
- assert( index == FRAG_RESULT_COLR );\r
- mapped_index = 1; /**TGSI_ATTRIB_COLOR0;**/\r
- }\r
- }\r
- else {\r
- /* vertex outputs are mapped according to the user-defined map */\r
- mapped_index = outputMapping[index];\r
- }\r
- break;\r
+ return outputMapping[index];\r
\r
default:\r
- mapped_index = index;\r
+ return index;\r
}\r
-\r
- return mapped_index;\r
}\r
\r
/*\r
fulldst = &fullinst->FullDstRegisters[0];\r
fulldst->DstRegister.File = map_register_file( inst->DstReg.File );\r
fulldst->DstRegister.Index = map_register_file_index(\r
- processor,\r
fulldst->DstRegister.File,\r
inst->DstReg.Index,\r
inputMapping,\r
fullsrc = &fullinst->FullSrcRegisters[i];\r
fullsrc->SrcRegister.File = map_register_file( inst->SrcReg[i].File );\r
fullsrc->SrcRegister.Index = map_register_file_index(\r
- processor,\r
fullsrc->SrcRegister.File,\r
inst->SrcReg[i].Index,\r
inputMapping,\r
defaultOutputMapping[attr] = slot;
}
- vs.outputs_written |= (1 << slot);
-
/*
printf("Output %u -> slot %u\n", attr, slot);
*/
}
/*
- * Semantics for outputs
+ * Semantics and mapping for outputs
*/
{
uint numColors = 0;
GLbitfield outputsWritten = stfp->Base.Base.OutputsWritten;
- /* output[0] is always Z, but may not really be written */
- fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION;
- fs.output_semantic_index[fs.num_outputs] = 0;
- outputMapping[FRAG_RESULT_DEPR] = fs.num_outputs;
- fs.num_outputs++;
-
+ /* if z is written, emit that first */
if (outputsWritten & (1 << FRAG_RESULT_DEPR)) {
- fs.outputs_written |= 0x1;
+ fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION;
+ fs.output_semantic_index[fs.num_outputs] = 0;
+ outputMapping[FRAG_RESULT_DEPR] = fs.num_outputs;
+ fs.num_outputs++;
outputsWritten &= ~(1 << FRAG_RESULT_DEPR);
}
- /* color outputs begin at output [1] */
+ /* handle remaning outputs (color) */
for (attr = 0; attr < FRAG_RESULT_MAX; attr++) {
if (outputsWritten & (1 << attr)) {
switch (attr) {
case FRAG_RESULT_DEPR:
+ /* handled above */
assert(0);
break;
case FRAG_RESULT_COLR:
fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR;
fs.output_semantic_index[fs.num_outputs] = numColors;
outputMapping[attr] = fs.num_outputs;
- fs.outputs_written |= (0x2 << numColors);
numColors++;
break;
default: