diff options
author | Jouk <joukj@tarantella.(none)> | 2007-06-08 13:38:24 +0200 |
---|---|---|
committer | Jouk <joukj@tarantella.(none)> | 2007-06-08 13:38:24 +0200 |
commit | 55f8b7053065ce88296608071feed6f9540f6c0d (patch) | |
tree | 86ac301ed5805c895985040caf56f857de017233 /src/mesa/tnl | |
parent | 518f9168862b2096278ae14a65c8c854c208e004 (diff) | |
parent | 7b559a91028d297b34df9ec939bd4d00fad6027c (diff) |
Merge branch 'master' of git+ssh://[email protected]/git/mesa/mesa
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_vb_fog.c | 29 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_points.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_vp_build.c | 23 |
3 files changed, 43 insertions, 19 deletions
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 5440ff7894d..f6518500d80 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -114,7 +114,7 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in) else d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { - const GLfloat z = FABSF(*v); + const GLfloat z = *v; GLfloat f = (end - z) * d; data[i][0] = CLAMP(f, 0.0F, 1.0F); } @@ -122,14 +122,14 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in) case GL_EXP: d = ctx->Fog.Density; for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) { - const GLfloat z = FABSF(*v); + const GLfloat z = *v; NEG_EXP( data[i][0], d * z ); } break; case GL_EXP2: d = ctx->Fog.Density*ctx->Fog.Density; for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { - const GLfloat z = FABSF(*v); + const GLfloat z = *v; NEG_EXP( data[i][0], d * z * z ); } break; @@ -153,6 +153,8 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { + GLuint i; + GLfloat *coord; /* Fog is computed from vertex or fragment Z values */ /* source = VB->ObjPtr or VB->EyePtr coords */ /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */ @@ -168,6 +170,8 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) input = &store->fogcoord; /* NOTE: negate plane here so we get positive fog coords! */ + /* NOTE2: this doesn't always work (tests/fog - all frag depth fog + coords will be negative). */ plane[0] = -m[2]; plane[1] = -m[6]; plane[2] = -m[10]; @@ -180,18 +184,29 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) VB->ObjPtr, plane ); input->count = VB->ObjPtr->count; + + /* make sure coords are really positive + NOTE should avoid going through array twice */ + coord = input->start; + for (i = 0; i < input->count; i++) { + input->data[i][0] = FABSF(*coord); + STRIDE_F(coord, input->stride); + } } else { /* fog coordinates = eye Z coordinates (use ABS later) */ - input = &store->input; + input = &store->fogcoord; if (VB->EyePtr->size < 2) _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 ); - input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]); - input->start = VB->EyePtr->start+2; - input->stride = VB->EyePtr->stride; + input->stride = 4 * sizeof(GLfloat); input->count = VB->EyePtr->count; + coord = VB->EyePtr->start; + for (i = 0 ; i < VB->EyePtr->count; i++) { + input->data[i][0] = FABSF(coord[2]); + STRIDE_F(coord, VB->EyePtr->stride); + } } } else { diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 9327f8c273c..1ac14fedf99 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -50,7 +50,8 @@ run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) { struct point_stage_data *store = POINT_STAGE_DATA(stage); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data; + const GLfloat *eyeCoord = (GLfloat *) VB->EyePtr->data + 2; + const GLint eyeCoordStride = VB->EyePtr->stride / sizeof(GLfloat); const GLfloat p0 = ctx->Point.Params[0]; const GLfloat p1 = ctx->Point.Params[1]; const GLfloat p2 = ctx->Point.Params[2]; @@ -59,10 +60,11 @@ run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) GLuint i; for (i = 0; i < VB->Count; i++) { - const GLfloat dist = FABSF(eye[i][2]); + const GLfloat dist = FABSF(*eyeCoord); const GLfloat q = p0 + dist * (p1 + dist * p2); const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0; size[i][0] = pointSize * atten; /* clamping done in rasterization */ + eyeCoord += eyeCoordStride; } VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize; diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index dff062a417c..2a1cae77f29 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1103,7 +1103,9 @@ static void build_fog( struct tnl_program *p ) { struct ureg fog = register_output(p, VERT_RESULT_FOGC); struct ureg input; - + GLuint useabs = p->state->fog_source_is_depth && p->state->fog_mode && + (p->state->fog_mode != FOG_EXP2); + if (p->state->fog_source_is_depth) { input = swizzle1(get_eye_position(p), Z); } @@ -1111,31 +1113,36 @@ static void build_fog( struct tnl_program *p ) input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); } - if (p->state->tnl_do_vertex_fog) { + if (p->state->fog_mode && p->state->tnl_do_vertex_fog) { struct ureg params = register_param2(p, STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED); struct ureg tmp = get_temp(p); + if (useabs) { + emit_op1(p, OPCODE_ABS, tmp, 0, input); + } + switch (p->state->fog_mode) { case FOG_LINEAR: { struct ureg id = get_identity_param(p); - emit_op3(p, OPCODE_MAD, tmp, 0, input, swizzle1(params,X), swizzle1(params,Y)); + emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input, + swizzle1(params,X), swizzle1(params,Y)); emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */ emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W)); break; } case FOG_EXP: - emit_op1(p, OPCODE_ABS, tmp, 0, input); - emit_op2(p, OPCODE_MUL, tmp, 0, tmp, swizzle1(params,Z)); + emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input, + swizzle1(params,Z)); emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); break; case FOG_EXP2: emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W)); - emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); + emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); break; } - + release_temp(p, tmp); } else { @@ -1143,7 +1150,7 @@ static void build_fog( struct tnl_program *p ) * * KW: Is it really necessary to do anything in this case? */ - emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input); + emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input); } } |