ac/llvm,radeonsi: lower fsin/fcos in nir
authorQiang Yu <yuq825@gmail.com>
Fri, 14 Apr 2023 13:05:05 +0000 (21:05 +0800)
committerMarge Bot <emma+marge@anholt.net>
Mon, 15 May 2023 02:01:10 +0000 (02:01 +0000)
ACO only support nir_fsin/cos_amd.

There's some pixel changes for gl-radeonsi-stoney trace.
Different pixels:
  furmark  61 (no tolerance), 0 (1% tol.)
  gimark   93867 (no tolerance), 888 (1% tol.)
  tessmark 39 (no tolerance), 0 (1% tol.)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22573>

src/amd/ci/traces-amd.yml
src/amd/llvm/ac_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader_nir.c

index 5c5f0da..5537205 100644 (file)
@@ -38,7 +38,7 @@ traces:
       checksum: 6cb8190a2ee4c335291914fbc70a8bb8
   gputest/furmark-v2.trace:
     gl-radeonsi-stoney:
-      checksum: 4ceea12000bb5995b915228d2d4b49c7
+      checksum: cc6344ca8f5348c5e39dafb1b38edd7c
   gputest/triangle-v2.trace:
     gl-radeonsi-stoney:
       checksum: 2d0527e7288a0fc31099404546dadbfb
@@ -50,7 +50,7 @@ traces:
       checksum: 0e7441a7f2c86c75eeac72269786e7a1
   gputest/gimark-v2.trace:
     gl-radeonsi-stoney:
-      checksum: 3e021c1c5f2900e53c3375e0366eeda9
+      checksum: 32d373e5ae6cd241c5a7b286c296113f
   gputest/pixmark-julia-fp32-v2.trace:
     gl-radeonsi-stoney:
       checksum: b5e0ae5ad680d884432f89a923f3e70d
@@ -65,7 +65,7 @@ traces:
       checksum: 2832d2190df232bcbde71a4b720303e1
   gputest/tessmark-v2.trace:
     gl-radeonsi-stoney:
-      checksum: b4bc7998ff804bf25aac9f9609b8acbf
+      checksum: 071c8863793e7adcd95acb054592f819
   humus/AmbientAperture-v2.trace:
     gl-radeonsi-stoney:
       checksum: 679dc88e5f0d3b3608e0490b4b39fbea
index fa50525..a28003b 100644 (file)
@@ -820,14 +820,6 @@ static bool visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
       result = emit_intrin_1f_param_scalar(&ctx->ac, "llvm.amdgcn.fract",
                                            ac_to_float_type(&ctx->ac, def_type), src[0]);
       break;
-   case nir_op_fsin:
-      result =
-         emit_intrin_1f_param(&ctx->ac, "llvm.sin", ac_to_float_type(&ctx->ac, def_type), src[0]);
-      break;
-   case nir_op_fcos:
-      result =
-         emit_intrin_1f_param(&ctx->ac, "llvm.cos", ac_to_float_type(&ctx->ac, def_type), src[0]);
-      break;
    case nir_op_fsin_amd:
    case nir_op_fcos_amd:
       /* before GFX9, v_sin_f32 and v_cos_f32 had a valid input domain of [-256, +256] */
index ea6c0c9..8b4d8e5 100644 (file)
@@ -305,6 +305,8 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
 
    NIR_PASS_V(nir, si_lower_intrinsics);
 
+   NIR_PASS_V(nir, ac_nir_lower_sin_cos);
+
    NIR_PASS_V(nir, nir_lower_subgroups, &si_nir_subgroups_options);
 
    NIR_PASS_V(nir, nir_lower_discard_or_demote,