amd/common: fix build_cube_select
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 22 Sep 2017 17:05:52 +0000 (19:05 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 29 Sep 2017 09:43:04 +0000 (11:43 +0200)
Fix the custom cube coord selection sequence to be identical to
the hardware v_cubesc/tc and OpenGL spec. Affects texture sampling
with user-provided derivatives.

Fixes dEQP-GLES3.functional.shaders.texture_functions.texturegrad.*

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/amd/common/ac_llvm_build.c

index 8a329515b57b0877efea2e9c1cc8cf3a8cfbd836..8c050f31a762d82501461db7ebc0c2072702fea2 100644 (file)
@@ -465,15 +465,15 @@ static void build_cube_select(LLVMBuilderRef builder,
        is_ma_x = LLVMBuildAnd(builder, is_not_ma_z, LLVMBuildNot(builder, is_ma_y, ""), "");
 
        /* Select sc */
-       tmp = LLVMBuildSelect(builder, is_ma_z, coords[2], coords[0], "");
+       tmp = LLVMBuildSelect(builder, is_ma_x, coords[2], coords[0], "");
        sgn = LLVMBuildSelect(builder, is_ma_y, LLVMConstReal(f32, 1.0),
-               LLVMBuildSelect(builder, is_ma_x, sgn_ma,
+               LLVMBuildSelect(builder, is_ma_z, sgn_ma,
                        LLVMBuildFNeg(builder, sgn_ma, ""), ""), "");
        out_st[0] = LLVMBuildFMul(builder, tmp, sgn, "");
 
        /* Select tc */
        tmp = LLVMBuildSelect(builder, is_ma_y, coords[2], coords[1], "");
-       sgn = LLVMBuildSelect(builder, is_ma_y, LLVMBuildFNeg(builder, sgn_ma, ""),
+       sgn = LLVMBuildSelect(builder, is_ma_y, sgn_ma,
                LLVMConstReal(f32, -1.0), "");
        out_st[1] = LLVMBuildFMul(builder, tmp, sgn, "");