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_x
, dst_y
, 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 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
227 dst_stride
= intelImage
->mt
->pitch
;
229 if (drm_intel_bo_references(intel
->batch
->buf
, dst_buffer
))
230 intelFlush(&intel
->ctx
);
231 LOCK_HARDWARE(intel
);
233 dri_bo
*src_buffer
= intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
235 if (!intelEmitCopyBlit(intel
,
237 src_stride
, src_buffer
, src_offset
, GL_FALSE
,
238 dst_stride
, dst_buffer
, 0, GL_FALSE
,
239 0, 0, dst_x
, dst_y
, width
, height
,
241 UNLOCK_HARDWARE(intel
);
245 UNLOCK_HARDWARE(intel
);
252 try_pbo_zcopy(struct intel_context
*intel
,
253 struct intel_texture_image
*intelImage
,
254 const struct gl_pixelstore_attrib
*unpack
,
255 GLint internalFormat
,
256 GLint width
, GLint height
,
257 GLenum format
, GLenum type
, const void *pixels
)
259 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
260 GLuint src_offset
, src_stride
;
261 GLuint dst_x
, dst_y
, dst_stride
;
263 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
264 intel
->ctx
._ImageTransferState
||
265 unpack
->SkipPixels
|| unpack
->SkipRows
) {
266 DBG("%s: failure 1\n", __FUNCTION__
);
270 /* note: potential 64-bit ptr to 32-bit int cast */
271 src_offset
= (GLuint
) (unsigned long) pixels
;
273 if (unpack
->RowLength
> 0)
274 src_stride
= unpack
->RowLength
;
278 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
282 dst_stride
= intelImage
->mt
->pitch
;
284 if (src_stride
!= dst_stride
|| dst_x
!= 0 || dst_y
!= 0 ||
286 DBG("%s: failure 2\n", __FUNCTION__
);
290 intel_region_attach_pbo(intel
, intelImage
->mt
->region
, pbo
);
297 intelTexImage(GLcontext
* ctx
,
299 GLenum target
, GLint level
,
300 GLint internalFormat
,
301 GLint width
, GLint height
, GLint depth
,
303 GLenum format
, GLenum type
, const void *pixels
,
304 const struct gl_pixelstore_attrib
*unpack
,
305 struct gl_texture_object
*texObj
,
306 struct gl_texture_image
*texImage
, GLsizei imageSize
,
307 GLboolean compressed
)
309 struct intel_context
*intel
= intel_context(ctx
);
310 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
311 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
312 GLint postConvWidth
= width
;
313 GLint postConvHeight
= height
;
314 GLint texelBytes
, sizeInBytes
;
315 GLuint dstRowStride
= 0, srcRowStride
= texImage
->RowStride
;
317 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
318 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
320 intelImage
->face
= target_to_face(target
);
321 intelImage
->level
= level
;
323 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
324 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
328 /* choose the texture format */
329 texImage
->TexFormat
= intelChooseTextureFormat(ctx
, internalFormat
,
332 _mesa_set_fetch_functions(texImage
, dims
);
334 if (texImage
->TexFormat
->TexelBytes
== 0) {
335 /* must be a compressed format */
337 texImage
->IsCompressed
= GL_TRUE
;
338 texImage
->CompressedSize
=
339 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
340 texImage
->Height
, texImage
->Depth
,
341 texImage
->TexFormat
->MesaFormat
);
343 texelBytes
= texImage
->TexFormat
->TexelBytes
;
345 /* Minimum pitch of 32 bytes */
346 if (postConvWidth
* texelBytes
< 32) {
347 postConvWidth
= 32 / texelBytes
;
348 texImage
->RowStride
= postConvWidth
;
351 if (!intelImage
->mt
) {
352 assert(texImage
->RowStride
== postConvWidth
);
356 /* Release the reference to a potentially orphaned buffer.
357 * Release any old malloced memory.
359 if (intelImage
->mt
) {
360 intel_miptree_release(intel
, &intelImage
->mt
);
361 assert(!texImage
->Data
);
363 else if (texImage
->Data
) {
364 _mesa_free_texmemory(texImage
->Data
);
365 texImage
->Data
= NULL
;
368 /* If this is the only texture image in the tree, could call
369 * bmBufferData with NULL data to free the old block and avoid
370 * waiting on any outstanding fences.
373 intelObj
->mt
->first_level
== level
&&
374 intelObj
->mt
->last_level
== level
&&
375 intelObj
->mt
->target
!= GL_TEXTURE_CUBE_MAP_ARB
&&
376 !intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
377 intelImage
->face
, intelImage
->level
)) {
380 intel_miptree_release(intel
, &intelObj
->mt
);
381 assert(!intelObj
->mt
);
385 guess_and_alloc_mipmap_tree(intel
, intelObj
, intelImage
, pixels
== NULL
);
387 DBG("guess_and_alloc_mipmap_tree: failed\n");
391 assert(!intelImage
->mt
);
394 intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
395 intelImage
->face
, intelImage
->level
)) {
397 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
398 assert(intelImage
->mt
);
399 } else if (intelImage
->base
.Border
== 0) {
402 if (intelImage
->base
.IsCompressed
) {
404 intel_compressed_num_bytes(intelImage
->base
.TexFormat
->MesaFormat
);
407 /* Didn't fit in the object miptree, but it's suitable for inclusion in
408 * a miptree, so create one just for our level and store it in the image.
409 * It'll get moved into the object miptree at validate time.
411 intelImage
->mt
= intel_miptree_create(intel
, target
,
412 intelImage
->base
.TexFormat
->BaseFormat
,
415 width
, height
, depth
,
416 intelImage
->base
.TexFormat
->TexelBytes
,
417 comp_byte
, pixels
== NULL
);
425 _mesa_is_bufferobj(unpack
->BufferObj
) &&
426 check_pbo_format(internalFormat
, format
,
427 type
, intelImage
->base
.TexFormat
)) {
429 DBG("trying pbo upload\n");
431 /* Attempt to texture directly from PBO data (zero copy upload).
433 * Currently disable as it can lead to worse as well as better
434 * performance (in particular when intel_region_cow() is
437 if (intelObj
->mt
== intelImage
->mt
&&
438 intelObj
->mt
->first_level
== level
&&
439 intelObj
->mt
->last_level
== level
) {
441 if (try_pbo_zcopy(intel
, intelImage
, unpack
,
443 width
, height
, format
, type
, pixels
)) {
445 DBG("pbo zcopy upload succeeded\n");
451 /* Otherwise, attempt to use the blitter for PBO image uploads.
453 if (try_pbo_upload(intel
, intelImage
, unpack
,
455 width
, height
, format
, type
, pixels
)) {
456 DBG("pbo upload succeeded\n");
460 DBG("pbo upload failed\n");
463 /* intelCopyTexImage calls this function with pixels == NULL, with
464 * the expectation that the mipmap tree will be set up but nothing
465 * more will be done. This is where those calls return:
468 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
470 "glCompressedTexImage");
472 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
474 pixels
, unpack
, "glTexImage");
477 LOCK_HARDWARE(intel
);
479 if (intelImage
->mt
) {
480 if (pixels
!= NULL
) {
481 /* Flush any queued rendering with the texture before mapping. */
482 if (drm_intel_bo_references(intel
->batch
->buf
,
483 intelImage
->mt
->region
->buffer
)) {
486 texImage
->Data
= intel_miptree_image_map(intel
,
491 intelImage
->base
.ImageOffsets
);
494 texImage
->RowStride
= dstRowStride
/ intelImage
->mt
->cpp
;
497 /* Allocate regular memory and store the image there temporarily. */
498 if (texImage
->IsCompressed
) {
499 sizeInBytes
= texImage
->CompressedSize
;
501 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
505 dstRowStride
= postConvWidth
* texelBytes
;
506 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
509 texImage
->Data
= _mesa_alloc_texmemory(sizeInBytes
);
512 DBG("Upload image %dx%dx%d row_len %d "
513 "pitch %d pixels %d compressed %d\n",
514 width
, height
, depth
, width
* texelBytes
, dstRowStride
,
515 pixels
? 1 : 0, compressed
);
517 /* Copy data. Would like to know when it's ok for us to eg. use
518 * the blitter to copy. Or, use the hardware to do the format
519 * conversion and copy:
523 if (intelImage
->mt
) {
524 struct intel_region
*dst
= intelImage
->mt
->region
;
525 _mesa_copy_rect(texImage
->Data
, dst
->cpp
, dst
->pitch
,
527 intelImage
->mt
->level
[level
].width
,
528 (intelImage
->mt
->level
[level
].height
+3)/4,
533 memcpy(texImage
->Data
, pixels
, imageSize
);
534 } else if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
535 texImage
->_BaseFormat
,
537 texImage
->Data
, 0, 0, 0, /* dstX/Y/Zoffset */
539 texImage
->ImageOffsets
,
540 width
, height
, depth
,
541 format
, type
, pixels
, unpack
)) {
542 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
546 _mesa_unmap_teximage_pbo(ctx
, unpack
);
548 if (intelImage
->mt
) {
550 intel_miptree_image_unmap(intel
, intelImage
->mt
);
551 texImage
->Data
= NULL
;
554 UNLOCK_HARDWARE(intel
);
559 intelTexImage3D(GLcontext
* ctx
,
560 GLenum target
, GLint level
,
561 GLint internalFormat
,
562 GLint width
, GLint height
, GLint depth
,
564 GLenum format
, GLenum type
, const void *pixels
,
565 const struct gl_pixelstore_attrib
*unpack
,
566 struct gl_texture_object
*texObj
,
567 struct gl_texture_image
*texImage
)
569 intelTexImage(ctx
, 3, target
, level
,
570 internalFormat
, width
, height
, depth
, border
,
571 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
576 intelTexImage2D(GLcontext
* ctx
,
577 GLenum target
, GLint level
,
578 GLint internalFormat
,
579 GLint width
, GLint height
, GLint border
,
580 GLenum format
, GLenum type
, const void *pixels
,
581 const struct gl_pixelstore_attrib
*unpack
,
582 struct gl_texture_object
*texObj
,
583 struct gl_texture_image
*texImage
)
585 intelTexImage(ctx
, 2, target
, level
,
586 internalFormat
, width
, height
, 1, border
,
587 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
592 intelTexImage1D(GLcontext
* ctx
,
593 GLenum target
, GLint level
,
594 GLint internalFormat
,
595 GLint width
, GLint border
,
596 GLenum format
, GLenum type
, const void *pixels
,
597 const struct gl_pixelstore_attrib
*unpack
,
598 struct gl_texture_object
*texObj
,
599 struct gl_texture_image
*texImage
)
601 intelTexImage(ctx
, 1, target
, level
,
602 internalFormat
, width
, 1, 1, border
,
603 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
608 intelCompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
609 GLint internalFormat
,
610 GLint width
, GLint height
, GLint border
,
611 GLsizei imageSize
, const GLvoid
*data
,
612 struct gl_texture_object
*texObj
,
613 struct gl_texture_image
*texImage
)
615 intelTexImage(ctx
, 2, target
, level
,
616 internalFormat
, width
, height
, 1, border
,
617 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
622 * Need to map texture image into memory before copying image data,
626 intel_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
627 GLenum format
, GLenum type
, GLvoid
* pixels
,
628 struct gl_texture_object
*texObj
,
629 struct gl_texture_image
*texImage
, GLboolean compressed
)
631 struct intel_context
*intel
= intel_context(ctx
);
632 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
634 /* If we're reading from a texture that has been rendered to, need to
635 * make sure rendering is complete.
636 * We could probably predicate this on texObj->_RenderToTexture
641 if (intelImage
->mt
) {
642 /* Image is stored in hardware format in a buffer managed by the
643 * kernel. Need to explicitly map and unmap it.
645 intelImage
->base
.Data
=
646 intel_miptree_image_map(intel
,
650 &intelImage
->base
.RowStride
,
651 intelImage
->base
.ImageOffsets
);
652 intelImage
->base
.RowStride
/= intelImage
->mt
->cpp
;
655 /* Otherwise, the image should actually be stored in
656 * intelImage->base.Data. This is pretty confusing for
657 * everybody, I'd much prefer to separate the two functions of
658 * texImage->Data - storage for texture images in main memory
659 * and access (ie mappings) of images. In other words, we'd
660 * create a new texImage->Map field and leave Data simply for
663 assert(intelImage
->base
.Data
);
668 _mesa_get_compressed_teximage(ctx
, target
, level
, pixels
,
671 _mesa_get_teximage(ctx
, target
, level
, format
, type
, pixels
,
677 if (intelImage
->mt
) {
678 intel_miptree_image_unmap(intel
, intelImage
->mt
);
679 intelImage
->base
.Data
= NULL
;
685 intelGetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
686 GLenum format
, GLenum type
, GLvoid
* pixels
,
687 struct gl_texture_object
*texObj
,
688 struct gl_texture_image
*texImage
)
690 intel_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
691 texObj
, texImage
, GL_FALSE
);
696 intelGetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
698 struct gl_texture_object
*texObj
,
699 struct gl_texture_image
*texImage
)
701 intel_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
702 texObj
, texImage
, GL_TRUE
);
707 intelSetTexOffset(__DRIcontext
*pDRICtx
, GLint texname
,
708 unsigned long long offset
, GLint depth
, GLuint pitch
)
710 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
711 struct gl_texture_object
*tObj
= _mesa_lookup_texture(&intel
->ctx
, texname
);
712 struct intel_texture_object
*intelObj
= intel_texture_object(tObj
);
718 intel_miptree_release(intel
, &intelObj
->mt
);
720 intelObj
->imageOverride
= GL_TRUE
;
721 intelObj
->depthOverride
= depth
;
722 intelObj
->pitchOverride
= pitch
;
725 intelObj
->textureOffset
= offset
;
729 intelSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
730 GLint glx_texture_format
,
731 __DRIdrawable
*dPriv
)
733 struct intel_framebuffer
*intel_fb
= dPriv
->driverPrivate
;
734 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
735 struct intel_texture_object
*intelObj
;
736 struct intel_texture_image
*intelImage
;
737 struct intel_mipmap_tree
*mt
;
738 struct intel_renderbuffer
*rb
;
739 struct gl_texture_unit
*texUnit
;
740 struct gl_texture_object
*texObj
;
741 struct gl_texture_image
*texImage
;
742 int level
= 0, type
, format
, internalFormat
;
744 texUnit
= &intel
->ctx
.Texture
.Unit
[intel
->ctx
.Texture
.CurrentUnit
];
745 texObj
= _mesa_select_tex_object(&intel
->ctx
, texUnit
, target
);
746 intelObj
= intel_texture_object(texObj
);
751 intel_update_renderbuffers(pDRICtx
, dPriv
);
753 rb
= intel_fb
->color_rb
[0];
754 /* If the region isn't set, then intel_update_renderbuffers was unable
755 * to get the buffers for the drawable.
757 if (rb
->region
== NULL
)
761 format
= GL_UNSIGNED_BYTE
;
762 if (glx_texture_format
== GLX_TEXTURE_FORMAT_RGB_EXT
)
763 internalFormat
= GL_RGB
;
765 internalFormat
= GL_RGBA
;
767 mt
= intel_miptree_create_for_region(intel
, target
,
769 0, 0, rb
->region
, 1, 0);
773 _mesa_lock_texture(&intel
->ctx
, texObj
);
775 texImage
= _mesa_get_tex_image(&intel
->ctx
, texObj
, target
, level
);
776 intelImage
= intel_texture_image(texImage
);
778 if (intelImage
->mt
) {
779 intel_miptree_release(intel
, &intelImage
->mt
);
780 assert(!texImage
->Data
);
783 intel_miptree_release(intel
, &intelObj
->mt
);
786 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
787 rb
->region
->width
, rb
->region
->height
, 1,
790 intelImage
->face
= target_to_face(target
);
791 intelImage
->level
= level
;
792 texImage
->TexFormat
= intelChooseTextureFormat(&intel
->ctx
, internalFormat
,
794 _mesa_set_fetch_functions(texImage
, 2);
795 texImage
->RowStride
= rb
->region
->pitch
;
796 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
798 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
,
799 intelImage
->face
, intelImage
->level
)) {
800 fprintf(stderr
, "miptree doesn't match image\n");
803 _mesa_unlock_texture(&intel
->ctx
, texObj
);
807 intelSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
809 /* The old interface didn't have the format argument, so copy our
810 * implementation's behavior at the time.
812 intelSetTexBuffer2(pDRICtx
, target
, GLX_TEXTURE_FORMAT_RGBA_EXT
, dPriv
);
817 intelInitTextureImageFuncs(struct dd_function_table
*functions
)
819 functions
->TexImage1D
= intelTexImage1D
;
820 functions
->TexImage2D
= intelTexImage2D
;
821 functions
->TexImage3D
= intelTexImage3D
;
822 functions
->GetTexImage
= intelGetTexImage
;
824 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
825 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;