From: Brian Date: Thu, 16 Aug 2007 01:23:58 +0000 (-0600) Subject: translate GL texture targets to PIPE_TEXTURE_x values X-Git-Tag: 062012170305~17580^2~390^2~4300 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5390a43ce06b27f6d54bc5f237aa305b6948f2af;p=profile%2Fivi%2Fmesa.git translate GL texture targets to PIPE_TEXTURE_x values --- diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index f633bd3..770c871 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -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, diff --git a/src/mesa/state_tracker/st_mipmap_tree.c b/src/mesa/state_tracker/st_mipmap_tree.c index 3cbe697..535004c 100644 --- a/src/mesa/state_tracker/st_mipmap_tree.c +++ b/src/mesa/state_tracker/st_mipmap_tree.c @@ -30,10 +30,12 @@ #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;