[Mesa-dev] [PATCH 10/14] mesa/main: Maintain compressed fog mode.
Gustaw Smolarczyk
wielkiegie at gmail.com
Fri Apr 7 16:54:36 UTC 2017
2017-04-07 16:31 GMT+02:00 Marek Olšák <maraeo at gmail.com>:
> On Thu, Mar 30, 2017 at 8:09 PM, Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
>> Signed-off-by: Gustaw Smolarczyk <wielkiegie at gmail.com>
>> ---
>> src/mesa/main/enable.c | 1 +
>> src/mesa/main/fog.c | 9 +++++++++
>> src/mesa/main/mtypes.h | 14 ++++++++++++++
>> 3 files changed, 24 insertions(+)
>>
>> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
>> index d9d63a6b4b..ef278a318a 100644
>> --- a/src/mesa/main/enable.c
>> +++ b/src/mesa/main/enable.c
>> @@ -385,6 +385,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
>> return;
>> FLUSH_VERTICES(ctx, _NEW_FOG);
>> ctx->Fog.Enabled = state;
>> + ctx->Fog._PackedEnabledMode = state ? ctx->Fog._PackedMode : FOG_NONE;
>> break;
>> case GL_LIGHT0:
>> case GL_LIGHT1:
>> diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
>> index 1ad939cfde..76e65080b7 100644
>> --- a/src/mesa/main/fog.c
>> +++ b/src/mesa/main/fog.c
>> @@ -102,8 +102,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
>> m = (GLenum) (GLint) *params;
>> switch (m) {
>> case GL_LINEAR:
>> + ctx->Fog._PackedMode = FOG_LINEAR;
>> + break;
>> case GL_EXP:
>> + ctx->Fog._PackedMode = FOG_EXP;
>> + break;
>> case GL_EXP2:
>> + ctx->Fog._PackedMode = FOG_EXP2;
>
> Perhaps these should be set before FLUSH_VERTICES?
>
> Marek
That would make us need two switch() statements instead of one. Also,
if ctx->Fog.Mode == m then we are essentially writing the same values
so nothing changes - doing it after the check shouldn't affect
correctness in any way. I might be wrong, though. _PackedMode is only
ever used to manage _PackedEnabledMode (here and in _mesa_set_enable),
so I think we should be safe.
Since this simplification is pretty minor, I can change the code if you want.
Gustaw
More information about the mesa-dev
mailing list