mesa/st: simplify format usage in st_bind_egl_image
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 29 May 2019 20:41:59 +0000 (16:41 -0400)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 1 Jul 2019 22:16:43 +0000 (15:16 -0700)
the formats handled in the switch statement will always return an
unknown mesa format, so process them directly and leave the default
case for other/unknown formats

no functional changes

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/state_tracker/st_cb_eglimage.c

index f79df5a..08697c4 100644 (file)
@@ -196,25 +196,23 @@ st_bind_egl_image(struct gl_context *ctx,
       stObj->surface_based = GL_TRUE;
    }
 
-   texFormat = st_pipe_format_to_mesa_format(stimg->format);
-
    /* TODO RequiredTextureImageUnits should probably be reset back
     * to 1 somewhere if different texture is bound??
     */
-   if (texFormat == MESA_FORMAT_NONE) {
-      switch (stimg->format) {
-      case PIPE_FORMAT_NV12:
-         texFormat = MESA_FORMAT_R_UNORM8;
-         texObj->RequiredTextureImageUnits = 2;
-         break;
-      case PIPE_FORMAT_IYUV:
-         texFormat = MESA_FORMAT_R_UNORM8;
-         texObj->RequiredTextureImageUnits = 3;
-         break;
-      default:
-         unreachable("bad YUV format!");
-      }
+   switch (stimg->format) {
+   case PIPE_FORMAT_NV12:
+      texFormat = MESA_FORMAT_R_UNORM8;
+      texObj->RequiredTextureImageUnits = 2;
+      break;
+   case PIPE_FORMAT_IYUV:
+      texFormat = MESA_FORMAT_R_UNORM8;
+      texObj->RequiredTextureImageUnits = 3;
+      break;
+   default:
+      texFormat = st_pipe_format_to_mesa_format(stimg->format);
+      break;
    }
+   assert(texFormat != MESA_FORMAT_NONE);
 
    _mesa_init_teximage_fields(ctx, texImage,
                               stimg->texture->width0, stimg->texture->height0,