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_texture.h"
43 #include "i915_screen.h"
44 #include "intel_winsys.h"
48 * Helper function and arrays
53 * Initial offset for Cube map.
55 static const int initial_offsets
[6][2] = {
65 * Step offsets for Cube map.
67 static const int step_offsets
[6][2] = {
76 /* XXX really need twice the size if x is already pot?
77 Otherwise just use util_next_power_of_two?
80 power_of_two(unsigned x
)
89 * More advanced helper funcs
94 i915_miptree_set_level_info(struct i915_texture
*tex
,
97 unsigned w
, unsigned h
, unsigned d
)
99 assert(level
< PIPE_MAX_TEXTURE_LEVELS
);
101 tex
->nr_images
[level
] = nr_images
;
104 DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
105 level, w, h, d, x, y, tex->level_offset[level]);
108 /* Not sure when this would happen, but anyway:
110 if (tex
->image_offset
[level
]) {
111 FREE(tex
->image_offset
[level
]);
112 tex
->image_offset
[level
] = NULL
;
116 assert(!tex
->image_offset
[level
]);
118 tex
->image_offset
[level
] = (unsigned *) MALLOC(nr_images
* sizeof(unsigned));
119 tex
->image_offset
[level
][0] = 0;
123 i915_miptree_set_image_offset(struct i915_texture
*tex
,
124 unsigned level
, unsigned img
, unsigned x
, unsigned y
)
126 if (img
== 0 && level
== 0)
127 assert(x
== 0 && y
== 0);
129 assert(img
< tex
->nr_images
[level
]);
131 tex
->image_offset
[level
][img
] = y
* tex
->stride
+ x
* util_format_get_blocksize(tex
->base
.format
);
134 printf("%s level %d img %d pos %d,%d image_offset %x\n",
135 __FUNCTION__, level, img, x, y, tex->image_offset[level][img]);
141 * i915 layout functions, some used by i945
146 * Special case to deal with scanout textures.
149 i915_scanout_layout(struct i915_texture
*tex
)
151 struct pipe_texture
*pt
= &tex
->base
;
153 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
156 i915_miptree_set_level_info(tex
, 0, 1,
160 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
162 if (pt
->width0
>= 240) {
163 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
164 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
165 tex
->hw_tiled
= INTEL_TILE_X
;
166 } else if (pt
->width0
== 64 && pt
->height0
== 64) {
167 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
168 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
173 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
174 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
175 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
181 * Special case to deal with shared textures.
184 i915_display_target_layout(struct i915_texture
*tex
)
186 struct pipe_texture
*pt
= &tex
->base
;
188 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
191 /* fallback to normal textures for small textures */
192 if (pt
->width0
< 240)
195 i915_miptree_set_level_info(tex
, 0, 1,
199 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
201 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
202 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
203 tex
->hw_tiled
= INTEL_TILE_X
;
205 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
206 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
207 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
213 i915_miptree_layout_2d(struct i915_texture
*tex
)
215 struct pipe_texture
*pt
= &tex
->base
;
217 unsigned width
= pt
->width0
;
218 unsigned height
= pt
->height0
;
219 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
221 /* used for scanouts that need special layouts */
222 if (pt
->tex_usage
& PIPE_TEXTURE_USAGE_SCANOUT
)
223 if (i915_scanout_layout(tex
))
226 /* shared buffers needs to be compatible with X servers */
227 if (pt
->tex_usage
& PIPE_TEXTURE_USAGE_SHARED
)
228 if (i915_display_target_layout(tex
))
231 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
232 tex
->total_nblocksy
= 0;
234 for (level
= 0; level
<= pt
->last_level
; level
++) {
235 i915_miptree_set_level_info(tex
, level
, 1, width
, height
, 1);
236 i915_miptree_set_image_offset(tex
, level
, 0, 0, tex
->total_nblocksy
);
238 nblocksy
= align(MAX2(2, nblocksy
), 2);
240 tex
->total_nblocksy
+= nblocksy
;
242 width
= u_minify(width
, 1);
243 height
= u_minify(height
, 1);
244 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
249 i915_miptree_layout_3d(struct i915_texture
*tex
)
251 struct pipe_texture
*pt
= &tex
->base
;
254 unsigned width
= pt
->width0
;
255 unsigned height
= pt
->height0
;
256 unsigned depth
= pt
->depth0
;
257 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
258 unsigned stack_nblocksy
= 0;
260 /* Calculate the size of a single slice.
262 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
264 /* XXX: hardware expects/requires 9 levels at minimum.
266 for (level
= 0; level
<= MAX2(8, pt
->last_level
); level
++) {
267 i915_miptree_set_level_info(tex
, level
, depth
, width
, height
, depth
);
269 stack_nblocksy
+= MAX2(2, nblocksy
);
271 width
= u_minify(width
, 1);
272 height
= u_minify(height
, 1);
273 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
276 /* Fixup depth image_offsets:
278 for (level
= 0; level
<= pt
->last_level
; level
++) {
280 for (i
= 0; i
< depth
; i
++)
281 i915_miptree_set_image_offset(tex
, level
, i
, 0, i
* stack_nblocksy
);
283 depth
= u_minify(depth
, 1);
286 /* Multiply slice size by texture depth for total size. It's
287 * remarkable how wasteful of memory the i915 texture layouts
288 * are. They are largely fixed in the i945.
290 tex
->total_nblocksy
= stack_nblocksy
* pt
->depth0
;
294 i915_miptree_layout_cube(struct i915_texture
*tex
)
296 struct pipe_texture
*pt
= &tex
->base
;
297 unsigned width
= pt
->width0
, height
= pt
->height0
;
298 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
302 assert(width
== height
); /* cubemap images are square */
304 /* double pitch for cube layouts */
305 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
306 tex
->total_nblocksy
= nblocks
* 4;
308 for (level
= 0; level
<= pt
->last_level
; level
++) {
309 i915_miptree_set_level_info(tex
, level
, 6, width
, height
, 1);
314 for (face
= 0; face
< 6; face
++) {
315 unsigned x
= initial_offsets
[face
][0] * nblocks
;
316 unsigned y
= initial_offsets
[face
][1] * nblocks
;
317 unsigned d
= nblocks
;
319 for (level
= 0; level
<= pt
->last_level
; level
++) {
320 i915_miptree_set_image_offset(tex
, level
, face
, x
, y
);
322 x
+= step_offsets
[face
][0] * d
;
323 y
+= step_offsets
[face
][1] * d
;
329 i915_miptree_layout(struct i915_texture
* tex
)
331 struct pipe_texture
*pt
= &tex
->base
;
333 switch (pt
->target
) {
334 case PIPE_TEXTURE_1D
:
335 case PIPE_TEXTURE_2D
:
336 i915_miptree_layout_2d(tex
);
338 case PIPE_TEXTURE_3D
:
339 i915_miptree_layout_3d(tex
);
341 case PIPE_TEXTURE_CUBE
:
342 i915_miptree_layout_cube(tex
);
354 * i945 layout functions
359 i945_miptree_layout_2d(struct i915_texture
*tex
)
361 struct pipe_texture
*pt
= &tex
->base
;
362 const int align_x
= 2, align_y
= 4;
366 unsigned width
= pt
->width0
;
367 unsigned height
= pt
->height0
;
368 unsigned nblocksx
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
369 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
371 /* used for scanouts that need special layouts */
372 if (tex
->base
.tex_usage
& PIPE_TEXTURE_USAGE_SCANOUT
)
373 if (i915_scanout_layout(tex
))
376 /* shared buffers needs to be compatible with X servers */
377 if (tex
->base
.tex_usage
& PIPE_TEXTURE_USAGE_SHARED
)
378 if (i915_display_target_layout(tex
))
381 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
383 /* May need to adjust pitch to accomodate the placement of
384 * the 2nd mipmap level. This occurs when the alignment
385 * constraints of mipmap placement push the right edge of the
386 * 2nd mipmap level out past the width of its parent.
388 if (pt
->last_level
> 0) {
389 unsigned mip1_nblocksx
390 = align(util_format_get_nblocksx(pt
->format
, u_minify(width
, 1)), align_x
)
391 + util_format_get_nblocksx(pt
->format
, u_minify(width
, 2));
393 if (mip1_nblocksx
> nblocksx
)
394 tex
->stride
= mip1_nblocksx
* util_format_get_blocksize(pt
->format
);
397 /* Pitch must be a whole number of dwords
399 tex
->stride
= align(tex
->stride
, 64);
400 tex
->total_nblocksy
= 0;
402 for (level
= 0; level
<= pt
->last_level
; level
++) {
403 i915_miptree_set_level_info(tex
, level
, 1, width
, height
, 1);
404 i915_miptree_set_image_offset(tex
, level
, 0, x
, y
);
406 nblocksy
= align(nblocksy
, align_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.
416 x
+= align(nblocksx
, align_x
);
422 width
= u_minify(width
, 1);
423 height
= u_minify(height
, 1);
424 nblocksx
= util_format_get_nblocksx(pt
->format
, width
);
425 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
430 i945_miptree_layout_3d(struct i915_texture
*tex
)
432 struct pipe_texture
*pt
= &tex
->base
;
433 unsigned width
= pt
->width0
;
434 unsigned height
= pt
->height0
;
435 unsigned depth
= pt
->depth0
;
436 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
437 unsigned pack_x_pitch
, pack_x_nr
;
438 unsigned pack_y_pitch
;
441 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
442 tex
->total_nblocksy
= 0;
444 pack_y_pitch
= MAX2(nblocksy
, 2);
445 pack_x_pitch
= tex
->stride
/ util_format_get_blocksize(pt
->format
);
448 for (level
= 0; level
<= pt
->last_level
; level
++) {
453 i915_miptree_set_level_info(tex
, level
, depth
, width
, height
, depth
);
455 for (q
= 0; q
< depth
;) {
456 for (j
= 0; j
< pack_x_nr
&& q
< depth
; j
++, q
++) {
457 i915_miptree_set_image_offset(tex
, level
, q
, x
, y
+ tex
->total_nblocksy
);
465 tex
->total_nblocksy
+= y
;
467 if (pack_x_pitch
> 4) {
470 assert(pack_x_pitch
* pack_x_nr
* util_format_get_blocksize(pt
->format
) <= tex
->stride
);
473 if (pack_y_pitch
> 2) {
477 width
= u_minify(width
, 1);
478 height
= u_minify(height
, 1);
479 depth
= u_minify(depth
, 1);
480 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
485 i945_miptree_layout_cube(struct i915_texture
*tex
)
487 struct pipe_texture
*pt
= &tex
->base
;
490 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
492 unsigned width
= pt
->width0
;
493 unsigned height
= pt
->height0
;
496 printf("%s %i, %i\n", __FUNCTION__, pt->width0, pt->height0);
499 assert(width
== height
); /* cubemap images are square */
502 * XXX Should only be used for compressed formats. But lets
503 * keep this code active just in case.
505 * Depending on the size of the largest images, pitch can be
506 * determined either by the old-style packing of cubemap faces,
507 * or the final row of 4x4, 2x2 and 1x1 faces below this.
510 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
512 tex
->stride
= 14 * 8 * util_format_get_blocksize(pt
->format
);
514 tex
->total_nblocksy
= nblocks
* 4;
516 /* Set all the levels to effectively occupy the whole rectangular region.
518 for (level
= 0; level
<= pt
->last_level
; level
++) {
519 i915_miptree_set_level_info(tex
, level
, 6, width
, height
, 1);
524 for (face
= 0; face
< 6; face
++) {
525 unsigned x
= initial_offsets
[face
][0] * nblocks
;
526 unsigned y
= initial_offsets
[face
][1] * nblocks
;
527 unsigned d
= nblocks
;
529 #if 0 /* Fix and enable this code for compressed formats */
530 if (nblocks
== 4 && face
>= 4) {
531 y
= tex
->total_height
- 4;
534 else if (nblocks
< 4 && (face
> 0)) {
535 y
= tex
->total_height
- 4;
540 for (level
= 0; level
<= pt
->last_level
; level
++) {
541 i915_miptree_set_image_offset(tex
, level
, face
, x
, y
);
545 #if 0 /* Fix and enable this code for compressed formats */
549 case PIPE_TEX_FACE_POS_X
:
550 case PIPE_TEX_FACE_NEG_X
:
551 x
+= step_offsets
[face
][0] * d
;
552 y
+= step_offsets
[face
][1] * d
;
554 case PIPE_TEX_FACE_POS_Y
:
555 case PIPE_TEX_FACE_NEG_Y
:
559 case PIPE_TEX_FACE_POS_Z
:
560 case PIPE_TEX_FACE_NEG_Z
:
561 y
= tex
->total_height
- 4;
566 y
= tex
->total_height
- 4;
575 x
+= step_offsets
[face
][0] * d
;
576 y
+= step_offsets
[face
][1] * d
;
586 i945_miptree_layout(struct i915_texture
* tex
)
588 struct pipe_texture
*pt
= &tex
->base
;
590 switch (pt
->target
) {
591 case PIPE_TEXTURE_1D
:
592 case PIPE_TEXTURE_2D
:
593 i945_miptree_layout_2d(tex
);
595 case PIPE_TEXTURE_3D
:
596 i945_miptree_layout_3d(tex
);
598 case PIPE_TEXTURE_CUBE
:
599 i945_miptree_layout_cube(tex
);
611 * Screen texture functions
615 static struct pipe_texture
*
616 i915_texture_create(struct pipe_screen
*screen
,
617 const struct pipe_texture
*templat
)
619 struct i915_screen
*is
= i915_screen(screen
);
620 struct intel_winsys
*iws
= is
->iws
;
621 struct i915_texture
*tex
= CALLOC_STRUCT(i915_texture
);
623 unsigned buf_usage
= 0;
628 tex
->base
= *templat
;
629 pipe_reference_init(&tex
->base
.reference
, 1);
630 tex
->base
.screen
= screen
;
633 if (!i945_miptree_layout(tex
))
636 if (!i915_miptree_layout(tex
))
640 tex_size
= tex
->stride
* tex
->total_nblocksy
;
644 /* for scanouts and cursors, cursors arn't scanouts */
645 if (templat
->tex_usage
& PIPE_TEXTURE_USAGE_SCANOUT
&& templat
->width0
!= 64)
646 buf_usage
= INTEL_NEW_SCANOUT
;
648 buf_usage
= INTEL_NEW_TEXTURE
;
650 tex
->buffer
= iws
->buffer_create(iws
, tex_size
, 64, buf_usage
);
654 /* setup any hw fences */
656 assert(tex
->sw_tiled
== INTEL_TILE_NONE
);
657 iws
->buffer_set_fence_reg(iws
, tex
->buffer
, tex
->stride
, tex
->hw_tiled
);
662 void *ptr
= ws
->buffer_map(ws
, tex
->buffer
,
663 PIPE_BUFFER_USAGE_CPU_WRITE
);
664 memset(ptr
, 0x80, tex_size
);
665 ws
->buffer_unmap(ws
, tex
->buffer
);
675 static struct pipe_texture
*
676 i915_texture_blanket(struct pipe_screen
* screen
,
677 const struct pipe_texture
*base
,
678 const unsigned *stride
,
679 struct pipe_buffer
*buffer
)
682 struct i915_texture
*tex
;
685 /* Only supports one type */
686 if (base
->target
!= PIPE_TEXTURE_2D
||
687 base
->last_level
!= 0 ||
692 tex
= CALLOC_STRUCT(i915_texture
);
697 pipe_reference_init(&tex
->base
.reference
, 1);
698 tex
->base
.screen
= screen
;
700 tex
->stride
= stride
[0];
702 i915_miptree_set_level_info(tex
, 0, 1, base
->width0
, base
->height0
, 1);
703 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
705 pipe_buffer_reference(&tex
->buffer
, buffer
);
714 i915_texture_destroy(struct pipe_texture
*pt
)
716 struct i915_texture
*tex
= (struct i915_texture
*)pt
;
717 struct intel_winsys
*iws
= i915_screen(pt
->screen
)->iws
;
721 DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
724 iws
->buffer_destroy(iws
, tex
->buffer
);
726 for (i
= 0; i
< PIPE_MAX_TEXTURE_LEVELS
; i
++)
727 if (tex
->image_offset
[i
])
728 FREE(tex
->image_offset
[i
]);
735 * Screen surface functions
739 static struct pipe_surface
*
740 i915_get_tex_surface(struct pipe_screen
*screen
,
741 struct pipe_texture
*pt
,
742 unsigned face
, unsigned level
, unsigned zslice
,
745 struct i915_texture
*tex
= (struct i915_texture
*)pt
;
746 struct pipe_surface
*ps
;
747 unsigned offset
; /* in bytes */
749 if (pt
->target
== PIPE_TEXTURE_CUBE
) {
750 offset
= tex
->image_offset
[level
][face
];
752 else if (pt
->target
== PIPE_TEXTURE_3D
) {
753 offset
= tex
->image_offset
[level
][zslice
];
756 offset
= tex
->image_offset
[level
][0];
761 ps
= CALLOC_STRUCT(pipe_surface
);
763 pipe_reference_init(&ps
->reference
, 1);
764 pipe_texture_reference(&ps
->texture
, pt
);
765 ps
->format
= pt
->format
;
766 ps
->width
= u_minify(pt
->width0
, level
);
767 ps
->height
= u_minify(pt
->height0
, level
);
775 i915_tex_surface_destroy(struct pipe_surface
*surf
)
777 pipe_texture_reference(&surf
->texture
, NULL
);
783 * Screen transfer functions
787 static struct pipe_transfer
*
788 i915_get_tex_transfer(struct pipe_screen
*screen
,
789 struct pipe_texture
*texture
,
790 unsigned face
, unsigned level
, unsigned zslice
,
791 enum pipe_transfer_usage usage
, unsigned x
, unsigned y
,
792 unsigned w
, unsigned h
)
794 struct i915_texture
*tex
= (struct i915_texture
*)texture
;
795 struct i915_transfer
*trans
;
796 unsigned offset
; /* in bytes */
798 if (texture
->target
== PIPE_TEXTURE_CUBE
) {
799 offset
= tex
->image_offset
[level
][face
];
801 else if (texture
->target
== PIPE_TEXTURE_3D
) {
802 offset
= tex
->image_offset
[level
][zslice
];
805 offset
= tex
->image_offset
[level
][0];
810 trans
= CALLOC_STRUCT(i915_transfer
);
812 pipe_texture_reference(&trans
->base
.texture
, texture
);
815 trans
->base
.width
= w
;
816 trans
->base
.height
= h
;
817 trans
->base
.stride
= tex
->stride
;
818 trans
->offset
= offset
;
819 trans
->base
.usage
= usage
;
825 i915_transfer_map(struct pipe_screen
*screen
,
826 struct pipe_transfer
*transfer
)
828 struct i915_texture
*tex
= (struct i915_texture
*)transfer
->texture
;
829 struct intel_winsys
*iws
= i915_screen(tex
->base
.screen
)->iws
;
831 boolean write
= FALSE
;
832 enum pipe_format format
= tex
->base
.format
;
834 if (transfer
->usage
& PIPE_TRANSFER_WRITE
)
837 map
= iws
->buffer_map(iws
, tex
->buffer
, write
);
841 return map
+ i915_transfer(transfer
)->offset
+
842 transfer
->y
/ util_format_get_blockheight(format
) * transfer
->stride
+
843 transfer
->x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
847 i915_transfer_unmap(struct pipe_screen
*screen
,
848 struct pipe_transfer
*transfer
)
850 struct i915_texture
*tex
= (struct i915_texture
*)transfer
->texture
;
851 struct intel_winsys
*iws
= i915_screen(tex
->base
.screen
)->iws
;
852 iws
->buffer_unmap(iws
, tex
->buffer
);
856 i915_tex_transfer_destroy(struct pipe_transfer
*trans
)
858 pipe_texture_reference(&trans
->texture
, NULL
);
864 * Other texture functions
869 i915_init_screen_texture_functions(struct i915_screen
*is
)
871 is
->base
.texture_create
= i915_texture_create
;
872 is
->base
.texture_blanket
= i915_texture_blanket
;
873 is
->base
.texture_destroy
= i915_texture_destroy
;
874 is
->base
.get_tex_surface
= i915_get_tex_surface
;
875 is
->base
.tex_surface_destroy
= i915_tex_surface_destroy
;
876 is
->base
.get_tex_transfer
= i915_get_tex_transfer
;
877 is
->base
.transfer_map
= i915_transfer_map
;
878 is
->base
.transfer_unmap
= i915_transfer_unmap
;
879 is
->base
.tex_transfer_destroy
= i915_tex_transfer_destroy
;
882 struct pipe_texture
*
883 i915_texture_blanket_intel(struct pipe_screen
*screen
,
884 struct pipe_texture
*base
,
886 struct intel_buffer
*buffer
)
888 struct i915_texture
*tex
;
891 /* Only supports one type */
892 if (base
->target
!= PIPE_TEXTURE_2D
||
893 base
->last_level
!= 0 ||
898 tex
= CALLOC_STRUCT(i915_texture
);
903 pipe_reference_init(&tex
->base
.reference
, 1);
904 tex
->base
.screen
= screen
;
906 tex
->stride
= stride
;
908 i915_miptree_set_level_info(tex
, 0, 1, base
->width0
, base
->height0
, 1);
909 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
911 tex
->buffer
= buffer
;
917 i915_get_texture_buffer_intel(struct pipe_texture
*texture
,
918 struct intel_buffer
**buffer
,
921 struct i915_texture
*tex
= (struct i915_texture
*)texture
;
926 *stride
= tex
->stride
;
927 *buffer
= tex
->buffer
;