[Mesa-dev] [PATCH 1/1] mesa: Properly set the fog scale (gl_Fog.scale) to +INF when fog start and end are equal.

Kenneth Graunke kenneth at whitecape.org
Wed Aug 21 23:44:35 PDT 2013


On 08/21/2013 03:31 PM, Ian Romanick wrote:
> On 08/17/2013 10:42 AM, Henri Verbeet wrote:
>> This was originally introduced by commit
>> ba47aabc9868b410cdfe3bc8b6d25a44a598cba2, but unfortunately the commit
>> message
>> doesn't go into much detail about why +INF would be a problem here. I
>> don't
>> see anything in the spec that would allow 1.0f here.
>
> Section 2.1.1 (Floating-point computation) says:
>
>      "The result of providing a value that is not a floating-point
>      number to such a command is unspecified, but must not lead to
>      GL interruption or termination. In IEEE arithmetic, for
>      example, providing a negative zero or a denormalized number
>      to a GL command yields predictable results, while providing a
>      NaN or an infinity yields unspecified results."
>
> I /think/ this qualifies for the "unspecified results" clause.  An
> argument could probably be made the other way, however.
>
>> A similar issue exists for STATE_FOG_PARAMS_OPTIMIZED, but allowing
>> infinity
>> there would potentially introduce NaNs where they shouldn't exist,
>> depending
>> on the values of fog end and the fog coord. Since
>> STATE_FOG_PARAMS_OPTIMIZED
>> is only used for fixed function (including ARB_fragment_program with fog
>> option), and the calculation there probably isn't very stable to begin
>> with
>> when fog start and end are close together, it seems best to just leave it
>> alone.
>>
>> This fixes a couple of Wine D3D tests. No piglit changes on Cayman.
>
> Have you tried it on older GPUs?  r300?  i915?  Could we get a simple
> piglit test case that reproduces the issue?
>
> It seems like there were some old ATI GPUs that didn't have a
> representation for INF... and would do something stupid if you tried to
> feed them INF.  Modern GPUs just use IEEE, so they do the right thing.

FWIW i965 still doesn't use proper IEEE mode for ARB fragment programs 
due to the silly pow 0^0 rules.  I don't know if that matters here.

--Ken


More information about the mesa-dev mailing list