Skip to content

WinRT#9214

Open
momo-AUX1 wants to merge 21 commits intogfx-rs:trunkfrom
momo-AUX1:WinRT
Open

WinRT#9214
momo-AUX1 wants to merge 21 commits intogfx-rs:trunkfrom
momo-AUX1:WinRT

Conversation

@momo-AUX1
Copy link
Copy Markdown

Description
this added the xbox support for both GLES and DX12

Testing
testing was done on an xbox and bevy and a few games ran on it

Checklist

  • [ x] Run cargo fmt.
  • [ x] Run taplo format.
  • [ x] Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

momo-AUX1 and others added 21 commits February 7, 2026 09:04
The __WINRT__ cfg controls whether wgpu-hal's GLES backend uses EGL
(ANGLE, UWP-safe) or WGL (Win32 desktop only). Previously the cfg was
only passed via --cfg in .cargo/config.toml rustflags, which could be
missed by incremental builds or stale caches — causing wgpu-hal to
compile the WGL path even for UWP targets.

Now build.rs inspects CARGO_ENCODED_RUSTFLAGS and RUSTFLAGS for
__WINRT__ and re-emits it via cargo:rustc-cfg, with rerun-if-env-changed
guards. Desktop builds without the flag are completely unaffected.

This fixes a FAST_FAIL_FATAL_APP_EXIT crash on Xbox where the WGL path
called CreateWindowExA (forbidden in UWP/AppContainer) and loaded the
desktop AMD OpenGL ICD.
Add DX12 surface support for RawWindowHandle::WinRt by creating swapchains via CreateSwapChainForCoreWindow. Keep GLES on WinRT/UWP via EGL and fix dx12 once_cell std.
@inner-daemons
Copy link
Copy Markdown
Collaborator

I'll handle this for a while but won't assign myself because that messes up stuff at meetings.

}
wgt::Dx12SwapchainKind::DxgiFromVisual => {
return Err(crate::InstanceError::new(
"DX12 presentation_system=DxgiFromVisual is not supported for WinRT CoreWindow surfaces"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to be documented on the Dx12SwapchainKind variant

Copy link
Copy Markdown
Collaborator

@inner-daemons inner-daemons left a comment

Choose a reason for hiding this comment

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

This will also need a changelog entry and probably some testing setup. You can do clippy for another target without necessarily running on said target, see examples in .github/workflows/ci.yml.

I'm also concerned about some of the potentially unrelated changes.

The biggest point of confusion though is that you put all of the work in to switch to EGL on UWP but then also completely disabled OpenGL on UWP if I'm understanding right.

Btw thanks for all this work, its very useful and its exciting to see that wgpu/bevy apps can run on Xbox!

pub use fence::Fence;

#[cfg(not(any(windows, webgl)))]
#[cfg(any(all(windows, target_vendor = "uwp"), not(any(windows, webgl))))]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Stuff like this probably belongs in the build.rs which declares some cfg aliases. It will get annoying to copy this everywhere.

config.extent.width as i32,
config.extent.height as i32,
);
let window = unsafe {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are you modifying wayland code?

let (config, supports_native_window) = choose_config(&egl, display, srgb_kind)?;

#[cfg(all(windows, target_vendor = "uwp"))]
let supports_opengl = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is OGL not supported on UWP? Then whats the point of all of these GLES changes when you could just disable the backend?

@momo-AUX1
Copy link
Copy Markdown
Author

Yes UWP is using EGL via angle and I encountered some issues so it was fixed quickly I never thought you guys would actually show interest let alone a PR

I'll clean it up further and add the requested changes once I get the time ideally before Monday

Copy link
Copy Markdown
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

@inner-daemons & @cwfitzgerald already pointed out a bunch of stuff, but to add to that we should also at the very least add uwp as a checked target on CI

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.

4 participants