On 11/19/2013 04:16 PM, Courtney Goeltzenleuchter wrote:
Add helper function to set texture_view state from TexStorage calls.

Signed-off-by: Courtney Goeltzenleuchter <court...@lunarg.com>
---
  src/mesa/main/textureview.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
  src/mesa/main/textureview.h |  4 +++
  2 files changed, 63 insertions(+)

diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 1858465..a25b928 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -379,6 +379,65 @@ compatible_format(struct gl_context *ctx, struct 
gl_texture_object *origTexObj,
                 _mesa_lookup_enum_by_nr(origInternalFormat));
     return GL_FALSE;
  }
+/**
+ * Helper function for TexStorage to set TextureView state
+ */

Could you put a bit more info into that comment?

+void
+set_texture_view_state(struct gl_context *ctx, struct gl_texture_object 
*texObj,
+                       GLenum target, GLuint levels)

non-static functions should be prefixed with "_mesa_".


+{
+   struct gl_texture_image *texImage;
+
+   /* Get a reference to what will become this View's base level */
+   texImage = _mesa_select_tex_image(ctx, texObj, target, 0);

Early return if texImage is NULL (out of memory, etc?)?


+
+   /* If the command is successful,

If what command is successful?  glTexStorage()?


+    * TEXTURE_IMMUTABLE_FORMAT becomes TRUE.
+    * TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become levels.
+    * If the texture target is TEXTURE_1D_ARRAY then
+    * TEXTURE_VIEW_NUM_LAYERS becomes height.
+    * If the texture target is TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY,
+    * or TEXTURE_2D_MULTISAMPLE_ARRAY then TEXTURE_VIEW_NUM_LAYERS becomes 
depth.
+    * If the texture target is TEXTURE_CUBE_MAP, then
+    * TEXTURE_VIEW_NUM_LAYERS becomes 6.
+    * For any other texture target, TEXTURE_VIEW_NUM_LAYERS becomes 1.
+    *
+    * ARB_texture_multisample: Multisample textures do
+    * not have multiple image levels.
+    */
+
+   texObj->Immutable = GL_TRUE;
+   texObj->ImmutableLevels = levels;
+   texObj->MinLevel = 0;
+   texObj->NumLevels = levels;
+   texObj->MinLayer = 0;
+   texObj->NumLayers = 1;
+   switch (target) {
+   case GL_TEXTURE_1D_ARRAY:
+      texObj->NumLayers = texImage->Height;
+      break;
+
+   case GL_TEXTURE_2D_MULTISAMPLE:
+      texObj->NumLevels = 1;
+      texObj->ImmutableLevels = 1;
+      break;
+
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+      texObj->NumLevels = 1;
+      texObj->ImmutableLevels = 1;
+      /* fall through to set NumLayers */
+
+   case GL_TEXTURE_2D_ARRAY:
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+      texObj->NumLayers = texImage->Depth;
+      break;
+
+   case GL_TEXTURE_CUBE_MAP:
+      texObj->NumLayers = 6;
+      break;
+
+   }
+}

  /**
   * glTextureView (ARB_texture_view)
diff --git a/src/mesa/main/textureview.h b/src/mesa/main/textureview.h
index c2f0f32..36a8ed3 100644
--- a/src/mesa/main/textureview.h
+++ b/src/mesa/main/textureview.h
@@ -36,4 +36,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint 
origtexture,
                    GLuint minlevel, GLuint numlevels,
                    GLuint minlayer, GLuint numlayers);

+extern void
+set_texture_view_state(struct gl_context *ctx, struct gl_texture_object 
*texObj,
+                       GLenum target, GLuint levels);
+
  #endif /* TEXTUREVIEW_H */


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to