* - extract operand swizzles
* - introduce a temporary register when write masks are needed
*
- * \todo If/when r5xx uses the radeon_program architecture, this can probably
- * be reused.
*/
static GLboolean transform_TEX(
struct radeon_program_transform_context* context,
inst.Opcode != OPCODE_KIL)
return GL_FALSE;
+ /* ARB_shadow & EXT_shadow_funcs */
if (inst.Opcode != OPCODE_KIL &&
compiler->fp->mesa_program.Base.ShadowSamplers & (1 << inst.TexSrcUnit)) {
GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
inst.DstReg.WriteMask = WRITEMASK_XYZW;
}
-
- /* Hardware uses [0..1]x[0..1] range for rectangle textures
- * instead of [0..Width]x[0..Height].
- * Add a scaling instruction.
- */
- if (inst.Opcode != OPCODE_KIL && inst.TexSrcTarget == TEXTURE_RECT_INDEX) {
- gl_state_index tokens[STATE_LENGTH] = {
- STATE_INTERNAL, STATE_R300_TEXRECT_FACTOR, 0, 0,
- 0
- };
-
- int tempreg = radeonCompilerAllocateTemporary(context->compiler);
- int factor_index;
-
- tokens[2] = inst.TexSrcUnit;
- factor_index =
- _mesa_add_state_reference(
- compiler->fp->mesa_program.Base.Parameters, tokens);
-
- tgt = radeonClauseInsertInstructions(context->compiler, context->dest,
- context->dest->NumInstructions, 1);
-
- tgt->Opcode = OPCODE_MAD;
- tgt->DstReg.File = PROGRAM_TEMPORARY;
- tgt->DstReg.Index = tempreg;
- tgt->SrcReg[0] = inst.SrcReg[0];
- tgt->SrcReg[1].File = PROGRAM_STATE_VAR;
- tgt->SrcReg[1].Index = factor_index;
- tgt->SrcReg[2].File = PROGRAM_BUILTIN;
- tgt->SrcReg[2].Swizzle = SWIZZLE_0000;
-
- reset_srcreg(&inst.SrcReg[0]);
- inst.SrcReg[0].File = PROGRAM_TEMPORARY;
- inst.SrcReg[0].Index = tempreg;
- }
-
- /* Texture operations do not support swizzles etc. in hardware,
- * so emit an additional arithmetic operation if necessary.
- */
- if (inst.SrcReg[0].Swizzle != SWIZZLE_NOOP ||
- inst.SrcReg[0].Abs || inst.SrcReg[0].NegateBase || inst.SrcReg[0].NegateAbs) {
- int tempreg = radeonCompilerAllocateTemporary(context->compiler);
-
- tgt = radeonClauseInsertInstructions(context->compiler, context->dest,
- context->dest->NumInstructions, 1);
-
- tgt->Opcode = OPCODE_MAD;
- tgt->DstReg.File = PROGRAM_TEMPORARY;
- tgt->DstReg.Index = tempreg;
- tgt->SrcReg[0] = inst.SrcReg[0];
- tgt->SrcReg[1].File = PROGRAM_BUILTIN;
- tgt->SrcReg[1].Swizzle = SWIZZLE_1111;
- tgt->SrcReg[2].File = PROGRAM_BUILTIN;
- tgt->SrcReg[2].Swizzle = SWIZZLE_0000;
-
- reset_srcreg(&inst.SrcReg[0]);
- inst.SrcReg[0].File = PROGRAM_TEMPORARY;
- inst.SrcReg[0].Index = tempreg;
- }
-
- if (inst.Opcode != OPCODE_KIL) {
- if (inst.DstReg.File != PROGRAM_TEMPORARY ||
- inst.DstReg.WriteMask != WRITEMASK_XYZW) {
- int tempreg = radeonCompilerAllocateTemporary(context->compiler);
-
- inst.DstReg.File = PROGRAM_TEMPORARY;
- inst.DstReg.Index = tempreg;
- inst.DstReg.WriteMask = WRITEMASK_XYZW;
- destredirect = GL_TRUE;
- }
- }
-
tgt = radeonClauseInsertInstructions(context->compiler, context->dest,
context->dest->NumInstructions, 1);
_mesa_copy_instructions(tgt, &inst, 1);
radeonCompilerInit(&compiler.compiler, r300->radeon.glCtx, &fp->mesa_program.Base);
- insert_WPOS_trailer(&compiler);
+ /* insert_WPOS_trailer(&compiler); */
struct radeon_program_transformation transformations[1] = {
{ &transform_TEX, &compiler }
break;
case PROGRAM_ENV_PARAM:
reg = emit_const4fv(cs,
- cs->compiler->fp->ctx->FragmentProgram.Parameters[src.Index]);
+ cs->compiler->compiler.Ctx->FragmentProgram.Parameters[src.Index]);
break;
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
PROG_CODE;
int clauseidx, counter = 0;
- for (clauseidx = 0; clauseidx < cs->compiler->compiler.NumClauses; ++clauseidx) {
+ for (clauseidx = 0; clauseidx < cs->compiler->compiler.NumClauses; clauseidx++) {
struct radeon_clause* clause = &cs->compiler->compiler.Clauses[clauseidx];
+ struct prog_instruction* fpi;
+
int ip;
- for (ip = 0; ip < clause->NumInstructions; ++ip) {
- counter = do_inst(cs, clause->Instructions + ip, counter);
+ for (ip = 0; ip < clause->NumInstructions; ip++) {
+ fpi = clause->Instructions + ip;
+ counter = do_inst(cs, fpi, counter);
- if (cs->compiler->fp->error)
+ if (cs->compiler->fp->error == GL_TRUE)
return GL_FALSE;
}
}
cs->inputs[i].reg = 0;
}
- if (!mp->Base.Instructions) {
- ERROR("No instructions found in program, going to go die now.\n");
- return;
- }
+ int clauseidx;
+
+ for (clauseidx = 0; clauseidx < cs->compiler->compiler.NumClauses; ++clauseidx) {
+ struct radeon_clause* clause = &cs->compiler->compiler.Clauses[clauseidx];
+ int ip;
- for (fpi = mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
- for (i = 0; i < 3; i++) {
- if (fpi->SrcReg[i].File == PROGRAM_TEMPORARY) {
- if (fpi->SrcReg[i].Index >= temps_used)
- temps_used = fpi->SrcReg[i].Index + 1;
+ for (ip = 0; ip < clause->NumInstructions; ip++) {
+ fpi = clause->Instructions + ip;
+ for (i = 0; i < 3; i++) {
+ if (fpi->SrcReg[i].File == PROGRAM_TEMPORARY) {
+ if (fpi->SrcReg[i].Index >= temps_used)
+ temps_used = fpi->SrcReg[i].Index + 1;
+ }
}
}
}
+
cs->temp_in_use = temps_used + 1;
code->max_temp_idx = code->temp_reg_offset + cs->temp_in_use;