1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include <stdio.h>
29
30 #include "st_context.h"
31 #include "st_format.h"
32 #include "st_texture.h"
33 #include "main/enums.h"
34
35 #include "pipe/p_state.h"
36 #include "pipe/p_context.h"
37 #include "pipe/p_defines.h"
38 #include "util/u_inlines.h"
39 #include "util/format/u_format.h"
40 #include "util/u_rect.h"
41 #include "util/u_math.h"
42 #include "util/u_memory.h"
43 #include "tgsi/tgsi_from_mesa.h"
44
45
46 #define DBG if(0) printf
47
48
49 /**
50 * Allocate a new pipe_resource object
51 * width0, height0, depth0 are the dimensions of the level 0 image
52 * (the highest resolution). last_level indicates how many mipmap levels
53 * to allocate storage for. For non-mipmapped textures, this will be zero.
54 */
55 struct pipe_resource *
st_texture_create(struct st_context * st,enum pipe_texture_target target,enum pipe_format format,GLuint last_level,GLuint width0,GLuint height0,GLuint depth0,GLuint layers,GLuint nr_samples,GLuint bind,bool sparse)56 st_texture_create(struct st_context *st,
57 enum pipe_texture_target target,
58 enum pipe_format format,
59 GLuint last_level,
60 GLuint width0,
61 GLuint height0,
62 GLuint depth0,
63 GLuint layers,
64 GLuint nr_samples,
65 GLuint bind,
66 bool sparse)
67 {
68 struct pipe_resource pt, *newtex;
69 struct pipe_screen *screen = st->screen;
70
71 assert(target < PIPE_MAX_TEXTURE_TYPES);
72 assert(width0 > 0);
73 assert(height0 > 0);
74 assert(depth0 > 0);
75 if (target == PIPE_TEXTURE_CUBE)
76 assert(layers == 6);
77
78 DBG("%s target %d format %s last_level %d\n", __func__,
79 (int) target, util_format_name(format), last_level);
80
81 assert(format);
82 assert(screen->is_format_supported(screen, format, target, 0, 0,
83 PIPE_BIND_SAMPLER_VIEW));
84
85 memset(&pt, 0, sizeof(pt));
86 pt.target = target;
87 pt.format = format;
88 pt.last_level = last_level;
89 pt.width0 = width0;
90 pt.height0 = height0;
91 pt.depth0 = depth0;
92 pt.array_size = layers;
93 pt.usage = PIPE_USAGE_DEFAULT;
94 pt.bind = bind;
95 /* only set this for OpenGL textures, not renderbuffers */
96 pt.flags = PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY;
97 pt.nr_samples = nr_samples;
98 pt.nr_storage_samples = nr_samples;
99
100 if (sparse)
101 pt.flags |= PIPE_RESOURCE_FLAG_SPARSE;
102
103 newtex = screen->resource_create(screen, &pt);
104
105 assert(!newtex || pipe_is_referenced(&newtex->reference));
106
107 return newtex;
108 }
109
110
111 /**
112 * In OpenGL the number of 1D array texture layers is the "height" and
113 * the number of 2D array texture layers is the "depth". In Gallium the
114 * number of layers in an array texture is a separate 'array_size' field.
115 * This function converts dimensions from the former to the later.
116 */
117 void
st_gl_texture_dims_to_pipe_dims(GLenum texture,unsigned widthIn,uint16_t heightIn,uint16_t depthIn,unsigned * widthOut,uint16_t * heightOut,uint16_t * depthOut,uint16_t * layersOut)118 st_gl_texture_dims_to_pipe_dims(GLenum texture,
119 unsigned widthIn,
120 uint16_t heightIn,
121 uint16_t depthIn,
122 unsigned *widthOut,
123 uint16_t *heightOut,
124 uint16_t *depthOut,
125 uint16_t *layersOut)
126 {
127 switch (texture) {
128 case GL_TEXTURE_1D:
129 case GL_PROXY_TEXTURE_1D:
130 assert(heightIn == 1);
131 assert(depthIn == 1);
132 *widthOut = widthIn;
133 *heightOut = 1;
134 *depthOut = 1;
135 *layersOut = 1;
136 break;
137 case GL_TEXTURE_1D_ARRAY:
138 case GL_PROXY_TEXTURE_1D_ARRAY:
139 assert(depthIn == 1);
140 *widthOut = widthIn;
141 *heightOut = 1;
142 *depthOut = 1;
143 *layersOut = heightIn;
144 break;
145 case GL_TEXTURE_2D:
146 case GL_PROXY_TEXTURE_2D:
147 case GL_TEXTURE_RECTANGLE:
148 case GL_PROXY_TEXTURE_RECTANGLE:
149 case GL_TEXTURE_EXTERNAL_OES:
150 case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
151 case GL_TEXTURE_2D_MULTISAMPLE:
152 assert(depthIn == 1);
153 *widthOut = widthIn;
154 *heightOut = heightIn;
155 *depthOut = 1;
156 *layersOut = 1;
157 break;
158 case GL_TEXTURE_CUBE_MAP:
159 case GL_PROXY_TEXTURE_CUBE_MAP:
160 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
161 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
162 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
163 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
164 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
165 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
166 assert(depthIn == 1);
167 *widthOut = widthIn;
168 *heightOut = heightIn;
169 *depthOut = 1;
170 *layersOut = 6;
171 break;
172 case GL_TEXTURE_2D_ARRAY:
173 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
174 case GL_PROXY_TEXTURE_2D_ARRAY:
175 case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
176 *widthOut = widthIn;
177 *heightOut = heightIn;
178 *depthOut = 1;
179 *layersOut = depthIn;
180 break;
181 case GL_TEXTURE_CUBE_MAP_ARRAY:
182 case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
183 *widthOut = widthIn;
184 *heightOut = heightIn;
185 *depthOut = 1;
186 *layersOut = util_align_npot(depthIn, 6);
187 break;
188 default:
189 unreachable("Unexpected texture in st_gl_texture_dims_to_pipe_dims()");
190 case GL_TEXTURE_3D:
191 case GL_PROXY_TEXTURE_3D:
192 *widthOut = widthIn;
193 *heightOut = heightIn;
194 *depthOut = depthIn;
195 *layersOut = 1;
196 break;
197 }
198 }
199
200
201 /**
202 * Check if a texture image can be pulled into a unified mipmap texture.
203 */
204 GLboolean
st_texture_match_image(struct st_context * st,const struct pipe_resource * pt,const struct gl_texture_image * image)205 st_texture_match_image(struct st_context *st,
206 const struct pipe_resource *pt,
207 const struct gl_texture_image *image)
208 {
209 unsigned ptWidth;
210 uint16_t ptHeight, ptDepth, ptLayers;
211
212 /* Images with borders are never pulled into mipmap textures.
213 */
214 if (image->Border)
215 return GL_FALSE;
216
217 /* Check if this image's format matches the established texture's format.
218 */
219 if (st_mesa_format_to_pipe_format(st, image->TexFormat) != pt->format)
220 return GL_FALSE;
221
222 st_gl_texture_dims_to_pipe_dims(image->TexObject->Target,
223 image->Width, image->Height, image->Depth,
224 &ptWidth, &ptHeight, &ptDepth, &ptLayers);
225
226 /* Test if this image's size matches what's expected in the
227 * established texture.
228 */
229 if (ptWidth != u_minify(pt->width0, image->Level) ||
230 ptHeight != u_minify(pt->height0, image->Level) ||
231 ptDepth != u_minify(pt->depth0, image->Level) ||
232 ptLayers != pt->array_size)
233 return GL_FALSE;
234
235 if (image->Level > pt->last_level)
236 return GL_FALSE;
237
238 return GL_TRUE;
239 }
240
241 void
st_texture_image_insert_transfer(struct gl_texture_image * stImage,unsigned index,struct pipe_transfer * transfer)242 st_texture_image_insert_transfer(struct gl_texture_image *stImage,
243 unsigned index,
244 struct pipe_transfer *transfer)
245 {
246 /* Enlarge the transfer array if it's not large enough. */
247 if (index >= stImage->num_transfers) {
248 unsigned new_size = index + 1;
249
250 stImage->transfer = realloc(stImage->transfer,
251 new_size * sizeof(struct st_texture_image_transfer));
252 memset(&stImage->transfer[stImage->num_transfers], 0,
253 (new_size - stImage->num_transfers) *
254 sizeof(struct st_texture_image_transfer));
255 stImage->num_transfers = new_size;
256 }
257
258 assert(!stImage->transfer[index].transfer);
259 stImage->transfer[index].transfer = transfer;
260 }
261
262 /* See st_texture.h for more information. */
263 GLuint
st_texture_image_resource_level(struct gl_texture_image * stImage)264 st_texture_image_resource_level(struct gl_texture_image *stImage)
265 {
266 /* An image for a non-finalized texture object only has a single level. */
267 if (stImage->pt != stImage->TexObject->pt)
268 return 0;
269
270 /* An immutable texture object may have views with an LOD offset. */
271 if (stImage->TexObject->Immutable)
272 return stImage->Level + stImage->TexObject->Attrib.MinLevel;
273
274 return stImage->Level;
275 }
276
277 /**
278 * Map a texture image and return the address for a particular 2D face/slice/
279 * layer. The stImage indicates the cube face and mipmap level. The slice
280 * of the 3D texture is passed in 'zoffset'.
281 * \param usage one of the PIPE_MAP_x values
282 * \param x, y, w, h the region of interest of the 2D image.
283 * \return address of mapping or NULL if any error
284 */
285 GLubyte *
st_texture_image_map(struct st_context * st,struct gl_texture_image * stImage,enum pipe_map_flags usage,GLuint x,GLuint y,GLuint z,GLuint w,GLuint h,GLuint d,struct pipe_transfer ** transfer)286 st_texture_image_map(struct st_context *st, struct gl_texture_image *stImage,
287 enum pipe_map_flags usage,
288 GLuint x, GLuint y, GLuint z,
289 GLuint w, GLuint h, GLuint d,
290 struct pipe_transfer **transfer)
291 {
292 struct gl_texture_object *stObj = stImage->TexObject;
293 GLuint level;
294 void *map;
295
296 DBG("%s \n", __func__);
297
298 if (!stImage->pt)
299 return NULL;
300
301 if (stObj->pt != stImage->pt)
302 level = 0;
303 else
304 level = stImage->Level;
305
306 if (stObj->Immutable) {
307 level += stObj->Attrib.MinLevel;
308 z += stObj->Attrib.MinLayer;
309 if (stObj->pt->array_size > 1)
310 d = MIN2(d, stObj->Attrib.NumLayers);
311 }
312
313 z += stImage->Face;
314
315 map = pipe_texture_map_3d(st->pipe, stImage->pt, level, usage,
316 x, y, z, w, h, d, transfer);
317
318 if (map)
319 st_texture_image_insert_transfer(stImage, z, *transfer);
320
321 return map;
322 }
323
324
325 void
st_texture_image_unmap(struct st_context * st,struct gl_texture_image * stImage,unsigned slice)326 st_texture_image_unmap(struct st_context *st,
327 struct gl_texture_image *stImage, unsigned slice)
328 {
329 struct pipe_context *pipe = st->pipe;
330 struct gl_texture_object *stObj = stImage->TexObject;
331 struct pipe_transfer **transfer;
332
333 if (stObj->Immutable)
334 slice += stObj->Attrib.MinLayer;
335 transfer = &stImage->transfer[slice + stImage->Face].transfer;
336
337 DBG("%s\n", __func__);
338
339 pipe_texture_unmap(pipe, *transfer);
340 *transfer = NULL;
341 }
342
343
344 /**
345 * For debug only: get/print center pixel in the src resource.
346 */
347 static void
print_center_pixel(struct pipe_context * pipe,struct pipe_resource * src)348 print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src)
349 {
350 struct pipe_transfer *xfer;
351 struct pipe_box region;
352 uint8_t *map;
353
354 region.x = src->width0 / 2;
355 region.y = src->height0 / 2;
356 region.z = 0;
357 region.width = 1;
358 region.height = 1;
359 region.depth = 1;
360
361 map = pipe->texture_map(pipe, src, 0, PIPE_MAP_READ, ®ion, &xfer);
362
363 printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]);
364
365 pipe->texture_unmap(pipe, xfer);
366 }
367
368
369 /**
370 * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'.
371 * This is used to copy mipmap images from one texture buffer to another.
372 * This typically happens when our initial guess at the total texture size
373 * is incorrect (see the guess_and_alloc_texture() function).
374 */
375 void
st_texture_image_copy(struct pipe_context * pipe,struct pipe_resource * dst,GLuint dstLevel,struct pipe_resource * src,GLuint srcLevel,GLuint face)376 st_texture_image_copy(struct pipe_context *pipe,
377 struct pipe_resource *dst, GLuint dstLevel,
378 struct pipe_resource *src, GLuint srcLevel,
379 GLuint face)
380 {
381 GLuint width = u_minify(dst->width0, dstLevel);
382 GLuint height = u_minify(dst->height0, dstLevel);
383 GLuint depth = u_minify(dst->depth0, dstLevel);
384 struct pipe_box src_box;
385 GLuint i;
386
387 if (u_minify(src->width0, srcLevel) != width ||
388 u_minify(src->height0, srcLevel) != height ||
389 u_minify(src->depth0, srcLevel) != depth) {
390 /* The source image size doesn't match the destination image size.
391 * This can happen in some degenerate situations such as rendering to a
392 * cube map face which was set up with mismatched texture sizes.
393 */
394 return;
395 }
396
397 src_box.x = 0;
398 src_box.y = 0;
399 src_box.width = width;
400 src_box.height = height;
401 src_box.depth = 1;
402
403 if (src->target == PIPE_TEXTURE_1D_ARRAY ||
404 src->target == PIPE_TEXTURE_2D_ARRAY ||
405 src->target == PIPE_TEXTURE_CUBE_ARRAY) {
406 face = 0;
407 depth = src->array_size;
408 }
409
410 /* Loop over 3D image slices */
411 /* could (and probably should) use "true" 3d box here -
412 but drivers can't quite handle it yet */
413 for (i = face; i < face + depth; i++) {
414 src_box.z = i;
415
416 if (0) {
417 print_center_pixel(pipe, src);
418 }
419
420 pipe->resource_copy_region(pipe,
421 dst,
422 dstLevel,
423 0, 0, i,/* destX, Y, Z */
424 src,
425 srcLevel,
426 &src_box);
427 }
428 }
429
430
431 struct pipe_resource *
st_create_color_map_texture(struct gl_context * ctx)432 st_create_color_map_texture(struct gl_context *ctx)
433 {
434 struct st_context *st = st_context(ctx);
435 struct pipe_resource *pt;
436 enum pipe_format format;
437 const uint texSize = 256; /* simple, and usually perfect */
438
439 /* find an RGBA texture format */
440 format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE,
441 PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW,
442 false, false);
443
444 /* create texture for color map/table */
445 pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
446 texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW, false);
447 return pt;
448 }
449
450
451 /**
452 * Destroy bound texture handles for the given stage.
453 */
454 static void
st_destroy_bound_texture_handles_per_stage(struct st_context * st,enum pipe_shader_type shader)455 st_destroy_bound_texture_handles_per_stage(struct st_context *st,
456 enum pipe_shader_type shader)
457 {
458 struct st_bound_handles *bound_handles = &st->bound_texture_handles[shader];
459 struct pipe_context *pipe = st->pipe;
460 unsigned i;
461
462 if (likely(!bound_handles->num_handles))
463 return;
464
465 for (i = 0; i < bound_handles->num_handles; i++) {
466 uint64_t handle = bound_handles->handles[i];
467
468 pipe->make_texture_handle_resident(pipe, handle, false);
469 pipe->delete_texture_handle(pipe, handle);
470 }
471 free(bound_handles->handles);
472 bound_handles->handles = NULL;
473 bound_handles->num_handles = 0;
474 }
475
476
477 /**
478 * Destroy all bound texture handles in the context.
479 */
480 void
st_destroy_bound_texture_handles(struct st_context * st)481 st_destroy_bound_texture_handles(struct st_context *st)
482 {
483 unsigned i;
484
485 for (i = 0; i < PIPE_SHADER_TYPES; i++) {
486 st_destroy_bound_texture_handles_per_stage(st, i);
487 }
488 }
489
490
491 /**
492 * Destroy bound image handles for the given stage.
493 */
494 static void
st_destroy_bound_image_handles_per_stage(struct st_context * st,enum pipe_shader_type shader)495 st_destroy_bound_image_handles_per_stage(struct st_context *st,
496 enum pipe_shader_type shader)
497 {
498 struct st_bound_handles *bound_handles = &st->bound_image_handles[shader];
499 struct pipe_context *pipe = st->pipe;
500 unsigned i;
501
502 if (likely(!bound_handles->num_handles))
503 return;
504
505 for (i = 0; i < bound_handles->num_handles; i++) {
506 uint64_t handle = bound_handles->handles[i];
507
508 pipe->make_image_handle_resident(pipe, handle, GL_READ_WRITE, false);
509 pipe->delete_image_handle(pipe, handle);
510 }
511 free(bound_handles->handles);
512 bound_handles->handles = NULL;
513 bound_handles->num_handles = 0;
514 }
515
516
517 /**
518 * Destroy all bound image handles in the context.
519 */
520 void
st_destroy_bound_image_handles(struct st_context * st)521 st_destroy_bound_image_handles(struct st_context *st)
522 {
523 unsigned i;
524
525 for (i = 0; i < PIPE_SHADER_TYPES; i++) {
526 st_destroy_bound_image_handles_per_stage(st, i);
527 }
528 }
529
530
531 /**
532 * Create a texture handle from a texture unit.
533 */
534 static GLuint64
st_create_texture_handle_from_unit(struct st_context * st,struct gl_program * prog,GLuint texUnit)535 st_create_texture_handle_from_unit(struct st_context *st,
536 struct gl_program *prog, GLuint texUnit)
537 {
538 struct pipe_context *pipe = st->pipe;
539 struct pipe_sampler_view *view;
540 struct pipe_sampler_state sampler = {0};
541 const bool glsl130 =
542 (prog->shader_program ? prog->shader_program->GLSL_Version : 0) >= 130;
543
544 /* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
545 view = st_update_single_texture(st, texUnit, glsl130, true, false);
546 if (!view)
547 return 0;
548
549 if (view->target != PIPE_BUFFER)
550 st_convert_sampler_from_unit(st, &sampler, texUnit, glsl130);
551
552 assert(st->ctx->Texture.Unit[texUnit]._Current);
553
554 return pipe->create_texture_handle(pipe, view, &sampler);
555 }
556
557
558 /**
559 * Create an image handle from an image unit.
560 */
561 static GLuint64
st_create_image_handle_from_unit(struct st_context * st,struct gl_program * prog,GLuint imgUnit)562 st_create_image_handle_from_unit(struct st_context *st,
563 struct gl_program *prog, GLuint imgUnit)
564 {
565 struct pipe_context *pipe = st->pipe;
566 struct pipe_image_view img;
567
568 st_convert_image_from_unit(st, &img, imgUnit, 0);
569
570 return pipe->create_image_handle(pipe, &img);
571 }
572
573
574 /**
575 * Make all bindless samplers bound to texture units resident in the context.
576 */
577 void
st_make_bound_samplers_resident(struct st_context * st,struct gl_program * prog)578 st_make_bound_samplers_resident(struct st_context *st,
579 struct gl_program *prog)
580 {
581 enum pipe_shader_type shader = pipe_shader_type_from_mesa(prog->info.stage);
582 struct st_bound_handles *bound_handles = &st->bound_texture_handles[shader];
583 struct pipe_context *pipe = st->pipe;
584 GLuint64 handle;
585 int i;
586
587 /* Remove previous bound texture handles for this stage. */
588 st_destroy_bound_texture_handles_per_stage(st, shader);
589
590 if (likely(!prog->sh.HasBoundBindlessSampler))
591 return;
592
593 for (i = 0; i < prog->sh.NumBindlessSamplers; i++) {
594 struct gl_bindless_sampler *sampler = &prog->sh.BindlessSamplers[i];
595
596 if (!sampler->bound)
597 continue;
598
599 /* Request a new texture handle from the driver and make it resident. */
600 handle = st_create_texture_handle_from_unit(st, prog, sampler->unit);
601 if (!handle)
602 continue;
603
604 pipe->make_texture_handle_resident(st->pipe, handle, true);
605
606 /* Overwrite the texture unit value by the resident handle before
607 * uploading the constant buffer.
608 */
609 *(uint64_t *)sampler->data = handle;
610
611 /* Store the handle in the context. */
612 bound_handles->handles = (uint64_t *)
613 realloc(bound_handles->handles,
614 (bound_handles->num_handles + 1) * sizeof(uint64_t));
615 bound_handles->handles[bound_handles->num_handles] = handle;
616 bound_handles->num_handles++;
617 }
618 }
619
620
621 /**
622 * Make all bindless images bound to image units resident in the context.
623 */
624 void
st_make_bound_images_resident(struct st_context * st,struct gl_program * prog)625 st_make_bound_images_resident(struct st_context *st,
626 struct gl_program *prog)
627 {
628 enum pipe_shader_type shader = pipe_shader_type_from_mesa(prog->info.stage);
629 struct st_bound_handles *bound_handles = &st->bound_image_handles[shader];
630 struct pipe_context *pipe = st->pipe;
631 GLuint64 handle;
632 int i;
633
634 /* Remove previous bound image handles for this stage. */
635 st_destroy_bound_image_handles_per_stage(st, shader);
636
637 if (likely(!prog->sh.HasBoundBindlessImage))
638 return;
639
640 for (i = 0; i < prog->sh.NumBindlessImages; i++) {
641 struct gl_bindless_image *image = &prog->sh.BindlessImages[i];
642
643 if (!image->bound)
644 continue;
645
646 /* Request a new image handle from the driver and make it resident. */
647 handle = st_create_image_handle_from_unit(st, prog, image->unit);
648 if (!handle)
649 continue;
650
651 pipe->make_image_handle_resident(st->pipe, handle, GL_READ_WRITE, true);
652
653 /* Overwrite the image unit value by the resident handle before uploading
654 * the constant buffer.
655 */
656 *(uint64_t *)image->data = handle;
657
658 /* Store the handle in the context. */
659 bound_handles->handles = (uint64_t *)
660 realloc(bound_handles->handles,
661 (bound_handles->num_handles + 1) * sizeof(uint64_t));
662 bound_handles->handles[bound_handles->num_handles] = handle;
663 bound_handles->num_handles++;
664 }
665 }
666