Miklós Máté <mtm...@gmail.com> writes:

> On 21/11/17 21:09, Eric Anholt wrote:
>> Miklós Máté <mtm...@gmail.com> writes:
>>> +
>>> +   piglit_report_result(PIGLIT_PASS);
>>> +}
>>> diff --git a/tests/spec/ati_fragment_shader/error02-inside.c 
>>> b/tests/spec/ati_fragment_shader/error02-inside.c
>>> new file mode 100644
>>> index 000000000..5dee70cf6
>>> --- /dev/null
>>> +++ b/tests/spec/ati_fragment_shader/error02-inside.c
>>> @@ -0,0 +1,59 @@
>>> +/* TODO license header */
>>> +
>>> +/**
>>> + * Tests API errors for GL_ATI_fragment_shader.
>>> + * One for each paragraph in the Errors section.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> +   config.supports_gl_compat_version = 10;
>>> +   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> +   /* UNREACHED */
>>> +   return PIGLIT_FAIL;
>>> +}
>>> +
>>> +#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
>>> piglit_report_result(PIGLIT_FAIL)
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> +   piglit_require_extension("GL_ATI_fragment_shader");
>>> +
>>> +   /*
>>> +    * Paragraph 2 of the Errors section:
>>> +    *
>>> +    * The error INVALID_OPERATION is generated if GenFragmentShadersATI,
>>> +    * BindFragmentShaderATI, DeleteFragmentShaderATI, or
>>> +    * BeginFragmentShaderATI are specified inside a
>>> +    * Begin/EndFragmentShaderATI pair.
>>> +    */
>>> +
>>> +   glBeginFragmentShaderATI();
>>> +
>>> +   check_gl_error(GL_NO_ERROR);
>>> +   glGenFragmentShadersATI(1);
>>> +   check_gl_error(GL_INVALID_OPERATION);
>> Instead of the macro, we'll often have
>>
>> bool pass = true;
>>
>> ...
>>
>> pass = piglit_check_gl_error(GL_NO_ERROR) && pass
>> glGenFragmentShadersATI(1);
>> pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass
>>
>> ...
>>
>> piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>>
>> That way you get to see multiple errors if there are different cases
>> failing.
> First I did that, but I had a difficult time finding out where Mesa 
> failed to throw the expected error, so I made the check fatal. If people 
> prefer non-fatal checks I can change it back.
>

piglit_check_gl_error() prints the file and line number of the check
that failed, to help you find it.

I'm not requiring a change here, just suggesting a way this has been
handled elsewhere.

>>> +   check_gl_error(GL_NO_ERROR);
>> I'd drop the GL_NO_ERROR checks -- you know there's no error because the
>> last thing you did is check the errors.
> As far as I understand the errors are pushed into a stack. I do these no 
> error checks to make sure the stack is empty before the critical call. 
> If it's not possible for one gl call to push more than one error into 
> the stack, then the no error checks can indeed be trimmed down in this test.

You can see the path in _mesa_error() -> _mesa_record_error() -- it's
just a single value, not a stack.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to