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/context.h"
8 #include "main/formats.h"
9 #include "main/texcompress.h"
10 #include "main/texstore.h"
11 #include "main/texgetimage.h"
12 #include "main/texobj.h"
13 #include "main/teximage.h"
15 #include "intel_context.h"
16 #include "intel_mipmap_tree.h"
17 #include "intel_buffer_objects.h"
18 #include "intel_batchbuffer.h"
19 #include "intel_tex.h"
20 #include "intel_blit.h"
21 #include "intel_fbo.h"
23 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
25 /* Functions to store texture images. Where possible, mipmap_tree's
26 * will be created or further instantiated with image data, otherwise
27 * images will be stored in malloc'd memory. A validation step is
28 * required to pull those images into a mipmap tree, or otherwise
29 * decide a fallback is required.
48 /* Otherwise, store it in memory if (Border != 0) or (any dimension ==
51 * Otherwise, if max_level >= level >= min_level, create tree with
52 * space for textures from min_level down to max_level.
54 * Otherwise, create tree with space for textures from (level
55 * 0)..(1x1). Consider pruning this tree at a validation if the
59 guess_and_alloc_mipmap_tree(struct intel_context
*intel
,
60 struct intel_texture_object
*intelObj
,
61 struct intel_texture_image
*intelImage
,
62 GLboolean expect_accelerated_upload
)
66 GLuint width
= intelImage
->base
.Width
;
67 GLuint height
= intelImage
->base
.Height
;
68 GLuint depth
= intelImage
->base
.Depth
;
69 GLuint l2width
, l2height
, l2depth
;
70 GLuint i
, comp_byte
= 0;
73 DBG("%s\n", __FUNCTION__
);
75 if (intelImage
->base
.Border
)
78 if (intelImage
->level
> intelObj
->base
.BaseLevel
&&
79 (intelImage
->base
.Width
== 1 ||
80 (intelObj
->base
.Target
!= GL_TEXTURE_1D
&&
81 intelImage
->base
.Height
== 1) ||
82 (intelObj
->base
.Target
== GL_TEXTURE_3D
&&
83 intelImage
->base
.Depth
== 1)))
86 /* If this image disrespects BaseLevel, allocate from level zero.
87 * Usually BaseLevel == 0, so it's unlikely to happen.
89 if (intelImage
->level
< intelObj
->base
.BaseLevel
)
92 firstLevel
= intelObj
->base
.BaseLevel
;
95 /* Figure out image dimensions at start level.
97 for (i
= intelImage
->level
; i
> firstLevel
; i
--) {
105 /* Guess a reasonable value for lastLevel. This is probably going
106 * to be wrong fairly often and might mean that we have to look at
107 * resizable buffers, or require that buffers implement lazy
108 * pagetable arrangements.
110 if ((intelObj
->base
.MinFilter
== GL_NEAREST
||
111 intelObj
->base
.MinFilter
== GL_LINEAR
) &&
112 intelImage
->level
== firstLevel
&&
113 (intel
->gen
< 4 || firstLevel
== 0)) {
114 lastLevel
= firstLevel
;
117 l2width
= logbase2(width
);
118 l2height
= logbase2(height
);
119 l2depth
= logbase2(depth
);
120 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
123 assert(!intelObj
->mt
);
124 if (_mesa_is_format_compressed(intelImage
->base
.TexFormat
))
125 comp_byte
= intel_compressed_num_bytes(intelImage
->base
.TexFormat
);
127 texelBytes
= _mesa_get_format_bytes(intelImage
->base
.TexFormat
);
129 intelObj
->mt
= intel_miptree_create(intel
,
130 intelObj
->base
.Target
,
131 intelImage
->base
._BaseFormat
,
132 intelImage
->base
.InternalFormat
,
140 expect_accelerated_upload
);
142 DBG("%s - success\n", __FUNCTION__
);
149 target_to_face(GLenum target
)
152 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
153 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
154 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
155 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
156 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
157 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
158 return ((GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
);
164 /* There are actually quite a few combinations this will work for,
165 * more than what I've listed here.
168 check_pbo_format(GLint internalFormat
,
169 GLenum format
, GLenum type
,
170 gl_format mesa_format
)
172 switch (internalFormat
) {
176 return (format
== GL_BGRA
&&
177 (type
== GL_UNSIGNED_BYTE
||
178 type
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
179 mesa_format
== MESA_FORMAT_ARGB8888
);
182 return (format
== GL_RGB
&&
183 type
== GL_UNSIGNED_SHORT_5_6_5
&&
184 mesa_format
== MESA_FORMAT_RGB565
);
187 return (format
== GL_LUMINANCE
&&
188 type
== GL_UNSIGNED_BYTE
&&
189 mesa_format
== MESA_FORMAT_L8
);
191 return (type
== GL_UNSIGNED_SHORT_8_8_MESA
|| type
== GL_UNSIGNED_BYTE
);
198 /* XXX: Do this for TexSubImage also:
201 try_pbo_upload(struct intel_context
*intel
,
202 struct intel_texture_image
*intelImage
,
203 const struct gl_pixelstore_attrib
*unpack
,
204 GLint internalFormat
,
205 GLint width
, GLint height
,
206 GLenum format
, GLenum type
, const void *pixels
)
208 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
209 GLuint src_offset
, src_stride
;
210 GLuint dst_x
, dst_y
, dst_stride
;
211 drm_intel_bo
*dst_buffer
= intel_region_buffer(intel
,
212 intelImage
->mt
->region
,
215 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
216 intel
->ctx
._ImageTransferState
||
217 unpack
->SkipPixels
|| unpack
->SkipRows
) {
218 DBG("%s: failure 1\n", __FUNCTION__
);
222 /* note: potential 64-bit ptr to 32-bit int cast */
223 src_offset
= (GLuint
) (unsigned long) pixels
;
225 if (unpack
->RowLength
> 0)
226 src_stride
= unpack
->RowLength
;
230 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
234 dst_stride
= intelImage
->mt
->region
->pitch
;
236 if (drm_intel_bo_references(intel
->batch
->buf
, dst_buffer
))
237 intel_flush(&intel
->ctx
);
240 drm_intel_bo
*src_buffer
= intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
242 if (!intelEmitCopyBlit(intel
,
244 src_stride
, src_buffer
, src_offset
, GL_FALSE
,
245 dst_stride
, dst_buffer
, 0,
246 intelImage
->mt
->region
->tiling
,
247 0, 0, dst_x
, dst_y
, width
, height
,
258 try_pbo_zcopy(struct intel_context
*intel
,
259 struct intel_texture_image
*intelImage
,
260 const struct gl_pixelstore_attrib
*unpack
,
261 GLint internalFormat
,
262 GLint width
, GLint height
,
263 GLenum format
, GLenum type
, const void *pixels
)
265 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
266 GLuint src_offset
, src_stride
;
267 GLuint dst_x
, dst_y
, dst_stride
;
269 if (!_mesa_is_bufferobj(unpack
->BufferObj
) ||
270 intel
->ctx
._ImageTransferState
||
271 unpack
->SkipPixels
|| unpack
->SkipRows
) {
272 DBG("%s: failure 1\n", __FUNCTION__
);
276 /* note: potential 64-bit ptr to 32-bit int cast */
277 src_offset
= (GLuint
) (unsigned long) pixels
;
279 if (unpack
->RowLength
> 0)
280 src_stride
= unpack
->RowLength
;
284 intel_miptree_get_image_offset(intelImage
->mt
, intelImage
->level
,
288 dst_stride
= intelImage
->mt
->region
->pitch
;
290 if (src_stride
!= dst_stride
|| dst_x
!= 0 || dst_y
!= 0 ||
292 DBG("%s: failure 2\n", __FUNCTION__
);
296 intel_region_attach_pbo(intel
, intelImage
->mt
->region
, pbo
);
303 intelTexImage(GLcontext
* ctx
,
305 GLenum target
, GLint level
,
306 GLint internalFormat
,
307 GLint width
, GLint height
, GLint depth
,
309 GLenum format
, GLenum type
, const void *pixels
,
310 const struct gl_pixelstore_attrib
*unpack
,
311 struct gl_texture_object
*texObj
,
312 struct gl_texture_image
*texImage
, GLsizei imageSize
,
313 GLboolean compressed
)
315 struct intel_context
*intel
= intel_context(ctx
);
316 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
317 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
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 (_mesa_is_format_compressed(texImage
->TexFormat
)) {
331 texelBytes
= _mesa_get_format_bytes(texImage
->TexFormat
);
333 if (!intelImage
->mt
) {
334 assert(texImage
->RowStride
== width
);
338 /* Release the reference to a potentially orphaned buffer.
339 * Release any old malloced memory.
341 if (intelImage
->mt
) {
342 intel_miptree_release(intel
, &intelImage
->mt
);
343 assert(!texImage
->Data
);
345 else if (texImage
->Data
) {
346 _mesa_free_texmemory(texImage
->Data
);
347 texImage
->Data
= NULL
;
350 /* If this is the only texture image in the tree, could call
351 * bmBufferData with NULL data to free the old block and avoid
352 * waiting on any outstanding fences.
355 intelObj
->mt
->first_level
== level
&&
356 intelObj
->mt
->last_level
== level
&&
357 intelObj
->mt
->target
!= GL_TEXTURE_CUBE_MAP_ARB
&&
358 !intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
)) {
361 intel_miptree_release(intel
, &intelObj
->mt
);
362 assert(!intelObj
->mt
);
366 guess_and_alloc_mipmap_tree(intel
, intelObj
, intelImage
, pixels
== NULL
);
368 DBG("guess_and_alloc_mipmap_tree: failed\n");
372 assert(!intelImage
->mt
);
375 intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
)) {
377 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
378 assert(intelImage
->mt
);
379 } else if (intelImage
->base
.Border
== 0) {
381 GLuint texelBytes
= _mesa_get_format_bytes(intelImage
->base
.TexFormat
);
382 GLenum baseFormat
= _mesa_get_format_base_format(intelImage
->base
.TexFormat
);
383 if (_mesa_is_format_compressed(intelImage
->base
.TexFormat
)) {
385 intel_compressed_num_bytes(intelImage
->base
.TexFormat
);
388 /* Didn't fit in the object miptree, but it's suitable for inclusion in
389 * a miptree, so create one just for our level and store it in the image.
390 * It'll get moved into the object miptree at validate time.
392 intelImage
->mt
= intel_miptree_create(intel
, target
,
396 width
, height
, depth
,
398 comp_byte
, pixels
== NULL
);
406 _mesa_is_bufferobj(unpack
->BufferObj
) &&
407 check_pbo_format(internalFormat
, format
,
408 type
, intelImage
->base
.TexFormat
)) {
410 DBG("trying pbo upload\n");
412 /* Attempt to texture directly from PBO data (zero copy upload).
414 * Currently disable as it can lead to worse as well as better
415 * performance (in particular when intel_region_cow() is
418 if (intelObj
->mt
== intelImage
->mt
&&
419 intelObj
->mt
->first_level
== level
&&
420 intelObj
->mt
->last_level
== level
) {
422 if (try_pbo_zcopy(intel
, intelImage
, unpack
,
424 width
, height
, format
, type
, pixels
)) {
426 DBG("pbo zcopy upload succeeded\n");
432 /* Otherwise, attempt to use the blitter for PBO image uploads.
434 if (try_pbo_upload(intel
, intelImage
, unpack
,
436 width
, height
, format
, type
, pixels
)) {
437 DBG("pbo upload succeeded\n");
441 DBG("pbo upload failed\n");
444 /* intelCopyTexImage calls this function with pixels == NULL, with
445 * the expectation that the mipmap tree will be set up but nothing
446 * more will be done. This is where those calls return:
449 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
451 "glCompressedTexImage");
453 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
455 pixels
, unpack
, "glTexImage");
458 if (intelImage
->mt
) {
459 if (pixels
!= NULL
) {
460 /* Flush any queued rendering with the texture before mapping. */
461 if (drm_intel_bo_references(intel
->batch
->buf
,
462 intelImage
->mt
->region
->buffer
)) {
465 texImage
->Data
= intel_miptree_image_map(intel
,
470 intelImage
->base
.ImageOffsets
);
473 texImage
->RowStride
= dstRowStride
/ intelImage
->mt
->cpp
;
476 /* Allocate regular memory and store the image there temporarily. */
477 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
478 sizeInBytes
= _mesa_format_image_size(texImage
->TexFormat
,
483 _mesa_format_row_stride(texImage
->TexFormat
, width
);
487 dstRowStride
= width
* texelBytes
;
488 sizeInBytes
= depth
* dstRowStride
* height
;
491 texImage
->Data
= _mesa_alloc_texmemory(sizeInBytes
);
494 DBG("Upload image %dx%dx%d row_len %d "
495 "pitch %d pixels %d compressed %d\n",
496 width
, height
, depth
, width
* texelBytes
, dstRowStride
,
497 pixels
? 1 : 0, compressed
);
499 /* Copy data. Would like to know when it's ok for us to eg. use
500 * the blitter to copy. Or, use the hardware to do the format
501 * conversion and copy:
505 if (intelImage
->mt
) {
506 struct intel_region
*dst
= intelImage
->mt
->region
;
507 _mesa_copy_rect(texImage
->Data
, dst
->cpp
, dst
->pitch
,
509 intelImage
->mt
->level
[level
].width
,
510 (intelImage
->mt
->level
[level
].height
+3)/4,
516 memcpy(texImage
->Data
, pixels
, imageSize
);
519 else if (!_mesa_texstore(ctx
, dims
,
520 texImage
->_BaseFormat
,
522 texImage
->Data
, 0, 0, 0, /* dstX/Y/Zoffset */
524 texImage
->ImageOffsets
,
525 width
, height
, depth
,
526 format
, type
, pixels
, unpack
)) {
527 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
531 _mesa_unmap_teximage_pbo(ctx
, unpack
);
533 if (intelImage
->mt
) {
535 intel_miptree_image_unmap(intel
, intelImage
->mt
);
536 texImage
->Data
= NULL
;
542 intelTexImage3D(GLcontext
* ctx
,
543 GLenum target
, GLint level
,
544 GLint internalFormat
,
545 GLint width
, GLint height
, GLint depth
,
547 GLenum format
, GLenum type
, const void *pixels
,
548 const struct gl_pixelstore_attrib
*unpack
,
549 struct gl_texture_object
*texObj
,
550 struct gl_texture_image
*texImage
)
552 intelTexImage(ctx
, 3, target
, level
,
553 internalFormat
, width
, height
, depth
, border
,
554 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
559 intelTexImage2D(GLcontext
* ctx
,
560 GLenum target
, GLint level
,
561 GLint internalFormat
,
562 GLint width
, GLint height
, GLint border
,
563 GLenum format
, GLenum type
, const void *pixels
,
564 const struct gl_pixelstore_attrib
*unpack
,
565 struct gl_texture_object
*texObj
,
566 struct gl_texture_image
*texImage
)
568 intelTexImage(ctx
, 2, target
, level
,
569 internalFormat
, width
, height
, 1, border
,
570 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
575 intelTexImage1D(GLcontext
* ctx
,
576 GLenum target
, GLint level
,
577 GLint internalFormat
,
578 GLint width
, GLint border
,
579 GLenum format
, GLenum type
, const void *pixels
,
580 const struct gl_pixelstore_attrib
*unpack
,
581 struct gl_texture_object
*texObj
,
582 struct gl_texture_image
*texImage
)
584 intelTexImage(ctx
, 1, target
, level
,
585 internalFormat
, width
, 1, 1, border
,
586 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
591 intelCompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
592 GLint internalFormat
,
593 GLint width
, GLint height
, GLint border
,
594 GLsizei imageSize
, const GLvoid
*data
,
595 struct gl_texture_object
*texObj
,
596 struct gl_texture_image
*texImage
)
598 intelTexImage(ctx
, 2, target
, level
,
599 internalFormat
, width
, height
, 1, border
,
600 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
605 * Need to map texture image into memory before copying image data,
609 intel_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
610 GLenum format
, GLenum type
, GLvoid
* pixels
,
611 struct gl_texture_object
*texObj
,
612 struct gl_texture_image
*texImage
, GLboolean compressed
)
614 struct intel_context
*intel
= intel_context(ctx
);
615 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
617 /* If we're reading from a texture that has been rendered to, need to
618 * make sure rendering is complete.
619 * We could probably predicate this on texObj->_RenderToTexture
624 if (intelImage
->mt
) {
625 /* Image is stored in hardware format in a buffer managed by the
626 * kernel. Need to explicitly map and unmap it.
628 intelImage
->base
.Data
=
629 intel_miptree_image_map(intel
,
633 &intelImage
->base
.RowStride
,
634 intelImage
->base
.ImageOffsets
);
635 intelImage
->base
.RowStride
/= intelImage
->mt
->cpp
;
638 /* Otherwise, the image should actually be stored in
639 * intelImage->base.Data. This is pretty confusing for
640 * everybody, I'd much prefer to separate the two functions of
641 * texImage->Data - storage for texture images in main memory
642 * and access (ie mappings) of images. In other words, we'd
643 * create a new texImage->Map field and leave Data simply for
646 assert(intelImage
->base
.Data
);
651 _mesa_get_compressed_teximage(ctx
, target
, level
, pixels
,
655 _mesa_get_teximage(ctx
, target
, level
, format
, type
, pixels
,
661 if (intelImage
->mt
) {
662 intel_miptree_image_unmap(intel
, intelImage
->mt
);
663 intelImage
->base
.Data
= NULL
;
669 intelGetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
670 GLenum format
, GLenum type
, GLvoid
* pixels
,
671 struct gl_texture_object
*texObj
,
672 struct gl_texture_image
*texImage
)
674 intel_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
675 texObj
, texImage
, GL_FALSE
);
680 intelGetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
682 struct gl_texture_object
*texObj
,
683 struct gl_texture_image
*texImage
)
685 intel_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
686 texObj
, texImage
, GL_TRUE
);
690 intelSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
691 GLint texture_format
,
692 __DRIdrawable
*dPriv
)
694 struct gl_framebuffer
*fb
= dPriv
->driverPrivate
;
695 struct intel_context
*intel
= pDRICtx
->driverPrivate
;
696 GLcontext
*ctx
= &intel
->ctx
;
697 struct intel_texture_object
*intelObj
;
698 struct intel_texture_image
*intelImage
;
699 struct intel_mipmap_tree
*mt
;
700 struct intel_renderbuffer
*rb
;
701 struct gl_texture_object
*texObj
;
702 struct gl_texture_image
*texImage
;
703 int level
= 0, internalFormat
;
705 texObj
= _mesa_get_current_tex_object(ctx
, target
);
706 intelObj
= intel_texture_object(texObj
);
711 if (dPriv
->lastStamp
!= dPriv
->dri2
.stamp
||
712 !pDRICtx
->driScreenPriv
->dri2
.useInvalidate
)
713 intel_update_renderbuffers(pDRICtx
, dPriv
);
715 rb
= intel_get_renderbuffer(fb
, BUFFER_FRONT_LEFT
);
716 /* If the region isn't set, then intel_update_renderbuffers was unable
717 * to get the buffers for the drawable.
719 if (rb
->region
== NULL
)
722 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
723 internalFormat
= GL_RGB
;
725 internalFormat
= GL_RGBA
;
727 mt
= intel_miptree_create_for_region(intel
, target
,
729 0, 0, rb
->region
, 1, 0);
733 _mesa_lock_texture(&intel
->ctx
, texObj
);
735 texImage
= _mesa_get_tex_image(&intel
->ctx
, texObj
, target
, level
);
736 intelImage
= intel_texture_image(texImage
);
738 if (intelImage
->mt
) {
739 intel_miptree_release(intel
, &intelImage
->mt
);
740 assert(!texImage
->Data
);
743 intel_miptree_release(intel
, &intelObj
->mt
);
746 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
747 rb
->region
->width
, rb
->region
->height
, 1,
750 intelImage
->face
= target_to_face(target
);
751 intelImage
->level
= level
;
752 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
753 texImage
->TexFormat
= MESA_FORMAT_XRGB8888
;
755 texImage
->TexFormat
= MESA_FORMAT_ARGB8888
;
756 texImage
->RowStride
= rb
->region
->pitch
;
757 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
759 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
)) {
760 fprintf(stderr
, "miptree doesn't match image\n");
763 _mesa_unlock_texture(&intel
->ctx
, texObj
);
767 intelSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
769 /* The old interface didn't have the format argument, so copy our
770 * implementation's behavior at the time.
772 intelSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
775 #if FEATURE_OES_EGL_image
777 intel_image_target_texture_2d(GLcontext
*ctx
, GLenum target
,
778 struct gl_texture_object
*texObj
,
779 struct gl_texture_image
*texImage
,
780 GLeglImageOES image_handle
)
782 struct intel_context
*intel
= intel_context(ctx
);
783 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
784 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
785 struct intel_mipmap_tree
*mt
;
789 screen
= intel
->intelScreen
->driScrnPriv
;
790 image
= screen
->dri2
.image
->lookupEGLImage(screen
, image_handle
,
791 screen
->loaderPrivate
);
795 mt
= intel_miptree_create_for_region(intel
, target
,
796 image
->internal_format
,
797 0, 0, image
->region
, 1, 0);
801 if (intelImage
->mt
) {
802 intel_miptree_release(intel
, &intelImage
->mt
);
803 assert(!texImage
->Data
);
806 intel_miptree_release(intel
, &intelObj
->mt
);
809 _mesa_init_teximage_fields(&intel
->ctx
, target
, texImage
,
810 image
->region
->width
, image
->region
->height
, 1,
811 0, image
->internal_format
);
813 intelImage
->face
= target_to_face(target
);
814 intelImage
->level
= 0;
815 texImage
->TexFormat
= image
->format
;
816 texImage
->RowStride
= image
->region
->pitch
;
817 intel_miptree_reference(&intelImage
->mt
, intelObj
->mt
);
819 if (!intel_miptree_match_image(intelObj
->mt
, &intelImage
->base
))
820 fprintf(stderr
, "miptree doesn't match image\n");
825 intelInitTextureImageFuncs(struct dd_function_table
*functions
)
827 functions
->TexImage1D
= intelTexImage1D
;
828 functions
->TexImage2D
= intelTexImage2D
;
829 functions
->TexImage3D
= intelTexImage3D
;
830 functions
->GetTexImage
= intelGetTexImage
;
832 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
833 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;
835 #if FEATURE_OES_EGL_image
836 functions
->EGLImageTargetTexture2D
= intel_image_target_texture_2d
;