mesa: Export shader image format to mesa format conversion function.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 18 Nov 2014 12:14:46 +0000 (14:14 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Mon, 4 May 2015 14:44:15 +0000 (17:44 +0300)
This function will be useful for back-ends to translate an image internal
format as specified in GLSL code into a mesa format.

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/main/shaderimage.c
src/mesa/main/shaderimage.h

index dcbcca623606fad7a84549f02905138dab689c69..f8120731e5aebe41050b49cd50831b8016faee5b 100644 (file)
@@ -58,8 +58,8 @@
 # define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_R8G8_SNORM
 #endif
 
-static mesa_format
-get_image_format(GLenum format)
+mesa_format
+_mesa_get_shader_image_format(GLenum format)
 {
    switch (format) {
    case GL_RGBA32F:
@@ -421,7 +421,7 @@ validate_bind_image_texture(struct gl_context *ctx, GLuint unit,
       return GL_FALSE;
    }
 
-   if (!get_image_format(format)) {
+   if (!_mesa_get_shader_image_format(format)) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(format)");
       return GL_FALSE;
    }
@@ -458,7 +458,7 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
       u->Level = level;
       u->Access = access;
       u->Format = format;
-      u->_ActualFormat = get_image_format(format);
+      u->_ActualFormat = _mesa_get_shader_image_format(format);
 
       if (_mesa_tex_target_is_layered(t->Target)) {
          u->Layered = layered;
@@ -573,7 +573,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
             continue;
          }
 
-         actualFormat = get_image_format(image->InternalFormat);
+         actualFormat = _mesa_get_shader_image_format(image->InternalFormat);
 
          if (actualFormat == MESA_FORMAT_NONE) {
             /* The ARB_multi_bind spec says:
index 733ac774777fff6826125cd4ca03e64737e5cac2..4aa859ca5cccaa73aa55c9c8a44b24415bb1310e 100644 (file)
 #define SHADERIMAGE_H
 
 #include "glheader.h"
+#include "formats.h"
 
 struct gl_context;
 
+/**
+ * Get the matching mesa_format for a shader image format GL enum.
+ */
+mesa_format
+_mesa_get_shader_image_format(GLenum format);
+
 /**
  * Recalculate the \c _Valid flag of a context's shader image units.
  *