ac: teach get_ac_sampler_dim() about subpass attachments
[mesa.git] / src / amd / common / ac_nir_to_llvm.c
index ba7f353a9ab367290db906fdfa35e0ff57d98b2c..900c1c4afeafa9cc2d7720057e66ccbdc9c57398 100644 (file)
@@ -87,7 +87,6 @@ get_ac_sampler_dim(const struct ac_llvm_context *ctx, enum glsl_sampler_dim dim,
                return is_array ? ac_image_1darray : ac_image_1d;
        case GLSL_SAMPLER_DIM_2D:
        case GLSL_SAMPLER_DIM_RECT:
-       case GLSL_SAMPLER_DIM_SUBPASS:
        case GLSL_SAMPLER_DIM_EXTERNAL:
                return is_array ? ac_image_2darray : ac_image_2d;
        case GLSL_SAMPLER_DIM_3D:
@@ -95,8 +94,11 @@ get_ac_sampler_dim(const struct ac_llvm_context *ctx, enum glsl_sampler_dim dim,
        case GLSL_SAMPLER_DIM_CUBE:
                return ac_image_cube;
        case GLSL_SAMPLER_DIM_MS:
-       case GLSL_SAMPLER_DIM_SUBPASS_MS:
                return is_array ? ac_image_2darraymsaa : ac_image_2dmsaa;
+       case GLSL_SAMPLER_DIM_SUBPASS:
+               return ac_image_2darray;
+       case GLSL_SAMPLER_DIM_SUBPASS_MS:
+               return ac_image_2darraymsaa;
        default:
                unreachable("bad sampler dim");
        }
@@ -3385,6 +3387,13 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
        }
 
        /* Texture coordinates fixups */
+       if (instr->coord_components > 1 &&
+           instr->sampler_dim == GLSL_SAMPLER_DIM_1D &&
+           instr->is_array &&
+           instr->op != nir_texop_txf) {
+               args.coords[1] = apply_round_slice(&ctx->ac, args.coords[1]);
+       }
+
        if (instr->coord_components > 2 &&
            (instr->sampler_dim == GLSL_SAMPLER_DIM_2D ||
             instr->sampler_dim == GLSL_SAMPLER_DIM_MS ||