From bb372f1c9bc08e8b0dca983cb4ba36b2f2f039fb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 16 May 2007 15:34:22 -0700 Subject: Initial implementation of MESA_texture_array Shadow sampling from texture arrays is still not implemented. Everything else should be there, though. --- src/mesa/main/texobj.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'src/mesa/main/texobj.c') diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 56d816e45f..bd447ac068 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -104,7 +104,9 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj, target == GL_TEXTURE_2D || target == GL_TEXTURE_3D || target == GL_TEXTURE_CUBE_MAP_ARB || - target == GL_TEXTURE_RECTANGLE_NV); + target == GL_TEXTURE_RECTANGLE_NV || + target == GL_TEXTURE_1D_ARRAY_EXT || + target == GL_TEXTURE_2D_ARRAY_EXT); _mesa_bzero(obj, sizeof(*obj)); /* init the non-zero fields */ @@ -279,11 +281,13 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, } /* Compute _MaxLevel */ - if (t->Target == GL_TEXTURE_1D) { + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { maxLog2 = t->Image[0][baseLevel]->WidthLog2; maxLevels = ctx->Const.MaxTextureLevels; } - else if (t->Target == GL_TEXTURE_2D) { + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, t->Image[0][baseLevel]->HeightLog2); maxLevels = ctx->Const.MaxTextureLevels; @@ -365,7 +369,8 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, } /* Test things which depend on number of texture image dimensions */ - if (t->Target == GL_TEXTURE_1D) { + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { /* Test 1-D mipmaps */ GLuint width = t->Image[0][baseLevel]->Width2; for (i = baseLevel + 1; i < maxLevels; i++) { @@ -389,7 +394,8 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, } } } - else if (t->Target == GL_TEXTURE_2D) { + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { /* Test 2-D mipmaps */ GLuint width = t->Image[0][baseLevel]->Width2; GLuint height = t->Image[0][baseLevel]->Height2; @@ -652,6 +658,14 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) curr = &unit->CurrentRect; unit->CurrentRect = ctx->Shared->DefaultRect; } + else if (texObj == unit->Current1DArray) { + curr = &unit->Current1DArray; + unit->CurrentRect = ctx->Shared->Default1DArray; + } + else if (texObj == unit->Current2DArray) { + curr = &unit->Current1DArray; + unit->CurrentRect = ctx->Shared->Default2DArray; + } if (curr) { (*curr)->RefCount++; @@ -796,6 +810,20 @@ _mesa_BindTexture( GLenum target, GLuint texName ) } oldTexObj = texUnit->CurrentRect; break; + case GL_TEXTURE_1D_ARRAY_EXT: + if (!ctx->Extensions.MESA_texture_array) { + _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); + return; + } + oldTexObj = texUnit->Current1DArray; + break; + case GL_TEXTURE_2D_ARRAY_EXT: + if (!ctx->Extensions.MESA_texture_array) { + _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); + return; + } + oldTexObj = texUnit->Current2DArray; + break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); return; @@ -832,6 +860,12 @@ _mesa_BindTexture( GLenum target, GLuint texName ) case GL_TEXTURE_RECTANGLE_NV: newTexObj = ctx->Shared->DefaultRect; break; + case GL_TEXTURE_1D_ARRAY_EXT: + newTexObj = ctx->Shared->Default1DArray; + break; + case GL_TEXTURE_2D_ARRAY_EXT: + newTexObj = ctx->Shared->Default2DArray; + break; default: ; /* Bad targets are caught above */ } @@ -902,6 +936,12 @@ _mesa_BindTexture( GLenum target, GLuint texName ) case GL_TEXTURE_RECTANGLE_NV: texUnit->CurrentRect = newTexObj; break; + case GL_TEXTURE_1D_ARRAY_EXT: + texUnit->Current1DArray = newTexObj; + break; + case GL_TEXTURE_2D_ARRAY_EXT: + texUnit->Current2DArray = newTexObj; + break; default: _mesa_problem(ctx, "bad target in BindTexture"); return; -- cgit v1.2.3