From e86c7ac9f4b23769f3dcbaf3267d46436749315b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Wed, 5 Oct 2022 21:22:05 +0200 Subject: [PATCH] r300: remove backend input range transformation for sin and cos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already do this in NIR since a04aa4bc08df2c3772fc7dda6766f76ef3a5dfb4 and 3f97306b956f707d637da6b76dd9465fcabfc451 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 Acked-by: David Heidelberg Reviewed-by: Filip Gawin Part-of: --- .../drivers/r300/compiler/r3xx_vertprog.c | 1 - .../r300/compiler/radeon_program_alu.c | 42 ------------------- src/gallium/drivers/r300/r300_vs.c | 1 - 3 files changed, 44 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c index e8e3712bffc..ceb590ea085 100644 --- a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c +++ b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c @@ -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 } }; diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c index c28cebce3a4..4f2c5081c62 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c @@ -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. * diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index dfa26de1c84..106d5520d41 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -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;