7cbacea89a1321a7b6705e8ffbad18acc2055509
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)
93 enum radeon_family
r600_get_family(struct radeon
*rw
);
97 struct radeon_ws_bo
*radeon_ws_bo(struct radeon
*radeon
,
98 unsigned size
, unsigned alignment
, unsigned usage
);
99 struct radeon_ws_bo
*radeon_ws_bo_handle(struct radeon
*radeon
,
101 void *radeon_ws_bo_map(struct radeon
*radeon
, struct radeon_ws_bo
*bo
, unsigned usage
, void *ctx
);
102 void radeon_ws_bo_unmap(struct radeon
*radeon
, struct radeon_ws_bo
*bo
);
103 void radeon_ws_bo_reference(struct radeon
*radeon
, struct radeon_ws_bo
**dst
,
104 struct radeon_ws_bo
*src
);
106 /* R600/R700 STATES */
107 #define R600_GROUP_MAX 16
108 #define R600_BLOCK_MAX_BO 32
109 #define R600_BLOCK_MAX_REG 128
112 R600_GROUP_CONFIG
= 0,
114 R600_GROUP_ALU_CONST
,
117 R600_GROUP_CTL_CONST
,
118 R600_GROUP_LOOP_CONST
,
119 R600_GROUP_BOOL_CONST
,
123 struct r600_pipe_reg
{
128 struct radeon_ws_bo
*bo
;
131 struct r600_pipe_state
{
134 struct r600_pipe_reg regs
[R600_BLOCK_MAX_REG
];
137 static inline void r600_pipe_state_add_reg(struct r600_pipe_state
*state
,
138 unsigned group_id
, u32 offset
,
140 struct radeon_ws_bo
*bo
)
142 state
->regs
[state
->nregs
].group_id
= group_id
;
143 state
->regs
[state
->nregs
].offset
= offset
;
144 state
->regs
[state
->nregs
].value
= value
;
145 state
->regs
[state
->nregs
].mask
= mask
;
146 state
->regs
[state
->nregs
].bo
= bo
;
148 assert(state
->nregs
< R600_BLOCK_MAX_REG
);
151 #define R600_BLOCK_STATUS_ENABLED (1 << 0)
152 #define R600_BLOCK_STATUS_DIRTY (1 << 1)
154 struct r600_block_reloc
{
155 struct radeon_ws_bo
*bo
;
157 unsigned bo_pm4_index
[R600_BLOCK_MAX_BO
];
160 struct r600_group_block
{
162 unsigned start_offset
;
163 unsigned pm4_ndwords
;
166 u32 pm4
[R600_BLOCK_MAX_REG
];
167 unsigned pm4_bo_index
[R600_BLOCK_MAX_REG
];
168 struct r600_block_reloc reloc
[R600_BLOCK_MAX_BO
];
172 unsigned start_offset
;
175 struct r600_group_block
*blocks
;
176 unsigned *offset_block_id
;
182 uint32_t read_domain
;
183 uint32_t write_domain
;
188 struct r600_context
{
189 struct radeon
*radeon
;
191 struct r600_group groups
[R600_GROUP_MAX
];
192 unsigned pm4_ndwords
;
193 unsigned pm4_cdwords
;
194 unsigned pm4_dirty_cdwords
;
195 unsigned ctx_pm4_ndwords
;
198 struct r600_reloc
*reloc
;
199 struct radeon_ws_bo
**bo
;
205 u32 vgt_num_instances
;
207 u32 vgt_draw_initiator
;
208 u32 indices_bo_offset
;
209 struct radeon_ws_bo
*indices
;
212 int r600_context_init(struct r600_context
*ctx
, struct radeon
*radeon
);
213 void r600_context_fini(struct r600_context
*ctx
);
214 void r600_context_pipe_state_set(struct r600_context
*ctx
, struct r600_pipe_state
*state
);
215 void r600_context_pipe_state_set_ps_resource(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned rid
);
216 void r600_context_pipe_state_set_vs_resource(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned rid
);
217 void r600_context_pipe_state_set_ps_sampler(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned id
);
218 void r600_context_pipe_state_set_vs_sampler(struct r600_context
*ctx
, struct r600_pipe_state
*state
, unsigned id
);
219 void r600_context_flush(struct r600_context
*ctx
);
220 void r600_context_dump_bof(struct r600_context
*ctx
, const char *file
);
221 void r600_context_draw(struct r600_context
*ctx
, const struct r600_draw
*draw
);