vrend: Enable vertex_attrib_binding also on Hosts with GLES >= 3.1

On GLES >= 3.1 all the functionality that is currently relevant for
attribute binding in virglrenderer is available. However, GLES 3.1 does
not fully implement GL_ARB_vertex_attrib_binding. Therefore, rename the
flag "have_vertex_attrib_binding" to "have_gles31_vertex_attrib_binding",
and set it when the host implements GL_ARB_vertex_attrib_binding, is
GL >= 4.3 or GLES >= 3.1. As a result with these configuration the new
code path vrend_draw_bind_vertex_binding is used.

Fixes on GLES 3.1 hosts:
  dEQP-GLES3.functional.clipping.point.wide_point_z_clip
  dEQP-GLES3.functional.clipping.point.wide_point_z_clip_viewport_center
  dEQP-GLES3.functional.clipping.point.wide_point_z_clip_viewport_corner

On an Intel Kabylake GLES 3.1 host this also fixes:
  dEQP-GLES3.functional.clipping.point.wide_point_clip
  dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_center
  dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_corner

but it should be noted that these three tests expect that also points with a
centre outside the clip volume will be partially drawn when they overlap with
the clip volume because of being "wide" (i.e. when moving towards the clip
volume boundary a wide point would "naturally" move out). The OpenGL standard
defines that points should be clipped the moment the centre is outside the
clip volume (i.e. points will "pop" in and out of the view when moving across
the border). Hence, for a host implementation following the standard to the
letter these tests should actually fail.

v2: - rename have_vertex_attrib_binding to have_gles31_vertex_attrib_binding
    - clarify the commit message describing the wide point clipping problem

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Gert Wollny 7 years ago committed by Jakob Bornecrantz
parent 3222f87b73
commit 4baf9b6a9e
  1. 23
      src/vrend_renderer.c

