~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/draw/draw_pipe_clip.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
   struct draw_stage stage;      /**< base class */
55
55
 
56
56
   unsigned pos_attr;
57
 
   boolean have_clipdist;
 
57
   bool have_clipdist;
58
58
   int cv_attr;
59
59
 
60
60
   /* List of the attributes to be constant interpolated. */
61
 
   uint num_const_attribs;
 
61
   unsigned num_const_attribs;
62
62
   uint8_t const_attribs[PIPE_MAX_SHADER_OUTPUTS];
63
63
   /* List of the attributes to be linear interpolated. */
64
 
   uint num_linear_attribs;
 
64
   unsigned num_linear_attribs;
65
65
   uint8_t linear_attribs[PIPE_MAX_SHADER_OUTPUTS];
66
66
   /* List of the attributes to be perspective interpolated. */
67
 
   uint num_perspect_attribs;
 
67
   unsigned num_perspect_attribs;
68
68
   uint8_t perspect_attribs[PIPE_MAX_SHADER_OUTPUTS];
69
69
 
70
70
   float (*plane)[4];
123
123
{
124
124
   const struct clip_stage *clipper = clip_stage(stage);
125
125
   for (unsigned i = 0; i < clipper->num_const_attribs; i++) {
126
 
      const uint attr = clipper->const_attribs[i];
 
126
      const unsigned attr = clipper->const_attribs[i];
127
127
      COPY_4FV(dst->data[attr], src->data[attr]);
128
128
   }
129
129
}
217
217
static void
218
218
emit_poly(struct draw_stage *stage,
219
219
          struct vertex_header **inlist,
220
 
          const boolean *edgeflags,
 
220
          const bool *edgeflags,
221
221
          unsigned n,
222
222
          const struct prim_header *origPrim)
