From 9f3a050fc46b5a947db02159d841183d67201145 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Sat, 19 Dec 2020 14:57:11 +0100 Subject: [PATCH] [rs] First step for WebGL support. --- wgpu/Cargo.toml | 8 ++++++++ wgpu/src/backend/mod.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 85c8298359..b47d9743e2 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -21,6 +21,7 @@ trace = ["serde", "wgc/trace"] replay = ["serde", "wgc/replay"] # Make Vulkan backend available on platforms where it is by default not, e.g. macOS vulkan-portability = ["wgc/gfx-backend-vulkan"] +webgl = ["wgc"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" @@ -28,6 +29,13 @@ git = "https://github.com/gfx-rs/wgpu" rev = "4ebe1f50b057046e4d4f015eb006330d62f5fe91" features = ["raw-window-handle"] +[target.'cfg(target_arch = "wasm32")'.dependencies.wgc] +package = "wgpu-core" +git = "https://github.com/gfx-rs/wgpu" +rev = "4ebe1f50b057046e4d4f015eb006330d62f5fe91" +features = ["raw-window-handle"] +optional = true + [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" diff --git a/wgpu/src/backend/mod.rs b/wgpu/src/backend/mod.rs index e0fbccf786..90001e6acf 100644 --- a/wgpu/src/backend/mod.rs +++ b/wgpu/src/backend/mod.rs @@ -1,15 +1,15 @@ -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))] mod web; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))] pub(crate) use web::{BufferMappedRange, Context}; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))] mod direct; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))] mod error; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))] pub(crate) use direct::{BufferMappedRange, Context}; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))] mod native_gpu_future;