svga: simplify array test in svga_init_shader_key_common()
authorBrian Paul <brianp@vmware.com>
Tue, 14 Nov 2017 16:34:29 +0000 (09:34 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 10 Sep 2018 19:07:30 +0000 (13:07 -0600)
And squash commit a patch to silence a compiler warning (add
default case to the switch statement).

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_shader.c

index e16842f2358a6f349ac2b391a49e091aa5486445..ebf1131d51d1e8238578dab51b92fdec40c7db73 100644 (file)
@@ -209,18 +209,17 @@ svga_init_shader_key_common(const struct svga_context *svga,
          assert(view->texture->target < (1 << 4)); /* texture_target:4 */
 
          /* 1D/2D array textures with one slice are treated as non-arrays
-          * by the SVGA3D device.  Convert the texture type here so that
-          * we emit the right TEX/SAMPLE instruction in the shader.
+          * by the SVGA3D device.  Set the is_array flag only if we know that
+          * we have more than 1 element.  This will be used to select shader
+          * instruction/resource types during shader translation.
           */
-         if (view->texture->target == PIPE_TEXTURE_1D_ARRAY ||
-             view->texture->target == PIPE_TEXTURE_2D_ARRAY) {
-            if (view->texture->array_size == 1) {
-               key->tex[i].is_array = 0;
-            }
-            else {
-               assert(view->texture->array_size > 1);
-               key->tex[i].is_array = 1;
-            }
+         switch (view->texture->target) {
+         case PIPE_TEXTURE_1D_ARRAY:
+         case PIPE_TEXTURE_2D_ARRAY:
+            key->tex[i].is_array = view->texture->array_size > 1;
+            break;
+         default:
+            ; /* nothing / silence compiler warning */
          }
 
          assert(view->texture->nr_samples < (1 << 5)); /* 5-bit field */