[virglrenderer-devel] [PATCH v3 6/7] vrend, caps: move all caps for version 1 into one function

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


Also rename the function caps_common to indicated that only v1 caps are set here.
(This is part one of the cleanup suggested by Gurchetan)

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

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 2d7b658..ec03a46 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -7411,11 +7411,9 @@ static void vrend_fill_caps_glsl_version(int gl_ver, int gles_ver,
       caps->v1.glsl_level = 130;
 }
 
-/*
- * Does all of the common caps setting,
- * if it dedects a early out returns true.
- */
-static void vrend_renderer_fill_caps_common(union virgl_caps *caps)
+/* Does all of the caps v1 setting,*/
+static void vrend_renderer_fill_caps_v1(int gl_ver, int gles_ver,
+                                        union virgl_caps *caps)
 {
    int i;
    GLint max;
@@ -7457,6 +7455,169 @@ static void vrend_renderer_fill_caps_common(union virgl_caps *caps)
        has_feature(feat_gl_prim_restart)) {
       caps->v1.bset.primitive_restart = 1;
    }
+
+   if (caps->v1.glsl_level >= 150) {
+      caps->v1.prim_mask |= (1 << PIPE_PRIM_LINES_ADJACENCY) |
+                            (1 << PIPE_PRIM_LINE_STRIP_ADJACENCY) |
+                            (1 << PIPE_PRIM_TRIANGLES_ADJACENCY) |
+                            (1 << PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
+   }
+
+   if (gl_ver >0 && !vrend_state.use_core_profile) {
+      caps->v1.bset.poly_stipple = 1;
+      caps->v1.bset.color_clamping = 1;
+      caps->v1.prim_mask |= (1 << PIPE_PRIM_QUADS) |
+                            (1 << PIPE_PRIM_QUAD_STRIP) |
+                            (1 << PIPE_PRIM_POLYGON);
+   }
+
+   if (caps->v1.glsl_level >= 400)
+      caps->v1.prim_mask |= (1 << PIPE_PRIM_PATCHES);
+
+   if (epoxy_has_gl_extension("GL_ARB_vertex_type_10f_11f_11f_rev")) {
+      int val = VIRGL_FORMAT_R11G11B10_FLOAT;
+      uint32_t offset = val / 32;
+      uint32_t index = val % 32;
+      caps->v1.vertexbuffer.bitmask[offset] |= (1 << index);
+   }
+
+   if (has_feature(feat_nv_conditional_render) ||
+       has_feature(feat_gl_conditional_render))
+      caps->v1.bset.conditional_render = 1;
+
+   if (has_feature(feat_indep_blend))
+      caps->v1.bset.indep_blend_enable = 1;
+
+   if (has_feature(feat_draw_instance))
+      caps->v1.bset.instanceid = 1;
+
+   if (has_feature(feat_ubo)) {
+      glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
+      vrend_state.max_uniform_blocks = max;
+      caps->v1.max_uniform_blocks = max + 1;
+   }
+
+   if (gl_ver >= 32) {
+      caps->v1.bset.fragment_coord_conventions = 1;
+      caps->v1.bset.depth_clip_disable = 1;
+      caps->v1.bset.seamless_cube_map = 1;
+   } else {
+      if (epoxy_has_gl_extension("GL_ARB_fragment_coord_conventions"))
+         caps->v1.bset.fragment_coord_conventions = 1;
+      if (epoxy_has_gl_extension("GL_ARB_seamless_cube_map"))
+         caps->v1.bset.seamless_cube_map = 1;
+   }
+
+   if (epoxy_has_gl_extension("GL_AMD_seamless_cube_map_per_texture")) {
+      caps->v1.bset.seamless_cube_map_per_texture = 1;
+   }
+
+   if (has_feature(feat_texture_multisample))
+      caps->v1.bset.texture_multisample = 1;
+
+   if (has_feature(feat_tessellation))
+      caps->v1.bset.has_tessellation_shaders = 1;
+
+   if (has_feature(feat_sample_shading))
+      caps->v1.bset.has_sample_shading = 1;
+
+   if (has_feature(feat_indirect_draw))
+      caps->v1.bset.has_indirect_draw = 1;
+
+   if (has_feature(feat_indep_blend_func))
+      caps->v1.bset.indep_blend_func = 1;
+
+   if (has_feature(feat_cube_map_array))
+      caps->v1.bset.cube_map_array = 1;
+
+   if (gl_ver >= 40) {
+      caps->v1.bset.texture_query_lod = 1;
+      caps->v1.bset.has_fp64 = 1;
+   } else {
+      if (epoxy_has_gl_extension("GL_ARB_texture_query_lod"))
+         caps->v1.bset.texture_query_lod = 1;
+      /* need gpu shader 5 for bitfield insert */
+      if (epoxy_has_gl_extension("GL_ARB_gpu_shader_fp64") &&
+          epoxy_has_gl_extension("GL_ARB_gpu_shader5"))
+         caps->v1.bset.has_fp64 = 1;
+   }
+
+   if (has_feature(feat_base_instance))
+      caps->v1.bset.start_instance = 1;
+
+   if (epoxy_has_gl_extension("GL_ARB_shader_stencil_export")) {
+      caps->v1.bset.shader_stencil_export = 1;
+   }
+
+   if (has_feature(feat_conditional_render_inverted))
+      caps->v1.bset.conditional_render_inverted = 1;
+
+   if (gl_ver >= 45) {
+      caps->v1.bset.has_cull = 1;
+      caps->v1.bset.derivative_control = 1;
+   } else {
+     if (epoxy_has_gl_extension("GL_ARB_cull_distance"))
+        caps->v1.bset.has_cull = 1;
+     if (epoxy_has_gl_extension("GL_ARB_derivative_control"))
+	caps->v1.bset.derivative_control = 1;
+   }
+
+   if (has_feature(feat_polygon_offset_clamp))
+      caps->v1.bset.polygon_offset_clamp = 1;
+
+   if (has_feature(feat_transform_feedback_overflow_query))
+     caps->v1.bset.transform_feedback_overflow_query = 1;
+
+   if (epoxy_has_gl_extension("GL_EXT_texture_mirror_clamp") ||
+       epoxy_has_gl_extension("GL_ARB_texture_mirror_clamp_to_edge")) {
+      caps->v1.bset.mirror_clamp = true;
+   }
+
+   if (has_feature(feat_texture_array)) {
+      glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max);
+      caps->v1.max_texture_array_layers = max;
+   }
+
+   /* we need tf3 so we can do gallium skip buffers */
+   if (has_feature(feat_transform_feedback)) {
+      if (has_feature(feat_transform_feedback2))
+         caps->v1.bset.streamout_pause_resume = 1;
+
+      if (has_feature(feat_transform_feedback3)) {
+         glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max);
+         caps->v1.max_streamout_buffers = max;
+      } else if (gles_ver > 0) {
+         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;
+         }
+      } else
+         caps->v1.max_streamout_buffers = 4;
+   }
+
+   if (has_feature(feat_dual_src_blend)) {
+      glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max);
+      caps->v1.max_dual_source_render_targets = max;
+   }
+
+   if (has_feature(feat_arb_or_gles_ext_texture_buffer)) {
+      glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max);
+      caps->v1.max_tbo_size = max;
+   }
+
+   if (epoxy_has_gl_extension("GL_ARB_texture_gather")) {
+      glGetIntegerv(GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB, &max);
+      caps->v1.max_texture_gather_components = max;
+   }
+
+   if (has_feature(feat_viewport_array)) {
+      glGetIntegerv(GL_MAX_VIEWPORTS, &max);
+      caps->v1.max_viewports = max;
+   } else {
+      caps->v1.max_viewports = 1;
+   }
+
 }
 
 static void vrend_renderer_fill_caps_v2_common(union virgl_caps *caps)
