[virglrenderer-devel] [PATCH] renderer: Protect glSampleMaski and GL_SAMPLE_MASK.

David Riley davidriley at chromium.org
Wed Jul 18 23:15:47 UTC 2018


Currently based on have_multisample, but glSampleMaski isn't supported
with the same versions.

Signed-off-by: David Riley <davidriley at chromium.org>
---
 src/vrend_renderer.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 69f1da3..e358b65 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -107,6 +107,7 @@ struct global_renderer_state {
    bool have_arb_or_gles_ext_texture_buffer;
    bool have_multisample;
    bool have_ms_scaled_blit;
+   bool have_sample_mask;
    bool have_nv_prim_restart;
    bool have_gl_prim_restart;
    bool have_bit_encoding;
@@ -4068,10 +4069,12 @@ static void vrend_hw_emit_rs(struct vrend_context *ctx)
    }
 
    if (vrend_state.have_multisample) {
-      if (state->multisample)
-         glEnable(GL_SAMPLE_MASK);
-      else
-         glDisable(GL_SAMPLE_MASK);
+      if (vrend_state.have_sample_mask) {
+	 if (state->multisample)
+	    glEnable(GL_SAMPLE_MASK);
+	 else
+	    glDisable(GL_SAMPLE_MASK);
+      }
 
       /* GLES doesn't have GL_MULTISAMPLE */
       if (!vrend_state.use_gles) {
@@ -4537,6 +4540,9 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
       if (epoxy_has_gl_extension("GL_EXT_framebuffer_multisample_blit_scaled"))
          vrend_state.have_ms_scaled_blit = true;
    }
+   if (gl_ver >= 32 || (gles && gl_ver >= 31) ||
+       epoxy_has_gl_extension("GL_ARB_texture_multisample"))
+      vrend_state.have_sample_mask = true;
 
    if (gl_ver >= 40 || epoxy_has_gl_extension("GL_ARB_sample_shading"))
       vrend_state.have_sample_shading = true;
@@ -6105,7 +6111,8 @@ void vrend_set_clip_state(struct vrend_context *ctx, struct pipe_clip_state *ucp
 
 void vrend_set_sample_mask(UNUSED struct vrend_context *ctx, unsigned sample_mask)
 {
-   glSampleMaski(0, sample_mask);
+   if (vrend_state.have_sample_mask)
+      glSampleMaski(0, sample_mask);
 }
 
 void vrend_set_min_samples(struct vrend_context *ctx, unsigned min_samples)
-- 
2.18.0.203.gfac676dfb9-goog



More information about the virglrenderer-devel mailing list