aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-07-02 15:37:16 +1000
committerDave Airlie <[email protected]>2020-07-04 07:19:08 +1000
commit29ce8060eb0584d619e48c440540adc1f32de76e (patch)
treed852ff79865808c560bf22800e6d799488618688 /src/gallium/auxiliary
parent3366171d0ac4c1b19b475f7b72e5dae95a091795 (diff)
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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5489>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_cliptest_tmp.h7
-rw-r--r--src/gallium/auxiliary/draw/draw_prim_assembler.c3
2 files changed, 8 insertions, 2 deletions
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: