2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Rob Clark <robclark@freedesktop.org>
29 #include "pipe/p_state.h"
30 #include "util/u_string.h"
31 #include "util/u_memory.h"
33 #include "fd6_rasterizer.h"
34 #include "fd6_context.h"
35 #include "fd6_format.h"
38 struct fd_ringbuffer
*
39 __fd6_setup_rasterizer_stateobj(struct fd_context
*ctx
,
40 const struct pipe_rasterizer_state
*cso
, bool primitive_restart
)
42 struct fd_ringbuffer
*ring
= fd_ringbuffer_new_object(ctx
->pipe
, 14 * 4);
43 float psize_min
, psize_max
;
45 if (cso
->point_size_per_vertex
) {
46 psize_min
= util_get_min_point_size(cso
);
49 /* Force the point size to be as if the vertex output was disabled. */
50 psize_min
= cso
->point_size
;
51 psize_max
= cso
->point_size
;
55 A6XX_GRAS_DISABLE_CNTL(.vp_clip_code_ignore
= 1),
56 A6XX_GRAS_UNKNOWN_8001());
60 .linehalfwidth
= cso
->line_width
/ 2.0,
61 .poly_offset
= cso
->offset_tri
,
62 .msaa_enable
= cso
->multisample
,
63 .cull_front
= cso
->cull_face
& PIPE_FACE_FRONT
,
64 .cull_back
= cso
->cull_face
& PIPE_FACE_BACK
,
65 .front_cw
= !cso
->front_ccw
,
69 A6XX_GRAS_SU_POINT_MINMAX(
73 A6XX_GRAS_SU_POINT_SIZE(
78 A6XX_GRAS_SU_POLY_OFFSET_SCALE(
81 A6XX_GRAS_SU_POLY_OFFSET_OFFSET(
84 A6XX_GRAS_SU_POLY_OFFSET_OFFSET_CLAMP(
89 A6XX_PC_PRIMITIVE_CNTL_0(
90 .provoking_vtx_last
= !cso
->flatshade_first
,
91 .primitive_restart
= primitive_restart
,
98 fd6_rasterizer_state_create(struct pipe_context
*pctx
,
99 const struct pipe_rasterizer_state
*cso
)
101 struct fd6_rasterizer_stateobj
*so
;
103 so
= CALLOC_STRUCT(fd6_rasterizer_stateobj
);
113 fd6_rasterizer_state_delete(struct pipe_context
*pctx
, void *hwcso
)
115 struct fd6_rasterizer_stateobj
*so
= hwcso
;
117 for (unsigned i
= 0; i
< ARRAY_SIZE(so
->stateobjs
); i
++)
118 if (so
->stateobjs
[i
])
119 fd_ringbuffer_del(so
->stateobjs
[i
]);