From be265410c3d9ce3890410e76ecc371cac3eb0f30 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 21 May 2018 15:43:45 +1000 Subject: [PATCH] add ARB_polygon_offset_clamp support Calls the new API and exposes the cap Reviewed-by: Elie Tournier --- src/virgl_hw.h | 1 + src/vrend_renderer.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index a0c4874..102a43a 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -240,6 +240,7 @@ struct virgl_caps_bool_set1 { unsigned has_cull:1; unsigned conditional_render_inverted:1; unsigned derivative_control:1; + unsigned polygon_offset_clamp:1; }; /* endless expansion capabilites - current gallium has 252 formats */ diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 4c4f34a..438c39e 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -117,6 +117,7 @@ struct global_renderer_state { bool have_stencil_texturing; bool have_sample_shading; bool have_texture_buffer_range; + bool have_polygon_offset_clamp; /* these appeared broken on at least one driver */ bool use_explicit_locations; @@ -3698,7 +3699,11 @@ static void vrend_hw_emit_rs(struct vrend_context *ctx) glProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT); } } - glPolygonOffset(state->offset_scale, state->offset_units); + + if (!vrend_state.use_gles && vrend_state.have_polygon_offset_clamp) + glPolygonOffsetClampEXT(state->offset_scale, state->offset_units, state->offset_clamp); + else + glPolygonOffset(state->offset_scale, state->offset_units); if (vrend_state.use_core_profile == false) { if (state->poly_stipple_enable) @@ -4253,6 +4258,9 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags) if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_texture_buffer_range")) vrend_state.have_texture_buffer_range = true; + if (gl_ver >= 46 || epoxy_has_gl_extension("GL_ARB_polygon_offset_clamp")) + vrend_state.have_polygon_offset_clamp = true; + /* callbacks for when we are cleaning up the object table */ vrend_resource_set_destroy_callback(vrend_destroy_resource_object); vrend_object_set_destroy_callback(VIRGL_OBJECT_QUERY, vrend_destroy_query_object); @@ -6965,6 +6973,13 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version, caps->v1.bset.derivative_control = 1; } + if (gl_ver >= 46) { + caps->v1.bset.polygon_offset_clamp = 1; + } else { + if (epoxy_has_gl_extension("GL_ARB_polygon_offset_clamp")) + caps->v1.bset.polygon_offset_clamp = 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;