From: Dave Airlie Date: Thu, 2 Jul 2020 05:37:16 +0000 (+1000) Subject: draw/clip: fix viewport index for geometry shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=29ce8060eb0584d619e48c440540adc1f32de76e;p=mesa.git draw/clip: fix viewport index for geometry shaders The old code updated the viewport index on the first vertex in a primitive, however it was picking the first vertex wrong when used with geometry shaders. This code has access to the prim info with the primitive lengths so instead keep track of when a new primitive starts by tracking the lengths and updating the viewport index then. The prim info is only valid after a GS or prim assembly, so enable prim assembly if a vertex shader ever uses viewport index. This fixes: piglit arb_viewport_array-render-viewport-2 KHR-GLES31.core.viewport_array.draw_to_single_layer_with_multiple_viewports,Fail KHR-GLES31.core.viewport_array.draw_mulitple_viewports_with_single_invocation,Fail KHR-GLES31.core.viewport_array.draw_multiple_layers,Fail KHR-GLES31.core.viewport_array.depth_range,Fail Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/.gitlab-ci/piglit/quick_gl.txt b/.gitlab-ci/piglit/quick_gl.txt index bc50f08f0f6..6c9f2d8f561 100644 --- a/.gitlab-ci/piglit/quick_gl.txt +++ b/.gitlab-ci/piglit/quick_gl.txt @@ -901,7 +901,6 @@ spec/arb_vertex_program/vp-address-02: skip spec/arb_vertex_program/vp-address-04: skip spec/arb_vertex_type_2_10_10_10_rev/attrib-p-type-size-match: skip spec/arb_viewport_array/display-list: skip -spec/arb_viewport_array/render-viewport-2: fail spec/ati_envmap_bumpmap/ati_envmap_bumpmap-bump: skip spec/egl 1.4/egl-blob-cache: skip spec/egl 1.4/egl-context-priority: skip @@ -1681,15 +1680,14 @@ spec/oes_texture_view/rendering-formats/render to gl_rgb8ui as gl_rgb8i: skip spec/oes_texture_view/rendering-formats/render to gl_rgb8ui as gl_rgb8ui: skip spec/oes_texture_view/texsubimage-layers pbo: skip spec/oes_texture_view/texsubimage-levels pbo: skip -spec/oes_viewport_array/render-viewport-2: fail wgl/wgl-multi-context-single-window: skip wgl/wgl-multi-window-single-context: skip wgl/wgl-sanity: skip summary: name: results ---- -------- - pass: 21837 - fail: 217 + pass: 21839 + fail: 215 crash: 0 skip: 1446 timeout: 0 diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h index ba02461db48..b7c77bfd85d 100644 --- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h +++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h @@ -49,7 +49,6 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, int viewport_index = 0; int num_written_clipdistance = draw_current_shader_num_written_clipdistances(pvs->draw); - unsigned verts_per_prim = u_vertices_per_prim(prim_info->prim); if (uses_vp_idx) { viewport_index = u_bitcast_f2u(out->data[viewport_index_output][0]); @@ -70,16 +69,20 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, } assert(pos != -1); + unsigned prim_idx = 0, prim_vert_idx = 0; for (j = 0; j < info->count; j++) { float *position = out->data[pos]; unsigned mask = 0x0; if (uses_vp_idx) { /* only change the viewport_index for the leading vertex */ - if (!(j % verts_per_prim)) { + if (prim_vert_idx == (prim_info->primitive_lengths[prim_idx])) { + prim_idx++; + prim_vert_idx = 0; viewport_index = u_bitcast_f2u(out->data[viewport_index_output][0]); viewport_index = draw_clamp_viewport_idx(viewport_index); } + prim_vert_idx++; } float *scale = pvs->draw->viewports[viewport_index].scale; float *trans = pvs->draw->viewports[viewport_index].translate; diff --git a/src/gallium/auxiliary/draw/draw_prim_assembler.c b/src/gallium/auxiliary/draw/draw_prim_assembler.c index c0bc145f38b..edaaf0d501f 100644 --- a/src/gallium/auxiliary/draw/draw_prim_assembler.c +++ b/src/gallium/auxiliary/draw/draw_prim_assembler.c @@ -76,6 +76,9 @@ draw_prim_assembler_is_required(const struct draw_context *draw, const struct draw_prim_info *prim_info, const struct draw_vertex_info *vert_info) { + /* viewport index requires primitive boundaries to get correct vertex */ + if (draw_current_shader_uses_viewport_index(draw)) + return TRUE; switch (prim_info->prim) { case PIPE_PRIM_LINES_ADJACENCY: case PIPE_PRIM_LINE_STRIP_ADJACENCY: