mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
r300: remove unused SIN/COS lowering
Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Filip Gawin <filip.gawin@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23642>
This commit is contained in:
parent
daac72de3a
commit
3a3b9b7a63
4 changed files with 2 additions and 173 deletions
|
|
@ -91,7 +91,6 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
|
|||
struct radeon_program_transformation native_rewrite_r300[] = {
|
||||
{ &radeonTransformALU, NULL },
|
||||
{ &radeonStubDeriv, NULL },
|
||||
{ &r300_transform_trig_simple, NULL },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -805,17 +805,11 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
|
|||
int opt = !c->Base.disable_optimizations;
|
||||
|
||||
/* Lists of instruction transformations. */
|
||||
struct radeon_program_transformation alu_rewrite_r500[] = {
|
||||
struct radeon_program_transformation alu_rewrite[] = {
|
||||
{ &r300_transform_vertex_alu, NULL },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
struct radeon_program_transformation alu_rewrite_r300[] = {
|
||||
{ &r300_transform_vertex_alu, NULL },
|
||||
{ &r300_transform_trig_simple, NULL },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* Note: These passes have to be done separately from ALU rewrite,
|
||||
* otherwise non-native ALU instructions with source conflits
|
||||
* or non-native modifiers will not be treated properly.
|
||||
|
|
@ -834,8 +828,7 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
|
|||
struct radeon_compiler_pass vs_list[] = {
|
||||
/* NAME DUMP PREDICATE FUNCTION PARAM */
|
||||
{"add artificial outputs", 0, 1, rc_vs_add_artificial_outputs, NULL},
|
||||
{"native rewrite", 1, is_r500, rc_local_transform, alu_rewrite_r500},
|
||||
{"native rewrite", 1, !is_r500, rc_local_transform, alu_rewrite_r300},
|
||||
{"native rewrite", 1, 1, rc_local_transform, alu_rewrite},
|
||||
{"emulate modifiers", 1, !is_r500, rc_local_transform, emulate_modifiers},
|
||||
{"deadcode", 1, opt, rc_dataflow_deadcode, NULL},
|
||||
{"dataflow optimize", 1, opt, rc_optimize, NULL},
|
||||
|
|
|
|||
|
|
@ -855,159 +855,6 @@ int r300_transform_vertex_alu(
|
|||
}
|
||||
}
|
||||
|
||||
static void sincos_constants(struct radeon_compiler* c, unsigned int *constants)
|
||||
{
|
||||
static const float SinCosConsts[2][4] = {
|
||||
{
|
||||
1.273239545, /* 4/PI */
|
||||
-0.405284735, /* -4/(PI*PI) */
|
||||
3.141592654, /* PI */
|
||||
0.2225 /* weight */
|
||||
},
|
||||
{
|
||||
0.75,
|
||||
0.5,
|
||||
0.159154943, /* 1/(2*PI) */
|
||||
6.283185307 /* 2*PI */
|
||||
}
|
||||
};
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 2; ++i)
|
||||
constants[i] = rc_constants_add_immediate_vec4(&c->Program.Constants, SinCosConsts[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approximate sin(x), where x is clamped to (-pi/2, pi/2).
|
||||
*
|
||||
* MUL tmp.xy, src, { 4/PI, -4/(PI^2) }
|
||||
* MAD tmp.x, tmp.y, |src|, tmp.x
|
||||
* MAD tmp.y, tmp.x, |tmp.x|, -tmp.x
|
||||
* MAD dest, tmp.y, weight, tmp.x
|
||||
*/
|
||||
static void sin_approx(
|
||||
struct radeon_compiler* c, struct rc_instruction * inst,
|
||||
struct rc_dst_register dst, struct rc_src_register src, const unsigned int* constants)
|
||||
{
|
||||
unsigned int tempreg = rc_find_free_temporary(c);
|
||||
|
||||
emit2(c, inst->Prev, RC_OPCODE_MUL, NULL, dstregtmpmask(tempreg, RC_MASK_XY),
|
||||
swizzle_xxxx(src),
|
||||
srcreg(RC_FILE_CONSTANT, constants[0]));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_X),
|
||||
swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
absolute(swizzle_xxxx(src)),
|
||||
swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_Y),
|
||||
swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
absolute(swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg))),
|
||||
negate(swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg))));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dst,
|
||||
swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[0])),
|
||||
swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the trigonometric functions COS and SIN
|
||||
* using only the basic instructions
|
||||
* MOV, ADD, MUL, MAD, FRC
|
||||
*/
|
||||
int r300_transform_trig_simple(struct radeon_compiler* c,
|
||||
struct rc_instruction* inst,
|
||||
void* unused)
|
||||
{
|
||||
unsigned int constants[2];
|
||||
unsigned int tempreg;
|
||||
|
||||
if (inst->U.I.Opcode != RC_OPCODE_COS &&
|
||||
inst->U.I.Opcode != RC_OPCODE_SIN)
|
||||
return 0;
|
||||
|
||||
tempreg = rc_find_free_temporary(c);
|
||||
|
||||
sincos_constants(c, constants);
|
||||
|
||||
if (inst->U.I.Opcode == RC_OPCODE_COS) {
|
||||
/* MAD tmp.x, src, 1/(2*PI), 0.75 */
|
||||
/* FRC tmp.x, tmp.x */
|
||||
/* MAD tmp.z, tmp.x, 2*PI, -PI */
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_xxxx(inst->U.I.SrcReg[0]),
|
||||
swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
swizzle_xxxx(srcreg(RC_FILE_CONSTANT, constants[1])));
|
||||
emit1(c, inst->Prev, RC_OPCODE_FRC, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
|
||||
|
||||
sin_approx(c, inst, inst->U.I.DstReg,
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
constants);
|
||||
} else if (inst->U.I.Opcode == RC_OPCODE_SIN) {
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_xxxx(inst->U.I.SrcReg[0]),
|
||||
swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
swizzle_yyyy(srcreg(RC_FILE_CONSTANT, constants[1])));
|
||||
emit1(c, inst->Prev, RC_OPCODE_FRC, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_W),
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
|
||||
|
||||
sin_approx(c, inst, inst->U.I.DstReg,
|
||||
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
constants);
|
||||
} else {
|
||||
struct rc_dst_register dst;
|
||||
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_XY),
|
||||
swizzle_xxxx(inst->U.I.SrcReg[0]),
|
||||
swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
swizzle(srcreg(RC_FILE_CONSTANT, constants[1]), RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_W));
|
||||
emit1(c, inst->Prev, RC_OPCODE_FRC, NULL, dstregtmpmask(tempreg, RC_MASK_XY),
|
||||
srcreg(RC_FILE_TEMPORARY, tempreg));
|
||||
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(tempreg, RC_MASK_XY),
|
||||
srcreg(RC_FILE_TEMPORARY, tempreg),
|
||||
swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
|
||||
negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
|
||||
|
||||
dst = inst->U.I.DstReg;
|
||||
|
||||
dst.WriteMask = inst->U.I.DstReg.WriteMask & RC_MASK_X;
|
||||
sin_approx(c, inst, dst,
|
||||
swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
constants);
|
||||
|
||||
dst.WriteMask = inst->U.I.DstReg.WriteMask & RC_MASK_Y;
|
||||
sin_approx(c, inst, dst,
|
||||
swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
|
||||
constants);
|
||||
}
|
||||
|
||||
rc_remove_instruction(inst);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void r300_transform_SIN_COS(struct radeon_compiler *c,
|
||||
struct rc_instruction *inst,
|
||||
unsigned srctmp)
|
||||
{
|
||||
if (inst->U.I.Opcode == RC_OPCODE_COS) {
|
||||
emit1(c, inst->Prev, RC_OPCODE_COS, &inst->U.I, inst->U.I.DstReg,
|
||||
srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
|
||||
} else if (inst->U.I.Opcode == RC_OPCODE_SIN) {
|
||||
emit1(c, inst->Prev, RC_OPCODE_SIN, &inst->U.I,
|
||||
inst->U.I.DstReg, srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
|
||||
}
|
||||
|
||||
rc_remove_instruction(inst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces DDX/DDY instructions with MOV 0 to avoid using dummy shaders on r300/r400.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,16 +40,6 @@ int r300_transform_vertex_alu(
|
|||
struct rc_instruction * inst,
|
||||
void*);
|
||||
|
||||
int r300_transform_trig_simple(
|
||||
struct radeon_compiler * c,
|
||||
struct rc_instruction * inst,
|
||||
void*);
|
||||
|
||||
int r300_transform_trig_scale_vertex(
|
||||
struct radeon_compiler *c,
|
||||
struct rc_instruction *inst,
|
||||
void*);
|
||||
|
||||
int radeonStubDeriv(
|
||||
struct radeon_compiler * c,
|
||||
struct rc_instruction * inst,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue