diff options
author | Marek Olšák <[email protected]> | 2011-02-15 23:30:23 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-03-29 12:04:55 +0200 |
commit | e5c6a92a12b5cd7db205d72039f58d302b0be9d5 (patch) | |
tree | 4131a362c087d9d8b45999e0bb3868b7ff2942f8 /src/mesa/program | |
parent | 3bdd12ecb57e9cdc2b21cd665fab14698c1c07df (diff) |
mesa: implement clamping controls (ARB_color_buffer_float)
Squashed commit of the following:
Author: Marek Olšák <[email protected]>
mesa: fix getteximage so that it doesn't clamp values
mesa: update the compute_version function
mesa: add display list support for ARB_color_buffer_float
mesa: fix glGet query with GL_ALPHA_TEST_REF and ARB_color_buffer_float
commit b2f6ddf907935b2594d2831ddab38cf57a1729ce
Author: Luca Barbieri <[email protected]>
Date: Tue Aug 31 16:50:57 2010 +0200
mesa: document known possible deviations from ARB_color_buffer_float
commit 5458935be800c1b19d1c9d1569dc4fa30a97e8b8
Author: Luca Barbieri <[email protected]>
Date: Tue Aug 24 21:54:56 2010 +0200
mesa: expose GL_ARB_color_buffer_float
commit aef5c3c6be6edd076e955e37c80905bc447f8a82
Author: Luca Barbieri <[email protected]>
Date: Thu Aug 26 18:12:34 2010 +0200
mesa, mesa/st: handle read color clamping properly
(I'll squash the st/mesa part to a separate commit. -Marek)
We set IMAGE_CLAMP_BIT in the caller based on _ClampReadColor, where
the operation mandates it.
TODO: did I get the set of operations mandating it right?
commit 3a9cb5e59b676b6148c50907ce6eef5441677e36
Author: Luca Barbieri <[email protected]>
Date: Thu Aug 26 18:09:41 2010 +0200
mesa: respect color clamping in texenv programs (v2)
Changes in v2:
- Fix attributes other than vertex color sometimes getting clamped
commit de26f9e47e886e176aab6e5a2c3d4481efb64362
Author: Luca Barbieri <[email protected]>
Date: Thu Aug 26 18:05:53 2010 +0200
mesa: restore color clamps on glPopAttrib
commit a55ac3c300c189616627c05d924c40a8b55bfafa
Author: Luca Barbieri <[email protected]>
Date: Thu Aug 26 18:04:26 2010 +0200
mesa: clamp color queries if and only if fragment clamping is enabled
commit 9940a3e31c2fb76cc3d28b15ea78dde369825107
Author: Luca Barbieri <[email protected]>
Date: Wed Aug 25 00:00:16 2010 +0200
mesa: introduce derived _ClampXxxColor state resolving FIXED_ONLY
To do this, we make ClampColor call FLUSH_VERTICES with the appropriate
_NEW flag.
We introduce _NEW_FRAG_CLAMP since fragment clamping has wide-ranging
effects, despite being in the Color attrib group.
This may be easily changed by s/_NEW_FRAG_CLAMP/_NEW_COLOR/g
commit 6244c446e3beed5473b4e811d10787e4019f59d6
Author: Luca Barbieri <[email protected]>
Date: Thu Aug 26 17:58:24 2010 +0200
mesa: add unclamped color parameters
Diffstat (limited to 'src/mesa/program')
-rw-r--r-- | src/mesa/program/arbprogparse.c | 5 | ||||
-rw-r--r-- | src/mesa/program/prog_statevars.c | 32 | ||||
-rw-r--r-- | src/mesa/program/prog_statevars.h | 1 | ||||
-rw-r--r-- | src/mesa/program/programopt.c | 5 | ||||
-rw-r--r-- | src/mesa/program/programopt.h | 2 |
5 files changed, 38 insertions, 7 deletions
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c index ca63e72c085..7f778c3c381 100644 --- a/src/mesa/program/arbprogparse.c +++ b/src/mesa/program/arbprogparse.c @@ -144,7 +144,10 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, * from the fragment shader. */ if (program->FogOption != GL_NONE) { - _mesa_append_fog_code(ctx, program); + /* XXX: we should somehow recompile this to remove clamping if disabled + * On the ATI driver, this is unclampled if fragment clamping is disabled + */ + _mesa_append_fog_code(ctx, program, GL_TRUE); program->FogOption = GL_NONE; } diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index c310acb01d4..384aa2cb2c6 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -237,11 +237,17 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], { /* state[1] is the texture unit */ const GLuint unit = (GLuint) state[1]; - COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); + if(ctx->Color._ClampFragmentColor) + COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); + else + COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped); } return; case STATE_FOG_COLOR: - COPY_4V(value, ctx->Fog.Color); + if(ctx->Color._ClampFragmentColor) + COPY_4V(value, ctx->Fog.Color); + else + COPY_4V(value, ctx->Fog.ColorUnclamped); return; case STATE_FOG_PARAMS: value[0] = ctx->Fog.Density; @@ -399,6 +405,22 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], } return; + case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: + { + const GLuint idx = (GLuint) state[2]; + if(ctx->Light._ClampVertexColor && + (idx == VERT_ATTRIB_COLOR0 || + idx == VERT_ATTRIB_COLOR1)) { + value[0] = CLAMP(ctx->Current.Attrib[idx][0], 0.0f, 1.0f); + value[1] = CLAMP(ctx->Current.Attrib[idx][1], 0.0f, 1.0f); + value[2] = CLAMP(ctx->Current.Attrib[idx][2], 0.0f, 1.0f); + value[3] = CLAMP(ctx->Current.Attrib[idx][3], 0.0f, 1.0f); + } + else + COPY_4V(value, ctx->Current.Attrib[idx]); + } + return; + case STATE_NORMAL_SCALE: ASSIGN_4V(value, ctx->_ModelViewInvScale, @@ -649,10 +671,12 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) return _NEW_LIGHT; case STATE_TEXGEN: - case STATE_TEXENV_COLOR: return _NEW_TEXTURE; + case STATE_TEXENV_COLOR: + return _NEW_TEXTURE | _NEW_BUFFERS | _NEW_FRAG_CLAMP; case STATE_FOG_COLOR: + return _NEW_FOG | _NEW_BUFFERS | _NEW_FRAG_CLAMP; case STATE_FOG_PARAMS: return _NEW_FOG; @@ -688,6 +712,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) switch (state[1]) { case STATE_CURRENT_ATTRIB: return _NEW_CURRENT_ATTRIB; + case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: + return _NEW_CURRENT_ATTRIB | _NEW_LIGHT | _NEW_BUFFERS; case STATE_NORMAL_SCALE: return _NEW_MODELVIEW; diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h index f2407af9c87..9fe8d81b3dd 100644 --- a/src/mesa/program/prog_statevars.h +++ b/src/mesa/program/prog_statevars.h @@ -106,6 +106,7 @@ typedef enum gl_state_index_ { STATE_INTERNAL, /* Mesa additions */ STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */ + STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, /* ctx->Current vertex attrib value after passthrough vertex processing */ STATE_NORMAL_SCALE, STATE_TEXRECT_SCALE, STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */ diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c index f92881f8337..5ad9571f757 100644 --- a/src/mesa/program/programopt.c +++ b/src/mesa/program/programopt.c @@ -238,7 +238,7 @@ _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog) * to vertex programs too. */ void -_mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog) +_mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog, GLboolean saturate) { static const gl_state_index fogPStateOpt[STATE_LENGTH] = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; @@ -290,7 +290,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog) /* change the instruction to write to colorTemp w/ clamping */ inst->DstReg.File = PROGRAM_TEMPORARY; inst->DstReg.Index = colorTemp; - inst->SaturateMode = SATURATE_ZERO_ONE; + inst->SaturateMode = saturate; /* don't break (may be several writes to result.color) */ } inst++; @@ -300,6 +300,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog) _mesa_init_instructions(inst, 5); /* emit instructions to compute fog blending factor */ + /* this is always clamped to [0, 1] regardless of fragment clamping */ if (fprog->FogOption == GL_LINEAR) { /* MAD fogFactorTemp.x, fragment.fogcoord.x, fogPRefOpt.x, fogPRefOpt.y; */ inst->Opcode = OPCODE_MAD; diff --git a/src/mesa/program/programopt.h b/src/mesa/program/programopt.h index ef6f1bd0794..79631aa5843 100644 --- a/src/mesa/program/programopt.h +++ b/src/mesa/program/programopt.h @@ -32,7 +32,7 @@ extern void _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog); extern void -_mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog); +_mesa_append_fog_code(struct gl_context *ctx, struct gl_fragment_program *fprog, GLboolean saturate); extern void _mesa_count_texture_indirections(struct gl_program *prog); |