i965: remove unused variable at intel_miptree_create_for_teximage
[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 assert(intelImage->base.Base.Level == 0);
54 break;
55 case GL_TEXTURE_3D:
56 depth <<= intelImage->base.Base.Level;
57 /* Fall through */
58 case GL_TEXTURE_2D:
59 case GL_TEXTURE_2D_ARRAY:
60 case GL_TEXTURE_CUBE_MAP:
61 case GL_TEXTURE_CUBE_MAP_ARRAY:
62 height <<= intelImage->base.Base.Level;
63 /* Fall through */
64 case GL_TEXTURE_1D:
65 case GL_TEXTURE_1D_ARRAY:
66 width <<= intelImage->base.Base.Level;
67 break;
68 default:
69 unreachable("Unexpected target");
70 }
71
72 /* Guess a reasonable value for lastLevel. This is probably going
73 * to be wrong fairly often and might mean that we have to look at
74 * resizable buffers, or require that buffers implement lazy
75 * pagetable arrangements.
76 */
77 if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
78 intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
79 intelImage->base.Base.Level == 0 &&
80 !intelObj->base.GenerateMipmap) {
81 lastLevel = 0;
82 } else {
83 lastLevel = _mesa_get_tex_max_num_levels(intelObj->base.Target,
84 width, height, depth) - 1;
85 }
86
87 return intel_miptree_create(brw,
88 intelObj->base.Target,
89 intelImage->base.Base.TexFormat,
90 0,
91 lastLevel,
92 width,
93 height,
94 depth,
95 intelImage->base.Base.NumSamples,
96 layout_flags | MIPTREE_LAYOUT_TILING_ANY);
97 }
98
99 static void
100 intelTexImage(struct gl_context * ctx,
101 GLuint dims,
102 struct gl_texture_image *texImage,
103 GLenum format, GLenum type, const void *pixels,
104 const struct gl_pixelstore_attrib *unpack)
105 {
106 struct intel_texture_image *intelImage = intel_texture_image(texImage);
107 bool ok;
108
109 bool tex_busy = intelImage->mt && drm_intel_bo_busy(intelImage->mt->bo);
110
111 DBG("%s mesa_format %s target %s format %s type %s level %d %dx%dx%d\n",
112 __func__, _mesa_get_format_name(texImage->TexFormat),
113 _mesa_enum_to_string(texImage->TexObject->Target),
114 _mesa_enum_to_string(format), _mesa_enum_to_string(type),
115 texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
116
117 /* Allocate storage for texture data. */
118 if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
119 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
120 return;
121 }
122
123 assert(intelImage->mt);
124
125 if (intelImage->mt->format == MESA_FORMAT_S_UINT8)
126 intelImage->mt->r8stencil_needs_update = true;
127
128 ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage, 0, 0, 0,
129 texImage->Width, texImage->Height,
130 texImage->Depth,
131 format, type, pixels,
132 tex_busy, unpack);
133 if (ok)
134 return;
135
136 ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
137 0, 0, 0, /*x,y,z offsets*/
138 texImage->Width,
139 texImage->Height,
140 texImage->Depth,
141 format, type, pixels, unpack,
142 false /*allocate_storage*/);
143 if (ok)
144 return;
145
146 DBG("%s: upload image %dx%dx%d pixels %p\n",
147 __func__, texImage->Width, texImage->Height, texImage->Depth,
148 pixels);
149
150 _mesa_store_teximage(ctx, dims, texImage,
151 format, type, pixels, unpack);
152 }
153
154
155 static void
156 intel_set_texture_image_mt(struct brw_context *brw,
157 struct gl_texture_image *image,
158 GLenum internal_format,
159 struct intel_mipmap_tree *mt)
160
161 {
162 struct gl_texture_object *texobj = image->TexObject;
163 struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
164 struct intel_texture_image *intel_image = intel_texture_image(image);
165
166 _mesa_init_teximage_fields(&brw->ctx, image,
167 mt->logical_width0, mt->logical_height0, 1,
168 0, internal_format, mt->format);
169
170 brw->ctx.Driver.FreeTextureImageBuffer(&brw->ctx, image);
171
172 intel_texobj->needs_validate = true;
173 intel_image->base.RowStride = mt->pitch / mt->cpp;
174 assert(mt->pitch % mt->cpp == 0);
175
176 intel_miptree_reference(&intel_image->mt, mt);
177
178 /* Immediately validate the image to the object. */
179 intel_miptree_reference(&intel_texobj->mt, mt);
180 }
181
182 static struct intel_mipmap_tree *
183 create_mt_for_planar_dri_image(struct brw_context *brw,
184 GLenum target, __DRIimage *image)
185 {
186 struct intel_image_format *f = image->planar_format;
187 struct intel_mipmap_tree *planar_mt;
188
189 for (int i = 0; i < f->nplanes; i++) {
190 const int index = f->planes[i].buffer_index;
191 const uint32_t dri_format = f->planes[i].dri_format;
192 const mesa_format format = driImageFormatToGLFormat(dri_format);
193 const uint32_t width = image->width >> f->planes[i].width_shift;
194 const uint32_t height = image->height >> f->planes[i].height_shift;
195
196 /* Disable creation of the texture's aux buffers because the driver
197 * exposes no EGL API to manage them. That is, there is no API for
198 * resolving the aux buffer's content to the main buffer nor for
199 * invalidating the aux buffer's content.
200 */
201 struct intel_mipmap_tree *mt =
202 intel_miptree_create_for_bo(brw, image->bo, format,
203 image->offsets[index],
204 width, height, 1,
205 image->strides[index],
206 MIPTREE_LAYOUT_DISABLE_AUX);
207 if (mt == NULL)
208 return NULL;
209
210 mt->target = target;
211 mt->total_width = width;
212 mt->total_height = height;
213
214 if (i == 0)
215 planar_mt = mt;
216 else
217 planar_mt->plane[i - 1] = mt;
218 }
219
220 return planar_mt;
221 }
222
223 /**
224 * Binds a BO to a texture image, as if it was uploaded by glTexImage2D().
225 *
226 * Used for GLX_EXT_texture_from_pixmap and EGL image extensions,
227 */
228 static struct intel_mipmap_tree *
229 create_mt_for_dri_image(struct brw_context *brw,
230 GLenum target, __DRIimage *image)
231 {
232 struct intel_mipmap_tree *mt;
233 uint32_t draw_x, draw_y;
234
235 /* Disable creation of the texture's aux buffers because the driver exposes
236 * no EGL API to manage them. That is, there is no API for resolving the aux
237 * buffer's content to the main buffer nor for invalidating the aux buffer's
238 * content.
239 */
240 mt = intel_miptree_create_for_bo(brw, image->bo, image->format,
241 0, image->width, image->height, 1,
242 image->pitch,
243 MIPTREE_LAYOUT_DISABLE_AUX);
244 if (mt == NULL)
245 return NULL;
246
247 mt->target = target;
248 mt->total_width = image->width;
249 mt->total_height = image->height;
250 mt->level[0].slice[0].x_offset = image->tile_x;
251 mt->level[0].slice[0].y_offset = image->tile_y;
252
253 intel_miptree_get_tile_offsets(mt, 0, 0, &draw_x, &draw_y);
254
255 /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION
256 * for EGL images from non-tile aligned sufaces in gen4 hw and earlier which has
257 * trouble resolving back to destination image due to alignment issues.
258 */
259 if (!brw->has_surface_tile_offset &&
260 (draw_x != 0 || draw_y != 0)) {
261 _mesa_error(&brw->ctx, GL_INVALID_OPERATION, __func__);
262 intel_miptree_release(&mt);
263 return NULL;
264 }
265
266 mt->offset = image->offset;
267
268 return mt;
269 }
270
271 void
272 intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
273 GLint texture_format,
274 __DRIdrawable *dPriv)
275 {
276 struct gl_framebuffer *fb = dPriv->driverPrivate;
277 struct brw_context *brw = pDRICtx->driverPrivate;
278 struct gl_context *ctx = &brw->ctx;
279 struct intel_renderbuffer *rb;
280 struct gl_texture_object *texObj;
281 struct gl_texture_image *texImage;
282 mesa_format texFormat = MESA_FORMAT_NONE;
283 struct intel_mipmap_tree *mt;
284 GLenum internal_format = 0;
285
286 texObj = _mesa_get_current_tex_object(ctx, target);
287
288 if (!texObj)
289 return;
290
291 if (dPriv->lastStamp != dPriv->dri2.stamp ||
292 !pDRICtx->driScreenPriv->dri2.useInvalidate)
293 intel_update_renderbuffers(pDRICtx, dPriv);
294
295 rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
296 /* If the miptree isn't set, then intel_update_renderbuffers was unable
297 * to get the BO for the drawable from the window system.
298 */
299 if (!rb || !rb->mt)
300 return;
301
302 if (rb->mt->cpp == 4) {
303 if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
304 internal_format = GL_RGB;
305 texFormat = MESA_FORMAT_B8G8R8X8_UNORM;
306 }
307 else {
308 internal_format = GL_RGBA;
309 texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
310 }
311 } else if (rb->mt->cpp == 2) {
312 internal_format = GL_RGB;
313 texFormat = MESA_FORMAT_B5G6R5_UNORM;
314 }
315
316 intel_miptree_make_shareable(brw, rb->mt);
317 mt = intel_miptree_create_for_bo(brw, rb->mt->bo, texFormat, 0,
318 rb->Base.Base.Width,
319 rb->Base.Base.Height,
320 1, rb->mt->pitch, 0);
321 if (mt == NULL)
322 return;
323 mt->target = target;
324 mt->total_width = rb->Base.Base.Width;
325 mt->total_height = rb->Base.Base.Height;
326
327 _mesa_lock_texture(&brw->ctx, texObj);
328 texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
329 intel_set_texture_image_mt(brw, texImage, internal_format, mt);
330 intel_miptree_release(&mt);
331 _mesa_unlock_texture(&brw->ctx, texObj);
332 }
333
334 static GLboolean
335 intel_bind_renderbuffer_tex_image(struct gl_context *ctx,
336 struct gl_renderbuffer *rb,
337 struct gl_texture_image *image)
338 {
339 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
340 struct intel_texture_image *intel_image = intel_texture_image(image);
341 struct gl_texture_object *texobj = image->TexObject;
342 struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
343
344 /* We can only handle RB allocated with AllocRenderbufferStorage, or
345 * window-system renderbuffers.
346 */
347 assert(!rb->TexImage);
348
349 if (!irb->mt)
350 return false;
351
352 _mesa_lock_texture(ctx, texobj);
353 _mesa_init_teximage_fields(ctx, image,
354 rb->Width, rb->Height, 1,
355 0, rb->InternalFormat, rb->Format);
356 image->NumSamples = rb->NumSamples;
357
358 intel_miptree_reference(&intel_image->mt, irb->mt);
359
360 /* Immediately validate the image to the object. */
361 intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
362
363 intel_texobj->needs_validate = true;
364 _mesa_unlock_texture(ctx, texobj);
365
366 return true;
367 }
368
369 void
370 intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
371 {
372 /* The old interface didn't have the format argument, so copy our
373 * implementation's behavior at the time.
374 */
375 intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
376 }
377
378 static void
379 intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
380 struct gl_texture_object *texObj,
381 struct gl_texture_image *texImage,
382 GLeglImageOES image_handle)
383 {
384 struct brw_context *brw = brw_context(ctx);
385 struct intel_mipmap_tree *mt;
386 __DRIscreen *screen;
387 __DRIimage *image;
388
389 screen = brw->intelScreen->driScrnPriv;
390 image = screen->dri2.image->lookupEGLImage(screen, image_handle,
391 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 }