diff options
author | Francisco Jerez <[email protected]> | 2014-11-14 20:31:13 +0200 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2015-05-04 17:44:15 +0300 |
commit | f74ba58f84ad41f485957fe7edfb175a21c2ac24 (patch) | |
tree | 4f0ec66716fb05ce0293cbdaf1c70fda1c5e2e2c /src | |
parent | 8424cafbac5c9747f0ee9ae55d8633e8172ee47f (diff) |
mesa: Add support for binding a buffer texture to a shader image unit.
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/shaderimage.c | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c index f8120731e5a..005698c526f 100644 --- a/src/mesa/main/shaderimage.c +++ b/src/mesa/main/shaderimage.c @@ -335,7 +335,7 @@ static GLboolean validate_image_unit(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) @@ -351,25 +351,32 @@ validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u) 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 = t->_BufferObjectFormat; - if (!img || img->Border || - get_image_format_class(img->TexFormat) == IMAGE_FORMAT_CLASS_NONE || - img->NumSamples > ctx->Const.MaxImageSamples) + } 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 = img->TexFormat; + } + + if (get_image_format_class(tex_format) == IMAGE_FORMAT_CLASS_NONE) 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; @@ -535,8 +542,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures) if (texture != 0) { struct gl_texture_object *texObj; - struct gl_texture_image *image; - mesa_format actualFormat; + GLenum tex_format; if (!u->TexObj || u->TexObj->Name != texture) { texObj = _mesa_lookup_texture_locked(ctx, texture); @@ -557,25 +563,30 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures) texObj = u->TexObj; } - image = texObj->Image[0][0]; + 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 <textures> 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; - } + 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 <textures> 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; + } - actualFormat = _mesa_get_shader_image_format(image->InternalFormat); + tex_format = image->InternalFormat; + } - if (actualFormat == MESA_FORMAT_NONE) { + if (_mesa_get_shader_image_format(tex_format) == MESA_FORMAT_NONE) { /* The ARB_multi_bind spec says: * * "An INVALID_OPERATION error is generated if the internal @@ -586,7 +597,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures) "glBindImageTextures(the internal format %s of " "the level zero texture image of textures[%d]=%u " "is not supported)", - _mesa_lookup_enum_by_nr(image->InternalFormat), + _mesa_lookup_enum_by_nr(tex_format), i, texture); continue; } @@ -597,8 +608,8 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures) u->Layered = _mesa_tex_target_is_layered(texObj->Target); u->Layer = 0; u->Access = GL_READ_WRITE; - u->Format = image->InternalFormat; - u->_ActualFormat = actualFormat; + u->Format = tex_format; + u->_ActualFormat = _mesa_get_shader_image_format(tex_format); u->_Valid = validate_image_unit(ctx, u); } else { /* Unbind the texture from the unit */ |