[Piglit] [PATCH] arb_texture_query_lod: allow some tolerance for comparisons

Marek Olšák maraeo at gmail.com
Wed Jun 18 11:19:27 PDT 2014


On Wed, Jun 18, 2014 at 6:47 AM, Matt Turner <mattst88 at gmail.com> wrote:
> I'm sort of skeptical. Firstly, why are you only modifying three of
> the four tests?

I only modified the conditionals which need changes for radeonsi. I
didn't modify all of them.

>
> On Tue, Jun 17, 2014 at 12:49 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> This is required for radeonsi to pass.
>> ---
>>  .../execution/fs-textureQueryLOD-linear.shader_test              | 9 +++++++--
>>  .../execution/fs-textureQueryLOD-nearest.shader_test             | 6 +++++-
>>  .../execution/fs-textureQueryLOD-no-mipmap.shader_test           | 6 +++++-
>>  3 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
>> index 4438951..6afef71 100644
>> --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
>> +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
>> @@ -46,11 +46,16 @@ GL_ARB_texture_query_lod
>>  #extension GL_ARB_texture_query_lod : enable
>>  uniform sampler2D tex;
>>  uniform float lod;
>> +
>> +#define tolerance (1.0/255.0)
>> +#define equal_v4(x,y) all(lessThanEqual(abs((x) - (y)), vec4(tolerance)))
>> +#define equal(x,y) (abs((x) - (y)) <= tolerance)
>> +
>>  void main()
>>  {
>>      vec4 frag1 = texture(tex, gl_TexCoord[0].st);
>>      vec4 frag2 = textureLod(tex, gl_TexCoord[0].st, lod);
>> -    if (frag1 != frag2) {
>
> It's been a while since I wrote these, so I might not remember, but
> aren't the squares drawn the exact size of the mip-levels? How could
> texture() and textureLod not return the same thing?

The differences seem to be rounding errors. I don't know why the
hardware returns imprecise values.

>
>> +    if (!equal_v4(frag1, frag2)) {
>>         discard;
>>      }
>>
>> @@ -58,7 +63,7 @@ void main()
>>      if (queried_lod.x != queried_lod.y) {
>>         discard;
>>      }
>> -    if (queried_lod.x != lod) {
>> +    if (!equal(queried_lod.x, lod)) {
>>         discard;
>>      }
>>
>> diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
>> index 2c1b62c..a9df764 100644
>> --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
>> +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
>> @@ -46,6 +46,10 @@ GL_ARB_texture_query_lod
>>  #extension GL_ARB_texture_query_lod : enable
>>  uniform sampler2D tex;
>>  uniform float lod;
>> +
>> +#define tolerance (1.0/255.0)
>> +#define equal(x,y) (abs((x) - (y)) <= tolerance)
>> +
>>  void main()
>>  {
>>      /* The ARB_texture_query_lod spec says that if TEXTURE_MIN_FILTER is set
>> @@ -64,7 +68,7 @@ void main()
>>      }
>>
>>      vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st);
>> -    if (queried_lod.x != queried_lod.y) {
>> +    if (!equal(queried_lod.x, queried_lod.y)) {
>
> What does textureQueryLod actually return for you?
>
> The man page says textureQueryLOD returns
>
> "The mipmap array(s) that would be accessed is returned in the
> xcomponent of the return value. The computed level-of-detail relative
> to the base level is returned in the y component of the return value."
>
> And this is the nearest test, so we're not even blending between
> levels. How could these be different?

I don't know. This is textureQueryLOD multiplied by 0.1 and stored in
the colorbuffer for various mipmap levels. The "nearest" test is used:

0.000000 0.000000 // 0
0.098039 0.098039 // 1
0.200000 0.200000 // 2
0.298039 0.298039 // 3

But some quads return this:
0.298039 0.301961 // 3

I have no explanation.

Marek


More information about the Piglit mailing list