Add Intel 945GM support
[mesa.git] / src / mesa / drivers / dri / i915 / intel_batchbuffer.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 #include <stdio.h>
30 #include <errno.h>
31
32 #include "mtypes.h"
33 #include "context.h"
34 #include "enums.h"
35
36 #include "intel_reg.h"
37 #include "intel_batchbuffer.h"
38 #include "intel_context.h"
39
40
41
42
43 /* ================================================================
44 * Performance monitoring functions
45 */
46
47 static void intel_fill_box( intelContextPtr intel,
48 GLshort x, GLshort y,
49 GLshort w, GLshort h,
50 GLubyte r, GLubyte g, GLubyte b )
51 {
52 x += intel->drawX;
53 y += intel->drawY;
54
55 if (x >= 0 && y >= 0 &&
56 x+w < intel->intelScreen->width &&
57 y+h < intel->intelScreen->height)
58 intelEmitFillBlitLocked( intel,
59 intel->intelScreen->cpp,
60 intel->intelScreen->back.pitch,
61 intel->intelScreen->back.offset,
62 x, y, w, h,
63 INTEL_PACKCOLOR(intel->intelScreen->fbFormat,
64 r,g,b,0xff));
65 }
66
67 static void intel_draw_performance_boxes( intelContextPtr intel )
68 {
69 /* Purple box for page flipping
70 */
71 if ( intel->perf_boxes & I830_BOX_FLIP )
72 intel_fill_box( intel, 4, 4, 8, 8, 255, 0, 255 );
73
74 /* Red box if we have to wait for idle at any point
75 */
76 if ( intel->perf_boxes & I830_BOX_WAIT )
77 intel_fill_box( intel, 16, 4, 8, 8, 255, 0, 0 );
78
79 /* Blue box: lost context?
80 */
81 if ( intel->perf_boxes & I830_BOX_LOST_CONTEXT )
82 intel_fill_box( intel, 28, 4, 8, 8, 0, 0, 255 );
83
84 /* Yellow box for texture swaps
85 */
86 if ( intel->perf_boxes & I830_BOX_TEXTURE_LOAD )
87 intel_fill_box( intel, 40, 4, 8, 8, 255, 255, 0 );
88
89 /* Green box if hardware never idles (as far as we can tell)
90 */
91 if ( !(intel->perf_boxes & I830_BOX_RING_EMPTY) )
92 intel_fill_box( intel, 64, 4, 8, 8, 0, 255, 0 );
93
94
95 /* Draw bars indicating number of buffers allocated
96 * (not a great measure, easily confused)
97 */
98 #if 0
99 if (intel->dma_used) {
100 int bar = intel->dma_used / 10240;
101 if (bar > 100) bar = 100;
102 if (bar < 1) bar = 1;
103 intel_fill_box( intel, 4, 16, bar, 4, 196, 128, 128 );
104 intel->dma_used = 0;
105 }
106 #endif
107
108 intel->perf_boxes = 0;
109 }
110
111
112
113
114
115
116 static int bad_prim_vertex_nr( int primitive, int nr )
117 {
118 switch (primitive & PRIM3D_MASK) {
119 case PRIM3D_POINTLIST:
120 return nr < 1;
121 case PRIM3D_LINELIST:
122 return (nr & 1) || nr == 0;
123 case PRIM3D_LINESTRIP:
124 return nr < 2;
125 case PRIM3D_TRILIST:
126 case PRIM3D_RECTLIST:
127 return nr % 3 || nr == 0;
128 case PRIM3D_POLY:
129 case PRIM3D_TRIFAN:
130 case PRIM3D_TRISTRIP:
131 case PRIM3D_TRISTRIP_RVRSE:
132 return nr < 3;
133 default:
134 return 1;
135 }
136 }
137
138 static void intel_flush_inline_primitive( GLcontext *ctx )
139 {
140 intelContextPtr intel = INTEL_CONTEXT( ctx );
141 GLuint used = intel->batch.ptr - intel->prim.start_ptr;
142 GLuint vertcount;
143
144 assert(intel->prim.primitive != ~0);
145
146 if (1) {
147 /* Check vertex size against the vertex we're specifying to
148 * hardware. If it's wrong, ditch the primitive.
149 */
150 if (!intel->vtbl.check_vertex_size( intel, intel->vertex_size ))
151 goto do_discard;
152
153 vertcount = (used - 4)/ (intel->vertex_size * 4);
154
155 if (!vertcount)
156 goto do_discard;
157
158 if (vertcount * intel->vertex_size * 4 != used - 4) {
159 fprintf(stderr, "vertex size confusion %d %d\n", used,
160 intel->vertex_size * vertcount * 4);
161 goto do_discard;
162 }
163
164 if (bad_prim_vertex_nr( intel->prim.primitive, vertcount )) {
165 fprintf(stderr, "bad_prim_vertex_nr %x %d\n", intel->prim.primitive,
166 vertcount);
167 goto do_discard;
168 }
169 }
170
171 if (used < 8)
172 goto do_discard;
173
174 *(int *)intel->prim.start_ptr = (_3DPRIMITIVE |
175 intel->prim.primitive |
176 (used/4-2));
177
178 goto finished;
179
180 do_discard:
181 intel->batch.ptr -= used;
182 intel->batch.space += used;
183 assert(intel->batch.space >= 0);
184
185 finished:
186 intel->prim.primitive = ~0;
187 intel->prim.start_ptr = 0;
188 intel->prim.flush = 0;
189 }
190
191
192 /* Emit a primitive referencing vertices in a vertex buffer.
193 */
194 void intelStartInlinePrimitive( intelContextPtr intel, GLuint prim )
195 {
196 BATCH_LOCALS;
197
198 if (0)
199 fprintf(stderr, "%s %x\n", __FUNCTION__, prim);
200
201
202 /* Finish any in-progress primitive:
203 */
204 INTEL_FIREVERTICES( intel );
205
206 /* Emit outstanding state:
207 */
208 intel->vtbl.emit_state( intel );
209
210 /* Make sure there is some space in this buffer:
211 */
212 if (intel->vertex_size * 10 * sizeof(GLuint) >= intel->batch.space) {
213 intelFlushBatch(intel, GL_TRUE);
214 intel->vtbl.emit_state( intel );
215 }
216
217 #if 1
218 if (((int)intel->batch.ptr) & 0x4) {
219 BEGIN_BATCH(1);
220 OUT_BATCH(0);
221 ADVANCE_BATCH();
222 }
223 #endif
224
225 /* Emit a slot which will be filled with the inline primitive
226 * command later.
227 */
228 BEGIN_BATCH(2);
229 OUT_BATCH( 0 );
230
231 intel->prim.start_ptr = batch_ptr;
232 intel->prim.primitive = prim;
233 intel->prim.flush = intel_flush_inline_primitive;
234 intel->batch.contains_geometry = 1;
235
236 OUT_BATCH( 0 );
237 ADVANCE_BATCH();
238 }
239
240
241 void intelRestartInlinePrimitive( intelContextPtr intel )
242 {
243 GLuint prim = intel->prim.primitive;
244
245 intel_flush_inline_primitive( &intel->ctx );
246 if (1) intelFlushBatch(intel, GL_TRUE); /* GL_TRUE - is critical */
247 intelStartInlinePrimitive( intel, prim );
248 }
249
250
251
252 void intelWrapInlinePrimitive( intelContextPtr intel )
253 {
254 GLuint prim = intel->prim.primitive;
255
256 if (0)
257 fprintf(stderr, "%s\n", __FUNCTION__);
258 intel_flush_inline_primitive( &intel->ctx );
259 intelFlushBatch(intel, GL_TRUE);
260 intelStartInlinePrimitive( intel, prim );
261 }
262
263
264 /* Emit a primitive with space for inline vertices.
265 */
266 GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel,
267 int primitive,
268 int dwords,
269 int vertex_size )
270 {
271 GLuint *tmp = 0;
272 BATCH_LOCALS;
273
274 if (0)
275 fprintf(stderr, "%s 0x%x %d\n", __FUNCTION__, primitive, dwords);
276
277 /* Emit outstanding state:
278 */
279 intel->vtbl.emit_state( intel );
280
281 if ((1+dwords)*4 >= intel->batch.space) {
282 intelFlushBatch(intel, GL_TRUE);
283 intel->vtbl.emit_state( intel );
284 }
285
286
287 if (1) {
288 int used = dwords * 4;
289 int vertcount;
290
291 /* Check vertex size against the vertex we're specifying to
292 * hardware. If it's wrong, ditch the primitive.
293 */
294 if (!intel->vtbl.check_vertex_size( intel, vertex_size ))
295 goto do_discard;
296
297 vertcount = dwords / vertex_size;
298
299 if (dwords % vertex_size) {
300 fprintf(stderr, "did not request a whole number of vertices\n");
301 goto do_discard;
302 }
303
304 if (bad_prim_vertex_nr( primitive, vertcount )) {
305 fprintf(stderr, "bad_prim_vertex_nr %x %d\n", primitive, vertcount);
306 goto do_discard;
307 }
308
309 if (used < 8)
310 goto do_discard;
311 }
312
313 /* Emit 3D_PRIMITIVE commands:
314 */
315 BEGIN_BATCH(1 + dwords);
316 OUT_BATCH( _3DPRIMITIVE |
317 primitive |
318 (dwords-1) );
319
320 tmp = (GLuint *)batch_ptr;
321 batch_ptr += dwords * 4;
322
323 ADVANCE_BATCH();
324
325 intel->batch.contains_geometry = 1;
326
327 do_discard:
328 return tmp;
329 }
330
331
332
333 /*
334 * Copy the back buffer to the front buffer.
335 */
336 void intelCopyBuffer( const __DRIdrawablePrivate *dPriv )
337 {
338 intelContextPtr intel;
339
340 if (0)
341 fprintf(stderr, "%s\n", __FUNCTION__);
342
343 assert(dPriv);
344 assert(dPriv->driContextPriv);
345 assert(dPriv->driContextPriv->driverPrivate);
346
347 intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
348
349 intelFlush( &intel->ctx );
350 LOCK_HARDWARE( intel );
351 {
352 const intelScreenPrivate *intelScreen = intel->intelScreen;
353 const __DRIdrawablePrivate *dPriv = intel->driDrawable;
354 const int nbox = dPriv->numClipRects;
355 const drm_clip_rect_t *pbox = dPriv->pClipRects;
356 const int cpp = intelScreen->cpp;
357 const int pitch = intelScreen->front.pitch; /* in bytes */
358 int i;
359 GLuint CMD, BR13;
360 BATCH_LOCALS;
361
362 switch(cpp) {
363 case 2:
364 BR13 = (pitch) | (0xCC << 16) | (1<<24);
365 CMD = XY_SRC_COPY_BLT_CMD;
366 break;
367 case 4:
368 BR13 = (pitch) | (0xCC << 16) | (1<<24) | (1<<25);
369 CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
370 XY_SRC_COPY_BLT_WRITE_RGB);
371 break;
372 default:
373 BR13 = (pitch) | (0xCC << 16) | (1<<24);
374 CMD = XY_SRC_COPY_BLT_CMD;
375 break;
376 }
377
378 if (0)
379 intel_draw_performance_boxes( intel );
380
381 for (i = 0 ; i < nbox; i++, pbox++)
382 {
383 if (pbox->x1 > pbox->x2 ||
384 pbox->y1 > pbox->y2 ||
385 pbox->x2 > intelScreen->width ||
386 pbox->y2 > intelScreen->height) {
387 _mesa_warning(&intel->ctx, "Bad cliprect in intelCopyBuffer()");
388 continue;
389 }
390
391 BEGIN_BATCH( 8);
392 OUT_BATCH( CMD );
393 OUT_BATCH( BR13 );
394 OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
395 OUT_BATCH( (pbox->y2 << 16) | pbox->x2 );
396
397 if (intel->sarea->pf_current_page == 0)
398 OUT_BATCH( intelScreen->front.offset );
399 else
400 OUT_BATCH( intelScreen->back.offset );
401
402 OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
403 OUT_BATCH( BR13 & 0xffff );
404
405 if (intel->sarea->pf_current_page == 0)
406 OUT_BATCH( intelScreen->back.offset );
407 else
408 OUT_BATCH( intelScreen->front.offset );
409
410 ADVANCE_BATCH();
411 }
412 }
413 intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE );
414 UNLOCK_HARDWARE( intel );
415 }
416
417
418
419
420 void intelEmitFillBlitLocked( intelContextPtr intel,
421 GLuint cpp,
422 GLshort dst_pitch, /* in bytes */
423 GLuint dst_offset,
424 GLshort x, GLshort y,
425 GLshort w, GLshort h,
426 GLuint color )
427 {
428 GLuint BR13, CMD;
429 BATCH_LOCALS;
430
431 switch(cpp) {
432 case 1:
433 case 2:
434 case 3:
435 BR13 = dst_pitch | (0xF0 << 16) | (1<<24);
436 CMD = XY_COLOR_BLT_CMD;
437 break;
438 case 4:
439 BR13 = dst_pitch | (0xF0 << 16) | (1<<24) | (1<<25);
440 CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA |
441 XY_COLOR_BLT_WRITE_RGB);
442 break;
443 default:
444 return;
445 }
446
447 BEGIN_BATCH( 6);
448 OUT_BATCH( CMD );
449 OUT_BATCH( BR13 );
450 OUT_BATCH( (y << 16) | x );
451 OUT_BATCH( ((y+h) << 16) | (x+w) );
452 OUT_BATCH( dst_offset );
453 OUT_BATCH( color );
454 ADVANCE_BATCH();
455 }
456
457
458 /* Copy BitBlt
459 */
460 void intelEmitCopyBlitLocked( intelContextPtr intel,
461 GLuint cpp,
462 GLshort src_pitch,
463 GLuint src_offset,
464 GLshort dst_pitch,
465 GLuint dst_offset,
466 GLshort src_x, GLshort src_y,
467 GLshort dst_x, GLshort dst_y,
468 GLshort w, GLshort h )
469 {
470 GLuint CMD, BR13;
471 int dst_y2 = dst_y + h;
472 int dst_x2 = dst_x + w;
473 BATCH_LOCALS;
474
475 src_pitch *= cpp;
476 dst_pitch *= cpp;
477
478 switch(cpp) {
479 case 1:
480 case 2:
481 case 3:
482 BR13 = dst_pitch | (0xCC << 16) | (1<<24);
483 CMD = XY_SRC_COPY_BLT_CMD;
484 break;
485 case 4:
486 BR13 = dst_pitch | (0xCC << 16) | (1<<24) | (1<<25);
487 CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
488 XY_SRC_COPY_BLT_WRITE_RGB);
489 break;
490 default:
491 return;
492 }
493
494 if (dst_y2 < dst_y ||
495 dst_x2 < dst_x) {
496 return;
497 }
498
499 BEGIN_BATCH( 12);
500 OUT_BATCH( CMD );
501 OUT_BATCH( BR13 );
502 OUT_BATCH( (dst_y << 16) | dst_x );
503 OUT_BATCH( (dst_y2 << 16) | dst_x2 );
504 OUT_BATCH( dst_offset );
505 OUT_BATCH( (src_y << 16) | src_x );
506 OUT_BATCH( src_pitch );
507 OUT_BATCH( src_offset );
508 ADVANCE_BATCH();
509 }
510
511
512
513 void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
514 GLint cx1, GLint cy1, GLint cw, GLint ch)
515 {
516 intelContextPtr intel = INTEL_CONTEXT( ctx );
517 intelScreenPrivate *intelScreen = intel->intelScreen;
518 GLuint clear_depth, clear_color;
519 GLint cx, cy;
520 GLint pitch;
521 GLint cpp = intelScreen->cpp;
522 GLint i;
523 GLuint BR13, CMD, D_CMD;
524 BATCH_LOCALS;
525
526 intelFlush( &intel->ctx );
527 LOCK_HARDWARE( intel );
528
529 pitch = intelScreen->front.pitch;
530
531 clear_color = intel->ClearColor;
532 clear_depth = 0;
533
534 if (flags & BUFFER_BIT_DEPTH) {
535 clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
536 }
537
538 if (flags & BUFFER_BIT_STENCIL) {
539 clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
540 }
541
542 switch(cpp) {
543 case 2:
544 BR13 = (0xF0 << 16) | (pitch) | (1<<24);
545 D_CMD = CMD = XY_COLOR_BLT_CMD;
546 break;
547 case 4:
548 BR13 = (0xF0 << 16) | (pitch) | (1<<24) | (1<<25);
549 CMD = (XY_COLOR_BLT_CMD |
550 XY_COLOR_BLT_WRITE_ALPHA |
551 XY_COLOR_BLT_WRITE_RGB);
552 D_CMD = XY_COLOR_BLT_CMD;
553 if (flags & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
554 if (flags & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
555 break;
556 default:
557 BR13 = (0xF0 << 16) | (pitch) | (1<<24);
558 D_CMD = CMD = XY_COLOR_BLT_CMD;
559 break;
560 }
561
562 {
563 /* flip top to bottom */
564 cy = intel->driDrawable->h-cy1-ch;
565 cx = cx1 + intel->drawX;
566 cy += intel->drawY;
567
568 /* adjust for page flipping */
569 if ( intel->sarea->pf_current_page == 1 ) {
570 GLuint tmp = flags;
571
572 flags &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
573 if ( tmp & BUFFER_BIT_FRONT_LEFT ) flags |= BUFFER_BIT_BACK_LEFT;
574 if ( tmp & BUFFER_BIT_BACK_LEFT ) flags |= BUFFER_BIT_FRONT_LEFT;
575 }
576
577 for (i = 0 ; i < intel->numClipRects ; i++)
578 {
579 drm_clip_rect_t *box = &intel->pClipRects[i];
580 drm_clip_rect_t b;
581
582 if (!all) {
583 GLint x = box[i].x1;
584 GLint y = box[i].y1;
585 GLint w = box[i].x2 - x;
586 GLint h = box[i].y2 - y;
587
588 if (x < cx) w -= cx - x, x = cx;
589 if (y < cy) h -= cy - y, y = cy;
590 if (x + w > cx + cw) w = cx + cw - x;
591 if (y + h > cy + ch) h = cy + ch - y;
592 if (w <= 0) continue;
593 if (h <= 0) continue;
594
595 b.x1 = x;
596 b.y1 = y;
597 b.x2 = x + w;
598 b.y2 = y + h;
599 } else {
600 b = *box;
601 }
602
603
604 if (b.x1 > b.x2 ||
605 b.y1 > b.y2 ||
606 b.x2 > intelScreen->width ||
607 b.y2 > intelScreen->height)
608 continue;
609
610 if ( flags & BUFFER_BIT_FRONT_LEFT ) {
611 BEGIN_BATCH( 6);
612 OUT_BATCH( CMD );
613 OUT_BATCH( BR13 );
614 OUT_BATCH( (b.y1 << 16) | b.x1 );
615 OUT_BATCH( (b.y2 << 16) | b.x2 );
616 OUT_BATCH( intelScreen->front.offset );
617 OUT_BATCH( clear_color );
618 ADVANCE_BATCH();
619 }
620
621 if ( flags & BUFFER_BIT_BACK_LEFT ) {
622 BEGIN_BATCH( 6);
623 OUT_BATCH( CMD );
624 OUT_BATCH( BR13 );
625 OUT_BATCH( (b.y1 << 16) | b.x1 );
626 OUT_BATCH( (b.y2 << 16) | b.x2 );
627 OUT_BATCH( intelScreen->back.offset );
628 OUT_BATCH( clear_color );
629 ADVANCE_BATCH();
630 }
631
632 if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) {
633 BEGIN_BATCH( 6);
634 OUT_BATCH( D_CMD );
635 OUT_BATCH( BR13 );
636 OUT_BATCH( (b.y1 << 16) | b.x1 );
637 OUT_BATCH( (b.y2 << 16) | b.x2 );
638 OUT_BATCH( intelScreen->depth.offset );
639 OUT_BATCH( clear_depth );
640 ADVANCE_BATCH();
641 }
642 }
643 }
644 intelFlushBatchLocked( intel, GL_TRUE, GL_FALSE, GL_TRUE );
645 UNLOCK_HARDWARE( intel );
646 }
647
648
649
650
651 void intelDestroyBatchBuffer( GLcontext *ctx )
652 {
653 intelContextPtr intel = INTEL_CONTEXT(ctx);
654
655 if (intel->alloc.offset) {
656 intelFreeAGP( intel, intel->alloc.ptr );
657 intel->alloc.ptr = NULL;
658 intel->alloc.offset = 0;
659 }
660 else if (intel->alloc.ptr) {
661 free(intel->alloc.ptr);
662 intel->alloc.ptr = NULL;
663 }
664
665 memset(&intel->batch, 0, sizeof(intel->batch));
666 }
667
668
669 void intelInitBatchBuffer( GLcontext *ctx )
670 {
671 intelContextPtr intel = INTEL_CONTEXT(ctx);
672
673 /* This path isn't really safe with rotate:
674 */
675 if (getenv("INTEL_BATCH") && intel->intelScreen->allow_batchbuffer) {
676 switch (intel->intelScreen->deviceID) {
677 case PCI_CHIP_I865_G:
678 /* HW bug? Seems to crash if batchbuffer crosses 4k boundary.
679 */
680 intel->alloc.size = 8 * 1024;
681 break;
682 default:
683 /* This is the smallest amount of memory the kernel deals with.
684 * We'd ideally like to make this smaller.
685 */
686 intel->alloc.size = 1 << intel->intelScreen->logTextureGranularity;
687 break;
688 }
689
690 /* KW: temporary - this make crashes & lockups more frequent, so
691 * leave in until they are solved.
692 */
693 intel->alloc.size = 8 * 1024;
694
695 intel->alloc.ptr = intelAllocateAGP( intel, intel->alloc.size );
696 if (intel->alloc.ptr)
697 intel->alloc.offset =
698 intelAgpOffsetFromVirtual( intel, intel->alloc.ptr );
699 else
700 intel->alloc.offset = 0; /* OK? */
701 }
702
703 /* The default is now to use a local buffer and pass that to the
704 * kernel. This is also a fallback if allocation fails on the
705 * above path:
706 */
707 if (!intel->alloc.ptr) {
708 intel->alloc.size = 8 * 1024;
709 intel->alloc.ptr = malloc( intel->alloc.size );
710 intel->alloc.offset = 0;
711 }
712
713 assert(intel->alloc.ptr);
714 }