aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/shaderimage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-05-08 00:18:25 +0200
committermarha <marha@users.sourceforge.net>2014-05-08 00:18:25 +0200
commit683155917770af9e63a938bc450df25d1904d567 (patch)
tree5eb9d2d0bba27ed4e8afe58c195d1918282c343b /mesalib/src/mesa/main/shaderimage.c
parentea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4 (diff)
downloadvcxsrv-683155917770af9e63a938bc450df25d1904d567.tar.gz
vcxsrv-683155917770af9e63a938bc450df25d1904d567.tar.bz2
vcxsrv-683155917770af9e63a938bc450df25d1904d567.zip
xserver xcb-proto mesa pixman xkeyboard-config git update 7 May 2014
xserver commit a5b9757142a2ab471ca26651dce9cc5f5e351f3d libxcb commit d978a4f69b30b630f28d07f1003cf290284d24d8 libxcb/xcb-proto commit 389889e2f95af19e7fc7ac89e7faeb2f28652415 xkeyboard-config commit 3e54f31b1f118f00c240f59d72d7ddb685c6db79 libX11 commit 8be4610939b833587954957f5963eb4191b43d19 libXdmcp commit 089081dca4ba3598c6f9bf401c029378943b5854 libXext commit 11aad96bd689d54156064d2e81213dc827a689d1 libfontenc commit 0037a42107b952c9d903719615747e760e4e7247 libXinerama commit edd95182b26eb5d576d4878c559e0f17dddaa909 libXau commit 1e4635be11154dd8262f37b379511bd627defa2a xkbcomp commit d4e02a09258063c6d024c3ccd42d6b22212e6e18 pixman commit 91f32ce961bc85f98b3372b95681ad8918d24b18 xextproto commit 66afec3f49e8eb0d4c2e9af7088fc3116d4bafd7 randrproto commit a4a6694c059d74247c16527eef4a0ec9f56bbef6 glproto commit f84853d97d5749308992412a215fa518b6536eb3 mkfontscale commit 399db42a151687f1181ae23d28a76d31125a2853 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 libXft commit 4acfdaf95adb0a05c2a25550bdde036c865902f4 libXmu commit 22d9c590901e121936f50dee97dc60c4f7defb63 libxtrans commit a57a7f62242e1ea972b81414741729bf3dbae0a4 fontconfig commit 81664fe54f117e4781fda5a30429b51858302e91 mesa commit 9ced3fc649ec04710a5f5c855bfb582b898cff83
Diffstat (limited to 'mesalib/src/mesa/main/shaderimage.c')
-rw-r--r--mesalib/src/mesa/main/shaderimage.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/shaderimage.c b/mesalib/src/mesa/main/shaderimage.c
index d1e752d3d..9e62f4294 100644
--- a/mesalib/src/mesa/main/shaderimage.c
+++ b/mesalib/src/mesa/main/shaderimage.c
@@ -33,6 +33,7 @@
#include "context.h"
#include "texobj.h"
#include "teximage.h"
+#include "enums.h"
/*
* Define endian-invariant aliases for some mesa formats that are
@@ -479,6 +480,148 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
}
void GLAPIENTRY
+_mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ int i;
+
+ if (!ctx->Extensions.ARB_shader_image_load_store) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBindImageTextures()");
+ return;
+ }
+
+ if (first + count > ctx->Const.MaxImageUnits) {
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_OPERATION error is generated if <first> + <count>
+ * is greater than the number of image units supported by
+ * the implementation."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindImageTextures(first=%u + count=%d > the value of "
+ "GL_MAX_IMAGE_UNITS=%u)",
+ first, count, ctx->Const.MaxImageUnits);
+ return;
+ }
+
+ /* Assume that at least one binding will be changed */
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;
+
+ /* Note that the error semantics for multi-bind commands differ from
+ * those of other GL commands.
+ *
+ * The Issues section in the ARB_multi_bind spec says:
+ *
+ * "(11) Typically, OpenGL specifies that if an error is generated by
+ * a command, that command has no effect. This is somewhat
+ * unfortunate for multi-bind commands, because it would require
+ * a first pass to scan the entire list of bound objects for
+ * errors and then a second pass to actually perform the
+ * bindings. Should we have different error semantics?
+ *
+ * RESOLVED: Yes. In this specification, when the parameters for
+ * one of the <count> binding points are invalid, that binding
+ * point is not updated and an error will be generated. However,
+ * other binding points in the same command will be updated if
+ * their parameters are valid and no other error occurs."
+ */
+
+ _mesa_begin_texture_lookups(ctx);
+
+ for (i = 0; i < count; i++) {
+ struct gl_image_unit *u = &ctx->ImageUnits[first + i];
+ const GLuint texture = textures ? textures[i] : 0;
+
+ if (texture != 0) {
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *image;
+ mesa_format actualFormat;
+
+ if (!u->TexObj || u->TexObj->Name != texture) {
+ texObj = _mesa_lookup_texture_locked(ctx, texture);
+ if (!texObj) {
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_OPERATION error is generated if any value
+ * in <textures> is not zero or the name of an existing
+ * texture object (per binding)."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindImageTextures(textures[%d]=%u "
+ "is not zero or the name of an existing texture "
+ "object)", i, texture);
+ continue;
+ }
+ } else {
+ texObj = u->TexObj;
+ }
+
+ 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;
+ }
+
+ actualFormat = get_image_format(image->InternalFormat);
+
+ if (actualFormat == MESA_FORMAT_NONE) {
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_OPERATION error is generated if the internal
+ * format of the level zero texture image of any texture
+ * in <textures> is not found in table 8.33 (per binding)."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "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),
+ i, texture);
+ continue;
+ }
+
+ /* Update the texture binding */
+ _mesa_reference_texobj(&u->TexObj, texObj);
+ u->Level = 0;
+ 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->_Valid = validate_image_unit(ctx, u);
+ } else {
+ /* Unbind the texture from the unit */
+ _mesa_reference_texobj(&u->TexObj, NULL);
+ u->Level = 0;
+ u->Layered = GL_FALSE;
+ u->Layer = 0;
+ u->Access = GL_READ_ONLY;
+ u->Format = GL_R8;
+ u->_ActualFormat = MESA_FORMAT_R_UNORM8;
+ u->_Valid = GL_FALSE;
+ }
+
+ /* Pass the BindImageTexture call down to the device driver */
+ if (ctx->Driver.BindImageTexture)
+ ctx->Driver.BindImageTexture(ctx, u, u->TexObj, u->Level, u->Layered,
+ u->Layer, u->Access, u->Format);
+ }
+
+ _mesa_end_texture_lookups(ctx);
+}
+
+void GLAPIENTRY
_mesa_MemoryBarrier(GLbitfield barriers)
{
GET_CURRENT_CONTEXT(ctx);