[virglrenderer-devel] [RFC PATCH 3/7] vrend caps: order caps that have versions or extensions versus general caps

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


Move caps that are set based on the API type to their functions and
everything else into the main cap setting routine.

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

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 0c3e607..b76d700 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -7318,42 +7318,10 @@ static void vrend_renderer_fill_caps_common(union virgl_caps *caps)
    }
 }
 
-static void vrend_renderer_fill_caps_gles(uint32_t set, UNUSED uint32_t version,
-					  union virgl_caps *caps)
+static void vrend_renderer_fill_caps_gles(bool fill_capset2, union virgl_caps *caps)
 {
    GLint max;
    GLfloat range[2];
-   bool fill_capset2 = false;
-   int gles_ver = epoxy_gl_version();
-
-   if (set == 2) {
-      fill_capset2 = true;
-   }
-
-   if (gles_ver >= 30) {
-      glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max);
-      caps->v1.max_texture_array_layers = max;
-      caps->v1.bset.primitive_restart = 1;
-   }
-
-   if (gles_ver >= 30) {
-      caps->v1.bset.instanceid = 1;
-      glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
-      vrend_state.max_uniform_blocks = max;
-      caps->v1.max_uniform_blocks = max + 1;
-   }
-
-   if (gles_ver >= 30) {
-      glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &max);
-      /* As with the earlier version of transform feedback this min 4. */
-      if (max >= 4) {
-         caps->v1.max_streamout_buffers = 4;
-      }
-   }
-
-   if (gles_ver >= 30) {
-      caps->v1.bset.texture_multisample = 1;
-   }
 
    if (!fill_capset2) {
       return;
@@ -7394,24 +7362,56 @@ static void vrend_renderer_fill_caps_gles(uint32_t set, UNUSED uint32_t version,
 
    glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.uniform_buffer_offset_alignment);
 
-   if (gles_ver >= 31)
-      glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.shader_buffer_offset_alignment);
-
    /* Not available on GLES */
    caps->v2.texture_buffer_offset_alignment = 0;
+}
 
-   caps->v1.max_samples = vrend_renderer_query_multisample_caps(max, &caps->v2);
+static void vrend_renderer_fill_caps_gl(bool fill_capset2,
+                                        union virgl_caps *caps)
+{
+   GLint max;
+   GLfloat range[2];
 
-   if (vrend_state.have_copy_image)
-      caps->v2.capability_bits |= VIRGL_CAP_COPY_IMAGE;
+   if (!fill_capset2)
+      return;
+
+   glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, range);
+   caps->v2.min_aliased_point_size = range[0];
+   caps->v2.max_aliased_point_size = range[1];
+
+   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_ALIASED_LINE_WIDTH_RANGE, range);
+   caps->v2.min_aliased_line_width = range[0];
+   caps->v2.max_aliased_line_width = 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);
+   caps->v2.max_vertex_outputs = max / 4;
 }
 
-void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
+void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
                               union virgl_caps *caps)
 {
    GLint max;
    GLfloat range[2];
-   int gl_ver = epoxy_gl_version();
+
+   int gl_ver, gles_ver;
+   if (vrend_state.use_gles) {
+       gles_ver = epoxy_gl_version();
+       gl_ver = 0;
+   } else {
+      gles_ver = 0;
+      gl_ver = epoxy_gl_version();
+   }
+
    bool fill_capset2 = false;
 
    if (!caps)
@@ -7461,6 +7461,14 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
    }
 
    vrend_renderer_fill_caps_common(caps);
+
+   /* GLES has it's own path */
+   if (vrend_state.use_gles) {
+      vrend_renderer_fill_caps_gles(fill_capset2, caps);
+   } else {
+      vrend_renderer_fill_caps_gl(fill_capset2, caps);
+   }
+
    if (gl_ver >= 30) {
       caps->v1.bset.indep_blend_enable = 1;
       caps->v1.bset.conditional_render = 1;
@@ -7553,9 +7561,9 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
      if (epoxy_has_gl_extension("GL_ARB_cull_distance"))
         caps->v1.bset.has_cull = 1;
      if (epoxy_has_gl_extension("GL_ARB_conditional_render_inverted"))
-	caps->v1.bset.conditional_render_inverted = 1;
+        caps->v1.bset.conditional_render_inverted = 1;
      if (epoxy_has_gl_extension("GL_ARB_derivative_control"))
-	caps->v1.bset.derivative_control = 1;
+        caps->v1.bset.derivative_control = 1;
    }
 
    if (gl_ver >= 46) {
@@ -7612,29 +7620,41 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
       caps->v1.max_viewports = 1;
    }
 
-   if (!fill_capset2)
-      return;
+   if (gles_ver >= 30) {
+      glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max);
+      caps->v1.max_texture_array_layers = max;
+      caps->v1.bset.primitive_restart = 1;
+   }
 
-   glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, range);
-   caps->v2.min_aliased_point_size = range[0];
-   caps->v2.max_aliased_point_size = range[1];
+   if (gles_ver >= 30) {
+      caps->v1.bset.instanceid = 1;
+      glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
+      vrend_state.max_uniform_blocks = max;
+      caps->v1.max_uniform_blocks = max + 1;
+   }
 
-   glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, range);
-   caps->v2.min_smooth_point_size = range[0];
-   caps->v2.max_smooth_point_size = range[1];
+   if (gles_ver >= 30) {
+      glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &max);
+      /* As with the earlier version of transform feedback this min 4. */
+      if (max >= 4) {
+         caps->v1.max_streamout_buffers = 4;
+      }
+   }
 
-   glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range);
-   caps->v2.min_aliased_line_width = range[0];
-   caps->v2.max_aliased_line_width = range[1];
+   if (gles_ver >= 30) {
+      caps->v1.bset.texture_multisample = 1;
+   }
 
-   glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range);
-   caps->v2.min_smooth_line_width = range[0];
-   caps->v2.max_smooth_line_width = range[1];
+   if (gles_ver >= 31)
+      glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.shader_buffer_offset_alignment);
 
-   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);
-   caps->v2.max_vertex_outputs = max / 4;
+   glGetIntegerv(GL_SAMPLES, &max);
+   caps->v1.max_samples = max;
+
+   if (!fill_capset2)
+      return;
+
+   caps->v1.max_samples = vrend_renderer_query_multisample_caps(caps->v1.max_samples, &caps->v2);
 
    if (gl_ver >= 32) {
       glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, (GLint*)&caps->v2.max_geom_output_vertices);
@@ -7673,9 +7693,7 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
       caps->v2.max_shader_buffer_frag_compute = max;
    }
 
-   caps->v1.max_samples = vrend_renderer_query_multisample_caps(max, &caps->v2);
-
-   caps->v2.capability_bits |= VIRGL_CAP_TGSI_INVARIANT | VIRGL_CAP_SET_MIN_SAMPLES;
+      caps->v2.capability_bits |= VIRGL_CAP_TGSI_INVARIANT | VIRGL_CAP_SET_MIN_SAMPLES;
 
    if (gl_ver >= 44)
       glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, (GLint*)&caps->v2.max_vertex_attrib_stride);
@@ -7685,6 +7703,7 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
 
    if (vrend_state.have_copy_image)
       caps->v2.capability_bits |= VIRGL_CAP_COPY_IMAGE;
+
 }
 
 GLint64 vrend_renderer_get_timestamp(void)
-- 
2.16.4



More information about the virglrenderer-devel mailing list