2 #include "main/glheader.h"
3 #include "main/macros.h"
4 #include "main/mfeatures.h"
5 #include "main/mtypes.h"
6 #include "main/enums.h"
7 #include "main/bufferobj.h"
8 #include "main/context.h"
9 #include "main/formats.h"
11 #include "main/renderbuffer.h"
12 #include "main/texcompress.h"
13 #include "main/texstore.h"
14 #include "main/texgetimage.h"
15 #include "main/texobj.h"
16 #include "main/teximage.h"
18 #include "intel_context.h"
19 #include "intel_mipmap_tree.h"
20 #include "intel_buffer_objects.h"
21 #include "intel_batchbuffer.h"
22 #include "intel_tex.h"
23 #include "intel_blit.h"
24 #include "intel_fbo.h"
25 #include "intel_span.h"
27 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
29 /* Functions to store texture images. Where possible, mipmap_tree's
30 * will be created or further instantiated with image data, otherwise
31 * images will be stored in malloc'd memory. A validation step is
32 * required to pull those images into a mipmap tree, or otherwise
33 * decide a fallback is required.
38 /* Otherwise, store it in memory if (Border != 0) or (any dimension ==
41 * Otherwise, if max_level >= level >= min_level, create tree with
42 * space for textures from min_level down to max_level.
44 * Otherwise, create tree with space for textures from (level
45 * 0)..(1x1). Consider pruning this tree at a validation if the
48 static struct intel_mipmap_tree *
49 intel_miptree_create_for_teximage(struct intel_context *intel,
50 struct intel_texture_object *intelObj,
51 struct intel_texture_image *intelImage,
52 GLboolean expect_accelerated_upload)
56 GLuint width = intelImage->base.Width;
57 GLuint height = intelImage->base.Height;
58 GLuint depth = intelImage->base.Depth;
61 DBG("%s\n", __FUNCTION__);
63 if (intelImage->base.Border)
66 if (intelImage->level > intelObj->base.BaseLevel &&
67 (intelImage->base.Width == 1 ||
68 (intelObj->base.Target != GL_TEXTURE_1D &&
69 intelImage->base.Height == 1) ||
70 (intelObj->base.Target == GL_TEXTURE_3D &&
71 intelImage->base.Depth == 1))) {
72 /* For this combination, we're at some lower mipmap level and
73 * some important dimension is 1. We can't extrapolate up to a
74 * likely base level width/height/depth for a full mipmap stack
75 * from this info, so just allocate this one level.
77 firstLevel = intelImage->level;
78 lastLevel = intelImage->level;
80 /* If this image disrespects BaseLevel, allocate from level zero.
81 * Usually BaseLevel == 0, so it's unlikely to happen.
83 if (intelImage->level < intelObj->base.BaseLevel)
86 firstLevel = intelObj->base.BaseLevel;
88 /* Figure out image dimensions at start level. */
89 for (i = intelImage->level; i > firstLevel; i--) {
97 /* Guess a reasonable value for lastLevel. This is probably going
98 * to be wrong fairly often and might mean that we have to look at
99 * resizable buffers, or require that buffers implement lazy
100 * pagetable arrangements.
102 if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
103 intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
104 intelImage->level == firstLevel &&
105 (intel->gen < 4 || firstLevel == 0)) {
106 lastLevel = firstLevel;
108 lastLevel = firstLevel + _mesa_logbase2(MAX2(MAX2(width, height), depth));
112 return intel_miptree_create(intel,
113 intelObj->base.Target,
114 intelImage->base.TexFormat,
120 expect_accelerated_upload);
127 target_to_face(GLenum target)
130 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
131 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
132 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
133 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
134 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
135 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
136 return ((GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
142 /* There are actually quite a few combinations this will work for,
143 * more than what I've listed here.
146 check_pbo_format(GLint internalFormat,
147 GLenum format, GLenum type,
148 gl_format mesa_format)
150 switch (internalFormat) {
154 return (format == GL_BGRA &&
155 (type == GL_UNSIGNED_BYTE ||
156 type == GL_UNSIGNED_INT_8_8_8_8_REV) &&
157 mesa_format == MESA_FORMAT_ARGB8888);
160 return (format == GL_RGB &&
161 type == GL_UNSIGNED_SHORT_5_6_5 &&
162 mesa_format == MESA_FORMAT_RGB565);
165 return (format == GL_LUMINANCE &&
166 type == GL_UNSIGNED_BYTE &&
167 mesa_format == MESA_FORMAT_L8);
169 return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
176 /* XXX: Do this for TexSubImage also:
179 try_pbo_upload(struct intel_context *intel,
180 struct intel_texture_image *intelImage,
181 const struct gl_pixelstore_attrib *unpack,
182 GLint internalFormat,
183 GLint width, GLint height,
184 GLenum format, GLenum type, const void *pixels)
186 struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
187 GLuint src_offset, src_stride;
188 GLuint dst_x, dst_y, dst_stride;
189 drm_intel_bo *dst_buffer = intel_region_buffer(intel,
190 intelImage->mt->region,
193 if (!_mesa_is_bufferobj(unpack->BufferObj) ||
194 intel->ctx._ImageTransferState ||
195 unpack->SkipPixels || unpack->SkipRows) {
196 DBG("%s: failure 1\n", __FUNCTION__);
200 /* note: potential 64-bit ptr to 32-bit int cast */
201 src_offset = (GLuint) (unsigned long) pixels;
203 if (unpack->RowLength > 0)
204 src_stride = unpack->RowLength;
208 intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
212 dst_stride = intelImage->mt->region->pitch;
214 if (drm_intel_bo_references(intel->batch.bo, dst_buffer))
215 intel_flush(&intel->ctx);
219 drm_intel_bo *src_buffer =
220 intel_bufferobj_source(intel, pbo, 64, &offset);
222 if (!intelEmitCopyBlit(intel,
224 src_stride, src_buffer,
225 src_offset + offset, GL_FALSE,
226 dst_stride, dst_buffer, 0,
227 intelImage->mt->region->tiling,
228 0, 0, dst_x, dst_y, width, height,
239 try_pbo_zcopy(struct intel_context *intel,
240 struct intel_texture_image *intelImage,
241 const struct gl_pixelstore_attrib *unpack,
242 GLint internalFormat,
243 GLint width, GLint height,
244 GLenum format, GLenum type, const void *pixels)
246 struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
247 GLuint src_offset, src_stride;
248 GLuint dst_x, dst_y, dst_stride;
250 if (!_mesa_is_bufferobj(unpack->BufferObj) ||
251 intel->ctx._ImageTransferState ||
252 unpack->SkipPixels || unpack->SkipRows) {
253 DBG("%s: failure 1\n", __FUNCTION__);
257 /* note: potential 64-bit ptr to 32-bit int cast */
258 src_offset = (GLuint) (unsigned long) pixels;
260 if (unpack->RowLength > 0)
261 src_stride = unpack->RowLength;
265 intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
269 dst_stride = intelImage->mt->region->pitch;
271 if (src_stride != dst_stride || dst_x != 0 || dst_y != 0 ||
273 DBG("%s: failure 2\n", __FUNCTION__);
277 intel_region_attach_pbo(intel, intelImage->mt->region, pbo);
283 * \param scatter Scatter if true. Gather if false.
285 * \see intel_tex_image_x8z24_scatter
286 * \see intel_tex_image_x8z24_gather
289 intel_tex_image_s8z24_scattergather(struct intel_context *intel,
290 struct intel_texture_image *intel_image,
293 struct gl_context *ctx = &intel->ctx;
294 struct gl_renderbuffer *depth_rb = intel_image->depth_rb;
295 struct gl_renderbuffer *stencil_rb = intel_image->stencil_rb;
297 int w = intel_image->base.Width;
298 int h = intel_image->base.Height;
300 uint32_t depth_row[w];
301 uint8_t stencil_row[w];
303 intel_renderbuffer_map(intel, depth_rb);
304 intel_renderbuffer_map(intel, stencil_rb);
307 for (int y = 0; y < h; ++y) {
308 depth_rb->GetRow(ctx, depth_rb, w, 0, y, depth_row);
309 for (int x = 0; x < w; ++x) {
310 stencil_row[x] = depth_row[x] >> 24;
312 stencil_rb->PutRow(ctx, stencil_rb, w, 0, y, stencil_row, NULL);
314 } else { /* gather */
315 for (int y = 0; y < h; ++y) {
316 depth_rb->GetRow(ctx, depth_rb, w, 0, y, depth_row);
317 stencil_rb->GetRow(ctx, stencil_rb, w, 0, y, stencil_row);
318 for (int x = 0; x < w; ++x) {
319 uint32_t s8_x24 = stencil_row[x] << 24;
320 uint32_t x8_z24 = depth_row[x] & 0x00ffffff;
321 depth_row[x] = s8_x24 | x8_z24;
323 depth_rb->PutRow(ctx, depth_rb, w, 0, y, depth_row, NULL);
327 intel_renderbuffer_unmap(intel, depth_rb);
328 intel_renderbuffer_unmap(intel, stencil_rb);
332 * Copy the x8 bits from intel_image->depth_rb to intel_image->stencil_rb.
335 intel_tex_image_s8z24_scatter(struct intel_context *intel,
336 struct intel_texture_image *intel_image)
338 intel_tex_image_s8z24_scattergather(intel, intel_image, true);
342 * Copy the data in intel_image->stencil_rb to the x8 bits in
343 * intel_image->depth_rb.
346 intel_tex_image_s8z24_gather(struct intel_context *intel,
347 struct intel_texture_image *intel_image)
349 intel_tex_image_s8z24_scattergather(intel, intel_image, false);
353 intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel,
354 struct intel_texture_image *image)
356 struct gl_context *ctx = &intel->ctx;
359 int width = image->base.Width;
360 int height = image->base.Height;
361 struct gl_renderbuffer *drb;
362 struct gl_renderbuffer *srb;
363 struct intel_renderbuffer *idrb;
364 struct intel_renderbuffer *isrb;
366 assert(intel->has_separate_stencil);
367 assert(image->base.TexFormat == MESA_FORMAT_S8_Z24);
368 assert(image->mt != NULL);
370 drb = intel_create_wrapped_renderbuffer(ctx, width, height,
372 srb = intel_create_wrapped_renderbuffer(ctx, width, height,
385 idrb = intel_renderbuffer(drb);
386 isrb = intel_renderbuffer(srb);
388 intel_region_reference(&idrb->region, image->mt->region);
389 ok = intel_alloc_renderbuffer_storage(ctx, srb, GL_STENCIL_INDEX8,
398 intel_renderbuffer_set_draw_offset(idrb, image, 0);
399 intel_renderbuffer_set_draw_offset(isrb, image, 0);
401 _mesa_reference_renderbuffer(&image->depth_rb, drb);
402 _mesa_reference_renderbuffer(&image->stencil_rb, srb);
408 intelTexImage(struct gl_context * ctx,
410 GLenum target, GLint level,
411 GLint internalFormat,
412 GLint width, GLint height, GLint depth,
414 GLenum format, GLenum type, const void *pixels,
415 const struct gl_pixelstore_attrib *unpack,
416 struct gl_texture_object *texObj,
417 struct gl_texture_image *texImage, GLsizei imageSize,
418 GLboolean compressed)
420 struct intel_context *intel = intel_context(ctx);
421 struct intel_texture_object *intelObj = intel_texture_object(texObj);
422 struct intel_texture_image *intelImage = intel_texture_image(texImage);
423 GLint texelBytes, sizeInBytes;
424 GLuint dstRowStride = 0, srcRowStride = texImage->RowStride;
426 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
427 _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
429 intelImage->face = target_to_face(target);
430 intelImage->level = level;
432 if (_mesa_is_format_compressed(texImage->TexFormat)) {
436 texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
438 if (!intelImage->mt) {
439 assert(texImage->RowStride == width);
443 ctx->Driver.FreeTexImageData(ctx, texImage);
444 assert(!intelImage->mt);
447 intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
448 /* Use an existing miptree when possible */
449 intel_miptree_reference(&intelImage->mt, intelObj->mt);
450 assert(intelImage->mt);
451 } else if (intelImage->base.Border == 0) {
452 /* Didn't fit in the object miptree, but it's suitable for inclusion in
453 * a miptree, so create one just for our level and store it in the image.
454 * It'll get moved into the object miptree at validate time.
456 intelImage->mt = intel_miptree_create_for_teximage(intel, intelObj,
460 /* Even if the object currently has a mipmap tree associated
461 * with it, this one is a more likely candidate to represent the
462 * whole object since our level didn't fit what was there
463 * before, and any lower levels would fit into our miptree.
465 if (intelImage->mt) {
466 intel_miptree_release(intel, &intelObj->mt);
467 intel_miptree_reference(&intelObj->mt, intelImage->mt);
475 _mesa_is_bufferobj(unpack->BufferObj) &&
476 check_pbo_format(internalFormat, format,
477 type, intelImage->base.TexFormat)) {
479 DBG("trying pbo upload\n");
481 /* Attempt to texture directly from PBO data (zero copy upload).
483 * Currently disable as it can lead to worse as well as better
484 * performance (in particular when intel_region_cow() is
487 if (intelObj->mt == intelImage->mt &&
488 intelObj->mt->first_level == level &&
489 intelObj->mt->last_level == level) {
491 if (try_pbo_zcopy(intel, intelImage, unpack,
493 width, height, format, type, pixels)) {
495 DBG("pbo zcopy upload succeeded\n");
501 /* Otherwise, attempt to use the blitter for PBO image uploads.
503 if (try_pbo_upload(intel, intelImage, unpack,
505 width, height, format, type, pixels)) {
506 DBG("pbo upload succeeded\n");
510 DBG("pbo upload failed\n");
513 /* intelCopyTexImage calls this function with pixels == NULL, with
514 * the expectation that the mipmap tree will be set up but nothing
515 * more will be done. This is where those calls return:
518 pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels,
520 "glCompressedTexImage");
522 pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
524 pixels, unpack, "glTexImage");
527 if (intelImage->mt) {
528 if (pixels != NULL) {
529 /* Flush any queued rendering with the texture before mapping. */
530 if (drm_intel_bo_references(intel->batch.bo,
531 intelImage->mt->region->buffer)) {
534 texImage->Data = intel_miptree_image_map(intel,
539 intelImage->base.ImageOffsets);
542 texImage->RowStride = dstRowStride / intelImage->mt->cpp;
545 /* Allocate regular memory and store the image there temporarily. */
546 if (_mesa_is_format_compressed(texImage->TexFormat)) {
547 sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
552 _mesa_format_row_stride(texImage->TexFormat, width);
556 dstRowStride = width * texelBytes;
557 sizeInBytes = depth * dstRowStride * height;
560 texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
563 DBG("Upload image %dx%dx%d row_len %d "
564 "pitch %d pixels %d compressed %d\n",
565 width, height, depth, width * texelBytes, dstRowStride,
566 pixels ? 1 : 0, compressed);
568 /* Copy data. Would like to know when it's ok for us to eg. use
569 * the blitter to copy. Or, use the hardware to do the format
570 * conversion and copy:
574 if (intelImage->mt) {
575 struct intel_region *dst = intelImage->mt->region;
576 _mesa_copy_rect(texImage->Data, dst->cpp, dst->pitch,
578 intelImage->mt->level[level].width,
579 (intelImage->mt->level[level].height+3)/4,
585 memcpy(texImage->Data, pixels, imageSize);
588 else if (!_mesa_texstore(ctx, dims,
589 texImage->_BaseFormat,
591 texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
593 texImage->ImageOffsets,
594 width, height, depth,
595 format, type, pixels, unpack)) {
596 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
599 _mesa_unmap_teximage_pbo(ctx, unpack);
602 if (intel->must_use_separate_stencil
603 && texImage->TexFormat == MESA_FORMAT_S8_Z24) {
604 intel_tex_image_s8z24_create_renderbuffers(intel, intelImage);
605 intel_tex_image_s8z24_scatter(intel, intelImage);
608 if (intelImage->mt) {
610 intel_miptree_image_unmap(intel, intelImage->mt);
611 texImage->Data = NULL;
617 intelTexImage3D(struct gl_context * ctx,
618 GLenum target, GLint level,
619 GLint internalFormat,
620 GLint width, GLint height, GLint depth,
622 GLenum format, GLenum type, const void *pixels,
623 const struct gl_pixelstore_attrib *unpack,
624 struct gl_texture_object *texObj,
625 struct gl_texture_image *texImage)
627 intelTexImage(ctx, 3, target, level,
628 internalFormat, width, height, depth, border,
629 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
634 intelTexImage2D(struct gl_context * ctx,
635 GLenum target, GLint level,
636 GLint internalFormat,
637 GLint width, GLint height, GLint border,
638 GLenum format, GLenum type, const void *pixels,
639 const struct gl_pixelstore_attrib *unpack,
640 struct gl_texture_object *texObj,
641 struct gl_texture_image *texImage)
643 intelTexImage(ctx, 2, target, level,
644 internalFormat, width, height, 1, border,
645 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
650 intelTexImage1D(struct gl_context * ctx,
651 GLenum target, GLint level,
652 GLint internalFormat,
653 GLint width, GLint border,
654 GLenum format, GLenum type, const void *pixels,
655 const struct gl_pixelstore_attrib *unpack,
656 struct gl_texture_object *texObj,
657 struct gl_texture_image *texImage)
659 intelTexImage(ctx, 1, target, level,
660 internalFormat, width, 1, 1, border,
661 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
666 intelCompressedTexImage2D( struct gl_context *ctx, GLenum target, GLint level,
667 GLint internalFormat,
668 GLint width, GLint height, GLint border,
669 GLsizei imageSize, const GLvoid *data,
670 struct gl_texture_object *texObj,
671 struct gl_texture_image *texImage )
673 intelTexImage(ctx, 2, target, level,
674 internalFormat, width, height, 1, border,
675 0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, GL_TRUE);
680 * Need to map texture image into memory before copying image data,
684 intel_get_tex_image(struct gl_context * ctx, GLenum target, GLint level,
685 GLenum format, GLenum type, GLvoid * pixels,
686 struct gl_texture_object *texObj,
687 struct gl_texture_image *texImage, GLboolean compressed)
689 struct intel_context *intel = intel_context(ctx);
690 struct intel_texture_image *intelImage = intel_texture_image(texImage);
692 /* If we're reading from a texture that has been rendered to, need to
693 * make sure rendering is complete.
694 * We could probably predicate this on texObj->_RenderToTexture
699 if (intelImage->mt) {
700 /* Image is stored in hardware format in a buffer managed by the
701 * kernel. Need to explicitly map and unmap it.
703 intelImage->base.Data =
704 intel_miptree_image_map(intel,
708 &intelImage->base.RowStride,
709 intelImage->base.ImageOffsets);
710 intelImage->base.RowStride /= intelImage->mt->cpp;
713 /* Otherwise, the image should actually be stored in
714 * intelImage->base.Data. This is pretty confusing for
715 * everybody, I'd much prefer to separate the two functions of
716 * texImage->Data - storage for texture images in main memory
717 * and access (ie mappings) of images. In other words, we'd
718 * create a new texImage->Map field and leave Data simply for
721 assert(intelImage->base.Data);
724 if (intelImage->stencil_rb) {
726 * The texture has packed depth/stencil format, but uses separate
727 * stencil. The texture's embedded stencil buffer contains the real
728 * stencil data, so copy that into the miptree.
730 intel_tex_image_s8z24_gather(intel, intelImage);
734 _mesa_get_compressed_teximage(ctx, target, level, pixels,
738 _mesa_get_teximage(ctx, target, level, format, type, pixels,
744 if (intelImage->mt) {
745 intel_miptree_image_unmap(intel, intelImage->mt);
746 intelImage->base.Data = NULL;
752 intelGetTexImage(struct gl_context * ctx, GLenum target, GLint level,
753 GLenum format, GLenum type, GLvoid * pixels,
754 struct gl_texture_object *texObj,
755 struct gl_texture_image *texImage)
757 intel_get_tex_image(ctx, target, level, format, type, pixels,
758 texObj, texImage, GL_FALSE);
763 intelGetCompressedTexImage(struct gl_context *ctx, GLenum target, GLint level,
765 struct gl_texture_object *texObj,
766 struct gl_texture_image *texImage)
768 intel_get_tex_image(ctx, target, level, 0, 0, pixels,
769 texObj, texImage, GL_TRUE);
773 intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
774 GLint texture_format,
775 __DRIdrawable *dPriv)
777 struct gl_framebuffer *fb = dPriv->driverPrivate;
778 struct intel_context *intel = pDRICtx->driverPrivate;
779 struct gl_context *ctx = &intel->ctx;
780 struct intel_texture_object *intelObj;
781 struct intel_texture_image *intelImage;
782 struct intel_mipmap_tree *mt;
783 struct intel_renderbuffer *rb;
784 struct gl_texture_object *texObj;
785 struct gl_texture_image *texImage;
786 int level = 0, internalFormat;
789 texObj = _mesa_get_current_tex_object(ctx, target);
790 intelObj = intel_texture_object(texObj);
795 if (dPriv->lastStamp != dPriv->dri2.stamp ||
796 !pDRICtx->driScreenPriv->dri2.useInvalidate)
797 intel_update_renderbuffers(pDRICtx, dPriv);
799 rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
800 /* If the region isn't set, then intel_update_renderbuffers was unable
801 * to get the buffers for the drawable.
803 if (rb->region == NULL)
806 if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
807 internalFormat = GL_RGB;
808 texFormat = MESA_FORMAT_XRGB8888;
811 internalFormat = GL_RGBA;
812 texFormat = MESA_FORMAT_ARGB8888;
815 mt = intel_miptree_create_for_region(intel, target, texFormat,
820 _mesa_lock_texture(&intel->ctx, texObj);
822 texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
823 intelImage = intel_texture_image(texImage);
825 if (intelImage->mt) {
826 intel_miptree_release(intel, &intelImage->mt);
827 assert(!texImage->Data);
830 intel_miptree_release(intel, &intelObj->mt);
834 _mesa_init_teximage_fields(&intel->ctx, target, texImage,
835 rb->region->width, rb->region->height, 1,
836 0, internalFormat, texFormat);
838 intelImage->face = target_to_face(target);
839 intelImage->level = level;
840 texImage->RowStride = rb->region->pitch;
841 intel_miptree_reference(&intelImage->mt, intelObj->mt);
843 if (!intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
844 fprintf(stderr, "miptree doesn't match image\n");
847 _mesa_unlock_texture(&intel->ctx, texObj);
851 intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
853 /* The old interface didn't have the format argument, so copy our
854 * implementation's behavior at the time.
856 intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
859 #if FEATURE_OES_EGL_image
861 intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
862 struct gl_texture_object *texObj,
863 struct gl_texture_image *texImage,
864 GLeglImageOES image_handle)
866 struct intel_context *intel = intel_context(ctx);
867 struct intel_texture_object *intelObj = intel_texture_object(texObj);
868 struct intel_texture_image *intelImage = intel_texture_image(texImage);
869 struct intel_mipmap_tree *mt;
873 screen = intel->intelScreen->driScrnPriv;
874 image = screen->dri2.image->lookupEGLImage(screen, image_handle,
875 screen->loaderPrivate);
879 mt = intel_miptree_create_for_region(intel, target, image->format,
884 if (intelImage->mt) {
885 intel_miptree_release(intel, &intelImage->mt);
886 assert(!texImage->Data);
889 intel_miptree_release(intel, &intelObj->mt);
892 _mesa_init_teximage_fields(&intel->ctx, target, texImage,
893 image->region->width, image->region->height, 1,
894 0, image->internal_format, image->format);
896 intelImage->face = target_to_face(target);
897 intelImage->level = 0;
898 texImage->RowStride = image->region->pitch;
899 intel_miptree_reference(&intelImage->mt, intelObj->mt);
901 if (!intel_miptree_match_image(intelObj->mt, &intelImage->base))
902 fprintf(stderr, "miptree doesn't match image\n");
907 intelInitTextureImageFuncs(struct dd_function_table *functions)
909 functions->TexImage1D = intelTexImage1D;
910 functions->TexImage2D = intelTexImage2D;
911 functions->TexImage3D = intelTexImage3D;
912 functions->GetTexImage = intelGetTexImage;
914 functions->CompressedTexImage2D = intelCompressedTexImage2D;
915 functions->GetCompressedTexImage = intelGetCompressedTexImage;
917 #if FEATURE_OES_EGL_image
918 functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;