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 "pipe/p_inlines.h"
37 #include "pipe/internal/p_winsys_screen.h"
38 #include "util/u_format.h"
39 #include "util/u_math.h"
40 #include "util/u_memory.h"
42 #include "i915_context.h"
43 #include "i915_texture.h"
44 #include "i915_screen.h"
45 #include "intel_winsys.h"
49 * Helper function and arrays
54 * Initial offset for Cube map.
56 static const int initial_offsets
[6][2] = {
66 * Step offsets for Cube map.
68 static const int step_offsets
[6][2] = {
77 /* XXX really need twice the size if x is already pot?
78 Otherwise just use util_next_power_of_two?
81 power_of_two(unsigned x
)
90 * More advanced helper funcs
95 i915_miptree_set_level_info(struct i915_texture
*tex
,
98 unsigned w
, unsigned h
, unsigned d
)
100 assert(level
< PIPE_MAX_TEXTURE_LEVELS
);
102 tex
->nr_images
[level
] = nr_images
;
105 DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
106 level, w, h, d, x, y, tex->level_offset[level]);
109 /* Not sure when this would happen, but anyway:
111 if (tex
->image_offset
[level
]) {
112 FREE(tex
->image_offset
[level
]);
113 tex
->image_offset
[level
] = NULL
;
117 assert(!tex
->image_offset
[level
]);
119 tex
->image_offset
[level
] = (unsigned *) MALLOC(nr_images
* sizeof(unsigned));
120 tex
->image_offset
[level
][0] = 0;
124 i915_miptree_set_image_offset(struct i915_texture
*tex
,
125 unsigned level
, unsigned img
, unsigned x
, unsigned y
)
127 if (img
== 0 && level
== 0)
128 assert(x
== 0 && y
== 0);
130 assert(img
< tex
->nr_images
[level
]);
132 tex
->image_offset
[level
][img
] = y
* tex
->stride
+ x
* util_format_get_blocksize(tex
->base
.format
);
135 printf("%s level %d img %d pos %d,%d image_offset %x\n",
136 __FUNCTION__, level, img, x, y, tex->image_offset[level][img]);
142 * i915 layout functions, some used by i945
147 * Special case to deal with scanout textures.
150 i915_scanout_layout(struct i915_texture
*tex
)
152 struct pipe_texture
*pt
= &tex
->base
;
154 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
157 i915_miptree_set_level_info(tex
, 0, 1,
161 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
163 if (pt
->width0
>= 240) {
164 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
165 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
166 tex
->hw_tiled
= INTEL_TILE_X
;
167 } else if (pt
->width0
== 64 && pt
->height0
== 64) {
168 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
169 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
174 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
175 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
176 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
182 * Special case to deal with shared textures.
185 i915_display_target_layout(struct i915_texture
*tex
)
187 struct pipe_texture
*pt
= &tex
->base
;
189 if (pt
->last_level
> 0 || util_format_get_blocksize(pt
->format
) != 4)
192 /* fallback to normal textures for small textures */
193 if (pt
->width0
< 240)
196 i915_miptree_set_level_info(tex
, 0, 1,
200 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
202 tex
->stride
= power_of_two(util_format_get_stride(pt
->format
, pt
->width0
));
203 tex
->total_nblocksy
= align(util_format_get_nblocksy(pt
->format
, pt
->height0
), 8);
204 tex
->hw_tiled
= INTEL_TILE_X
;
206 debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__
,
207 pt
->width0
, pt
->height0
, util_format_get_blocksize(pt
->format
),
208 tex
->stride
, tex
->total_nblocksy
, tex
->stride
* tex
->total_nblocksy
);
214 i915_miptree_layout_2d(struct i915_texture
*tex
)
216 struct pipe_texture
*pt
= &tex
->base
;
218 unsigned width
= pt
->width0
;
219 unsigned height
= pt
->height0
;
220 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
222 /* used for scanouts that need special layouts */
223 if (pt
->tex_usage
& PIPE_TEXTURE_USAGE_PRIMARY
)
224 if (i915_scanout_layout(tex
))
227 /* for shared buffers we use some very like scanout */
228 if (pt
->tex_usage
& PIPE_TEXTURE_USAGE_DISPLAY_TARGET
)
229 if (i915_display_target_layout(tex
))
232 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
233 tex
->total_nblocksy
= 0;
235 for (level
= 0; level
<= pt
->last_level
; level
++) {
236 i915_miptree_set_level_info(tex
, level
, 1, width
, height
, 1);
237 i915_miptree_set_image_offset(tex
, level
, 0, 0, tex
->total_nblocksy
);
239 nblocksy
= align(MAX2(2, nblocksy
), 2);
241 tex
->total_nblocksy
+= nblocksy
;
243 width
= u_minify(width
, 1);
244 height
= u_minify(height
, 1);
245 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
250 i915_miptree_layout_3d(struct i915_texture
*tex
)
252 struct pipe_texture
*pt
= &tex
->base
;
255 unsigned width
= pt
->width0
;
256 unsigned height
= pt
->height0
;
257 unsigned depth
= pt
->depth0
;
258 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
259 unsigned stack_nblocksy
= 0;
261 /* Calculate the size of a single slice.
263 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
265 /* XXX: hardware expects/requires 9 levels at minimum.
267 for (level
= 0; level
<= MAX2(8, pt
->last_level
); level
++) {
268 i915_miptree_set_level_info(tex
, level
, depth
, width
, height
, depth
);
270 stack_nblocksy
+= MAX2(2, nblocksy
);
272 width
= u_minify(width
, 1);
273 height
= u_minify(height
, 1);
274 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
277 /* Fixup depth image_offsets:
279 for (level
= 0; level
<= pt
->last_level
; level
++) {
281 for (i
= 0; i
< depth
; i
++)
282 i915_miptree_set_image_offset(tex
, level
, i
, 0, i
* stack_nblocksy
);
284 depth
= u_minify(depth
, 1);
287 /* Multiply slice size by texture depth for total size. It's
288 * remarkable how wasteful of memory the i915 texture layouts
289 * are. They are largely fixed in the i945.
291 tex
->total_nblocksy
= stack_nblocksy
* pt
->depth0
;
295 i915_miptree_layout_cube(struct i915_texture
*tex
)
297 struct pipe_texture
*pt
= &tex
->base
;
298 unsigned width
= pt
->width0
, height
= pt
->height0
;
299 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
303 assert(width
== height
); /* cubemap images are square */
305 /* double pitch for cube layouts */
306 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
307 tex
->total_nblocksy
= nblocks
* 4;
309 for (level
= 0; level
<= pt
->last_level
; level
++) {
310 i915_miptree_set_level_info(tex
, level
, 6, width
, height
, 1);
315 for (face
= 0; face
< 6; face
++) {
316 unsigned x
= initial_offsets
[face
][0] * nblocks
;
317 unsigned y
= initial_offsets
[face
][1] * nblocks
;
318 unsigned d
= nblocks
;
320 for (level
= 0; level
<= pt
->last_level
; level
++) {
321 i915_miptree_set_image_offset(tex
, level
, face
, x
, y
);
323 x
+= step_offsets
[face
][0] * d
;
324 y
+= step_offsets
[face
][1] * d
;
330 i915_miptree_layout(struct i915_texture
* tex
)
332 struct pipe_texture
*pt
= &tex
->base
;
334 switch (pt
->target
) {
335 case PIPE_TEXTURE_1D
:
336 case PIPE_TEXTURE_2D
:
337 i915_miptree_layout_2d(tex
);
339 case PIPE_TEXTURE_3D
:
340 i915_miptree_layout_3d(tex
);
342 case PIPE_TEXTURE_CUBE
:
343 i915_miptree_layout_cube(tex
);
355 * i945 layout functions
360 i945_miptree_layout_2d(struct i915_texture
*tex
)
362 struct pipe_texture
*pt
= &tex
->base
;
363 const int align_x
= 2, align_y
= 4;
367 unsigned width
= pt
->width0
;
368 unsigned height
= pt
->height0
;
369 unsigned nblocksx
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
370 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->height0
);
372 /* used for scanouts that need special layouts */
373 if (tex
->base
.tex_usage
& PIPE_TEXTURE_USAGE_PRIMARY
)
374 if (i915_scanout_layout(tex
))
377 /* for shared buffers we use some very like scanout */
378 if (tex
->base
.tex_usage
& PIPE_TEXTURE_USAGE_DISPLAY_TARGET
)
379 if (i915_display_target_layout(tex
))
382 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
384 /* May need to adjust pitch to accomodate the placement of
385 * the 2nd mipmap level. This occurs when the alignment
386 * constraints of mipmap placement push the right edge of the
387 * 2nd mipmap level out past the width of its parent.
389 if (pt
->last_level
> 0) {
390 unsigned mip1_nblocksx
391 = align(util_format_get_nblocksx(pt
->format
, u_minify(width
, 1)), align_x
)
392 + util_format_get_nblocksx(pt
->format
, u_minify(width
, 2));
394 if (mip1_nblocksx
> nblocksx
)
395 tex
->stride
= mip1_nblocksx
* util_format_get_blocksize(pt
->format
);
398 /* Pitch must be a whole number of dwords
400 tex
->stride
= align(tex
->stride
, 64);
401 tex
->total_nblocksy
= 0;
403 for (level
= 0; level
<= pt
->last_level
; level
++) {
404 i915_miptree_set_level_info(tex
, level
, 1, width
, height
, 1);
405 i915_miptree_set_image_offset(tex
, level
, 0, x
, y
);
407 nblocksy
= align(nblocksy
, align_y
);
409 /* Because the images are packed better, the final offset
410 * might not be the maximal one:
412 tex
->total_nblocksy
= MAX2(tex
->total_nblocksy
, y
+ nblocksy
);
414 /* Layout_below: step right after second mipmap level.
417 x
+= align(nblocksx
, align_x
);
423 width
= u_minify(width
, 1);
424 height
= u_minify(height
, 1);
425 nblocksx
= util_format_get_nblocksx(pt
->format
, width
);
426 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
431 i945_miptree_layout_3d(struct i915_texture
*tex
)
433 struct pipe_texture
*pt
= &tex
->base
;
434 unsigned width
= pt
->width0
;
435 unsigned height
= pt
->height0
;
436 unsigned depth
= pt
->depth0
;
437 unsigned nblocksy
= util_format_get_nblocksy(pt
->format
, pt
->width0
);
438 unsigned pack_x_pitch
, pack_x_nr
;
439 unsigned pack_y_pitch
;
442 tex
->stride
= align(util_format_get_stride(pt
->format
, pt
->width0
), 4);
443 tex
->total_nblocksy
= 0;
445 pack_y_pitch
= MAX2(nblocksy
, 2);
446 pack_x_pitch
= tex
->stride
/ util_format_get_blocksize(pt
->format
);
449 for (level
= 0; level
<= pt
->last_level
; level
++) {
454 i915_miptree_set_level_info(tex
, level
, depth
, width
, height
, depth
);
456 for (q
= 0; q
< depth
;) {
457 for (j
= 0; j
< pack_x_nr
&& q
< depth
; j
++, q
++) {
458 i915_miptree_set_image_offset(tex
, level
, q
, x
, y
+ tex
->total_nblocksy
);
466 tex
->total_nblocksy
+= y
;
468 if (pack_x_pitch
> 4) {
471 assert(pack_x_pitch
* pack_x_nr
* util_format_get_blocksize(pt
->format
) <= tex
->stride
);
474 if (pack_y_pitch
> 2) {
478 width
= u_minify(width
, 1);
479 height
= u_minify(height
, 1);
480 depth
= u_minify(depth
, 1);
481 nblocksy
= util_format_get_nblocksy(pt
->format
, height
);
486 i945_miptree_layout_cube(struct i915_texture
*tex
)
488 struct pipe_texture
*pt
= &tex
->base
;
491 const unsigned nblocks
= util_format_get_nblocksx(pt
->format
, pt
->width0
);
493 unsigned width
= pt
->width0
;
494 unsigned height
= pt
->height0
;
497 printf("%s %i, %i\n", __FUNCTION__, pt->width0, pt->height0);
500 assert(width
== height
); /* cubemap images are square */
503 * XXX Should only be used for compressed formats. But lets
504 * keep this code active just in case.
506 * Depending on the size of the largest images, pitch can be
507 * determined either by the old-style packing of cubemap faces,
508 * or the final row of 4x4, 2x2 and 1x1 faces below this.
511 tex
->stride
= align(nblocks
* util_format_get_blocksize(pt
->format
) * 2, 4);
513 tex
->stride
= 14 * 8 * util_format_get_blocksize(pt
->format
);
515 tex
->total_nblocksy
= nblocks
* 4;
517 /* Set all the levels to effectively occupy the whole rectangular region.
519 for (level
= 0; level
<= pt
->last_level
; level
++) {
520 i915_miptree_set_level_info(tex
, level
, 6, width
, height
, 1);
525 for (face
= 0; face
< 6; face
++) {
526 unsigned x
= initial_offsets
[face
][0] * nblocks
;
527 unsigned y
= initial_offsets
[face
][1] * nblocks
;
528 unsigned d
= nblocks
;
530 #if 0 /* Fix and enable this code for compressed formats */
531 if (nblocks
== 4 && face
>= 4) {
532 y
= tex
->total_height
- 4;
535 else if (nblocks
< 4 && (face
> 0)) {
536 y
= tex
->total_height
- 4;
541 for (level
= 0; level
<= pt
->last_level
; level
++) {
542 i915_miptree_set_image_offset(tex
, level
, face
, x
, y
);
546 #if 0 /* Fix and enable this code for compressed formats */
550 case PIPE_TEX_FACE_POS_X
:
551 case PIPE_TEX_FACE_NEG_X
:
552 x
+= step_offsets
[face
][0] * d
;
553 y
+= step_offsets
[face
][1] * d
;
555 case PIPE_TEX_FACE_POS_Y
:
556 case PIPE_TEX_FACE_NEG_Y
:
560 case PIPE_TEX_FACE_POS_Z
:
561 case PIPE_TEX_FACE_NEG_Z
:
562 y
= tex
->total_height
- 4;
567 y
= tex
->total_height
- 4;
576 x
+= step_offsets
[face
][0] * d
;
577 y
+= step_offsets
[face
][1] * d
;
587 i945_miptree_layout(struct i915_texture
* tex
)
589 struct pipe_texture
*pt
= &tex
->base
;
591 switch (pt
->target
) {
592 case PIPE_TEXTURE_1D
:
593 case PIPE_TEXTURE_2D
:
594 i945_miptree_layout_2d(tex
);
596 case PIPE_TEXTURE_3D
:
597 i945_miptree_layout_3d(tex
);
599 case PIPE_TEXTURE_CUBE
:
600 i945_miptree_layout_cube(tex
);
612 * Screen texture functions
616 static struct pipe_texture
*
617 i915_texture_create(struct pipe_screen
*screen
,
618 const struct pipe_texture
*templat
)
620 struct i915_screen
*is
= i915_screen(screen
);
621 struct intel_winsys
*iws
= is
->iws
;
622 struct i915_texture
*tex
= CALLOC_STRUCT(i915_texture
);
624 unsigned buf_usage
= 0;
629 tex
->base
= *templat
;
630 pipe_reference_init(&tex
->base
.reference
, 1);
631 tex
->base
.screen
= screen
;
634 if (!i945_miptree_layout(tex
))
637 if (!i915_miptree_layout(tex
))
641 tex_size
= tex
->stride
* tex
->total_nblocksy
;
645 /* for scanouts and cursors, cursors arn't scanouts */
646 if (templat
->tex_usage
& PIPE_TEXTURE_USAGE_PRIMARY
&& templat
->width0
!= 64)
647 buf_usage
= INTEL_NEW_SCANOUT
;
649 buf_usage
= INTEL_NEW_TEXTURE
;
651 tex
->buffer
= iws
->buffer_create(iws
, tex_size
, 64, buf_usage
);
655 /* setup any hw fences */
657 assert(tex
->sw_tiled
== INTEL_TILE_NONE
);
658 iws
->buffer_set_fence_reg(iws
, tex
->buffer
, tex
->stride
, tex
->hw_tiled
);
663 void *ptr
= ws
->buffer_map(ws
, tex
->buffer
,
664 PIPE_BUFFER_USAGE_CPU_WRITE
);
665 memset(ptr
, 0x80, tex_size
);
666 ws
->buffer_unmap(ws
, tex
->buffer
);
676 static struct pipe_texture
*
677 i915_texture_blanket(struct pipe_screen
* screen
,
678 const struct pipe_texture
*base
,
679 const unsigned *stride
,
680 struct pipe_buffer
*buffer
)
683 struct i915_texture
*tex
;
686 /* Only supports one type */
687 if (base
->target
!= PIPE_TEXTURE_2D
||
688 base
->last_level
!= 0 ||
693 tex
= CALLOC_STRUCT(i915_texture
);
698 pipe_reference_init(&tex
->base
.reference
, 1);
699 tex
->base
.screen
= screen
;
701 tex
->stride
= stride
[0];
703 i915_miptree_set_level_info(tex
, 0, 1, base
->width0
, base
->height0
, 1);
704 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
706 pipe_buffer_reference(&tex
->buffer
, buffer
);
715 i915_texture_destroy(struct pipe_texture
*pt
)
717 struct i915_texture
*tex
= (struct i915_texture
*)pt
;
718 struct intel_winsys
*iws
= i915_screen(pt
->screen
)->iws
;
722 DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
725 iws
->buffer_destroy(iws
, tex
->buffer
);
727 for (i
= 0; i
< PIPE_MAX_TEXTURE_LEVELS
; i
++)
728 if (tex
->image_offset
[i
])
729 FREE(tex
->image_offset
[i
]);
736 * Screen surface functions
740 static struct pipe_surface
*
741 i915_get_tex_surface(struct pipe_screen
*screen
,
742 struct pipe_texture
*pt
,
743 unsigned face
, unsigned level
, unsigned zslice
,
746 struct i915_texture
*tex
= (struct i915_texture
*)pt
;
747 struct pipe_surface
*ps
;
748 unsigned offset
; /* in bytes */
750 if (pt
->target
== PIPE_TEXTURE_CUBE
) {
751 offset
= tex
->image_offset
[level
][face
];
753 else if (pt
->target
== PIPE_TEXTURE_3D
) {
754 offset
= tex
->image_offset
[level
][zslice
];
757 offset
= tex
->image_offset
[level
][0];
762 ps
= CALLOC_STRUCT(pipe_surface
);
764 pipe_reference_init(&ps
->reference
, 1);
765 pipe_texture_reference(&ps
->texture
, pt
);
766 ps
->format
= pt
->format
;
767 ps
->width
= u_minify(pt
->width0
, level
);
768 ps
->height
= u_minify(pt
->height0
, level
);
776 i915_tex_surface_destroy(struct pipe_surface
*surf
)
778 pipe_texture_reference(&surf
->texture
, NULL
);
784 * Screen transfer functions
788 static struct pipe_transfer
*
789 i915_get_tex_transfer(struct pipe_screen
*screen
,
790 struct pipe_texture
*texture
,
791 unsigned face
, unsigned level
, unsigned zslice
,
792 enum pipe_transfer_usage usage
, unsigned x
, unsigned y
,
793 unsigned w
, unsigned h
)
795 struct i915_texture
*tex
= (struct i915_texture
*)texture
;
796 struct i915_transfer
*trans
;
797 unsigned offset
; /* in bytes */
799 if (texture
->target
== PIPE_TEXTURE_CUBE
) {
800 offset
= tex
->image_offset
[level
][face
];
802 else if (texture
->target
== PIPE_TEXTURE_3D
) {
803 offset
= tex
->image_offset
[level
][zslice
];
806 offset
= tex
->image_offset
[level
][0];
811 trans
= CALLOC_STRUCT(i915_transfer
);
813 pipe_texture_reference(&trans
->base
.texture
, texture
);
816 trans
->base
.width
= w
;
817 trans
->base
.height
= h
;
818 trans
->base
.stride
= tex
->stride
;
819 trans
->offset
= offset
;
820 trans
->base
.usage
= usage
;
826 i915_transfer_map(struct pipe_screen
*screen
,
827 struct pipe_transfer
*transfer
)
829 struct i915_texture
*tex
= (struct i915_texture
*)transfer
->texture
;
830 struct intel_winsys
*iws
= i915_screen(tex
->base
.screen
)->iws
;
832 boolean write
= FALSE
;
833 enum pipe_format format
= tex
->base
.format
;
835 if (transfer
->usage
& PIPE_TRANSFER_WRITE
)
838 map
= iws
->buffer_map(iws
, tex
->buffer
, write
);
842 return map
+ i915_transfer(transfer
)->offset
+
843 transfer
->y
/ util_format_get_blockheight(format
) * transfer
->stride
+
844 transfer
->x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
848 i915_transfer_unmap(struct pipe_screen
*screen
,
849 struct pipe_transfer
*transfer
)
851 struct i915_texture
*tex
= (struct i915_texture
*)transfer
->texture
;
852 struct intel_winsys
*iws
= i915_screen(tex
->base
.screen
)->iws
;
853 iws
->buffer_unmap(iws
, tex
->buffer
);
857 i915_tex_transfer_destroy(struct pipe_transfer
*trans
)
859 pipe_texture_reference(&trans
->texture
, NULL
);
865 * Other texture functions
870 i915_init_screen_texture_functions(struct i915_screen
*is
)
872 is
->base
.texture_create
= i915_texture_create
;
873 is
->base
.texture_blanket
= i915_texture_blanket
;
874 is
->base
.texture_destroy
= i915_texture_destroy
;
875 is
->base
.get_tex_surface
= i915_get_tex_surface
;
876 is
->base
.tex_surface_destroy
= i915_tex_surface_destroy
;
877 is
->base
.get_tex_transfer
= i915_get_tex_transfer
;
878 is
->base
.transfer_map
= i915_transfer_map
;
879 is
->base
.transfer_unmap
= i915_transfer_unmap
;
880 is
->base
.tex_transfer_destroy
= i915_tex_transfer_destroy
;
883 struct pipe_texture
*
884 i915_texture_blanket_intel(struct pipe_screen
*screen
,
885 struct pipe_texture
*base
,
887 struct intel_buffer
*buffer
)
889 struct i915_texture
*tex
;
892 /* Only supports one type */
893 if (base
->target
!= PIPE_TEXTURE_2D
||
894 base
->last_level
!= 0 ||
899 tex
= CALLOC_STRUCT(i915_texture
);
904 pipe_reference_init(&tex
->base
.reference
, 1);
905 tex
->base
.screen
= screen
;
907 tex
->stride
= stride
;
909 i915_miptree_set_level_info(tex
, 0, 1, base
->width0
, base
->height0
, 1);
910 i915_miptree_set_image_offset(tex
, 0, 0, 0, 0);
912 tex
->buffer
= buffer
;
918 i915_get_texture_buffer_intel(struct pipe_texture
*texture
,
919 struct intel_buffer
**buffer
,
922 struct i915_texture
*tex
= (struct i915_texture
*)texture
;
927 *stride
= tex
->stride
;
928 *buffer
= tex
->buffer
;