[virglrenderer-devel] [RFC PATCH 7/7] vrend caps: unify caps and remove some duplications

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


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

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 6b6d4ac..4fbba84 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4634,7 +4634,8 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
    if (gl_ver >= 42 || epoxy_has_gl_extension("GL_ARB_texture_storage"))
       vrend_state.have_texture_storage = true;
 
-   if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_texture_view"))
+   if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_texture_view") ||
+       epoxy_has_gl_extension("GL_OES_texture_view"))
       vrend_state.have_texture_view = true;
 
    if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_shader_storage_buffer_object"))
@@ -7398,7 +7399,8 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
 
    /* These are filled in by the init code, so are common. */
    if (vrend_state.have_nv_prim_restart ||
-       vrend_state.have_gl_prim_restart) {
+       vrend_state.have_gl_prim_restart ||
+       gles_ver >= 30) {
       caps->v1.bset.primitive_restart = 1;
    }
 
@@ -7439,7 +7441,7 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       caps->v1.bset.color_clamping = 1;
    }
 
-   if (gl_ver >= 31) {
+   if (gl_ver >= 31 || gles_ver >= 30) {
       caps->v1.bset.instanceid = 1;
       glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
       vrend_state.max_uniform_blocks = max;
@@ -7464,10 +7466,6 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       caps->v1.bset.seamless_cube_map_per_texture = 1;
    }
 
-   if (epoxy_has_gl_extension("GL_ARB_texture_multisample")) {
-      caps->v1.bset.texture_multisample = 1;
-   }
-
    if (gl_ver >= 40) {
       caps->v1.bset.indep_blend_func = 1;
       caps->v1.bset.cube_map_array = 1;
@@ -7533,7 +7531,7 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       caps->v1.bset.mirror_clamp = true;
    }
 
-   if (epoxy_has_gl_extension("GL_EXT_texture_array")) {
+   if (gles_ver >= 30 || gl_ver >= 30 ||epoxy_has_gl_extension("GL_EXT_texture_array")) {
       glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max);
       caps->v1.max_texture_array_layers = max;
    }
@@ -7543,63 +7541,47 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       caps->v1.bset.streamout_pause_resume = 1;
    }
 
-   if (epoxy_has_gl_extension("GL_ARB_transform_feedback3")) {
+   if (gl_ver >= 40 || epoxy_has_gl_extension("GL_ARB_transform_feedback3")) {
       glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max);
       caps->v1.max_streamout_buffers = max;
+   } else 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;
+      }
    } else if (epoxy_has_gl_extension("GL_EXT_transform_feedback")) {
       caps->v1.max_streamout_buffers = 4;
    }
 
-   if (epoxy_has_gl_extension("GL_ARB_blend_func_extended")) {
+   if (gl_ver >= 33 || epoxy_has_gl_extension("GL_ARB_blend_func_extended")) {
       glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max);
       caps->v1.max_dual_source_render_targets = max;
    }
 
-   if (epoxy_has_gl_extension("GL_ARB_texture_buffer_object")) {
+   if (gl_ver >= 43 || gles_ver >= 31 || epoxy_has_gl_extension("GL_ARB_texture_buffer_object")) {
       glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max);
       caps->v1.max_tbo_size = max;
    }
 
-   if (epoxy_has_gl_extension("GL_ARB_texture_gather")) {
+   if (gles_ver >= 31) {
+      caps->v1.max_texture_gather_components = 4;
+  } else if (gl_ver >= 40 ||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 (epoxy_has_gl_extension("GL_ARB_viewport_array")) {
+   if (gl_ver >= 41 || epoxy_has_gl_extension("GL_ARB_viewport_array")) {
       glGetIntegerv(GL_MAX_VIEWPORTS, &max);
       caps->v1.max_viewports = max;
    } else {
       caps->v1.max_viewports = 1;
    }
 
-   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 || gl_ver >= 32 || epoxy_has_gl_extension("GL_ARB_texture_multisample")) {
+       caps->v1.bset.texture_multisample = 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 (gles_ver >= 31)
-      glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.shader_buffer_offset_alignment);
-
    glGetIntegerv(GL_SAMPLES, &max);
    caps->v1.max_samples = max;
 
@@ -7632,7 +7614,7 @@ void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,
       glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.texture_buffer_offset_alignment);
    }
 
-   if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_shader_storage_buffer_object")) {
+   if (gl_ver >= 43 || gles_ver >= 31 || epoxy_has_gl_extension("GL_ARB_shader_storage_buffer_object")) {
       glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, (GLint*)&caps->v2.shader_buffer_offset_alignment);
 
       glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max);
-- 
2.16.4



More information about the virglrenderer-devel mailing list