2 * Copyright 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Francisco Jerez <currojerez@riseup.net>
29 #include "shaderimage.h"
40 * Define endian-invariant aliases for some mesa formats that are
41 * defined in terms of their channel layout from LSB to MSB in a
42 * 32-bit word. The actual byte offsets matter here because the user
43 * is allowed to bit-cast one format into another and get predictable
46 #ifdef MESA_BIG_ENDIAN
47 # define MESA_FORMAT_RGBA_8 MESA_FORMAT_A8B8G8R8_UNORM
48 # define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_A8B8G8R8_SNORM
50 # define MESA_FORMAT_RGBA_8 MESA_FORMAT_R8G8B8A8_UNORM
51 # define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_R8G8B8A8_SNORM
55 _mesa_get_shader_image_format(GLenum format
)
59 return MESA_FORMAT_RGBA_FLOAT32
;
62 return MESA_FORMAT_RGBA_FLOAT16
;
65 return MESA_FORMAT_RG_FLOAT32
;
68 return MESA_FORMAT_RG_FLOAT16
;
70 case GL_R11F_G11F_B10F
:
71 return MESA_FORMAT_R11G11B10_FLOAT
;
74 return MESA_FORMAT_R_FLOAT32
;
77 return MESA_FORMAT_R_FLOAT16
;
80 return MESA_FORMAT_RGBA_UINT32
;
83 return MESA_FORMAT_RGBA_UINT16
;
86 return MESA_FORMAT_R10G10B10A2_UINT
;
89 return MESA_FORMAT_RGBA_UINT8
;
92 return MESA_FORMAT_RG_UINT32
;
95 return MESA_FORMAT_RG_UINT16
;
98 return MESA_FORMAT_RG_UINT8
;
101 return MESA_FORMAT_R_UINT32
;
104 return MESA_FORMAT_R_UINT16
;
107 return MESA_FORMAT_R_UINT8
;
110 return MESA_FORMAT_RGBA_SINT32
;
113 return MESA_FORMAT_RGBA_SINT16
;
116 return MESA_FORMAT_RGBA_SINT8
;
119 return MESA_FORMAT_RG_SINT32
;
122 return MESA_FORMAT_RG_SINT16
;
125 return MESA_FORMAT_RG_SINT8
;
128 return MESA_FORMAT_R_SINT32
;
131 return MESA_FORMAT_R_SINT16
;
134 return MESA_FORMAT_R_SINT8
;
137 return MESA_FORMAT_RGBA_UNORM16
;
140 return MESA_FORMAT_R10G10B10A2_UNORM
;
143 return MESA_FORMAT_RGBA_8
;
146 return MESA_FORMAT_RG_UNORM16
;
149 return MESA_FORMAT_RG_UNORM8
;
152 return MESA_FORMAT_R_UNORM16
;
155 return MESA_FORMAT_R_UNORM8
;
157 case GL_RGBA16_SNORM
:
158 return MESA_FORMAT_RGBA_SNORM16
;
161 return MESA_FORMAT_SIGNED_RGBA_8
;
164 return MESA_FORMAT_RG_SNORM16
;
167 return MESA_FORMAT_RG_SNORM8
;
170 return MESA_FORMAT_R_SNORM16
;
173 return MESA_FORMAT_R_SNORM8
;
176 return MESA_FORMAT_NONE
;
180 enum image_format_class
182 /** Not a valid image format. */
183 IMAGE_FORMAT_CLASS_NONE
= 0,
185 /** Classes of image formats you can cast into each other. */
187 IMAGE_FORMAT_CLASS_1X8
,
188 IMAGE_FORMAT_CLASS_1X16
,
189 IMAGE_FORMAT_CLASS_1X32
,
190 IMAGE_FORMAT_CLASS_2X8
,
191 IMAGE_FORMAT_CLASS_2X16
,
192 IMAGE_FORMAT_CLASS_2X32
,
193 IMAGE_FORMAT_CLASS_10_11_11
,
194 IMAGE_FORMAT_CLASS_4X8
,
195 IMAGE_FORMAT_CLASS_4X16
,
196 IMAGE_FORMAT_CLASS_4X32
,
197 IMAGE_FORMAT_CLASS_2_10_10_10
201 static enum image_format_class
202 get_image_format_class(mesa_format format
)
205 case MESA_FORMAT_RGBA_FLOAT32
:
206 return IMAGE_FORMAT_CLASS_4X32
;
208 case MESA_FORMAT_RGBA_FLOAT16
:
209 return IMAGE_FORMAT_CLASS_4X16
;
211 case MESA_FORMAT_RG_FLOAT32
:
212 return IMAGE_FORMAT_CLASS_2X32
;
214 case MESA_FORMAT_RG_FLOAT16
:
215 return IMAGE_FORMAT_CLASS_2X16
;
217 case MESA_FORMAT_R11G11B10_FLOAT
:
218 return IMAGE_FORMAT_CLASS_10_11_11
;
220 case MESA_FORMAT_R_FLOAT32
:
221 return IMAGE_FORMAT_CLASS_1X32
;
223 case MESA_FORMAT_R_FLOAT16
:
224 return IMAGE_FORMAT_CLASS_1X16
;
226 case MESA_FORMAT_RGBA_UINT32
:
227 return IMAGE_FORMAT_CLASS_4X32
;
229 case MESA_FORMAT_RGBA_UINT16
:
230 return IMAGE_FORMAT_CLASS_4X16
;
232 case MESA_FORMAT_R10G10B10A2_UINT
:
233 return IMAGE_FORMAT_CLASS_2_10_10_10
;
235 case MESA_FORMAT_RGBA_UINT8
:
236 return IMAGE_FORMAT_CLASS_4X8
;
238 case MESA_FORMAT_RG_UINT32
:
239 return IMAGE_FORMAT_CLASS_2X32
;
241 case MESA_FORMAT_RG_UINT16
:
242 return IMAGE_FORMAT_CLASS_2X16
;
244 case MESA_FORMAT_RG_UINT8
:
245 return IMAGE_FORMAT_CLASS_2X8
;
247 case MESA_FORMAT_R_UINT32
:
248 return IMAGE_FORMAT_CLASS_1X32
;
250 case MESA_FORMAT_R_UINT16
:
251 return IMAGE_FORMAT_CLASS_1X16
;
253 case MESA_FORMAT_R_UINT8
:
254 return IMAGE_FORMAT_CLASS_1X8
;
256 case MESA_FORMAT_RGBA_SINT32
:
257 return IMAGE_FORMAT_CLASS_4X32
;
259 case MESA_FORMAT_RGBA_SINT16
:
260 return IMAGE_FORMAT_CLASS_4X16
;
262 case MESA_FORMAT_RGBA_SINT8
:
263 return IMAGE_FORMAT_CLASS_4X8
;
265 case MESA_FORMAT_RG_SINT32
:
266 return IMAGE_FORMAT_CLASS_2X32
;
268 case MESA_FORMAT_RG_SINT16
:
269 return IMAGE_FORMAT_CLASS_2X16
;
271 case MESA_FORMAT_RG_SINT8
:
272 return IMAGE_FORMAT_CLASS_2X8
;
274 case MESA_FORMAT_R_SINT32
:
275 return IMAGE_FORMAT_CLASS_1X32
;
277 case MESA_FORMAT_R_SINT16
:
278 return IMAGE_FORMAT_CLASS_1X16
;
280 case MESA_FORMAT_R_SINT8
:
281 return IMAGE_FORMAT_CLASS_1X8
;
283 case MESA_FORMAT_RGBA_UNORM16
:
284 return IMAGE_FORMAT_CLASS_4X16
;
286 case MESA_FORMAT_R10G10B10A2_UNORM
:
287 return IMAGE_FORMAT_CLASS_2_10_10_10
;
289 case MESA_FORMAT_RGBA_8
:
290 return IMAGE_FORMAT_CLASS_4X8
;
292 case MESA_FORMAT_RG_UNORM16
:
293 return IMAGE_FORMAT_CLASS_2X16
;
295 case MESA_FORMAT_RG_UNORM8
:
296 return IMAGE_FORMAT_CLASS_2X8
;
298 case MESA_FORMAT_R_UNORM16
:
299 return IMAGE_FORMAT_CLASS_1X16
;
301 case MESA_FORMAT_R_UNORM8
:
302 return IMAGE_FORMAT_CLASS_1X8
;
304 case MESA_FORMAT_RGBA_SNORM16
:
305 return IMAGE_FORMAT_CLASS_4X16
;
307 case MESA_FORMAT_SIGNED_RGBA_8
:
308 return IMAGE_FORMAT_CLASS_4X8
;
310 case MESA_FORMAT_RG_SNORM16
:
311 return IMAGE_FORMAT_CLASS_2X16
;
313 case MESA_FORMAT_RG_SNORM8
:
314 return IMAGE_FORMAT_CLASS_2X8
;
316 case MESA_FORMAT_R_SNORM16
:
317 return IMAGE_FORMAT_CLASS_1X16
;
319 case MESA_FORMAT_R_SNORM8
:
320 return IMAGE_FORMAT_CLASS_1X8
;
323 return IMAGE_FORMAT_CLASS_NONE
;
328 _image_format_class_to_glenum(enum image_format_class
class)
331 case IMAGE_FORMAT_CLASS_NONE
:
333 case IMAGE_FORMAT_CLASS_1X8
:
334 return GL_IMAGE_CLASS_1_X_8
;
335 case IMAGE_FORMAT_CLASS_1X16
:
336 return GL_IMAGE_CLASS_1_X_16
;
337 case IMAGE_FORMAT_CLASS_1X32
:
338 return GL_IMAGE_CLASS_1_X_32
;
339 case IMAGE_FORMAT_CLASS_2X8
:
340 return GL_IMAGE_CLASS_2_X_8
;
341 case IMAGE_FORMAT_CLASS_2X16
:
342 return GL_IMAGE_CLASS_2_X_16
;
343 case IMAGE_FORMAT_CLASS_2X32
:
344 return GL_IMAGE_CLASS_2_X_32
;
345 case IMAGE_FORMAT_CLASS_10_11_11
:
346 return GL_IMAGE_CLASS_11_11_10
;
347 case IMAGE_FORMAT_CLASS_4X8
:
348 return GL_IMAGE_CLASS_4_X_8
;
349 case IMAGE_FORMAT_CLASS_4X16
:
350 return GL_IMAGE_CLASS_4_X_16
;
351 case IMAGE_FORMAT_CLASS_4X32
:
352 return GL_IMAGE_CLASS_4_X_32
;
353 case IMAGE_FORMAT_CLASS_2_10_10_10
:
354 return GL_IMAGE_CLASS_10_10_10_2
;
356 assert(!"Invalid image_format_class");
362 _mesa_get_image_format_class(GLenum format
)
364 mesa_format tex_format
= _mesa_get_shader_image_format(format
);
365 if (tex_format
== MESA_FORMAT_NONE
)
368 enum image_format_class
class = get_image_format_class(tex_format
);
369 return _image_format_class_to_glenum(class);
373 _mesa_is_shader_image_format_supported(const struct gl_context
*ctx
,
377 /* Formats supported on both desktop and ES GL, c.f. table 8.27 of the
378 * OpenGL ES 3.1 specification.
395 /* Formats supported on unextended desktop GL and the original
396 * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2
397 * specification or by GLES 3.1 with GL_NV_image_formats extension.
401 case GL_R11F_G11F_B10F
:
421 /* Formats supported on unextended desktop GL and the original
422 * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2
425 * Following formats are supported by GLES 3.1 with GL_NV_image_formats &
426 * GL_EXT_texture_norm16 extensions.
429 case GL_RGBA16_SNORM
:
434 return _mesa_is_desktop_gl(ctx
) || _mesa_has_EXT_texture_norm16(ctx
);
442 _mesa_default_image_unit(struct gl_context
*ctx
)
444 const GLenum format
= _mesa_is_desktop_gl(ctx
) ? GL_R8
: GL_R32UI
;
445 const struct gl_image_unit u
= {
446 .Access
= GL_READ_ONLY
,
448 ._ActualFormat
= _mesa_get_shader_image_format(format
)
454 _mesa_init_image_units(struct gl_context
*ctx
)
458 ASSERT_BITFIELD_SIZE(struct gl_image_unit
, Format
, MESA_FORMAT_COUNT
);
460 for (i
= 0; i
< ARRAY_SIZE(ctx
->ImageUnits
); ++i
)
461 ctx
->ImageUnits
[i
] = _mesa_default_image_unit(ctx
);
466 _mesa_free_image_textures(struct gl_context
*ctx
)
470 for (i
= 0; i
< ARRAY_SIZE(ctx
->ImageUnits
); ++i
)
471 _mesa_reference_texobj(&ctx
->ImageUnits
[i
].TexObj
, NULL
);
475 _mesa_is_image_unit_valid(struct gl_context
*ctx
, struct gl_image_unit
*u
)
477 struct gl_texture_object
*t
= u
->TexObj
;
478 mesa_format tex_format
;
483 if (!t
->_BaseComplete
&& !t
->_MipmapComplete
)
484 _mesa_test_texobj_completeness(ctx
, t
);
486 if (u
->Level
< t
->BaseLevel
||
487 u
->Level
> t
->_MaxLevel
||
488 (u
->Level
== t
->BaseLevel
&& !t
->_BaseComplete
) ||
489 (u
->Level
!= t
->BaseLevel
&& !t
->_MipmapComplete
))
492 if (_mesa_tex_target_is_layered(t
->Target
) &&
493 u
->_Layer
>= _mesa_get_texture_layers(t
, u
->Level
))
496 if (t
->Target
== GL_TEXTURE_BUFFER
) {
497 tex_format
= _mesa_get_shader_image_format(t
->BufferObjectFormat
);
500 struct gl_texture_image
*img
= (t
->Target
== GL_TEXTURE_CUBE_MAP
?
501 t
->Image
[u
->_Layer
][u
->Level
] :
502 t
->Image
[0][u
->Level
]);
504 if (!img
|| img
->Border
|| img
->NumSamples
> ctx
->Const
.MaxImageSamples
)
507 tex_format
= _mesa_get_shader_image_format(img
->InternalFormat
);
513 switch (t
->ImageFormatCompatibilityType
) {
514 case GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE
:
515 if (_mesa_get_format_bytes(tex_format
) !=
516 _mesa_get_format_bytes(u
->_ActualFormat
))
520 case GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS
:
521 if (get_image_format_class(tex_format
) !=
522 get_image_format_class(u
->_ActualFormat
))
527 assert(!"Unexpected image format compatibility type");
534 validate_bind_image_texture(struct gl_context
*ctx
, GLuint unit
,
535 GLuint texture
, GLint level
, GLint layer
,
536 GLenum access
, GLenum format
, bool check_level_layer
)
538 assert(ctx
->Const
.MaxImageUnits
<= MAX_IMAGE_UNITS
);
540 if (unit
>= ctx
->Const
.MaxImageUnits
) {
541 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(unit)");
545 if (check_level_layer
) {
546 /* EXT_shader_image_load_store doesn't throw an error if level or
550 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(level)");
555 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(layer)");
560 if (access
!= GL_READ_ONLY
&&
561 access
!= GL_WRITE_ONLY
&&
562 access
!= GL_READ_WRITE
) {
563 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(access)");
567 if (!_mesa_is_shader_image_format_supported(ctx
, format
)) {
568 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(format)");
576 set_image_binding(struct gl_image_unit
*u
, struct gl_texture_object
*texObj
,
577 GLint level
, GLboolean layered
, GLint layer
, GLenum access
,
583 u
->_ActualFormat
= _mesa_get_shader_image_format(format
);
585 if (texObj
&& _mesa_tex_target_is_layered(texObj
->Target
)) {
586 u
->Layered
= layered
;
589 u
->Layered
= GL_FALSE
;
592 u
->_Layer
= (u
->Layered
? 0 : u
->Layer
);
594 _mesa_reference_texobj(&u
->TexObj
, texObj
);
598 bind_image_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
599 GLuint unit
, GLint level
, GLboolean layered
, GLint layer
,
600 GLenum access
, GLenum format
)
602 struct gl_image_unit
*u
;
604 u
= &ctx
->ImageUnits
[unit
];
606 FLUSH_VERTICES(ctx
, 0);
607 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewImageUnits
;
609 set_image_binding(u
, texObj
, level
, layered
, layer
, access
, format
);
613 _mesa_BindImageTexture_no_error(GLuint unit
, GLuint texture
, GLint level
,
614 GLboolean layered
, GLint layer
, GLenum access
,
617 struct gl_texture_object
*texObj
= NULL
;
619 GET_CURRENT_CONTEXT(ctx
);
622 texObj
= _mesa_lookup_texture(ctx
, texture
);
624 bind_image_texture(ctx
, texObj
, unit
, level
, layered
, layer
, access
, format
);
628 _mesa_BindImageTexture(GLuint unit
, GLuint texture
, GLint level
,
629 GLboolean layered
, GLint layer
, GLenum access
,
632 struct gl_texture_object
*texObj
= NULL
;
634 GET_CURRENT_CONTEXT(ctx
);
636 if (!validate_bind_image_texture(ctx
, unit
, texture
, level
, layer
, access
,
641 texObj
= _mesa_lookup_texture(ctx
, texture
);
644 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTexture(texture)");
648 /* From section 8.22 "Texture Image Loads and Stores" of the OpenGL ES
651 * "An INVALID_OPERATION error is generated if texture is not the name
652 * of an immutable texture object."
654 * However note that issue 7 of the GL_OES_texture_buffer spec
655 * recognizes that there is no way to create immutable buffer textures,
656 * so those are excluded from this requirement.
658 * Additionally, issue 10 of the OES_EGL_image_external_essl3 spec
659 * states that glBindImageTexture must accept external textures.
661 if (_mesa_is_gles(ctx
) && !texObj
->Immutable
&&
662 texObj
->Target
!= GL_TEXTURE_BUFFER
&&
663 texObj
->Target
!= GL_TEXTURE_EXTERNAL_OES
) {
664 _mesa_error(ctx
, GL_INVALID_OPERATION
,
665 "glBindImageTexture(!immutable)");
670 bind_image_texture(ctx
, texObj
, unit
, level
, layered
, layer
, access
, format
);
674 _mesa_BindImageTextureEXT(GLuint index
, GLuint texture
, GLint level
,
675 GLboolean layered
, GLint layer
, GLenum access
,
678 struct gl_texture_object
*texObj
= NULL
;
680 GET_CURRENT_CONTEXT(ctx
);
682 if (!validate_bind_image_texture(ctx
, index
, texture
, level
, layer
, access
,
687 texObj
= _mesa_lookup_texture(ctx
, texture
);
690 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindImageTextureEXT(texture)");
695 bind_image_texture(ctx
, texObj
, index
, level
, layered
, layer
, access
, format
);
698 static ALWAYS_INLINE
void
699 bind_image_textures(struct gl_context
*ctx
, GLuint first
, GLuint count
,
700 const GLuint
*textures
, bool no_error
)
704 /* Assume that at least one binding will be changed */
705 FLUSH_VERTICES(ctx
, 0);
706 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewImageUnits
;
708 /* Note that the error semantics for multi-bind commands differ from
709 * those of other GL commands.
711 * The Issues section in the ARB_multi_bind spec says:
713 * "(11) Typically, OpenGL specifies that if an error is generated by
714 * a command, that command has no effect. This is somewhat
715 * unfortunate for multi-bind commands, because it would require
716 * a first pass to scan the entire list of bound objects for
717 * errors and then a second pass to actually perform the
718 * bindings. Should we have different error semantics?
720 * RESOLVED: Yes. In this specification, when the parameters for
721 * one of the <count> binding points are invalid, that binding
722 * point is not updated and an error will be generated. However,
723 * other binding points in the same command will be updated if
724 * their parameters are valid and no other error occurs."
727 _mesa_HashLockMutex(ctx
->Shared
->TexObjects
);
729 for (i
= 0; i
< count
; i
++) {
730 struct gl_image_unit
*u
= &ctx
->ImageUnits
[first
+ i
];
731 const GLuint texture
= textures
? textures
[i
] : 0;
734 struct gl_texture_object
*texObj
= u
->TexObj
;
737 if (!texObj
|| texObj
->Name
!= texture
) {
738 texObj
= _mesa_lookup_texture_locked(ctx
, texture
);
739 if (!no_error
&& !texObj
) {
740 /* The ARB_multi_bind spec says:
742 * "An INVALID_OPERATION error is generated if any value
743 * in <textures> is not zero or the name of an existing
744 * texture object (per binding)."
746 _mesa_error(ctx
, GL_INVALID_OPERATION
,
747 "glBindImageTextures(textures[%d]=%u "
748 "is not zero or the name of an existing texture "
749 "object)", i
, texture
);
754 if (texObj
->Target
== GL_TEXTURE_BUFFER
) {
755 tex_format
= texObj
->BufferObjectFormat
;
757 struct gl_texture_image
*image
= texObj
->Image
[0][0];
759 if (!no_error
&& (!image
|| image
->Width
== 0 ||
760 image
->Height
== 0 || image
->Depth
== 0)) {
761 /* The ARB_multi_bind spec says:
763 * "An INVALID_OPERATION error is generated if the width,
764 * height, or depth of the level zero texture image of
765 * any texture in <textures> is zero (per binding)."
767 _mesa_error(ctx
, GL_INVALID_OPERATION
,
768 "glBindImageTextures(the width, height or depth "
769 "of the level zero texture image of "
770 "textures[%d]=%u is zero)", i
, texture
);
774 tex_format
= image
->InternalFormat
;
778 !_mesa_is_shader_image_format_supported(ctx
, tex_format
)) {
779 /* The ARB_multi_bind spec says:
781 * "An INVALID_OPERATION error is generated if the internal
782 * format of the level zero texture image of any texture
783 * in <textures> is not found in table 8.33 (per binding)."
785 _mesa_error(ctx
, GL_INVALID_OPERATION
,
786 "glBindImageTextures(the internal format %s of "
787 "the level zero texture image of textures[%d]=%u "
789 _mesa_enum_to_string(tex_format
),
794 /* Update the texture binding */
795 set_image_binding(u
, texObj
, 0,
796 _mesa_tex_target_is_layered(texObj
->Target
),
797 0, GL_READ_WRITE
, tex_format
);
799 /* Unbind the texture from the unit */
800 set_image_binding(u
, NULL
, 0, GL_FALSE
, 0, GL_READ_ONLY
, GL_R8
);
804 _mesa_HashUnlockMutex(ctx
->Shared
->TexObjects
);
808 _mesa_BindImageTextures_no_error(GLuint first
, GLsizei count
,
809 const GLuint
*textures
)
811 GET_CURRENT_CONTEXT(ctx
);
813 bind_image_textures(ctx
, first
, count
, textures
, true);
817 _mesa_BindImageTextures(GLuint first
, GLsizei count
, const GLuint
*textures
)
819 GET_CURRENT_CONTEXT(ctx
);
821 if (!ctx
->Extensions
.ARB_shader_image_load_store
) {
822 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindImageTextures()");
826 if (first
+ count
> ctx
->Const
.MaxImageUnits
) {
827 /* The ARB_multi_bind spec says:
829 * "An INVALID_OPERATION error is generated if <first> + <count>
830 * is greater than the number of image units supported by
831 * the implementation."
833 _mesa_error(ctx
, GL_INVALID_OPERATION
,
834 "glBindImageTextures(first=%u + count=%d > the value of "
835 "GL_MAX_IMAGE_UNITS=%u)",
836 first
, count
, ctx
->Const
.MaxImageUnits
);
840 bind_image_textures(ctx
, first
, count
, textures
, false);