[Piglit] [PATCH] egl: Test more invalid GLES2 context versions

Chad Versace chad.versace at linux.intel.com
Tue Nov 6 17:01:28 PST 2012


On 11/06/2012 04:21 PM, Ian Romanick wrote:
> On 11/06/2012 12:51 PM, Chad Versace wrote:
>> 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.
> 
> Can you refresh my memory... what are the cases where we generate EGL_BAD_CONFIG?

When the user requests a GLES context >= 4.0. By examining the code, it's
apparent that Mesa doesn't intend to emit EGL_BAD_CONFIG; it's an accident
due to unexpected interaction between eglGetContextAPIBit (internal function)
and its caller.

 
>> 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.
> 
> I think so.

Great.
 
>> // 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_OPENGL_ES3_BIT_KHR?

I intended to use the ES2 bit. That's how the OpenGL ES3 conformance suite
creates ES3 contexts.

I'm unsure if that bit is strictly required to create an ES3 context.
The current situation is:
(1) Mesa doesn't recognize the bit and emits an error on encountering it
and (2) the OpenGL ES3 conformance suite doesn't set the bit when creating ES3
contexts. See my mail today to the Khronos EGL list for details.

> 
>>
>>      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