223
223
{
224
224
   const struct clip_stage *clipper = clip_stage(stage);
225
 
   ushort edge_first, edge_middle, edge_last;
 
225
   uint16_t edge_first, edge_middle, edge_last;
226
226
 
227
227
   if (stage->draw->rasterizer->flatshade_first) {
228
228
      edge_first  = DRAW_PIPE_EDGE_FLAG_0;
353
353
   struct vertex_header *prov_vertex;
354
354
   unsigned tmpnr = 0;
355
355
   unsigned n = 3;
356
 
   boolean aEdges[MAX_CLIPPED_VERTICES];
357
 
   boolean bEdges[MAX_CLIPPED_VERTICES];
358
 
   boolean *inEdges = aEdges;
359
 
   boolean *outEdges = bEdges;
 
356
   bool aEdges[MAX_CLIPPED_VERTICES];
 
357
   bool bEdges[MAX_CLIPPED_VERTICES];
 
358
   bool *inEdges = aEdges;
 
359
   bool *outEdges = bEdges;
360
360
   int viewport_index = 0;
361
361
 
362
362
   inlist[0] = header->v[0];
410
410
 
411
411
   while (clipmask && n >= 3) {
412
412
      const unsigned plane_idx = ffs(clipmask)-1;
413
 
      const boolean is_user_clip_plane = plane_idx >= 6;
 
413
      const bool is_user_clip_plane = plane_idx >= 6;
414
414
      struct vertex_header *vert_prev = inlist[0];
415
 
      boolean *edge_prev = &inEdges[0];
 
415
      bool *edge_prev = &inEdges[0];
416
416
      float dp_prev;
417
417
      unsigned outcount = 0;
418
418
 
430
430
 
431
431
      for (unsigned i = 1; i <= n; i++) {
432
432
         struct vertex_header *vert = inlist[i];
433
 
         boolean *edge = &inEdges[i];
434
 
         boolean different_sign;
 
433
         bool *edge = &inEdges[i];
 
434
         bool different_sign;
435
435
 
436
436
         float dp = getclipdist(clipper, vert, plane_idx);
437
437
 
451
451
 
452
452
         if (different_sign) {
453
453
            struct vertex_header *new_vert;
454
 
            boolean *new_edge;
 
454
            bool *new_edge;
455
455
 
456
456
            assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
457
457
            if (tmpnr >= MAX_CLIPPED_VERTICES + 1)
484
484
                */
485
485
               if (is_user_clip_plane) {
486
486
                  /* we want to see an edge along the clip plane */
487
 
                  *new_edge = TRUE;
488
 
                  new_vert->edgeflag = TRUE;
 
487
                  *new_edge = true;
 
488
                  new_vert->edgeflag = true;
489
489
               }
490
490
               else {
491
491
                  /* we don't want to see an edge along the frustum clip plane */
492
492
                  *new_edge = *edge_prev;
493
 
                  new_vert->edgeflag = FALSE;
 
493
                  new_vert->edgeflag = false;
494
494
               }
495
495
            }
496
496
            else {
524
524
         n = outcount;
525
525
      }
526
526
      {
527
 
         boolean *tmp = inEdges;
 
527
         bool *tmp = inEdges;
528
528
         inEdges = outEdges;
529
529
         outEdges = tmp;
530
530
      }
688
688
static void
689
689
clip_first_point(struct draw_stage *stage, struct prim_header *header)
690
690
{
691
 
   stage->point = stage->draw->guard_band_points_xy ? clip_point_guard_xy : clip_point;
 
691
   stage->point = stage->draw->guard_band_points_lines_xy ? clip_point_guard_xy : clip_point;
692
692
   stage->point(stage, header);
693
693
}
694
694
 
710
710
   /* else, totally clipped */
711
711
}
712
712
 
 
713
static void
 
714
clip_line_guard_xy(struct draw_stage *stage, struct prim_header *header)
 
715
{
 
716
   unsigned clipmask = (header->v[0]->clipmask |
 
717
                        header->v[1]->clipmask);
 
718
 
 
719
   if ((clipmask & 0xffffffff) == 0) {
 
720
      stage->next->line(stage->next, header);
 
721
   }
 
722
   else if ((clipmask & 0xfffffff0) == 0) {
 
723
      while (clipmask) {
 
724
         const unsigned plane_idx = ffs(clipmask)-1;
 
725
         clipmask &= ~(1 << plane_idx);  /* turn off this plane's bit */
 
726
         /* TODO: this should really do proper guardband clipping,
 
727
          * currently just throw out infs/nans.
 
728
          * Also note that vertices with negative w values MUST be tossed
 
729
          * out (not sure if proper guardband clipping would do this
 
730
          * automatically). These would usually be captured by depth clip
 
731
          * too but this can be disabled.
 
732
          */
 
733
         if ((header->v[0]->clip_pos[3] <= 0.0f &&
 
734
              header->v[1]->clip_pos[3] <= 0.0f) ||
 
735
             util_is_nan(header->v[0]->clip_pos[0]) ||
 
736
             util_is_nan(header->v[0]->clip_pos[1]) ||
 
737
             util_is_nan(header->v[1]->clip_pos[0]) ||
 
738
             util_is_nan(header->v[1]->clip_pos[1]))
 
739
            return;
 
740
      }
 
741
      stage->next->line(stage->next, header);
 
742
   } else if ((header->v[0]->clipmask &
 
743
               header->v[1]->clipmask) == 0) {
 
744
      do_clip_line(stage, header, clipmask & 0xfffffff0);
 
745
   }
 
746
}
713
747
 
714
748
static void
715
749
clip_tri(struct draw_stage *stage, struct prim_header *header)
733
767
static enum tgsi_interpolate_mode
734
768
find_interp(const struct draw_fragment_shader *fs,
735
769
            enum tgsi_interpolate_mode *indexed_interp,
736
 
            uint semantic_name, uint semantic_index)
 
770
            enum tgsi_semantic semantic_name, unsigned semantic_index)
737
771
{
738
772
   enum tgsi_interpolate_mode interp;
739
773
 
753
787
       * This probably only matters for layer, vpindex, culldist, maybe
754
788
       * front_face.
755
789
       */
756
 
      uint j;
 
790
      unsigned j;
757
791
      if (semantic_name == TGSI_SEMANTIC_LAYER ||
758
792
          semantic_name == TGSI_SEMANTIC_VIEWPORT_INDEX) {
759
793
         interp = TGSI_INTERPOLATE_CONSTANT;
894
928
   }
895
929
 
896
930
   stage->tri = clip_tri;
897
 
   stage->line = clip_line;
898
931
}
899
932
 
900
933
 
912
945
                struct prim_header *header)
913
946
{
914
947
   clip_init_state(stage);
 
948
   stage->line = stage->draw->guard_band_points_lines_xy ? clip_line_guard_xy : clip_line;
915
949
   stage->line(stage, header);
916
950
}
917
951