5 #include "main/glheader.h"
6 #include "main/macros.h"
7 #include "main/mtypes.h"
8 #include "main/enums.h"
9 #include "main/colortab.h"
10 #include "main/convolve.h"
11 #include "main/context.h"
12 #include "main/simple_list.h"
13 #include "main/texcompress.h"
14 #include "main/texformat.h"
15 #include "main/texgetimage.h"
16 #include "main/texobj.h"
17 #include "main/texstore.h"
18 #include "main/teximage.h"
20 #include "intel_context.h"
21 #include "intel_mipmap_tree.h"
22 #include "intel_buffer_objects.h"
23 #include "intel_batchbuffer.h"
24 #include "intel_tex.h"
25 #include "intel_blit.h"
26 #include "intel_fbo.h"
28 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
30 /* Functions to store texture images. Where possible, mipmap_tree's
31 * will be created or further instantiated with image data, otherwise
32 * images will be stored in malloc'd memory. A validation step is
33 * required to pull those images into a mipmap tree, or otherwise
34 * decide a fallback is required.
53 /* Otherwise, store it in memory if (Border != 0) or (any dimension ==
56 * Otherwise, if max_level >= level >= min_level, create tree with
57 * space for textures from min_level down to max_level.
59 * Otherwise, create tree with space for textures from (level
60 * 0)..(1x1). Consider pruning this tree at a validation if the
64 guess_and_alloc_mipmap_tree(struct intel_context
*intel
,
65 struct intel_texture_object
*intelObj
,
66 struct intel_texture_image
*intelImage
,
67 GLboolean expect_accelerated_upload
)
71 GLuint width
= intelImage
->base
.Width
;
72 GLuint height
= intelImage
->base
.Height
;
73 GLuint depth
= intelImage
->base
.Depth
;
74 GLuint l2width
, l2height
, l2depth
;
75 GLuint i
, comp_byte
= 0;
77 DBG("%s\n", __FUNCTION__
);
79 if (intelImage
->base
.Border
||
80 ((intelImage
->base
._BaseFormat
== GL_DEPTH_COMPONENT
) &&
81 ((intelObj
->base
.WrapS
== GL_CLAMP_TO_BORDER
) ||
82 (intelObj
->base
.WrapT
== GL_CLAMP_TO_BORDER
))))
85 if (intelImage
->level
> intelObj
->base
.BaseLevel
&&
86 (intelImage
->base
.Width
== 1 ||
87 (intelObj
->base
.Target
!= GL_TEXTURE_1D
&&
88 intelImage
->base
.Height
== 1) ||
89 (intelObj
->base
.Target
== GL_TEXTURE_3D
&&
90 intelImage
->base
.Depth
== 1)))
93 /* If this image disrespects BaseLevel, allocate from level zero.
94 * Usually BaseLevel == 0, so it's unlikely to happen.
96 if (intelImage
->level
< intelObj
->base
.BaseLevel
)
99 firstLevel
= intelObj
->base
.BaseLevel
;
102 /* Figure out image dimensions at start level.
104 for (i
= intelImage
->level
; i
> firstLevel
; i
--) {
112 /* Guess a reasonable value for lastLevel. This is probably going
113 * to be wrong fairly often and might mean that we have to look at
114 * resizable buffers, or require that buffers implement lazy
115 * pagetable arrangements.
117 if ((intelObj
->base
.MinFilter
== GL_NEAREST
||
118 intelObj
->base
.MinFilter
== GL_LINEAR
) &&
119 intelImage
->level
== firstLevel
) {
120 lastLevel
= firstLevel
;
123 l2width
= logbase2(width
);
124 l2height
= logbase2(height
);
125 l2depth
= logbase2(depth
);
126 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
129 assert(!intelObj
->mt
);
130 if (intelImage
->base
.IsCompressed
)
131 comp_byte
= intel_compressed_num_bytes(intelImage
->base
.TexFormat
->MesaFormat
);
132 intelObj
->mt
= intel_miptree_create(intel
,
133 intelObj
->base
.Target
,
134 intelImage
->base
._BaseFormat
,
135 intelImage
->base
.InternalFormat
,
141 intelImage
->base
.TexFormat
->TexelBytes
,
143 expect_accelerated_upload
);
145 DBG("%s - success\n", __FUNCTION__
);
152 target_to_face(GLenum target
)
155 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
156 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
157 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
158 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
159 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
160 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
161 return ((GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
);
167 /* There are actually quite a few combinations this will work for,
168 * more than what I've listed here.
171 check_pbo_format(GLint internalFormat
,
172 GLenum format
, GLenum type
,
173 const struct gl_texture_format
*mesa_format
)
175 switch (internalFormat
) {
178 return (format
== GL_BGRA
&&
179 (type
== GL_UNSIGNED_BYTE
||
180 type
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
181 mesa_format
== &_mesa_texformat_argb8888
);
184 return (format
== GL_RGB
&&
185 type
== GL_UNSIGNED_SHORT_5_6_5
&&
186 mesa_format
== &_mesa_texformat_rgb565
);
188 return (type
== GL_UNSIGNED_SHORT_8_8_MESA
|| type
== GL_UNSIGNED_BYTE
);
195 /* XXX: Do this for TexSubImage also:
198 try_pbo_upload(struct intel_context
*intel
,
199 struct intel_texture_image
*intelImage
,
200 const struct gl_pixelstore_attrib
*unpack
,
201 GLint internalFormat
,
202 GLint width
, GLint height
,
203 GLenum format
, GLenum type
, const void *pixels
)
205 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
206 GLuint src_offset
, src_stride
;
207 GLuint dst_offset
, dst_stride
;
209 if (unpack
->BufferObj
->Name
== 0 ||
210 intel
->ctx
._ImageTransferState
||
211 unpack
->SkipPixels
|| unpack
->SkipRows
) {
212 DBG("%s: failure 1\n", __FUNCTION__
);
216 /* note: potential 64-bit ptr to 32-bit int cast */
217 src_offset
= (GLuint
) (unsigned long) pixels
;
219 if (unpack
->RowLength
> 0)
220 src_stride
= unpack
->RowLength
;
224 dst_offset
= intel_miptree_image_offset(intelImage
->mt
,
228 dst_stride
= intelImage
->mt
->pitch
;
230 intelFlush(&intel
->ctx
);
231 LOCK_HARDWARE(intel
);
233 dri_bo
*src_buffer
= intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
234 dri_bo
*dst_buffer
= intel_region_buffer(intel
,
235 intelImage
->mt
->region
,
239 if (!intelEmitCopyBlit(intel
,
241 src_stride
, src_buffer
, src_offset
, GL_FALSE
,
242 dst_stride
, dst_buffer
, dst_offset
, GL_FALSE
,
243 0, 0, 0, 0, width
, height
,
245 UNLOCK_HARDWARE(intel
);
249 UNLOCK_HARDWARE(intel
);
256 try_pbo_zcopy(struct intel_context
*intel
,
257 struct intel_texture_image
*intelImage
,
258 const struct gl_pixelstore_attrib
*unpack
,
259 GLint internalFormat
,
260 GLint width
, GLint height
,
261 GLenum format
, GLenum type
, const void *pixels
)
263 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
264 GLuint src_offset
, src_stride
;
265 GLuint dst_offset
, dst_stride
;
267 if (unpack
->BufferObj
->Name
== 0 ||
268 intel
->ctx
._ImageTransferState
||
269 unpack
->SkipPixels
|| unpack
->SkipRows
) {
270 DBG("%s: failure 1\n", __FUNCTION__
);
274 /* note: potential 64-bit ptr to 32-bit int cast */
275 src_offset
= (GLuint
) (unsigned long) pixels
;
277 if (unpack
->RowLength
> 0)
278 src_stride
= unpack
->RowLength
;
282 dst_offset
= intel_miptree_image_offset(intelImage
->mt
,
286 dst_stride
= intelImage
->mt
->pitch
;
288 if (src_stride
!= dst_stride
|| dst_offset
!= 0 || src_offset
!= 0) {
289 DBG("%s: failure 2\n", __FUNCTION__
);
293 intel_region_attach_pbo(intel
, intelImage
->mt
->region
, pbo
);
300 intelTexImage(GLcontext
* ctx
,
302 GLenum target
, GLint level
,
303 GLint internalFormat
,
304 GLint width
, GLint height
, GLint depth
,
306 GLenum format
, GLenum type
, const void *pixels
,
307 const struct gl_pixelstore_attrib
*unpack
,
308 struct gl_texture_object
*texObj
,
309 struct gl_texture_image
*texImage
, GLsizei imageSize
,
310 GLboolean compressed
)
312 struct intel_context
*intel
= intel_context(ctx
);
313 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
314 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
315 GLint postConvWidth
= width
;
316 GLint postConvHeight
= height
;
317 GLint texelBytes
, sizeInBytes
;
318 GLuint dstRowStride
= 0, srcRowStride
= texImage
->RowStride
;
320 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
321 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
325 intelImage
->face
= target_to_face(target
);
326 intelImage
->level
= level
;
328 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
329 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
333 /* choose the texture format */
334 texImage
->TexFormat
= intelChooseTextureFormat(ctx
, internalFormat
,
337 _mesa_set_fetch_functions(texImage
, dims
);
339 if (texImage
->TexFormat
->TexelBytes
== 0) {
340 /* must be a compressed format */
342 texImage
->IsCompressed
= GL_TRUE
;
343 texImage
->CompressedSize
=
344 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
345 texImage
->Height
, texImage
->Depth
,
346 texImage
->TexFormat
->MesaFormat
);
348 texelBytes
= texImage
->TexFormat
->TexelBytes
;
350 /* Minimum pitch of 32 bytes */
351 if (postConvWidth
* texelBytes
< 32) {
352 postConvWidth
= 32 / texelBytes
;
353 texImage
->RowStride
= postConvWidth
;
356 if (!intelImage
->mt
) {
357 assert(texImage
->RowStride
== postConvWidth
);
361 /* Release the reference to a potentially orphaned buffer.
362 * Release any old malloced memory.
364 if (intelImage
->mt
) {
365 intel_miptree_release(intel
, &intelImage
->mt
);
366 assert(!texImage
->Data
);
368 else if (texImage
->Data
) {
369 _mesa_free_texmemory(texImage
->Data
);
370 texImage
->Data
= NULL
;
373 /* If this is the only texture image in the tree, could call
374 * bmBufferData with NULL data to free the old block and avoid
375 * waiting on any outstanding fences.
378 intelObj
->mt
->first_level
== level
&&
379 intelObj
->mt
->last_level
== level
&&
380 intelObj
->mt
->target
!= GL_TEXTURE_CUBE_MAP_ARB
&&
381 !intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
382 intelImage
->face
, intelImage
->level
)) {
385 intel_miptree_release(intel
, &intelObj
->mt
);
386 assert(!intelObj
->mt
);
390 guess_and_alloc_mipmap_tree(intel
, intelObj
, intelImage
, pixels
== NULL
);
392 DBG("guess_and_alloc_mipmap_tree: failed\n");
396 assert(!intelImage
->mt
);
399 intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
400 intelImage
->face
, intelImage
->level
)) {
402 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
403 assert(intelImage
->mt
);
404 } else if (intelImage
->base
.Border
== 0) {
407 if (intelImage
->base
.IsCompressed
) {
409 intel_compressed_num_bytes(intelImage
->base
.TexFormat
->MesaFormat
);
412 /* Didn't fit in the object miptree, but it's suitable for inclusion in
413 * a miptree, so create one just for our level and store it in the image.
414 * It'll get moved into the object miptree at validate time.
416 intelImage
->mt
= intel_miptree_create(intel
, target
,
417 intelImage
->base
.TexFormat
->BaseFormat
,
420 width
, height
, depth
,
421 intelImage
->base
.TexFormat
->TexelBytes
,
422 comp_byte
, pixels
== NULL
);
430 unpack
->BufferObj
->Name
!= 0 &&
431 check_pbo_format(internalFormat
, format
,
432 type
, intelImage
->base
.TexFormat
)) {
434 DBG("trying pbo upload\n");
436 /* Attempt to texture directly from PBO data (zero copy upload).
438 * Currently disable as it can lead to worse as well as better
439 * performance (in particular when intel_region_cow() is
442 if (intelObj
->mt
== intelImage
->mt
&&
443 intelObj
->mt
->first_level
== level
&&
444 intelObj
->mt
->last_level
== level
) {
446 if (try_pbo_zcopy(intel
, intelImage
, unpack
,
448 width
, height
, format
, type
, pixels
)) {
450 DBG("pbo zcopy upload succeeded\n");
456 /* Otherwise, attempt to use the blitter for PBO image uploads.
458 if (try_pbo_upload(intel
, intelImage
, unpack
,
460 width
, height
, format
, type
, pixels
)) {
461 DBG("pbo upload succeeded\n");
465 DBG("pbo upload failed\n");
468 /* intelCopyTexImage calls this function with pixels == NULL, with
469 * the expectation that the mipmap tree will be set up but nothing
470 * more will be done. This is where those calls return:
473 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
475 "glCompressedTexImage");
477 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
479 pixels
, unpack
, "glTexImage");
482 LOCK_HARDWARE(intel
);
484 if (intelImage
->mt
) {
486 texImage
->Data
= intel_miptree_image_map(intel
,
491 intelImage
->base
.ImageOffsets
);
492 texImage
->RowStride
= dstRowStride
/ intelImage
->mt
->cpp
;
495 /* Allocate regular memory and store the image there temporarily. */
496 if (texImage
->IsCompressed
) {
497 sizeInBytes
= texImage
->CompressedSize
;
499 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
503 dstRowStride
= postConvWidth
* texelBytes
;
504 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
507 texImage
->Data
= _mesa_alloc_texmemory(sizeInBytes
);
510 DBG("Upload image %dx%dx%d row_len %d "
511 "pitch %d pixels %d compressed %d\n",
512 width
, height
, depth
, width
* texelBytes
, dstRowStride
,
513 pixels
? 1 : 0, compressed
);
515 /* Copy data. Would like to know when it's ok for us to eg. use
516 * the blitter to copy. Or, use the hardware to do the format
517 * conversion and copy:
521 if (intelImage
->mt
) {
522 struct intel_region
*dst
= intelImage
->mt
->region
;
523 _mesa_copy_rect(texImage
->Data
, dst
->cpp
, dst
->pitch
,
525 intelImage
->mt
->level
[level
].width
,
526 (intelImage
->mt
->level
[level
].height
+3)/4,
531 memcpy(texImage
->Data
, pixels
, imageSize
);
532 } else if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
533 texImage
->_BaseFormat
,
535 texImage
->Data
, 0, 0, 0, /* dstX/Y/Zoffset */
537 texImage
->ImageOffsets
,
538 width
, height
, depth
,
539 format
, type
, pixels
, unpack
)) {
540 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
544 _mesa_unmap_teximage_pbo(ctx
, unpack
);
546 if (intelImage
->mt
) {
548 intel_miptree_image_unmap(intel
, intelImage
->mt
);
549 texImage
->Data
= NULL
;
552 UNLOCK_HARDWARE(intel
);
554 /* GL_SGIS_generate_mipmap */
555 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
556 intel_generate_mipmap(ctx
, target
, texObj
);
562 intelTexImage3D(GLcontext
* ctx
,
563 GLenum target
, GLint level
,
564 GLint internalFormat
,
565 GLint width
, GLint height
, GLint depth
,
567 GLenum format
, GLenum type
, const void *pixels
,
568 const struct gl_pixelstore_attrib
*unpack
,
569 struct gl_texture_object
*texObj
,
570 struct gl_texture_image
*texImage
)
572 intelTexImage(ctx
, 3, target
, level
,
573 internalFormat
, width
, height
, depth
, border
,
574 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
579 intelTexImage2D(GLcontext
* ctx
,
580 GLenum target
, GLint level
,
581 GLint internalFormat
,
582 GLint width
, GLint height
, GLint border
,
583 GLenum format
, GLenum type
, const void *pixels
,
584 const struct gl_pixelstore_attrib
*unpack
,
585 struct gl_texture_object
*texObj
,
586 struct gl_texture_image
*texImage
)
588 intelTexImage(ctx
, 2, target
, level
,
589 internalFormat
, width
, height
, 1, border
,
590 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
595 intelTexImage1D(GLcontext
* ctx
,
596 GLenum target
, GLint level
,
597 GLint internalFormat
,
598 GLint width
, GLint border
,
599 GLenum format
, GLenum type
, const void *pixels
,
600 const struct gl_pixelstore_attrib
*unpack
,
601 struct gl_texture_object
*texObj
,
602 struct gl_texture_image
*texImage
)
604 intelTexImage(ctx
, 1, target
, level
,
605 internalFormat
, width
, 1, 1, border
,
606 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
611 intelCompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
612 GLint internalFormat
,
613 GLint width
, GLint height
, GLint border
,
614 GLsizei imageSize
, const GLvoid
*data
,
615 struct gl_texture_object
*texObj
,
616 struct gl_texture_image
*texImage
)
618 intelTexImage(ctx
, 2, target
, level
,
619 internalFormat
, width
, height
, 1, border
,
620 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
625 * Need to map texture image into memory before copying image data,
629 intel_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
630 GLenum format
, GLenum type
, GLvoid
* pixels
,
631 struct gl_texture_object
*texObj
,
632 struct gl_texture_image
*texImage
, GLboolean compressed
)
634 struct intel_context
*intel
= intel_context(ctx
);
635 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
637 /* If we're reading from a texture that has been rendered to, need to
638 * make sure rendering is complete.
639 * We could probably predicate this on texObj->_RenderToTexture
644 if (intelImage
->mt
) {
645 /* Image is stored in hardware format in a buffer managed by the
646 * kernel. Need to explicitly map and unmap it.
648 intelImage
->base
.Data
=
649 intel_miptree_image_map(intel
,
653 &intelImage
->base
.RowStride
,
654 intelImage
->base
.ImageOffsets
);
655 intelImage
->base
.RowStride
/= intelImage
->mt
->cpp
;
658 /* Otherwise, the image should actually be stored in
659 * intelImage->base.Data. This is pretty confusing for
660 * everybody, I'd much prefer to separate the two functions of
661 * texImage->Data - storage for texture images in main memory
662 * and access (ie mappings) of images. In other words, we'd
663 * create a new texImage->Map field and leave Data simply for
666 assert(intelImage
->base
.Data
);
671 _mesa_get_compressed_teximage(ctx
, target
, level
, pixels
,
674 _mesa_get_teximage(ctx
, target
, level
, format
, type
, pixels
,
680 if (intelImage
->mt
) {
681 intel_miptree_image_unmap(intel
, intelImage
->mt
);
682 intelImage
->base
.Data
= NULL
;
688 intelGetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
689 GLenum format
, GLenum type
, GLvoid
* pixels
,
690 struct gl_texture_object
*texObj
,
691 struct gl_texture_image
*texImage
)
693 intel_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
694 texObj
, texImage
, GL_FALSE
);
699 intelGetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
701 struct gl_texture_object
*texObj
,
702 struct gl_texture_image
*texImage
)
704 intel_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
705 texObj
, texImage
, GL_TRUE
);
710 intelSetTexOffset(__DRIcontext
*pDRICtx
, GLint texname
,
711 unsigned long long offset
, GLint depth
, GLuint pitch
)
713 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
714 struct gl_texture_object
*tObj
= _mesa_lookup_texture(&intel
->ctx
, texname
);
715 struct intel_texture_object
*intelObj
= intel_texture_object(tObj
);
721 intel_miptree_release(intel
, &intelObj
->mt
);
723 intelObj
->imageOverride
= GL_TRUE
;
724 intelObj
->depthOverride
= depth
;
725 intelObj
->pitchOverride
= pitch
;
728 intelObj
->textureOffset
= offset
;
732 intelSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
733 GLint glx_texture_format
,
734 __DRIdrawable
*dPriv
)
736 struct intel_framebuffer
*intel_fb
= dPriv
->driverPrivate
;
737 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
738 struct intel_texture_object
*intelObj
;
739 struct intel_texture_image
*intelImage
;
740 struct intel_mipmap_tree
*mt
;
741 struct intel_renderbuffer
*rb
;
742 struct gl_texture_unit
*texUnit
;
743 struct gl_texture_object
*texObj
;
744 struct gl_texture_image
*texImage
;
745 int level
= 0, type
, format
, internalFormat
;
747 texUnit
= &intel
->ctx
.Texture
.Unit
[intel
->ctx
.Texture
.CurrentUnit
];
748 texObj
= _mesa_select_tex_object(&intel
->ctx
, texUnit
, target
);
749 intelObj
= intel_texture_object(texObj
);
754 intel_update_renderbuffers(pDRICtx
, dPriv
);
756 rb
= intel_fb
->color_rb
[0];
757 /* If the region isn't set, then intel_update_renderbuffers was unable
758 * to get the buffers for the drawable.
760 if (rb
->region
== NULL
)
764 format
= GL_UNSIGNED_BYTE
;
765 if (glx_texture_format
== GLX_TEXTURE_FORMAT_RGB_EXT
)
766 internalFormat
= GL_RGB
;
768 internalFormat
= GL_RGBA
;
770 mt
= intel_miptree_create_for_region(intel
, target
,
772 0, 0, rb
->region
, 1, 0);
776 _mesa_lock_texture(&intel
->ctx
, texObj
);
778 texImage
= _mesa_get_tex_image(&intel
->ctx
, texObj
, target
, level
);
779 intelImage
= intel_texture_image(texImage
);
781 if (intelImage
->mt
) {
782 intel_miptree_release(intel
, &intelImage
->mt
);
783 assert(!texImage
->Data
);
786 intel_miptree_release(intel
, &intelObj
->mt
);
789 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
790 rb
->region
->width
, rb
->region
->height
, 1,
793 intelImage
->face
= target_to_face(target
);
794 intelImage
->level
= level
;
795 texImage
->TexFormat
= intelChooseTextureFormat(&intel
->ctx
, internalFormat
,
797 _mesa_set_fetch_functions(texImage
, 2);
798 texImage
->RowStride
= rb
->region
->pitch
;
799 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
801 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
802 intelImage
->face
, intelImage
->level
)) {
803 fprintf(stderr
, "miptree doesn't match image\n");
806 _mesa_unlock_texture(&intel
->ctx
, texObj
);
810 intelSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
812 /* The old interface didn't have the format argument, so copy our
813 * implementation's behavior at the time.
815 intelSetTexBuffer2(pDRICtx
, target
, GLX_TEXTURE_FORMAT_RGBA_EXT
, dPriv
);
820 intelInitTextureImageFuncs(struct dd_function_table
*functions
)
822 functions
->TexImage1D
= intelTexImage1D
;
823 functions
->TexImage2D
= intelTexImage2D
;
824 functions
->TexImage3D
= intelTexImage3D
;
825 functions
->GetTexImage
= intelGetTexImage
;
827 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
828 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;