intel: Drop batchbuffer cliprect_mode tracking
[mesa.git] / src / mesa / drivers / dri / i915 / i915_vtbl.c
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29
30 #include "main/glheader.h"
31 #include "main/mtypes.h"
32 #include "main/imports.h"
33 #include "main/macros.h"
34 #include "main/colormac.h"
35
36 #include "tnl/t_context.h"
37 #include "tnl/t_vertex.h"
38
39 #include "intel_batchbuffer.h"
40 #include "intel_tex.h"
41 #include "intel_regions.h"
42 #include "intel_tris.h"
43 #include "intel_fbo.h"
44 #include "intel_chipset.h"
45
46 #include "i915_reg.h"
47 #include "i915_context.h"
48
49 #include "glapi/glapi.h"
50
51 static void
52 i915_render_prevalidate(struct intel_context *intel)
53 {
54 struct i915_context *i915 = i915_context(&intel->ctx);
55
56 i915ValidateFragmentProgram(i915);
57 }
58
59 static void
60 i915_render_start(struct intel_context *intel)
61 {
62 }
63
64
65 static void
66 i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim)
67 {
68 struct i915_context *i915 = i915_context(&intel->ctx);
69 GLuint st1 = i915->state.Stipple[I915_STPREG_ST1];
70
71 st1 &= ~ST1_ENABLE;
72
73 switch (rprim) {
74 case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
75 case GL_TRIANGLES:
76 if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple)
77 st1 |= ST1_ENABLE;
78 break;
79 case GL_LINES:
80 case GL_POINTS:
81 default:
82 break;
83 }
84
85 i915->intel.reduced_primitive = rprim;
86
87 if (st1 != i915->state.Stipple[I915_STPREG_ST1]) {
88 INTEL_FIREVERTICES(intel);
89
90 I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE);
91 i915->state.Stipple[I915_STPREG_ST1] = st1;
92 }
93 }
94
95
96 /* Pull apart the vertex format registers and figure out how large a
97 * vertex is supposed to be.
98 */
99 static GLboolean
100 i915_check_vertex_size(struct intel_context *intel, GLuint expected)
101 {
102 struct i915_context *i915 = i915_context(&intel->ctx);
103 int lis2 = i915->current->Ctx[I915_CTXREG_LIS2];
104 int lis4 = i915->current->Ctx[I915_CTXREG_LIS4];
105 int i, sz = 0;
106
107 switch (lis4 & S4_VFMT_XYZW_MASK) {
108 case S4_VFMT_XY:
109 sz = 2;
110 break;
111 case S4_VFMT_XYZ:
112 sz = 3;
113 break;
114 case S4_VFMT_XYW:
115 sz = 3;
116 break;
117 case S4_VFMT_XYZW:
118 sz = 4;
119 break;
120 default:
121 fprintf(stderr, "no xyzw specified\n");
122 return 0;
123 }
124
125 if (lis4 & S4_VFMT_SPEC_FOG)
126 sz++;
127 if (lis4 & S4_VFMT_COLOR)
128 sz++;
129 if (lis4 & S4_VFMT_DEPTH_OFFSET)
130 sz++;
131 if (lis4 & S4_VFMT_POINT_WIDTH)
132 sz++;
133 if (lis4 & S4_VFMT_FOG_PARAM)
134 sz++;
135
136 for (i = 0; i < 8; i++) {
137 switch (lis2 & S2_TEXCOORD_FMT0_MASK) {
138 case TEXCOORDFMT_2D:
139 sz += 2;
140 break;
141 case TEXCOORDFMT_3D:
142 sz += 3;
143 break;
144 case TEXCOORDFMT_4D:
145 sz += 4;
146 break;
147 case TEXCOORDFMT_1D:
148 sz += 1;
149 break;
150 case TEXCOORDFMT_2D_16:
151 sz += 1;
152 break;
153 case TEXCOORDFMT_4D_16:
154 sz += 2;
155 break;
156 case TEXCOORDFMT_NOT_PRESENT:
157 break;
158 default:
159 fprintf(stderr, "bad texcoord fmt %d\n", i);
160 return GL_FALSE;
161 }
162 lis2 >>= S2_TEXCOORD_FMT1_SHIFT;
163 }
164
165 if (sz != expected)
166 fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
167
168 return sz == expected;
169 }
170
171
172 static void
173 i915_emit_invarient_state(struct intel_context *intel)
174 {
175 BATCH_LOCALS;
176
177 BEGIN_BATCH(17);
178
179 OUT_BATCH(_3DSTATE_AA_CMD |
180 AA_LINE_ECAAR_WIDTH_ENABLE |
181 AA_LINE_ECAAR_WIDTH_1_0 |
182 AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0);
183
184 OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
185 OUT_BATCH(0);
186
187 OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
188 OUT_BATCH(0);
189
190 OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
191 OUT_BATCH(0);
192
193 /* Don't support texture crossbar yet */
194 OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS |
195 CSB_TCB(0, 0) |
196 CSB_TCB(1, 1) |
197 CSB_TCB(2, 2) |
198 CSB_TCB(3, 3) |
199 CSB_TCB(4, 4) | CSB_TCB(5, 5) | CSB_TCB(6, 6) | CSB_TCB(7, 7));
200
201 /* Need to initialize this to zero.
202 */
203 OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0));
204 OUT_BATCH(0);
205
206 /* XXX: Use this */
207 OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
208
209 OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
210 OUT_BATCH(0);
211 OUT_BATCH(0);
212
213 OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
214
215 OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */
216 OUT_BATCH(0);
217
218 ADVANCE_BATCH();
219 }
220
221
222 #define emit(intel, state, size ) \
223 intel_batchbuffer_data(intel->batch, state, size)
224
225 static GLuint
226 get_dirty(struct i915_hw_state *state)
227 {
228 GLuint dirty;
229
230 /* Workaround the multitex hang - if one texture unit state is
231 * modified, emit all texture units.
232 */
233 dirty = state->active & ~state->emitted;
234 if (dirty & I915_UPLOAD_TEX_ALL)
235 state->emitted &= ~I915_UPLOAD_TEX_ALL;
236 dirty = state->active & ~state->emitted;
237 return dirty;
238 }
239
240
241 static GLuint
242 get_state_size(struct i915_hw_state *state)
243 {
244 GLuint dirty = get_dirty(state);
245 GLuint i;
246 GLuint sz = 0;
247
248 if (dirty & I915_UPLOAD_INVARIENT)
249 sz += 30 * 4;
250
251 if (dirty & I915_UPLOAD_RASTER_RULES)
252 sz += sizeof(state->RasterRules);
253
254 if (dirty & I915_UPLOAD_CTX)
255 sz += sizeof(state->Ctx);
256
257 if (dirty & I915_UPLOAD_BUFFERS)
258 sz += sizeof(state->Buffer);
259
260 if (dirty & I915_UPLOAD_STIPPLE)
261 sz += sizeof(state->Stipple);
262
263 if (dirty & I915_UPLOAD_FOG)
264 sz += sizeof(state->Fog);
265
266 if (dirty & I915_UPLOAD_TEX_ALL) {
267 int nr = 0;
268 for (i = 0; i < I915_TEX_UNITS; i++)
269 if (dirty & I915_UPLOAD_TEX(i))
270 nr++;
271
272 sz += (2 + nr * 3) * sizeof(GLuint) * 2;
273 }
274
275 if (dirty & I915_UPLOAD_CONSTANTS)
276 sz += state->ConstantSize * sizeof(GLuint);
277
278 if (dirty & I915_UPLOAD_PROGRAM)
279 sz += state->ProgramSize * sizeof(GLuint);
280
281 return sz;
282 }
283
284 /* Push the state into the sarea and/or texture memory.
285 */
286 static void
287 i915_emit_state(struct intel_context *intel)
288 {
289 struct i915_context *i915 = i915_context(&intel->ctx);
290 struct i915_hw_state *state = i915->current;
291 int i, count, aper_count;
292 GLuint dirty;
293 dri_bo *aper_array[3 + I915_TEX_UNITS];
294 GET_CURRENT_CONTEXT(ctx);
295 BATCH_LOCALS;
296
297 /* We don't hold the lock at this point, so want to make sure that
298 * there won't be a buffer wrap between the state emits and the primitive
299 * emit header.
300 *
301 * It might be better to talk about explicit places where
302 * scheduling is allowed, rather than assume that it is whenever a
303 * batchbuffer fills up.
304 */
305 intel_batchbuffer_require_space(intel->batch,
306 get_state_size(state) + INTEL_PRIM_EMIT_SIZE);
307 count = 0;
308 again:
309 aper_count = 0;
310 dirty = get_dirty(state);
311
312 aper_array[aper_count++] = intel->batch->buf;
313 if (dirty & I915_UPLOAD_BUFFERS) {
314 aper_array[aper_count++] = state->draw_region->buffer;
315 if (state->depth_region)
316 aper_array[aper_count++] = state->depth_region->buffer;
317 }
318
319 if (dirty & I915_UPLOAD_TEX_ALL) {
320 for (i = 0; i < I915_TEX_UNITS; i++) {
321 if (dirty & I915_UPLOAD_TEX(i)) {
322 if (state->tex_buffer[i]) {
323 aper_array[aper_count++] = state->tex_buffer[i];
324 }
325 }
326 }
327 }
328
329 if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) {
330 if (count == 0) {
331 count++;
332 intel_batchbuffer_flush(intel->batch);
333 goto again;
334 } else {
335 _mesa_error(ctx, GL_OUT_OF_MEMORY, "i915 emit state");
336 assert(0);
337 }
338 }
339
340 /* work out list of buffers to emit */
341
342 /* Do this here as we may have flushed the batchbuffer above,
343 * causing more state to be dirty!
344 */
345 dirty = get_dirty(state);
346 state->emitted |= dirty;
347 assert(get_dirty(state) == 0);
348
349 if (INTEL_DEBUG & DEBUG_STATE)
350 fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty);
351
352 if (dirty & I915_UPLOAD_INVARIENT) {
353 if (INTEL_DEBUG & DEBUG_STATE)
354 fprintf(stderr, "I915_UPLOAD_INVARIENT:\n");
355 i915_emit_invarient_state(intel);
356 }
357
358 if (dirty & I915_UPLOAD_RASTER_RULES) {
359 if (INTEL_DEBUG & DEBUG_STATE)
360 fprintf(stderr, "I915_UPLOAD_RASTER_RULES:\n");
361 emit(intel, state->RasterRules, sizeof(state->RasterRules));
362 }
363
364 if (dirty & I915_UPLOAD_CTX) {
365 if (INTEL_DEBUG & DEBUG_STATE)
366 fprintf(stderr, "I915_UPLOAD_CTX:\n");
367
368 emit(intel, state->Ctx, sizeof(state->Ctx));
369 }
370
371 if (dirty & I915_UPLOAD_BUFFERS) {
372 GLuint count = 9;
373
374 if (INTEL_DEBUG & DEBUG_STATE)
375 fprintf(stderr, "I915_UPLOAD_BUFFERS:\n");
376
377 if (state->depth_region)
378 count += 3;
379
380 if (intel->constant_cliprect)
381 count += 6;
382
383 BEGIN_BATCH(count);
384 OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]);
385 OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]);
386 OUT_RELOC(state->draw_region->buffer,
387 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
388 state->draw_region->draw_offset);
389
390 if (state->depth_region) {
391 OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]);
392 OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]);
393 OUT_RELOC(state->depth_region->buffer,
394 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
395 state->depth_region->draw_offset);
396 }
397
398 OUT_BATCH(state->Buffer[I915_DESTREG_DV0]);
399 OUT_BATCH(state->Buffer[I915_DESTREG_DV1]);
400 OUT_BATCH(state->Buffer[I915_DESTREG_SENABLE]);
401 OUT_BATCH(state->Buffer[I915_DESTREG_SR0]);
402 OUT_BATCH(state->Buffer[I915_DESTREG_SR1]);
403 OUT_BATCH(state->Buffer[I915_DESTREG_SR2]);
404
405 if (intel->constant_cliprect) {
406 assert(state->Buffer[I915_DESTREG_DRAWRECT0] != MI_NOOP);
407 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT0]);
408 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT1]);
409 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT2]);
410 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT3]);
411 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT4]);
412 OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT5]);
413 }
414
415 ADVANCE_BATCH();
416 }
417
418 if (dirty & I915_UPLOAD_STIPPLE) {
419 if (INTEL_DEBUG & DEBUG_STATE)
420 fprintf(stderr, "I915_UPLOAD_STIPPLE:\n");
421 emit(intel, state->Stipple, sizeof(state->Stipple));
422 }
423
424 if (dirty & I915_UPLOAD_FOG) {
425 if (INTEL_DEBUG & DEBUG_STATE)
426 fprintf(stderr, "I915_UPLOAD_FOG:\n");
427 emit(intel, state->Fog, sizeof(state->Fog));
428 }
429
430 /* Combine all the dirty texture state into a single command to
431 * avoid lockups on I915 hardware.
432 */
433 if (dirty & I915_UPLOAD_TEX_ALL) {
434 int nr = 0;
435
436 for (i = 0; i < I915_TEX_UNITS; i++)
437 if (dirty & I915_UPLOAD_TEX(i))
438 nr++;
439
440 BEGIN_BATCH(2 + nr * 3);
441 OUT_BATCH(_3DSTATE_MAP_STATE | (3 * nr));
442 OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
443 for (i = 0; i < I915_TEX_UNITS; i++)
444 if (dirty & I915_UPLOAD_TEX(i)) {
445
446 if (state->tex_buffer[i]) {
447 OUT_RELOC(state->tex_buffer[i],
448 I915_GEM_DOMAIN_SAMPLER, 0,
449 state->tex_offset[i]);
450 }
451 else if (state == &i915->meta) {
452 assert(i == 0);
453 OUT_BATCH(0);
454 }
455 else {
456 OUT_BATCH(state->tex_offset[i]);
457 }
458
459 OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]);
460 OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]);
461 }
462 ADVANCE_BATCH();
463
464 BEGIN_BATCH(2 + nr * 3);
465 OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * nr));
466 OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
467 for (i = 0; i < I915_TEX_UNITS; i++)
468 if (dirty & I915_UPLOAD_TEX(i)) {
469 OUT_BATCH(state->Tex[i][I915_TEXREG_SS2]);
470 OUT_BATCH(state->Tex[i][I915_TEXREG_SS3]);
471 OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]);
472 }
473 ADVANCE_BATCH();
474 }
475
476 if (dirty & I915_UPLOAD_CONSTANTS) {
477 if (INTEL_DEBUG & DEBUG_STATE)
478 fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n");
479 emit(intel, state->Constant, state->ConstantSize * sizeof(GLuint));
480 }
481
482 if (dirty & I915_UPLOAD_PROGRAM) {
483 if (state->ProgramSize) {
484 if (INTEL_DEBUG & DEBUG_STATE)
485 fprintf(stderr, "I915_UPLOAD_PROGRAM:\n");
486
487 assert((state->Program[0] & 0x1ff) + 2 == state->ProgramSize);
488
489 emit(intel, state->Program, state->ProgramSize * sizeof(GLuint));
490 if (INTEL_DEBUG & DEBUG_STATE)
491 i915_disassemble_program(state->Program, state->ProgramSize);
492 }
493 }
494
495 intel->batch->dirty_state &= ~dirty;
496 assert(get_dirty(state) == 0);
497 assert((intel->batch->dirty_state & (1<<1)) == 0);
498 }
499
500 static void
501 i915_destroy_context(struct intel_context *intel)
502 {
503 GLuint i;
504 struct i915_context *i915 = i915_context(&intel->ctx);
505
506 intel_region_release(&i915->state.draw_region);
507 intel_region_release(&i915->state.depth_region);
508 intel_region_release(&i915->meta.draw_region);
509 intel_region_release(&i915->meta.depth_region);
510 intel_region_release(&i915->initial.draw_region);
511 intel_region_release(&i915->initial.depth_region);
512
513 for (i = 0; i < I915_TEX_UNITS; i++) {
514 if (i915->state.tex_buffer[i] != NULL) {
515 dri_bo_unreference(i915->state.tex_buffer[i]);
516 i915->state.tex_buffer[i] = NULL;
517 }
518 }
519
520 _tnl_free_vertices(&intel->ctx);
521 }
522
523 void
524 i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
525 uint32_t buffer_id)
526 {
527 state[0] = _3DSTATE_BUF_INFO_CMD;
528 state[1] = buffer_id;
529
530 if (region != NULL) {
531 state[1] |= BUF_3D_PITCH(region->pitch * region->cpp);
532
533 if (region->tiling != I915_TILING_NONE) {
534 state[1] |= BUF_3D_TILED_SURFACE;
535 if (region->tiling == I915_TILING_Y)
536 state[1] |= BUF_3D_TILE_WALK_Y;
537 }
538 }
539 }
540
541 /**
542 * Set the drawing regions for the color and depth/stencil buffers.
543 * This involves setting the pitch, cpp and buffer ID/location.
544 * Also set pixel format for color and Z rendering
545 * Used for setting both regular and meta state.
546 */
547 void
548 i915_state_draw_region(struct intel_context *intel,
549 struct i915_hw_state *state,
550 struct intel_region *color_region,
551 struct intel_region *depth_region)
552 {
553 struct i915_context *i915 = i915_context(&intel->ctx);
554 GLcontext *ctx = &intel->ctx;
555 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
556 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
557 GLuint value;
558
559 ASSERT(state == &i915->state || state == &i915->meta);
560
561 if (state->draw_region != color_region) {
562 intel_region_release(&state->draw_region);
563 intel_region_reference(&state->draw_region, color_region);
564 }
565 if (state->depth_region != depth_region) {
566 intel_region_release(&state->depth_region);
567 intel_region_reference(&state->depth_region, depth_region);
568 }
569
570 /*
571 * Set stride/cpp values
572 */
573 i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_CBUFADDR0],
574 color_region, BUF_3D_ID_COLOR_BACK);
575
576 i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_DBUFADDR0],
577 depth_region, BUF_3D_ID_DEPTH);
578
579 /*
580 * Compute/set I915_DESTREG_DV1 value
581 */
582 value = (DSTORG_HORT_BIAS(0x8) | /* .5 */
583 DSTORG_VERT_BIAS(0x8) | /* .5 */
584 LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL);
585 if (irb != NULL) {
586 switch (irb->Base.Format) {
587 case MESA_FORMAT_ARGB8888:
588 case MESA_FORMAT_XRGB8888:
589 value |= DV_PF_8888;
590 break;
591 case MESA_FORMAT_RGB565:
592 value |= DV_PF_565 | DITHER_FULL_ALWAYS;
593 break;
594 case MESA_FORMAT_ARGB1555:
595 value |= DV_PF_1555 | DITHER_FULL_ALWAYS;
596 break;
597 case MESA_FORMAT_ARGB4444:
598 value |= DV_PF_4444 | DITHER_FULL_ALWAYS;
599 break;
600 default:
601 _mesa_problem(ctx, "Bad renderbuffer format: %d\n",
602 irb->Base.Format);
603 }
604 }
605
606 /* This isn't quite safe, thus being hidden behind an option. When changing
607 * the value of this bit, the pipeline needs to be MI_FLUSHed. And it
608 * can only be set when a depth buffer is already defined.
609 */
610 if (intel->is_945 && intel->use_early_z &&
611 depth_region->tiling != I915_TILING_NONE)
612 value |= CLASSIC_EARLY_DEPTH;
613
614 if (depth_region && depth_region->cpp == 4) {
615 value |= DEPTH_FRMT_24_FIXED_8_OTHER;
616 }
617 else {
618 value |= DEPTH_FRMT_16_FIXED;
619 }
620 state->Buffer[I915_DESTREG_DV1] = value;
621
622 if (intel->constant_cliprect) {
623 state->Buffer[I915_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
624 state->Buffer[I915_DESTREG_DRAWRECT1] = 0;
625 state->Buffer[I915_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
626 state->Buffer[I915_DESTREG_DRAWRECT3] =
627 (ctx->DrawBuffer->Width & 0xffff) |
628 (ctx->DrawBuffer->Height << 16);
629 state->Buffer[I915_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
630 state->Buffer[I915_DESTREG_DRAWRECT5] = 0;
631 } else {
632 state->Buffer[I915_DESTREG_DRAWRECT0] = MI_NOOP;
633 state->Buffer[I915_DESTREG_DRAWRECT1] = MI_NOOP;
634 state->Buffer[I915_DESTREG_DRAWRECT2] = MI_NOOP;
635 state->Buffer[I915_DESTREG_DRAWRECT3] = MI_NOOP;
636 state->Buffer[I915_DESTREG_DRAWRECT4] = MI_NOOP;
637 state->Buffer[I915_DESTREG_DRAWRECT5] = MI_NOOP;
638 }
639
640 I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
641 }
642
643
644 static void
645 i915_set_draw_region(struct intel_context *intel,
646 struct intel_region *color_regions[],
647 struct intel_region *depth_region,
648 GLuint num_regions)
649 {
650 struct i915_context *i915 = i915_context(&intel->ctx);
651 i915_state_draw_region(intel, &i915->state, color_regions[0], depth_region);
652 }
653
654
655
656 static void
657 i915_new_batch(struct intel_context *intel)
658 {
659 struct i915_context *i915 = i915_context(&intel->ctx);
660
661 /* Mark all state as needing to be emitted when starting a new batchbuffer.
662 * Using hardware contexts would be an alternative, but they have some
663 * difficulties associated with them (physical address requirements).
664 */
665 i915->state.emitted = 0;
666 }
667
668 static void
669 i915_assert_not_dirty( struct intel_context *intel )
670 {
671 struct i915_context *i915 = i915_context(&intel->ctx);
672 struct i915_hw_state *state = i915->current;
673 GLuint dirty = get_dirty(state);
674 assert(!dirty);
675 }
676
677 void
678 i915InitVtbl(struct i915_context *i915)
679 {
680 i915->intel.vtbl.check_vertex_size = i915_check_vertex_size;
681 i915->intel.vtbl.destroy = i915_destroy_context;
682 i915->intel.vtbl.emit_state = i915_emit_state;
683 i915->intel.vtbl.new_batch = i915_new_batch;
684 i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state;
685 i915->intel.vtbl.render_start = i915_render_start;
686 i915->intel.vtbl.render_prevalidate = i915_render_prevalidate;
687 i915->intel.vtbl.set_draw_region = i915_set_draw_region;
688 i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
689 i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
690 i915->intel.vtbl.finish_batch = intel_finish_vb;
691 }