From 68db29c434e144891e5990b032b44495de52f6eb Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Sat, 15 Nov 2014 13:29:25 -0500 Subject: st/mesa: add a fallback for clear_with_quad when no vs_layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all drivers can set gl_Layer from VS. Add a fallback that passes the instance id from VS to GS, and then uses the GS to set the layer. Tested by adding quad_buffers |= clear_buffers; clear_buffers = 0; to the st_Clear logic, and forcing set_vertex_shader_layered in all cases. No piglit regressions (on piglits with 'clear' in the name). Signed-off-by: Ilia Mirkin Reviewed-by: Marek Olšák Cc: "10.4 10.3" --- src/mesa/state_tracker/st_cb_clear.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_clear.c') diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 3a359f31885..45dea594ee7 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -88,6 +88,14 @@ st_destroy_clear(struct st_context *st) cso_delete_vertex_shader(st->cso_context, st->clear.vs); st->clear.vs = NULL; } + if (st->clear.vs_layered) { + cso_delete_vertex_shader(st->cso_context, st->clear.vs_layered); + st->clear.vs_layered = NULL; + } + if (st->clear.gs_layered) { + cso_delete_geometry_shader(st->cso_context, st->clear.gs_layered); + st->clear.gs_layered = NULL; + } } @@ -128,6 +136,7 @@ set_vertex_shader(struct st_context *st) } cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); + cso_set_geometry_shader_handle(st->cso_context, NULL); } @@ -136,18 +145,25 @@ set_vertex_shader_layered(struct st_context *st) { struct pipe_context *pipe = st->pipe; - if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) || - !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) { - assert(!"Got layered clear, but the VS layer output is unsupported"); + if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID)) { + assert(!"Got layered clear, but VS instancing is unsupported"); set_vertex_shader(st); return; } if (!st->clear.vs_layered) { - st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe); + bool vs_layer = + pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT); + if (vs_layer) { + st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe); + } else { + st->clear.vs_layered = util_make_layered_clear_helper_vertex_shader(pipe); + st->clear.gs_layered = util_make_layered_clear_geometry_shader(pipe); + } } cso_set_vertex_shader_handle(st->cso_context, st->clear.vs_layered); + cso_set_geometry_shader_handle(st->cso_context, st->clear.gs_layered); } @@ -331,7 +347,6 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) } set_fragment_shader(st); - cso_set_geometry_shader_handle(st->cso_context, NULL); if (num_layers > 1) set_vertex_shader_layered(st); -- cgit v1.2.3