translate GL texture targets to PIPE_TEXTURE_x values
authorBrian <brian.paul@tungstengraphics.com>
Thu, 16 Aug 2007 01:23:58 +0000 (19:23 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 16 Aug 2007 01:23:58 +0000 (19:23 -0600)
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_mipmap_tree.c

index f633bd328f9f63ff8deab3ed09c772d3742cdfee..770c87143448dd634deae5e99e166480024ceae4 100644 (file)
@@ -114,6 +114,30 @@ st_get_texobj_mipmap_tree(struct gl_texture_object *texObj)
 }
 
 
+static unsigned
+gl_target_to_pipe(GLenum target)
+{
+   switch (target) {
+   case GL_TEXTURE_1D:
+      return PIPE_TEXTURE_1D;
+
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE_NV:
+      return PIPE_TEXTURE_2D;
+
+   case GL_TEXTURE_3D:
+      return PIPE_TEXTURE_3D;
+
+   case GL_TEXTURE_CUBE_MAP_ARB:
+      return PIPE_TEXTURE_CUBE;
+
+   default:
+      assert(0);
+      return 0;
+   }
+}
+
+
 static int
 compressed_num_bytes(GLuint mesaFormat)
 {
@@ -360,15 +384,15 @@ guess_and_alloc_mipmap_tree(struct pipe_context *pipe,
    if (stImage->base.IsCompressed)
       comp_byte = compressed_num_bytes(stImage->base.TexFormat->MesaFormat);
    stObj->mt = st_miptree_create(pipe,
-                                       stObj->base.Target,
-                                       stImage->base.InternalFormat,
-                                       firstLevel,
-                                       lastLevel,
-                                       width,
-                                       height,
-                                       depth,
-                                       stImage->base.TexFormat->TexelBytes,
-                                       comp_byte);
+                                 gl_target_to_pipe(stObj->base.Target),
+                                 stImage->base.InternalFormat,
+                                 firstLevel,
+                                 lastLevel,
+                                 width,
+                                 height,
+                                 depth,
+                                 stImage->base.TexFormat->TexelBytes,
+                                 comp_byte);
 
    stObj->mt->format
       = st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat);
@@ -587,7 +611,7 @@ st_TexImage(GLcontext * ctx,
    if (stObj->mt &&
        stObj->mt->first_level == level &&
        stObj->mt->last_level == level &&
-       stObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
+       stObj->mt->target != PIPE_TEXTURE_CUBE &&
        !st_miptree_match_image(stObj->mt, &stImage->base,
                                   stImage->face, stImage->level)) {
 
@@ -1476,7 +1500,7 @@ st_finalize_mipmap_tree(GLcontext *ctx,
     * leaving the tree alone.
     */
    if (stObj->mt &&
-       (stObj->mt->target != stObj->base.Target ||
+       (stObj->mt->target != gl_target_to_pipe(stObj->base.Target) ||
        stObj->mt->internal_format != firstImage->base.InternalFormat ||
        stObj->mt->first_level != stObj->firstLevel ||
        stObj->mt->last_level != stObj->lastLevel ||
@@ -1493,7 +1517,7 @@ st_finalize_mipmap_tree(GLcontext *ctx,
     */
    if (!stObj->mt) {
       stObj->mt = st_miptree_create(pipe,
-                                    stObj->base.Target,
+                                    gl_target_to_pipe(stObj->base.Target),
                                     firstImage->base.InternalFormat,
                                     stObj->firstLevel,
                                     stObj->lastLevel,
index 3cbe697ab3faf08dce2a4abd2ad31f222af5c487..535004c892fe51c5fef8c983607e8f2b4cd1fd3c 100644 (file)
 
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
+#include "pipe/p_defines.h"
 
 
 #define DBG if(0) printf
 
+#if 0
 static GLenum
 target_to_target(GLenum target)
 {
@@ -49,10 +51,11 @@ target_to_target(GLenum target)
       return target;
    }
 }
+#endif
 
 struct pipe_mipmap_tree *
 st_miptree_create(struct pipe_context *pipe,
-                     GLenum target,
+                  unsigned target,
                      GLenum internal_format,
                      GLuint first_level,
                      GLuint last_level,
@@ -64,11 +67,13 @@ st_miptree_create(struct pipe_context *pipe,
    struct pipe_mipmap_tree *mt = calloc(sizeof(*mt), 1);
    GLbitfield flags = 0x0;
 
+   assert(target <= PIPE_TEXTURE_CUBE);
+
    DBG("%s target %s format %s level %d..%d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),
        _mesa_lookup_enum_by_nr(internal_format), first_level, last_level);
 
-   mt->target = target_to_target(target);
+   mt->target = target;
    mt->internal_format = internal_format;
    mt->first_level = first_level;
    mt->last_level = last_level;