i965: Rename intelScreen to screen.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_tex_image.c
1
2 #include "main/macros.h"
3 #include "main/mtypes.h"
4 #include "main/enums.h"
5 #include "main/bufferobj.h"
6 #include "main/context.h"
7 #include "main/formats.h"
8 #include "main/glformats.h"
9 #include "main/image.h"
10 #include "main/pbo.h"
11 #include "main/renderbuffer.h"
12 #include "main/texcompress.h"
13 #include "main/texgetimage.h"
14 #include "main/texobj.h"
15 #include "main/teximage.h"
16 #include "main/texstore.h"
17
18 #include "drivers/common/meta.h"
19
20 #include "intel_mipmap_tree.h"
21 #include "intel_buffer_objects.h"
22 #include "intel_batchbuffer.h"
23 #include "intel_tex.h"
24 #include "intel_blit.h"
25 #include "intel_fbo.h"
26 #include "intel_image.h"
27 #include "intel_tiled_memcpy.h"
28 #include "brw_context.h"
29
30 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
31
32 /* Work back from the specified level of the image to the baselevel and create a
33 * miptree of that size.
34 */
35 struct intel_mipmap_tree *
36 intel_miptree_create_for_teximage(struct brw_context *brw,
37 struct intel_texture_object *intelObj,
38 struct intel_texture_image *intelImage,
39 uint32_t layout_flags)
40 {
41 GLuint lastLevel;
42 int width, height, depth;
43
44 intel_get_image_dims(&intelImage->base.Base, &width, &height, &depth);
45
46 DBG("%s\n", __func__);
47
48 /* Figure out image dimensions at start level. */
49 switch(intelObj->base.Target) {
50 case GL_TEXTURE_2D_MULTISAMPLE:
51 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
52 case GL_TEXTURE_RECTANGLE:
53 case GL_TEXTURE_EXTERNAL_OES:
54 assert(intelImage->base.Base.Level == 0);
55 break;
56 case GL_TEXTURE_3D:
57 depth <<= intelImage->base.Base.Level;
58 /* Fall through */
59 case GL_TEXTURE_2D:
60 case GL_TEXTURE_2D_ARRAY:
61 case GL_TEXTURE_CUBE_MAP:
62 case GL_TEXTURE_CUBE_MAP_ARRAY:
63 height <<= intelImage->base.Base.Level;
64 /* Fall through */
65 case GL_TEXTURE_1D:
66 case GL_TEXTURE_1D_ARRAY:
67 width <<= intelImage->base.Base.Level;
68 break;
69 default:
70 unreachable("Unexpected target");
71 }
72
73 /* Guess a reasonable value for lastLevel. This is probably going
74 * to be wrong fairly often and might mean that we have to look at
75 * resizable buffers, or require that buffers implement lazy
76 * pagetable arrangements.
77 */
78 if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
79 intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
80 intelImage->base.Base.Level == 0 &&
81 !intelObj->base.GenerateMipmap) {
82 lastLevel = 0;
83 } else {
84 lastLevel = _mesa_get_tex_max_num_levels(intelObj->base.Target,
85 width, height, depth) - 1;
86 }
87
88 return intel_miptree_create(brw,
89 intelObj->base.Target,
90 intelImage->base.Base.TexFormat,
91 0,
92 lastLevel,
93 width,
94 height,
95 depth,
96 intelImage->base.Base.NumSamples,
97 layout_flags | MIPTREE_LAYOUT_TILING_ANY);
98 }
99
100 static void
101 intelTexImage(struct gl_context * ctx,
102 GLuint dims,
103 struct gl_texture_image *texImage,
104 GLenum format, GLenum type, const void *pixels,
105 const struct gl_pixelstore_attrib *unpack)
106 {
107 struct intel_texture_image *intelImage = intel_texture_image(texImage);
108 bool ok;
109
110 bool tex_busy = intelImage->mt && drm_intel_bo_busy(intelImage->mt->bo);
111
112 DBG("%s mesa_format %s target %s format %s type %s level %d %dx%dx%d\n",
113 __func__, _mesa_get_format_name(texImage->TexFormat),
114 _mesa_enum_to_string(texImage->TexObject->Target),
115 _mesa_enum_to_string(format), _mesa_enum_to_string(type),
116 texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
117
118 /* Allocate storage for texture data. */
119 if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
120 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
121 return;
122 }
123
124 assert(intelImage->mt);
125
126 if (intelImage->mt->format == MESA_FORMAT_S_UINT8)
127 intelImage->mt->r8stencil_needs_update = true;
128
129 ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage, 0, 0, 0,
130 texImage->Width, texImage->Height,
131 texImage->Depth,
132 format, type, pixels,
133 tex_busy, unpack);
134 if (ok)
135 return;
136
137 ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
138 0, 0, 0, /*x,y,z offsets*/
139 texImage->Width,
140 texImage->Height,
141 texImage->Depth,
142 format, type, pixels, unpack,
143 false /*allocate_storage*/);
144 if (ok)
145 return;
146
147 DBG("%s: upload image %dx%dx%d pixels %p\n",
148 __func__, texImage->Width, texImage->Height, texImage->Depth,
149 pixels);
150
151 _mesa_store_teximage(ctx, dims, texImage,
152 format, type, pixels, unpack);
153 }
154
155
156 static void
157 intel_set_texture_image_mt(struct brw_context *brw,
158 struct gl_texture_image *image,
159 GLenum internal_format,
160 struct intel_mipmap_tree *mt)
161
162 {
163 struct gl_texture_object *texobj = image->TexObject;
164 struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
165 struct intel_texture_image *intel_image = intel_texture_image(image);
166
167 _mesa_init_teximage_fields(&brw->ctx, image,
168 mt->logical_width0, mt->logical_height0, 1,
169 0, internal_format, mt->format);
170
171 brw->ctx.Driver.FreeTextureImageBuffer(&brw->ctx, image);
172
173 intel_texobj->needs_validate = true;
174 intel_image->base.RowStride = mt->pitch / mt->cpp;
175 assert(mt->pitch % mt->cpp == 0);
176
177 intel_miptree_reference(&intel_image->mt, mt);
178
179 /* Immediately validate the image to the object. */
180 intel_miptree_reference(&intel_texobj->mt, mt);
181 }
182
183 static struct intel_mipmap_tree *
184 create_mt_for_planar_dri_image(struct brw_context *brw,
185 GLenum target, __DRIimage *image)
186 {
187 struct intel_image_format *f = image->planar_format;
188 struct intel_mipmap_tree *planar_mt;
189
190 for (int i = 0; i < f->nplanes; i++) {
191 const int index = f->planes[i].buffer_index;
192 const uint32_t dri_format = f->planes[i].dri_format;
193 const mesa_format format = driImageFormatToGLFormat(dri_format);
194 const uint32_t width = image->width >> f->planes[i].width_shift;
195 const uint32_t height = image->height >> f->planes[i].height_shift;
196
197 /* Disable creation of the texture's aux buffers because the driver
198 * exposes no EGL API to manage them. That is, there is no API for
199 * resolving the aux buffer's content to the main buffer nor for
200 * invalidating the aux buffer's content.
201 */
202 struct intel_mipmap_tree *mt =
203 intel_miptree_create_for_bo(brw, image->bo, format,
204 image->offsets[index],
205 width, height, 1,
206 image->strides[index],
207 MIPTREE_LAYOUT_DISABLE_AUX);
208 if (mt == NULL)
209 return NULL;
210
211 mt->target = target;
212 mt->total_width = width;
213 mt->total_height = height;
214
215 if (i == 0)
216 planar_mt = mt;
217 else
218 planar_mt->plane[i - 1] = mt;
219 }
220
221 return planar_mt;
222 }
223
224 /**
225 * Binds a BO to a texture image, as if it was uploaded by glTexImage2D().
226 *
227 * Used for GLX_EXT_texture_from_pixmap and EGL image extensions,
228 */
229 static struct intel_mipmap_tree *
230 create_mt_for_dri_image(struct brw_context *brw,
231 GLenum target, __DRIimage *image)
232 {
233 struct intel_mipmap_tree *mt;
234 uint32_t draw_x, draw_y;
235
236 /* Disable creation of the texture's aux buffers because the driver exposes
237 * no EGL API to manage them. That is, there is no API for resolving the aux
238 * buffer's content to the main buffer nor for invalidating the aux buffer's
239 * content.
240 */
241 mt = intel_miptree_create_for_bo(brw, image->bo, image->format,
242 0, image->width, image->height, 1,
243 image->pitch,
244 MIPTREE_LAYOUT_DISABLE_AUX);
245 if (mt == NULL)
246 return NULL;
247
248 mt->target = target;
249 mt->total_width = image->width;
250 mt->total_height = image->height;
251 mt->level[0].slice[0].x_offset = image->tile_x;
252 mt->level[0].slice[0].y_offset = image->tile_y;
253
254 intel_miptree_get_tile_offsets(mt, 0, 0, &draw_x, &draw_y);
255
256 /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION
257 * for EGL images from non-tile aligned sufaces in gen4 hw and earlier which has
258 * trouble resolving back to destination image due to alignment issues.
259 */
260 if (!brw->has_surface_tile_offset &&
261 (draw_x != 0 || draw_y != 0)) {
262 _mesa_error(&brw->ctx, GL_INVALID_OPERATION, __func__);
263 intel_miptree_release(&mt);
264 return NULL;
265 }
266
267 mt->offset = image->offset;
268
269 return mt;
270 }
271
272 void
273 intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
274 GLint texture_format,
275 __DRIdrawable *dPriv)
276 {
277 struct gl_framebuffer *fb = dPriv->driverPrivate;
278 struct brw_context *brw = pDRICtx->driverPrivate;
279 struct gl_context *ctx = &brw->ctx;
280 struct intel_renderbuffer *rb;
281 struct gl_texture_object *texObj;
282 struct gl_texture_image *texImage;
283 mesa_format texFormat = MESA_FORMAT_NONE;
284 struct intel_mipmap_tree *mt;
285 GLenum internal_format = 0;
286
287 texObj = _mesa_get_current_tex_object(ctx, target);
288
289 if (!texObj)
290 return;
291
292 if (dPriv->lastStamp != dPriv->dri2.stamp ||
293 !pDRICtx->driScreenPriv->dri2.useInvalidate)
294 intel_update_renderbuffers(pDRICtx, dPriv);
295
296 rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
297 /* If the miptree isn't set, then intel_update_renderbuffers was unable
298 * to get the BO for the drawable from the window system.
299 */
300 if (!rb || !rb->mt)
301 return;
302
303 if (rb->mt->cpp == 4) {
304 if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
305 internal_format = GL_RGB;
306 texFormat = MESA_FORMAT_B8G8R8X8_UNORM;
307 }
308 else {
309 internal_format = GL_RGBA;
310 texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
311 }
312 } else if (rb->mt->cpp == 2) {
313 internal_format = GL_RGB;
314 texFormat = MESA_FORMAT_B5G6R5_UNORM;
315 }
316
317 intel_miptree_make_shareable(brw, rb->mt);
318 mt = intel_miptree_create_for_bo(brw, rb->mt->bo, texFormat, 0,
319 rb->Base.Base.Width,
320 rb->Base.Base.Height,
321 1, rb->mt->pitch, 0);
322 if (mt == NULL)
323 return;
324 mt->target = target;
325 mt->total_width = rb->Base.Base.Width;
326 mt->total_height = rb->Base.Base.Height;
327
328 _mesa_lock_texture(&brw->ctx, texObj);
329 texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
330 intel_set_texture_image_mt(brw, texImage, internal_format, mt);
331 intel_miptree_release(&mt);
332 _mesa_unlock_texture(&brw->ctx, texObj);
333 }
334
335 static GLboolean
336 intel_bind_renderbuffer_tex_image(struct gl_context *ctx,
337 struct gl_renderbuffer *rb,
338 struct gl_texture_image *image)
339 {
340 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
341 struct intel_texture_image *intel_image = intel_texture_image(image);
342 struct gl_texture_object *texobj = image->TexObject;
343 struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
344
345 /* We can only handle RB allocated with AllocRenderbufferStorage, or
346 * window-system renderbuffers.
347 */
348 assert(!rb->TexImage);
349
350 if (!irb->mt)
351 return false;
352
353 _mesa_lock_texture(ctx, texobj);
354 _mesa_init_teximage_fields(ctx, image,
355 rb->Width, rb->Height, 1,
356 0, rb->InternalFormat, rb->Format);
357 image->NumSamples = rb->NumSamples;
358
359 intel_miptree_reference(&intel_image->mt, irb->mt);
360
361 /* Immediately validate the image to the object. */
362 intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
363
364 intel_texobj->needs_validate = true;
365 _mesa_unlock_texture(ctx, texobj);
366
367 return true;
368 }
369
370 void
371 intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
372 {
373 /* The old interface didn't have the format argument, so copy our
374 * implementation's behavior at the time.
375 */
376 intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
377 }
378
379 static void
380 intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
381 struct gl_texture_object *texObj,
382 struct gl_texture_image *texImage,
383 GLeglImageOES image_handle)
384 {
385 struct brw_context *brw = brw_context(ctx);
386 struct intel_mipmap_tree *mt;
387 __DRIscreen *dri_screen = brw->screen->driScrnPriv;
388 __DRIimage *image;
389
390 image = dri_screen->dri2.image->lookupEGLImage(dri_screen, image_handle,
391 dri_screen->loaderPrivate);
392 if (image == NULL)
393 return;
394
395 /* We support external textures only for EGLImages created with
396 * EGL_EXT_image_dma_buf_import. We may lift that restriction in the future.
397 */
398 if (target == GL_TEXTURE_EXTERNAL_OES && !image->dma_buf_imported) {
399 _mesa_error(ctx, GL_INVALID_OPERATION,
400 "glEGLImageTargetTexture2DOES(external target is enabled only "
401 "for images created with EGL_EXT_image_dma_buf_import");
402 return;
403 }
404
405 /* Disallow depth/stencil textures: we don't have a way to pass the
406 * separate stencil miptree of a GL_DEPTH_STENCIL texture through.
407 */
408 if (image->has_depthstencil) {
409 _mesa_error(ctx, GL_INVALID_OPERATION, __func__);
410 return;
411 }
412
413 if (image->planar_format && image->planar_format->nplanes > 0)
414 mt = create_mt_for_planar_dri_image(brw, target, image);
415 else
416 mt = create_mt_for_dri_image(brw, target, image);
417 if (mt == NULL)
418 return;
419
420 struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
421 intel_texobj->planar_format = image->planar_format;
422
423 const GLenum internal_format =
424 image->internal_format != 0 ?
425 image->internal_format : _mesa_get_format_base_format(mt->format);
426 intel_set_texture_image_mt(brw, texImage, internal_format, mt);
427 intel_miptree_release(&mt);
428 }
429
430 /**
431 * \brief A fast path for glGetTexImage.
432 *
433 * \see intel_readpixels_tiled_memcpy()
434 */
435 bool
436 intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx,
437 struct gl_texture_image *texImage,
438 GLint xoffset, GLint yoffset,
439 GLsizei width, GLsizei height,
440 GLenum format, GLenum type,
441 GLvoid *pixels,
442 const struct gl_pixelstore_attrib *packing)
443 {
444 struct brw_context *brw = brw_context(ctx);
445 struct intel_texture_image *image = intel_texture_image(texImage);
446 int dst_pitch;
447
448 /* The miptree's buffer. */
449 drm_intel_bo *bo;
450
451 int error = 0;
452
453 uint32_t cpp;
454 mem_copy_fn mem_copy = NULL;
455
456 /* This fastpath is restricted to specific texture types:
457 * a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support
458 * more types.
459 *
460 * FINISHME: The restrictions below on packing alignment and packing row
461 * length are likely unneeded now because we calculate the destination stride
462 * with _mesa_image_row_stride. However, before removing the restrictions
463 * we need tests.
464 */
465 if (!brw->has_llc ||
466 !(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) ||
467 !(texImage->TexObject->Target == GL_TEXTURE_2D ||
468 texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
469 pixels == NULL ||
470 _mesa_is_bufferobj(packing->BufferObj) ||
471 packing->Alignment > 4 ||
472 packing->SkipPixels > 0 ||
473 packing->SkipRows > 0 ||
474 (packing->RowLength != 0 && packing->RowLength != width) ||
475 packing->SwapBytes ||
476 packing->LsbFirst ||
477 packing->Invert)
478 return false;
479
480 /* We can't handle copying from RGBX or BGRX because the tiled_memcpy
481 * function doesn't set the last channel to 1. Note this checks BaseFormat
482 * rather than TexFormat in case the RGBX format is being simulated with an
483 * RGBA format.
484 */
485 if (texImage->_BaseFormat == GL_RGB)
486 return false;
487
488 if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp))
489 return false;
490
491 /* If this is a nontrivial texture view, let another path handle it instead. */
492 if (texImage->TexObject->MinLayer)
493 return false;
494
495 if (!image->mt ||
496 (image->mt->tiling != I915_TILING_X &&
497 image->mt->tiling != I915_TILING_Y)) {
498 /* The algorithm is written only for X- or Y-tiled memory. */
499 return false;
500 }
501
502 /* Since we are going to write raw data to the miptree, we need to resolve
503 * any pending fast color clears before we start.
504 */
505 intel_miptree_resolve_color(brw, image->mt, 0);
506
507 bo = image->mt->bo;
508
509 if (drm_intel_bo_references(brw->batch.bo, bo)) {
510 perf_debug("Flushing before mapping a referenced bo.\n");
511 intel_batchbuffer_flush(brw);
512 }
513
514 error = brw_bo_map(brw, bo, false /* write enable */, "miptree");
515 if (error) {
516 DBG("%s: failed to map bo\n", __func__);
517 return false;
518 }
519
520 dst_pitch = _mesa_image_row_stride(packing, width, format, type);
521
522 DBG("%s: level=%d x,y=(%d,%d) (w,h)=(%d,%d) format=0x%x type=0x%x "
523 "mesa_format=0x%x tiling=%d "
524 "packing=(alignment=%d row_length=%d skip_pixels=%d skip_rows=%d)\n",
525 __func__, texImage->Level, xoffset, yoffset, width, height,
526 format, type, texImage->TexFormat, image->mt->tiling,
527 packing->Alignment, packing->RowLength, packing->SkipPixels,
528 packing->SkipRows);
529
530 int level = texImage->Level + texImage->TexObject->MinLevel;
531
532 /* Adjust x and y offset based on miplevel */
533 xoffset += image->mt->level[level].level_x;
534 yoffset += image->mt->level[level].level_y;
535
536 tiled_to_linear(
537 xoffset * cpp, (xoffset + width) * cpp,
538 yoffset, yoffset + height,
539 pixels - (ptrdiff_t) yoffset * dst_pitch - (ptrdiff_t) xoffset * cpp,
540 bo->virtual,
541 dst_pitch, image->mt->pitch,
542 brw->has_swizzling,
543 image->mt->tiling,
544 mem_copy
545 );
546
547 drm_intel_bo_unmap(bo);
548 return true;
549 }
550
551 static void
552 intel_get_tex_sub_image(struct gl_context *ctx,
553 GLint xoffset, GLint yoffset, GLint zoffset,
554 GLsizei width, GLsizei height, GLint depth,
555 GLenum format, GLenum type, GLvoid *pixels,
556 struct gl_texture_image *texImage)
557 {
558 struct brw_context *brw = brw_context(ctx);
559 bool ok;
560
561 DBG("%s\n", __func__);
562
563 if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
564 if (_mesa_meta_pbo_GetTexSubImage(ctx, 3, texImage,
565 xoffset, yoffset, zoffset,
566 width, height, depth, format, type,
567 pixels, &ctx->Pack)) {
568 /* Flush to guarantee coherency between the render cache and other
569 * caches the PBO could potentially be bound to after this point.
570 * See the related comment in intelReadPixels() for a more detailed
571 * explanation.
572 */
573 brw_emit_mi_flush(brw);
574 return;
575 }
576
577 perf_debug("%s: fallback to CPU mapping in PBO case\n", __func__);
578 }
579
580 ok = intel_gettexsubimage_tiled_memcpy(ctx, texImage, xoffset, yoffset,
581 width, height,
582 format, type, pixels, &ctx->Pack);
583
584 if(ok)
585 return;
586
587 _mesa_meta_GetTexSubImage(ctx, xoffset, yoffset, zoffset,
588 width, height, depth,
589 format, type, pixels, texImage);
590
591 DBG("%s - DONE\n", __func__);
592 }
593
594 static void
595 flush_astc_denorms(struct gl_context *ctx, GLuint dims,
596 struct gl_texture_image *texImage,
597 GLint xoffset, GLint yoffset, GLint zoffset,
598 GLsizei width, GLsizei height, GLsizei depth)
599 {
600 struct compressed_pixelstore store;
601 _mesa_compute_compressed_pixelstore(dims, texImage->TexFormat,
602 width, height, depth,
603 &ctx->Unpack, &store);
604
605 for (int slice = 0; slice < store.CopySlices; slice++) {
606
607 /* Map dest texture buffer */
608 GLubyte *dstMap;
609 GLint dstRowStride;
610 ctx->Driver.MapTextureImage(ctx, texImage, slice + zoffset,
611 xoffset, yoffset, width, height,
612 GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
613 &dstMap, &dstRowStride);
614 if (!dstMap)
615 continue;
616
617 for (int i = 0; i < store.CopyRowsPerSlice; i++) {
618
619 /* An ASTC block is stored in little endian mode. The byte that
620 * contains bits 0..7 is stored at the lower address in memory.
621 */
622 struct astc_void_extent {
623 uint16_t header : 12;
624 uint16_t dontcare[3];
625 uint16_t R;
626 uint16_t G;
627 uint16_t B;
628 uint16_t A;
629 } *blocks = (struct astc_void_extent*) dstMap;
630
631 /* Iterate over every copied block in the row */
632 for (int j = 0; j < store.CopyBytesPerRow / 16; j++) {
633
634 /* Check if the header matches that of an LDR void-extent block */
635 if (blocks[j].header == 0xDFC) {
636
637 /* Flush UNORM16 values that would be denormalized */
638 if (blocks[j].A < 4) blocks[j].A = 0;
639 if (blocks[j].B < 4) blocks[j].B = 0;
640 if (blocks[j].G < 4) blocks[j].G = 0;
641 if (blocks[j].R < 4) blocks[j].R = 0;
642 }
643 }
644
645 dstMap += dstRowStride;
646 }
647
648 ctx->Driver.UnmapTextureImage(ctx, texImage, slice + zoffset);
649 }
650 }
651
652
653 static void
654 intelCompressedTexSubImage(struct gl_context *ctx, GLuint dims,
655 struct gl_texture_image *texImage,
656 GLint xoffset, GLint yoffset, GLint zoffset,
657 GLsizei width, GLsizei height, GLsizei depth,
658 GLenum format,
659 GLsizei imageSize, const GLvoid *data)
660 {
661 /* Upload the compressed data blocks */
662 _mesa_store_compressed_texsubimage(ctx, dims, texImage,
663 xoffset, yoffset, zoffset,
664 width, height, depth,
665 format, imageSize, data);
666
667 /* Fix up copied ASTC blocks if necessary */
668 GLenum gl_format = _mesa_compressed_format_to_glenum(ctx,
669 texImage->TexFormat);
670 bool is_linear_astc = _mesa_is_astc_format(gl_format) &&
671 !_mesa_is_srgb_format(gl_format);
672 struct brw_context *brw = (struct brw_context*) ctx;
673 if (brw->gen == 9 && is_linear_astc)
674 flush_astc_denorms(ctx, dims, texImage,
675 xoffset, yoffset, zoffset,
676 width, height, depth);
677 }
678
679 void
680 intelInitTextureImageFuncs(struct dd_function_table *functions)
681 {
682 functions->TexImage = intelTexImage;
683 functions->CompressedTexSubImage = intelCompressedTexSubImage;
684 functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
685 functions->BindRenderbufferTexImage = intel_bind_renderbuffer_tex_image;
686 functions->GetTexSubImage = intel_get_tex_sub_image;
687 }