mesa: Initialize image units to default state on context creation.
authorFrancisco Jerez <currojerez@riseup.net>
Sat, 31 Jan 2015 15:00:19 +0000 (17:00 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Mon, 4 May 2015 14:44:16 +0000 (17:44 +0300)
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 <mattst88@gmail.com>
src/mesa/main/context.c
src/mesa/main/shaderimage.c
src/mesa/main/shaderimage.h

index 4aaf8b1af57c4a7110d279b9cf1960cab718d74c..0a192de8c0a47087076e9638c2235e100a2bb361 100644 (file)
 #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 );
index 8caff2f2660a3a91fa85da3744efe181c237f3d3..efe439c6dfd705e4880e4a39137f5d6cdb87d327 100644 (file)
@@ -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)
 {
index 1c7d1e0e89409083fbf308ba888f465b6cb2799b..33d8a1eff5516c71cad4d34edc83937b9a1961aa 100644 (file)
@@ -42,6 +42,12 @@ struct gl_context;
 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.
  *