Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WGL context creation and OpenGL support #4248

Merged
merged 14 commits into from
Oct 18, 2023
Merged

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Oct 16, 2023

This adds WGL context creation and desktop OpenGL support to the gles backend. It's used instead of EGL on Windows. Only WGL requests desktop OpenGL contexts. The behavior of EGL is left unchanged.

To enable construction of an OpenGL context without a surface, a memory device is used. Each surface gets their own OpenGL context which share object with the memory device OpenGL context. Rendering to surfaces happens indirectly via renderbuffers as framebuffers cannot be shared across OpenGL contexts.

Currently a lot of gles backend features are not enabled on desktop OpenGL.

I've tested it with an HD 5870 using the examples and vello.

bunnymark is plain blue. skybox crashes in the driver. mipmap is too white, Vsync locks to 30 fps instead of 60 fps on a 60 Hz display. These may be issues with the driver or gles backend rather than this PR however.

@Zoxc Zoxc requested a review from a team as a code owner October 16, 2023 18:26
@Zoxc
Copy link
Contributor Author

Zoxc commented Oct 16, 2023

I added some more feature detection and driver workarounds. That makes pass tests for vger-rs.

@teoxoy
Copy link
Member

teoxoy commented Oct 17, 2023

Is it possible to test this in CI?

@cwfitzgerald
Copy link
Member

@teoxoy not yet. Unless we manage to set up gl-on-12 over warp, this will need to wait until we have a physical box with a real gpu running our windows tests.

@cwfitzgerald
Copy link
Member

I am very happy to be wrong! GLon12 isn't terribly hard to set up, though definitely shouldn't be part of this PR. Will file a follow up with more information.

@Zoxc
Copy link
Contributor Author

Zoxc commented Oct 17, 2023

I've changed the PR to use a dummy window instead of a memory device, as that makes OpenGL context creation work on Mesa and my Sandy Bridge laptop.

@Zoxc Zoxc force-pushed the wgl branch 3 times, most recently from 0c74fc2 to 3956713 Compare October 17, 2023 20:54
@cwfitzgerald
Copy link
Member

Pushed a commit that enables renderdoc with wgl.

Outside of presentation being all black on nvidia, this is looking good.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super amazing stuff. Tested successfully on all of my devices!

Everything is fairly minor

wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Show resolved Hide resolved
wgpu-hal/src/gles/wgl.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/wgl.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/wgl.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/wgl.rs Show resolved Hide resolved
wgpu/tests/multi-instance.rs Outdated Show resolved Hide resolved
@teoxoy
Copy link
Member

teoxoy commented Oct 18, 2023

Could you also add an "OpenGL" row to the "Supported Platforms" table in the readme (and remove the GLES3 Angle entry for windows)?

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stunning work! Thank you for getting this all through!

README.md Outdated Show resolved Hide resolved
@cwfitzgerald cwfitzgerald enabled auto-merge (squash) October 18, 2023 18:31
@cwfitzgerald cwfitzgerald merged commit 2b985e2 into gfx-rs:trunk Oct 18, 2023
23 checks passed
@Zoxc Zoxc deleted the wgl branch October 18, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants