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/formats.h"
10 #include "main/texcompress.h"
11 #include "main/texstore.h"
12 #include "main/texgetimage.h"
13 #include "main/texobj.h"
14 #include "main/texstore.h"
15 #include "main/teximage.h"
17 #include "intel_context.h"
18 #include "intel_mipmap_tree.h"
19 #include "intel_buffer_objects.h"
20 #include "intel_batchbuffer.h"
21 #include "intel_tex.h"
22 #include "intel_blit.h"
23 #include "intel_fbo.h"
25 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
27 /* Functions to store texture images. Where possible, mipmap_tree's
28 * will be created or further instantiated with image data, otherwise
29 * images will be stored in malloc'd memory. A validation step is
30 * required to pull those images into a mipmap tree, or otherwise
31 * decide a fallback is required.
50 /* Otherwise, store it in memory if (Border != 0) or (any dimension ==
53 * Otherwise, if max_level >= level >= min_level, create tree with
54 * space for textures from min_level down to max_level.
56 * Otherwise, create tree with space for textures from (level
57 * 0)..(1x1). Consider pruning this tree at a validation if the
61 guess_and_alloc_mipmap_tree(struct intel_context
*intel
,
62 struct intel_texture_object
*intelObj
,
63 struct intel_texture_image
*intelImage
,
64 GLboolean expect_accelerated_upload
)
68 GLuint width
= intelImage
->base
.Width
;
69 GLuint height
= intelImage
->base
.Height
;
70 GLuint depth
= intelImage
->base
.Depth
;
71 GLuint l2width
, l2height
, l2depth
;
72 GLuint i
, comp_byte
= 0;
75 DBG("%s\n", __FUNCTION__
);
77 if (intelImage
->base
.Border
||
78 ((intelImage
->base
._BaseFormat
== GL_DEPTH_COMPONENT
) &&
79 ((intelObj
->base
.WrapS
== GL_CLAMP_TO_BORDER
) ||
80 (intelObj
->base
.WrapT
== GL_CLAMP_TO_BORDER
))))
83 if (intelImage
->level
> intelObj
->base
.BaseLevel
&&
84 (intelImage
->base
.Width
== 1 ||
85 (intelObj
->base
.Target
!= GL_TEXTURE_1D
&&
86 intelImage
->base
.Height
== 1) ||
87 (intelObj
->base
.Target
== GL_TEXTURE_3D
&&
88 intelImage
->base
.Depth
== 1)))
91 /* If this image disrespects BaseLevel, allocate from level zero.
92 * Usually BaseLevel == 0, so it's unlikely to happen.
94 if (intelImage
->level
< intelObj
->base
.BaseLevel
)
97 firstLevel
= intelObj
->base
.BaseLevel
;
100 /* Figure out image dimensions at start level.
102 for (i
= intelImage
->level
; i
> firstLevel
; i
--) {
110 /* Guess a reasonable value for lastLevel. This is probably going
111 * to be wrong fairly often and might mean that we have to look at
112 * resizable buffers, or require that buffers implement lazy
113 * pagetable arrangements.
115 if ((intelObj
->base
.MinFilter
== GL_NEAREST
||
116 intelObj
->base
.MinFilter
== GL_LINEAR
) &&
117 intelImage
->level
== firstLevel
&&
118 (intel
->gen
< 4 || firstLevel
== 0)) {
119 lastLevel
= firstLevel
;
122 l2width
= logbase2(width
);
123 l2height
= logbase2(height
);
124 l2depth
= logbase2(depth
);
125 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
128 assert(!intelObj
->mt
);
129 if (_mesa_is_format_compressed(intelImage
->base
.TexFormat
))
130 comp_byte
= intel_compressed_num_bytes(intelImage
->base
.TexFormat
);
132 texelBytes
= _mesa_get_format_bytes(intelImage
->base
.TexFormat
);
134 intelObj
->mt
= intel_miptree_create(intel
,
135 intelObj
->base
.Target
,
136 intelImage
->base
._BaseFormat
,
137 intelImage
->base
.InternalFormat
,
145 expect_accelerated_upload
);
147 DBG("%s - success\n", __FUNCTION__
);
154 target_to_face(GLenum target
)
157 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
158 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
159 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
160 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
161 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
162 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
163 return ((GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
);
169 /* There are actually quite a few combinations this will work for,
170 * more than what I've listed here.
173 check_pbo_format(GLint internalFormat
,
174 GLenum format
, GLenum type
,
175 gl_format mesa_format
)
177 switch (internalFormat
) {
181 return (format
== GL_BGRA
&&
182 (type
== GL_UNSIGNED_BYTE
||
183 type
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
184 mesa_format
== MESA_FORMAT_ARGB8888
);
187 return (format
== GL_RGB
&&
188 type
== GL_UNSIGNED_SHORT_5_6_5
&&
189 mesa_format
== MESA_FORMAT_RGB565
);
192 return (format
== GL_LUMINANCE
&&
193 type
== GL_UNSIGNED_BYTE
&&
194 mesa_format
== MESA_FORMAT_L8
);
196 return (type
== GL_UNSIGNED_SHORT_8_8_MESA
|| type
== GL_UNSIGNED_BYTE
);
203 /* XXX: Do this for TexSubImage also:
206 try_pbo_upload(struct intel_context
*intel
,
207 struct intel_texture_image
*intelImage
,
208 const struct gl_pixelstore_attrib
*unpack
,
209 GLint internalFormat
,
210 GLint width
, GLint height
,
211 GLenum format
, GLenum type
, const void *pixels
)
213 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
214 GLuint src_offset
, src_stride
;
215 GLuint dst_x
, dst_y
, dst_stride
;
216 drm_intel_bo
*dst_buffer
= intel_region_buffer(intel
,
217 intelImage
->mt
->region
,
220 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
221 intel
->ctx
._ImageTransferState
||
222 unpack
->SkipPixels
|| unpack
->SkipRows
) {
223 DBG("%s: failure 1\n", __FUNCTION__
);
227 /* note: potential 64-bit ptr to 32-bit int cast */
228 src_offset
= (GLuint
) (unsigned long) pixels
;
230 if (unpack
->RowLength
> 0)
231 src_stride
= unpack
->RowLength
;
235 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
239 dst_stride
= intelImage
->mt
->region
->pitch
;
241 if (drm_intel_bo_references(intel
->batch
->buf
, dst_buffer
))
242 intel_flush(&intel
->ctx
);
245 drm_intel_bo
*src_buffer
= intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
247 if (!intelEmitCopyBlit(intel
,
249 src_stride
, src_buffer
, src_offset
, GL_FALSE
,
250 dst_stride
, dst_buffer
, 0,
251 intelImage
->mt
->region
->tiling
,
252 0, 0, dst_x
, dst_y
, width
, height
,
263 try_pbo_zcopy(struct intel_context
*intel
,
264 struct intel_texture_image
*intelImage
,
265 const struct gl_pixelstore_attrib
*unpack
,
266 GLint internalFormat
,
267 GLint width
, GLint height
,
268 GLenum format
, GLenum type
, const void *pixels
)
270 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
271 GLuint src_offset
, src_stride
;
272 GLuint dst_x
, dst_y
, dst_stride
;
274 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
275 intel
->ctx
._ImageTransferState
||
276 unpack
->SkipPixels
|| unpack
->SkipRows
) {
277 DBG("%s: failure 1\n", __FUNCTION__
);
281 /* note: potential 64-bit ptr to 32-bit int cast */
282 src_offset
= (GLuint
) (unsigned long) pixels
;
284 if (unpack
->RowLength
> 0)
285 src_stride
= unpack
->RowLength
;
289 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
293 dst_stride
= intelImage
->mt
->region
->pitch
;
295 if (src_stride
!= dst_stride
|| dst_x
!= 0 || dst_y
!= 0 ||
297 DBG("%s: failure 2\n", __FUNCTION__
);
301 intel_region_attach_pbo(intel
, intelImage
->mt
->region
, pbo
);
308 intelTexImage(GLcontext
* ctx
,
310 GLenum target
, GLint level
,
311 GLint internalFormat
,
312 GLint width
, GLint height
, GLint depth
,
314 GLenum format
, GLenum type
, const void *pixels
,
315 const struct gl_pixelstore_attrib
*unpack
,
316 struct gl_texture_object
*texObj
,
317 struct gl_texture_image
*texImage
, GLsizei imageSize
,
318 GLboolean compressed
)
320 struct intel_context
*intel
= intel_context(ctx
);
321 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
322 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
323 GLint postConvWidth
= width
;
324 GLint postConvHeight
= height
;
325 GLint texelBytes
, sizeInBytes
;
326 GLuint dstRowStride
= 0, srcRowStride
= texImage
->RowStride
;
328 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
329 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
331 intelImage
->face
= target_to_face(target
);
332 intelImage
->level
= level
;
334 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
335 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
339 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
343 texelBytes
= _mesa_get_format_bytes(texImage
->TexFormat
);
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
)) {
379 intel_miptree_release(intel
, &intelObj
->mt
);
380 assert(!intelObj
->mt
);
384 guess_and_alloc_mipmap_tree(intel
, intelObj
, intelImage
, pixels
== NULL
);
386 DBG("guess_and_alloc_mipmap_tree: failed\n");
390 assert(!intelImage
->mt
);
393 intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
)) {
395 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
396 assert(intelImage
->mt
);
397 } else if (intelImage
->base
.Border
== 0) {
399 GLuint texelBytes
= _mesa_get_format_bytes(intelImage
->base
.TexFormat
);
400 GLenum baseFormat
= _mesa_get_format_base_format(intelImage
->base
.TexFormat
);
401 if (_mesa_is_format_compressed(intelImage
->base
.TexFormat
)) {
403 intel_compressed_num_bytes(intelImage
->base
.TexFormat
);
406 /* Didn't fit in the object miptree, but it's suitable for inclusion in
407 * a miptree, so create one just for our level and store it in the image.
408 * It'll get moved into the object miptree at validate time.
410 intelImage
->mt
= intel_miptree_create(intel
, target
,
414 width
, height
, depth
,
416 comp_byte
, pixels
== NULL
);
424 _mesa_is_bufferobj(unpack
->BufferObj
) &&
425 check_pbo_format(internalFormat
, format
,
426 type
, intelImage
->base
.TexFormat
)) {
428 DBG("trying pbo upload\n");
430 /* Attempt to texture directly from PBO data (zero copy upload).
432 * Currently disable as it can lead to worse as well as better
433 * performance (in particular when intel_region_cow() is
436 if (intelObj
->mt
== intelImage
->mt
&&
437 intelObj
->mt
->first_level
== level
&&
438 intelObj
->mt
->last_level
== level
) {
440 if (try_pbo_zcopy(intel
, intelImage
, unpack
,
442 width
, height
, format
, type
, pixels
)) {
444 DBG("pbo zcopy upload succeeded\n");
450 /* Otherwise, attempt to use the blitter for PBO image uploads.
452 if (try_pbo_upload(intel
, intelImage
, unpack
,
454 width
, height
, format
, type
, pixels
)) {
455 DBG("pbo upload succeeded\n");
459 DBG("pbo upload failed\n");
462 /* intelCopyTexImage calls this function with pixels == NULL, with
463 * the expectation that the mipmap tree will be set up but nothing
464 * more will be done. This is where those calls return:
467 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
469 "glCompressedTexImage");
471 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
473 pixels
, unpack
, "glTexImage");
476 if (intelImage
->mt
) {
477 if (pixels
!= NULL
) {
478 /* Flush any queued rendering with the texture before mapping. */
479 if (drm_intel_bo_references(intel
->batch
->buf
,
480 intelImage
->mt
->region
->buffer
)) {
483 texImage
->Data
= intel_miptree_image_map(intel
,
488 intelImage
->base
.ImageOffsets
);
491 texImage
->RowStride
= dstRowStride
/ intelImage
->mt
->cpp
;
494 /* Allocate regular memory and store the image there temporarily. */
495 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
496 sizeInBytes
= _mesa_format_image_size(texImage
->TexFormat
,
501 _mesa_format_row_stride(texImage
->TexFormat
, 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,
534 memcpy(texImage
->Data
, pixels
, imageSize
);
537 else if (!_mesa_texstore(ctx
, dims
,
538 texImage
->_BaseFormat
,
540 texImage
->Data
, 0, 0, 0, /* dstX/Y/Zoffset */
542 texImage
->ImageOffsets
,
543 width
, height
, depth
,
544 format
, type
, pixels
, unpack
)) {
545 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
549 _mesa_unmap_teximage_pbo(ctx
, unpack
);
551 if (intelImage
->mt
) {
553 intel_miptree_image_unmap(intel
, intelImage
->mt
);
554 texImage
->Data
= NULL
;
560 intelTexImage3D(GLcontext
* ctx
,
561 GLenum target
, GLint level
,
562 GLint internalFormat
,
563 GLint width
, GLint height
, GLint depth
,
565 GLenum format
, GLenum type
, const void *pixels
,
566 const struct gl_pixelstore_attrib
*unpack
,
567 struct gl_texture_object
*texObj
,
568 struct gl_texture_image
*texImage
)
570 intelTexImage(ctx
, 3, target
, level
,
571 internalFormat
, width
, height
, depth
, border
,
572 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
577 intelTexImage2D(GLcontext
* ctx
,
578 GLenum target
, GLint level
,
579 GLint internalFormat
,
580 GLint width
, GLint height
, GLint border
,
581 GLenum format
, GLenum type
, const void *pixels
,
582 const struct gl_pixelstore_attrib
*unpack
,
583 struct gl_texture_object
*texObj
,
584 struct gl_texture_image
*texImage
)
586 intelTexImage(ctx
, 2, target
, level
,
587 internalFormat
, width
, height
, 1, border
,
588 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
593 intelTexImage1D(GLcontext
* ctx
,
594 GLenum target
, GLint level
,
595 GLint internalFormat
,
596 GLint width
, GLint border
,
597 GLenum format
, GLenum type
, const void *pixels
,
598 const struct gl_pixelstore_attrib
*unpack
,
599 struct gl_texture_object
*texObj
,
600 struct gl_texture_image
*texImage
)
602 intelTexImage(ctx
, 1, target
, level
,
603 internalFormat
, width
, 1, 1, border
,
604 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
609 intelCompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
610 GLint internalFormat
,
611 GLint width
, GLint height
, GLint border
,
612 GLsizei imageSize
, const GLvoid
*data
,
613 struct gl_texture_object
*texObj
,
614 struct gl_texture_image
*texImage
)
616 intelTexImage(ctx
, 2, target
, level
,
617 internalFormat
, width
, height
, 1, border
,
618 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
623 * Need to map texture image into memory before copying image data,
627 intel_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
628 GLenum format
, GLenum type
, GLvoid
* pixels
,
629 struct gl_texture_object
*texObj
,
630 struct gl_texture_image
*texImage
, GLboolean compressed
)
632 struct intel_context
*intel
= intel_context(ctx
);
633 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
635 /* If we're reading from a texture that has been rendered to, need to
636 * make sure rendering is complete.
637 * We could probably predicate this on texObj->_RenderToTexture
642 if (intelImage
->mt
) {
643 /* Image is stored in hardware format in a buffer managed by the
644 * kernel. Need to explicitly map and unmap it.
646 intelImage
->base
.Data
=
647 intel_miptree_image_map(intel
,
651 &intelImage
->base
.RowStride
,
652 intelImage
->base
.ImageOffsets
);
653 intelImage
->base
.RowStride
/= intelImage
->mt
->cpp
;
656 /* Otherwise, the image should actually be stored in
657 * intelImage->base.Data. This is pretty confusing for
658 * everybody, I'd much prefer to separate the two functions of
659 * texImage->Data - storage for texture images in main memory
660 * and access (ie mappings) of images. In other words, we'd
661 * create a new texImage->Map field and leave Data simply for
664 assert(intelImage
->base
.Data
);
669 _mesa_get_compressed_teximage(ctx
, target
, level
, pixels
,
673 _mesa_get_teximage(ctx
, target
, level
, format
, type
, pixels
,
679 if (intelImage
->mt
) {
680 intel_miptree_image_unmap(intel
, intelImage
->mt
);
681 intelImage
->base
.Data
= NULL
;
687 intelGetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
688 GLenum format
, GLenum type
, GLvoid
* pixels
,
689 struct gl_texture_object
*texObj
,
690 struct gl_texture_image
*texImage
)
692 intel_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
693 texObj
, texImage
, GL_FALSE
);
698 intelGetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
700 struct gl_texture_object
*texObj
,
701 struct gl_texture_image
*texImage
)
703 intel_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
704 texObj
, texImage
, GL_TRUE
);
708 intelSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
709 GLint texture_format
,
710 __DRIdrawable
*dPriv
)
712 struct gl_framebuffer
*fb
= dPriv
->driverPrivate
;
713 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
714 GLcontext
*ctx
= &intel
->ctx
;
715 struct intel_texture_object
*intelObj
;
716 struct intel_texture_image
*intelImage
;
717 struct intel_mipmap_tree
*mt
;
718 struct intel_renderbuffer
*rb
;
719 struct gl_texture_object
*texObj
;
720 struct gl_texture_image
*texImage
;
721 int level
= 0, internalFormat
;
723 texObj
= _mesa_get_current_tex_object(ctx
, target
);
724 intelObj
= intel_texture_object(texObj
);
729 if (dPriv
->lastStamp
!= dPriv
->dri2
.stamp
||
730 !pDRICtx
->driScreenPriv
->dri2
.useInvalidate
)
731 intel_update_renderbuffers(pDRICtx
, dPriv
);
733 rb
= intel_get_renderbuffer(fb
, BUFFER_FRONT_LEFT
);
734 /* If the region isn't set, then intel_update_renderbuffers was unable
735 * to get the buffers for the drawable.
737 if (rb
->region
== NULL
)
740 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
741 internalFormat
= GL_RGB
;
743 internalFormat
= GL_RGBA
;
745 mt
= intel_miptree_create_for_region(intel
, target
,
747 0, 0, rb
->region
, 1, 0);
751 _mesa_lock_texture(&intel
->ctx
, texObj
);
753 texImage
= _mesa_get_tex_image(&intel
->ctx
, texObj
, target
, level
);
754 intelImage
= intel_texture_image(texImage
);
756 if (intelImage
->mt
) {
757 intel_miptree_release(intel
, &intelImage
->mt
);
758 assert(!texImage
->Data
);
761 intel_miptree_release(intel
, &intelObj
->mt
);
764 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
765 rb
->region
->width
, rb
->region
->height
, 1,
768 intelImage
->face
= target_to_face(target
);
769 intelImage
->level
= level
;
770 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
771 texImage
->TexFormat
= MESA_FORMAT_XRGB8888
;
773 texImage
->TexFormat
= MESA_FORMAT_ARGB8888
;
774 texImage
->RowStride
= rb
->region
->pitch
;
775 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
777 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
)) {
778 fprintf(stderr
, "miptree doesn't match image\n");
781 _mesa_unlock_texture(&intel
->ctx
, texObj
);
785 intelSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
787 /* The old interface didn't have the format argument, so copy our
788 * implementation's behavior at the time.
790 intelSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
793 #if FEATURE_OES_EGL_image
795 intel_image_target_texture_2d(GLcontext
*ctx
, GLenum target
,
796 struct gl_texture_object
*texObj
,
797 struct gl_texture_image
*texImage
,
798 GLeglImageOES image_handle
)
800 struct intel_context
*intel
= intel_context(ctx
);
801 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
802 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
803 struct intel_mipmap_tree
*mt
;
807 screen
= intel
->intelScreen
->driScrnPriv
;
808 image
= screen
->dri2
.image
->lookupEGLImage(intel
->driContext
, image_handle
,
809 intel
->driContext
->loaderPrivate
);
813 mt
= intel_miptree_create_for_region(intel
, target
,
814 image
->internal_format
,
815 0, 0, image
->region
, 1, 0);
819 if (intelImage
->mt
) {
820 intel_miptree_release(intel
, &intelImage
->mt
);
821 assert(!texImage
->Data
);
824 intel_miptree_release(intel
, &intelObj
->mt
);
827 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
828 image
->region
->width
, image
->region
->height
, 1,
829 0, image
->internal_format
);
831 intelImage
->face
= target_to_face(target
);
832 intelImage
->level
= 0;
833 texImage
->TexFormat
= image
->format
;
834 texImage
->RowStride
= image
->region
->pitch
;
835 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
837 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
))
838 fprintf(stderr
, "miptree doesn't match image\n");
843 intelInitTextureImageFuncs(struct dd_function_table
*functions
)
845 functions
->TexImage1D
= intelTexImage1D
;
846 functions
->TexImage2D
= intelTexImage2D
;
847 functions
->TexImage3D
= intelTexImage3D
;
848 functions
->GetTexImage
= intelGetTexImage
;
850 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
851 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;
853 #if FEATURE_OES_EGL_image
854 functions
->EGLImageTargetTexture2D
= intel_image_target_texture_2d
;