[virglrenderer-devel] [PATCH v3 7/7] vrend, caps: Move all v2 caps into according function

Gert Wollny gert.wollny at collabora.com
Mon Jul 30 13:01:11 UTC 2018


Move all v2 caps into the caps_v2 function that also gets renamed.
Protect the GL only value queries by using the according gl_ver test.

(Part two of cleanup suggested by Gurchetan)

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

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index ec03a46..03b195e 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -7620,7 +7620,7 @@ static void vrend_renderer_fill_caps_v1(int gl_ver, int gles_ver,
 
 }
 
-static void vrend_renderer_fill_caps_v2_common(union virgl_caps *caps)
+static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_caps *caps)
 {
    GLint max;
    GLfloat range[2];
@@ -7633,6 +7633,16 @@ static void vrend_renderer_fill_caps_v2_common(union virgl_caps *caps)
    caps->v2.min_aliased_line_width = range[0];
    caps->v2.max_aliased_line_width = range[1];
 
+   if (gl_ver > 12) {
+      glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, range);
+      caps->v2.min_smooth_point_size = range[0];
+      caps->v2.max_smooth_point_size = range[1];
+
+      glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range);
+      caps->v2.min_smooth_line_width = range[0];
+      caps->v2.max_smooth_line_width = range[1];
+   }
+
    glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &caps->v2.max_texture_lod_bias);
    glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint*)&caps->v2.max_vertex_attribs);
    glGetIntegerv(GL_MAX_VERTEX_OUTPUT_COMPONENTS, &max);
@@ -7642,67 +7652,6 @@ static void vrend_renderer_fill_caps_v2_common(union virgl_caps *caps)
    glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &caps->v2.max_texel_offset);
 
    glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.uniform_buffer_offset_alignment);
-}
-
-static void vrend_renderer_fill_caps_gl(bool fill_capset2, union virgl_caps *caps)
-{
-   GLfloat range[2];
-
-   if (!fill_capset2)
-      return;
-
-   glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, range);
-   caps->v2.min_smooth_point_size = range[0];
-   caps->v2.max_smooth_point_size = range[1];
-
-   glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range);
-   caps->v2.min_smooth_line_width = range[0];
-   caps->v2.max_smooth_line_width = range[1];
-}
-
-void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
-                              union virgl_caps *caps)
-{
-   GLint max;
-   int gl_ver, gles_ver;
-   bool fill_capset2 = false;
-
-   if (!caps)
-      return;
-
-   if (set > 2) {
-      caps->max_version = 0;
-      return;
-   }
-
-   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;
-   }
-
-   if (vrend_state.use_gles) {
-      gles_ver = epoxy_gl_version();
-      gl_ver = 0;
-   } else {
-      gles_ver = 0;
-      gl_ver = epoxy_gl_version();
-   }
-
-   vrend_fill_caps_glsl_version(gl_ver, gles_ver, caps);
-   vrend_renderer_fill_caps_v1(gl_ver, gles_ver, caps);
-
-   if (!vrend_state.use_gles)
-      vrend_renderer_fill_caps_gl(fill_capset2, caps);
-
-
-   if (!fill_capset2)
-      return;
-
-   vrend_renderer_fill_caps_v2_common(caps);
 
    if (has_feature(feat_geometry_shader)) {
       glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, (GLint*)&caps->v2.max_geom_output_vertices);
@@ -7751,6 +7700,44 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       caps->v2.capability_bits |= VIRGL_CAP_COPY_IMAGE;
 }
 
+void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
+                              union virgl_caps *caps)
+{
+   int gl_ver, gles_ver;
+   bool fill_capset2 = false;
+
+   if (!caps)
+      return;
+
+   if (set > 2) {
+      caps->max_version = 0;
+      return;
+   }
+
+   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;
+   }
+
+   if (vrend_state.use_gles) {
+      gles_ver = epoxy_gl_version();
+      gl_ver = 0;
+   } else {
+      gles_ver = 0;
+      gl_ver = epoxy_gl_version();
+   }
+
+   vrend_fill_caps_glsl_version(gl_ver, gles_ver, caps);
+   vrend_renderer_fill_caps_v1(gl_ver, gles_ver, caps);
+
+   if (fill_capset2)
+      vrend_renderer_fill_caps_v2(gl_ver, gles_ver, caps);
+}
+
 GLint64 vrend_renderer_get_timestamp(void)
 {
    GLint64 v;
-- 
2.16.4



More information about the virglrenderer-devel mailing list