Multiple calls to eglGetPlatformDisplayEXT with different requested renderers

451 views
Skip to first unread message

Austin Kinross

unread,
Sep 26, 2014, 2:29:56 PM9/26/14
to anglep...@googlegroups.com
Should you be able to call eglGetPlatformDisplayEXT multiple times with different requested renderers?

For example, when I do the following:

1) Create a Win32 window
2) Call eglGetPlatformDisplayEXT with this Win32 window, and EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE as the requested display
3) Finish initializing EGL (eglCreateWindowSurface, etc)
4) Tear down EGL (eglDestroySurface, eglDestroyContext, eglTerminate)
5) Call eglGetPlatformDisplayEXT with the Win32 window, and EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE as the requested display
6) Finish initializing EGL

then ANGLE still uses the D3D11 renderer after step 6, instead of D3D9. It seems to always use whichever display was requested first.

Is this expected behavior?

I was able to work around it by modifying this code to search 'displays' for both the displayId and the displayType:

egl::Display *Display::getDisplay(EGLNativeDisplayType displayId, EGLint displayType)
{
    DisplayMap *displays = GetDisplayMap();
    DisplayMap::const_iterator iter = displays->find(displayId);
    if (iter != displays->end())
    {
        return iter->second;
    }

I'm preparing a change to the "angle_tests" to run them against multiple renderers (e.g. D3D11, D3D9), which is how I've hit this issue. At a later date we plan to run the tests against D3D11 Feature Level 9_3 too, which we are preparing in our MSOpenTech GitHub repo.

Thanks,
Austin

Jamie Madill

unread,
Sep 26, 2014, 2:38:56 PM9/26/14
to Austin Kinross, anglep...@googlegroups.com
Hey Austin,

This sounds like a bug. I've definitely opened multiple Renderers in the same process, with different back-ends (after appropriate clean-up). Please open an issue on the tracker, making sure to mention which version of ANGLE you're based off of.

BTW Geoff was working on a change to run multiple configs in the tests, I'll ask him what's the status on that. If you come up with something too, feel free to contribute it back. We could benefit from multiple config tests.

On Fri, Sep 26, 2014 at 2:37 PM, Jamie Madill <jma...@google.com> wrote:
Hey Austin,

This sounds like a bug. I've definitely opened multiple Renderers in the same process, with different back-ends (after appropriate clean-up). Please open an issue on the tracker, making sure to mention which version of ANGLE you're based off of.

BTW Geoff was working on a change to run multiple configs in the tests, I'll ask him what's the status on that. If you come up with something too, feel free to contribute it back. We could benefit from multiple config tests.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Geoff Lang

unread,
Sep 26, 2014, 4:22:34 PM9/26/14
to Jamie Madill, Austin Kinross, anglep...@googlegroups.com
It looks like eglTerminate is not deleting the display so it ends up getting re-used on the next call to eglGetDisplay that has the same HDC.  I'll fix this, thanks for the report.

Austin Kinross

unread,
Sep 26, 2014, 4:28:05 PM9/26/14
to anglep...@googlegroups.com, jma...@chromium.org, auki...@microsoft.com
That's great, thank you Geoff/Jamie!

Jamie- I nearly have the change ready. I intend to contribute it back soon.

Shannon Woods

unread,
Sep 26, 2014, 4:41:05 PM9/26/14
to anglep...@googlegroups.com, jma...@chromium.org, auki...@microsoft.com
eglTerminate should not delete the display, but make it uninitialized. See sec 3.2 of the EGL 1.4 spec, pp13-14.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.

Geoff Lang

unread,
Sep 26, 2014, 4:46:11 PM9/26/14
to shanno...@chromium.org, anglep...@googlegroups.com, Jamie Madill, Austin Kinross
I just realized the same thing. I think there is something that needs to be fixed there though, eglGetPlatformDisplay should probably return a unique display when given different platform types.

To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.

Geoff Lang

unread,
Sep 26, 2014, 5:00:23 PM9/26/14
to shanno...@chromium.org, anglep...@googlegroups.com, Jamie Madill, Austin Kinross
We looked some more at the relevant specs. It looks like we're in spec to use the same renderer here.  According to ANGLE_platform_angle (https://chromium.googlesource.com/angle/angle/+/master/extensions/ANGLE_platform_angle.txt):
 "The value of GL_PLATFORM_ANGLE_TYPE_ANGLE, if any, is ignored if there was previously a EGLDisplay successfully created for a given value of EGLNativeDisplayType".

You'll have to destroy and re-create the window in order to create a display with a different renderer.  It would be complicated to support multiple displays for the same HDC and verify that a new one can only be created after the others have been terminated.

Austin Kinross

unread,
Oct 20, 2014, 10:26:20 PM10/20/14
to anglep...@googlegroups.com, shanno...@chromium.org, jma...@chromium.org, auki...@microsoft.com
Hi,

We discussed adding more attributes to eglGetPlatformDisplay to allow applications to specify the renderer's major or minor version. This will require a change to the extension spec (https://chromium.googlesource.com/angle/angle/+/master/extensions/ANGLE_platform_angle.txt).

What are you thoughts about us also changing the behavior of eglGetPlatformDisplay when multiple calls are made with the same <platform> and <native_display>, but with different <attrib_list>s?

The current behavior means that applications hitting the following scenarios have to destroy their window, which seems strange to me:
- Application requests D3D11, but resorts to D3D9 if eglInitialize() fails for the D3D11 renderer (e.g. because it doesn't support Feature Level 10_0+)
- Application requests OpenGL, but the user wants to switch to D3D11
- Application requests one renderer, but then switches to another renderer if it hits a driver issue
- Application requests certain major/minor version attributes, but resorts to a lower major/minor version if eglInitialize() fails.

I think ANGLE could solve this problem by doing the following:
- on the first call to eglGetPlatformDisplay, do the same as it does now
- on subsequent calls to eglGetPlatformDisplay, apply the requested attributes to the existing display if the display isn't initialized. 

I believe this would be within the spec for EXT_platform_base, since this remains true: "Multiple calls made to eglGetPlatformDisplayEXT with the same <platform> and <native_display> will return the same EGLDisplay handle".

What do you think about this?

Thanks,
Austin
Reply all
Reply to author
Forward
0 new messages