On 12.06.2017 20:18, Marek Olšák wrote:
From: Marek Olšák <marek.ol...@amd.com>

---
  src/mesa/state_tracker/st_atom_sampler.c | 79 +++++++++++++-------------------
  1 file changed, 31 insertions(+), 48 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index 9695069..ea231f3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -51,85 +51,68 @@
#include "util/u_format.h" /**
   * Convert GLenum texcoord wrap tokens to pipe tokens.
   */
  static GLuint
  gl_wrap_xlate(GLenum wrap)
  {
-   switch (wrap) {
-   case GL_REPEAT:
-      return PIPE_TEX_WRAP_REPEAT;
-   case GL_CLAMP:
-      return PIPE_TEX_WRAP_CLAMP;
-   case GL_CLAMP_TO_EDGE:
-      return PIPE_TEX_WRAP_CLAMP_TO_EDGE;
-   case GL_CLAMP_TO_BORDER:
-      return PIPE_TEX_WRAP_CLAMP_TO_BORDER;
-   case GL_MIRRORED_REPEAT:
-      return PIPE_TEX_WRAP_MIRROR_REPEAT;
-   case GL_MIRROR_CLAMP_EXT:
-      return PIPE_TEX_WRAP_MIRROR_CLAMP;
-   case GL_MIRROR_CLAMP_TO_EDGE_EXT:
-      return PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE;
-   case GL_MIRROR_CLAMP_TO_BORDER_EXT:
-      return PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER;
-   default:
-      assert(0);
-      return 0;
-   }
+   /* Take advantage of how the enums are defined. */
+   static const unsigned table[32] = {
+      PIPE_TEX_WRAP_CLAMP,
+      PIPE_TEX_WRAP_REPEAT,
+      PIPE_TEX_WRAP_MIRROR_CLAMP,
+      PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      PIPE_TEX_WRAP_CLAMP_TO_BORDER,
+      0,
+      PIPE_TEX_WRAP_CLAMP_TO_EDGE,
+      PIPE_TEX_WRAP_MIRROR_REPEAT,
+      0,
+      PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER,

Please use designated initializers, like

 [GL_REPEAT & 0x1f] = PIPE_TEX_WRAP_CLAMP

etc.

With this and Timothy's comment on patch 9 fixed, patches 1-10 are

Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com>


+   };
+
+   return table[wrap & 0x1f];
  }
static GLuint
  gl_filter_to_mip_filter(GLenum filter)
  {
-   switch (filter) {
-   case GL_NEAREST:
-   case GL_LINEAR:
+   /* Take advantage of how the enums are defined. */
+   if (filter <= GL_LINEAR)
        return PIPE_TEX_MIPFILTER_NONE;
-
-   case GL_NEAREST_MIPMAP_NEAREST:
-   case GL_LINEAR_MIPMAP_NEAREST:
+   if (filter <= GL_LINEAR_MIPMAP_NEAREST)
        return PIPE_TEX_MIPFILTER_NEAREST;
- case GL_NEAREST_MIPMAP_LINEAR:
-   case GL_LINEAR_MIPMAP_LINEAR:
-      return PIPE_TEX_MIPFILTER_LINEAR;
-
-   default:
-      assert(0);
-      return PIPE_TEX_MIPFILTER_NONE;
-   }
+   return PIPE_TEX_MIPFILTER_LINEAR;
  }
static GLuint
  gl_filter_to_img_filter(GLenum filter)
  {
-   switch (filter) {
-   case GL_NEAREST:
-   case GL_NEAREST_MIPMAP_NEAREST:
-   case GL_NEAREST_MIPMAP_LINEAR:
-      return PIPE_TEX_FILTER_NEAREST;
-
-   case GL_LINEAR:
-   case GL_LINEAR_MIPMAP_NEAREST:
-   case GL_LINEAR_MIPMAP_LINEAR:
+   /* Take advantage of how the enums are defined. */
+   if (filter & 1)
        return PIPE_TEX_FILTER_LINEAR;
- default:
-      assert(0);
-      return PIPE_TEX_FILTER_NEAREST;
-   }
+   return PIPE_TEX_FILTER_NEAREST;
  }
/**
   * Convert a gl_sampler_object to a pipe_sampler_state object.
   */
  void
  st_convert_sampler(const struct st_context *st,
                     const struct gl_texture_object *texobj,
                     const struct gl_sampler_object *msamp,



--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to