1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
29 #ifndef FREEDRENO_DRAW_H_
30 #define FREEDRENO_DRAW_H_
32 #include "pipe/p_state.h"
33 #include "pipe/p_context.h"
35 #include "freedreno_context.h"
36 #include "freedreno_screen.h"
37 #include "freedreno_util.h"
41 void fd_draw_emit(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
42 enum pc_di_vis_cull_mode vismode
,
43 const struct pipe_draw_info
*info
);
45 void fd_draw_init(struct pipe_context
*pctx
);
48 fd_draw(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
49 enum pc_di_primtype primtype
,
50 enum pc_di_vis_cull_mode vismode
,
51 enum pc_di_src_sel src_sel
, uint32_t count
,
52 enum pc_di_index_size idx_type
,
53 uint32_t idx_size
, uint32_t idx_offset
,
56 /* for debug after a lock up, write a unique counter value
57 * to scratch7 for each draw, to make it easier to match up
58 * register dumps to cmdstream. The combination of IB
59 * (scratch6) and DRAW is enough to "triangulate" the
60 * particular draw that caused lockup.
64 if (ctx
->screen
->gpu_id
== 320) {
65 /* dummy-draw workaround: */
66 OUT_PKT3(ring
, CP_DRAW_INDX
, 3);
67 OUT_RING(ring
, 0x00000000);
68 OUT_RING(ring
, DRAW(1, DI_SRC_SEL_AUTO_INDEX
,
69 INDEX_SIZE_IGN
, USE_VISIBILITY
));
70 OUT_RING(ring
, 0); /* NumIndices */
72 /* ugg, hard-code register offset to avoid pulling in the
73 * a3xx register headers into something #included from a2xx
75 OUT_PKT0(ring
, 0x2206, 1); /* A3XX_HLSQ_CONST_VSPRESV_RANGE_REG */
79 OUT_PKT3(ring
, CP_DRAW_INDX
, idx_bo
? 5 : 3);
80 OUT_RING(ring
, 0x00000000); /* viz query info. */
81 if (vismode
== USE_VISIBILITY
) {
82 /* leave vis mode blank for now, it will be patched up when
83 * we know if we are binning or not
85 OUT_RINGP(ring
, DRAW(primtype
, src_sel
, idx_type
, 0),
88 OUT_RING(ring
, DRAW(primtype
, src_sel
, idx_type
, vismode
));
90 OUT_RING(ring
, count
); /* NumIndices */
92 OUT_RELOC(ring
, idx_bo
, idx_offset
, 0, 0);
93 OUT_RING (ring
, idx_size
);
98 ctx
->rmw
.need_wfi
= true;
101 #endif /* FREEDRENO_DRAW_H_ */