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

[d3d12 wgl] Upgrade to windows 0.59 crates #6876

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 83 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bit-set = "0.8"
gpu-allocator = { version = "0.27", default-features = false }
range-alloc = "0.1"
mach-dxcompiler-rs = { version = "0.1.4", default-features = false }
windows-core = { version = "0.58", default-features = false }
windows-core = { version = "0.59", default-features = false }

# Gles dependencies
khronos-egl = "6"
Expand All @@ -168,7 +168,7 @@ glutin-winit = { version = "0.4", default-features = false }
glutin_wgl_sys = "0.6"

# DX and GLES dependencies
windows = { version = "0.58", default-features = false }
windows = { version = "0.59", default-features = false }

# wasm32 dependencies
console_error_panic_hook = "0.1.7"
Expand Down Expand Up @@ -207,6 +207,11 @@ ndk-sys = "0.5.0"
#js-sys = { path = "../wasm-bindgen/crates/js-sys" }
#wasm-bindgen = { path = "../wasm-bindgen" }

# https://github.com/Traverse-Research/gpu-allocator/pull/258
gpu-allocator = { git = "https://github.com/Traverse-Research/gpu-allocator", rev = "dd4ad67" }
# https://github.com/Xudong-Huang/generator-rs/pull/72
generator = { git = "https://github.com/MarijnS95/generator-rs", rev = "bb99244" }

[profile.release]
lto = "thin"
debug = true
Expand Down
15 changes: 2 additions & 13 deletions wgpu-hal/src/dx12/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,23 +768,12 @@ impl crate::CommandEncoder for super::CommandEncoder {
if let Some(ds_view) = ds_view {
if flags != Direct3D12::D3D12_CLEAR_FLAGS::default() {
unsafe {
// list.ClearDepthStencilView(
// ds_view,
// flags,
// ds.clear_value.0,
// ds.clear_value.1 as u8,
// None,
// )
// TODO: Replace with the above in the next breaking windows-rs release,
// when https://github.com/microsoft/win32metadata/pull/1971 is in.
(windows_core::Interface::vtable(list).ClearDepthStencilView)(
windows_core::Interface::as_raw(list),
list.ClearDepthStencilView(
ds_view,
flags,
ds.clear_value.0,
ds.clear_value.1 as u8,
0,
std::ptr::null(),
None,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/dx12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ impl crate::Surface for Surface {
.ok_or(crate::SurfaceError::Other("IDXGIFactoryMedia not found"))?
.CreateSwapChainForCompositionSurfaceHandle(
&device.present_queue,
handle,
Some(handle),
&desc,
None,
)
Expand Down
12 changes: 6 additions & 6 deletions wgpu-hal/src/gles/wgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl WglContext {
if unsafe { OpenGL::wglGetCurrentContext() }.is_invalid() {
return Ok(());
}
unsafe { OpenGL::wglMakeCurrent(None, None) }
unsafe { OpenGL::wglMakeCurrent(Default::default(), Default::default()) }
Copy link
Contributor Author

@MarijnS95 MarijnS95 Jan 8, 2025

Choose a reason for hiding this comment

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

@kennykerr can you help us here? I did not do my due diligence this time to search through windows-rs and win32metadata for relevant changes, but while most handles have been made optional (see other Some() wrapping changes in this PR), quite strangely these parameters are no longer optional in wglMakeCurrent() where they have a specific use-case to uncurrent the context.

Is this change intended or accidental? We can clearly get around it by passing a defaulted HDC/HGLRC, but it seems strange when compared to other functions where None can be passed.

Choose a reason for hiding this comment

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

The code generator now faithfully honors the metadata's [Optional] attribute - in the case of wglMakeCurrent the handle parameters are not optional whereas in the case of CreateSwapChainForCompositionSurfaceHandle the handle parameter is optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @kennykerr. So this'll take another trip through win32metadata to annotate correctly.

}
}

Expand Down Expand Up @@ -380,7 +380,7 @@ fn create_instance_device() -> Result<InstanceDevice, crate::InstanceError> {
1,
None,
None,
instance,
Some(instance.into()),
None,
)
}
Expand All @@ -392,7 +392,7 @@ fn create_instance_device() -> Result<InstanceDevice, crate::InstanceError> {
})?;
let window = Window { window };

let dc = unsafe { Gdi::GetDC(window.window) };
let dc = unsafe { Gdi::GetDC(Some(window.window)) };
if dc.is_invalid() {
return Err(crate::InstanceError::with_source(
String::from("unable to create memory device"),
Expand Down Expand Up @@ -627,7 +627,7 @@ struct DeviceContextHandle {
impl Drop for DeviceContextHandle {
fn drop(&mut self) {
unsafe {
Gdi::ReleaseDC(self.window, self.device);
Gdi::ReleaseDC(Some(self.window), self.device);
};
}
}
Expand Down Expand Up @@ -663,7 +663,7 @@ impl Surface {
) -> Result<(), crate::SurfaceError> {
let swapchain = self.swapchain.read();
let sc = swapchain.as_ref().unwrap();
let dc = unsafe { Gdi::GetDC(self.window) };
let dc = unsafe { Gdi::GetDC(Some(self.window)) };
if dc.is_invalid() {
log::error!(
"unable to get the device context from window: {}",
Expand Down Expand Up @@ -741,7 +741,7 @@ impl crate::Surface for Surface {
// Remove the old configuration.
unsafe { self.unconfigure(device) };

let dc = unsafe { Gdi::GetDC(self.window) };
let dc = unsafe { Gdi::GetDC(Some(self.window)) };
if dc.is_invalid() {
log::error!(
"unable to get the device context from window: {}",
Expand Down
Loading