@ -112,7 +112,7 @@ struct global_renderer_state {
bool have_nv_prim_restart; bool have_nv_prim_restart;
bool have_gl_prim_restart; bool have_gl_prim_restart;
bool have_bit_encoding; bool have_bit_encoding;
bool have_vertex_attrib_binding; bool have_gles31_vertex_attrib_binding;
bool have_tf2; bool have_tf2;
bool have_stencil_texturing; bool have_stencil_texturing;
bool have_sample_shading; bool have_sample_shading;
@ -932,7 +932,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
} else } else
sprog->dual_src_linked = false; sprog->dual_src_linked = false;
if (vrend_state.have_vertex_attrib_binding) { if (vrend_state.have_gles31_vertex_attrib_binding) {
uint32_t mask = vs->sel->sinfo.attrib_input_mask; uint32_t mask = vs->sel->sinfo.attrib_input_mask;
while (mask) { while (mask) {
i = u_bit_scan(&mask); i = u_bit_scan(&mask);
@ -1035,7 +1035,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
sprog->const_locs[id] = NULL; sprog->const_locs[id] = NULL;
} }
if (!vrend_state.have_vertex_attrib_binding) { if (!vrend_state.have_gles31_vertex_attrib_binding) {
if (vs->sel->sinfo.num_inputs) { if (vs->sel->sinfo.num_inputs) {
sprog->attrib_locs = calloc(vs->sel->sinfo.num_inputs, sizeof(uint32_t)); sprog->attrib_locs = calloc(vs->sel->sinfo.num_inputs, sizeof(uint32_t));
if (sprog->attrib_locs) { if (sprog->attrib_locs) {
@ -1224,7 +1224,7 @@ static void vrend_destroy_vertex_elements_object(void *obj_ptr)
{ {
struct vrend_vertex_element_array *v = obj_ptr; struct vrend_vertex_element_array *v = obj_ptr;
if (vrend_state.have_vertex_attrib_binding) { if (vrend_state.have_gles31_vertex_attrib_binding) {
glDeleteVertexArrays(1, &v->id); glDeleteVertexArrays(1, &v->id);
} }
FREE(v); FREE(v);
@ -1837,7 +1837,7 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx,
v->elements[i].nr_chan = desc->nr_channels; v->elements[i].nr_chan = desc->nr_channels;
} }
if (vrend_state.have_vertex_attrib_binding) { if (vrend_state.have_gles31_vertex_attrib_binding) {
glGenVertexArrays(1, &v->id); glGenVertexArrays(1, &v->id);
glBindVertexArray(v->id); glBindVertexArray(v->id);
for (i = 0; i < num_elements; i++) { for (i = 0; i < num_elements; i++) {
@ -2715,7 +2715,7 @@ static void vrend_draw_bind_vertex_legacy(struct vrend_context *ctx,
continue; continue;
} }
if (vrend_state.use_explicit_locations || vrend_state.have_vertex_attrib_binding) { if (vrend_state.use_explicit_locations || vrend_state.have_gles31_vertex_attrib_binding) {
loc = i; loc = i;
} else { } else {
if (ctx->sub->prog->attrib_locs) { if (ctx->sub->prog->attrib_locs) {
@ -3064,7 +3064,7 @@ void vrend_draw_vbo(struct vrend_context *ctx,
} }
} }
if (vrend_state.have_vertex_attrib_binding) if (vrend_state.have_gles31_vertex_attrib_binding)
vrend_draw_bind_vertex_binding(ctx, ctx->sub->ve); vrend_draw_bind_vertex_binding(ctx, ctx->sub->ve);
else else
vrend_draw_bind_vertex_legacy(ctx, ctx->sub->ve); vrend_draw_bind_vertex_legacy(ctx, ctx->sub->ve);
@ -4229,8 +4229,9 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
if (epoxy_has_gl_extension("GL_MESA_pack_invert")) if (epoxy_has_gl_extension("GL_MESA_pack_invert"))
vrend_state.have_mesa_invert = true; vrend_state.have_mesa_invert = true;
if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_vertex_attrib_binding")) if (gl_ver >= 43 || (gles && gl_ver >= 31) ||
vrend_state.have_vertex_attrib_binding = true; epoxy_has_gl_extension("GL_ARB_vertex_attrib_binding"))
vrend_state.have_gles31_vertex_attrib_binding = true;
if (gl_ver >= 33 || epoxy_has_gl_extension("GL_ARB_sampler_objects")) if (gl_ver >= 33 || epoxy_has_gl_extension("GL_ARB_sampler_objects"))
vrend_state.have_samplers = true; vrend_state.have_samplers = true;
if (gl_ver >= 33 || epoxy_has_gl_extension("GL_ARB_shader_bit_encoding")) if (gl_ver >= 33 || epoxy_has_gl_extension("GL_ARB_shader_bit_encoding"))
@ -4339,7 +4340,7 @@ static void vrend_destroy_sub_context(struct vrend_sub_context *sub)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
if (!vrend_state.have_vertex_attrib_binding) { if (!vrend_state.have_gles31_vertex_attrib_binding) {
while (sub->enabled_attribs_bitmask) { while (sub->enabled_attribs_bitmask) {
i = u_bit_scan(&sub->enabled_attribs_bitmask); i = u_bit_scan(&sub->enabled_attribs_bitmask);
@ -7327,7 +7328,7 @@ void vrend_renderer_create_sub_ctx(struct vrend_context *ctx, int sub_ctx_id)
sub->sub_ctx_id = sub_ctx_id; sub->sub_ctx_id = sub_ctx_id;
if (!vrend_state.have_vertex_attrib_binding) { if (!vrend_state.have_gles31_vertex_attrib_binding) {
glGenVertexArrays(1, &sub->vaoid); glGenVertexArrays(1, &sub->vaoid);
glBindVertexArray(sub->vaoid); glBindVertexArray(sub->vaoid);
} }

Loading…
Cancel
Save