OSDN Git Service

[965] Move temporary vbo array storage into the function using it.
[android-x86/external-mesa.git] / src / mesa / drivers / dri / i965 / brw_draw_upload.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 #include <stdlib.h>
29
30 #include "glheader.h"
31 #include "context.h"
32 #include "state.h"
33 #include "api_validate.h"
34 #include "enums.h"
35
36 #include "brw_draw.h"
37 #include "brw_defines.h"
38 #include "brw_context.h"
39 #include "brw_state.h"
40 #include "brw_fallback.h"
41
42 #include "intel_ioctl.h"
43 #include "intel_batchbuffer.h"
44 #include "intel_buffer_objects.h"
45 #include "intel_tex.h"
46
47 struct brw_array_state {
48    union header_union header;
49
50    struct {
51       union {
52          struct {
53             GLuint pitch:11; 
54             GLuint pad:15;
55             GLuint access_type:1; 
56             GLuint vb_index:5; 
57          } bits;
58          GLuint dword;
59       } vb0;
60    
61       dri_bo *buffer;
62       GLuint offset;
63
64       GLuint max_index;   
65       GLuint instance_data_step_rate;
66
67    } vb[BRW_VBP_MAX];
68 };
69
70
71 static dri_bo *array_buffer( struct intel_context *intel,
72                              const struct gl_client_array *array )
73 {
74    return intel_bufferobj_buffer(intel, intel_buffer_object(array->BufferObj),
75                                  INTEL_WRITE_PART);
76 }
77
78 static GLuint double_types[5] = {
79    0,
80    BRW_SURFACEFORMAT_R64_FLOAT,
81    BRW_SURFACEFORMAT_R64G64_FLOAT,
82    BRW_SURFACEFORMAT_R64G64B64_FLOAT,
83    BRW_SURFACEFORMAT_R64G64B64A64_FLOAT
84 };
85
86 static GLuint float_types[5] = {
87    0,
88    BRW_SURFACEFORMAT_R32_FLOAT,
89    BRW_SURFACEFORMAT_R32G32_FLOAT,
90    BRW_SURFACEFORMAT_R32G32B32_FLOAT,
91    BRW_SURFACEFORMAT_R32G32B32A32_FLOAT
92 };
93
94 static GLuint uint_types_norm[5] = {
95    0,
96    BRW_SURFACEFORMAT_R32_UNORM,
97    BRW_SURFACEFORMAT_R32G32_UNORM,
98    BRW_SURFACEFORMAT_R32G32B32_UNORM,
99    BRW_SURFACEFORMAT_R32G32B32A32_UNORM
100 };
101
102 static GLuint uint_types_scale[5] = {
103    0,
104    BRW_SURFACEFORMAT_R32_USCALED,
105    BRW_SURFACEFORMAT_R32G32_USCALED,
106    BRW_SURFACEFORMAT_R32G32B32_USCALED,
107    BRW_SURFACEFORMAT_R32G32B32A32_USCALED
108 };
109
110 static GLuint int_types_norm[5] = {
111    0,
112    BRW_SURFACEFORMAT_R32_SNORM,
113    BRW_SURFACEFORMAT_R32G32_SNORM,
114    BRW_SURFACEFORMAT_R32G32B32_SNORM,
115    BRW_SURFACEFORMAT_R32G32B32A32_SNORM
116 };
117
118 static GLuint int_types_scale[5] = {
119    0,
120    BRW_SURFACEFORMAT_R32_SSCALED,
121    BRW_SURFACEFORMAT_R32G32_SSCALED,
122    BRW_SURFACEFORMAT_R32G32B32_SSCALED,
123    BRW_SURFACEFORMAT_R32G32B32A32_SSCALED
124 };
125
126 static GLuint ushort_types_norm[5] = {
127    0,
128    BRW_SURFACEFORMAT_R16_UNORM,
129    BRW_SURFACEFORMAT_R16G16_UNORM,
130    BRW_SURFACEFORMAT_R16G16B16_UNORM,
131    BRW_SURFACEFORMAT_R16G16B16A16_UNORM
132 };
133
134 static GLuint ushort_types_scale[5] = {
135    0,
136    BRW_SURFACEFORMAT_R16_USCALED,
137    BRW_SURFACEFORMAT_R16G16_USCALED,
138    BRW_SURFACEFORMAT_R16G16B16_USCALED,
139    BRW_SURFACEFORMAT_R16G16B16A16_USCALED
140 };
141
142 static GLuint short_types_norm[5] = {
143    0,
144    BRW_SURFACEFORMAT_R16_SNORM,
145    BRW_SURFACEFORMAT_R16G16_SNORM,
146    BRW_SURFACEFORMAT_R16G16B16_SNORM,
147    BRW_SURFACEFORMAT_R16G16B16A16_SNORM
148 };
149
150 static GLuint short_types_scale[5] = {
151    0,
152    BRW_SURFACEFORMAT_R16_SSCALED,
153    BRW_SURFACEFORMAT_R16G16_SSCALED,
154    BRW_SURFACEFORMAT_R16G16B16_SSCALED,
155    BRW_SURFACEFORMAT_R16G16B16A16_SSCALED
156 };
157
158 static GLuint ubyte_types_norm[5] = {
159    0,
160    BRW_SURFACEFORMAT_R8_UNORM,
161    BRW_SURFACEFORMAT_R8G8_UNORM,
162    BRW_SURFACEFORMAT_R8G8B8_UNORM,
163    BRW_SURFACEFORMAT_R8G8B8A8_UNORM
164 };
165
166 static GLuint ubyte_types_scale[5] = {
167    0,
168    BRW_SURFACEFORMAT_R8_USCALED,
169    BRW_SURFACEFORMAT_R8G8_USCALED,
170    BRW_SURFACEFORMAT_R8G8B8_USCALED,
171    BRW_SURFACEFORMAT_R8G8B8A8_USCALED
172 };
173
174 static GLuint byte_types_norm[5] = {
175    0,
176    BRW_SURFACEFORMAT_R8_SNORM,
177    BRW_SURFACEFORMAT_R8G8_SNORM,
178    BRW_SURFACEFORMAT_R8G8B8_SNORM,
179    BRW_SURFACEFORMAT_R8G8B8A8_SNORM
180 };
181
182 static GLuint byte_types_scale[5] = {
183    0,
184    BRW_SURFACEFORMAT_R8_SSCALED,
185    BRW_SURFACEFORMAT_R8G8_SSCALED,
186    BRW_SURFACEFORMAT_R8G8B8_SSCALED,
187    BRW_SURFACEFORMAT_R8G8B8A8_SSCALED
188 };
189
190
191 static GLuint get_surface_type( GLenum type, GLuint size, GLboolean normalized )
192 {
193    if (INTEL_DEBUG & DEBUG_VERTS)
194       _mesa_printf("type %s size %d normalized %d\n", 
195                    _mesa_lookup_enum_by_nr(type), size, normalized);
196
197    if (normalized) {
198       switch (type) {
199       case GL_DOUBLE: return double_types[size];
200       case GL_FLOAT: return float_types[size];
201       case GL_INT: return int_types_norm[size];
202       case GL_SHORT: return short_types_norm[size];
203       case GL_BYTE: return byte_types_norm[size];
204       case GL_UNSIGNED_INT: return uint_types_norm[size];
205       case GL_UNSIGNED_SHORT: return ushort_types_norm[size];
206       case GL_UNSIGNED_BYTE: return ubyte_types_norm[size];
207       default: assert(0); return 0;
208       }      
209    }
210    else {
211       switch (type) {
212       case GL_DOUBLE: return double_types[size];
213       case GL_FLOAT: return float_types[size];
214       case GL_INT: return int_types_scale[size];
215       case GL_SHORT: return short_types_scale[size];
216       case GL_BYTE: return byte_types_scale[size];
217       case GL_UNSIGNED_INT: return uint_types_scale[size];
218       case GL_UNSIGNED_SHORT: return ushort_types_scale[size];
219       case GL_UNSIGNED_BYTE: return ubyte_types_scale[size];
220       default: assert(0); return 0;
221       }      
222    }
223 }
224
225
226 static GLuint get_size( GLenum type )
227 {
228    switch (type) {
229    case GL_DOUBLE: return sizeof(GLdouble);
230    case GL_FLOAT: return sizeof(GLfloat);
231    case GL_INT: return sizeof(GLint);
232    case GL_SHORT: return sizeof(GLshort);
233    case GL_BYTE: return sizeof(GLbyte);
234    case GL_UNSIGNED_INT: return sizeof(GLuint);
235    case GL_UNSIGNED_SHORT: return sizeof(GLushort);
236    case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
237    default: return 0;
238    }      
239 }
240
241 static GLuint get_index_type(GLenum type) 
242 {
243    switch (type) {
244    case GL_UNSIGNED_BYTE:  return BRW_INDEX_BYTE;
245    case GL_UNSIGNED_SHORT: return BRW_INDEX_WORD;
246    case GL_UNSIGNED_INT:   return BRW_INDEX_DWORD;
247    default: assert(0); return 0;
248    }
249 }
250
251 static void copy_strided_array( GLubyte *dest, 
252                                 const GLubyte *src, 
253                                 GLuint size, 
254                                 GLuint stride,
255                                 GLuint count )
256 {
257    if (size == stride) 
258       memcpy(dest, src, count * size);
259    else {
260       GLuint i;
261    
262       for (i = 0; i < count; i++) {
263          memcpy(dest, src, size);
264          src += stride;
265          dest += size;
266       }
267    }
268 }
269
270 static void wrap_buffers( struct brw_context *brw,
271                           GLuint size )
272 {
273    GLcontext *ctx = &brw->intel.ctx;
274
275    if (size < BRW_UPLOAD_INIT_SIZE)
276       size = BRW_UPLOAD_INIT_SIZE;
277
278    brw->vb.upload.buf++;
279    brw->vb.upload.buf %= BRW_NR_UPLOAD_BUFS;
280    brw->vb.upload.offset = 0;
281
282    ctx->Driver.BufferData(ctx,
283                           GL_ARRAY_BUFFER_ARB,
284                           size,
285                           NULL,
286                           GL_DYNAMIC_DRAW_ARB,
287                           brw->vb.upload.vbo[brw->vb.upload.buf]);
288 }
289
290 static void get_space( struct brw_context *brw,
291                        GLuint size,
292                        struct gl_buffer_object **vbo_return,
293                        GLuint *offset_return )
294 {
295    size = ALIGN(size, 64);
296    
297    if (brw->vb.upload.offset + size > BRW_UPLOAD_INIT_SIZE)
298       wrap_buffers(brw, size);
299
300    *vbo_return = brw->vb.upload.vbo[brw->vb.upload.buf];
301    *offset_return = brw->vb.upload.offset;
302
303    brw->vb.upload.offset += size;
304 }
305
306 static void
307 copy_array_to_vbo_array( struct brw_context *brw,
308                          struct gl_client_array *vbo_array,
309                          const struct gl_client_array *array,
310                          GLuint element_size,
311                          GLuint count)
312 {
313    GLcontext *ctx = &brw->intel.ctx;
314    GLuint size = count * element_size;
315    struct gl_buffer_object *vbo;
316    GLuint offset;
317    GLuint new_stride;
318
319    get_space(brw, size, &vbo, &offset);
320
321    if (array->StrideB == 0) {
322       assert(count == 1);
323       new_stride = 0;
324    }
325    else 
326       new_stride = element_size;
327
328    vbo_array->Size = array->Size;
329    vbo_array->Type = array->Type;
330    vbo_array->Stride = new_stride;
331    vbo_array->StrideB = new_stride;   
332    vbo_array->Ptr = (const void *)offset;
333    vbo_array->Enabled = 1;
334    vbo_array->Normalized = array->Normalized;
335    vbo_array->_MaxElement = array->_MaxElement; /* ? */
336    vbo_array->BufferObj = vbo;
337
338    {
339       GLubyte *map = ctx->Driver.MapBuffer(ctx,
340                                            GL_ARRAY_BUFFER_ARB,
341                                            GL_DYNAMIC_DRAW_ARB,
342                                            vbo);
343    
344       map += offset;
345
346       copy_strided_array( map, 
347                           array->Ptr,
348                           element_size,
349                           array->StrideB,
350                           count);
351
352       ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, vbo_array->BufferObj);
353    }
354 }
355
356 /**
357  * Just a wrapper to highlight which cause of copy_array_to_vbo_array
358  * is happening in the profile.
359  */
360 static void
361 interleaved_copy_array_to_vbo_array(struct brw_context *brw,
362                                     struct gl_client_array *vbo_array,
363                                     const struct gl_client_array *array,
364                                     GLuint element_size,
365                                     GLuint count)
366 {
367    copy_array_to_vbo_array(brw, vbo_array, array, element_size, count);
368 }
369
370 static void
371 interleaved_vbo_array( struct brw_context *brw,
372                        struct gl_client_array *vbo_array,
373                        const struct gl_client_array *uploaded_array,
374                        const struct gl_client_array *array,
375                        const char *ptr)
376 {
377    vbo_array->Size = array->Size;
378    vbo_array->Type = array->Type;
379    vbo_array->Stride = array->Stride;
380    vbo_array->StrideB = array->StrideB;   
381    vbo_array->Ptr = (const void *)((const char *)uploaded_array->Ptr + 
382                                    ((const char *)array->Ptr - ptr));
383    vbo_array->Enabled = 1;
384    vbo_array->Normalized = array->Normalized;
385    vbo_array->_MaxElement = array->_MaxElement; 
386    vbo_array->BufferObj = uploaded_array->BufferObj;
387 }
388
389
390 GLboolean brw_upload_vertices( struct brw_context *brw,
391                                GLuint min_index,
392                                GLuint max_index )
393 {
394    GLcontext *ctx = &brw->intel.ctx;
395    struct intel_context *intel = intel_context(ctx);
396    GLuint tmp = brw->vs.prog_data->inputs_read; 
397    GLuint i;
398    const void *ptr = NULL;
399    GLuint interleave = 0;
400    struct gl_client_array vbo_array_temp[VERT_ATTRIB_MAX];
401
402    struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
403    GLuint nr_enabled = 0;
404
405    struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
406    GLuint nr_uploads = 0;
407
408    /* First build an array of pointers to ve's in vb.inputs_read
409     */
410    if (0)
411       _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index);
412    
413    while (tmp) {
414       GLuint i = _mesa_ffsll(tmp)-1;
415       struct brw_vertex_element *input = &brw->vb.inputs[i];
416
417       tmp &= ~(1<<i);
418       enabled[nr_enabled++] = input;
419
420       input->element_size = get_size(input->glarray->Type) * input->glarray->Size;
421       input->count = input->glarray->StrideB ? max_index + 1 - min_index : 1;
422
423       if (!input->glarray->BufferObj->Name) {
424          if (i == 0) {
425             /* Position array not properly enabled:
426              */
427             if (input->glarray->StrideB == 0)
428                return GL_FALSE;
429
430             interleave = input->glarray->StrideB;
431             ptr = input->glarray->Ptr;
432          }
433          else if (interleave != input->glarray->StrideB ||
434                   (const char *)input->glarray->Ptr - (const char *)ptr < 0 ||
435                   (const char *)input->glarray->Ptr - (const char *)ptr > interleave) {
436             interleave = 0;
437          }
438
439          upload[nr_uploads++] = input;
440          
441          /* We rebase drawing to start at element zero only when
442           * varyings are not in vbos, which means we can end up
443           * uploading non-varying arrays (stride != 0) when min_index
444           * is zero.  This doesn't matter as the amount to upload is
445           * the same for these arrays whether the draw call is rebased
446           * or not - we just have to upload the one element.
447           */
448          assert(min_index == 0 || input->glarray->StrideB == 0);
449       }
450    }
451
452    /* Upload interleaved arrays if all uploads are interleaved
453     */
454    if (nr_uploads > 1 && interleave && interleave <= 256) {
455       interleaved_copy_array_to_vbo_array(brw, &vbo_array_temp[0],
456                                           upload[0]->glarray,
457                                           interleave,
458                                           upload[0]->count);
459       upload[0]->glarray = &vbo_array_temp[0];
460
461       for (i = 1; i < nr_uploads; i++) {
462          interleaved_vbo_array(brw,
463                                &vbo_array_temp[i],
464                                upload[0]->glarray,
465                                upload[i]->glarray,
466                                ptr);
467          upload[i]->glarray = &vbo_array_temp[i];
468       }
469    }
470    else {
471       for (i = 0; i < nr_uploads; i++) {
472          copy_array_to_vbo_array(brw, &vbo_array_temp[i],
473                                  upload[i]->glarray,
474                                  upload[i]->element_size,
475                                  upload[i]->count);
476          upload[i]->glarray = &vbo_array_temp[i];
477       }
478    }
479
480    /* XXX: In the rare cases where this happens we fallback all
481     * the way to software rasterization, although a tnl fallback
482     * would be sufficient.  I don't know of *any* real world
483     * cases with > 17 vertex attributes enabled, so it probably
484     * isn't an issue at this point.
485     */
486    if (nr_enabled >= BRW_VEP_MAX)
487          return GL_FALSE;
488
489    /* Now emit VB and VEP state packets.
490     *
491     * This still defines a hardware VB for each input, even if they
492     * are interleaved or from the same VBO.  TBD if this makes a
493     * performance difference.
494     */
495    BEGIN_BATCH(1 + nr_enabled * 4, IGNORE_CLIPRECTS);
496    OUT_BATCH((CMD_VERTEX_BUFFER << 16) |
497              ((1 + nr_enabled * 4) - 2));
498
499    for (i = 0; i < nr_enabled; i++) {
500       struct brw_vertex_element *input = enabled[i];
501
502       OUT_BATCH((i << BRW_VB0_INDEX_SHIFT) |
503                 BRW_VB0_ACCESS_VERTEXDATA |
504                 (input->glarray->StrideB << BRW_VB0_PITCH_SHIFT));
505       OUT_RELOC(array_buffer(intel, input->glarray),
506                 DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
507                 (GLuint)input->glarray->Ptr);
508       OUT_BATCH(max_index);
509       OUT_BATCH(0); /* Instance data step rate */
510    }
511    ADVANCE_BATCH();
512
513    BEGIN_BATCH(1 + nr_enabled * 2, IGNORE_CLIPRECTS);
514    OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr_enabled * 2) - 2));
515    for (i = 0; i < nr_enabled; i++) {
516       struct brw_vertex_element *input = enabled[i];
517       uint32_t format = get_surface_type(input->glarray->Type,
518                                          input->glarray->Size,
519                                          input->glarray->Normalized);
520       uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
521       uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
522       uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC;
523       uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC;
524
525       switch (input->glarray->Size) {
526       case 0: comp0 = BRW_VE1_COMPONENT_STORE_0;
527       case 1: comp1 = BRW_VE1_COMPONENT_STORE_0;
528       case 2: comp2 = BRW_VE1_COMPONENT_STORE_0;
529       case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT;
530          break;
531       }
532
533       OUT_BATCH((i << BRW_VE0_INDEX_SHIFT) |
534                 BRW_VE0_VALID |
535                 (format << BRW_VE0_FORMAT_SHIFT) |
536                 (0 << BRW_VE0_SRC_OFFSET_SHIFT));
537       OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
538                 (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
539                 (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
540                 (comp3 << BRW_VE1_COMPONENT_3_SHIFT) |
541                 ((i * 4) << BRW_VE1_DST_OFFSET_SHIFT));
542    }
543    ADVANCE_BATCH();
544
545    return GL_TRUE;
546 }
547
548 void brw_upload_indices( struct brw_context *brw,
549                          const struct _mesa_index_buffer *index_buffer )
550 {
551    GLcontext *ctx = &brw->intel.ctx;
552    struct intel_context *intel = &brw->intel;
553    GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
554    struct gl_buffer_object *bufferobj = index_buffer->obj;
555    GLuint offset = (GLuint)index_buffer->ptr;
556
557    /* Turn into a proper VBO:
558     */
559    if (!bufferobj->Name) {
560      
561       /* Get new bufferobj, offset:
562        */
563       get_space(brw, ib_size, &bufferobj, &offset);
564
565       /* Straight upload
566        */
567       ctx->Driver.BufferSubData( ctx,
568                                  GL_ELEMENT_ARRAY_BUFFER_ARB,
569                                  offset, 
570                                  ib_size,
571                                  index_buffer->ptr,
572                                  bufferobj);
573    } else {
574       /* If the index buffer isn't aligned to its element size, we have to
575        * rebase it into a temporary.
576        */
577        if ((get_size(index_buffer->type) - 1) & offset) {
578            struct gl_buffer_object *vbo;
579            GLuint voffset;
580            GLubyte *map = ctx->Driver.MapBuffer(ctx,
581                                                 GL_ELEMENT_ARRAY_BUFFER_ARB,
582                                                 GL_DYNAMIC_DRAW_ARB,
583                                                 bufferobj);
584            map += offset;
585            get_space(brw, ib_size, &vbo, &voffset);
586            
587            ctx->Driver.BufferSubData(ctx,
588                                      GL_ELEMENT_ARRAY_BUFFER_ARB,
589                                      voffset,
590                                      ib_size,
591                                      map,
592                                      vbo);
593            ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, bufferobj);
594
595            bufferobj = vbo;
596            offset = voffset;
597        }
598    }
599
600    /* Emit the indexbuffer packet:
601     */
602    {
603       struct brw_indexbuffer ib;
604       dri_bo *buffer = intel_bufferobj_buffer(intel,
605                                               intel_buffer_object(bufferobj),
606                                               INTEL_READ);
607
608       memset(&ib, 0, sizeof(ib));
609    
610       ib.header.bits.opcode = CMD_INDEX_BUFFER;
611       ib.header.bits.length = sizeof(ib)/4 - 2;
612       ib.header.bits.index_format = get_index_type(index_buffer->type);
613       ib.header.bits.cut_index_enable = 0;
614    
615
616       BEGIN_BATCH(4, IGNORE_CLIPRECTS);
617       OUT_BATCH( ib.header.dword );
618       OUT_RELOC( buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, offset);
619       OUT_RELOC( buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
620                  offset + ib_size);
621       OUT_BATCH( 0 );
622       ADVANCE_BATCH();
623    }
624 }