2 #include "main/glheader.h"
3 #include "main/macros.h"
4 #include "main/mtypes.h"
5 #include "main/enums.h"
6 #include "main/bufferobj.h"
7 #include "main/convolve.h"
8 #include "main/context.h"
9 #include "main/texcompress.h"
10 #include "main/texformat.h"
11 #include "main/texgetimage.h"
12 #include "main/texobj.h"
13 #include "main/texstore.h"
14 #include "main/teximage.h"
16 #include "intel_context.h"
17 #include "intel_mipmap_tree.h"
18 #include "intel_buffer_objects.h"
19 #include "intel_batchbuffer.h"
20 #include "intel_tex.h"
21 #include "intel_blit.h"
22 #include "intel_fbo.h"
24 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
26 /* Functions to store texture images. Where possible, mipmap_tree's
27 * will be created or further instantiated with image data, otherwise
28 * images will be stored in malloc'd memory. A validation step is
29 * required to pull those images into a mipmap tree, or otherwise
30 * decide a fallback is required.
49 /* Otherwise, store it in memory if (Border != 0) or (any dimension ==
52 * Otherwise, if max_level >= level >= min_level, create tree with
53 * space for textures from min_level down to max_level.
55 * Otherwise, create tree with space for textures from (level
56 * 0)..(1x1). Consider pruning this tree at a validation if the
60 guess_and_alloc_mipmap_tree(struct intel_context
*intel
,
61 struct intel_texture_object
*intelObj
,
62 struct intel_texture_image
*intelImage
,
63 GLboolean expect_accelerated_upload
)
67 GLuint width
= intelImage
->base
.Width
;
68 GLuint height
= intelImage
->base
.Height
;
69 GLuint depth
= intelImage
->base
.Depth
;
70 GLuint l2width
, l2height
, l2depth
;
71 GLuint i
, comp_byte
= 0;
73 DBG("%s\n", __FUNCTION__
);
75 if (intelImage
->base
.Border
||
76 ((intelImage
->base
._BaseFormat
== GL_DEPTH_COMPONENT
) &&
77 ((intelObj
->base
.WrapS
== GL_CLAMP_TO_BORDER
) ||
78 (intelObj
->base
.WrapT
== GL_CLAMP_TO_BORDER
))))
81 if (intelImage
->level
> intelObj
->base
.BaseLevel
&&
82 (intelImage
->base
.Width
== 1 ||
83 (intelObj
->base
.Target
!= GL_TEXTURE_1D
&&
84 intelImage
->base
.Height
== 1) ||
85 (intelObj
->base
.Target
== GL_TEXTURE_3D
&&
86 intelImage
->base
.Depth
== 1)))
89 /* If this image disrespects BaseLevel, allocate from level zero.
90 * Usually BaseLevel == 0, so it's unlikely to happen.
92 if (intelImage
->level
< intelObj
->base
.BaseLevel
)
95 firstLevel
= intelObj
->base
.BaseLevel
;
98 /* Figure out image dimensions at start level.
100 for (i
= intelImage
->level
; i
> firstLevel
; i
--) {
108 /* Guess a reasonable value for lastLevel. This is probably going
109 * to be wrong fairly often and might mean that we have to look at
110 * resizable buffers, or require that buffers implement lazy
111 * pagetable arrangements.
113 if ((intelObj
->base
.MinFilter
== GL_NEAREST
||
114 intelObj
->base
.MinFilter
== GL_LINEAR
) &&
115 intelImage
->level
== firstLevel
) {
116 lastLevel
= firstLevel
;
119 l2width
= logbase2(width
);
120 l2height
= logbase2(height
);
121 l2depth
= logbase2(depth
);
122 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
125 assert(!intelObj
->mt
);
126 if (intelImage
->base
.IsCompressed
)
127 comp_byte
= intel_compressed_num_bytes(intelImage
->base
.TexFormat
->MesaFormat
);
128 intelObj
->mt
= intel_miptree_create(intel
,
129 intelObj
->base
.Target
,
130 intelImage
->base
._BaseFormat
,
131 intelImage
->base
.InternalFormat
,
137 intelImage
->base
.TexFormat
->TexelBytes
,
139 expect_accelerated_upload
);
141 DBG("%s - success\n", __FUNCTION__
);
148 target_to_face(GLenum target
)
151 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
152 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
153 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
154 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
155 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
156 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
157 return ((GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
);
163 /* There are actually quite a few combinations this will work for,
164 * more than what I've listed here.
167 check_pbo_format(GLint internalFormat
,
168 GLenum format
, GLenum type
,
169 const struct gl_texture_format
*mesa_format
)
171 switch (internalFormat
) {
174 return (format
== GL_BGRA
&&
175 (type
== GL_UNSIGNED_BYTE
||
176 type
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
177 mesa_format
== &_mesa_texformat_argb8888
);
180 return (format
== GL_RGB
&&
181 type
== GL_UNSIGNED_SHORT_5_6_5
&&
182 mesa_format
== &_mesa_texformat_rgb565
);
184 return (type
== GL_UNSIGNED_SHORT_8_8_MESA
|| type
== GL_UNSIGNED_BYTE
);
191 /* XXX: Do this for TexSubImage also:
194 try_pbo_upload(struct intel_context
*intel
,
195 struct intel_texture_image
*intelImage
,
196 const struct gl_pixelstore_attrib
*unpack
,
197 GLint internalFormat
,
198 GLint width
, GLint height
,
199 GLenum format
, GLenum type
, const void *pixels
)
201 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
202 GLuint src_offset
, src_stride
;
203 GLuint dst_offset
, dst_stride
;
204 dri_bo
*dst_buffer
= intel_region_buffer(intel
,
205 intelImage
->mt
->region
,
208 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
209 intel
->ctx
._ImageTransferState
||
210 unpack
->SkipPixels
|| unpack
->SkipRows
) {
211 DBG("%s: failure 1\n", __FUNCTION__
);
215 /* note: potential 64-bit ptr to 32-bit int cast */
216 src_offset
= (GLuint
) (unsigned long) pixels
;
218 if (unpack
->RowLength
> 0)
219 src_stride
= unpack
->RowLength
;
223 dst_offset
= intel_miptree_image_offset(intelImage
->mt
,
228 dst_stride
= intelImage
->mt
->pitch
;
230 if (drm_intel_bo_references(intel
->batch
->buf
, dst_buffer
))
231 intelFlush(&intel
->ctx
);
232 LOCK_HARDWARE(intel
);
234 dri_bo
*src_buffer
= intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
235 dri_bo
*dst_buffer
= intel_region_buffer(intel
,
236 intelImage
->mt
->region
,
240 if (!intelEmitCopyBlit(intel
,
242 src_stride
, src_buffer
, src_offset
, GL_FALSE
,
243 dst_stride
, dst_buffer
, dst_offset
, GL_FALSE
,
244 0, 0, 0, 0, width
, height
,
246 UNLOCK_HARDWARE(intel
);
250 UNLOCK_HARDWARE(intel
);
257 try_pbo_zcopy(struct intel_context
*intel
,
258 struct intel_texture_image
*intelImage
,
259 const struct gl_pixelstore_attrib
*unpack
,
260 GLint internalFormat
,
261 GLint width
, GLint height
,
262 GLenum format
, GLenum type
, const void *pixels
)
264 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
265 GLuint src_offset
, src_stride
;
266 GLuint dst_offset
, dst_stride
;
268 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
269 intel
->ctx
._ImageTransferState
||
270 unpack
->SkipPixels
|| unpack
->SkipRows
) {
271 DBG("%s: failure 1\n", __FUNCTION__
);
275 /* note: potential 64-bit ptr to 32-bit int cast */
276 src_offset
= (GLuint
) (unsigned long) pixels
;
278 if (unpack
->RowLength
> 0)
279 src_stride
= unpack
->RowLength
;
283 dst_offset
= intel_miptree_image_offset(intelImage
->mt
,
287 dst_stride
= intelImage
->mt
->pitch
;
289 if (src_stride
!= dst_stride
|| dst_offset
!= 0 || src_offset
!= 0) {
290 DBG("%s: failure 2\n", __FUNCTION__
);
294 intel_region_attach_pbo(intel
, intelImage
->mt
->region
, pbo
);
301 intelTexImage(GLcontext
* ctx
,
303 GLenum target
, GLint level
,
304 GLint internalFormat
,
305 GLint width
, GLint height
, GLint depth
,
307 GLenum format
, GLenum type
, const void *pixels
,
308 const struct gl_pixelstore_attrib
*unpack
,
309 struct gl_texture_object
*texObj
,
310 struct gl_texture_image
*texImage
, GLsizei imageSize
,
311 GLboolean compressed
)
313 struct intel_context
*intel
= intel_context(ctx
);
314 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
315 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
316 GLint postConvWidth
= width
;
317 GLint postConvHeight
= height
;
318 GLint texelBytes
, sizeInBytes
;
319 GLuint dstRowStride
= 0, srcRowStride
= texImage
->RowStride
;
321 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
322 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
324 intelImage
->face
= target_to_face(target
);
325 intelImage
->level
= level
;
327 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
328 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
332 /* choose the texture format */
333 texImage
->TexFormat
= intelChooseTextureFormat(ctx
, internalFormat
,
336 _mesa_set_fetch_functions(texImage
, dims
);
338 if (texImage
->TexFormat
->TexelBytes
== 0) {
339 /* must be a compressed format */
341 texImage
->IsCompressed
= GL_TRUE
;
342 texImage
->CompressedSize
=
343 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
344 texImage
->Height
, texImage
->Depth
,
345 texImage
->TexFormat
->MesaFormat
);
347 texelBytes
= texImage
->TexFormat
->TexelBytes
;
349 /* Minimum pitch of 32 bytes */
350 if (postConvWidth
* texelBytes
< 32) {
351 postConvWidth
= 32 / texelBytes
;
352 texImage
->RowStride
= postConvWidth
;
355 if (!intelImage
->mt
) {
356 assert(texImage
->RowStride
== postConvWidth
);
360 /* Release the reference to a potentially orphaned buffer.
361 * Release any old malloced memory.
363 if (intelImage
->mt
) {
364 intel_miptree_release(intel
, &intelImage
->mt
);
365 assert(!texImage
->Data
);
367 else if (texImage
->Data
) {
368 _mesa_free_texmemory(texImage
->Data
);
369 texImage
->Data
= NULL
;
372 /* If this is the only texture image in the tree, could call
373 * bmBufferData with NULL data to free the old block and avoid
374 * waiting on any outstanding fences.
377 intelObj
->mt
->first_level
== level
&&
378 intelObj
->mt
->last_level
== level
&&
379 intelObj
->mt
->target
!= GL_TEXTURE_CUBE_MAP_ARB
&&
380 !intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
381 intelImage
->face
, intelImage
->level
)) {
384 intel_miptree_release(intel
, &intelObj
->mt
);
385 assert(!intelObj
->mt
);
389 guess_and_alloc_mipmap_tree(intel
, intelObj
, intelImage
, pixels
== NULL
);
391 DBG("guess_and_alloc_mipmap_tree: failed\n");
395 assert(!intelImage
->mt
);
398 intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
399 intelImage
->face
, intelImage
->level
)) {
401 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
402 assert(intelImage
->mt
);
403 } else if (intelImage
->base
.Border
== 0) {
406 if (intelImage
->base
.IsCompressed
) {
408 intel_compressed_num_bytes(intelImage
->base
.TexFormat
->MesaFormat
);
411 /* Didn't fit in the object miptree, but it's suitable for inclusion in
412 * a miptree, so create one just for our level and store it in the image.
413 * It'll get moved into the object miptree at validate time.
415 intelImage
->mt
= intel_miptree_create(intel
, target
,
416 intelImage
->base
.TexFormat
->BaseFormat
,
419 width
, height
, depth
,
420 intelImage
->base
.TexFormat
->TexelBytes
,
421 comp_byte
, pixels
== NULL
);
429 _mesa_is_bufferobj(unpack
->BufferObj
) &&
430 check_pbo_format(internalFormat
, format
,
431 type
, intelImage
->base
.TexFormat
)) {
433 DBG("trying pbo upload\n");
435 /* Attempt to texture directly from PBO data (zero copy upload).
437 * Currently disable as it can lead to worse as well as better
438 * performance (in particular when intel_region_cow() is
441 if (intelObj
->mt
== intelImage
->mt
&&
442 intelObj
->mt
->first_level
== level
&&
443 intelObj
->mt
->last_level
== level
) {
445 if (try_pbo_zcopy(intel
, intelImage
, unpack
,
447 width
, height
, format
, type
, pixels
)) {
449 DBG("pbo zcopy upload succeeded\n");
455 /* Otherwise, attempt to use the blitter for PBO image uploads.
457 if (try_pbo_upload(intel
, intelImage
, unpack
,
459 width
, height
, format
, type
, pixels
)) {
460 DBG("pbo upload succeeded\n");
464 DBG("pbo upload failed\n");
467 /* intelCopyTexImage calls this function with pixels == NULL, with
468 * the expectation that the mipmap tree will be set up but nothing
469 * more will be done. This is where those calls return:
472 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
474 "glCompressedTexImage");
476 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
478 pixels
, unpack
, "glTexImage");
481 LOCK_HARDWARE(intel
);
483 if (intelImage
->mt
) {
484 if (pixels
!= NULL
) {
485 /* Flush any queued rendering with the texture before mapping. */
486 if (drm_intel_bo_references(intel
->batch
->buf
,
487 intelImage
->mt
->region
->buffer
)) {
490 texImage
->Data
= intel_miptree_image_map(intel
,
495 intelImage
->base
.ImageOffsets
);
498 texImage
->RowStride
= dstRowStride
/ intelImage
->mt
->cpp
;
501 /* Allocate regular memory and store the image there temporarily. */
502 if (texImage
->IsCompressed
) {
503 sizeInBytes
= texImage
->CompressedSize
;
505 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
509 dstRowStride
= postConvWidth
* texelBytes
;
510 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
513 texImage
->Data
= _mesa_alloc_texmemory(sizeInBytes
);
516 DBG("Upload image %dx%dx%d row_len %d "
517 "pitch %d pixels %d compressed %d\n",
518 width
, height
, depth
, width
* texelBytes
, dstRowStride
,
519 pixels
? 1 : 0, compressed
);
521 /* Copy data. Would like to know when it's ok for us to eg. use
522 * the blitter to copy. Or, use the hardware to do the format
523 * conversion and copy:
527 if (intelImage
->mt
) {
528 struct intel_region
*dst
= intelImage
->mt
->region
;
529 _mesa_copy_rect(texImage
->Data
, dst
->cpp
, dst
->pitch
,
531 intelImage
->mt
->level
[level
].width
,
532 (intelImage
->mt
->level
[level
].height
+3)/4,
537 memcpy(texImage
->Data
, pixels
, imageSize
);
538 } else if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
539 texImage
->_BaseFormat
,
541 texImage
->Data
, 0, 0, 0, /* dstX/Y/Zoffset */
543 texImage
->ImageOffsets
,
544 width
, height
, depth
,
545 format
, type
, pixels
, unpack
)) {
546 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
550 _mesa_unmap_teximage_pbo(ctx
, unpack
);
552 if (intelImage
->mt
) {
554 intel_miptree_image_unmap(intel
, intelImage
->mt
);
555 texImage
->Data
= NULL
;
558 UNLOCK_HARDWARE(intel
);
563 intelTexImage3D(GLcontext
* ctx
,
564 GLenum target
, GLint level
,
565 GLint internalFormat
,
566 GLint width
, GLint height
, GLint depth
,
568 GLenum format
, GLenum type
, const void *pixels
,
569 const struct gl_pixelstore_attrib
*unpack
,
570 struct gl_texture_object
*texObj
,
571 struct gl_texture_image
*texImage
)
573 intelTexImage(ctx
, 3, target
, level
,
574 internalFormat
, width
, height
, depth
, border
,
575 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
580 intelTexImage2D(GLcontext
* ctx
,
581 GLenum target
, GLint level
,
582 GLint internalFormat
,
583 GLint width
, GLint height
, GLint border
,
584 GLenum format
, GLenum type
, const void *pixels
,
585 const struct gl_pixelstore_attrib
*unpack
,
586 struct gl_texture_object
*texObj
,
587 struct gl_texture_image
*texImage
)
589 intelTexImage(ctx
, 2, target
, level
,
590 internalFormat
, width
, height
, 1, border
,
591 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
596 intelTexImage1D(GLcontext
* ctx
,
597 GLenum target
, GLint level
,
598 GLint internalFormat
,
599 GLint width
, GLint border
,
600 GLenum format
, GLenum type
, const void *pixels
,
601 const struct gl_pixelstore_attrib
*unpack
,
602 struct gl_texture_object
*texObj
,
603 struct gl_texture_image
*texImage
)
605 intelTexImage(ctx
, 1, target
, level
,
606 internalFormat
, width
, 1, 1, border
,
607 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
612 intelCompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
613 GLint internalFormat
,
614 GLint width
, GLint height
, GLint border
,
615 GLsizei imageSize
, const GLvoid
*data
,
616 struct gl_texture_object
*texObj
,
617 struct gl_texture_image
*texImage
)
619 intelTexImage(ctx
, 2, target
, level
,
620 internalFormat
, width
, height
, 1, border
,
621 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
626 * Need to map texture image into memory before copying image data,
630 intel_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
631 GLenum format
, GLenum type
, GLvoid
* pixels
,
632 struct gl_texture_object
*texObj
,
633 struct gl_texture_image
*texImage
, GLboolean compressed
)
635 struct intel_context
*intel
= intel_context(ctx
);
636 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
638 /* If we're reading from a texture that has been rendered to, need to
639 * make sure rendering is complete.
640 * We could probably predicate this on texObj->_RenderToTexture
645 if (intelImage
->mt
) {
646 /* Image is stored in hardware format in a buffer managed by the
647 * kernel. Need to explicitly map and unmap it.
649 intelImage
->base
.Data
=
650 intel_miptree_image_map(intel
,
654 &intelImage
->base
.RowStride
,
655 intelImage
->base
.ImageOffsets
);
656 intelImage
->base
.RowStride
/= intelImage
->mt
->cpp
;
659 /* Otherwise, the image should actually be stored in
660 * intelImage->base.Data. This is pretty confusing for
661 * everybody, I'd much prefer to separate the two functions of
662 * texImage->Data - storage for texture images in main memory
663 * and access (ie mappings) of images. In other words, we'd
664 * create a new texImage->Map field and leave Data simply for
667 assert(intelImage
->base
.Data
);
672 _mesa_get_compressed_teximage(ctx
, target
, level
, pixels
,
675 _mesa_get_teximage(ctx
, target
, level
, format
, type
, pixels
,
681 if (intelImage
->mt
) {
682 intel_miptree_image_unmap(intel
, intelImage
->mt
);
683 intelImage
->base
.Data
= NULL
;
689 intelGetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
690 GLenum format
, GLenum type
, GLvoid
* pixels
,
691 struct gl_texture_object
*texObj
,
692 struct gl_texture_image
*texImage
)
694 intel_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
695 texObj
, texImage
, GL_FALSE
);
700 intelGetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
702 struct gl_texture_object
*texObj
,
703 struct gl_texture_image
*texImage
)
705 intel_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
706 texObj
, texImage
, GL_TRUE
);
711 intelSetTexOffset(__DRIcontext
*pDRICtx
, GLint texname
,
712 unsigned long long offset
, GLint depth
, GLuint pitch
)
714 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
715 struct gl_texture_object
*tObj
= _mesa_lookup_texture(&intel
->ctx
, texname
);
716 struct intel_texture_object
*intelObj
= intel_texture_object(tObj
);
722 intel_miptree_release(intel
, &intelObj
->mt
);
724 intelObj
->imageOverride
= GL_TRUE
;
725 intelObj
->depthOverride
= depth
;
726 intelObj
->pitchOverride
= pitch
;
729 intelObj
->textureOffset
= offset
;
733 intelSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
734 GLint glx_texture_format
,
735 __DRIdrawable
*dPriv
)
737 struct intel_framebuffer
*intel_fb
= dPriv
->driverPrivate
;
738 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
739 struct intel_texture_object
*intelObj
;
740 struct intel_texture_image
*intelImage
;
741 struct intel_mipmap_tree
*mt
;
742 struct intel_renderbuffer
*rb
;
743 struct gl_texture_unit
*texUnit
;
744 struct gl_texture_object
*texObj
;
745 struct gl_texture_image
*texImage
;
746 int level
= 0, type
, format
, internalFormat
;
748 texUnit
= &intel
->ctx
.Texture
.Unit
[intel
->ctx
.Texture
.CurrentUnit
];
749 texObj
= _mesa_select_tex_object(&intel
->ctx
, texUnit
, target
);
750 intelObj
= intel_texture_object(texObj
);
755 intel_update_renderbuffers(pDRICtx
, dPriv
);
757 rb
= intel_fb
->color_rb
[0];
758 /* If the region isn't set, then intel_update_renderbuffers was unable
759 * to get the buffers for the drawable.
761 if (rb
->region
== NULL
)
765 format
= GL_UNSIGNED_BYTE
;
766 if (glx_texture_format
== GLX_TEXTURE_FORMAT_RGB_EXT
)
767 internalFormat
= GL_RGB
;
769 internalFormat
= GL_RGBA
;
771 mt
= intel_miptree_create_for_region(intel
, target
,
773 0, 0, rb
->region
, 1, 0);
777 _mesa_lock_texture(&intel
->ctx
, texObj
);
779 texImage
= _mesa_get_tex_image(&intel
->ctx
, texObj
, target
, level
);
780 intelImage
= intel_texture_image(texImage
);
782 if (intelImage
->mt
) {
783 intel_miptree_release(intel
, &intelImage
->mt
);
784 assert(!texImage
->Data
);
787 intel_miptree_release(intel
, &intelObj
->mt
);
790 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
791 rb
->region
->width
, rb
->region
->height
, 1,
794 intelImage
->face
= target_to_face(target
);
795 intelImage
->level
= level
;
796 texImage
->TexFormat
= intelChooseTextureFormat(&intel
->ctx
, internalFormat
,
798 _mesa_set_fetch_functions(texImage
, 2);
799 texImage
->RowStride
= rb
->region
->pitch
;
800 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
802 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
803 intelImage
->face
, intelImage
->level
)) {
804 fprintf(stderr
, "miptree doesn't match image\n");
807 _mesa_unlock_texture(&intel
->ctx
, texObj
);
811 intelSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
813 /* The old interface didn't have the format argument, so copy our
814 * implementation's behavior at the time.
816 intelSetTexBuffer2(pDRICtx
, target
, GLX_TEXTURE_FORMAT_RGBA_EXT
, dPriv
);
821 intelInitTextureImageFuncs(struct dd_function_table
*functions
)
823 functions
->TexImage1D
= intelTexImage1D
;
824 functions
->TexImage2D
= intelTexImage2D
;
825 functions
->TexImage3D
= intelTexImage3D
;
826 functions
->GetTexImage
= intelGetTexImage
;
828 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
829 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;