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

Author: Courtney Goeltzenleuchter <court...@lunarg.com>
Date:   Wed Nov  6 14:40:31 2013 -0700

mesa: add texture_view helper function for TexStorage

Add helper function to set texture_view state from TexStorage calls.
Include review feedback.

Signed-off-by: Courtney Goeltzenleuchter <court...@lunarg.com>

Reviewed-by: Brian Paul <bri...@vmware.com>

---

 src/mesa/main/textureview.c |   61 +++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/textureview.h |    4 +++
 2 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 1094993..5c08b1a 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -346,6 +346,67 @@ compatible_format(struct gl_context *ctx, const struct 
gl_texture_object *origTe
                _mesa_lookup_enum_by_nr(origInternalFormat));
    return false;
 }
+/**
+ * Helper function for TexStorage and teximagemultisample to set immutable
+ * texture state needed by ARB_texture_view.
+ */
+void
+_mesa_set_texture_view_state(struct gl_context *ctx,
+                             struct gl_texture_object *texObj,
+                             GLenum target, GLuint levels)
+{
+   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);
+
+   /* When an immutable texture is created via glTexStorage or 
glTexImageMultisample,
+    * 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..3088ac1 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
+_mesa_set_texture_view_state(struct gl_context *ctx, struct gl_texture_object 
*texObj,
+                       GLenum target, GLuint levels);
+
 #endif /* TEXTUREVIEW_H */

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

Reply via email to