X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fshaderimage.c;h=45b72c9b4ffe0a629d43d996f5950b0bb15c8b6f;hb=6fa34de8308fd4abc2fb23aa9071a35cb08552c9;hp=cfb5ad47754f0690b262a10f6d073101727b488d;hpb=71fe9437169cfdafda8814aa814bb85429fb6cfc;p=mesa.git diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c index cfb5ad47754..45b72c9b4ff 100644 --- a/src/mesa/main/shaderimage.c +++ b/src/mesa/main/shaderimage.c @@ -30,9 +30,11 @@ #include "mtypes.h" #include "formats.h" #include "errors.h" +#include "hash.h" #include "context.h" #include "texobj.h" #include "teximage.h" +#include "enums.h" /* * Define endian-invariant aliases for some mesa formats that are @@ -42,23 +44,23 @@ * results. */ #ifdef MESA_BIG_ENDIAN -# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA8888 -# define MESA_FORMAT_RG_16 MESA_FORMAT_RG1616 -# define MESA_FORMAT_RG_8 MESA_FORMAT_RG88 -# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA8888 -# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_RG1616 -# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88 +# define MESA_FORMAT_RGBA_8 MESA_FORMAT_A8B8G8R8_UNORM +# define MESA_FORMAT_RG_16 MESA_FORMAT_G16R16_UNORM +# define MESA_FORMAT_RG_8 MESA_FORMAT_G8R8_UNORM +# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_A8B8G8R8_SNORM +# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_G16R16_SNORM +# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_G8R8_SNORM #else -# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA8888_REV -# define MESA_FORMAT_RG_16 MESA_FORMAT_GR1616 -# define MESA_FORMAT_RG_8 MESA_FORMAT_GR88 -# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA8888_REV -# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_GR1616 -# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88_REV +# define MESA_FORMAT_RGBA_8 MESA_FORMAT_R8G8B8A8_UNORM +# define MESA_FORMAT_RG_16 MESA_FORMAT_R16G16_UNORM +# define MESA_FORMAT_RG_8 MESA_FORMAT_R8G8_UNORM +# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_R8G8B8A8_SNORM +# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_R16G16_SNORM +# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_R8G8_SNORM #endif -static mesa_format -get_image_format(GLenum format) +mesa_format +_mesa_get_shader_image_format(GLenum format) { switch (format) { case GL_RGBA32F: @@ -74,7 +76,7 @@ get_image_format(GLenum format) return MESA_FORMAT_RG_FLOAT16; case GL_R11F_G11F_B10F: - return MESA_FORMAT_R11_G11_B10_FLOAT; + return MESA_FORMAT_R11G11B10_FLOAT; case GL_R32F: return MESA_FORMAT_R_FLOAT32; @@ -89,7 +91,7 @@ get_image_format(GLenum format) return MESA_FORMAT_RGBA_UINT16; case GL_RGB10_A2UI: - return MESA_FORMAT_ABGR2101010_UINT; + return MESA_FORMAT_R10G10B10A2_UINT; case GL_RGBA8UI: return MESA_FORMAT_RGBA_UINT8; @@ -113,37 +115,37 @@ get_image_format(GLenum format) return MESA_FORMAT_R_UINT8; case GL_RGBA32I: - return MESA_FORMAT_RGBA_INT32; + return MESA_FORMAT_RGBA_SINT32; case GL_RGBA16I: - return MESA_FORMAT_RGBA_INT16; + return MESA_FORMAT_RGBA_SINT16; case GL_RGBA8I: - return MESA_FORMAT_RGBA_INT8; + return MESA_FORMAT_RGBA_SINT8; case GL_RG32I: - return MESA_FORMAT_RG_INT32; + return MESA_FORMAT_RG_SINT32; case GL_RG16I: - return MESA_FORMAT_RG_INT16; + return MESA_FORMAT_RG_SINT16; case GL_RG8I: - return MESA_FORMAT_RG_INT8; + return MESA_FORMAT_RG_SINT8; case GL_R32I: - return MESA_FORMAT_R_INT32; + return MESA_FORMAT_R_SINT32; case GL_R16I: - return MESA_FORMAT_R_INT16; + return MESA_FORMAT_R_SINT16; case GL_R8I: - return MESA_FORMAT_R_INT8; + return MESA_FORMAT_R_SINT8; case GL_RGBA16: - return MESA_FORMAT_RGBA_16; + return MESA_FORMAT_RGBA_UNORM16; case GL_RGB10_A2: - return MESA_FORMAT_ABGR2101010; + return MESA_FORMAT_R10G10B10A2_UNORM; case GL_RGBA8: return MESA_FORMAT_RGBA_8; @@ -155,13 +157,13 @@ get_image_format(GLenum format) return MESA_FORMAT_RG_8; case GL_R16: - return MESA_FORMAT_R16; + return MESA_FORMAT_R_UNORM16; case GL_R8: - return MESA_FORMAT_R8; + return MESA_FORMAT_R_UNORM8; case GL_RGBA16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; + return MESA_FORMAT_RGBA_SNORM16; case GL_RGBA8_SNORM: return MESA_FORMAT_SIGNED_RGBA_8; @@ -173,10 +175,10 @@ get_image_format(GLenum format) return MESA_FORMAT_SIGNED_RG_8; case GL_R16_SNORM: - return MESA_FORMAT_SIGNED_R16; + return MESA_FORMAT_R_SNORM16; case GL_R8_SNORM: - return MESA_FORMAT_SIGNED_R8; + return MESA_FORMAT_R_SNORM8; default: return MESA_FORMAT_NONE; @@ -220,7 +222,7 @@ get_image_format_class(mesa_format format) case MESA_FORMAT_RG_FLOAT16: return IMAGE_FORMAT_CLASS_2X16; - case MESA_FORMAT_R11_G11_B10_FLOAT: + case MESA_FORMAT_R11G11B10_FLOAT: return IMAGE_FORMAT_CLASS_10_11_11; case MESA_FORMAT_R_FLOAT32: @@ -235,7 +237,7 @@ get_image_format_class(mesa_format format) case MESA_FORMAT_RGBA_UINT16: return IMAGE_FORMAT_CLASS_4X16; - case MESA_FORMAT_ABGR2101010_UINT: + case MESA_FORMAT_R10G10B10A2_UINT: return IMAGE_FORMAT_CLASS_2_10_10_10; case MESA_FORMAT_RGBA_UINT8: @@ -259,37 +261,37 @@ get_image_format_class(mesa_format format) case MESA_FORMAT_R_UINT8: return IMAGE_FORMAT_CLASS_1X8; - case MESA_FORMAT_RGBA_INT32: + case MESA_FORMAT_RGBA_SINT32: return IMAGE_FORMAT_CLASS_4X32; - case MESA_FORMAT_RGBA_INT16: + case MESA_FORMAT_RGBA_SINT16: return IMAGE_FORMAT_CLASS_4X16; - case MESA_FORMAT_RGBA_INT8: + case MESA_FORMAT_RGBA_SINT8: return IMAGE_FORMAT_CLASS_4X8; - case MESA_FORMAT_RG_INT32: + case MESA_FORMAT_RG_SINT32: return IMAGE_FORMAT_CLASS_2X32; - case MESA_FORMAT_RG_INT16: + case MESA_FORMAT_RG_SINT16: return IMAGE_FORMAT_CLASS_2X16; - case MESA_FORMAT_RG_INT8: + case MESA_FORMAT_RG_SINT8: return IMAGE_FORMAT_CLASS_2X8; - case MESA_FORMAT_R_INT32: + case MESA_FORMAT_R_SINT32: return IMAGE_FORMAT_CLASS_1X32; - case MESA_FORMAT_R_INT16: + case MESA_FORMAT_R_SINT16: return IMAGE_FORMAT_CLASS_1X16; - case MESA_FORMAT_R_INT8: + case MESA_FORMAT_R_SINT8: return IMAGE_FORMAT_CLASS_1X8; - case MESA_FORMAT_RGBA_16: + case MESA_FORMAT_RGBA_UNORM16: return IMAGE_FORMAT_CLASS_4X16; - case MESA_FORMAT_ABGR2101010: + case MESA_FORMAT_R10G10B10A2_UNORM: return IMAGE_FORMAT_CLASS_2_10_10_10; case MESA_FORMAT_RGBA_8: @@ -301,13 +303,13 @@ get_image_format_class(mesa_format format) case MESA_FORMAT_RG_8: return IMAGE_FORMAT_CLASS_2X8; - case MESA_FORMAT_R16: + case MESA_FORMAT_R_UNORM16: return IMAGE_FORMAT_CLASS_1X16; - case MESA_FORMAT_R8: + case MESA_FORMAT_R_UNORM8: return IMAGE_FORMAT_CLASS_1X8; - case MESA_FORMAT_SIGNED_RGBA_16: + case MESA_FORMAT_RGBA_SNORM16: return IMAGE_FORMAT_CLASS_4X16; case MESA_FORMAT_SIGNED_RGBA_8: @@ -319,10 +321,10 @@ get_image_format_class(mesa_format format) case MESA_FORMAT_SIGNED_RG_8: return IMAGE_FORMAT_CLASS_2X8; - case MESA_FORMAT_SIGNED_R16: + case MESA_FORMAT_R_SNORM16: return IMAGE_FORMAT_CLASS_1X16; - case MESA_FORMAT_SIGNED_R8: + case MESA_FORMAT_R_SNORM8: return IMAGE_FORMAT_CLASS_1X8; default: @@ -330,45 +332,190 @@ get_image_format_class(mesa_format format) } } -static GLboolean -validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u) +static GLenum +_image_format_class_to_glenum(enum image_format_class class) +{ + switch (class) { + case IMAGE_FORMAT_CLASS_NONE: + return GL_NONE; + case IMAGE_FORMAT_CLASS_1X8: + return GL_IMAGE_CLASS_1_X_8; + case IMAGE_FORMAT_CLASS_1X16: + return GL_IMAGE_CLASS_1_X_16; + case IMAGE_FORMAT_CLASS_1X32: + return GL_IMAGE_CLASS_1_X_32; + case IMAGE_FORMAT_CLASS_2X8: + return GL_IMAGE_CLASS_2_X_8; + case IMAGE_FORMAT_CLASS_2X16: + return GL_IMAGE_CLASS_2_X_16; + case IMAGE_FORMAT_CLASS_2X32: + return GL_IMAGE_CLASS_2_X_32; + case IMAGE_FORMAT_CLASS_10_11_11: + return GL_IMAGE_CLASS_11_11_10; + case IMAGE_FORMAT_CLASS_4X8: + return GL_IMAGE_CLASS_4_X_8; + case IMAGE_FORMAT_CLASS_4X16: + return GL_IMAGE_CLASS_4_X_16; + case IMAGE_FORMAT_CLASS_4X32: + return GL_IMAGE_CLASS_4_X_32; + case IMAGE_FORMAT_CLASS_2_10_10_10: + return GL_IMAGE_CLASS_10_10_10_2; + default: + assert(!"Invalid image_format_class"); + return GL_NONE; + } +} + +GLenum +_mesa_get_image_format_class(GLenum format) +{ + mesa_format tex_format = _mesa_get_shader_image_format(format); + if (tex_format == MESA_FORMAT_NONE) + return GL_NONE; + + enum image_format_class class = get_image_format_class(tex_format); + return _image_format_class_to_glenum(class); +} + +bool +_mesa_is_shader_image_format_supported(const struct gl_context *ctx, + GLenum format) +{ + switch (format) { + /* Formats supported on both desktop and ES GL, c.f. table 8.27 of the + * OpenGL ES 3.1 specification. + */ + case GL_RGBA32F: + case GL_RGBA16F: + case GL_R32F: + case GL_RGBA32UI: + case GL_RGBA16UI: + case GL_RGBA8UI: + case GL_R32UI: + case GL_RGBA32I: + case GL_RGBA16I: + case GL_RGBA8I: + case GL_R32I: + case GL_RGBA8: + case GL_RGBA8_SNORM: + return true; + + /* Formats supported on unextended desktop GL and the original + * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2 + * specification or by GLES 3.1 with GL_NV_image_formats extension. + */ + case GL_RG32F: + case GL_RG16F: + case GL_R11F_G11F_B10F: + case GL_R16F: + case GL_RGB10_A2UI: + case GL_RG32UI: + case GL_RG16UI: + case GL_RG8UI: + case GL_R16UI: + case GL_R8UI: + case GL_RG32I: + case GL_RG16I: + case GL_RG8I: + case GL_R16I: + case GL_R8I: + case GL_RGB10_A2: + case GL_RG8: + case GL_R8: + case GL_RG8_SNORM: + case GL_R8_SNORM: + return true; + + /* Formats supported on unextended desktop GL and the original + * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2 + * specification. + * + * These can be supported by GLES 3.1 with GL_NV_image_formats & + * GL_EXT_texture_norm16 extensions but we don't have support for the + * latter in Mesa yet. + */ + case GL_RGBA16: + case GL_RGBA16_SNORM: + case GL_RG16: + case GL_RG16_SNORM: + case GL_R16: + case GL_R16_SNORM: + return _mesa_is_desktop_gl(ctx); + + default: + return false; + } +} + +struct gl_image_unit +_mesa_default_image_unit(struct gl_context *ctx) +{ + const GLenum format = _mesa_is_desktop_gl(ctx) ? GL_R8 : GL_R32UI; + const struct gl_image_unit u = { + .Access = GL_READ_ONLY, + .Format = format, + ._ActualFormat = _mesa_get_shader_image_format(format) + }; + return u; +} + +void +_mesa_init_image_units(struct gl_context *ctx) +{ + unsigned i; + + for (i = 0; i < ARRAY_SIZE(ctx->ImageUnits); ++i) + ctx->ImageUnits[i] = _mesa_default_image_unit(ctx); +} + +GLboolean +_mesa_is_image_unit_valid(struct gl_context *ctx, struct gl_image_unit *u) { struct gl_texture_object *t = u->TexObj; - struct gl_texture_image *img; + mesa_format tex_format; - if (!t || u->Level < t->BaseLevel || - u->Level > t->_MaxLevel) + if (!t) return GL_FALSE; - _mesa_test_texobj_completeness(ctx, t); + if (!t->_BaseComplete && !t->_MipmapComplete) + _mesa_test_texobj_completeness(ctx, t); - if ((u->Level == t->BaseLevel && !t->_BaseComplete) || + if (u->Level < t->BaseLevel || + u->Level > t->_MaxLevel || + (u->Level == t->BaseLevel && !t->_BaseComplete) || (u->Level != t->BaseLevel && !t->_MipmapComplete)) return GL_FALSE; if (_mesa_tex_target_is_layered(t->Target) && - u->Layer >= _mesa_get_texture_layers(t, u->Level)) + u->_Layer >= _mesa_get_texture_layers(t, u->Level)) return GL_FALSE; - if (t->Target == GL_TEXTURE_CUBE_MAP) - img = t->Image[u->Layer][u->Level]; - else - img = t->Image[0][u->Level]; + if (t->Target == GL_TEXTURE_BUFFER) { + tex_format = _mesa_get_shader_image_format(t->BufferObjectFormat); + + } else { + struct gl_texture_image *img = (t->Target == GL_TEXTURE_CUBE_MAP ? + t->Image[u->_Layer][u->Level] : + t->Image[0][u->Level]); + + if (!img || img->Border || img->NumSamples > ctx->Const.MaxImageSamples) + return GL_FALSE; + + tex_format = _mesa_get_shader_image_format(img->InternalFormat); + } - if (!img || img->Border || - get_image_format_class(img->TexFormat) == IMAGE_FORMAT_CLASS_NONE || - img->NumSamples > ctx->Const.MaxImageSamples) + if (!tex_format) return GL_FALSE; switch (t->ImageFormatCompatibilityType) { case GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE: - if (_mesa_get_format_bytes(img->TexFormat) != + if (_mesa_get_format_bytes(tex_format) != _mesa_get_format_bytes(u->_ActualFormat)) return GL_FALSE; break; case GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS: - if (get_image_format_class(img->TexFormat) != + if (get_image_format_class(tex_format) != get_image_format_class(u->_ActualFormat)) return GL_FALSE; break; @@ -380,17 +527,6 @@ validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u) return GL_TRUE; } -void -_mesa_validate_image_units(struct gl_context *ctx) -{ - int i; - - for (i = 0; i < ctx->Const.MaxImageUnits; ++i) { - struct gl_image_unit *u = &ctx->ImageUnits[i]; - u->_Valid = validate_image_unit(ctx, u); - } -} - static GLboolean validate_bind_image_texture(struct gl_context *ctx, GLuint unit, GLuint texture, GLint level, GLboolean layered, @@ -420,7 +556,7 @@ validate_bind_image_texture(struct gl_context *ctx, GLuint unit, return GL_FALSE; } - if (!get_image_format(format)) { + if (!_mesa_is_shader_image_format_supported(ctx, format)) { _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(format)"); return GL_FALSE; } @@ -434,7 +570,6 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level, GLenum format) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_object *t = NULL; struct gl_image_unit *u; if (!validate_bind_image_texture(ctx, unit, texture, level, @@ -447,42 +582,185 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level, ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits; if (texture) { - t = _mesa_lookup_texture(ctx, texture); + struct gl_texture_object *t = _mesa_lookup_texture(ctx, texture); + if (!t) { _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(texture)"); return; } - _mesa_reference_texobj(&u->TexObj, t); - u->Level = level; - u->Access = access; - u->Format = format; - u->_ActualFormat = get_image_format(format); - - if (_mesa_tex_target_is_layered(t->Target)) { - u->Layered = layered; - u->Layer = (layered ? 0 : layer); - } else { - u->Layered = GL_FALSE; - u->Layer = 0; + /* From section 8.22 "Texture Image Loads and Stores" of the OpenGL ES + * 3.1 spec: + * + * "An INVALID_OPERATION error is generated if texture is not the name + * of an immutable texture object." + * + * However note that issue 7 of the GL_OES_texture_buffer spec + * recognizes that there is no way to create immutable buffer textures, + * so those are excluded from this requirement. + */ + if (_mesa_is_gles(ctx) && !t->Immutable && + t->Target != GL_TEXTURE_BUFFER) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindImageTexture(!immutable)"); + return; } + _mesa_reference_texobj(&u->TexObj, t); } else { _mesa_reference_texobj(&u->TexObj, NULL); } - u->_Valid = validate_image_unit(ctx, u); + u->Level = level; + u->Access = access; + u->Format = format; + u->_ActualFormat = _mesa_get_shader_image_format(format); - if (ctx->Driver.BindImageTexture) - ctx->Driver.BindImageTexture(ctx, u, t, level, layered, - layer, access, format); + if (u->TexObj && _mesa_tex_target_is_layered(u->TexObj->Target)) { + u->Layered = layered; + u->Layer = layer; + u->_Layer = (u->Layered ? 0 : u->Layer); + } else { + u->Layered = GL_FALSE; + u->Layer = 0; + } } void GLAPIENTRY -_mesa_MemoryBarrier(GLbitfield barriers) +_mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures) { GET_CURRENT_CONTEXT(ctx); + int i; + + if (!ctx->Extensions.ARB_shader_image_load_store) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindImageTextures()"); + return; + } + + if (first + count > ctx->Const.MaxImageUnits) { + /* The ARB_multi_bind spec says: + * + * "An INVALID_OPERATION error is generated if + + * is greater than the number of image units supported by + * the implementation." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindImageTextures(first=%u + count=%d > the value of " + "GL_MAX_IMAGE_UNITS=%u)", + first, count, ctx->Const.MaxImageUnits); + return; + } + + /* Assume that at least one binding will be changed */ + FLUSH_VERTICES(ctx, 0); + ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits; + + /* Note that the error semantics for multi-bind commands differ from + * those of other GL commands. + * + * The Issues section in the ARB_multi_bind spec says: + * + * "(11) Typically, OpenGL specifies that if an error is generated by + * a command, that command has no effect. This is somewhat + * unfortunate for multi-bind commands, because it would require + * a first pass to scan the entire list of bound objects for + * errors and then a second pass to actually perform the + * bindings. Should we have different error semantics? + * + * RESOLVED: Yes. In this specification, when the parameters for + * one of the binding points are invalid, that binding + * point is not updated and an error will be generated. However, + * other binding points in the same command will be updated if + * their parameters are valid and no other error occurs." + */ + + _mesa_HashLockMutex(ctx->Shared->TexObjects); + + for (i = 0; i < count; i++) { + struct gl_image_unit *u = &ctx->ImageUnits[first + i]; + const GLuint texture = textures ? textures[i] : 0; + + if (texture != 0) { + struct gl_texture_object *texObj; + GLenum tex_format; + + if (!u->TexObj || u->TexObj->Name != texture) { + texObj = _mesa_lookup_texture_locked(ctx, texture); + if (!texObj) { + /* The ARB_multi_bind spec says: + * + * "An INVALID_OPERATION error is generated if any value + * in is not zero or the name of an existing + * texture object (per binding)." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindImageTextures(textures[%d]=%u " + "is not zero or the name of an existing texture " + "object)", i, texture); + continue; + } + } else { + texObj = u->TexObj; + } + + if (texObj->Target == GL_TEXTURE_BUFFER) { + tex_format = texObj->BufferObjectFormat; + } else { + struct gl_texture_image *image = texObj->Image[0][0]; + + if (!image || image->Width == 0 || image->Height == 0 || + image->Depth == 0) { + /* The ARB_multi_bind spec says: + * + * "An INVALID_OPERATION error is generated if the width, + * height, or depth of the level zero texture image of + * any texture in is zero (per binding)." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindImageTextures(the width, height or depth " + "of the level zero texture image of " + "textures[%d]=%u is zero)", i, texture); + continue; + } + + tex_format = image->InternalFormat; + } + + if (!_mesa_is_shader_image_format_supported(ctx, tex_format)) { + /* The ARB_multi_bind spec says: + * + * "An INVALID_OPERATION error is generated if the internal + * format of the level zero texture image of any texture + * in is not found in table 8.33 (per binding)." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindImageTextures(the internal format %s of " + "the level zero texture image of textures[%d]=%u " + "is not supported)", + _mesa_enum_to_string(tex_format), + i, texture); + continue; + } + + /* Update the texture binding */ + _mesa_reference_texobj(&u->TexObj, texObj); + u->Level = 0; + u->Layered = _mesa_tex_target_is_layered(texObj->Target); + u->_Layer = u->Layer = 0; + u->Access = GL_READ_WRITE; + u->Format = tex_format; + u->_ActualFormat = _mesa_get_shader_image_format(tex_format); + } else { + /* Unbind the texture from the unit */ + _mesa_reference_texobj(&u->TexObj, NULL); + u->Level = 0; + u->Layered = GL_FALSE; + u->_Layer = u->Layer = 0; + u->Access = GL_READ_ONLY; + u->Format = GL_R8; + u->_ActualFormat = MESA_FORMAT_R_UNORM8; + } + } - if (ctx->Driver.MemoryBarrier) - ctx->Driver.MemoryBarrier(ctx, barriers); + _mesa_HashUnlockMutex(ctx->Shared->TexObjects); }