struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
struct ureg_src samplers[PIPE_MAX_SAMPLERS];
- const GLuint *inputMapping;
- const GLuint *outputMapping;
+ const ubyte *inputMapping;
+ const ubyte *outputMapping;
unsigned current_pass;
imm[0] = src;
imm[1] = ureg_imm4f(t->ureg, 1.0f, 1.0f, 0.0f, 0.0f);
imm[2] = ureg_imm4f(t->ureg, 0.0f, 0.0f, 1.0f, 1.0f);
- ureg_insn(t->ureg, TGSI_OPCODE_MAD, &tmp[0], 1, imm, 3);
+ ureg_insn(t->ureg, TGSI_OPCODE_MAD, &tmp[0], 1, imm, 3, 0);
if (swizzle == GL_SWIZZLE_STR_DR_ATI) {
imm[0] = ureg_scalar(src, TGSI_SWIZZLE_Z);
} else {
imm[0] = ureg_scalar(src, TGSI_SWIZZLE_W);
}
- ureg_insn(t->ureg, TGSI_OPCODE_RCP, &tmp[1], 1, &imm[0], 1);
+ ureg_insn(t->ureg, TGSI_OPCODE_RCP, &tmp[1], 1, &imm[0], 1, 0);
imm[0] = ureg_src(tmp[0]);
imm[1] = ureg_src(tmp[1]);
- ureg_insn(t->ureg, TGSI_OPCODE_MUL, &tmp[0], 1, imm, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_MUL, &tmp[0], 1, imm, 2, 0);
return ureg_src(tmp[0]);
}
src = ureg_scalar(src, TGSI_SWIZZLE_W);
break;
}
- ureg_insn(t->ureg, TGSI_OPCODE_MOV, &arg, 1, &src, 1);
+ ureg_insn(t->ureg, TGSI_OPCODE_MOV, &arg, 1, &src, 1, 0);
if (srcReg->argMod & GL_COMP_BIT_ATI) {
struct ureg_src modsrc[2];
modsrc[0] = ureg_imm1f(t->ureg, 1.0f);
modsrc[1] = ureg_negate(ureg_src(arg));
- ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2, 0);
}
if (srcReg->argMod & GL_BIAS_BIT_ATI) {
struct ureg_src modsrc[2];
modsrc[0] = ureg_src(arg);
modsrc[1] = ureg_imm1f(t->ureg, -0.5f);
- ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2, 0);
}
if (srcReg->argMod & GL_2X_BIT_ATI) {
struct ureg_src modsrc[2];
modsrc[0] = ureg_src(arg);
modsrc[1] = ureg_src(arg);
- ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2, 0);
}
if (srcReg->argMod & GL_NEGATE_BIT_ATI) {
struct ureg_src modsrc[2];
modsrc[0] = ureg_src(arg);
modsrc[1] = ureg_imm1f(t->ureg, -1.0f);
- ureg_insn(t->ureg, TGSI_OPCODE_MUL, &arg, 1, modsrc, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_MUL, &arg, 1, modsrc, 2, 0);
}
return ureg_src(arg);
}
tmp[0] = get_temp(t, MAX_NUM_FRAGMENT_REGISTERS_ATI + 2); /* re-purpose a3 */
src[0] = ureg_imm1f(t->ureg, 0.5f);
src[1] = ureg_negate(args[2]);
- ureg_insn(t->ureg, TGSI_OPCODE_ADD, tmp, 1, src, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_ADD, tmp, 1, src, 2, 0);
src[0] = ureg_src(tmp[0]);
src[1] = args[0];
src[2] = args[1];
- ureg_insn(t->ureg, TGSI_OPCODE_CMP, dst, 1, src, 3);
+ ureg_insn(t->ureg, TGSI_OPCODE_CMP, dst, 1, src, 3, 0);
} else if (!strcmp(desc->name, "CND0")) {
src[0] = args[2];
src[1] = args[1];
src[2] = args[0];
- ureg_insn(t->ureg, TGSI_OPCODE_CMP, dst, 1, src, 3);
+ ureg_insn(t->ureg, TGSI_OPCODE_CMP, dst, 1, src, 3, 0);
} else if (!strcmp(desc->name, "DOT2_ADD")) {
- /* note: DP2A is not implemented in most pipe drivers */
tmp[0] = get_temp(t, MAX_NUM_FRAGMENT_REGISTERS_ATI); /* re-purpose a1 */
src[0] = args[0];
src[1] = args[1];
- ureg_insn(t->ureg, TGSI_OPCODE_DP2, tmp, 1, src, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_DP2, tmp, 1, src, 2, 0);
src[0] = ureg_src(tmp[0]);
src[1] = ureg_scalar(args[2], TGSI_SWIZZLE_Z);
- ureg_insn(t->ureg, TGSI_OPCODE_ADD, dst, 1, src, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_ADD, dst, 1, src, 2, 0);
}
}
struct ureg_dst *dst, struct ureg_src *args, unsigned argcount)
{
if (desc->TGSI_opcode == TGSI_OPCODE_NOP) {
- return emit_special_inst(t, desc, dst, args, argcount);
+ emit_special_inst(t, desc, dst, args, argcount);
+ return;
}
- ureg_insn(t->ureg, desc->TGSI_opcode, dst, 1, args, argcount);
+ ureg_insn(t->ureg, desc->TGSI_opcode, dst, 1, args, argcount, 0);
}
static void
if (dstMod & GL_SATURATE_BIT_ATI) {
dst = ureg_saturate(dst);
}
- ureg_insn(t->ureg, TGSI_OPCODE_MUL, &dst, 1, src, 2);
+ ureg_insn(t->ureg, TGSI_OPCODE_MUL, &dst, 1, src, 2, 0);
}
/**
src[1] = t->samplers[r];
/* the texture target is still unknown, it will be fixed in the draw call */
ureg_tex_insn(t->ureg, TGSI_OPCODE_TEX, dst, 1, TGSI_TEXTURE_2D,
- NULL, 0, src, 2);
+ TGSI_RETURN_TYPE_FLOAT, NULL, 0, src, 2);
} else if (texinst->Opcode == ATI_FRAGMENT_SHADER_PASS_OP) {
- ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1);
+ ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1, 0);
}
t->regs_written[t->current_pass][r] = true;
/* copy the result into the OUT slot */
dst[0] = t->outputs[t->outputMapping[FRAG_RESULT_COLOR]];
src[0] = ureg_src(t->temps[0]);
- ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1);
+ ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1, 0);
}
/* signal the end of the program */
- ureg_insn(t->ureg, TGSI_OPCODE_END, dst, 0, src, 0);
+ ureg_insn(t->ureg, TGSI_OPCODE_END, dst, 0, src, 0, 0);
}
/**
struct ati_fragment_shader *atifs,
struct gl_program *program,
GLuint numInputs,
- const GLuint inputMapping[],
+ const ubyte inputMapping[],
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
- const GLuint interpMode[],
+ const ubyte interpMode[],
GLuint numOutputs,
- const GLuint outputMapping[],
+ const ubyte outputMapping[],
const ubyte outputSemanticName[],
const ubyte outputSemanticIndex[])
{
}
for (i = 0; i < program->Parameters->NumParameters; i++) {
+ unsigned pvo = program->Parameters->ParameterValueOffset[i];
+
switch (program->Parameters->Parameters[i].Type) {
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
case PROGRAM_CONSTANT:
t->constants[i] =
ureg_DECL_immediate(ureg,
- (const float*)program->Parameters->ParameterValues[i],
+ (const float*)program->Parameters->ParameterValues + pvo,
4);
break;
default:
st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
{
/* we know this is st_fragment_program, because of st_new_ati_fs() */
- struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
+ struct st_program *stfp = (struct st_program *) prog;
struct ati_fragment_shader *atifs = stfp->ati_fs;
unsigned pass, i, r, optype, arg;
- static const gl_state_index fog_params_state[STATE_LENGTH] =
+ static const gl_state_index16 fog_params_state[STATE_LENGTH] =
{STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0};
- static const gl_state_index fog_color[STATE_LENGTH] =
+ static const gl_state_index16 fog_color[STATE_LENGTH] =
{STATE_FOG_COLOR, 0, 0, 0, 0};
prog->info.inputs_read = 0;
/* we always have the ATI_fs constants, and the fog params */
for (i = 0; i < MAX_NUM_FRAGMENT_CONSTANTS_ATI; i++) {
_mesa_add_parameter(prog->Parameters, PROGRAM_UNIFORM,
- NULL, 4, GL_FLOAT, NULL, NULL);
+ NULL, 4, GL_FLOAT, NULL, NULL, true);
}
_mesa_add_state_reference(prog->Parameters, fog_params_state);
_mesa_add_state_reference(prog->Parameters, fog_color);
-
- prog->arb.NumInstructions = 0;
- prog->arb.NumTemporaries = MAX_NUM_FRAGMENT_REGISTERS_ATI + 3; /* 3 input temps for arith ops */
- prog->arb.NumParameters = MAX_NUM_FRAGMENT_CONSTANTS_ATI + 2; /* 2 state variables for fog */
}
const struct st_fp_variant_key *key;
bool first_instruction_emitted;
unsigned fog_factor_temp;
- unsigned fog_clamp_imm;
};
static inline struct tgsi_atifs_transform *
inst->Src[i].Register.SwizzleY = y;
inst->Src[i].Register.SwizzleZ = z;
inst->Src[i].Register.SwizzleW = w;
+ if (file == TGSI_FILE_CONSTANT) {
+ inst->Src[i].Register.Dimension = 1;
+ inst->Src[i].Dimension.Index = 0;
+ }
}
#define SET_SRC(inst, i, file, index, x, y, z, w) \
/* add a new temp for the fog factor */
ctx->fog_factor_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1;
tgsi_transform_temp_decl(tctx, ctx->fog_factor_temp);
-
- /* add immediates for clamp */
- ctx->fog_clamp_imm = ctx->info.immediate_count;
- tgsi_transform_immediate_decl(tctx, 1.0f, 0.0f, 0.0f, 0.0f);
}
transform_inst:
}
/* compute the 1 component fog factor f */
- if (ctx->key->fog == 1) {
+ if (ctx->key->fog == FOG_LINEAR) {
/* LINEAR formula: f = (end - z) / (end - start)
* with optimized parameters:
* f = MAD(fogcoord, oparams.x, oparams.y)
SET_SRC(&inst, 1, TGSI_FILE_CONSTANT, MAX_NUM_FRAGMENT_CONSTANTS_ATI, X, X, X, X);
SET_SRC(&inst, 2, TGSI_FILE_CONSTANT, MAX_NUM_FRAGMENT_CONSTANTS_ATI, Y, Y, Y, Y);
tctx->emit_instruction(tctx, &inst);
- } else if (ctx->key->fog == 2) {
+ } else if (ctx->key->fog == FOG_EXP) {
/* EXP formula: f = exp(-dens * z)
* with optimized parameters:
* f = MUL(fogcoord, oparams.z); f= EX2(-f)
SET_SRC(&inst, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, W);
inst.Src[0].Register.Negate = 1;
tctx->emit_instruction(tctx, &inst);
- } else if (ctx->key->fog == 3) {
+ } else if (ctx->key->fog == FOG_EXP2) {
/* EXP2 formula: f = exp(-(dens * z)^2)
* with optimized parameters:
* f = MUL(fogcoord, oparams.w); f=MUL(f, f); f= EX2(-f)
inst.Src[0].Register.Negate ^= 1;
tctx->emit_instruction(tctx, &inst);
}
- /* f = CLAMP(f, 0.0, 1.0) */
+ /* f = saturate(f) */
inst = tgsi_default_full_instruction();
- inst.Instruction.Opcode = TGSI_OPCODE_CLAMP;
+ inst.Instruction.Opcode = TGSI_OPCODE_MOV;
inst.Instruction.NumDstRegs = 1;
+ inst.Instruction.Saturate = 1;
inst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
inst.Dst[0].Register.Index = ctx->fog_factor_temp;
inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
- inst.Instruction.NumSrcRegs = 3;
+ inst.Instruction.NumSrcRegs = 1;
SET_SRC(&inst, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, W);
- SET_SRC(&inst, 1, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, Y, Y, Y, Y); // 0.0
- SET_SRC(&inst, 2, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, X, X, X, X); // 1.0
tctx->emit_instruction(tctx, &inst);
/* REG0 = LRP(f, REG0, fogcolor) */