[Piglit] [PATCH] egl: Test more invalid GLES2 context versions
Chad Versace
chad.versace at linux.intel.com
Tue Nov 6 12:51:04 PST 2012
On 11/06/2012 12:19 PM, Ian Romanick wrote:
> On 11/05/2012 02:53 PM, Chad Versace wrote:
>> In test egl-create-context-invalid-gl-version, try to create OpenGL ES2
>> contexts with additional invalid versions: 3.2, 3.9, 4.7.
>>
>> Fails with mesa-84b437 on Intel Sandybridge.
>>
>> CC: Matt Turner <mattst88 at gmail.com>
>> ---
>> tests/egl/spec/egl_khr_create_context/invalid-gl-version.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
>> b/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
>> index ee33fb9..d83c40b 100644
>> --- a/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
>> +++ b/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
>> @@ -82,6 +82,9 @@ int main(int argc, char **argv)
>> pass = pass && try_version(0, 0);
>> pass = pass && try_version(0, -1);
>> pass = pass && try_version(1, 2);
>> + pass = pass && try_version(3, 2);
>> + pass = pass && try_version(3, 9);
>> + pass = pass && try_version(4, 7);
>
> All of the other subtests check for GLES versions that can *never* be value. It
> is conceivable that someday 3.2 or 3.9 or 4.7 could be valid.
>
> One test that we are missing is a test that tries to create a context of a
> particular version and verifies that it got a context of that version. It seems
> like that would be the right way to check for this problem. You may get a
> context when you ask for 3.2, but I bet glGetString(GL_VERSION) or
> glGetIntegerv(GL_MAJOR_VERSION) / glGetIntegerv(GL_MINOR_VERSION) only say 3.0.
>
> My preference is to not add a test that may break on a future valid
> implementation. We need that other test anyway.
That's a sensible suggestion. I'll write that test.
In that new test, I still want to verify that Mesa returns EGL_BAD_MATCH if
context creation fails soley due to the driver not supporting the requested,
perhaps invalid, version. Currently, in situations where EGL_BAD_MATCH is
the correct error to emit, Mesa emits one of EGL_SUCCESS (!),
EGL_BAD_CONFIG, or EGL_BAD_MATCH depending on where internally context
creation failed. We really need a test to ensure that Mesa doesn't do that.
I see a way to write the new test so that, if context creation fails, the
only reasonably expected error is EGL_BAD_MATCH. The pattern looks like the
code below. Let me know if you think this is a sensible approach.
// A minimal ES2 config.
EGLint config_attrs[] = {
EGL_BUFFER_SIZE, 32,
EGL_RED_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_ALPHA_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE,
};
EGLint context_attrs[] = {
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_NONE,
};
EGLConfig config;
EGLContext ctx;
eglBindAPI(EGL_OPENGL_ES);
eglChooseConfig(..., config_attrs, &config);
assert(config != 0);
ctx = eglCreateContext(..., config, context_attrs);
// If the driver supports the requested context version and api,
// then we can reasonably expect context creation to succeed because
// the chosen config is minimal. Therefore, if context creation fails,
// it is safe to assume that failure occurred due to the driver not
// supporting the requested context version and api, in which case
// the EGL_KHR_create_context spec requires EGL_BAD_MATCH to be emitted.
if (ctx) {
// Verify the context's actual version.
} else {
if (eglGetError() == EGL_BAD_MATCH)
PASS();
else
FAIL();
}
More information about the Piglit
mailing list