From 0319ea9ff6a9cc2eba4879fbe09c6fac137d6ce1 Mon Sep 17 00:00:00 2001 From: Matthew McClure Date: Tue, 26 Nov 2013 10:50:27 -0800 Subject: llvmpipe: clamp fragment shader depth write to the current viewport depth range. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this patch, generate_fs_loop will clamp any fragment shader depth writes to the viewport's min and max depth values. Viewport selection is determined by the geometry shader output for the viewport array index. If no index is specified, then the default viewport index is zero. Semantics for this path can be found in draw_clamp_viewport_idx and lp_clamp_viewport_idx. lp_jit_viewport was created to store viewport information visible to JIT code, and is validated when the LP_NEW_VIEWPORT dirty flag is set. lp_rast_shader_inputs is responsible for passing the viewport_index through the rasterizer stage to fragment stage (via lp_jit_thread_data). Reviewed-by: Roland Scheidegger Reviewed-by: José Fonseca --- src/gallium/drivers/llvmpipe/lp_setup_line.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gallium/drivers/llvmpipe/lp_setup_line.c') diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c index 9b3321e3ec1..7e1f6a36745 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_line.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c @@ -294,7 +294,7 @@ try_setup_line( struct lp_setup_context *setup, int y[4]; int i; int nr_planes = 4; - unsigned scissor_index = 0; + unsigned viewport_index = 0; unsigned layer = 0; /* linewidth should be interpreted as integer */ @@ -324,7 +324,7 @@ try_setup_line( struct lp_setup_context *setup, nr_planes = 8; if (setup->viewport_index_slot > 0) { unsigned *udata = (unsigned*)v1[setup->viewport_index_slot]; - scissor_index = lp_clamp_scissor_idx(*udata); + viewport_index = lp_clamp_viewport_idx(*udata); } } else { @@ -573,7 +573,7 @@ try_setup_line( struct lp_setup_context *setup, return TRUE; } - if (!u_rect_test_intersection(&setup->draw_regions[scissor_index], &bbox)) { + if (!u_rect_test_intersection(&setup->draw_regions[viewport_index], &bbox)) { if (0) debug_printf("offscreen\n"); LP_COUNT(nr_culled_tris); return TRUE; @@ -635,6 +635,7 @@ try_setup_line( struct lp_setup_context *setup, line->inputs.disable = FALSE; line->inputs.opaque = FALSE; line->inputs.layer = layer; + line->inputs.viewport_index = viewport_index; for (i = 0; i < 4; i++) { @@ -697,7 +698,7 @@ try_setup_line( struct lp_setup_context *setup, */ if (nr_planes == 8) { const struct u_rect *scissor = - &setup->scissors[scissor_index]; + &setup->scissors[viewport_index]; plane[4].dcdx = -1; plane[4].dcdy = 0; @@ -720,7 +721,7 @@ try_setup_line( struct lp_setup_context *setup, plane[7].eo = 0; } - return lp_setup_bin_triangle(setup, line, &bbox, nr_planes, scissor_index); + return lp_setup_bin_triangle(setup, line, &bbox, nr_planes, viewport_index); } -- cgit v1.2.3