[Piglit] [PATCH] texture-integer-glsl130: Make sure we use usampler for ui textures.

Eric Anholt eric at anholt.net
Mon Apr 30 18:02:01 UTC 2018


Ilia Mirkin <imirkin at alum.mit.edu> writes:

> On Thu, Apr 26, 2018 at 1:01 PM, Eric Anholt <eric at anholt.net> wrote:
>> Fixes failure on VC5 because we would sign-extend 16ui.  Sampling ui
>> with isampler is undefined according to the table under "8.7 Texture
>> Lookup Functions" in the 1.30 spec.
>> ---
>>  .../texture-integer-glsl130.c                 | 40 ++++++++++++-------
>>  1 file changed, 26 insertions(+), 14 deletions(-)
>>
>> diff --git a/tests/spec/ext_texture_integer/texture-integer-glsl130.c b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
>> index 2247207173a1..06332b66f2cf 100644
>> --- a/tests/spec/ext_texture_integer/texture-integer-glsl130.c
>> +++ b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
>> @@ -44,7 +44,7 @@ static const char *TestName = "texture-integer";
>>  static GLint TexWidth = 16, TexHeight = 16;
>>  static GLuint Texture;
>>
>> -static GLint BiasUniform = -1, TexUniform = -1;
>> +static GLint BiasUniform[2] = {-1, -1}, TexUniform[2] = {-1, -1};
>>
>>  struct format_info
>>  {
>> @@ -131,18 +131,28 @@ static const struct format_info rgb10_formats[] = {
>>         { GL_RGB10_A2UI, GL_BGRA_INTEGER_EXT, 10, GL_TRUE },
>>  };
>>
>> -static const char *FragShaderText =
>> +/* The programs will be indexed by whether the texture is signed or not. */
>> +static const char *FragShaderText[2] = {
>>         "#version 130\n"
>>         "uniform vec4 bias; \n"
>> -       "uniform isampler2D tex; \n"
>> +       "uniform usampler2D tex; \n"
>>         "void main() \n"
>>         "{ \n"
>>         "   vec4 t = vec4(texture(tex, gl_TexCoord[0].xy)); \n"
>>         "   gl_FragColor = t + bias; \n"
>> -       "} \n";
>> +       "} \n",
>>
>> -static GLuint Program;
>> +       "#version 130\n"
>> +       "uniform vec4 bias; \n"
>> +       "uniform isampler2D tex; \n"
>> +       "void main() \n"
>> +       "{ \n"
>> +       "   vec4 t = vec4(texture(tex, gl_TexCoord[0].xy)); \n"
>> +       "   gl_FragColor = t + bias; \n"
>> +       "} \n",
>> +};
>>
>> +static GLuint Program[2];
>>
>>  static int
>>  get_max_val(const struct format_info *info)
>> @@ -440,12 +450,14 @@ test_format(const struct format_info *info)
>>                 ;
>>         }
>>
>> +       glUseProgram(Program[info->Signed]);
>> +
>>         /* compute, set test bias */
>>         bias[0] = expected[0] - value[0];
>>         bias[1] = expected[1] - value[1];
>>         bias[2] = expected[2] - value[2];
>>         bias[3] = expected[3] - value[3];
>> -       glUniform4fv(BiasUniform, 1, bias);
>> +       glUniform4fv(BiasUniform[info->Signed], 1, bias);
>
> I'd feel very slightly better if this said BiasUniform[!!info->Signed]
> or some variant thereof (GL_TRUE is 1, but ... who knows). And same
> for Program[] above.
>
> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

No thanks.  true has always been 1, and won't change.  !! just makes
things more confusing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20180430/b3555d5d/attachment.sig>


More information about the Piglit mailing list