gallivm/sample: add gather component selection to the key.
authorDave Airlie <airlied@redhat.com>
Fri, 30 Aug 2019 00:30:00 +0000 (10:30 +1000)
committerDave Airlie <airlied@linux.ie>
Fri, 11 Oct 2019 00:32:15 +0000 (00:32 +0000)
This allows for component selection to work as per ARB_gpu_shader5/GLES3.1

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c

index 8509179..0e4d956 100644 (file)
@@ -96,6 +96,8 @@ enum lp_sampler_op_type {
 #define LP_SAMPLER_LOD_CONTROL_MASK   (3 << 4)
 #define LP_SAMPLER_LOD_PROPERTY_SHIFT       6
 #define LP_SAMPLER_LOD_PROPERTY_MASK  (3 << 6)
+#define LP_SAMPLER_GATHER_COMP_SHIFT        8
+#define LP_SAMPLER_GATHER_COMP_MASK   (3 << 8)
 
 struct lp_sampler_params
 {
@@ -345,6 +347,7 @@ struct lp_build_sample_context
    /** number of lod values (valid are 1, length/4, length) */
    unsigned num_lods;
 
+   unsigned gather_comp;
    boolean no_quad_lod;
    boolean no_brilinear;
    boolean no_rho_approx;
index 48d98bb..964818b 100644 (file)
@@ -1033,6 +1033,17 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
    boolean seamless_cube_filter, accurate_cube_corners;
    unsigned chan_swiz = bld->static_texture_state->swizzle_r;
 
+   if (is_gather) {
+      switch (bld->gather_comp) {
+      case 0: chan_swiz = bld->static_texture_state->swizzle_r; break;
+      case 1: chan_swiz = bld->static_texture_state->swizzle_g; break;
+      case 2: chan_swiz = bld->static_texture_state->swizzle_b; break;
+      case 3: chan_swiz = bld->static_texture_state->swizzle_a; break;
+      default:
+        break;
+      }
+   }
+
    seamless_cube_filter = (bld->static_texture_state->target == PIPE_TEXTURE_CUBE ||
                            bld->static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) &&
                           bld->static_sampler_state->seamless_cube_map;
@@ -2978,7 +2989,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
       bld.num_lods = num_quads;
    }
 
-
+   if (op_is_gather)
+      bld.gather_comp = (sample_key & LP_SAMPLER_GATHER_COMP_MASK) >> LP_SAMPLER_GATHER_COMP_SHIFT;
    bld.lodf_type = type;
    /* we want native vector size to be able to use our intrinsics */
    if (bld.num_lods != type.length) {