prog_to_nir: Reuse glsl_get_sampler_dim_coordinate_components().
authorEric Anholt <eric@anholt.net>
Wed, 5 Feb 2020 22:45:33 +0000 (14:45 -0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 18:25:02 +0000 (18:25 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3728>

src/mesa/program/prog_to_nir.c

index 5289f0cb4f2a41b9745e45228672096c6e5fc8f1..95bcde2937eb77e237c9db64e8d7a2758c70d16d 100644 (file)
@@ -534,25 +534,8 @@ ptn_tex(struct ptn_compile *c, nir_alu_dest dest, nir_ssa_def **src,
       abort();
    }
 
-   switch (instr->sampler_dim) {
-   case GLSL_SAMPLER_DIM_1D:
-   case GLSL_SAMPLER_DIM_BUF:
-      instr->coord_components = 1;
-      break;
-   case GLSL_SAMPLER_DIM_2D:
-   case GLSL_SAMPLER_DIM_RECT:
-   case GLSL_SAMPLER_DIM_EXTERNAL:
-   case GLSL_SAMPLER_DIM_MS:
-      instr->coord_components = 2;
-      break;
-   case GLSL_SAMPLER_DIM_3D:
-   case GLSL_SAMPLER_DIM_CUBE:
-      instr->coord_components = 3;
-      break;
-   case GLSL_SAMPLER_DIM_SUBPASS:
-   case GLSL_SAMPLER_DIM_SUBPASS_MS:
-      unreachable("can't reach");
-   }
+   instr->coord_components =
+      glsl_get_sampler_dim_coordinate_components(instr->sampler_dim);
 
    nir_variable *var = c->sampler_vars[prog_inst->TexSrcUnit];
    if (!var) {