1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
30 * Michel Dänzer <michel@tungstengraphics.com>
33 #include "pipe/p_state.h"
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36 #include "util/u_inlines.h"
37 #include "util/u_format.h"
38 #include "util/u_math.h"
39 #include "util/u_memory.h"
41 #include "i915_context.h"
42 #include "i915_resource.h"
43 #include "i915_screen.h"
44 #include "i915_winsys.h"
47 #define DEBUG_TEXTURES 0
50 * Helper function and arrays
55 * Initial offset for Cube map.
57 static const int initial_offsets
[6][2] = {
67 * Step offsets for Cube map.
69 static const int step_offsets
[6][2] = {
78 /* XXX really need twice the size if x is already pot?
79 Otherwise just use util_next_power_of_two?
82 power_of_two(unsigned x
)
92 * More advanced helper funcs
97 i915_texture_set_level_info(struct i915_texture
*tex
,
98 unsigned level
, unsigned nr_images
)
100 assert(level
< Elements(tex
->nr_images
));
102 assert(!tex
->image_offset
[level
]);
104 tex
->nr_images
[level
] = nr_images
;
105 tex
->image_offset
[level
] = (unsigned *) MALLOC(nr_images
* sizeof(unsigned));
106 tex
->image_offset
[level
][0] = 0;
110 i915_texture_set_image_offset(struct i915_texture
*tex
,
111 unsigned level
, unsigned img
,
112 unsigned x
, unsigned y
)
114 /* for the first image and level make sure offset is zero */
115 assert(!(img
== 0 && level
== 0) || (x
== 0 && y
== 0));
116 assert(img
< tex
->nr_images
[level
]);
118 tex
->image_offset
[level
][img
] = y
* tex
->stride
+ x
* util_format_get_blocksize(tex
->b
.b
.format
);
121 debug_printf("%s: %p level %u, img %u (%u, %u) %p\n", __FUNCTION__
,
122 tex
, level
, img
, x
, y
,
123 (void*)(uintptr_t)tex
->image_offset
[level
][img
]);
129 * Shared layout functions
134 * Special case to deal with scanout textures.
137 i9x5_scanout_layout(struct i915_texture
*tex
)
139 struct pipe_resource
*pt
= &tex
->b
.b
;
141 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
144 i915_texture_set_level_info(tex
, 0, 1);
145 i915_texture_set_image_offset(tex
, 0, 0, 0, 0);
147 if (pt
->width0
>= 240) {
148 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
149 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
150 tex
->hw_tiled
= I915_TILE_X
;
151 } else if (pt
->width0
== 64 && pt
->height0
== 64) {
152 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
153 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
159 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
160 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
161 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
168 * Special case to deal with shared textures.
171 i9x5_display_target_layout(struct i915_texture
*tex
)
173 struct pipe_resource
*pt
= &tex
->b
.b
;
175 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
178 /* fallback to normal textures for small textures */
179 if (pt
->width0
< 240)
182 i915_texture_set_level_info(tex
, 0, 1);
183 i915_texture_set_image_offset(tex
, 0, 0, 0, 0);
185 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
186 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
187 tex
->hw_tiled
= I915_TILE_X
;
190 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
191 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
192 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
199 * Helper function for special layouts
202 i9x5_special_layout(struct i915_texture
*tex
)
204 struct pipe_resource
*pt
= &tex
->b
.b
;
206 /* Scanouts needs special care */
207 if (pt
->bind
& PIPE_BIND_SCANOUT
)
208 if (i9x5_scanout_layout(tex
))
211 /* Shared buffers needs to be compatible with X servers
213 * XXX: need a better name than shared for this if it is to be part
214 * of core gallium, and probably move the flag to resource.flags,
215 * rather than bindings.
217 if (pt
->bind
& (PIPE_BIND_SHARED
| PIPE_BIND_DISPLAY_TARGET
))
218 if (i9x5_display_target_layout(tex
))
226 * i915 layout functions
231 i915_texture_layout_2d(struct i915_texture
*tex
)
233 struct pipe_resource
*pt
= &tex
->b
.b
;
235 unsigned width
= pt
->width0
;
236 unsigned height
= pt
->height0
;
237 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
238 unsigned align_y
= 2;
240 if (util_format_is_s3tc(pt
->format
))
243 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
244 tex
->total_nblocksy
= 0;
246 for (level
= 0; level
<= pt
->last_level
; level
++) {
247 i915_texture_set_level_info(tex
, level
, 1);
248 i915_texture_set_image_offset(tex
, level
, 0, 0, tex
->total_nblocksy
);
250 tex
->total_nblocksy
+= nblocksy
;
252 width
= u_minify(width
, 1);
253 height
= u_minify(height
, 1);
254 nblocksy
= align(util_format_get_nblocksy(pt
->format
, height
), align_y
);
259 i915_texture_layout_3d(struct i915_texture
*tex
)
261 struct pipe_resource
*pt
= &tex
->b
.b
;
264 unsigned width
= pt
->width0
;
265 unsigned height
= pt
->height0
;
266 unsigned depth
= pt
->depth0
;
267 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
268 unsigned stack_nblocksy
= 0;
270 /* Calculate the size of a single slice.
272 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
274 /* XXX: hardware expects/requires 9 levels at minimum.
276 for (level
= 0; level
<= MAX2(8, pt
->last_level
); level
++) {
277 i915_texture_set_level_info(tex
, level
, depth
);
279 stack_nblocksy
+= MAX2(2, nblocksy
);
281 width
= u_minify(width
, 1);
282 height
= u_minify(height
, 1);
283 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
286 /* Fixup depth image_offsets:
288 for (level
= 0; level
<= pt
->last_level
; level
++) {
290 for (i
= 0; i
< depth
; i
++)
291 i915_texture_set_image_offset(tex
, level
, i
, 0, i
* stack_nblocksy
);
293 depth
= u_minify(depth
, 1);
296 /* Multiply slice size by texture depth for total size. It's
297 * remarkable how wasteful of memory the i915 texture layouts
298 * are. They are largely fixed in the i945.
300 tex
->total_nblocksy
= stack_nblocksy
* pt
->depth0
;
304 i915_texture_layout_cube(struct i915_texture
*tex
)
306 struct pipe_resource
*pt
= &tex
->b
.b
;
307 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
311 assert(pt
->width0
== pt
->height0
); /* cubemap images are square */
313 /* double pitch for cube layouts */
314 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
315 tex
->total_nblocksy
= nblocks
* 4;
317 for (level
= 0; level
<= pt
->last_level
; level
++)
318 i915_texture_set_level_info(tex
, level
, 6);
320 for (face
= 0; face
< 6; face
++) {
321 unsigned x
= initial_offsets
[face
][0] * nblocks
;
322 unsigned y
= initial_offsets
[face
][1] * nblocks
;
323 unsigned d
= nblocks
;
325 for (level
= 0; level
<= pt
->last_level
; level
++) {
326 i915_texture_set_image_offset(tex
, level
, face
, x
, y
);
328 x
+= step_offsets
[face
][0] * d
;
329 y
+= step_offsets
[face
][1] * d
;
335 i915_texture_layout(struct i915_texture
* tex
)
337 struct pipe_resource
*pt
= &tex
->b
.b
;
339 switch (pt
->target
) {
340 case PIPE_TEXTURE_1D
:
341 case PIPE_TEXTURE_2D
:
342 if (!i9x5_special_layout(tex
))
343 i915_texture_layout_2d(tex
);
345 case PIPE_TEXTURE_3D
:
346 i915_texture_layout_3d(tex
);
348 case PIPE_TEXTURE_CUBE
:
349 i915_texture_layout_cube(tex
);
361 * i945 layout functions
366 i945_texture_layout_2d(struct i915_texture
*tex
)
368 struct pipe_resource
*pt
= &tex
->b
.b
;
369 int align_x
= 4, align_y
= 2;
373 unsigned width
= pt
->width0
;
374 unsigned height
= pt
->height0
;
375 unsigned nblocksx
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
376 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
378 if (util_format_is_s3tc(pt
->format
)) {
383 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
385 /* May need to adjust pitch to accomodate the placement of
386 * the 2nd mipmap level. This occurs when the alignment
387 * constraints of mipmap placement push the right edge of the
388 * 2nd mipmap level out past the width of its parent.
390 if (pt
->last_level
> 0) {
391 unsigned mip1_nblocksx
=
392 align(util_format_get_nblocksx(pt
->format
, u_minify(pt
->width0
, 1)), align_x
) +
393 util_format_get_nblocksx(pt
->format
, u_minify(pt
->width0
, 2));
395 if (mip1_nblocksx
> nblocksx
)
396 tex
->stride
= mip1_nblocksx
* util_format_get_blocksize(pt
->format
);
399 /* Pitch must be a whole number of dwords
401 tex
->stride
= align(tex
->stride
, 64);
402 tex
->total_nblocksy
= 0;
404 for (level
= 0; level
<= pt
->last_level
; level
++) {
405 i915_texture_set_level_info(tex
, level
, 1);
406 i915_texture_set_image_offset(tex
, level
, 0, x
, y
);
408 /* Because the images are packed better, the final offset
409 * might not be the maximal one:
411 tex
->total_nblocksy
= MAX2(tex
->total_nblocksy
, y
+ nblocksy
);
413 /* Layout_below: step right after second mipmap level.
421 width
= u_minify(width
, 1);
422 height
= u_minify(height
, 1);
423 nblocksx
= align(util_format_get_nblocksx(pt
->format
, width
), align_x
);
424 nblocksy
= align(util_format_get_nblocksy(pt
->format
, height
), align_y
);
429 i945_texture_layout_3d(struct i915_texture
*tex
)
431 struct pipe_resource
*pt
= &tex
->b
.b
;
432 unsigned width
= pt
->width0
;
433 unsigned height
= pt
->height0
;
434 unsigned depth
= pt
->depth0
;
435 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
436 unsigned pack_x_pitch
, pack_x_nr
;
437 unsigned pack_y_pitch
;
440 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
441 tex
->total_nblocksy
= 0;
443 pack_y_pitch
= MAX2(nblocksy
, 2);
444 pack_x_pitch
= tex
->stride
/ util_format_get_blocksize(pt
->format
);
447 for (level
= 0; level
<= pt
->last_level
; level
++) {
452 i915_texture_set_level_info(tex
, level
, depth
);
454 for (q
= 0; q
< depth
;) {
455 for (j
= 0; j
< pack_x_nr
&& q
< depth
; j
++, q
++) {
456 i915_texture_set_image_offset(tex
, level
, q
, x
, y
+ tex
->total_nblocksy
);
464 tex
->total_nblocksy
+= y
;
466 if (pack_x_pitch
> 4) {
469 assert(pack_x_pitch
* pack_x_nr
* util_format_get_blocksize(pt
->format
) <= tex
->stride
);
472 if (pack_y_pitch
> 2) {
476 width
= u_minify(width
, 1);
477 height
= u_minify(height
, 1);
478 depth
= u_minify(depth
, 1);
479 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
484 i945_texture_layout_cube(struct i915_texture
*tex
)
486 struct pipe_resource
*pt
= &tex
->b
.b
;
488 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
492 printf("%s %i, %i\n", __FUNCTION__, pt->width0, pt->height0);
495 assert(pt
->width0
== pt
->height0
); /* cubemap images are square */
498 * XXX Should only be used for compressed formats. But lets
499 * keep this code active just in case.
501 * Depending on the size of the largest images, pitch can be
502 * determined either by the old-style packing of cubemap faces,
503 * or the final row of 4x4, 2x2 and 1x1 faces below this.
506 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
508 tex
->stride
= 14 * 8 * util_format_get_blocksize(pt
->format
);
510 tex
->total_nblocksy
= nblocks
* 4;
512 /* Set all the levels to effectively occupy the whole rectangular region.
514 for (level
= 0; level
<= pt
->last_level
; level
++)
515 i915_texture_set_level_info(tex
, level
, 6);
517 for (face
= 0; face
< 6; face
++) {
518 unsigned x
= initial_offsets
[face
][0] * nblocks
;
519 unsigned y
= initial_offsets
[face
][1] * nblocks
;
520 unsigned d
= nblocks
;
522 #if 0 /* Fix and enable this code for compressed formats */
523 if (nblocks
== 4 && face
>= 4) {
524 y
= tex
->total_height
- 4;
527 else if (nblocks
< 4 && (face
> 0)) {
528 y
= tex
->total_height
- 4;
533 for (level
= 0; level
<= pt
->last_level
; level
++) {
534 i915_texture_set_image_offset(tex
, level
, face
, x
, y
);
538 #if 0 /* Fix and enable this code for compressed formats */
542 case PIPE_TEX_FACE_POS_X
:
543 case PIPE_TEX_FACE_NEG_X
:
544 x
+= step_offsets
[face
][0] * d
;
545 y
+= step_offsets
[face
][1] * d
;
547 case PIPE_TEX_FACE_POS_Y
:
548 case PIPE_TEX_FACE_NEG_Y
:
552 case PIPE_TEX_FACE_POS_Z
:
553 case PIPE_TEX_FACE_NEG_Z
:
554 y
= tex
->total_height
- 4;
559 y
= tex
->total_height
- 4;
568 x
+= step_offsets
[face
][0] * d
;
569 y
+= step_offsets
[face
][1] * d
;
579 i945_texture_layout(struct i915_texture
* tex
)
581 struct pipe_resource
*pt
= &tex
->b
.b
;
583 switch (pt
->target
) {
584 case PIPE_TEXTURE_1D
:
585 case PIPE_TEXTURE_2D
:
586 if (!i9x5_special_layout(tex
))
587 i945_texture_layout_2d(tex
);
589 case PIPE_TEXTURE_3D
:
590 i945_texture_layout_3d(tex
);
592 case PIPE_TEXTURE_CUBE
:
593 i945_texture_layout_cube(tex
);
606 * Screen texture functions
612 i915_texture_get_handle(struct pipe_screen
* screen
,
613 struct pipe_resource
*texture
,
614 struct winsys_handle
*whandle
)
616 struct i915_screen
*is
= i915_screen(screen
);
617 struct i915_texture
*tex
= i915_texture(texture
);
618 struct i915_winsys
*iws
= is
->iws
;
620 return iws
->buffer_get_handle(iws
, tex
->buffer
, whandle
, tex
->stride
);
625 i915_texture_destroy(struct pipe_screen
*screen
,
626 struct pipe_resource
*pt
)
628 struct i915_texture
*tex
= i915_texture(pt
);
629 struct i915_winsys
*iws
= i915_screen(screen
)->iws
;
632 iws
->buffer_destroy(iws
, tex
->buffer
);
634 for (i
= 0; i
< Elements(tex
->image_offset
); i
++)
635 if (tex
->image_offset
[i
])
636 FREE(tex
->image_offset
[i
]);
641 static struct pipe_transfer
*
642 i915_texture_get_transfer(struct pipe_context
*context
,
643 struct pipe_resource
*resource
,
644 struct pipe_subresource sr
,
646 const struct pipe_box
*box
)
648 struct i915_texture
*tex
= i915_texture(resource
);
649 struct pipe_transfer
*transfer
= CALLOC_STRUCT(pipe_transfer
);
650 if (transfer
== NULL
)
653 transfer
->resource
= resource
;
655 transfer
->usage
= usage
;
656 transfer
->box
= *box
;
657 transfer
->stride
= tex
->stride
;
664 i915_texture_transfer_map(struct pipe_context
*pipe
,
665 struct pipe_transfer
*transfer
)
667 struct pipe_resource
*resource
= transfer
->resource
;
668 struct i915_texture
*tex
= i915_texture(resource
);
669 struct i915_winsys
*iws
= i915_screen(pipe
->screen
)->iws
;
670 struct pipe_subresource sr
= transfer
->sr
;
671 struct pipe_box
*box
= &transfer
->box
;
672 enum pipe_format format
= resource
->format
;
676 if (resource
->target
== PIPE_TEXTURE_CUBE
) {
677 offset
= tex
->image_offset
[sr
.level
][sr
.face
];
678 } else if (resource
->target
== PIPE_TEXTURE_3D
) {
679 offset
= tex
->image_offset
[sr
.level
][box
->z
];
681 offset
= tex
->image_offset
[sr
.level
][0];
682 assert(sr
.face
== 0);
686 map
= iws
->buffer_map(iws
, tex
->buffer
,
687 (transfer
->usage
& PIPE_TRANSFER_WRITE
) ? TRUE
: FALSE
);
691 return map
+ offset
+
692 box
->y
/ util_format_get_blockheight(format
) * transfer
->stride
+
693 box
->x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
697 i915_texture_transfer_unmap(struct pipe_context
*pipe
,
698 struct pipe_transfer
*transfer
)
700 struct i915_texture
*tex
= i915_texture(transfer
->resource
);
701 struct i915_winsys
*iws
= i915_screen(tex
->b
.b
.screen
)->iws
;
702 iws
->buffer_unmap(iws
, tex
->buffer
);
707 struct u_resource_vtbl i915_texture_vtbl
=
709 i915_texture_get_handle
, /* get_handle */
710 i915_texture_destroy
, /* resource_destroy */
711 NULL
, /* is_resource_referenced */
712 i915_texture_get_transfer
, /* get_transfer */
713 u_default_transfer_destroy
, /* transfer_destroy */
714 i915_texture_transfer_map
, /* transfer_map */
715 u_default_transfer_flush_region
, /* transfer_flush_region */
716 i915_texture_transfer_unmap
, /* transfer_unmap */
717 u_default_transfer_inline_write
/* transfer_inline_write */
723 struct pipe_resource
*
724 i915_texture_create(struct pipe_screen
*screen
,
725 const struct pipe_resource
*template)
727 struct i915_screen
*is
= i915_screen(screen
);
728 struct i915_winsys
*iws
= is
->iws
;
729 struct i915_texture
*tex
= CALLOC_STRUCT(i915_texture
);
731 unsigned buf_usage
= 0;
736 tex
->b
.b
= *template;
737 tex
->b
.vtbl
= &i915_texture_vtbl
;
738 pipe_reference_init(&tex
->b
.b
.reference
, 1);
739 tex
->b
.b
.screen
= screen
;
742 if (!i945_texture_layout(tex
))
745 if (!i915_texture_layout(tex
))
749 tex_size
= tex
->stride
* tex
->total_nblocksy
;
751 /* for scanouts and cursors, cursors arn't scanouts */
753 /* XXX: use a custom flag for cursors, don't rely on magically
754 * guessing that this is Xorg asking for a cursor
756 if ((template->bind
& PIPE_BIND_SCANOUT
) && template->width0
!= 64)
757 buf_usage
= I915_NEW_SCANOUT
;
759 buf_usage
= I915_NEW_TEXTURE
;
761 tex
->buffer
= iws
->buffer_create(iws
, tex_size
, 64, buf_usage
);
765 /* setup any hw fences */
767 assert(tex
->sw_tiled
== I915_TILE_NONE
);
768 iws
->buffer_set_fence_reg(iws
, tex
->buffer
, tex
->stride
, tex
->hw_tiled
);
773 void *ptr
= ws
->buffer_map(ws
, tex
->buffer
,
774 PIPE_BUFFER_USAGE_CPU_WRITE
);
775 memset(ptr
, 0x80, tex_size
);
776 ws
->buffer_unmap(ws
, tex
->buffer
);
780 debug_printf("%s: %p size %u, stride %u, blocks (%u, %u)\n", __func__
,
781 tex
, (unsigned int)tex_size
, tex
->stride
,
782 tex
->stride
/ util_format_get_blocksize(tex
->b
.b
.format
),
783 tex
->total_nblocksy
);
793 struct pipe_resource
*
794 i915_texture_from_handle(struct pipe_screen
* screen
,
795 const struct pipe_resource
*template,
796 struct winsys_handle
*whandle
)
798 struct i915_screen
*is
= i915_screen(screen
);
799 struct i915_texture
*tex
;
800 struct i915_winsys
*iws
= is
->iws
;
801 struct i915_winsys_buffer
*buffer
;
806 buffer
= iws
->buffer_from_handle(iws
, whandle
, &stride
);
808 /* Only supports one type */
809 if (template->target
!= PIPE_TEXTURE_2D
||
810 template->last_level
!= 0 ||
811 template->depth0
!= 1) {
815 tex
= CALLOC_STRUCT(i915_texture
);
819 tex
->b
.b
= *template;
820 tex
->b
.vtbl
= &i915_texture_vtbl
;
821 pipe_reference_init(&tex
->b
.b
.reference
, 1);
822 tex
->b
.b
.screen
= screen
;
824 tex
->stride
= stride
;
826 i915_texture_set_level_info(tex
, 0, 1);
827 i915_texture_set_image_offset(tex
, 0, 0, 0, 0);
829 tex
->buffer
= buffer
;