2 * Copyright 2010 Jerome Glisse <glisse@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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define RADEON_CTX_MAX_PM4 (64 * 1024 / 4)
34 #define R600_ERR(fmt, args...) \
35 fprintf(stderr, "EE %s/%s:%d - "fmt, __FILE__, __func__, __LINE__, ##args)
99 enum radeon_family
r600_get_family(struct radeon
*rw
);
100 enum chip_class
r600_get_family_class(struct radeon
*radeon
);
104 struct radeon_ws_bo
*radeon_ws_bo(struct radeon
*radeon
,
105 unsigned size
, unsigned alignment
, unsigned usage
);
106 struct radeon_ws_bo
*radeon_ws_bo_handle(struct radeon
*radeon
,
108 void *radeon_ws_bo_map(struct radeon
*radeon
, struct radeon_ws_bo
*bo
, unsigned usage
, void *ctx
);
109 void radeon_ws_bo_unmap(struct radeon
*radeon
, struct radeon_ws_bo
*bo
);
110 void radeon_ws_bo_reference(struct radeon
*radeon
, struct radeon_ws_bo
**dst
,
111 struct radeon_ws_bo
*src
);
113 /* R600/R700 STATES */
114 #define R600_GROUP_MAX 16
115 #define R600_BLOCK_MAX_BO 32
116 #define R600_BLOCK_MAX_REG 128
119 R600_GROUP_CONFIG
= 0,
121 R600_GROUP_ALU_CONST
,
124 R600_GROUP_CTL_CONST
,
125 R600_GROUP_LOOP_CONST
,
126 R600_GROUP_BOOL_CONST
,
130 struct r600_pipe_reg
{
135 struct radeon_ws_bo
*bo
;
138 struct r600_pipe_state
{
141 struct r600_pipe_reg regs
[R600_BLOCK_MAX_REG
];
144 static inline void r600_pipe_state_add_reg(struct r600_pipe_state
*state
,
145 unsigned group_id
, u32 offset
,
147 struct radeon_ws_bo
*bo
)
149 state
->regs
[state
->nregs
].group_id
= group_id
;
150 state
->regs
[state
->nregs
].offset
= offset
;
151 state
->regs
[state
->nregs
].value
= value
;
152 state
->regs
[state
->nregs
].mask
= mask
;
153 state
->regs
[state
->nregs
].bo
= bo
;
155 assert(state
->nregs
< R600_BLOCK_MAX_REG
);
158 #define R600_BLOCK_STATUS_ENABLED (1 << 0)
159 #define R600_BLOCK_STATUS_DIRTY (1 << 1)
161 struct r600_block_reloc
{
162 struct radeon_ws_bo
*bo
;
164 unsigned bo_pm4_index
[R600_BLOCK_MAX_BO
];
167 struct r600_group_block
{
169 unsigned start_offset
;
170 unsigned pm4_ndwords
;
173 u32 pm4
[R600_BLOCK_MAX_REG
];
174 unsigned pm4_bo_index
[R600_BLOCK_MAX_REG
];
175 struct r600_block_reloc reloc
[R600_BLOCK_MAX_BO
];
179 unsigned start_offset
;
182 struct r600_group_block
*blocks
;
183 unsigned *offset_block_id
;
189 uint32_t read_domain
;
190 uint32_t write_domain
;
197 struct r600_context
{
198 struct radeon
*radeon
;
200 struct r600_group groups
[R600_GROUP_MAX
];
201 unsigned pm4_ndwords
;
202 unsigned pm4_cdwords
;
203 unsigned pm4_dirty_cdwords
;
204 unsigned ctx_pm4_ndwords
;
207 struct r600_reloc
*reloc
;
208 struct radeon_bo
**bo
;
214 u32 vgt_num_instances
;
216 u32 vgt_draw_initiator
;
217 u32 indices_bo_offset
;
218 struct radeon_ws_bo
*indices
;
221 int r600_context_init(struct r600_context
*ctx
, struct radeon
*radeon
);
222 void r600_context_fini(struct r600_context
*ctx
);
223 void r600_context_pipe_state_set(struct r600_context
*ctx
, struct r600_pipe_state
*state
);
224 void r600_context_pipe_state_set_ps_resource(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned rid
);
225 void r600_context_pipe_state_set_vs_resource(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned rid
);
226 void r600_context_pipe_state_set_ps_sampler(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned id
);
227 void r600_context_pipe_state_set_vs_sampler(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned id
);
228 void r600_context_flush(struct r600_context
*ctx
);
229 void r600_context_dump_bof(struct r600_context
*ctx
, const char *file
);
230 void r600_context_draw(struct r600_context
*ctx
, const struct r600_draw
*draw
);