Debian Codegraph @

src/gallium/drivers/freedreno/a2xx/fd2_rasterizer.c

raw
1 /*
2 * Copyright © 2012-2013 Rob Clark <[email protected]>
3 * SPDX-License-Identifier: MIT
4 *
5 * Authors:
6 * Rob Clark <[email protected]>
7 */
8
9 #include "pipe/p_state.h"
10 #include "util/u_memory.h"
11 #include "util/u_string.h"
12
13 #include "fd2_context.h"
14 #include "fd2_rasterizer.h"
15 #include "fd2_util.h"
16
17 void *
18 fd2_rasterizer_state_create(struct pipe_context *pctx,
19 const struct pipe_rasterizer_state *cso)
20 {
21 struct fd2_rasterizer_stateobj *so;
22 float psize_min, psize_max;
23
24 so = CALLOC_STRUCT(fd2_rasterizer_stateobj);
25 if (!so)
26 return NULL;
27
28 if (cso->point_size_per_vertex) {
29 psize_min = util_get_min_point_size(cso);
30 psize_max = 8192.0f - 0.0625f;
31 } else {
32 /* Force the point size to be as if the vertex output was disabled. */
33 psize_min = cso->point_size;
34 psize_max = cso->point_size;
35 }
36
37 so->base = *cso;
38
39 so->pa_sc_line_stipple =
40 cso->line_stipple_enable
41 ? A2XX_PA_SC_LINE_STIPPLE_LINE_PATTERN(cso->line_stipple_pattern) |
42 A2XX_PA_SC_LINE_STIPPLE_REPEAT_COUNT(cso->line_stipple_factor)
43 : 0;
44
45 so->pa_cl_clip_cntl = 0; // TODO
46
47 so->pa_su_vtx_cntl =
48 A2XX_PA_SU_VTX_CNTL_PIX_CENTER(cso->half_pixel_center ? PIXCENTER_OGL
49 : PIXCENTER_D3D) |
50 A2XX_PA_SU_VTX_CNTL_QUANT_MODE(ONE_SIXTEENTH);
51
52 so->pa_su_point_size = A2XX_PA_SU_POINT_SIZE_HEIGHT(cso->point_size / 2) |
53 A2XX_PA_SU_POINT_SIZE_WIDTH(cso->point_size / 2);
54
55 so->pa_su_point_minmax = A2XX_PA_SU_POINT_MINMAX_MIN(psize_min / 2) |
56 A2XX_PA_SU_POINT_MINMAX_MAX(psize_max / 2);
57
58 so->pa_su_line_cntl = A2XX_PA_SU_LINE_CNTL_WIDTH(cso->line_width / 2);
59
60 so->pa_su_sc_mode_cntl =
61 A2XX_PA_SU_SC_MODE_CNTL_VTX_WINDOW_OFFSET_ENABLE |
62 A2XX_PA_SU_SC_MODE_CNTL_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) |
63 A2XX_PA_SU_SC_MODE_CNTL_BACK_PTYPE(fd_polygon_mode(cso->fill_back));
64
65 if (cso->cull_face & PIPE_FACE_FRONT)
66 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_FRONT;
67 if (cso->cull_face & PIPE_FACE_BACK)
68 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_BACK;
69 if (!cso->flatshade_first)
70 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_PROVOKING_VTX_LAST;
71 if (!cso->front_ccw)
72 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_FACE;
73 if (cso->line_stipple_enable)
74 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_LINE_STIPPLE_ENABLE;
75 if (cso->multisample)
76 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_MSAA_ENABLE;
77
78 if (cso->fill_front != PIPE_POLYGON_MODE_FILL ||
79 cso->fill_back != PIPE_POLYGON_MODE_FILL)
80 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DUALMODE);
81 else
82 so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DISABLED);
83
84 if (cso->offset_tri)
85 so->pa_su_sc_mode_cntl |=
86 A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_FRONT_ENABLE |
87 A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_BACK_ENABLE |
88 A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_PARA_ENABLE;
89
90 return so;
91 }