|
|
@@ -57,9 +57,7 @@ struct state_key { |
|
|
|
unsigned rescale_normals:1; |
|
|
|
|
|
|
|
unsigned fog_source_is_depth:1; |
|
|
|
unsigned tnl_do_vertex_fog:1; |
|
|
|
unsigned separate_specular:1; |
|
|
|
unsigned fog_mode:2; |
|
|
|
unsigned point_attenuated:1; |
|
|
|
unsigned point_array:1; |
|
|
|
unsigned texture_enabled_global:1; |
|
|
@@ -83,23 +81,6 @@ struct state_key { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FOG_NONE 0 |
|
|
|
#define FOG_LINEAR 1 |
|
|
|
#define FOG_EXP 2 |
|
|
|
#define FOG_EXP2 3 |
|
|
|
|
|
|
|
static GLuint translate_fog_mode( GLenum mode ) |
|
|
|
{ |
|
|
|
switch (mode) { |
|
|
|
case GL_LINEAR: return FOG_LINEAR; |
|
|
|
case GL_EXP: return FOG_EXP; |
|
|
|
case GL_EXP2: return FOG_EXP2; |
|
|
|
default: return FOG_NONE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define TXG_NONE 0 |
|
|
|
#define TXG_OBJ_LINEAR 1 |
|
|
|
#define TXG_EYE_LINEAR 2 |
|
|
@@ -124,21 +105,6 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Should fog be computed per-vertex? |
|
|
|
*/ |
|
|
|
static GLboolean |
|
|
|
tnl_get_per_vertex_fog(GLcontext *ctx) |
|
|
|
{ |
|
|
|
#if 0 |
|
|
|
TNLcontext *tnl = TNL_CONTEXT(ctx); |
|
|
|
return tnl->_DoVertexFog; |
|
|
|
#else |
|
|
|
return GL_FALSE; |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static GLboolean check_active_shininess( GLcontext *ctx, |
|
|
|
const struct state_key *key, |
|
|
|
GLuint side ) |
|
|
@@ -234,12 +200,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) |
|
|
|
if (ctx->Transform.RescaleNormals) |
|
|
|
key->rescale_normals = 1; |
|
|
|
|
|
|
|
key->fog_mode = translate_fog_mode(fp->FogOption); |
|
|
|
|
|
|
|
if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) |
|
|
|
key->fog_source_is_depth = 1; |
|
|
|
|
|
|
|
key->tnl_do_vertex_fog = tnl_get_per_vertex_fog(ctx); |
|
|
|
|
|
|
|
if (ctx->Point._Attenuated) |
|
|
|
key->point_attenuated = 1; |
|
|
@@ -1344,52 +1306,10 @@ static void build_fog( struct tnl_program *p ) |
|
|
|
input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
GLboolean useabs = (p->state->fog_mode != FOG_EXP2); |
|
|
|
|
|
|
|
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, 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_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_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
release_temp(p, tmp); |
|
|
|
} |
|
|
|
else { |
|
|
|
/* results = incoming fog coords (compute fog per-fragment later) |
|
|
|
* |
|
|
|
* KW: Is it really necessary to do anything in this case? |
|
|
|
* BP: Yes, we always need to compute the absolute value, unless |
|
|
|
* we want to push that down into the fragment program... |
|
|
|
*/ |
|
|
|
GLboolean useabs = GL_TRUE; |
|
|
|
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input); |
|
|
|
} |
|
|
|
emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void build_reflect_texgen( struct tnl_program *p, |
|
|
|
struct ureg dest, |
|
|
|
GLuint writemask ) |
|
|
@@ -1646,8 +1566,7 @@ static void build_tnl_program( struct tnl_program *p ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ((p->state->fragprog_inputs_read & FRAG_BIT_FOGC) || |
|
|
|
p->state->fog_mode != FOG_NONE) |
|
|
|
if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC) |
|
|
|
build_fog(p); |
|
|
|
|
|
|
|
if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY) |