@@ -7487,14 +7648,6 @@ static void vrend_renderer_fill_caps_gl(bool fill_capset2, union virgl_caps *cap
 {
    GLfloat range[2];
 
-   if (!vrend_state.use_core_profile) {
-      caps->v1.bset.poly_stipple = 1;
-      caps->v1.bset.color_clamping = 1;
-      caps->v1.prim_mask |= (1 << PIPE_PRIM_QUADS) |
-                            (1 << PIPE_PRIM_QUAD_STRIP) |
-                            (1 << PIPE_PRIM_POLYGON);
-   }
-
    if (!fill_capset2)
       return;
 
@@ -7540,163 +7693,11 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
    }
 
    vrend_fill_caps_glsl_version(gl_ver, gles_ver, caps);
-   vrend_renderer_fill_caps_common(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 (caps->v1.glsl_level >= 150) {
-      caps->v1.prim_mask |= (1 << PIPE_PRIM_LINES_ADJACENCY) |
-                            (1 << PIPE_PRIM_LINE_STRIP_ADJACENCY) |
-                            (1 << PIPE_PRIM_TRIANGLES_ADJACENCY) |
-                            (1 << PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
-   }
-   if (caps->v1.glsl_level >= 400)
-      caps->v1.prim_mask |= (1 << PIPE_PRIM_PATCHES);
-
-   if (epoxy_has_gl_extension("GL_ARB_vertex_type_10f_11f_11f_rev")) {
-      int val = VIRGL_FORMAT_R11G11B10_FLOAT;
-      uint32_t offset = val / 32;
-      uint32_t index = val % 32;
-      caps->v1.vertexbuffer.bitmask[offset] |= (1 << index);
-   }
-
-   if (has_feature(feat_nv_conditional_render) ||
-       has_feature(feat_gl_conditional_render))
-      caps->v1.bset.conditional_render = 1;
-
-   if (has_feature(feat_indep_blend))
-      caps->v1.bset.indep_blend_enable = 1;
-
-   if (has_feature(feat_draw_instance))
-      caps->v1.bset.instanceid = 1;
-
-   if (has_feature(feat_ubo)) {
-      glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
-      vrend_state.max_uniform_blocks = max;
-      caps->v1.max_uniform_blocks = max + 1;
-   }
-
-   if (gl_ver >= 32) {
-      caps->v1.bset.fragment_coord_conventions = 1;
-      caps->v1.bset.depth_clip_disable = 1;
-      caps->v1.bset.seamless_cube_map = 1;
-   } else {
-      if (epoxy_has_gl_extension("GL_ARB_fragment_coord_conventions"))
-         caps->v1.bset.fragment_coord_conventions = 1;
-      if (epoxy_has_gl_extension("GL_ARB_seamless_cube_map"))
-         caps->v1.bset.seamless_cube_map = 1;
-   }
-
-   if (epoxy_has_gl_extension("GL_AMD_seamless_cube_map_per_texture")) {
-      caps->v1.bset.seamless_cube_map_per_texture = 1;
-   }
-
-   if (has_feature(feat_texture_multisample))
-      caps->v1.bset.texture_multisample = 1;
-
-   if (has_feature(feat_tessellation))
-      caps->v1.bset.has_tessellation_shaders = 1;
-
-   if (has_feature(feat_sample_shading))
-      caps->v1.bset.has_sample_shading = 1;
-
-   if (has_feature(feat_indirect_draw))
-      caps->v1.bset.has_indirect_draw = 1;
-
-   if (has_feature(feat_indep_blend_func))
-      caps->v1.bset.indep_blend_func = 1;
-
-   if (has_feature(feat_cube_map_array))
-      caps->v1.bset.cube_map_array = 1;
-
-   if (gl_ver >= 40) {
-      caps->v1.bset.texture_query_lod = 1;
-      caps->v1.bset.has_fp64 = 1;
-   } else {
-      if (epoxy_has_gl_extension("GL_ARB_texture_query_lod"))
-         caps->v1.bset.texture_query_lod = 1;
-      /* need gpu shader 5 for bitfield insert */
-      if (epoxy_has_gl_extension("GL_ARB_gpu_shader_fp64") &&
-          epoxy_has_gl_extension("GL_ARB_gpu_shader5"))
-         caps->v1.bset.has_fp64 = 1;
-   }
-
-   if (has_feature(feat_base_instance))
-      caps->v1.bset.start_instance = 1;
-
-   if (epoxy_has_gl_extension("GL_ARB_shader_stencil_export")) {
-      caps->v1.bset.shader_stencil_export = 1;
-   }
-
-   if (has_feature(feat_conditional_render_inverted))
-      caps->v1.bset.conditional_render_inverted = 1;
-
-   if (gl_ver >= 45) {
-      caps->v1.bset.has_cull = 1;
-      caps->v1.bset.derivative_control = 1;
-   } else {
-     if (epoxy_has_gl_extension("GL_ARB_cull_distance"))
-        caps->v1.bset.has_cull = 1;
-     if (epoxy_has_gl_extension("GL_ARB_derivative_control"))
-	caps->v1.bset.derivative_control = 1;
-   }
-
-   if (has_feature(feat_polygon_offset_clamp))
-      caps->v1.bset.polygon_offset_clamp = 1;
-
-   if (has_feature(feat_transform_feedback_overflow_query))
-     caps->v1.bset.transform_feedback_overflow_query = 1;
-
-   if (epoxy_has_gl_extension("GL_EXT_texture_mirror_clamp") ||
-       epoxy_has_gl_extension("GL_ARB_texture_mirror_clamp_to_edge")) {
-      caps->v1.bset.mirror_clamp = true;
-   }
-
-   if (has_feature(feat_texture_array)) {
-      glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max);
-      caps->v1.max_texture_array_layers = max;
-   }
-
-   /* we need tf3 so we can do gallium skip buffers */
-   if (has_feature(feat_transform_feedback)) {
-      if (has_feature(feat_transform_feedback2))
-         caps->v1.bset.streamout_pause_resume = 1;
-
-      if (has_feature(feat_transform_feedback3)) {
-         glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max);
-         caps->v1.max_streamout_buffers = max;
-      } else if (gles_ver > 0) {
-         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;
-         }
-      } else
-         caps->v1.max_streamout_buffers = 4;
-   }
-
-   if (has_feature(feat_dual_src_blend)) {
-      glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max);
-      caps->v1.max_dual_source_render_targets = max;
-   }
-
-   if (has_feature(feat_arb_or_gles_ext_texture_buffer)) {
-      glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max);
-      caps->v1.max_tbo_size = max;
-   }
-
-   if (epoxy_has_gl_extension("GL_ARB_texture_gather")) {
-      glGetIntegerv(GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB, &max);
-      caps->v1.max_texture_gather_components = max;
-   }
-
-   if (has_feature(feat_viewport_array)) {
-      glGetIntegerv(GL_MAX_VIEWPORTS, &max);
-      caps->v1.max_viewports = max;
-   } else {
-      caps->v1.max_viewports = 1;
-   }
 
    if (!fill_capset2)
       return;
-- 
2.16.4



More information about the virglrenderer-devel mailing list