Mesa (master): freedreno: Reuse glsl_get_sampler_coordinate_components().
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 4 23:57:22 UTC 2019
Module: Mesa
Branch: master
Commit: 8843b90cacc3546c6cb4a6e49daec4117649f1bf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8843b90cacc3546c6cb4a6e49daec4117649f1bf
Author: Eric Anholt <eric at anholt.net>
Date: Tue May 14 17:18:40 2019 -0700
freedreno: Reuse glsl_get_sampler_coordinate_components().
We have the GLSL type, so we can just ask it how many coordinates there
are. The GLSL function already has Vulkan cases that we'd probably want
eventually.
Reviewed-by: Rob Clark <robdclark at gmail.com>
---
src/freedreno/ir3/ir3_image.c | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/src/freedreno/ir3/ir3_image.c b/src/freedreno/ir3/ir3_image.c
index 835b5381d23..bb852dc25f5 100644
--- a/src/freedreno/ir3/ir3_image.c
+++ b/src/freedreno/ir3/ir3_image.c
@@ -120,34 +120,14 @@ unsigned
ir3_get_image_coords(const nir_variable *var, unsigned *flagsp)
{
const struct glsl_type *type = glsl_without_array(var->type);
- unsigned coords, flags = 0;
-
- switch (glsl_get_sampler_dim(type)) {
- case GLSL_SAMPLER_DIM_1D:
- case GLSL_SAMPLER_DIM_BUF:
- coords = 1;
- break;
- case GLSL_SAMPLER_DIM_2D:
- case GLSL_SAMPLER_DIM_RECT:
- case GLSL_SAMPLER_DIM_EXTERNAL:
- case GLSL_SAMPLER_DIM_MS:
- coords = 2;
- break;
- case GLSL_SAMPLER_DIM_3D:
- case GLSL_SAMPLER_DIM_CUBE:
+ unsigned coords = glsl_get_sampler_coordinate_components(type);
+ unsigned flags = 0;
+
+ if (coords == 3)
flags |= IR3_INSTR_3D;
- coords = 3;
- break;
- default:
- unreachable("bad sampler dim");
- return 0;
- }
- if (glsl_sampler_type_is_array(type)) {
- /* note: unlike tex_info(), adjust # of coords to include array idx: */
- coords++;
+ if (glsl_sampler_type_is_array(type))
flags |= IR3_INSTR_A;
- }
if (flagsp)
*flagsp = flags;
More information about the mesa-commit
mailing list