Module: Mesa
Branch: master
Commit: b663d6bc6f4de9439107fc6444e436d14e21ee79
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b663d6bc6f4de9439107fc6444e436d14e21ee79

Author: Francisco Jerez <[email protected]>
Date:   Sat Jan 31 17:00:19 2015 +0200

mesa: Initialize image units to default state on context creation.

This is the required initial image unit state according to "Table 23.45. Image
State (state per image unit)" of the OpenGL 4.3 specification.

Reviewed-by: Matt Turner <[email protected]>

---

 src/mesa/main/context.c     |    2 ++
 src/mesa/main/shaderimage.c |   13 +++++++++++++
 src/mesa/main/shaderimage.h |    6 ++++++
 3 files changed, 21 insertions(+)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4aaf8b1..0a192de 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -118,6 +118,7 @@
 #include "scissor.h"
 #include "shared.h"
 #include "shaderobj.h"
+#include "shaderimage.h"
 #include "util/simple_list.h"
 #include "state.h"
 #include "stencil.h"
@@ -821,6 +822,7 @@ init_attrib_groups(struct gl_context *ctx)
    _mesa_init_feedback( ctx );
    _mesa_init_fog( ctx );
    _mesa_init_hint( ctx );
+   _mesa_init_image_units( ctx );
    _mesa_init_line( ctx );
    _mesa_init_lighting( ctx );
    _mesa_init_matrix( ctx );
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index 8caff2f..efe439c 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -331,6 +331,19 @@ get_image_format_class(mesa_format format)
    }
 }
 
+void
+_mesa_init_image_units(struct gl_context *ctx)
+{
+   unsigned i;
+
+   for (i = 0; i < ARRAY_SIZE(ctx->ImageUnits); ++i) {
+      struct gl_image_unit *u = &ctx->ImageUnits[i];
+      u->Access = GL_READ_ONLY;
+      u->Format = GL_R8;
+      u->_ActualFormat = _mesa_get_shader_image_format(u->Format);
+   }
+}
+
 static GLboolean
 validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u)
 {
diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h
index 1c7d1e0..33d8a1e 100644
--- a/src/mesa/main/shaderimage.h
+++ b/src/mesa/main/shaderimage.h
@@ -43,6 +43,12 @@ mesa_format
 _mesa_get_shader_image_format(GLenum format);
 
 /**
+ * Initialize a context's shader image units to the default state.
+ */
+void
+_mesa_init_image_units(struct gl_context *ctx);
+
+/**
  * 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

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to