2 * Copyright (C) 2008-2010 Advanced Micro Devices, Inc.
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 shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
27 #include "main/imports.h"
28 #include "main/glheader.h"
29 #include "main/simple_list.h"
31 #include "r600_context.h"
32 #include "r600_cmdbuf.h"
34 #include "evergreen_chip.h"
35 #include "evergreen_off.h"
36 #include "evergreen_diff.h"
37 #include "evergreen_fragprog.h"
38 #include "evergreen_vertprog.h"
40 #include "radeon_mipmap_tree.h"
42 void evergreenCreateChip(context_t *context)
44 EVERGREEN_CHIP_CONTEXT * evergreen =
45 (EVERGREEN_CHIP_CONTEXT*) CALLOC(sizeof(EVERGREEN_CHIP_CONTEXT));
47 context->pChip = (void*)evergreen;
50 #define EVERGREEN_ALLOC_STATE( ATOM, CHK, SZ, EMIT ) \
52 context->evergreen_atoms.ATOM.cmd_size = (SZ); \
53 context->evergreen_atoms.ATOM.cmd = NULL; \
54 context->evergreen_atoms.ATOM.name = #ATOM; \
55 context->evergreen_atoms.ATOM.idx = 0; \
56 context->evergreen_atoms.ATOM.check = check_##CHK; \
57 context->evergreen_atoms.ATOM.dirty = GL_FALSE; \
58 context->evergreen_atoms.ATOM.emit = (EMIT); \
59 context->radeon.hw.max_state_size += (SZ); \
60 insert_at_tail(&context->radeon.hw.atomlist, &context->evergreen_atoms.ATOM); \
63 static int check_queryobj(struct gl_context *ctx, struct radeon_state_atom *atom)
65 radeonContextPtr radeon = RADEON_CONTEXT(ctx);
66 struct radeon_query_object *query = radeon->query.current;
69 if (!query || query->emitted_begin)
72 count = atom->cmd_size;
73 radeon_print(RADEON_STATE, RADEON_TRACE, "%s %d\n", __func__, count);
77 static void evergreenSendQueryBegin(struct gl_context *ctx, struct radeon_state_atom *atom)
79 radeonContextPtr radeon = RADEON_CONTEXT(ctx);
80 struct radeon_query_object *query = radeon->query.current;
82 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
84 /* clear the buffer */
85 radeon_bo_map(query->bo, GL_FALSE);
86 memset(query->bo->ptr, 0, 8 * 2 * sizeof(uint64_t)); /* 8 DBs, 2 qwords each */
87 radeon_bo_unmap(query->bo);
89 radeon_cs_space_check_with_bo(radeon->cmdbuf.cs,
91 0, RADEON_GEM_DOMAIN_GTT);
93 BEGIN_BATCH_NO_AUTOSTATE(4 + 2);
94 R600_OUT_BATCH(CP_PACKET3(R600_IT_EVENT_WRITE, 2));
95 R600_OUT_BATCH(R600_EVENT_TYPE(ZPASS_DONE) | R600_EVENT_INDEX(1));
96 R600_OUT_BATCH(query->curr_offset); /* hw writes qwords */
97 R600_OUT_BATCH(0x00000000);
98 R600_OUT_BATCH_RELOC(VGT_EVENT_INITIATOR, query->bo, 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
100 query->emitted_begin = GL_TRUE;
103 static void evergreen_init_query_stateobj(radeonContextPtr radeon, int SZ)
105 radeon->query.queryobj.cmd_size = (SZ);
106 radeon->query.queryobj.cmd = NULL;
107 radeon->query.queryobj.name = "queryobj";
108 radeon->query.queryobj.idx = 0;
109 radeon->query.queryobj.check = check_queryobj;
110 radeon->query.queryobj.dirty = GL_FALSE;
111 radeon->query.queryobj.emit = evergreenSendQueryBegin;
112 radeon->hw.max_state_size += (SZ);
113 insert_at_tail(&radeon->hw.atomlist, &radeon->query.queryobj);
117 static int check_always(struct gl_context *ctx, struct radeon_state_atom *atom)
119 return atom->cmd_size;
122 static void evergreenSendTexState(struct gl_context *ctx, struct radeon_state_atom *atom)
124 context_t *context = EVERGREEN_CONTEXT(ctx);
125 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
127 struct evergreen_vertex_program *vp = (struct evergreen_vertex_program *) context->selected_vp;
129 struct radeon_bo *bo = NULL;
131 unsigned int nBorderSet = 0;
132 BATCH_LOCALS(&context->radeon);
134 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
136 for (i = 0; i < R700_TEXTURE_NUMBERUNITS; i++) {
137 if (ctx->Texture.Unit[i]._ReallyEnabled) {
138 radeonTexObj *t = evergreen->textures[i];
142 if (!t->image_override) {
150 r700SyncSurf(context, bo,
151 RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM,
152 0, TC_ACTION_ENA_bit);
154 BEGIN_BATCH_NO_AUTOSTATE(10 + 4);
155 R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_RESOURCE, 8));
157 if( (1<<i) & vp->r700AsmCode.unVetTexBits )
159 R600_OUT_BATCH((i + VERT_ATTRIB_MAX + EG_SQ_FETCH_RESOURCE_VS_OFFSET) * EG_FETCH_RESOURCE_STRIDE);
163 R600_OUT_BATCH(i * EG_FETCH_RESOURCE_STRIDE);
166 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE0);
167 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE1);
168 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE2);
169 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE3);
170 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE4);
171 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE5);
172 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE6);
173 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_RESOURCE7);
175 R600_OUT_BATCH_RELOC(evergreen->textures[i]->SQ_TEX_RESOURCE2,
177 evergreen->textures[i]->SQ_TEX_RESOURCE2,
178 RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
179 R600_OUT_BATCH_RELOC(evergreen->textures[i]->SQ_TEX_RESOURCE3,
181 evergreen->textures[i]->SQ_TEX_RESOURCE3,
182 RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
187 BEGIN_BATCH_NO_AUTOSTATE(5);
188 R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_SAMPLER, 3));
190 if( (1<<i) & vp->r700AsmCode.unVetTexBits )
192 R600_OUT_BATCH((i+SQ_TEX_SAMPLER_VS_OFFSET) * 3);
196 R600_OUT_BATCH(i * 3);
198 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_SAMPLER0);
199 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_SAMPLER1);
200 R600_OUT_BATCH(evergreen->textures[i]->SQ_TEX_SAMPLER2);
205 /* Tex border color */
208 BEGIN_BATCH_NO_AUTOSTATE(2 + 4);
209 R600_OUT_BATCH_REGSEQ(EG_TD_PS_BORDER_COLOR_RED, 4);
210 R600_OUT_BATCH(evergreen->textures[i]->TD_PS_SAMPLER0_BORDER_RED);
211 R600_OUT_BATCH(evergreen->textures[i]->TD_PS_SAMPLER0_BORDER_GREEN);
212 R600_OUT_BATCH(evergreen->textures[i]->TD_PS_SAMPLER0_BORDER_BLUE);
213 R600_OUT_BATCH(evergreen->textures[i]->TD_PS_SAMPLER0_BORDER_ALPHA);
224 static int check_evergreen_tx(struct gl_context *ctx, struct radeon_state_atom *atom)
226 context_t *context = EVERGREEN_CONTEXT(ctx);
227 unsigned int i, count = 0;
228 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
230 for (i = 0; i < R700_TEXTURE_NUMBERUNITS; i++) {
231 if (ctx->Texture.Unit[i]._ReallyEnabled) {
232 radeonTexObj *t = evergreen->textures[i];
237 radeon_print(RADEON_STATE, RADEON_TRACE, "%s %d\n", __func__, count);
238 return count * 37 + 6;
241 static void evergreenSendSQConfig(struct gl_context *ctx, struct radeon_state_atom *atom)
243 context_t *context = EVERGREEN_CONTEXT(ctx);
244 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
245 BATCH_LOCALS(&context->radeon);
246 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
248 BEGIN_BATCH_NO_AUTOSTATE(19);
250 EVERGREEN_OUT_BATCH_REGVAL(EG_SPI_CONFIG_CNTL, evergreen->evergreen_config.SPI_CONFIG_CNTL.u32All);
251 EVERGREEN_OUT_BATCH_REGVAL(EG_SPI_CONFIG_CNTL_1, evergreen->evergreen_config.SPI_CONFIG_CNTL_1.u32All);
253 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_CONFIG, 4);
254 R600_OUT_BATCH(evergreen->evergreen_config.SQ_CONFIG.u32All);
255 R600_OUT_BATCH(evergreen->evergreen_config.SQ_GPR_RESOURCE_MGMT_1.u32All);
256 R600_OUT_BATCH(evergreen->evergreen_config.SQ_GPR_RESOURCE_MGMT_2.u32All);
257 R600_OUT_BATCH(evergreen->evergreen_config.SQ_GPR_RESOURCE_MGMT_3.u32All);
259 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_THREAD_RESOURCE_MGMT, 5);
260 R600_OUT_BATCH(evergreen->evergreen_config.SQ_THREAD_RESOURCE_MGMT.u32All);
261 R600_OUT_BATCH(evergreen->evergreen_config.SQ_THREAD_RESOURCE_MGMT_2.u32All);
262 R600_OUT_BATCH(evergreen->evergreen_config.SQ_STACK_RESOURCE_MGMT_1.u32All);
263 R600_OUT_BATCH(evergreen->evergreen_config.SQ_STACK_RESOURCE_MGMT_2.u32All);
264 R600_OUT_BATCH(evergreen->evergreen_config.SQ_STACK_RESOURCE_MGMT_3.u32All);
271 extern int evergreen_getTypeSize(GLenum type);
272 static void evergreenSetupVTXConstants(struct gl_context * ctx,
274 StreamDesc * pStreamDesc)
276 context_t *context = EVERGREEN_CONTEXT(ctx);
277 struct radeon_aos * paos = (struct radeon_aos *)pAos;
278 BATCH_LOCALS(&context->radeon);
280 unsigned int uSQ_VTX_CONSTANT_WORD0_0;
281 unsigned int uSQ_VTX_CONSTANT_WORD1_0;
282 unsigned int uSQ_VTX_CONSTANT_WORD2_0 = 0;
283 unsigned int uSQ_VTX_CONSTANT_WORD3_0 = 0;
284 unsigned int uSQ_VTX_CONSTANT_WORD7_0 = 0;
289 if ((context->radeon.radeonScreen->chip_family == CHIP_FAMILY_CEDAR) ||
290 (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_PALM) ||
291 (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_SUMO) ||
292 (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_SUMO2))
293 r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, TC_ACTION_ENA_bit);
295 r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, VC_ACTION_ENA_bit);
297 //uSQ_VTX_CONSTANT_WORD0_0
298 uSQ_VTX_CONSTANT_WORD0_0 = paos->offset;
300 //uSQ_VTX_CONSTANT_WORD1_0
301 uSQ_VTX_CONSTANT_WORD1_0 = paos->bo->size - paos->offset - 1;
303 //uSQ_VTX_CONSTANT_WORD2_0
304 SETfield(uSQ_VTX_CONSTANT_WORD2_0,
306 SQ_VTX_CONSTANT_WORD2_0__STRIDE_shift,
307 SQ_VTX_CONSTANT_WORD2_0__STRIDE_mask);
308 SETfield(uSQ_VTX_CONSTANT_WORD2_0, GetSurfaceFormat(pStreamDesc->type, pStreamDesc->size, NULL),
309 SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_shift,
310 SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_mask); // TODO : trace back api for initial data type, not only GL_FLOAT
311 SETfield(uSQ_VTX_CONSTANT_WORD2_0, 0, BASE_ADDRESS_HI_shift, BASE_ADDRESS_HI_mask); // TODO
313 SETfield(uSQ_VTX_CONSTANT_WORD2_0,
314 #ifdef MESA_BIG_ENDIAN
319 SQ_VTX_CONSTANT_WORD2_0__ENDIAN_SWAP_shift,
320 SQ_VTX_CONSTANT_WORD2_0__ENDIAN_SWAP_mask);
322 if(GL_TRUE == pStreamDesc->normalize)
324 SETfield(uSQ_VTX_CONSTANT_WORD2_0, SQ_NUM_FORMAT_NORM,
325 SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_shift, SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_mask);
329 SETfield(uSQ_VTX_CONSTANT_WORD2_0, SQ_NUM_FORMAT_SCALED,
330 SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_shift, SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_mask);
332 if(1 == pStreamDesc->_signed)
334 SETbit(uSQ_VTX_CONSTANT_WORD2_0, SQ_VTX_CONSTANT_WORD2_0__FORMAT_COMP_ALL_bit);
337 //uSQ_VTX_CONSTANT_WORD3_0
338 SETfield(uSQ_VTX_CONSTANT_WORD3_0, SQ_SEL_X,
339 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_X_shift,
340 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_X_mask);
341 SETfield(uSQ_VTX_CONSTANT_WORD3_0, SQ_SEL_Y,
342 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_Y_shift,
343 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_Y_mask);
344 SETfield(uSQ_VTX_CONSTANT_WORD3_0, SQ_SEL_Z,
345 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_Z_shift,
346 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_Z_mask);
347 SETfield(uSQ_VTX_CONSTANT_WORD3_0, SQ_SEL_W,
348 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_W_shift,
349 EG_SQ_VTX_CONSTANT_WORD3_0__DST_SEL_W_mask);
351 //uSQ_VTX_CONSTANT_WORD7_0
352 SETfield(uSQ_VTX_CONSTANT_WORD7_0, SQ_TEX_VTX_VALID_BUFFER,
353 SQ_TEX_RESOURCE_WORD6_0__TYPE_shift, SQ_TEX_RESOURCE_WORD6_0__TYPE_mask);
355 BEGIN_BATCH_NO_AUTOSTATE(10 + 2);
357 R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_RESOURCE, 8));
358 R600_OUT_BATCH((pStreamDesc->element + EG_SQ_FETCH_RESOURCE_VS_OFFSET) * EG_FETCH_RESOURCE_STRIDE);
359 R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD0_0);
360 R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD1_0);
361 R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD2_0);
362 R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD3_0);
366 R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD7_0);
367 R600_OUT_BATCH_RELOC(uSQ_VTX_CONSTANT_WORD0_0,
369 uSQ_VTX_CONSTANT_WORD0_0,
370 RADEON_GEM_DOMAIN_GTT, 0, 0);
376 static int check_evergreen_vtx(struct gl_context *ctx, struct radeon_state_atom *atom)
378 context_t *context = EVERGREEN_CONTEXT(ctx);
379 int count = context->radeon.tcl.aos_count * 12;
384 radeon_print(RADEON_STATE, RADEON_TRACE, "%s %d\n", __func__, count);
388 static void evergreenSendVTX(struct gl_context *ctx, struct radeon_state_atom *atom)
390 context_t *context = EVERGREEN_CONTEXT(ctx);
391 struct evergreen_vertex_program *vp = (struct evergreen_vertex_program *)(context->selected_vp);
392 unsigned int i, j = 0;
393 BATCH_LOCALS(&context->radeon);
394 (void) b_l_rmesa; /* silence unused var warning */
396 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
398 if (context->radeon.tcl.aos_count == 0)
401 for(i=0; i<VERT_ATTRIB_MAX; i++) {
402 if(vp->mesa_program->Base.InputsRead & (1 << i))
404 evergreenSetupVTXConstants(ctx,
405 (void*)(&context->radeon.tcl.aos[j]),
406 &(context->stream_desc[j]));
411 static void evergreenSendPA(struct gl_context *ctx, struct radeon_state_atom *atom)
413 context_t *context = EVERGREEN_CONTEXT(ctx);
414 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
415 BATCH_LOCALS(&context->radeon);
416 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
419 BEGIN_BATCH_NO_AUTOSTATE(3);
420 EVERGREEN_OUT_BATCH_REGVAL(EG_PA_SU_HARDWARE_SCREEN_OFFSET, 0);
423 BEGIN_BATCH_NO_AUTOSTATE(22);
424 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_SCREEN_SCISSOR_TL, 2);
425 R600_OUT_BATCH(evergreen->PA_SC_SCREEN_SCISSOR_TL.u32All);
426 R600_OUT_BATCH(evergreen->PA_SC_SCREEN_SCISSOR_BR.u32All);
428 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_WINDOW_OFFSET, 12);
429 R600_OUT_BATCH(evergreen->PA_SC_WINDOW_OFFSET.u32All);
430 R600_OUT_BATCH(evergreen->PA_SC_WINDOW_SCISSOR_TL.u32All);
431 R600_OUT_BATCH(evergreen->PA_SC_WINDOW_SCISSOR_BR.u32All);
432 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_RULE.u32All);
433 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_0_TL.u32All);
434 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_0_BR.u32All);
435 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_1_TL.u32All);
436 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_1_BR.u32All);
437 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_2_TL.u32All);
438 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_2_BR.u32All);
439 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_3_TL.u32All);
440 R600_OUT_BATCH(evergreen->PA_SC_CLIPRECT_3_BR.u32All);
442 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_GENERIC_SCISSOR_TL, 2);
443 R600_OUT_BATCH(evergreen->PA_SC_GENERIC_SCISSOR_TL.u32All);
444 R600_OUT_BATCH(evergreen->PA_SC_GENERIC_SCISSOR_BR.u32All);
447 BEGIN_BATCH_NO_AUTOSTATE(3);
448 EVERGREEN_OUT_BATCH_REGVAL(EG_PA_SC_EDGERULE, evergreen->PA_SC_EDGERULE.u32All);
452 BEGIN_BATCH_NO_AUTOSTATE(18);
453 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_VPORT_SCISSOR_0_TL, 4);
454 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_SCISSOR_0_TL.u32All);
455 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_SCISSOR_0_BR.u32All);
456 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_SCISSOR_0_TL.u32All);
457 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_SCISSOR_0_BR.u32All);
459 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_VPORT_ZMIN_0, 2);
460 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_ZMIN_0.u32All);
461 R600_OUT_BATCH(evergreen->viewport[id].PA_SC_VPORT_ZMAX_0.u32All);
463 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_CL_VPORT_XSCALE, 6);
464 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_XSCALE.u32All);
465 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_XOFFSET.u32All);
466 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_YSCALE.u32All);
467 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_YOFFSET.u32All);
468 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_ZSCALE.u32All);
469 R600_OUT_BATCH(evergreen->viewport[id].PA_CL_VPORT_ZOFFSET.u32All);
473 for (id = 0; id < EVERGREEN_MAX_UCP; id++) {
474 if (evergreen->ucp[id].enabled) {
475 BEGIN_BATCH_NO_AUTOSTATE(6);
476 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_CL_UCP_0_X + (4 * id), 4);
477 R600_OUT_BATCH(evergreen->ucp[id].PA_CL_UCP_0_X.u32All);
478 R600_OUT_BATCH(evergreen->ucp[id].PA_CL_UCP_0_Y.u32All);
479 R600_OUT_BATCH(evergreen->ucp[id].PA_CL_UCP_0_Z.u32All);
480 R600_OUT_BATCH(evergreen->ucp[id].PA_CL_UCP_0_W.u32All);
485 BEGIN_BATCH_NO_AUTOSTATE(42);
486 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_CL_CLIP_CNTL, 5);
487 R600_OUT_BATCH(evergreen->PA_CL_CLIP_CNTL.u32All);
488 R600_OUT_BATCH(evergreen->PA_SU_SC_MODE_CNTL.u32All);
489 R600_OUT_BATCH(evergreen->PA_CL_VTE_CNTL.u32All);
490 R600_OUT_BATCH(evergreen->PA_CL_VS_OUT_CNTL.u32All);
491 R600_OUT_BATCH(evergreen->PA_CL_NANINF_CNTL.u32All);
493 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SU_POINT_SIZE, 3);
494 R600_OUT_BATCH(evergreen->PA_SU_POINT_SIZE.u32All);
495 R600_OUT_BATCH(evergreen->PA_SU_POINT_MINMAX.u32All);
496 R600_OUT_BATCH(evergreen->PA_SU_LINE_CNTL.u32All);
498 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_MODE_CNTL_0, 2);
499 R600_OUT_BATCH(evergreen->PA_SC_MODE_CNTL_0.u32All);
500 R600_OUT_BATCH(evergreen->PA_SC_MODE_CNTL_1.u32All);
502 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SU_POLY_OFFSET_DB_FMT_CNTL, 6);
503 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_DB_FMT_CNTL.u32All);
504 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_CLAMP.u32All);
505 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_FRONT_SCALE.u32All);
506 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_FRONT_OFFSET.u32All);
507 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_BACK_SCALE.u32All);
508 R600_OUT_BATCH(evergreen->PA_SU_POLY_OFFSET_BACK_OFFSET.u32All);
510 EVERGREEN_OUT_BATCH_REGSEQ(EG_PA_SC_LINE_CNTL, 16);
511 R600_OUT_BATCH(evergreen->PA_SC_LINE_CNTL.u32All);
512 R600_OUT_BATCH(evergreen->PA_SC_AA_CONFIG.u32All);
513 R600_OUT_BATCH(evergreen->PA_SU_VTX_CNTL.u32All);
514 R600_OUT_BATCH(evergreen->PA_CL_GB_VERT_CLIP_ADJ.u32All);
515 R600_OUT_BATCH(evergreen->PA_CL_GB_VERT_DISC_ADJ.u32All);
516 R600_OUT_BATCH(evergreen->PA_CL_GB_HORZ_CLIP_ADJ.u32All);
517 R600_OUT_BATCH(evergreen->PA_CL_GB_HORZ_DISC_ADJ.u32All);
518 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_0.u32All);
519 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_1.u32All);
520 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_2.u32All);
521 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_3.u32All);
522 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_4.u32All);
523 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_5.u32All);
524 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_6.u32All);
525 R600_OUT_BATCH(evergreen->PA_SC_AA_SAMPLE_LOCS_7.u32All);
526 R600_OUT_BATCH(evergreen->PA_SC_AA_MASK.u32All);
532 static void evergreenSendTP(struct gl_context *ctx, struct radeon_state_atom *atom)
535 context_t *context = EVERGREEN_CONTEXT(ctx);
536 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
537 BATCH_LOCALS(&context->radeon);
538 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
544 static void evergreenSendPSresource(struct gl_context *ctx)
546 context_t *context = EVERGREEN_CONTEXT(ctx);
547 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
548 struct radeon_bo * pbo;
549 struct radeon_bo * pbo_const;
550 /* const size reg is in units of 16 consts */
551 int const_size = ((evergreen->ps.num_consts * 4) + 15) & ~15;
553 BATCH_LOCALS(&context->radeon);
554 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
556 pbo = (struct radeon_bo *)evergreenGetActiveFpShaderBo(GL_CONTEXT(context));
561 r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
563 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
564 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_START_PS, 1);
565 R600_OUT_BATCH(evergreen->ps.SQ_PGM_START_PS.u32All);
566 R600_OUT_BATCH_RELOC(evergreen->ps.SQ_PGM_START_PS.u32All,
568 evergreen->ps.SQ_PGM_START_PS.u32All,
569 RADEON_GEM_DOMAIN_GTT, 0, 0);
572 BEGIN_BATCH_NO_AUTOSTATE(3);
573 EVERGREEN_OUT_BATCH_REGVAL(EG_SQ_LOOP_CONST_0, 0x01000FFF);
576 pbo_const = (struct radeon_bo *)(context->fp_Constbo);
578 if(NULL != pbo_const)
580 r700SyncSurf(context, pbo_const, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
582 BEGIN_BATCH_NO_AUTOSTATE(3);
583 EVERGREEN_OUT_BATCH_REGVAL(EG_SQ_ALU_CONST_BUFFER_SIZE_PS_0, const_size / 16);
586 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
587 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_ALU_CONST_CACHE_PS_0, 1);
588 R600_OUT_BATCH(context->fp_bo_offset >> 8);
589 R600_OUT_BATCH_RELOC(0,
592 RADEON_GEM_DOMAIN_GTT, 0, 0);
599 static void evergreenSendVSresource(struct gl_context *ctx, struct radeon_state_atom *atom)
601 context_t *context = EVERGREEN_CONTEXT(ctx);
602 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
603 struct radeon_bo * pbo;
604 struct radeon_bo * pbo_const;
605 /* const size reg is in units of 16 consts */
606 int const_size = ((evergreen->vs.num_consts * 4) + 15) & ~15;
608 BATCH_LOCALS(&context->radeon);
609 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
611 pbo = (struct radeon_bo *)evergreenGetActiveVpShaderBo(GL_CONTEXT(context));
616 r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
618 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
619 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_START_VS, 1);
620 R600_OUT_BATCH(evergreen->vs.SQ_PGM_START_VS.u32All);
621 R600_OUT_BATCH_RELOC(evergreen->vs.SQ_PGM_START_VS.u32All,
623 evergreen->vs.SQ_PGM_START_VS.u32All,
624 RADEON_GEM_DOMAIN_GTT, 0, 0);
627 BEGIN_BATCH_NO_AUTOSTATE(3);
628 EVERGREEN_OUT_BATCH_REGVAL((EG_SQ_LOOP_CONST_0 + 32*1), 0x0100000F); //consts == 1
629 //EVERGREEN_OUT_BATCH_REGVAL((EG_SQ_LOOP_CONST_0 + (SQ_LOOP_CONST_vs<2)), 0x0100000F);
632 pbo_const = (struct radeon_bo *)(context->vp_Constbo);
634 if(NULL != pbo_const)
636 r700SyncSurf(context, pbo_const, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
638 BEGIN_BATCH_NO_AUTOSTATE(3);
639 EVERGREEN_OUT_BATCH_REGVAL(EG_SQ_ALU_CONST_BUFFER_SIZE_VS_0, const_size / 16);
642 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
643 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_ALU_CONST_CACHE_VS_0, 1);
644 R600_OUT_BATCH(context->vp_bo_offset >> 8);
645 R600_OUT_BATCH_RELOC(0,
648 RADEON_GEM_DOMAIN_GTT, 0, 0);
655 static void evergreenSendSQ(struct gl_context *ctx, struct radeon_state_atom *atom)
657 context_t *context = EVERGREEN_CONTEXT(ctx);
658 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
659 BATCH_LOCALS(&context->radeon);
660 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
662 evergreenSendPSresource(ctx); //16 entries now
664 BEGIN_BATCH_NO_AUTOSTATE(77);
667 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_VTX_SEMANTIC_0, 32);
668 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_0.u32All); //// // = 0x28380, // SAME
669 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_1.u32All); //// // = 0x28384, // SAME
670 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_2.u32All); //// // = 0x28388, // SAME
671 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_3.u32All); //// // = 0x2838C, // SAME
672 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_4.u32All); //// // = 0x28390, // SAME
673 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_5.u32All); //// // = 0x28394, // SAME
674 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_6.u32All); //// // = 0x28398, // SAME
675 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_7.u32All); //// // = 0x2839C, // SAME
676 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_8.u32All); //// // = 0x283A0, // SAME
677 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_9.u32All); //// // = 0x283A4, // SAME
678 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_10.u32All); //// // = 0x283A8, // SAME
679 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_11.u32All); //// // = 0x283AC, // SAME
680 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_12.u32All); //// // = 0x283B0, // SAME
681 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_13.u32All); //// // = 0x283B4, // SAME
682 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_14.u32All); //// // = 0x283B8, // SAME
683 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_15.u32All); //// // = 0x283BC, // SAME
684 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_16.u32All); //// // = 0x283C0, // SAME
685 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_17.u32All); //// // = 0x283C4, // SAME
686 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_18.u32All); //// // = 0x283C8, // SAME
687 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_19.u32All); //// // = 0x283CC, // SAME
688 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_20.u32All); //// // = 0x283D0, // SAME
689 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_21.u32All); //// // = 0x283D4, // SAME
690 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_22.u32All); //// // = 0x283D8, // SAME
691 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_23.u32All); //// // = 0x283DC, // SAME
692 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_24.u32All); //// // = 0x283E0, // SAME
693 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_25.u32All); //// // = 0x283E4, // SAME
694 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_26.u32All); //// // = 0x283E8, // SAME
695 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_27.u32All); //// // = 0x283EC, // SAME
696 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_28.u32All); //// // = 0x283F0, // SAME
697 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_29.u32All); //// // = 0x283F4, // SAME
698 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_30.u32All); //// // = 0x283F8, // SAME
699 R600_OUT_BATCH(evergreen->SQ_VTX_SEMANTIC_31.u32All); //// // = 0x283FC, // SAME
703 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_DYN_GPR_RESOURCE_LIMIT_1, 1);
704 R600_OUT_BATCH(evergreen->SQ_DYN_GPR_RESOURCE_LIMIT_1.u32All);//// // = 0x28838, //
707 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_PS, 3);
708 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_PS.u32All); //// // = 0x28844, // DIFF 0x28850
709 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_PS.u32All); //// // = 0x28848, //
710 R600_OUT_BATCH(evergreen->SQ_PGM_EXPORTS_PS.u32All); //// // = 0x2884C, // SAME 0x28854
713 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_VS, 2);
714 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_VS.u32All);//// // = 0x28860, // DIFF 0x28868
715 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_VS.u32All); //// // = 0x28864, //
718 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_GS, 2);
720 R600_OUT_BATCH(evergreen->SQ_PGM_START_GS.u32All); //// // = 0x28874, // SAME 0x2886C
722 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_GS.u32All); //// // = 0x28878, // DIFF 0x2887C
723 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_GS.u32All); //// // = 0x2887C, //
726 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_ES, 2);
728 R600_OUT_BATCH(evergreen->SQ_PGM_START_ES.u32All); //// // = 0x2888C, // SAME 0x28880
730 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_ES.u32All); //// // = 0x28890, // DIFF
731 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_ES.u32All); //// // = 0x28894, //
734 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_FS, 1);
736 R600_OUT_BATCH(evergreen->SQ_PGM_START_FS.u32All); //// // = 0x288A4, // SAME 0x28894
738 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_FS.u32All); //// // = 0x288A8, // DIFF 0x288A4
741 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_2_HS, 1);
742 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_HS.u32All);//// // = 0x288C0, //
745 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_PGM_RESOURCES_2_LS, 1);
746 R600_OUT_BATCH(evergreen->SQ_PGM_RESOURCES_2_LS.u32All); //// // = 0x288D8, //
749 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_LDS_ALLOC_PS, 1);
750 R600_OUT_BATCH(evergreen->SQ_LDS_ALLOC_PS.u32All); //// // = 0x288EC, //
753 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_ESGS_RING_ITEMSIZE, 6);
754 R600_OUT_BATCH(evergreen->SQ_ESGS_RING_ITEMSIZE.u32All); //// // = 0x28900, // SAME 0x288A8
755 R600_OUT_BATCH(evergreen->SQ_GSVS_RING_ITEMSIZE.u32All); //// // = 0x28904, // SAME 0x288AC
756 R600_OUT_BATCH(evergreen->SQ_ESTMP_RING_ITEMSIZE.u32All); //// // = 0x28908, // SAME 0x288B0
757 R600_OUT_BATCH(evergreen->SQ_GSTMP_RING_ITEMSIZE.u32All); //// // = 0x2890C, // SAME 0x288B4
758 R600_OUT_BATCH(evergreen->SQ_VSTMP_RING_ITEMSIZE.u32All); //// // = 0x28910, // SAME 0x288B8
759 R600_OUT_BATCH(evergreen->SQ_PSTMP_RING_ITEMSIZE.u32All); //// // = 0x28914, // SAME 0x288BC
762 EVERGREEN_OUT_BATCH_REGSEQ(EG_SQ_GS_VERT_ITEMSIZE, 1);
763 R600_OUT_BATCH(evergreen->SQ_GS_VERT_ITEMSIZE.u32All); //// // = 0x2891C, // SAME 0x288C8
770 static void evergreenSendSPI(struct gl_context *ctx, struct radeon_state_atom *atom)
772 context_t *context = EVERGREEN_CONTEXT(ctx);
773 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
774 BATCH_LOCALS(&context->radeon);
775 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
777 BEGIN_BATCH_NO_AUTOSTATE(59);
779 EVERGREEN_OUT_BATCH_REGSEQ(EG_SPI_VS_OUT_ID_0, 10);
780 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_0.u32All);
781 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_1.u32All);
782 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_2.u32All);
783 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_3.u32All);
784 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_4.u32All);
785 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_5.u32All);
786 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_6.u32All);
787 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_7.u32All);
788 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_8.u32All);
789 R600_OUT_BATCH(evergreen->SPI_VS_OUT_ID_9.u32All);
791 EVERGREEN_OUT_BATCH_REGSEQ(EG_SPI_PS_INPUT_CNTL_0, 45);
792 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[0].u32All);
793 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[1].u32All);
794 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[2].u32All);
795 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[3].u32All);
796 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[4].u32All);
797 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[5].u32All);
798 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[6].u32All);
799 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[7].u32All);
800 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[8].u32All);
801 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[9].u32All);
802 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[10].u32All);
803 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[11].u32All);
804 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[12].u32All);
805 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[13].u32All);
806 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[14].u32All);
807 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[15].u32All);
808 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[16].u32All);
809 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[17].u32All);
810 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[18].u32All);
811 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[19].u32All);
812 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[20].u32All);
813 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[21].u32All);
814 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[22].u32All);
815 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[23].u32All);
816 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[24].u32All);
817 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[25].u32All);
818 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[26].u32All);
819 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[27].u32All);
820 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[28].u32All);
821 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[29].u32All);
822 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[30].u32All);
823 R600_OUT_BATCH(evergreen->SPI_PS_INPUT_CNTL[31].u32All);
824 R600_OUT_BATCH(evergreen->SPI_VS_OUT_CONFIG.u32All);
825 R600_OUT_BATCH(evergreen->SPI_THREAD_GROUPING.u32All);
826 R600_OUT_BATCH(evergreen->SPI_PS_IN_CONTROL_0.u32All);
827 R600_OUT_BATCH(evergreen->SPI_PS_IN_CONTROL_1.u32All);
828 R600_OUT_BATCH(evergreen->SPI_INTERP_CONTROL_0.u32All);
829 R600_OUT_BATCH(evergreen->SPI_INPUT_Z.u32All);
830 R600_OUT_BATCH(evergreen->SPI_FOG_CNTL.u32All);
831 R600_OUT_BATCH(evergreen->SPI_BARYC_CNTL.u32All);
832 R600_OUT_BATCH(evergreen->SPI_PS_IN_CONTROL_2.u32All);
833 R600_OUT_BATCH(evergreen->SPI_COMPUTE_INPUT_CNTL.u32All);
834 R600_OUT_BATCH(evergreen->SPI_COMPUTE_NUM_THREAD_X.u32All);
835 R600_OUT_BATCH(evergreen->SPI_COMPUTE_NUM_THREAD_Y.u32All);
836 R600_OUT_BATCH(evergreen->SPI_COMPUTE_NUM_THREAD_Z.u32All);
842 static void evergreenSendSX(struct gl_context *ctx, struct radeon_state_atom *atom)
844 context_t *context = EVERGREEN_CONTEXT(ctx);
845 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
846 BATCH_LOCALS(&context->radeon);
847 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
849 BEGIN_BATCH_NO_AUTOSTATE(9);
851 EVERGREEN_OUT_BATCH_REGVAL(EG_SX_MISC, evergreen->SX_MISC.u32All);
852 EVERGREEN_OUT_BATCH_REGVAL(EG_SX_ALPHA_TEST_CONTROL, evergreen->SX_ALPHA_TEST_CONTROL.u32All);
853 EVERGREEN_OUT_BATCH_REGVAL(EG_SX_ALPHA_REF, evergreen->SX_ALPHA_REF.u32All);
860 static void evergreenSetDepthTarget(context_t *context)
862 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
863 struct radeon_renderbuffer *rrb;
864 unsigned int nPitchInPixel, height, offtostencil;
866 rrb = radeon_get_depthbuffer(&context->radeon);
872 EVERGREEN_STATECHANGE(context, db);
874 evergreen->DB_DEPTH_SIZE.u32All = 0;
876 nPitchInPixel = rrb->pitch/rrb->cpp;
878 if (context->radeon.radeonScreen->driScreen->dri2.enabled)
880 height = rrb->base.Height;
884 height = context->radeon.radeonScreen->driScreen->fbHeight;
887 SETfield(evergreen->DB_DEPTH_SIZE.u32All, (nPitchInPixel/8)-1,
888 EG_DB_DEPTH_SIZE__PITCH_TILE_MAX_shift,
889 EG_DB_DEPTH_SIZE__PITCH_TILE_MAX_mask);
890 SETfield(evergreen->DB_DEPTH_SIZE.u32All, (height/8)-1,
891 EG_DB_DEPTH_SIZE__HEIGHT_TILE_MAX_shift,
892 EG_DB_DEPTH_SIZE__HEIGHT_TILE_MAX_mask);
893 evergreen->DB_DEPTH_SLICE.u32All = ( (nPitchInPixel * height)/64 )-1;
897 SETfield(evergreen->DB_Z_INFO.u32All, EG_Z_24,
898 EG_DB_Z_INFO__FORMAT_shift,
899 EG_DB_Z_INFO__FORMAT_mask);
903 SETfield(evergreen->DB_Z_INFO.u32All, EG_Z_16,
904 EG_DB_Z_INFO__FORMAT_shift,
905 EG_DB_Z_INFO__FORMAT_mask);
907 SETfield(evergreen->DB_Z_INFO.u32All, ARRAY_1D_TILED_THIN1,
908 EG_DB_Z_INFO__ARRAY_MODE_shift,
909 EG_DB_Z_INFO__ARRAY_MODE_mask);
912 offtostencil = ((height * rrb->pitch) + 255) & ~255;
913 evergreen->DB_STENCIL_WRITE_BASE.u32All = offtostencil >> 8;
914 evergreen->DB_STENCIL_READ_BASE.u32All = offtostencil >> 8;
918 static void evergreenSendDB(struct gl_context *ctx, struct radeon_state_atom *atom)
920 context_t *context = EVERGREEN_CONTEXT(ctx);
921 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
922 struct radeon_renderbuffer *rrb;
923 BATCH_LOCALS(&context->radeon);
924 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
926 evergreenSetDepthTarget(context);
929 BEGIN_BATCH_NO_AUTOSTATE(7);
930 EVERGREEN_OUT_BATCH_REGSEQ(EG_DB_RENDER_CONTROL, 5);
931 R600_OUT_BATCH(evergreen->DB_RENDER_CONTROL.u32All);
932 R600_OUT_BATCH(evergreen->DB_COUNT_CONTROL.u32All);
933 R600_OUT_BATCH(evergreen->DB_DEPTH_VIEW.u32All);
934 R600_OUT_BATCH(evergreen->DB_RENDER_OVERRIDE.u32All);
935 R600_OUT_BATCH(evergreen->DB_RENDER_OVERRIDE2.u32All);
939 BEGIN_BATCH_NO_AUTOSTATE(4);
940 EVERGREEN_OUT_BATCH_REGSEQ(EG_DB_STENCIL_CLEAR, 2);
941 R600_OUT_BATCH(evergreen->DB_STENCIL_CLEAR.u32All);
942 R600_OUT_BATCH(evergreen->DB_DEPTH_CLEAR.u32All);
946 BEGIN_BATCH_NO_AUTOSTATE(4);
947 EVERGREEN_OUT_BATCH_REGSEQ(EG_DB_DEPTH_SIZE, 2);
948 R600_OUT_BATCH(evergreen->DB_DEPTH_SIZE.u32All);
949 R600_OUT_BATCH(evergreen->DB_DEPTH_SLICE.u32All);
953 BEGIN_BATCH_NO_AUTOSTATE(3);
954 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_DEPTH_CONTROL, evergreen->DB_DEPTH_CONTROL.u32All);
958 BEGIN_BATCH_NO_AUTOSTATE(3);
959 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_SHADER_CONTROL, evergreen->DB_SHADER_CONTROL.u32All);
963 BEGIN_BATCH_NO_AUTOSTATE(5);
964 EVERGREEN_OUT_BATCH_REGSEQ(EG_DB_SRESULTS_COMPARE_STATE0, 3);
965 R600_OUT_BATCH(evergreen->DB_SRESULTS_COMPARE_STATE0.u32All);
966 R600_OUT_BATCH(evergreen->DB_SRESULTS_COMPARE_STATE1.u32All);
967 R600_OUT_BATCH(evergreen->DB_PRELOAD_CONTROL.u32All);
971 BEGIN_BATCH_NO_AUTOSTATE(3);
972 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_ALPHA_TO_MASK, evergreen->DB_ALPHA_TO_MASK.u32All);
975 rrb = radeon_get_depthbuffer(&context->radeon);
977 if( (rrb != NULL) && (rrb->bo != NULL) )
980 /* make the hw happy */
981 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
982 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_HTILE_DATA_BASE, evergreen->DB_HTILE_DATA_BASE.u32All);
983 R600_OUT_BATCH_RELOC(evergreen->DB_HTILE_DATA_BASE.u32All,
985 evergreen->DB_HTILE_DATA_BASE.u32All,
986 0, RADEON_GEM_DOMAIN_VRAM, 0);
990 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
991 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_Z_INFO, evergreen->DB_Z_INFO.u32All);
992 R600_OUT_BATCH_RELOC(evergreen->DB_Z_INFO.u32All,
994 evergreen->DB_Z_INFO.u32All,
995 0, RADEON_GEM_DOMAIN_VRAM, 0);
999 if((evergreen->DB_DEPTH_CONTROL.u32All & Z_ENABLE_bit) > 0)
1001 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1002 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_Z_READ_BASE, evergreen->DB_Z_READ_BASE.u32All);
1003 R600_OUT_BATCH_RELOC(evergreen->DB_Z_READ_BASE.u32All,
1005 evergreen->DB_Z_READ_BASE.u32All,
1006 0, RADEON_GEM_DOMAIN_VRAM, 0);
1010 if((evergreen->DB_DEPTH_CONTROL.u32All & Z_WRITE_ENABLE_bit) > 0)
1012 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1013 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_Z_WRITE_BASE, evergreen->DB_Z_READ_BASE.u32All);
1014 R600_OUT_BATCH_RELOC(evergreen->DB_Z_WRITE_BASE.u32All,
1016 evergreen->DB_Z_WRITE_BASE.u32All,
1017 0, RADEON_GEM_DOMAIN_VRAM, 0);
1022 if (ctx->DrawBuffer)
1024 rrb = radeon_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
1026 if((rrb != NULL) && (rrb->bo != NULL))
1029 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1030 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_STENCIL_INFO, evergreen->DB_STENCIL_INFO.u32All);
1031 R600_OUT_BATCH_RELOC(evergreen->DB_STENCIL_INFO.u32All,
1033 evergreen->DB_STENCIL_INFO.u32All,
1034 0, RADEON_GEM_DOMAIN_VRAM, 0);
1038 BEGIN_BATCH_NO_AUTOSTATE(4);
1039 R600_OUT_BATCH_REGSEQ(DB_STENCILREFMASK, 2);
1040 R600_OUT_BATCH(evergreen->DB_STENCILREFMASK.u32All);
1041 R600_OUT_BATCH(evergreen->DB_STENCILREFMASK_BF.u32All);
1043 //------------------------
1046 if((evergreen->DB_DEPTH_CONTROL.u32All & STENCIL_ENABLE_bit) > 0)
1049 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1050 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_STENCIL_READ_BASE, evergreen->DB_STENCIL_READ_BASE.u32All);
1051 R600_OUT_BATCH_RELOC(evergreen->DB_STENCIL_READ_BASE.u32All,
1053 evergreen->DB_STENCIL_READ_BASE.u32All,
1054 0, RADEON_GEM_DOMAIN_VRAM, 0);
1057 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1058 EVERGREEN_OUT_BATCH_REGVAL(EG_DB_STENCIL_WRITE_BASE, evergreen->DB_STENCIL_WRITE_BASE.u32All);
1059 R600_OUT_BATCH_RELOC(evergreen->DB_STENCIL_WRITE_BASE.u32All,
1061 evergreen->DB_STENCIL_WRITE_BASE.u32All,
1062 0, RADEON_GEM_DOMAIN_VRAM, 0);
1071 static void evergreenSetRenderTarget(context_t *context, int id)
1073 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
1074 uint32_t format = COLOR_8_8_8_8, comp_swap = SWAP_ALT, number_type = NUMBER_UNORM, source_format = 1;
1075 struct radeon_renderbuffer *rrb;
1076 unsigned int nPitchInPixel, height;
1078 rrb = radeon_get_colorbuffer(&context->radeon);
1079 if (!rrb || !rrb->bo) {
1083 EVERGREEN_STATECHANGE(context, cb);
1086 evergreen->render_target[id].CB_COLOR0_BASE.u32All = context->radeon.state.color.draw_offset / 256;
1089 nPitchInPixel = rrb->pitch/rrb->cpp;
1091 if (context->radeon.radeonScreen->driScreen->dri2.enabled)
1093 height = rrb->base.Height;
1097 height = context->radeon.radeonScreen->driScreen->fbHeight;
1100 SETfield(evergreen->render_target[id].CB_COLOR0_PITCH.u32All, (nPitchInPixel/8)-1,
1101 EG_CB_COLOR0_PITCH__TILE_MAX_shift,
1102 EG_CB_COLOR0_PITCH__TILE_MAX_mask);
1105 SETfield(evergreen->render_target[id].CB_COLOR0_SLICE.u32All,
1106 ( (nPitchInPixel * height)/64 )-1,
1107 EG_CB_COLOR0_SLICE__TILE_MAX_shift,
1108 EG_CB_COLOR0_SLICE__TILE_MAX_mask);
1110 /* CB_COLOR0_ATTRIB */ /* TODO : for z clear, this should be set to 0 */
1111 SETbit(evergreen->render_target[id].CB_COLOR0_ATTRIB.u32All,
1112 EG_CB_COLOR0_ATTRIB__NON_DISP_TILING_ORDER_bit);
1114 /* CB_COLOR0_INFO */
1115 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1117 EG_CB_COLOR0_INFO__ENDIAN_shift,
1118 EG_CB_COLOR0_INFO__ENDIAN_mask);
1119 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1120 ARRAY_LINEAR_GENERAL,
1121 EG_CB_COLOR0_INFO__ARRAY_MODE_shift,
1122 EG_CB_COLOR0_INFO__ARRAY_MODE_mask);
1124 switch (rrb->base.Format) {
1125 case MESA_FORMAT_RGBA8888:
1126 format = COLOR_8_8_8_8;
1127 comp_swap = SWAP_STD_REV;
1128 number_type = NUMBER_UNORM;
1131 case MESA_FORMAT_SIGNED_RGBA8888:
1132 format = COLOR_8_8_8_8;
1133 comp_swap = SWAP_STD_REV;
1134 number_type = NUMBER_SNORM;
1137 case MESA_FORMAT_RGBA8888_REV:
1138 format = COLOR_8_8_8_8;
1139 comp_swap = SWAP_STD;
1140 number_type = NUMBER_UNORM;
1143 case MESA_FORMAT_SIGNED_RGBA8888_REV:
1144 format = COLOR_8_8_8_8;
1145 comp_swap = SWAP_STD;
1146 number_type = NUMBER_SNORM;
1149 case MESA_FORMAT_ARGB8888:
1150 case MESA_FORMAT_XRGB8888:
1151 format = COLOR_8_8_8_8;
1152 comp_swap = SWAP_ALT;
1153 number_type = NUMBER_UNORM;
1156 case MESA_FORMAT_ARGB8888_REV:
1157 case MESA_FORMAT_XRGB8888_REV:
1158 format = COLOR_8_8_8_8;
1159 comp_swap = SWAP_ALT_REV;
1160 number_type = NUMBER_UNORM;
1163 case MESA_FORMAT_RGB565:
1164 format = COLOR_5_6_5;
1165 comp_swap = SWAP_STD_REV;
1166 number_type = NUMBER_UNORM;
1169 case MESA_FORMAT_RGB565_REV:
1170 format = COLOR_5_6_5;
1171 comp_swap = SWAP_STD;
1172 number_type = NUMBER_UNORM;
1175 case MESA_FORMAT_ARGB4444:
1176 format = COLOR_4_4_4_4;
1177 comp_swap = SWAP_ALT;
1178 number_type = NUMBER_UNORM;
1181 case MESA_FORMAT_ARGB4444_REV:
1182 format = COLOR_4_4_4_4;
1183 comp_swap = SWAP_ALT_REV;
1184 number_type = NUMBER_UNORM;
1187 case MESA_FORMAT_ARGB1555:
1188 format = COLOR_1_5_5_5;
1189 comp_swap = SWAP_ALT;
1190 number_type = NUMBER_UNORM;
1193 case MESA_FORMAT_ARGB1555_REV:
1194 format = COLOR_1_5_5_5;
1195 comp_swap = SWAP_ALT_REV;
1196 number_type = NUMBER_UNORM;
1199 case MESA_FORMAT_AL88:
1201 comp_swap = SWAP_STD;
1202 number_type = NUMBER_UNORM;
1205 case MESA_FORMAT_AL88_REV:
1207 comp_swap = SWAP_STD_REV;
1208 number_type = NUMBER_UNORM;
1211 case MESA_FORMAT_RGB332:
1212 format = COLOR_3_3_2;
1213 comp_swap = SWAP_STD_REV;
1214 number_type = NUMBER_UNORM;
1217 case MESA_FORMAT_A8:
1219 comp_swap = SWAP_ALT_REV;
1220 number_type = NUMBER_UNORM;
1223 case MESA_FORMAT_I8:
1225 comp_swap = SWAP_STD;
1226 number_type = NUMBER_UNORM;
1229 case MESA_FORMAT_L8:
1231 comp_swap = SWAP_ALT;
1232 number_type = NUMBER_UNORM;
1235 case MESA_FORMAT_RGBA_FLOAT32:
1236 format = COLOR_32_32_32_32_FLOAT;
1237 comp_swap = SWAP_STD_REV;
1238 number_type = NUMBER_FLOAT;
1241 case MESA_FORMAT_RGBA_FLOAT16:
1242 format = COLOR_16_16_16_16_FLOAT;
1243 comp_swap = SWAP_STD_REV;
1244 number_type = NUMBER_FLOAT;
1247 case MESA_FORMAT_ALPHA_FLOAT32:
1248 format = COLOR_32_FLOAT;
1249 comp_swap = SWAP_ALT_REV;
1250 number_type = NUMBER_FLOAT;
1253 case MESA_FORMAT_ALPHA_FLOAT16:
1254 format = COLOR_16_FLOAT;
1255 comp_swap = SWAP_ALT_REV;
1256 number_type = NUMBER_FLOAT;
1259 case MESA_FORMAT_LUMINANCE_FLOAT32:
1260 format = COLOR_32_FLOAT;
1261 comp_swap = SWAP_ALT;
1262 number_type = NUMBER_FLOAT;
1265 case MESA_FORMAT_LUMINANCE_FLOAT16:
1266 format = COLOR_16_FLOAT;
1267 comp_swap = SWAP_ALT;
1268 number_type = NUMBER_FLOAT;
1271 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
1272 format = COLOR_32_32_FLOAT;
1273 comp_swap = SWAP_ALT_REV;
1274 number_type = NUMBER_FLOAT;
1277 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
1278 format = COLOR_16_16_FLOAT;
1279 comp_swap = SWAP_ALT_REV;
1280 number_type = NUMBER_FLOAT;
1283 case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */
1284 format = COLOR_32_FLOAT;
1285 comp_swap = SWAP_STD;
1286 number_type = NUMBER_FLOAT;
1289 case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */
1290 format = COLOR_16_FLOAT;
1291 comp_swap = SWAP_STD;
1292 number_type = NUMBER_UNORM;
1295 case MESA_FORMAT_X8_Z24:
1296 case MESA_FORMAT_S8_Z24:
1297 format = COLOR_8_24;
1298 comp_swap = SWAP_STD;
1299 number_type = NUMBER_UNORM;
1300 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1301 ARRAY_1D_TILED_THIN1,
1302 EG_CB_COLOR0_INFO__ARRAY_MODE_shift,
1303 EG_CB_COLOR0_INFO__ARRAY_MODE_mask);
1306 case MESA_FORMAT_Z24_S8:
1307 format = COLOR_24_8;
1308 comp_swap = SWAP_STD;
1309 number_type = NUMBER_UNORM;
1310 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1311 ARRAY_1D_TILED_THIN1,
1312 EG_CB_COLOR0_INFO__ARRAY_MODE_shift,
1313 EG_CB_COLOR0_INFO__ARRAY_MODE_mask);
1316 case MESA_FORMAT_Z16:
1318 comp_swap = SWAP_STD;
1319 number_type = NUMBER_UNORM;
1320 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1321 ARRAY_1D_TILED_THIN1,
1322 EG_CB_COLOR0_INFO__ARRAY_MODE_shift,
1323 EG_CB_COLOR0_INFO__ARRAY_MODE_mask);
1326 case MESA_FORMAT_Z32:
1328 comp_swap = SWAP_STD;
1329 number_type = NUMBER_UNORM;
1330 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1331 ARRAY_1D_TILED_THIN1,
1332 EG_CB_COLOR0_INFO__ARRAY_MODE_shift,
1333 EG_CB_COLOR0_INFO__ARRAY_MODE_mask);
1336 case MESA_FORMAT_SARGB8:
1337 format = COLOR_8_8_8_8;
1338 comp_swap = SWAP_ALT;
1339 number_type = NUMBER_SRGB;
1342 case MESA_FORMAT_SLA8:
1344 comp_swap = SWAP_ALT_REV;
1345 number_type = NUMBER_SRGB;
1348 case MESA_FORMAT_SL8:
1350 comp_swap = SWAP_ALT_REV;
1351 number_type = NUMBER_SRGB;
1355 _mesa_problem(context->radeon.glCtx, "unexpected format in evergreenSetRenderTarget()");
1359 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1361 EG_CB_COLOR0_INFO__FORMAT_shift,
1362 EG_CB_COLOR0_INFO__FORMAT_mask);
1363 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1365 EG_CB_COLOR0_INFO__COMP_SWAP_shift,
1366 EG_CB_COLOR0_INFO__COMP_SWAP_mask);
1367 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1369 EG_CB_COLOR0_INFO__NUMBER_TYPE_shift,
1370 EG_CB_COLOR0_INFO__NUMBER_TYPE_mask);
1371 SETfield(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1373 EG_CB_COLOR0_INFO__SOURCE_FORMAT_shift,
1374 EG_CB_COLOR0_INFO__SOURCE_FORMAT_mask);
1375 SETbit(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1376 EG_CB_COLOR0_INFO__BLEND_CLAMP_bit);
1378 evergreen->render_target[id].CB_COLOR0_VIEW.u32All = 0;
1379 evergreen->render_target[id].CB_COLOR0_CMASK.u32All = 0;
1380 evergreen->render_target[id].CB_COLOR0_FMASK.u32All = 0;
1381 evergreen->render_target[id].CB_COLOR0_FMASK_SLICE.u32All = 0;
1383 evergreen->render_target[id].enabled = GL_TRUE;
1386 static void evergreenSendCB(struct gl_context *ctx, struct radeon_state_atom *atom)
1388 context_t *context = EVERGREEN_CONTEXT(ctx);
1389 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
1390 struct radeon_renderbuffer *rrb;
1391 BATCH_LOCALS(&context->radeon);
1393 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
1395 rrb = radeon_get_colorbuffer(&context->radeon);
1396 if (!rrb || !rrb->bo) {
1400 evergreenSetRenderTarget(context, 0);
1402 if (!evergreen->render_target[id].enabled)
1405 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1406 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_COLOR0_BASE + (4 * id), 1);
1407 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_BASE.u32All);
1408 R600_OUT_BATCH_RELOC(evergreen->render_target[id].CB_COLOR0_BASE.u32All,
1410 evergreen->render_target[id].CB_COLOR0_BASE.u32All,
1411 0, RADEON_GEM_DOMAIN_VRAM, 0);
1414 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1415 EVERGREEN_OUT_BATCH_REGVAL(EG_CB_COLOR0_INFO, evergreen->render_target[id].CB_COLOR0_INFO.u32All);
1416 R600_OUT_BATCH_RELOC(evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1418 evergreen->render_target[id].CB_COLOR0_INFO.u32All,
1419 0, RADEON_GEM_DOMAIN_VRAM, 0);
1422 BEGIN_BATCH_NO_AUTOSTATE(5);
1423 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_COLOR0_PITCH, 3);
1424 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_PITCH.u32All);
1425 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_SLICE.u32All);
1426 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_VIEW.u32All);
1429 BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
1430 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_COLOR0_ATTRIB, 1);
1431 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_ATTRIB.u32All);
1432 R600_OUT_BATCH_RELOC(0,
1435 0, RADEON_GEM_DOMAIN_VRAM, 0);
1438 BEGIN_BATCH_NO_AUTOSTATE(3);
1439 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_COLOR0_DIM, 1);
1440 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_DIM.u32All);
1442 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_CMASK.u32All);
1443 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_CMASK_SLICE.u32All);
1444 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_FMASK.u32All);
1445 R600_OUT_BATCH(evergreen->render_target[id].CB_COLOR0_FMASK_SLICE.u32All);
1449 BEGIN_BATCH_NO_AUTOSTATE(4);
1450 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_TARGET_MASK, 2);
1451 R600_OUT_BATCH(evergreen->CB_TARGET_MASK.u32All);
1452 R600_OUT_BATCH(evergreen->CB_SHADER_MASK.u32All);
1455 BEGIN_BATCH_NO_AUTOSTATE(6);
1456 EVERGREEN_OUT_BATCH_REGSEQ(EG_CB_BLEND_RED, 4);
1457 R600_OUT_BATCH(evergreen->CB_BLEND_RED.u32All);
1458 R600_OUT_BATCH(evergreen->CB_BLEND_GREEN.u32All);
1459 R600_OUT_BATCH(evergreen->CB_BLEND_BLUE.u32All);
1460 R600_OUT_BATCH(evergreen->CB_BLEND_ALPHA.u32All);
1463 BEGIN_BATCH_NO_AUTOSTATE(6);
1464 EVERGREEN_OUT_BATCH_REGVAL(EG_CB_BLEND0_CONTROL, evergreen->CB_BLEND0_CONTROL.u32All);
1465 EVERGREEN_OUT_BATCH_REGVAL(EG_CB_COLOR_CONTROL, evergreen->CB_COLOR_CONTROL.u32All);
1471 static void evergreenSendVGT(struct gl_context *ctx, struct radeon_state_atom *atom)
1473 context_t *context = EVERGREEN_CONTEXT(ctx);
1474 EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
1475 BATCH_LOCALS(&context->radeon);
1476 radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
1483 BEGIN_BATCH_NO_AUTOSTATE(5);
1484 EVERGREEN_OUT_BATCH_REGSEQ(EG_VGT_MAX_VTX_INDX, 3);
1485 R600_OUT_BATCH(evergreen->VGT_MAX_VTX_INDX.u32All);
1486 R600_OUT_BATCH(evergreen->VGT_MIN_VTX_INDX.u32All);
1487 R600_OUT_BATCH(evergreen->VGT_INDX_OFFSET.u32All);
1490 BEGIN_BATCH_NO_AUTOSTATE(6);
1491 EVERGREEN_OUT_BATCH_REGVAL(EG_VGT_OUTPUT_PATH_CNTL, evergreen->VGT_OUTPUT_PATH_CNTL.u32All);
1493 EVERGREEN_OUT_BATCH_REGVAL(EG_VGT_GS_MODE, evergreen->VGT_GS_MODE.u32All);
1496 BEGIN_BATCH_NO_AUTOSTATE(3);
1497 EVERGREEN_OUT_BATCH_REGSEQ(EG_VGT_PRIMITIVEID_EN, 1);
1498 R600_OUT_BATCH(evergreen->VGT_PRIMITIVEID_EN.u32All);
1501 BEGIN_BATCH_NO_AUTOSTATE(4);
1502 EVERGREEN_OUT_BATCH_REGSEQ(EG_VGT_INSTANCE_STEP_RATE_0, 2);
1503 R600_OUT_BATCH(evergreen->VGT_INSTANCE_STEP_RATE_0.u32All);
1504 R600_OUT_BATCH(evergreen->VGT_INSTANCE_STEP_RATE_1.u32All);
1507 BEGIN_BATCH_NO_AUTOSTATE(4);
1508 EVERGREEN_OUT_BATCH_REGSEQ(EG_VGT_REUSE_OFF, 2);
1509 R600_OUT_BATCH(evergreen->VGT_REUSE_OFF.u32All);
1510 R600_OUT_BATCH(evergreen->VGT_VTX_CNT_EN.u32All);
1513 BEGIN_BATCH_NO_AUTOSTATE(3);
1514 EVERGREEN_OUT_BATCH_REGVAL(EG_VGT_SHADER_STAGES_EN, evergreen->VGT_SHADER_STAGES_EN.u32All);
1517 BEGIN_BATCH_NO_AUTOSTATE(4);
1518 EVERGREEN_OUT_BATCH_REGSEQ(EG_VGT_STRMOUT_CONFIG, 2);
1519 R600_OUT_BATCH(evergreen->VGT_STRMOUT_CONFIG.u32All);
1520 R600_OUT_BATCH(evergreen->VGT_STRMOUT_BUFFER_CONFIG.u32All);
1526 void evergreenInitAtoms(context_t *context)
1528 radeon_print(RADEON_STATE, RADEON_NORMAL, "%s %p\n", __func__, context);
1529 context->radeon.hw.max_state_size = 10 + 5 + 14 + 3; /* start 3d, idle, cb/db flush, 3 for time stamp */
1531 /* Setup the atom linked list */
1532 make_empty_list(&context->radeon.hw.atomlist);
1533 context->radeon.hw.atomlist.name = "atom-list";
1535 EVERGREEN_ALLOC_STATE(init, always, 19, evergreenSendSQConfig);
1536 EVERGREEN_ALLOC_STATE(vtx, evergreen_vtx, (VERT_ATTRIB_MAX * 12), evergreenSendVTX);
1537 EVERGREEN_ALLOC_STATE(pa, always, 124, evergreenSendPA);
1538 EVERGREEN_ALLOC_STATE(tp, always, 0, evergreenSendTP);
1539 EVERGREEN_ALLOC_STATE(sq, always, 86, evergreenSendSQ); /* 85 */
1540 EVERGREEN_ALLOC_STATE(vs, always, 16, evergreenSendVSresource);
1541 EVERGREEN_ALLOC_STATE(spi, always, 59, evergreenSendSPI);
1542 EVERGREEN_ALLOC_STATE(sx, always, 9, evergreenSendSX);
1543 EVERGREEN_ALLOC_STATE(tx, evergreen_tx, (R700_TEXTURE_NUMBERUNITS * (21+5) + 6), evergreenSendTexState); /* 21 for resource, 5 for sampler */
1544 EVERGREEN_ALLOC_STATE(db, always, 69, evergreenSendDB);
1545 EVERGREEN_ALLOC_STATE(cb, always, 37, evergreenSendCB);
1546 EVERGREEN_ALLOC_STATE(vgt, always, 29, evergreenSendVGT);
1548 evergreen_init_query_stateobj(&context->radeon, 6 * 2);
1550 context->radeon.hw.is_dirty = GL_TRUE;
1551 context->radeon.hw.all_dirty = GL_TRUE;