X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_vb_texgen.c;h=bd585324e2b53b1b18aef4ae3463e29c40ae5c5a;hb=39d0c68321dfb592afc1f6f63d90d5508cdf7333;hp=9ef13bc96d87cadb66f2f604779b30dbf77b9c3b;hpb=a5585cb533af3d4e5d5324d5f526447b98597402;p=mesa.git diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index 9ef13bc96d8..bd585324e2b 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 6.5 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -17,13 +16,13 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. * * Authors: - * Brian Paul - * Keith Whitwell + * Brian Paul Keith Whitwell */ /* @@ -35,9 +34,8 @@ * including any use thereof or modifications thereto. */ +#include "main/errors.h" #include "main/glheader.h" -#include "main/colormac.h" -#include "main/context.h" #include "main/macros.h" #include "main/imports.h" #include "main/mtypes.h" @@ -55,7 +53,7 @@ struct texgen_stage_data; -typedef void (*texgen_func)( GLcontext *ctx, +typedef void (*texgen_func)( struct gl_context *ctx, struct texgen_stage_data *store, GLuint unit); @@ -118,7 +116,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * _mesa_inv_sqrtf(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } @@ -147,7 +145,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * _mesa_inv_sqrtf(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } @@ -249,7 +247,7 @@ static build_f_func build_f_tab[5] = { /* Special case texgen functions. */ -static void texgen_reflection_map_nv( GLcontext *ctx, +static void texgen_reflection_map_nv( struct gl_context *ctx, struct texgen_stage_data *store, GLuint unit ) { @@ -271,7 +269,7 @@ static void texgen_reflection_map_nv( GLcontext *ctx, -static void texgen_normal_map_nv( GLcontext *ctx, +static void texgen_normal_map_nv( struct gl_context *ctx, struct texgen_stage_data *store, GLuint unit ) { @@ -299,7 +297,7 @@ static void texgen_normal_map_nv( GLcontext *ctx, } -static void texgen_sphere_map( GLcontext *ctx, +static void texgen_sphere_map( struct gl_context *ctx, struct texgen_stage_data *store, GLuint unit ) { @@ -332,7 +330,7 @@ static void texgen_sphere_map( GLcontext *ctx, -static void texgen( GLcontext *ctx, +static void texgen( struct gl_context *ctx, struct texgen_stage_data *store, GLuint unit ) { @@ -340,7 +338,8 @@ static void texgen( GLcontext *ctx, struct vertex_buffer *VB = &tnl->vb; GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit]; GLvector4f *out = &store->texcoord[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + const struct gl_fixedfunc_texture_unit *texUnit = + &ctx->Texture.FixedFuncUnit[unit]; const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS]; const GLvector4f *eye = VB->EyePtr; const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; @@ -481,7 +480,7 @@ static void texgen( GLcontext *ctx, -static GLboolean run_texgen_stage( GLcontext *ctx, +static GLboolean run_texgen_stage( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; @@ -492,10 +491,10 @@ static GLboolean run_texgen_stage( GLcontext *ctx, return GL_TRUE; for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + struct gl_fixedfunc_texture_unit *texUnit = + &ctx->Texture.FixedFuncUnit[i]; if (texUnit->TexGenEnabled) { - store->TexgenFunc[i]( ctx, store, i ); VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i]; @@ -506,7 +505,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx, } -static void validate_texgen_stage( GLcontext *ctx, +static void validate_texgen_stage( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) { struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); @@ -516,7 +515,8 @@ static void validate_texgen_stage( GLcontext *ctx, return; for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + struct gl_fixedfunc_texture_unit *texUnit = + &ctx->Texture.FixedFuncUnit[i]; if (texUnit->TexGenEnabled) { GLuint sz; @@ -556,14 +556,14 @@ static void validate_texgen_stage( GLcontext *ctx, /* Called the first time stage->run() is invoked. */ -static GLboolean alloc_texgen_data( GLcontext *ctx, +static GLboolean alloc_texgen_data( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct texgen_stage_data *store; GLuint i; - stage->privatePtr = CALLOC(sizeof(*store)); + stage->privatePtr = calloc(1, sizeof(*store)); store = TEXGEN_STAGE_DATA(stage); if (!store) return GL_FALSE; @@ -571,8 +571,8 @@ static GLboolean alloc_texgen_data( GLcontext *ctx, for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); - store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3); - store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat)); + store->tmp_f = malloc(VB->Size * sizeof(GLfloat) * 3); + store->tmp_m = malloc(VB->Size * sizeof(GLfloat)); return GL_TRUE; } @@ -590,9 +590,9 @@ static void free_texgen_data( struct tnl_pipeline_stage *stage ) _mesa_vector4f_free( &store->texcoord[i] ); - if (store->tmp_f) FREE( store->tmp_f ); - if (store->tmp_m) FREE( store->tmp_m ); - FREE( store ); + free( store->tmp_f ); + free( store->tmp_m ); + free( store ); stage->privatePtr = NULL; } }