2 * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
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:
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
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
24 * Rob Clark <robclark@freedesktop.org>
28 #include "pipe/p_state.h"
29 #include "util/u_string.h"
30 #include "util/u_memory.h"
32 #include "fd3_rasterizer.h"
33 #include "fd3_context.h"
34 #include "fd3_format.h"
37 fd3_rasterizer_state_create(struct pipe_context
*pctx
,
38 const struct pipe_rasterizer_state
*cso
)
40 struct fd3_rasterizer_stateobj
*so
;
41 float psize_min
, psize_max
;
43 so
= CALLOC_STRUCT(fd3_rasterizer_stateobj
);
49 if (cso
->point_size_per_vertex
) {
50 psize_min
= util_get_min_point_size(cso
);
53 /* Force the point size to be as if the vertex output was disabled. */
54 psize_min
= cso
->point_size
;
55 psize_max
= cso
->point_size
;
59 if (cso->line_stipple_enable) {
62 TODO cso->half_pixel_center
66 so
->gras_cl_clip_cntl
=
67 COND(cso
->clip_halfz
, A3XX_GRAS_CL_CLIP_CNTL_ZERO_GB_SCALE_Z
);
68 so
->gras_su_point_minmax
=
69 A3XX_GRAS_SU_POINT_MINMAX_MIN(psize_min
) |
70 A3XX_GRAS_SU_POINT_MINMAX_MAX(psize_max
);
71 so
->gras_su_point_size
= A3XX_GRAS_SU_POINT_SIZE(cso
->point_size
);
72 so
->gras_su_poly_offset_scale
=
73 A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL(cso
->offset_scale
);
74 so
->gras_su_poly_offset_offset
=
75 A3XX_GRAS_SU_POLY_OFFSET_OFFSET(cso
->offset_units
* 2.0f
);
77 so
->gras_su_mode_control
=
78 A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(cso
->line_width
/2.0);
80 so
->pc_prim_vtx_cntl
=
81 A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE(fd_polygon_mode(cso
->fill_front
)) |
82 A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(fd_polygon_mode(cso
->fill_back
));
84 if (cso
->fill_front
!= PIPE_POLYGON_MODE_FILL
||
85 cso
->fill_back
!= PIPE_POLYGON_MODE_FILL
)
86 so
->pc_prim_vtx_cntl
|= A3XX_PC_PRIM_VTX_CNTL_POLYMODE_ENABLE
;
88 if (cso
->cull_face
& PIPE_FACE_FRONT
)
89 so
->gras_su_mode_control
|= A3XX_GRAS_SU_MODE_CONTROL_CULL_FRONT
;
90 if (cso
->cull_face
& PIPE_FACE_BACK
)
91 so
->gras_su_mode_control
|= A3XX_GRAS_SU_MODE_CONTROL_CULL_BACK
;
93 so
->gras_su_mode_control
|= A3XX_GRAS_SU_MODE_CONTROL_FRONT_CW
;
94 if (!cso
->flatshade_first
)
95 so
->pc_prim_vtx_cntl
|= A3XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST
;
98 so
->gras_su_mode_control
|= A3XX_GRAS_SU_MODE_CONTROL_POLY_OFFSET
;
99 if (!cso
->depth_clip_near
)
100 so
->gras_cl_clip_cntl
|= A3XX_GRAS_CL_CLIP_CNTL_CLIP_DISABLE
;