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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ Bottom level categories:

- Update Naga to 9eb3a1dc (2023-10-12), which includes support for WGSL constant expressions. By @jimblandy in [#4233](https://github.com/gfx-rs/wgpu/pull/4233)

#### Support desktop OpenGL via WGL on Windows

Added creating of full OpenGL contexts to the GLES backend using WGL to support older devices.

By @Zoxc in [#4248](https://github.com/gfx-rs/wgpu/pull/4248)

#### Pass timestamp queries

Addition of `TimestampWrites` to compute and render passes to allow profiling.
Expand Down
13 changes: 12 additions & 1 deletion Cargo.lock

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

17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ We have a [wiki](https://github.com/gfx-rs/wgpu/wiki) that serves as a knowledge

## Supported Platforms

| API | Windows | Linux & Android | macOS & iOS | Web (wasm) |
| --------- | ------------------------------ | ------------------ | ------------------------- | ------------------------- |
| Vulkan | :white_check_mark: | :white_check_mark: | :ok: (vulkan-portability) | |
| Metal | | | :white_check_mark: | |
| DX12 | :white_check_mark: (W10+ only) | | | |
| DX11 | :hammer_and_wrench: | | | |
| GLES3 | :ok: (angle) | :ok: | :ok: (angle; macOS only) | :ok: (WebGL2 Only) |
| WebGPU | | | | :white_check_mark: |
| API | Windows | Linux & Android | macOS & iOS | Web (wasm) |
| ----------- | ------------------------------ | ------------------ | ------------------------- | ------------------------- |
| Vulkan | :white_check_mark: | :white_check_mark: | :ok: (vulkan-portability) | |
| Metal | | | :white_check_mark: | |
| DX12 | :white_check_mark: (W10+ only) | | | |
| DX11 | :hammer_and_wrench: | | | |
| OpenGL | :ok: (Desktop GL 3.3+) | :ok: (GL ES 3.0+) | :ok: (angle; GL ES 3.0+) | :ok: (WebGL2) |
| WebGPU | | | | :white_check_mark: |

:white_check_mark: = First Class Support — :ok: = Best Effort Support — :hammer_and_wrench: = Unsupported, but support in progress

Expand Down Expand Up @@ -148,6 +148,7 @@ We have multiple methods of testing, each of which tests different qualities abo
| DX11/Windows 10 | :construction: | — | using WARP |
| Metal/MacOS | :heavy_check_mark: | — | using hardware runner |
| Vulkan/Linux | :heavy_check_mark: | - | using swiftshader |
| GL/Windows | | — | |
| GLES/Linux | :heavy_check_mark: | — | using llvmpipe |
| WebGL/Chrome | :heavy_check_mark: | — | using swiftshader |

Expand Down
33 changes: 33 additions & 0 deletions tests/tests/multi-instance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#![cfg(not(target_arch = "wasm32"))]

async fn get() -> wgpu::Adapter {
let adapter = {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all),
..Default::default()
});
instance
.request_adapter(&wgpu::RequestAdapterOptions::default())
.await
.unwrap()
};

log::info!("Selected adapter: {:?}", adapter.get_info());

adapter
}

#[test]
fn multi_instance() {
{
env_logger::init();

// Sequential instances.
for _ in 0..3 {
pollster::block_on(get());
}

// Concurrent instances
let _instances: Vec<_> = (0..3).map(|_| pollster::block_on(get())).collect();
}
}
5 changes: 4 additions & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ targets = [
default = ["link"]
metal = ["naga/msl-out", "block"]
vulkan = ["naga/spv-out", "ash", "gpu-alloc", "gpu-descriptor", "libloading", "smallvec"]
gles = ["naga/glsl-out", "glow", "khronos-egl", "libloading"]
gles = ["naga/glsl-out", "glow", "glutin_wgl_sys", "khronos-egl", "libloading"]
dx11 = ["naga/hlsl-out", "d3d12", "libloading", "winapi/d3d11", "winapi/std", "winapi/d3d11_1", "winapi/d3d11_2", "winapi/d3d11sdklayers", "winapi/dxgi1_6"]
dx12 = ["naga/hlsl-out", "d3d12", "bit-set", "libloading", "range-alloc", "winapi/std", "winapi/winbase", "winapi/d3d12", "winapi/d3d12shader", "winapi/d3d12sdklayers", "winapi/dxgi1_6"]
# TODO: This is a separate feature until Mozilla okays windows-rs, see https://github.com/gfx-rs/wgpu/issues/3207 for the tracking issue.
Expand All @@ -59,6 +59,7 @@ parking_lot = ">=0.11,<0.13"
profiling = { version = "1", default-features = false }
raw-window-handle = "0.5"
thiserror = "1"
once_cell = "1.18.0"

# backends common
arrayvec = "0.7"
Expand Down Expand Up @@ -95,6 +96,8 @@ bit-set = { version = "0.5", optional = true }
range-alloc = { version = "0.1", optional = true }
gpu-allocator = { version = "0.23", default_features = false, features = ["d3d12", "public-winapi"], optional = true }
hassle-rs = { version = "0.10", optional = true }
# backend: Gles
glutin_wgl_sys = { version = "0.4", optional = true }

winapi = { version = "0.3", features = ["profileapi", "libloaderapi", "windef", "winuser", "dcomp"] }
d3d12 = { version = "0.7", features = ["libloading"], optional = true }
Expand Down
6 changes: 3 additions & 3 deletions wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

extern crate wgpu_hal as hal;

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(windows, target_arch = "wasm32")))]
fn main() {
env_logger::init();
println!("Initializing external GL context");
Expand Down Expand Up @@ -116,10 +116,10 @@ fn main() {
fill_screen(&exposed, 640, 400);
}

#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[cfg(any(windows, all(target_arch = "wasm32", not(target_os = "emscripten"))))]
fn main() {}

#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
#[cfg(any(not(any(windows, target_arch = "wasm32")), target_os = "emscripten"))]
fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height: u32) {
use hal::{Adapter as _, CommandEncoder as _, Device as _, Queue as _};

Expand Down
Loading