~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/freedreno/a2xx/fd2_rasterizer.c

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2012-2013 Rob Clark <robclark@freedesktop.org>
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the "Software"),
6
 
 * to deal in the Software without restriction, including without limitation
7
 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 
 * and/or sell copies of the Software, and to permit persons to whom the
9
 
 * Software is furnished to do so, subject to the following conditions:
10
 
 *
11
 
 * The above copyright notice and this permission notice (including the next
12
 
 * paragraph) shall be included in all copies or substantial portions of the
13
 
 * Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 
 * SOFTWARE.
22
 
 *
23
 
 * Authors:
24
 
 *    Rob Clark <robclark@freedesktop.org>
25
 
 */
26
 
 
27
 
#include "pipe/p_state.h"
28
 
#include "util/u_memory.h"
29
 
#include "util/u_string.h"
30
 
 
31
 
#include "fd2_context.h"
32
 
#include "fd2_rasterizer.h"
33
 
#include "fd2_util.h"
34
 
 
35
 
void *
36
 
fd2_rasterizer_state_create(struct pipe_context *pctx,
37
 
                            const struct pipe_rasterizer_state *cso)
38
 
{
39
 
   struct fd2_rasterizer_stateobj *so;
40
 
   float psize_min, psize_max;
41
 
 
42
 
   so = CALLOC_STRUCT(fd2_rasterizer_stateobj);
43
 
   if (!so)
44
 
      return NULL;
45
 
 
46
 
   if (cso->point_size_per_vertex) {
47
 
      psize_min = util_get_min_point_size(cso);
48
 
      psize_max = 8192.0f - 0.0625f;
49
 
   } else {
50
 
      /* Force the point size to be as if the vertex output was disabled. */
51
 
      psize_min = cso->point_size;
52
 
      psize_max = cso->point_size;
53
 
   }
54
 
 
55
 
   so->base = *cso;
56
 
 
57
 
   so->pa_sc_line_stipple =
58
 
      cso->line_stipple_enable
59
 
         ? A2XX_PA_SC_LINE_STIPPLE_LINE_PATTERN(cso->line_stipple_pattern) |
60
 
              A2XX_PA_SC_LINE_STIPPLE_REPEAT_COUNT(cso->line_stipple_factor)
61
 
         : 0;
62
 
 
63
 
   so->pa_cl_clip_cntl = 0; // TODO
64
 
 
65
 
   so->pa_su_vtx_cntl =
66
 
      A2XX_PA_SU_VTX_CNTL_PIX_CENTER(cso->half_pixel_center ? PIXCENTER_OGL
67
 
                                                            : PIXCENTER_D3D) |
68
 
      A2XX_PA_SU_VTX_CNTL_QUANT_MODE(ONE_SIXTEENTH);
69
 
 
70
 
   so->pa_su_point_size = A2XX_PA_SU_POINT_SIZE_HEIGHT(cso->point_size / 2) |
71
 
                          A2XX_PA_SU_POINT_SIZE_WIDTH(cso->point_size / 2);
72
 
 
73
 
   so->pa_su_point_minmax = A2XX_PA_SU_POINT_MINMAX_MIN(psize_min / 2) |
74
 
                            A2XX_PA_SU_POINT_MINMAX_MAX(psize_max / 2);
75
 
 
76
 
   so->pa_su_line_cntl = A2XX_PA_SU_LINE_CNTL_WIDTH(cso->line_width / 2);
77
 
 
78
 
   so->pa_su_sc_mode_cntl =
79
 
      A2XX_PA_SU_SC_MODE_CNTL_VTX_WINDOW_OFFSET_ENABLE |
80
 
      A2XX_PA_SU_SC_MODE_CNTL_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) |
81
 
      A2XX_PA_SU_SC_MODE_CNTL_BACK_PTYPE(fd_polygon_mode(cso->fill_back));
82
 
 
83
 
   if (cso->cull_face & PIPE_FACE_FRONT)
84
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_FRONT;
85
 
   if (cso->cull_face & PIPE_FACE_BACK)
86
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_BACK;
87
 
   if (!cso->flatshade_first)
88
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_PROVOKING_VTX_LAST;
89
 
   if (!cso->front_ccw)
90
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_FACE;
91
 
   if (cso->line_stipple_enable)
92
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_LINE_STIPPLE_ENABLE;
93
 
   if (cso->multisample)
94
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_MSAA_ENABLE;
95
 
 
96
 
   if (cso->fill_front != PIPE_POLYGON_MODE_FILL ||
97
 
       cso->fill_back != PIPE_POLYGON_MODE_FILL)
98
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DUALMODE);
99
 
   else
100
 
      so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DISABLED);
101
 
 
102
 
   if (cso->offset_tri)
103
 
      so->pa_su_sc_mode_cntl |=
104
 
         A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_FRONT_ENABLE |
105
 
         A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_BACK_ENABLE |
106
 
         A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_PARA_ENABLE;
107
 
 
108
 
   return so;
109
 
}