Mesa (master): draw/clip: cleanup viewport index handling code.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 3 21:40:35 UTC 2020


Module: Mesa
Branch: master
Commit: 3366171d0ac4c1b19b475f7b72e5dae95a091795
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3366171d0ac4c1b19b475f7b72e5dae95a091795

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jul  2 15:29:32 2020 +1000

draw/clip: cleanup viewport index handling code.

This moves code around, and adds initial clamping

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5489>

---

 src/gallium/auxiliary/draw/draw_cliptest_tmp.h | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
index dd57c5678e0..ba02461db48 100644
--- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
+++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
@@ -43,13 +43,18 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
    unsigned j;
    unsigned i;
    bool have_cd = false;
+   bool uses_vp_idx = draw_current_shader_uses_viewport_index(pvs->draw);
    unsigned viewport_index_output =
       draw_current_shader_viewport_index_output(pvs->draw);
-   int viewport_index = 
-      draw_current_shader_uses_viewport_index(pvs->draw) ?
-      u_bitcast_f2u(out->data[viewport_index_output][0]): 0;
+   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]);
+      viewport_index = draw_clamp_viewport_idx(viewport_index);
+   }
 
    cd[0] = draw_current_shader_ccdistance_output(pvs->draw, 0);
    cd[1] = draw_current_shader_ccdistance_output(pvs->draw, 1);
@@ -68,19 +73,16 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
    for (j = 0; j < info->count; j++) {
       float *position = out->data[pos];
       unsigned mask = 0x0;
-      float *scale = pvs->draw->viewports[0].scale;
-      float *trans = pvs->draw->viewports[0].translate;
-      if (draw_current_shader_uses_viewport_index(pvs->draw)) {
-         unsigned verts_per_prim = u_vertices_per_prim(prim_info->prim);
+
+      if (uses_vp_idx) {
          /* only change the viewport_index for the leading vertex */
          if (!(j % verts_per_prim)) {
             viewport_index = u_bitcast_f2u(out->data[viewport_index_output][0]);
             viewport_index = draw_clamp_viewport_idx(viewport_index);
          }
-         scale = pvs->draw->viewports[viewport_index].scale;
-         trans = pvs->draw->viewports[viewport_index].translate;
       }
-  
+      float *scale = pvs->draw->viewports[viewport_index].scale;
+      float *trans = pvs->draw->viewports[viewport_index].translate;
       initialize_vertex_header(out);
 
       if (flags & (DO_CLIP_XY | DO_CLIP_XY_GUARD_BAND |



More information about the mesa-commit mailing list