r300: move CEIL lowering to NIR
authorPavel Ondračka <pavel.ondracka@gmail.com>
Wed, 14 Jun 2023 06:39:33 +0000 (08:39 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 15 Jun 2023 15:59:25 +0000 (15:59 +0000)
Also remove unused backend CEIL lowering.

Single regressed gnome-shell shader due to fceil followed by f2i32
where before nir_lower_int_to_float would recognize that we already
have integer and emit mov instead of trunc for the f2i32. We can
clean this up easily once we move ntt to the backend.

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>

src/gallium/drivers/r300/compiler/radeon_opcodes.c
src/gallium/drivers/r300/compiler/radeon_opcodes.h
src/gallium/drivers/r300/compiler/radeon_program_alu.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_tgsi_to_rc.c

index 7f43afc..818b307 100644 (file)
@@ -61,13 +61,6 @@ const struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
                .HasDstReg = 1
        },
        {
-               .Opcode = RC_OPCODE_CEIL,
-               .Name = "CEIL",
-               .NumSrcRegs = 1,
-               .HasDstReg = 1,
-               .IsComponentwise = 1
-       },
-       {
                .Opcode = RC_OPCODE_CMP,
                .Name = "CMP",
                .NumSrcRegs = 3,
index 3bb8962..5459561 100644 (file)
@@ -48,9 +48,6 @@ typedef enum {
         * dst.x = round(src.x), where dst must be an address register */
        RC_OPCODE_ARR,
 
-       /** vec4 instruction: dst.c = ceil(src0.c) */
-       RC_OPCODE_CEIL,
-
        /** vec4 instruction: dst.c = src0.c < 0.0 ? src1.c : src2.c */
        RC_OPCODE_CMP,
 
index 24caef1..8e8c29a 100644 (file)
@@ -203,26 +203,6 @@ static struct rc_dst_register new_dst_reg(struct radeon_compiler *c,
        return dstregtmpmask(tmp, inst->U.I.DstReg.WriteMask);
 }
 
-static void transform_CEIL(struct radeon_compiler* c,
-       struct rc_instruction* inst)
-{
-       /* Assuming:
-        *     ceil(x) = -floor(-x)
-        *
-        * After inlining floor:
-        *     ceil(x) = -(-x-frac(-x))
-        *
-        * After simplification:
-        *     ceil(x) = x+frac(-x)
-        */
-
-       struct rc_dst_register dst = new_dst_reg(c, inst);
-       emit1(c, inst->Prev, RC_OPCODE_FRC, NULL, dst, negate(inst->U.I.SrcReg[0]));
-       emit2(c, inst->Prev, RC_OPCODE_ADD, &inst->U.I, inst->U.I.DstReg,
-               inst->U.I.SrcReg[0], srcreg(RC_FILE_TEMPORARY, dst.Index));
-       rc_remove_instruction(inst);
-}
-
 static void transform_DP2(struct radeon_compiler* c,
        struct rc_instruction* inst)
 {
@@ -544,7 +524,7 @@ static void transform_KILP(struct radeon_compiler * c,
  * no userData necessary.
  *
  * Eliminates the following ALU instructions:
- *  CEIL, DST, FLR, LIT, LRP, POW, SEQ, SGE, SGT, SLE, SLT, SNE, SUB
+ *  DST, FLR, LIT, LRP, POW, SEQ, SGE, SGT, SLE, SLT, SNE, SUB
  * using:
  *  MOV, ADD, MUL, MAD, FRC, DP3, LG2, EX2, CMP
  *
@@ -559,7 +539,6 @@ int radeonTransformALU(
        void* unused)
 {
        switch(inst->U.I.Opcode) {
-       case RC_OPCODE_CEIL: transform_CEIL(c, inst); return 1;
        case RC_OPCODE_DP2: transform_DP2(c, inst); return 1;
        case RC_OPCODE_DST: transform_DST(c, inst); return 1;
        case RC_OPCODE_FLR: transform_FLR(c, inst); return 1;
@@ -751,7 +730,6 @@ int r300_transform_vertex_alu(
        void* unused)
 {
        switch(inst->U.I.Opcode) {
-       case RC_OPCODE_CEIL: transform_CEIL(c, inst); return 1;
        case RC_OPCODE_CMP: transform_r300_vertex_CMP(c, inst); return 1;
        case RC_OPCODE_DP2: transform_r300_vertex_DP2(c, inst); return 1;
        case RC_OPCODE_DP3: transform_r300_vertex_DP3(c, inst); return 1;
index c096dbc..1e920b0 100644 (file)
@@ -493,6 +493,7 @@ static int r300_get_video_param(struct pipe_screen *screen,
    .lower_bitops = true,                      \
    .lower_extract_byte = true,                \
    .lower_extract_word = true,                \
+   .lower_fceil = true,                       \
    .lower_fdiv = true,                        \
    .lower_fdph = true,                        \
    .lower_ffloor = true,                      \
index 70dd87b..d5b1f0a 100644 (file)
@@ -95,7 +95,6 @@ static unsigned translate_opcode(unsigned opcode)
         case TGSI_OPCODE_ENDLOOP: return RC_OPCODE_ENDLOOP;
      /* case TGSI_OPCODE_PUSHA: return RC_OPCODE_PUSHA; */
      /* case TGSI_OPCODE_POPA: return RC_OPCODE_POPA; */
-        case TGSI_OPCODE_CEIL: return RC_OPCODE_CEIL;
      /* case TGSI_OPCODE_I2F: return RC_OPCODE_I2F; */
      /* case TGSI_OPCODE_NOT: return RC_OPCODE_NOT; */
         case TGSI_OPCODE_TRUNC: return RC_OPCODE_TRUNC;