[virglrenderer-devel] [RFC PATCH 2/7] vrend caps: move some common caps to main routine

Gert Wollny gert.wollny at collabora.com
Mon Jul 23 10:38:00 UTC 2018


This is an incomplet move of some caps to the main routine, needs
further cleanup.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/vrend_renderer.c | 102 +++++++++++++++++++++------------------------------
 1 file changed, 41 insertions(+), 61 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index e5ca585..0c3e607 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -7257,61 +7257,11 @@ static void vrender_get_glsl_version(int *glsl_version)
  * Does all of the common caps setting,
  * if it dedects a early out returns true.
  */
-static bool vrend_renderer_fill_caps_common(uint32_t set, UNUSED uint32_t version,
-					    union virgl_caps *caps)
+static void vrend_renderer_fill_caps_common(union virgl_caps *caps)
 {
-   int i, gl_ver;
+   int i;
    GLint max;
 
-   if (!caps) {
-      return true;
-   }
-
-   if (set > 2) {
-      caps->max_version = 0;
-      return true;
-   }
-
-   if (set == 1) {
-      memset(caps, 0, sizeof(struct virgl_caps_v1));
-      caps->max_version = 1;
-   } else if (set == 2) {
-      memset(caps, 0, sizeof(*caps));
-      caps->max_version = 2;
-   }
-
-   gl_ver = epoxy_gl_version();
-
-   /*
-    * We can't fully support this feature on GLES,
-    * but it is needed for OpenGL 2.1 so lie.
-    */
-   caps->v1.bset.occlusion_query = 1;
-
-
-   /* Some checks looks at v1.glsl_level so set it here. */
-   if (vrend_state.use_gles) {
-      if (gl_ver >= 30) {
-         caps->v1.glsl_level = 130;
-      } else {
-         caps->v1.glsl_level = 120;
-      }
-   } else if (vrend_state.use_core_profile) {
-      if (gl_ver == 31)
-         caps->v1.glsl_level = 140;
-      else if (gl_ver == 32)
-         caps->v1.glsl_level = 150;
-      else if (gl_ver == 33)
-         caps->v1.glsl_level = 330;
-      else if (gl_ver == 40)
-         caps->v1.glsl_level = 400;
-      else if (gl_ver >= 41)
-         caps->v1.glsl_level = 410;
-   } else {
-      caps->v1.glsl_level = 130;
-   }
-
-
    /* Set supported prims here as we now know what shaders we support. */
    caps->v1.prim_mask = (1 << PIPE_PRIM_POINTS) | (1 << PIPE_PRIM_LINES) | (1 << PIPE_PRIM_LINE_STRIP) | (1 << PIPE_PRIM_LINE_LOOP) | (1 << PIPE_PRIM_TRIANGLES) | (1 << PIPE_PRIM_TRIANGLE_STRIP) | (1 << PIPE_PRIM_TRIANGLE_FAN);
 
@@ -7366,8 +7316,6 @@ static bool vrend_renderer_fill_caps_common(uint32_t set, UNUSED uint32_t versio
        vrend_state.have_gl_prim_restart) {
       caps->v1.bset.primitive_restart = 1;
    }
-
-   return false;
 }
 
 static void vrend_renderer_fill_caps_gles(uint32_t set, UNUSED uint32_t version,
@@ -7466,21 +7414,53 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
    int gl_ver = epoxy_gl_version();
    bool fill_capset2 = false;
 
-   /* Returns true if we should early out. */
-   if (vrend_renderer_fill_caps_common(set, version, caps)) {
+   if (!caps)
       return;
-   }
 
-   /* GLES has it's own path */
-   if (vrend_state.use_gles) {
-      vrend_renderer_fill_caps_gles(set, version, caps);
+   if (set > 2) {
+      caps->max_version = 0;
       return;
    }
 
-   if (set == 2) {
+   if (set == 1) {
+      memset(caps, 0, sizeof(struct virgl_caps_v1));
+      caps->max_version = 1;
+   } else if (set == 2) {
+      memset(caps, 0, sizeof(*caps));
+      caps->max_version = 2;
       fill_capset2 = true;
    }
 
+   /*
+    * We can't fully support this feature on GLES,
+    * but it is needed for OpenGL 2.1 so lie.
+    */
+   caps->v1.bset.occlusion_query = 1;
+
+
+   /* Some checks looks at v1.glsl_level so set it here. */
+   if (vrend_state.use_gles) {
+      if (gles_ver >= 30) {
+         caps->v1.glsl_level = 130;
+      } else {
+         caps->v1.glsl_level = 120;
+      }
+   } else if (vrend_state.use_core_profile) {
+      if (gl_ver == 31)
+         caps->v1.glsl_level = 140;
+      else if (gl_ver == 32)
+         caps->v1.glsl_level = 150;
+      else if (gl_ver == 33)
+         caps->v1.glsl_level = 330;
+      else if (gl_ver == 40)
+         caps->v1.glsl_level = 400;
+      else if (gl_ver >= 41)
+         caps->v1.glsl_level = 410;
+   } else {
+      caps->v1.glsl_level = 130;
+   }
+
+   vrend_renderer_fill_caps_common(caps);
    if (gl_ver >= 30) {
       caps->v1.bset.indep_blend_enable = 1;
       caps->v1.bset.conditional_render = 1;
-- 
2.16.4



More information about the virglrenderer-devel mailing list