[Mesa-stable] [PATCH 1/4] mesa: Expose function to calculate whether a shader image unit is valid.
Francisco Jerez
currojerez at riseup.net
Thu Sep 3 06:53:12 PDT 2015
A future commit will remove all texture object-dependent derived state
from the image unit struct to make validation unnecessary on texture
state changes. Instead of checking gl_image_unit::_Valid drivers will
be required to call this function when needed to find out whether an
image unit is in a valid state and whether access from the shader is
allowed.
Tested-by: Ye Tian <yex.tian at intel.com>
CC: "11.0" <mesa-stable at lists.freedesktop.org>
---
src/mesa/main/shaderimage.c | 8 ++++----
src/mesa/main/shaderimage.h | 11 +++++++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index c4bba84..a0a3b7b 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -415,8 +415,8 @@ _mesa_init_image_units(struct gl_context *ctx)
ctx->ImageUnits[i] = _mesa_default_image_unit(ctx);
}
-static GLboolean
-validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u)
+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;
@@ -567,7 +567,7 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
u->Access = access;
u->Format = format;
u->_ActualFormat = _mesa_get_shader_image_format(format);
- u->_Valid = validate_image_unit(ctx, u);
+ u->_Valid = _mesa_is_image_unit_valid(ctx, u);
if (u->TexObj && _mesa_tex_target_is_layered(u->TexObj->Target)) {
u->Layered = layered;
@@ -707,7 +707,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
u->Access = GL_READ_WRITE;
u->Format = tex_format;
u->_ActualFormat = _mesa_get_shader_image_format(tex_format);
- u->_Valid = validate_image_unit(ctx, u);
+ u->_Valid = _mesa_is_image_unit_valid(ctx, u);
} else {
/* Unbind the texture from the unit */
_mesa_reference_texobj(&u->TexObj, NULL);
diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h
index bbe088a..14a544f 100644
--- a/src/mesa/main/shaderimage.h
+++ b/src/mesa/main/shaderimage.h
@@ -55,6 +55,17 @@ void
_mesa_init_image_units(struct gl_context *ctx);
/**
+ * Return GL_TRUE if the state of the image unit passed as argument is valid
+ * and access from the shader is allowed. Otherwise loads from this unit
+ * should return zero and stores should have no effect.
+ *
+ * The result depends on context state other than the passed image unit, part
+ * of the _NEW_TEXTURE set.
+ */
+GLboolean
+_mesa_is_image_unit_valid(struct gl_context *ctx, struct gl_image_unit *u);
+
+/**
* Recalculate the \c _Valid flag of a context's shader image units.
*
* To be called when the state of any texture bound to an image unit
--
2.4.6
More information about the mesa-stable
mailing list