OSDN Git Service

radv/ac: fix multisample subpass image.
authorDave Airlie <airlied@redhat.com>
Mon, 30 Jan 2017 06:13:30 +0000 (16:13 +1000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 3 Feb 2017 11:08:58 +0000 (11:08 +0000)
We weren't adding the fragment position properly.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: "17.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 059dd171759bb89d915c049de1ca1c93865c21d3)

src/amd/common/ac_nir_to_llvm.c

index 72ae6eb..26e8453 100644 (file)
@@ -2241,7 +2241,7 @@ static int image_type_to_components_count(enum glsl_sampler_dim dim, bool array)
 }
 
 static LLVMValueRef get_image_coords(struct nir_to_llvm_context *ctx,
-                                    nir_intrinsic_instr *instr, bool add_frag_pos)
+                                    nir_intrinsic_instr *instr)
 {
        const struct glsl_type *type = instr->variables[0]->var->type;
        if(instr->variables[0]->deref.child)
@@ -2256,6 +2256,8 @@ static LLVMValueRef get_image_coords(struct nir_to_llvm_context *ctx,
        LLVMValueRef res;
        int count;
        enum glsl_sampler_dim dim = glsl_get_sampler_dim(type);
+       bool add_frag_pos = (dim == GLSL_SAMPLER_DIM_SUBPASS ||
+                            dim == GLSL_SAMPLER_DIM_SUBPASS_MS);
        bool is_ms = (dim == GLSL_SAMPLER_DIM_MS ||
                      dim == GLSL_SAMPLER_DIM_SUBPASS_MS);
 
@@ -2381,12 +2383,11 @@ static LLVMValueRef visit_image_load(struct nir_to_llvm_context *ctx,
        } else {
                bool is_da = glsl_sampler_type_is_array(type) ||
                             glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE;
-               bool add_frag_pos = glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_SUBPASS;
                LLVMValueRef da = is_da ? ctx->i32one : ctx->i32zero;
                LLVMValueRef glc = LLVMConstInt(ctx->i1, 0, false);
                LLVMValueRef slc = LLVMConstInt(ctx->i1, 0, false);
 
-               params[0] = get_image_coords(ctx, instr, add_frag_pos);
+               params[0] = get_image_coords(ctx, instr);
                params[1] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
                params[2] = LLVMConstInt(ctx->i32, 15, false); /* dmask */
                if (HAVE_LLVM <= 0x0309) {
@@ -2445,7 +2446,7 @@ static void visit_image_store(struct nir_to_llvm_context *ctx,
                LLVMValueRef slc = i1false;
 
                params[0] = to_float(ctx, get_src(ctx, instr->src[2]));
-               params[1] = get_image_coords(ctx, instr, false); /* coords */
+               params[1] = get_image_coords(ctx, instr); /* coords */
                params[2] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
                params[3] = LLVMConstInt(ctx->i32, 15, false); /* dmask */
                if (HAVE_LLVM <= 0x0309) {
@@ -2505,7 +2506,7 @@ static LLVMValueRef visit_image_atomic(struct nir_to_llvm_context *ctx,
                bool da = glsl_sampler_type_is_array(type) ||
                          glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE;
 
-               coords = params[param_count++] = get_image_coords(ctx, instr, false);
+               coords = params[param_count++] = get_image_coords(ctx, instr);
                params[param_count++] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
                params[param_count++] = i1false; /* r128 */
                params[param_count++] = da ? i1true : i1false;      /* da */