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

wgpu: Allow wgpu on web and various improvements #5250

Merged
merged 10 commits into from
Oct 25, 2021

Conversation

Herschel
Copy link
Member

@Herschel Herschel commented Sep 8, 2021

This is working towards several wgpu changes:

  • Bump to latest wgpu 0.11, using the new wgpu-hal.
  • Replace the use of push constants with uniforms.
    • Push constants are not part of the current WebGPU spec, and are provided as an extension in wgpu that is unfortunately not supported on most backends.
    • We'll need to do this to support WebGPU in the browser.
  • The OpenGL backend should now function on Linux.
  • Support sRGB surface formats by allowing shaders to perform the sRGB->linear conversion.
    • OpenGL does not support the non-sRGB surface format.
  • Add web support for the wgpu backend.
    • wgpu feature added to ruffle_web.
    • Web will try to create wgpu renderer, WebGL renderer, and canvas renderer, in that order.
    • WebGPU currently requires Chrome Canary/Firefox Nightly with the proper flags enabled.
  • Rewrite all shaders in WGSL.

Let's hold off on merging this until either the DX11 backend is re-enabled, or the OpenGL backend works on Windows.

@Herschel Herschel changed the title chore: Bump to wgpu 0.10 wgpu: Use uniforms instead of push constants Sep 8, 2021
@Herschel Herschel marked this pull request as draft September 8, 2021 09:01
@Herschel Herschel force-pushed the wgpu-0.10 branch 4 times, most recently from c61bc2e to acd9816 Compare September 8, 2021 09:21
@torokati44
Copy link
Member

About the surface format issue: My experience was that only sRGBA formats were supported on OpenGL.

@Herschel Herschel force-pushed the wgpu-0.10 branch 6 times, most recently from 0872c43 to 09c3418 Compare September 10, 2021 19:52
@Herschel Herschel changed the title wgpu: Use uniforms instead of push constants [wip] wgpu: Allow wgpu use on web and various improvements Sep 10, 2021
@Herschel Herschel changed the title [wip] wgpu: Allow wgpu use on web and various improvements [wip] wgpu: Allow wgpu on web and various improvements Sep 10, 2021
@Herschel
Copy link
Member Author

Bumped to wgpu 0.11.

@torokati44
Copy link
Member

After the bump to 0.11, it still works fine for me on native Linux; on both Vulkan with HW acceleration, and on OpenGL - with or without HW acceleration.
Now I only get these warnings, but they don't seem to matter:

[2021-10-11T20:25:07Z WARN  ruffle_render_wgpu] Open GL graphics backend support may not be fully supported.
[2021-10-11T20:25:07Z WARN  wgpu_core::instance] Missing downlevel flags: READ_ONLY_DEPTH_STENCIL
    The underlying API or device in use does not support enough features to be a fully compliant implementation of WebGPU. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to limit the features you use to the supported subset, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.
[2021-10-11T20:25:07Z WARN  wgpu_core::validation] Unexpected varying type: Array { base: [1], size: Constant([5]), stride: 4 }
[2021-10-11T20:25:07Z WARN  wgpu_core::validation] Unexpected varying type: Array { base: [1], size: Constant([5]), stride: 4 }
[2021-10-11T20:25:07Z WARN  wgpu_core::validation] Unexpected varying type: Array { base: [1], size: Constant([7]), stride: 4 }
[2021-10-11T20:25:07Z WARN  wgpu_core::validation] Unexpected varying type: Array { base: [1], size: Constant([7]), stride: 4 }
[2021-10-11T20:25:07Z WARN  wgpu_core::device] Surface does not support present mode: Mailbox, falling back to FIFO
[2021-10-11T20:25:07Z WARN  wgpu_core::device] Surface does not support present mode: Mailbox, falling back to FIFO

@Herschel Herschel force-pushed the wgpu-0.10 branch 3 times, most recently from f0ccfca to af662b0 Compare October 21, 2021 02:44
@Herschel Herschel marked this pull request as ready for review October 21, 2021 02:46
@Herschel
Copy link
Member Author

I've converted all of the shaders over to WSGL. I don't think it's worth waiting for DX11 support, so this is more or less ready to go; unfortunately I'm getting errors on DX12 at the moment that I need to investigate.

@torokati44 Could you give this another try on your machine with OpenGL?

@Herschel Herschel changed the title [wip] wgpu: Allow wgpu on web and various improvements wgpu: Allow wgpu on web and various improvements Oct 21, 2021
@torokati44
Copy link
Member

Still works fine for me on all four [OpenGL, Vulkan] x [HW, SW] combinations.

@torokati44
Copy link
Member

BTW is running with DX11 any better than OpenGL on Windows?
I'm not sure raw performance is that important for most content, I'm asking more about compatibility.

@Herschel
Copy link
Member Author

Unfortunately wgpu OpenGL backend doesn't function on Windows (it uses egl for the context management, it would need to use wgl on Windows). And I don't think it's really on their roadmap to support OpenGL on Windows.

I don't know what machines would support DX11 but not DX12; DX12 was back-ported to Windows 7, and I think even integrated GPUs would support both DX11 and 12. But not 100% sure.

@Herschel
Copy link
Member Author

Herschel commented Oct 21, 2021

To answer my own question a little bit, Intel provides this page indicating which APIs their chips support:
https://www.intel.com/content/www/us/en/support/articles/000005524/graphics.html

You actually don't need to fully support DX12 feature set to use DirectX 12; the versions are more like feature levels nowadays, and ostensibly you can use the DirectX12 API with the DX11 feature set. wgpu itself only requests D3D_FEATURE_LEVEL_11_0 which should in theory go all the way back to HD Graphics 2500.

HD Graphics 2000 is the first to only support DX10, and that's dating to 2011, so I think that's far enough back to be okay ignoring it.

@Herschel
Copy link
Member Author

Herschel commented Oct 23, 2021

My DX12 issue mentioned above was kindly fixed in gfx-rs/wgpu#2103.

Unfortunately as far as Win7 goes, looks like Microsoft's D3D12on7 wrapper is required to use DX12 API on older Windows -- I mistakenly thought MS had seamlessly backported it. So this would require these pre-Win10 users to have Vulkan. Consulting back to the Intel support page, the chipsets that supposedly support Vulkan date back to only ~2015.

@Herschel Herschel force-pushed the wgpu-0.10 branch 4 times, most recently from 49a61f8 to e327400 Compare October 24, 2021 22:38
This will be necessary for using wgpu on web, where the whole
renderer creation will need to be async.
Enable web_sys_unstable_apis RUSTFLAGS in .cargo/config.toml.
These are necessary to use WebGPU in the browser, as well as other
features such as clipboard.
Add wgpu feature to web build (disabled by default currently).
This backend has not yet been reimplemented in wgpu 0.10+, so
disallow it for now.
wgpu only supports OpenGL on Linux, so provide a better message if
a user tries to use the GL backend on Windows/macOS.
@Herschel
Copy link
Member Author

Let's go ahead and merge this, with pre-emptive apologies to any users on older Win 7 systems.

@Herschel Herschel merged commit bbb788c into ruffle-rs:master Oct 25, 2021
@Herschel Herschel deleted the wgpu-0.10 branch October 25, 2021 00:20
relrelb added a commit to relrelb/ruffle that referenced this pull request Jan 24, 2022
The switch to 8081 seems like a leftover from ruffle-rs#5250.
Return to the default 8080.
Herschel pushed a commit that referenced this pull request Jan 24, 2022
The switch to 8081 seems like a leftover from #5250.
Return to the default 8080.
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.

None yet

2 participants