2 * Copyright (C) 2014 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>
27 #include "pipe/p_state.h"
28 #include "util/u_string.h"
29 #include "util/u_memory.h"
30 #include "util/u_helpers.h"
31 #include "util/format/u_format.h"
32 #include "util/u_viewport.h"
34 #include "freedreno_resource.h"
35 #include "freedreno_query_hw.h"
38 #include "fd4_blend.h"
39 #include "fd4_context.h"
40 #include "fd4_program.h"
41 #include "fd4_rasterizer.h"
42 #include "fd4_texture.h"
43 #include "fd4_format.h"
46 #define emit_const_user fd4_emit_const_user
47 #define emit_const_bo fd4_emit_const_bo
48 #include "ir3_const.h"
50 /* regid: base const register
51 * prsc or dwords: buffer containing constant values
52 * sizedwords: size of const value buffer
55 fd4_emit_const_user(struct fd_ringbuffer
*ring
,
56 const struct ir3_shader_variant
*v
, uint32_t regid
, uint32_t sizedwords
,
57 const uint32_t *dwords
)
59 emit_const_asserts(ring
, v
, regid
, sizedwords
);
61 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + sizedwords
);
62 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
63 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
64 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(v
->type
)) |
65 CP_LOAD_STATE4_0_NUM_UNIT(sizedwords
/4));
66 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
67 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
68 for (int i
= 0; i
< sizedwords
; i
++)
69 OUT_RING(ring
, dwords
[i
]);
73 fd4_emit_const_bo(struct fd_ringbuffer
*ring
, const struct ir3_shader_variant
*v
,
74 uint32_t regid
, uint32_t offset
, uint32_t sizedwords
,
77 emit_const_asserts(ring
, v
, regid
, sizedwords
);
79 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2);
80 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
81 CP_LOAD_STATE4_0_STATE_SRC(SS4_INDIRECT
) |
82 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(v
->type
)) |
83 CP_LOAD_STATE4_0_NUM_UNIT(sizedwords
/4));
84 OUT_RELOC(ring
, bo
, offset
,
85 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
), 0);
89 fd4_emit_const_ptrs(struct fd_ringbuffer
*ring
, gl_shader_stage type
,
90 uint32_t regid
, uint32_t num
, struct pipe_resource
**prscs
, uint32_t *offsets
)
92 uint32_t anum
= align(num
, 4);
95 debug_assert((regid
% 4) == 0);
97 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + anum
);
98 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
99 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
100 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type
)) |
101 CP_LOAD_STATE4_0_NUM_UNIT(anum
/4));
102 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
103 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
105 for (i
= 0; i
< num
; i
++) {
107 OUT_RELOC(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
109 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
113 for (; i
< anum
; i
++)
114 OUT_RING(ring
, 0xffffffff);
118 is_stateobj(struct fd_ringbuffer
*ring
)
124 emit_const_ptrs(struct fd_ringbuffer
*ring
,
125 const struct ir3_shader_variant
*v
, uint32_t dst_offset
,
126 uint32_t num
, struct pipe_resource
**prscs
, uint32_t *offsets
)
128 /* TODO inline this */
129 assert(dst_offset
+ num
<= v
->constlen
* 4);
130 fd4_emit_const_ptrs(ring
, v
->type
, dst_offset
, num
, prscs
, offsets
);
134 emit_textures(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
135 enum a4xx_state_block sb
, struct fd_texture_stateobj
*tex
,
136 const struct ir3_shader_variant
*v
)
138 static const uint32_t bcolor_reg
[] = {
139 [SB4_VS_TEX
] = REG_A4XX_TPL1_TP_VS_BORDER_COLOR_BASE_ADDR
,
140 [SB4_FS_TEX
] = REG_A4XX_TPL1_TP_FS_BORDER_COLOR_BASE_ADDR
,
142 struct fd4_context
*fd4_ctx
= fd4_context(ctx
);
143 bool needs_border
= false;
146 if (tex
->num_samplers
> 0) {
149 /* not sure if this is an a420.0 workaround, but we seem
150 * to need to emit these in pairs.. emit a final dummy
151 * entry if odd # of samplers:
153 num_samplers
= align(tex
->num_samplers
, 2);
155 /* output sampler state: */
156 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + (2 * num_samplers
));
157 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
158 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
159 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
160 CP_LOAD_STATE4_0_NUM_UNIT(num_samplers
));
161 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_SHADER
) |
162 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
163 for (i
= 0; i
< tex
->num_samplers
; i
++) {
164 static const struct fd4_sampler_stateobj dummy_sampler
= {};
165 const struct fd4_sampler_stateobj
*sampler
= tex
->samplers
[i
] ?
166 fd4_sampler_stateobj(tex
->samplers
[i
]) :
168 OUT_RING(ring
, sampler
->texsamp0
);
169 OUT_RING(ring
, sampler
->texsamp1
);
171 needs_border
|= sampler
->needs_border
;
174 for (; i
< num_samplers
; i
++) {
175 OUT_RING(ring
, 0x00000000);
176 OUT_RING(ring
, 0x00000000);
180 if (tex
->num_textures
> 0) {
181 unsigned num_textures
= tex
->num_textures
+ v
->astc_srgb
.count
;
183 /* emit texture state: */
184 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + (8 * num_textures
));
185 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
186 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
187 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
188 CP_LOAD_STATE4_0_NUM_UNIT(num_textures
));
189 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
) |
190 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
191 for (i
= 0; i
< tex
->num_textures
; i
++) {
192 static const struct fd4_pipe_sampler_view dummy_view
= {};
193 const struct fd4_pipe_sampler_view
*view
= tex
->textures
[i
] ?
194 fd4_pipe_sampler_view(tex
->textures
[i
]) :
197 OUT_RING(ring
, view
->texconst0
);
198 OUT_RING(ring
, view
->texconst1
);
199 OUT_RING(ring
, view
->texconst2
);
200 OUT_RING(ring
, view
->texconst3
);
201 if (view
->base
.texture
) {
202 struct fd_resource
*rsc
= fd_resource(view
->base
.texture
);
203 if (view
->base
.format
== PIPE_FORMAT_X32_S8X24_UINT
)
205 OUT_RELOC(ring
, rsc
->bo
, view
->offset
, view
->texconst4
, 0);
207 OUT_RING(ring
, 0x00000000);
209 OUT_RING(ring
, 0x00000000);
210 OUT_RING(ring
, 0x00000000);
211 OUT_RING(ring
, 0x00000000);
214 for (i
= 0; i
< v
->astc_srgb
.count
; i
++) {
215 static const struct fd4_pipe_sampler_view dummy_view
= {};
216 const struct fd4_pipe_sampler_view
*view
;
217 unsigned idx
= v
->astc_srgb
.orig_idx
[i
];
219 view
= tex
->textures
[idx
] ?
220 fd4_pipe_sampler_view(tex
->textures
[idx
]) :
223 debug_assert(view
->texconst0
& A4XX_TEX_CONST_0_SRGB
);
225 OUT_RING(ring
, view
->texconst0
& ~A4XX_TEX_CONST_0_SRGB
);
226 OUT_RING(ring
, view
->texconst1
);
227 OUT_RING(ring
, view
->texconst2
);
228 OUT_RING(ring
, view
->texconst3
);
229 if (view
->base
.texture
) {
230 struct fd_resource
*rsc
= fd_resource(view
->base
.texture
);
231 OUT_RELOC(ring
, rsc
->bo
, view
->offset
, view
->texconst4
, 0);
233 OUT_RING(ring
, 0x00000000);
235 OUT_RING(ring
, 0x00000000);
236 OUT_RING(ring
, 0x00000000);
237 OUT_RING(ring
, 0x00000000);
240 debug_assert(v
->astc_srgb
.count
== 0);
247 u_upload_alloc(fd4_ctx
->border_color_uploader
,
248 0, BORDER_COLOR_UPLOAD_SIZE
,
249 BORDER_COLOR_UPLOAD_SIZE
, &off
,
250 &fd4_ctx
->border_color_buf
,
253 fd_setup_border_colors(tex
, ptr
, 0);
254 OUT_PKT0(ring
, bcolor_reg
[sb
], 1);
255 OUT_RELOC(ring
, fd_resource(fd4_ctx
->border_color_buf
)->bo
, off
, 0, 0);
257 u_upload_unmap(fd4_ctx
->border_color_uploader
);
261 /* emit texture state for mem->gmem restore operation.. eventually it would
262 * be good to get rid of this and use normal CSO/etc state for more of these
266 fd4_emit_gmem_restore_tex(struct fd_ringbuffer
*ring
, unsigned nr_bufs
,
267 struct pipe_surface
**bufs
)
269 unsigned char mrt_comp
[A4XX_MAX_RENDER_TARGETS
];
272 for (i
= 0; i
< A4XX_MAX_RENDER_TARGETS
; i
++) {
273 mrt_comp
[i
] = (i
< nr_bufs
) ? 0xf : 0;
276 /* output sampler state: */
277 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + (2 * nr_bufs
));
278 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
279 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
280 CP_LOAD_STATE4_0_STATE_BLOCK(SB4_FS_TEX
) |
281 CP_LOAD_STATE4_0_NUM_UNIT(nr_bufs
));
282 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_SHADER
) |
283 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
284 for (i
= 0; i
< nr_bufs
; i
++) {
285 OUT_RING(ring
, A4XX_TEX_SAMP_0_XY_MAG(A4XX_TEX_NEAREST
) |
286 A4XX_TEX_SAMP_0_XY_MIN(A4XX_TEX_NEAREST
) |
287 A4XX_TEX_SAMP_0_WRAP_S(A4XX_TEX_CLAMP_TO_EDGE
) |
288 A4XX_TEX_SAMP_0_WRAP_T(A4XX_TEX_CLAMP_TO_EDGE
) |
289 A4XX_TEX_SAMP_0_WRAP_R(A4XX_TEX_REPEAT
));
290 OUT_RING(ring
, 0x00000000);
293 /* emit texture state: */
294 OUT_PKT3(ring
, CP_LOAD_STATE4
, 2 + (8 * nr_bufs
));
295 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
296 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
297 CP_LOAD_STATE4_0_STATE_BLOCK(SB4_FS_TEX
) |
298 CP_LOAD_STATE4_0_NUM_UNIT(nr_bufs
));
299 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
) |
300 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
301 for (i
= 0; i
< nr_bufs
; i
++) {
303 struct fd_resource
*rsc
= fd_resource(bufs
[i
]->texture
);
304 enum pipe_format format
= fd_gmem_restore_format(bufs
[i
]->format
);
306 /* The restore blit_zs shader expects stencil in sampler 0,
307 * and depth in sampler 1
309 if (rsc
->stencil
&& (i
== 0)) {
311 format
= fd_gmem_restore_format(rsc
->base
.format
);
314 /* note: PIPE_BUFFER disallowed for surfaces */
315 unsigned lvl
= bufs
[i
]->u
.tex
.level
;
316 unsigned offset
= fd_resource_offset(rsc
, lvl
, bufs
[i
]->u
.tex
.first_layer
);
318 /* z32 restore is accomplished using depth write. If there is
319 * no stencil component (ie. PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
320 * then no render target:
322 * (The same applies for z32_s8x24, since for stencil sampler
323 * state the above 'if' will replace 'format' with s8)
325 if ((format
== PIPE_FORMAT_Z32_FLOAT
) ||
326 (format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
))
329 debug_assert(bufs
[i
]->u
.tex
.first_layer
== bufs
[i
]->u
.tex
.last_layer
);
331 OUT_RING(ring
, A4XX_TEX_CONST_0_FMT(fd4_pipe2tex(format
)) |
332 A4XX_TEX_CONST_0_TYPE(A4XX_TEX_2D
) |
333 fd4_tex_swiz(format
, PIPE_SWIZZLE_X
, PIPE_SWIZZLE_Y
,
334 PIPE_SWIZZLE_Z
, PIPE_SWIZZLE_W
));
335 OUT_RING(ring
, A4XX_TEX_CONST_1_WIDTH(bufs
[i
]->width
) |
336 A4XX_TEX_CONST_1_HEIGHT(bufs
[i
]->height
));
337 OUT_RING(ring
, A4XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc
, lvl
)));
338 OUT_RING(ring
, 0x00000000);
339 OUT_RELOC(ring
, rsc
->bo
, offset
, 0, 0);
340 OUT_RING(ring
, 0x00000000);
341 OUT_RING(ring
, 0x00000000);
342 OUT_RING(ring
, 0x00000000);
344 OUT_RING(ring
, A4XX_TEX_CONST_0_FMT(0) |
345 A4XX_TEX_CONST_0_TYPE(A4XX_TEX_2D
) |
346 A4XX_TEX_CONST_0_SWIZ_X(A4XX_TEX_ONE
) |
347 A4XX_TEX_CONST_0_SWIZ_Y(A4XX_TEX_ONE
) |
348 A4XX_TEX_CONST_0_SWIZ_Z(A4XX_TEX_ONE
) |
349 A4XX_TEX_CONST_0_SWIZ_W(A4XX_TEX_ONE
));
350 OUT_RING(ring
, A4XX_TEX_CONST_1_WIDTH(0) |
351 A4XX_TEX_CONST_1_HEIGHT(0));
352 OUT_RING(ring
, A4XX_TEX_CONST_2_PITCH(0));
353 OUT_RING(ring
, 0x00000000);
354 OUT_RING(ring
, 0x00000000);
355 OUT_RING(ring
, 0x00000000);
356 OUT_RING(ring
, 0x00000000);
357 OUT_RING(ring
, 0x00000000);
361 OUT_PKT0(ring
, REG_A4XX_RB_RENDER_COMPONENTS
, 1);
362 OUT_RING(ring
, A4XX_RB_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
363 A4XX_RB_RENDER_COMPONENTS_RT1(mrt_comp
[1]) |
364 A4XX_RB_RENDER_COMPONENTS_RT2(mrt_comp
[2]) |
365 A4XX_RB_RENDER_COMPONENTS_RT3(mrt_comp
[3]) |
366 A4XX_RB_RENDER_COMPONENTS_RT4(mrt_comp
[4]) |
367 A4XX_RB_RENDER_COMPONENTS_RT5(mrt_comp
[5]) |
368 A4XX_RB_RENDER_COMPONENTS_RT6(mrt_comp
[6]) |
369 A4XX_RB_RENDER_COMPONENTS_RT7(mrt_comp
[7]));
373 fd4_emit_vertex_bufs(struct fd_ringbuffer
*ring
, struct fd4_emit
*emit
)
375 int32_t i
, j
, last
= -1;
376 uint32_t total_in
= 0;
377 const struct fd_vertex_state
*vtx
= emit
->vtx
;
378 const struct ir3_shader_variant
*vp
= fd4_emit_get_vp(emit
);
379 unsigned vertex_regid
= regid(63, 0);
380 unsigned instance_regid
= regid(63, 0);
381 unsigned vtxcnt_regid
= regid(63, 0);
383 /* Note that sysvals come *after* normal inputs: */
384 for (i
= 0; i
< vp
->inputs_count
; i
++) {
385 if (!vp
->inputs
[i
].compmask
)
387 if (vp
->inputs
[i
].sysval
) {
388 switch(vp
->inputs
[i
].slot
) {
389 case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
:
390 vertex_regid
= vp
->inputs
[i
].regid
;
392 case SYSTEM_VALUE_INSTANCE_ID
:
393 instance_regid
= vp
->inputs
[i
].regid
;
395 case SYSTEM_VALUE_VERTEX_CNT
:
396 vtxcnt_regid
= vp
->inputs
[i
].regid
;
399 unreachable("invalid system value");
402 } else if (i
< vtx
->vtx
->num_elements
) {
407 for (i
= 0, j
= 0; i
<= last
; i
++) {
408 assert(!vp
->inputs
[i
].sysval
);
409 if (vp
->inputs
[i
].compmask
) {
410 struct pipe_vertex_element
*elem
= &vtx
->vtx
->pipe
[i
];
411 const struct pipe_vertex_buffer
*vb
=
412 &vtx
->vertexbuf
.vb
[elem
->vertex_buffer_index
];
413 struct fd_resource
*rsc
= fd_resource(vb
->buffer
.resource
);
414 enum pipe_format pfmt
= elem
->src_format
;
415 enum a4xx_vtx_fmt fmt
= fd4_pipe2vtx(pfmt
);
416 bool switchnext
= (i
!= last
) ||
417 (vertex_regid
!= regid(63, 0)) ||
418 (instance_regid
!= regid(63, 0)) ||
419 (vtxcnt_regid
!= regid(63, 0));
420 bool isint
= util_format_is_pure_integer(pfmt
);
421 uint32_t fs
= util_format_get_blocksize(pfmt
);
422 uint32_t off
= vb
->buffer_offset
+ elem
->src_offset
;
423 uint32_t size
= fd_bo_size(rsc
->bo
) - off
;
424 debug_assert(fmt
!= VFMT4_NONE
);
427 /* see dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.bind_vertex_buffer_offset_near_wrap_10
429 if (off
> fd_bo_size(rsc
->bo
))
433 OUT_PKT0(ring
, REG_A4XX_VFD_FETCH(j
), 4);
434 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_0_FETCHSIZE(fs
- 1) |
435 A4XX_VFD_FETCH_INSTR_0_BUFSTRIDE(vb
->stride
) |
436 COND(elem
->instance_divisor
, A4XX_VFD_FETCH_INSTR_0_INSTANCED
) |
437 COND(switchnext
, A4XX_VFD_FETCH_INSTR_0_SWITCHNEXT
));
438 OUT_RELOC(ring
, rsc
->bo
, off
, 0, 0);
439 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_2_SIZE(size
));
440 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_3_STEPRATE(MAX2(1, elem
->instance_divisor
)));
442 OUT_PKT0(ring
, REG_A4XX_VFD_DECODE_INSTR(j
), 1);
443 OUT_RING(ring
, A4XX_VFD_DECODE_INSTR_CONSTFILL
|
444 A4XX_VFD_DECODE_INSTR_WRITEMASK(vp
->inputs
[i
].compmask
) |
445 A4XX_VFD_DECODE_INSTR_FORMAT(fmt
) |
446 A4XX_VFD_DECODE_INSTR_SWAP(fd4_pipe2swap(pfmt
)) |
447 A4XX_VFD_DECODE_INSTR_REGID(vp
->inputs
[i
].regid
) |
448 A4XX_VFD_DECODE_INSTR_SHIFTCNT(fs
) |
449 A4XX_VFD_DECODE_INSTR_LASTCOMPVALID
|
450 COND(isint
, A4XX_VFD_DECODE_INSTR_INT
) |
451 COND(switchnext
, A4XX_VFD_DECODE_INSTR_SWITCHNEXT
));
453 total_in
+= util_bitcount(vp
->inputs
[i
].compmask
);
458 /* hw doesn't like to be configured for zero vbo's, it seems: */
460 /* just recycle the shader bo, we just need to point to *something*
463 struct fd_bo
*dummy_vbo
= vp
->bo
;
464 bool switchnext
= (vertex_regid
!= regid(63, 0)) ||
465 (instance_regid
!= regid(63, 0)) ||
466 (vtxcnt_regid
!= regid(63, 0));
468 OUT_PKT0(ring
, REG_A4XX_VFD_FETCH(0), 4);
469 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_0_FETCHSIZE(0) |
470 A4XX_VFD_FETCH_INSTR_0_BUFSTRIDE(0) |
471 COND(switchnext
, A4XX_VFD_FETCH_INSTR_0_SWITCHNEXT
));
472 OUT_RELOC(ring
, dummy_vbo
, 0, 0, 0);
473 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_2_SIZE(1));
474 OUT_RING(ring
, A4XX_VFD_FETCH_INSTR_3_STEPRATE(1));
476 OUT_PKT0(ring
, REG_A4XX_VFD_DECODE_INSTR(0), 1);
477 OUT_RING(ring
, A4XX_VFD_DECODE_INSTR_CONSTFILL
|
478 A4XX_VFD_DECODE_INSTR_WRITEMASK(0x1) |
479 A4XX_VFD_DECODE_INSTR_FORMAT(VFMT4_8_UNORM
) |
480 A4XX_VFD_DECODE_INSTR_SWAP(XYZW
) |
481 A4XX_VFD_DECODE_INSTR_REGID(regid(0,0)) |
482 A4XX_VFD_DECODE_INSTR_SHIFTCNT(1) |
483 A4XX_VFD_DECODE_INSTR_LASTCOMPVALID
|
484 COND(switchnext
, A4XX_VFD_DECODE_INSTR_SWITCHNEXT
));
490 OUT_PKT0(ring
, REG_A4XX_VFD_CONTROL_0
, 5);
491 OUT_RING(ring
, A4XX_VFD_CONTROL_0_TOTALATTRTOVS(total_in
) |
493 A4XX_VFD_CONTROL_0_STRMDECINSTRCNT(j
) |
494 A4XX_VFD_CONTROL_0_STRMFETCHINSTRCNT(j
));
495 OUT_RING(ring
, A4XX_VFD_CONTROL_1_MAXSTORAGE(129) | // XXX
496 A4XX_VFD_CONTROL_1_REGID4VTX(vertex_regid
) |
497 A4XX_VFD_CONTROL_1_REGID4INST(instance_regid
));
498 OUT_RING(ring
, 0x00000000); /* XXX VFD_CONTROL_2 */
499 OUT_RING(ring
, A4XX_VFD_CONTROL_3_REGID_VTXCNT(vtxcnt_regid
));
500 OUT_RING(ring
, 0x00000000); /* XXX VFD_CONTROL_4 */
502 /* cache invalidate, otherwise vertex fetch could see
503 * stale vbo contents:
505 OUT_PKT0(ring
, REG_A4XX_UCHE_INVALIDATE0
, 2);
506 OUT_RING(ring
, 0x00000000);
507 OUT_RING(ring
, 0x00000012);
511 fd4_emit_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
512 struct fd4_emit
*emit
)
514 const struct ir3_shader_variant
*vp
= fd4_emit_get_vp(emit
);
515 const struct ir3_shader_variant
*fp
= fd4_emit_get_fp(emit
);
516 const enum fd_dirty_3d_state dirty
= emit
->dirty
;
518 emit_marker(ring
, 5);
520 if ((dirty
& FD_DIRTY_FRAMEBUFFER
) && !emit
->binning_pass
) {
521 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
522 unsigned char mrt_comp
[A4XX_MAX_RENDER_TARGETS
] = {0};
524 for (unsigned i
= 0; i
< A4XX_MAX_RENDER_TARGETS
; i
++) {
525 mrt_comp
[i
] = ((i
< pfb
->nr_cbufs
) && pfb
->cbufs
[i
]) ? 0xf : 0;
528 OUT_PKT0(ring
, REG_A4XX_RB_RENDER_COMPONENTS
, 1);
529 OUT_RING(ring
, A4XX_RB_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
530 A4XX_RB_RENDER_COMPONENTS_RT1(mrt_comp
[1]) |
531 A4XX_RB_RENDER_COMPONENTS_RT2(mrt_comp
[2]) |
532 A4XX_RB_RENDER_COMPONENTS_RT3(mrt_comp
[3]) |
533 A4XX_RB_RENDER_COMPONENTS_RT4(mrt_comp
[4]) |
534 A4XX_RB_RENDER_COMPONENTS_RT5(mrt_comp
[5]) |
535 A4XX_RB_RENDER_COMPONENTS_RT6(mrt_comp
[6]) |
536 A4XX_RB_RENDER_COMPONENTS_RT7(mrt_comp
[7]));
539 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_FRAMEBUFFER
)) {
540 struct fd4_zsa_stateobj
*zsa
= fd4_zsa_stateobj(ctx
->zsa
);
541 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
542 uint32_t rb_alpha_control
= zsa
->rb_alpha_control
;
544 if (util_format_is_pure_integer(pipe_surface_format(pfb
->cbufs
[0])))
545 rb_alpha_control
&= ~A4XX_RB_ALPHA_CONTROL_ALPHA_TEST
;
547 OUT_PKT0(ring
, REG_A4XX_RB_ALPHA_CONTROL
, 1);
548 OUT_RING(ring
, rb_alpha_control
);
550 OUT_PKT0(ring
, REG_A4XX_RB_STENCIL_CONTROL
, 2);
551 OUT_RING(ring
, zsa
->rb_stencil_control
);
552 OUT_RING(ring
, zsa
->rb_stencil_control2
);
555 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_STENCIL_REF
)) {
556 struct fd4_zsa_stateobj
*zsa
= fd4_zsa_stateobj(ctx
->zsa
);
557 struct pipe_stencil_ref
*sr
= &ctx
->stencil_ref
;
559 OUT_PKT0(ring
, REG_A4XX_RB_STENCILREFMASK
, 2);
560 OUT_RING(ring
, zsa
->rb_stencilrefmask
|
561 A4XX_RB_STENCILREFMASK_STENCILREF(sr
->ref_value
[0]));
562 OUT_RING(ring
, zsa
->rb_stencilrefmask_bf
|
563 A4XX_RB_STENCILREFMASK_BF_STENCILREF(sr
->ref_value
[1]));
566 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
567 struct fd4_zsa_stateobj
*zsa
= fd4_zsa_stateobj(ctx
->zsa
);
568 bool fragz
= fp
->no_earlyz
| fp
->has_kill
| fp
->writes_pos
;
569 bool clamp
= !ctx
->rasterizer
->depth_clip_near
;
571 OUT_PKT0(ring
, REG_A4XX_RB_DEPTH_CONTROL
, 1);
572 OUT_RING(ring
, zsa
->rb_depth_control
|
573 COND(clamp
, A4XX_RB_DEPTH_CONTROL_Z_CLAMP_ENABLE
) |
574 COND(fragz
, A4XX_RB_DEPTH_CONTROL_EARLY_Z_DISABLE
) |
575 COND(fragz
&& fp
->fragcoord_compmask
!= 0,
576 A4XX_RB_DEPTH_CONTROL_FORCE_FRAGZ_TO_FS
));
578 /* maybe this register/bitfield needs a better name.. this
579 * appears to be just disabling early-z
581 OUT_PKT0(ring
, REG_A4XX_GRAS_ALPHA_CONTROL
, 1);
582 OUT_RING(ring
, zsa
->gras_alpha_control
|
583 COND(fragz
, A4XX_GRAS_ALPHA_CONTROL_ALPHA_TEST_ENABLE
) |
584 COND(fragz
&& fp
->fragcoord_compmask
!= 0,
585 A4XX_GRAS_ALPHA_CONTROL_FORCE_FRAGZ_TO_FS
));
588 if (dirty
& FD_DIRTY_RASTERIZER
) {
589 struct fd4_rasterizer_stateobj
*rasterizer
=
590 fd4_rasterizer_stateobj(ctx
->rasterizer
);
592 OUT_PKT0(ring
, REG_A4XX_GRAS_SU_MODE_CONTROL
, 1);
593 OUT_RING(ring
, rasterizer
->gras_su_mode_control
|
594 A4XX_GRAS_SU_MODE_CONTROL_RENDERING_PASS
);
596 OUT_PKT0(ring
, REG_A4XX_GRAS_SU_POINT_MINMAX
, 2);
597 OUT_RING(ring
, rasterizer
->gras_su_point_minmax
);
598 OUT_RING(ring
, rasterizer
->gras_su_point_size
);
600 OUT_PKT0(ring
, REG_A4XX_GRAS_SU_POLY_OFFSET_SCALE
, 3);
601 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_scale
);
602 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_offset
);
603 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_clamp
);
605 OUT_PKT0(ring
, REG_A4XX_GRAS_CL_CLIP_CNTL
, 1);
606 OUT_RING(ring
, rasterizer
->gras_cl_clip_cntl
);
609 /* NOTE: since primitive_restart is not actually part of any
610 * state object, we need to make sure that we always emit
611 * PRIM_VTX_CNTL.. either that or be more clever and detect
615 const struct pipe_draw_info
*info
= emit
->info
;
616 struct fd4_rasterizer_stateobj
*rast
=
617 fd4_rasterizer_stateobj(ctx
->rasterizer
);
618 uint32_t val
= rast
->pc_prim_vtx_cntl
;
620 if (info
->index_size
&& info
->primitive_restart
)
621 val
|= A4XX_PC_PRIM_VTX_CNTL_PRIMITIVE_RESTART
;
623 val
|= COND(vp
->writes_psize
, A4XX_PC_PRIM_VTX_CNTL_PSIZE
);
625 if (fp
->total_in
> 0) {
626 uint32_t varout
= align(fp
->total_in
, 16) / 16;
628 varout
= align(varout
, 2);
629 val
|= A4XX_PC_PRIM_VTX_CNTL_VAROUT(varout
);
632 OUT_PKT0(ring
, REG_A4XX_PC_PRIM_VTX_CNTL
, 2);
634 OUT_RING(ring
, rast
->pc_prim_vtx_cntl2
);
637 /* NOTE: scissor enabled bit is part of rasterizer state: */
638 if (dirty
& (FD_DIRTY_SCISSOR
| FD_DIRTY_RASTERIZER
)) {
639 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
641 OUT_PKT0(ring
, REG_A4XX_GRAS_SC_WINDOW_SCISSOR_BR
, 2);
642 OUT_RING(ring
, A4XX_GRAS_SC_WINDOW_SCISSOR_BR_X(scissor
->maxx
- 1) |
643 A4XX_GRAS_SC_WINDOW_SCISSOR_BR_Y(scissor
->maxy
- 1));
644 OUT_RING(ring
, A4XX_GRAS_SC_WINDOW_SCISSOR_TL_X(scissor
->minx
) |
645 A4XX_GRAS_SC_WINDOW_SCISSOR_TL_Y(scissor
->miny
));
647 ctx
->batch
->max_scissor
.minx
= MIN2(ctx
->batch
->max_scissor
.minx
, scissor
->minx
);
648 ctx
->batch
->max_scissor
.miny
= MIN2(ctx
->batch
->max_scissor
.miny
, scissor
->miny
);
649 ctx
->batch
->max_scissor
.maxx
= MAX2(ctx
->batch
->max_scissor
.maxx
, scissor
->maxx
);
650 ctx
->batch
->max_scissor
.maxy
= MAX2(ctx
->batch
->max_scissor
.maxy
, scissor
->maxy
);
653 if (dirty
& FD_DIRTY_VIEWPORT
) {
654 fd_wfi(ctx
->batch
, ring
);
655 OUT_PKT0(ring
, REG_A4XX_GRAS_CL_VPORT_XOFFSET_0
, 6);
656 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_XOFFSET_0(ctx
->viewport
.translate
[0]));
657 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_XSCALE_0(ctx
->viewport
.scale
[0]));
658 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_YOFFSET_0(ctx
->viewport
.translate
[1]));
659 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_YSCALE_0(ctx
->viewport
.scale
[1]));
660 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_ZOFFSET_0(ctx
->viewport
.translate
[2]));
661 OUT_RING(ring
, A4XX_GRAS_CL_VPORT_ZSCALE_0(ctx
->viewport
.scale
[2]));
664 if (dirty
& (FD_DIRTY_VIEWPORT
| FD_DIRTY_RASTERIZER
| FD_DIRTY_FRAMEBUFFER
)) {
667 if (ctx
->batch
->framebuffer
.zsbuf
) {
668 depth
= util_format_get_component_bits(
669 pipe_surface_format(ctx
->batch
->framebuffer
.zsbuf
),
670 UTIL_FORMAT_COLORSPACE_ZS
, 0);
672 util_viewport_zmin_zmax(&ctx
->viewport
, ctx
->rasterizer
->clip_halfz
,
675 OUT_PKT0(ring
, REG_A4XX_RB_VPORT_Z_CLAMP(0), 2);
677 OUT_RING(ring
, fui(zmin
));
678 OUT_RING(ring
, fui(zmax
));
679 } else if (depth
== 16) {
680 OUT_RING(ring
, (uint32_t)(zmin
* 0xffff));
681 OUT_RING(ring
, (uint32_t)(zmax
* 0xffff));
683 OUT_RING(ring
, (uint32_t)(zmin
* 0xffffff));
684 OUT_RING(ring
, (uint32_t)(zmax
* 0xffffff));
688 if (dirty
& (FD_DIRTY_PROG
| FD_DIRTY_FRAMEBUFFER
)) {
689 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
690 unsigned n
= pfb
->nr_cbufs
;
691 /* if we have depth/stencil, we need at least on MRT: */
694 fd4_program_emit(ring
, emit
, n
, pfb
->cbufs
);
697 if (emit
->prog
== &ctx
->prog
) { /* evil hack to deal sanely with clear path */
698 ir3_emit_vs_consts(vp
, ring
, ctx
, emit
->info
);
699 if (!emit
->binning_pass
)
700 ir3_emit_fs_consts(fp
, ring
, ctx
);
703 if ((dirty
& FD_DIRTY_BLEND
)) {
704 struct fd4_blend_stateobj
*blend
= fd4_blend_stateobj(ctx
->blend
);
707 for (i
= 0; i
< A4XX_MAX_RENDER_TARGETS
; i
++) {
708 enum pipe_format format
= pipe_surface_format(
709 ctx
->batch
->framebuffer
.cbufs
[i
]);
710 bool is_int
= util_format_is_pure_integer(format
);
711 bool has_alpha
= util_format_has_alpha(format
);
712 uint32_t control
= blend
->rb_mrt
[i
].control
;
715 control
&= A4XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK
;
716 control
|= A4XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY
);
720 control
&= ~A4XX_RB_MRT_CONTROL_BLEND2
;
723 OUT_PKT0(ring
, REG_A4XX_RB_MRT_CONTROL(i
), 1);
724 OUT_RING(ring
, control
);
726 OUT_PKT0(ring
, REG_A4XX_RB_MRT_BLEND_CONTROL(i
), 1);
727 OUT_RING(ring
, blend
->rb_mrt
[i
].blend_control
);
730 OUT_PKT0(ring
, REG_A4XX_RB_FS_OUTPUT
, 1);
731 OUT_RING(ring
, blend
->rb_fs_output
|
732 A4XX_RB_FS_OUTPUT_SAMPLE_MASK(0xffff));
735 if (dirty
& FD_DIRTY_BLEND_COLOR
) {
736 struct pipe_blend_color
*bcolor
= &ctx
->blend_color
;
738 OUT_PKT0(ring
, REG_A4XX_RB_BLEND_RED
, 8);
739 OUT_RING(ring
, A4XX_RB_BLEND_RED_FLOAT(bcolor
->color
[0]) |
740 A4XX_RB_BLEND_RED_UINT(bcolor
->color
[0] * 0xff) |
741 A4XX_RB_BLEND_RED_SINT(bcolor
->color
[0] * 0x7f));
742 OUT_RING(ring
, A4XX_RB_BLEND_RED_F32(bcolor
->color
[0]));
743 OUT_RING(ring
, A4XX_RB_BLEND_GREEN_FLOAT(bcolor
->color
[1]) |
744 A4XX_RB_BLEND_GREEN_UINT(bcolor
->color
[1] * 0xff) |
745 A4XX_RB_BLEND_GREEN_SINT(bcolor
->color
[1] * 0x7f));
746 OUT_RING(ring
, A4XX_RB_BLEND_RED_F32(bcolor
->color
[1]));
747 OUT_RING(ring
, A4XX_RB_BLEND_BLUE_FLOAT(bcolor
->color
[2]) |
748 A4XX_RB_BLEND_BLUE_UINT(bcolor
->color
[2] * 0xff) |
749 A4XX_RB_BLEND_BLUE_SINT(bcolor
->color
[2] * 0x7f));
750 OUT_RING(ring
, A4XX_RB_BLEND_BLUE_F32(bcolor
->color
[2]));
751 OUT_RING(ring
, A4XX_RB_BLEND_ALPHA_FLOAT(bcolor
->color
[3]) |
752 A4XX_RB_BLEND_ALPHA_UINT(bcolor
->color
[3] * 0xff) |
753 A4XX_RB_BLEND_ALPHA_SINT(bcolor
->color
[3] * 0x7f));
754 OUT_RING(ring
, A4XX_RB_BLEND_ALPHA_F32(bcolor
->color
[3]));
757 if (ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] & FD_DIRTY_SHADER_TEX
)
758 emit_textures(ctx
, ring
, SB4_VS_TEX
, &ctx
->tex
[PIPE_SHADER_VERTEX
], vp
);
760 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_TEX
)
761 emit_textures(ctx
, ring
, SB4_FS_TEX
, &ctx
->tex
[PIPE_SHADER_FRAGMENT
], fp
);
764 /* emit setup at begin of new cmdstream buffer (don't rely on previous
765 * state, there could have been a context switch between ioctls):
768 fd4_emit_restore(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
)
770 struct fd_context
*ctx
= batch
->ctx
;
771 struct fd4_context
*fd4_ctx
= fd4_context(ctx
);
773 OUT_PKT0(ring
, REG_A4XX_RBBM_PERFCTR_CTL
, 1);
774 OUT_RING(ring
, 0x00000001);
776 OUT_PKT0(ring
, REG_A4XX_GRAS_DEBUG_ECO_CONTROL
, 1);
777 OUT_RING(ring
, 0x00000000);
779 OUT_PKT0(ring
, REG_A4XX_SP_MODE_CONTROL
, 1);
780 OUT_RING(ring
, 0x00000006);
782 OUT_PKT0(ring
, REG_A4XX_TPL1_TP_MODE_CONTROL
, 1);
783 OUT_RING(ring
, 0x0000003a);
785 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_0D01
, 1);
786 OUT_RING(ring
, 0x00000001);
788 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_0E42
, 1);
789 OUT_RING(ring
, 0x00000000);
791 OUT_PKT0(ring
, REG_A4XX_UCHE_CACHE_WAYS_VFD
, 1);
792 OUT_RING(ring
, 0x00000007);
794 OUT_PKT0(ring
, REG_A4XX_UCHE_CACHE_MODE_CONTROL
, 1);
795 OUT_RING(ring
, 0x00000000);
797 OUT_PKT0(ring
, REG_A4XX_UCHE_INVALIDATE0
, 2);
798 OUT_RING(ring
, 0x00000000);
799 OUT_RING(ring
, 0x00000012);
801 OUT_PKT0(ring
, REG_A4XX_HLSQ_MODE_CONTROL
, 1);
802 OUT_RING(ring
, 0x00000000);
804 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_0CC5
, 1);
805 OUT_RING(ring
, 0x00000006);
807 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_0CC6
, 1);
808 OUT_RING(ring
, 0x00000000);
810 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_0EC2
, 1);
811 OUT_RING(ring
, 0x00040000);
813 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2001
, 1);
814 OUT_RING(ring
, 0x00000000);
816 OUT_PKT3(ring
, CP_INVALIDATE_STATE
, 1);
817 OUT_RING(ring
, 0x00001000);
819 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_20EF
, 1);
820 OUT_RING(ring
, 0x00000000);
822 OUT_PKT0(ring
, REG_A4XX_RB_BLEND_RED
, 4);
823 OUT_RING(ring
, A4XX_RB_BLEND_RED_UINT(0) |
824 A4XX_RB_BLEND_RED_FLOAT(0.0));
825 OUT_RING(ring
, A4XX_RB_BLEND_GREEN_UINT(0) |
826 A4XX_RB_BLEND_GREEN_FLOAT(0.0));
827 OUT_RING(ring
, A4XX_RB_BLEND_BLUE_UINT(0) |
828 A4XX_RB_BLEND_BLUE_FLOAT(0.0));
829 OUT_RING(ring
, A4XX_RB_BLEND_ALPHA_UINT(0x7fff) |
830 A4XX_RB_BLEND_ALPHA_FLOAT(1.0));
832 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2152
, 1);
833 OUT_RING(ring
, 0x00000000);
835 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2153
, 1);
836 OUT_RING(ring
, 0x00000000);
838 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2154
, 1);
839 OUT_RING(ring
, 0x00000000);
841 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2155
, 1);
842 OUT_RING(ring
, 0x00000000);
844 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2156
, 1);
845 OUT_RING(ring
, 0x00000000);
847 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_2157
, 1);
848 OUT_RING(ring
, 0x00000000);
850 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_21C3
, 1);
851 OUT_RING(ring
, 0x0000001d);
853 OUT_PKT0(ring
, REG_A4XX_PC_GS_PARAM
, 1);
854 OUT_RING(ring
, 0x00000000);
856 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_21E6
, 1);
857 OUT_RING(ring
, 0x00000001);
859 OUT_PKT0(ring
, REG_A4XX_PC_HS_PARAM
, 1);
860 OUT_RING(ring
, 0x00000000);
862 OUT_PKT0(ring
, REG_A4XX_UNKNOWN_22D7
, 1);
863 OUT_RING(ring
, 0x00000000);
865 OUT_PKT0(ring
, REG_A4XX_TPL1_TP_TEX_OFFSET
, 1);
866 OUT_RING(ring
, 0x00000000);
868 OUT_PKT0(ring
, REG_A4XX_TPL1_TP_TEX_COUNT
, 1);
869 OUT_RING(ring
, A4XX_TPL1_TP_TEX_COUNT_VS(16) |
870 A4XX_TPL1_TP_TEX_COUNT_HS(0) |
871 A4XX_TPL1_TP_TEX_COUNT_DS(0) |
872 A4XX_TPL1_TP_TEX_COUNT_GS(0));
874 OUT_PKT0(ring
, REG_A4XX_TPL1_TP_FS_TEX_COUNT
, 1);
877 /* we don't use this yet.. probably best to disable.. */
878 OUT_PKT3(ring
, CP_SET_DRAW_STATE
, 2);
879 OUT_RING(ring
, CP_SET_DRAW_STATE__0_COUNT(0) |
880 CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS
|
881 CP_SET_DRAW_STATE__0_GROUP_ID(0));
882 OUT_RING(ring
, CP_SET_DRAW_STATE__1_ADDR_LO(0));
884 OUT_PKT0(ring
, REG_A4XX_SP_VS_PVT_MEM_PARAM
, 2);
885 OUT_RING(ring
, 0x08000001); /* SP_VS_PVT_MEM_PARAM */
886 OUT_RELOC(ring
, fd4_ctx
->vs_pvt_mem
, 0,0,0); /* SP_VS_PVT_MEM_ADDR */
888 OUT_PKT0(ring
, REG_A4XX_SP_FS_PVT_MEM_PARAM
, 2);
889 OUT_RING(ring
, 0x08000001); /* SP_FS_PVT_MEM_PARAM */
890 OUT_RELOC(ring
, fd4_ctx
->fs_pvt_mem
, 0,0,0); /* SP_FS_PVT_MEM_ADDR */
892 OUT_PKT0(ring
, REG_A4XX_GRAS_SC_CONTROL
, 1);
893 OUT_RING(ring
, A4XX_GRAS_SC_CONTROL_RENDER_MODE(RB_RENDERING_PASS
) |
894 A4XX_GRAS_SC_CONTROL_MSAA_DISABLE
|
895 A4XX_GRAS_SC_CONTROL_MSAA_SAMPLES(MSAA_ONE
) |
896 A4XX_GRAS_SC_CONTROL_RASTER_MODE(0));
898 OUT_PKT0(ring
, REG_A4XX_RB_MSAA_CONTROL
, 1);
899 OUT_RING(ring
, A4XX_RB_MSAA_CONTROL_DISABLE
|
900 A4XX_RB_MSAA_CONTROL_SAMPLES(MSAA_ONE
));
902 OUT_PKT0(ring
, REG_A4XX_GRAS_CL_GB_CLIP_ADJ
, 1);
903 OUT_RING(ring
, A4XX_GRAS_CL_GB_CLIP_ADJ_HORZ(0) |
904 A4XX_GRAS_CL_GB_CLIP_ADJ_VERT(0));
906 OUT_PKT0(ring
, REG_A4XX_RB_ALPHA_CONTROL
, 1);
907 OUT_RING(ring
, A4XX_RB_ALPHA_CONTROL_ALPHA_TEST_FUNC(FUNC_ALWAYS
));
909 OUT_PKT0(ring
, REG_A4XX_RB_FS_OUTPUT
, 1);
910 OUT_RING(ring
, A4XX_RB_FS_OUTPUT_SAMPLE_MASK(0xffff));
912 OUT_PKT0(ring
, REG_A4XX_GRAS_ALPHA_CONTROL
, 1);
915 fd_hw_query_enable(batch
, ring
);
919 fd4_mem_to_mem(struct fd_ringbuffer
*ring
, struct pipe_resource
*dst
,
920 unsigned dst_off
, struct pipe_resource
*src
, unsigned src_off
,
923 struct fd_bo
*src_bo
= fd_resource(src
)->bo
;
924 struct fd_bo
*dst_bo
= fd_resource(dst
)->bo
;
927 for (i
= 0; i
< sizedwords
; i
++) {
928 OUT_PKT3(ring
, CP_MEM_TO_MEM
, 3);
929 OUT_RING(ring
, 0x00000000);
930 OUT_RELOC(ring
, dst_bo
, dst_off
, 0, 0);
931 OUT_RELOC(ring
, src_bo
, src_off
, 0, 0);
939 fd4_emit_init_screen(struct pipe_screen
*pscreen
)
941 struct fd_screen
*screen
= fd_screen(pscreen
);
943 screen
->emit_ib
= fd4_emit_ib
;
944 screen
->mem_to_mem
= fd4_mem_to_mem
;
948 fd4_emit_init(struct pipe_context
*pctx
)