r300: remove backend input range transformation for sin and cos

We already do this in NIR since a04aa4bc08
and 3f97306b95 so there is no effect
for the mesa state tracker now that it can not emit TGSI any more.
This leaves only nine when RADEON_DEBUG=use_tgsi is set. D3D9 however
requires that sin and cos inputs already have the proper range.

This is super important when the nine shader uses relative adressing
and therefore needs all 256 constants we have. If we add our extra
constants for the fixup, we get over the limit and fail compilation.

v2: vertex shaders only

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Reviewed-by: Filip Gawin <filip@gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18933>
This commit is contained in:
Pavel Ondračka
2022-10-05 21:22:05 +02:00
committed by Marge Bot
parent d8f59b14d0
commit e86c7ac9f4
3 changed files with 0 additions and 44 deletions

View File

@@ -878,7 +878,6 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
/* Lists of instruction transformations. */
struct radeon_program_transformation alu_rewrite_r500[] = {
{ &r300_transform_vertex_alu, NULL },
{ &r300_transform_trig_scale_vertex, NULL },
{ NULL, NULL }
};

View File

@@ -1036,48 +1036,6 @@ int radeonTransformTrigScale(struct radeon_compiler* c,
return 1;
}
/**
* Transform the trigonometric functions COS and SIN
* so that the input to COS and SIN is always in the range [-PI, PI].
*/
int r300_transform_trig_scale_vertex(struct radeon_compiler *c,
struct rc_instruction *inst,
void *unused)
{
static const float cons[4] = {0.15915494309189535, 0.5, 6.28318530717959, -3.14159265358979};
unsigned int temp;
unsigned int constant;
if (inst->U.I.Opcode != RC_OPCODE_COS &&
inst->U.I.Opcode != RC_OPCODE_SIN)
return 0;
if (!c->needs_trig_input_transform)
return 1;
/* Repeat x in the range [-PI, PI]:
*
* repeat(x) = frac(x / 2PI + 0.5) * 2PI - PI
*/
temp = rc_find_free_temporary(c);
constant = rc_constants_add_immediate_vec4(&c->Program.Constants, cons);
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(temp, RC_MASK_W),
swizzle_xxxx(inst->U.I.SrcReg[0]),
srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_XXXX),
srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_YYYY));
emit1(c, inst->Prev, RC_OPCODE_FRC, NULL, dstregtmpmask(temp, RC_MASK_W),
srcreg(RC_FILE_TEMPORARY, temp));
emit3(c, inst->Prev, RC_OPCODE_MAD, NULL, dstregtmpmask(temp, RC_MASK_W),
srcreg(RC_FILE_TEMPORARY, temp),
srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_ZZZZ),
srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_WWWW));
r300_transform_SIN_COS(c, inst, temp);
return 1;
}
/**
* Replaces DDX/DDY instructions with MOV 0 to avoid using dummy shaders on r300/r400.
*

View File

@@ -201,7 +201,6 @@ void r300_translate_vertex_shader(struct r300_context *r300,
compiler.Base.has_half_swizzles = FALSE;
compiler.Base.has_presub = FALSE;
compiler.Base.has_omod = FALSE;
compiler.Base.needs_trig_input_transform = DBG_ON(r300, DBG_USE_TGSI);
compiler.Base.max_temp_regs = 32;
compiler.Base.max_constants = 256;
compiler.Base.max_alu_insts = r300->screen->caps.is_r500 ? 1024 : 256;