virgl: access caps in a less verbose way in virgl_is_format_supported
authorGurchetan Singh <gurchetansingh@chromium.org>
Wed, 7 Aug 2019 02:04:25 +0000 (19:04 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Thu, 8 Aug 2019 23:21:57 +0000 (16:21 -0700)
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
src/gallium/drivers/virgl/virgl_screen.c

index 37e75b5e048b36aa6068c6fdbabf07021d41d58f..7153383e9a165eb9023883355bbf7fa36fb3828a 100644 (file)
@@ -651,7 +651,10 @@ virgl_is_format_supported( struct pipe_screen *screen,
    const struct util_format_description *format_desc;
    int i;
 
-   boolean may_emulate_bgra = false;
+   union virgl_caps *caps = &vscreen->caps.caps; 
+   boolean may_emulate_bgra = (caps->v2.capability_bits &
+                               VIRGL_CAP_APP_TWEAK_SUPPORT) &&
+                               vscreen->tweak_gles_emulate_bgra;
 
    if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
       return false;
@@ -674,15 +677,15 @@ virgl_is_format_supported( struct pipe_screen *screen,
       return false;
 
    if (sample_count > 1) {
-      if (!vscreen->caps.caps.v1.bset.texture_multisample)
+      if (!caps->v1.bset.texture_multisample)
          return false;
 
       if (bind & PIPE_BIND_SHADER_IMAGE) {
-         if (sample_count > vscreen->caps.caps.v2.max_image_samples)
+         if (sample_count > caps->v2.max_image_samples)
             return false;
       }
 
-      if (sample_count > vscreen->caps.caps.v1.max_samples)
+      if (sample_count > caps->v1.max_samples)
          return false;
    }
 
@@ -706,9 +709,6 @@ virgl_is_format_supported( struct pipe_screen *screen,
        target == PIPE_TEXTURE_3D)
       return false;
 
-   may_emulate_bgra = (vscreen->caps.caps.v2.capability_bits &
-                       VIRGL_CAP_APP_TWEAK_SUPPORT) &&
-                      vscreen->tweak_gles_emulate_bgra;
 
    if (bind & PIPE_BIND_RENDER_TARGET) {
       /* For ARB_framebuffer_no_attachments. */
@@ -728,7 +728,7 @@ virgl_is_format_supported( struct pipe_screen *screen,
          return false;
 
       if (!virgl_format_check_bitmask(format,
-                                      vscreen->caps.caps.v1.render.bitmask,
+                                      caps->v1.render.bitmask,
                                       may_emulate_bgra))
          return false;
    }
@@ -774,7 +774,7 @@ virgl_is_format_supported( struct pipe_screen *screen,
 
  out_lookup:
    return virgl_format_check_bitmask(format,
-                                     vscreen->caps.caps.v1.sampler.bitmask,
+                                     caps->v1.sampler.bitmask,
                                      may_emulate_bgra);
 }