[Mesa-dev] [PATCH 31/31] mesa: simplify _mesa_is_image_unit_valid for buffers
Marek Olšák
maraeo at gmail.com
Mon Jun 12 16:55:56 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/main/shaderimage.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index 5e31d4e..c722b32 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -470,47 +470,48 @@ _mesa_init_image_units(struct gl_context *ctx)
GLboolean
_mesa_is_image_unit_valid(struct gl_context *ctx, struct gl_image_unit *u)
{
struct gl_texture_object *t = u->TexObj;
mesa_format tex_format;
if (!t)
return GL_FALSE;
+ /* The GL 4.5 Core spec doesn't say anything about buffers. In practice,
+ * the image buffer format is always compatible with the underlying
+ * buffer storage.
+ */
+ if (t->Target == GL_TEXTURE_BUFFER)
+ return GL_TRUE;
+
if (!t->_BaseComplete && !t->_MipmapComplete)
_mesa_test_texobj_completeness(ctx, t);
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))
return GL_FALSE;
- 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;
+ struct gl_texture_image *img = (t->Target == GL_TEXTURE_CUBE_MAP ?
+ t->Image[u->_Layer][u->Level] :
+ t->Image[0][u->Level]);
- tex_format = _mesa_get_shader_image_format(img->InternalFormat);
- }
+ if (!img || img->Border || img->NumSamples > ctx->Const.MaxImageSamples)
+ return GL_FALSE;
+ tex_format = _mesa_get_shader_image_format(img->InternalFormat);
if (!tex_format)
return GL_FALSE;
switch (t->ImageFormatCompatibilityType) {
case GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE:
if (_mesa_get_format_bytes(tex_format) !=
_mesa_get_format_bytes(u->_ActualFormat))
return GL_FALSE;
break;
--
2.7.4
More information about the mesa-dev
mailing list