ac/nir: Add support for planes.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 30 Mar 2019 02:15:32 +0000 (03:15 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 25 Apr 2019 19:56:20 +0000 (19:56 +0000)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_shader_abi.h
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index 78f25b8..92aea7d 100644 (file)
@@ -3593,6 +3593,7 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx,
 {
        nir_deref_instr *texture_deref_instr = NULL;
        nir_deref_instr *sampler_deref_instr = NULL;
+       int plane = -1;
 
        for (unsigned i = 0; i < instr->num_srcs; i++) {
                switch (instr->src[i].src_type) {
@@ -3602,6 +3603,9 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx,
                case nir_tex_src_sampler_deref:
                        sampler_deref_instr = nir_src_as_deref(instr->src[i].src);
                        break;
+               case nir_tex_src_plane:
+                       plane = nir_src_as_int(instr->src[i].src);
+                       break;
                default:
                        break;
                }
@@ -3610,10 +3614,18 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx,
        if (!sampler_deref_instr)
                sampler_deref_instr = texture_deref_instr;
 
-       if (instr->sampler_dim  == GLSL_SAMPLER_DIM_BUF)
-               *res_ptr = get_sampler_desc(ctx, texture_deref_instr, AC_DESC_BUFFER, &instr->instr, false, false);
-       else
-               *res_ptr = get_sampler_desc(ctx, texture_deref_instr, AC_DESC_IMAGE, &instr->instr, false, false);
+       enum ac_descriptor_type main_descriptor = instr->sampler_dim  == GLSL_SAMPLER_DIM_BUF ? AC_DESC_BUFFER : AC_DESC_IMAGE;
+
+       if (plane >= 0) {
+               assert(instr->op != nir_texop_txf_ms &&
+                      instr->op != nir_texop_samples_identical);
+               assert(instr->sampler_dim  != GLSL_SAMPLER_DIM_BUF);
+
+               main_descriptor = AC_DESC_PLANE_0 + plane;
+       }
+
+       *res_ptr = get_sampler_desc(ctx, texture_deref_instr, main_descriptor, &instr->instr, false, false);
+
        if (samp_ptr) {
                *samp_ptr = get_sampler_desc(ctx, sampler_deref_instr, AC_DESC_SAMPLER, &instr->instr, false, false);
                if (instr->sampler_dim < GLSL_SAMPLER_DIM_RECT)
index c9b2c2e..108fe58 100644 (file)
@@ -39,6 +39,9 @@ enum ac_descriptor_type {
        AC_DESC_FMASK,
        AC_DESC_SAMPLER,
        AC_DESC_BUFFER,
+       AC_DESC_PLANE_0,
+       AC_DESC_PLANE_1,
+       AC_DESC_PLANE_2,
 };
 
 /* Document the shader ABI during compilation. This is what allows radeonsi and
index ed67976..eb90bfb 100644 (file)
@@ -1089,6 +1089,13 @@ LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
                list = LLVMBuildPointerCast(builder, list,
                                            ac_array_in_const32_addr_space(ctx->v4i32), "");
                break;
+       case AC_DESC_PLANE_0:
+       case AC_DESC_PLANE_1:
+       case AC_DESC_PLANE_2:
+               /* Only used for the multiplane image support for Vulkan. Should
+                * never be reached in radeonsi.
+                */
+               unreachable("Plane descriptor requested in radeonsi.");
        }
 
        return ac_build_load_to_sgpr(&ctx->ac, list, index);