OSDN Git Service

amd/common: round cube array slice in ac_prepare_cube_coords
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 13 Sep 2017 08:47:02 +0000 (10:47 +0200)
committerJuan A. Suarez Romero <jasuarez@igalia.com>
Wed, 20 Sep 2017 20:54:11 +0000 (22:54 +0200)
The NIR-to-LLVM pass already does this; now the same fix covers
radeonsi as well.

Fixes various tests of
dEQP-GLES31.functional.texture.filtering.cube_array.combinations.*

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit e0af3bed2cb52b5d8cf1da08b42cf28bae131c76)
[Juan A. Suarez: resolve trivial conflicts. Apply patch into
si_shader.c]
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Conflicts:
src/amd/common/ac_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/amd/common/ac_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader.c

index d45094c..e2707e3 100644 (file)
@@ -327,7 +327,7 @@ static void build_cube_select(LLVMBuilderRef builder,
 
 void
 ac_prepare_cube_coords(struct ac_llvm_context *ctx,
-                      bool is_deriv, bool is_array,
+                      bool is_deriv, bool is_array, bool is_lod,
                       LLVMValueRef *coords_arg,
                       LLVMValueRef *derivs_arg)
 {
@@ -337,6 +337,11 @@ ac_prepare_cube_coords(struct ac_llvm_context *ctx,
        LLVMValueRef coords[3];
        LLVMValueRef invma;
 
+       if (is_array && !is_lod) {
+               coords_arg[3] = ac_build_intrinsic(ctx, "llvm.rint.f32", ctx->f32,
+                                                  &coords_arg[3], 1, 0);
+       }
+
        build_cube_intrinsic(ctx, coords_arg, &selcoords);
 
        invma = ac_build_intrinsic(ctx, "llvm.fabs.f32",
index d6edcde..7b40950 100644 (file)
@@ -82,7 +82,7 @@ ac_build_fdiv(struct ac_llvm_context *ctx,
 
 void
 ac_prepare_cube_coords(struct ac_llvm_context *ctx,
-                      bool is_deriv, bool is_array,
+                      bool is_deriv, bool is_array, bool is_lod,
                       LLVMValueRef *coords_arg,
                       LLVMValueRef *derivs_arg);
 
index e3ada43..ab2d802 100644 (file)
@@ -4333,15 +4333,13 @@ static void visit_tex(struct nir_to_llvm_context *ctx, nir_tex_instr *instr)
        }
 
        if (instr->sampler_dim == GLSL_SAMPLER_DIM_CUBE && coord) {
-               if (instr->is_array && instr->op != nir_texop_lod)
-                       coords[3] = apply_round_slice(ctx, coords[3]);
                for (chan = 0; chan < instr->coord_components; chan++)
                        coords[chan] = to_float(ctx, coords[chan]);
                if (instr->coord_components == 3)
                        coords[3] = LLVMGetUndef(ctx->f32);
                ac_prepare_cube_coords(&ctx->ac,
                        instr->op == nir_texop_txd, instr->is_array,
-                       coords, derivs);
+                       instr->op == nir_texop_lod, coords, derivs);
                if (num_deriv_comp)
                        num_deriv_comp--;
        }
index f77a508..3adb9da 100644 (file)
@@ -4660,6 +4660,7 @@ static void tex_fetch_args(
                                       opcode == TGSI_OPCODE_TXD,
                                       target == TGSI_TEXTURE_CUBE_ARRAY ||
                                       target == TGSI_TEXTURE_SHADOWCUBE_ARRAY,
+                                      opcode == TGSI_OPCODE_LODQ,
                                       coords, derivs);
 
        if (opcode == TGSI_OPCODE_TXD)