mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Remove emscripten
crate features (#3467)
This commit is contained in:
parent
c51edd36fd
commit
e4445205c2
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -139,13 +139,13 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# build for Emscripten/WebGL
|
# build for Emscripten/WebGL
|
||||||
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --no-default-features --features webgl,emscripten
|
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --no-default-features
|
||||||
|
|
||||||
# build cube example
|
# build cube example
|
||||||
cargo clippy --target ${{ matrix.target }} --example cube --features webgl,emscripten
|
cargo clippy --target ${{ matrix.target }} --example cube
|
||||||
|
|
||||||
# build raw-gles example
|
# build raw-gles example
|
||||||
cargo clippy --target ${{ matrix.target }} --example raw-gles --features webgl,emscripten
|
cargo clippy --target ${{ matrix.target }} --example raw-gles
|
||||||
|
|
||||||
- name: check native
|
- name: check native
|
||||||
if: matrix.kind == 'native'
|
if: matrix.kind == 'native'
|
||||||
|
@ -35,6 +35,6 @@ workspace = true
|
|||||||
features = ["dx11", "dx12"]
|
features = ["dx11", "dx12"]
|
||||||
|
|
||||||
# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
|
# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
|
||||||
[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"))))'.dependencies.wgpu-core]
|
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"))))'.dependencies.wgpu-core]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["vulkan"]
|
features = ["vulkan"]
|
||||||
|
@ -37,7 +37,7 @@ features = ["metal"]
|
|||||||
workspace = true
|
workspace = true
|
||||||
features = ["dx11", "dx12"]
|
features = ["dx11", "dx12"]
|
||||||
|
|
||||||
[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
|
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["vulkan"]
|
features = ["vulkan"]
|
||||||
|
|
||||||
|
@ -35,9 +35,6 @@ dx12 = ["hal/dx12"]
|
|||||||
# https://renderdoc.org/
|
# https://renderdoc.org/
|
||||||
renderdoc = ["hal/renderdoc"]
|
renderdoc = ["hal/renderdoc"]
|
||||||
|
|
||||||
# Compile for the Emscripten POSIX-in-a-web-page emulation environment.
|
|
||||||
emscripten = ["hal/emscripten"]
|
|
||||||
|
|
||||||
# Apply run-time checks, even in release builds. These are in addition
|
# Apply run-time checks, even in release builds. These are in addition
|
||||||
# to the validation carried out at public APIs in all builds.
|
# to the validation carried out at public APIs in all builds.
|
||||||
strict_asserts = ["wgt/strict_asserts"]
|
strict_asserts = ["wgt/strict_asserts"]
|
||||||
|
@ -34,7 +34,7 @@ pub fn is_valid_copy_dst_texture_format(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
any(not(target_arch = "wasm32"), feature = "emscripten"),
|
any(not(target_arch = "wasm32"), target_os = "emscripten"),
|
||||||
allow(unused)
|
allow(unused)
|
||||||
)]
|
)]
|
||||||
pub fn is_valid_external_image_copy_dst_texture_format(format: wgt::TextureFormat) -> bool {
|
pub fn is_valid_external_image_copy_dst_texture_format(format: wgt::TextureFormat) -> bool {
|
||||||
|
@ -824,7 +824,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub fn queue_copy_external_image_to_texture<A: HalApi>(
|
pub fn queue_copy_external_image_to_texture<A: HalApi>(
|
||||||
&self,
|
&self,
|
||||||
queue_id: id::QueueId,
|
queue_id: id::QueueId,
|
||||||
|
@ -43,7 +43,6 @@ dx12 = ["naga/hlsl-out", "native", "bit-set", "range-alloc", "winapi/std", "wina
|
|||||||
windows_rs = ["gpu-allocator"]
|
windows_rs = ["gpu-allocator"]
|
||||||
dxc_shader_compiler = ["hassle-rs"]
|
dxc_shader_compiler = ["hassle-rs"]
|
||||||
renderdoc = ["libloading", "renderdoc-sys"]
|
renderdoc = ["libloading", "renderdoc-sys"]
|
||||||
emscripten = ["gles"]
|
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "halmark"
|
name = "halmark"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//! Emscripten build:
|
//! Emscripten build:
|
||||||
//! 1. install emsdk
|
//! 1. install emsdk
|
||||||
//! 2. build this example with cargo:
|
//! 2. build this example with cargo:
|
||||||
//! EMCC_CFLAGS="-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry -s FULL_ES3=1" cargo build --example raw-gles --target wasm32-unknown-emscripten --features emscripten,webgl
|
//! EMCC_CFLAGS="-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry -s FULL_ES3=1" cargo build --example raw-gles --target wasm32-unknown-emscripten
|
||||||
//! 3. copy raw-gles.em.html into target directory and open it in browser:
|
//! 3. copy raw-gles.em.html into target directory and open it in browser:
|
||||||
//! cp wgpu-hal/examples/raw-gles.em.html target/wasm32-unknown-emscripten/debug/examples
|
//! cp wgpu-hal/examples/raw-gles.em.html target/wasm32-unknown-emscripten/debug/examples
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ fn main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ fn main() {
|
|||||||
fill_screen(&exposed, 640, 400);
|
fill_screen(&exposed, 640, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height: u32) {
|
fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height: u32) {
|
||||||
|
@ -264,7 +264,7 @@ impl crate::CommandEncoder<Api> for Encoder {
|
|||||||
|
|
||||||
unsafe fn copy_buffer_to_buffer<T>(&mut self, src: &Resource, dst: &Resource, regions: T) {}
|
unsafe fn copy_buffer_to_buffer<T>(&mut self, src: &Resource, dst: &Resource, regions: T) {}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
unsafe fn copy_external_image_to_texture<T>(
|
unsafe fn copy_external_image_to_texture<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
src: &wgt::ImageCopyExternalImage,
|
src: &wgt::ImageCopyExternalImage,
|
||||||
|
@ -309,7 +309,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
unsafe fn copy_external_image_to_texture<T>(
|
unsafe fn copy_external_image_to_texture<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
src: &wgt::ImageCopyExternalImage,
|
src: &wgt::ImageCopyExternalImage,
|
||||||
|
@ -94,7 +94,7 @@ impl super::Device {
|
|||||||
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the texture. If `drop_guard` is
|
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the texture. If `drop_guard` is
|
||||||
/// [`Some`], the texture must be valid until the drop implementation
|
/// [`Some`], the texture must be valid until the drop implementation
|
||||||
/// of the drop guard is called.
|
/// of the drop guard is called.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn texture_from_raw(
|
pub unsafe fn texture_from_raw(
|
||||||
&self,
|
&self,
|
||||||
name: std::num::NonZeroU32,
|
name: std::num::NonZeroU32,
|
||||||
@ -125,7 +125,7 @@ impl super::Device {
|
|||||||
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the renderbuffer. If `drop_guard` is
|
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the renderbuffer. If `drop_guard` is
|
||||||
/// [`Some`], the renderbuffer must be valid until the drop implementation
|
/// [`Some`], the renderbuffer must be valid until the drop implementation
|
||||||
/// of the drop guard is called.
|
/// of the drop guard is called.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn texture_from_raw_renderbuffer(
|
pub unsafe fn texture_from_raw_renderbuffer(
|
||||||
&self,
|
&self,
|
||||||
name: std::num::NonZeroU32,
|
name: std::num::NonZeroU32,
|
||||||
|
@ -26,10 +26,10 @@ type WlDisplayConnectFun =
|
|||||||
|
|
||||||
type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void);
|
type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void);
|
||||||
|
|
||||||
#[cfg(not(feature = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
type EglInstance = egl::DynamicInstance<egl::EGL1_4>;
|
type EglInstance = egl::DynamicInstance<egl::EGL1_4>;
|
||||||
|
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
type EglInstance = egl::Instance<egl::Static>;
|
type EglInstance = egl::Instance<egl::Static>;
|
||||||
|
|
||||||
type WlEglWindowCreateFun = unsafe extern "system" fn(
|
type WlEglWindowCreateFun = unsafe extern "system" fn(
|
||||||
@ -423,7 +423,7 @@ struct Inner {
|
|||||||
version: (i32, i32),
|
version: (i32, i32),
|
||||||
supports_native_window: bool,
|
supports_native_window: bool,
|
||||||
config: egl::Config,
|
config: egl::Config,
|
||||||
#[cfg_attr(feature = "emscripten", allow(dead_code))]
|
#[cfg_attr(target_os = "emscripten", allow(dead_code))]
|
||||||
wl_display: Option<*mut raw::c_void>,
|
wl_display: Option<*mut raw::c_void>,
|
||||||
/// Method by which the framebuffer should support srgb
|
/// Method by which the framebuffer should support srgb
|
||||||
srgb_kind: SrgbFrameBufferKind,
|
srgb_kind: SrgbFrameBufferKind,
|
||||||
@ -535,7 +535,7 @@ impl Inner {
|
|||||||
// and creating dummy pbuffer surface if not.
|
// and creating dummy pbuffer surface if not.
|
||||||
let pbuffer = if version >= (1, 5)
|
let pbuffer = if version >= (1, 5)
|
||||||
|| display_extensions.contains("EGL_KHR_surfaceless_context")
|
|| display_extensions.contains("EGL_KHR_surfaceless_context")
|
||||||
|| cfg!(feature = "emscripten")
|
|| cfg!(target_os = "emscripten")
|
||||||
{
|
{
|
||||||
log::info!("\tEGL context: +surfaceless");
|
log::info!("\tEGL context: +surfaceless");
|
||||||
None
|
None
|
||||||
@ -624,10 +624,10 @@ unsafe impl Sync for Instance {}
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for Instance {
|
impl crate::Instance<super::Api> for Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
let egl_result: Result<EglInstance, egl::Error> = Ok(egl::Instance::new(egl::Static));
|
let egl_result: Result<EglInstance, egl::Error> = Ok(egl::Instance::new(egl::Static));
|
||||||
|
|
||||||
#[cfg(not(feature = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
let egl_result = if cfg!(windows) {
|
let egl_result = if cfg!(windows) {
|
||||||
unsafe {
|
unsafe {
|
||||||
egl::DynamicInstance::<egl::EGL1_4>::load_required_from_filename("libEGL.dll")
|
egl::DynamicInstance::<egl::EGL1_4>::load_required_from_filename("libEGL.dll")
|
||||||
@ -674,10 +674,10 @@ impl crate::Instance<super::Api> for Instance {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
let egl1_5 = egl.upcast::<egl::EGL1_5>();
|
let egl1_5 = egl.upcast::<egl::EGL1_5>();
|
||||||
|
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
let egl1_5: Option<&Arc<EglInstance>> = Some(&egl);
|
let egl1_5: Option<&Arc<EglInstance>> = Some(&egl);
|
||||||
|
|
||||||
let (display, wsi_library, wsi_kind) = if let (Some(library), Some(egl)) =
|
let (display, wsi_library, wsi_kind) = if let (Some(library), Some(egl)) =
|
||||||
@ -776,7 +776,10 @@ impl crate::Instance<super::Api> for Instance {
|
|||||||
) -> Result<Surface, crate::InstanceError> {
|
) -> Result<Surface, crate::InstanceError> {
|
||||||
use raw_window_handle::RawWindowHandle as Rwh;
|
use raw_window_handle::RawWindowHandle as Rwh;
|
||||||
|
|
||||||
#[cfg_attr(any(target_os = "android", feature = "emscripten"), allow(unused_mut))]
|
#[cfg_attr(
|
||||||
|
any(target_os = "android", target_os = "emscripten"),
|
||||||
|
allow(unused_mut)
|
||||||
|
)]
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.lock();
|
||||||
|
|
||||||
match (window_handle, display_handle) {
|
match (window_handle, display_handle) {
|
||||||
@ -801,7 +804,7 @@ impl crate::Instance<super::Api> for Instance {
|
|||||||
return Err(crate::InstanceError);
|
return Err(crate::InstanceError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
(Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => {
|
(Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => {
|
||||||
if inner
|
if inner
|
||||||
.wl_display
|
.wl_display
|
||||||
@ -841,7 +844,7 @@ impl crate::Instance<super::Api> for Instance {
|
|||||||
drop(old_inner);
|
drop(old_inner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
(Rwh::Web(_), _) => {}
|
(Rwh::Web(_), _) => {}
|
||||||
other => {
|
other => {
|
||||||
log::error!("Unsupported window: {:?}", other);
|
log::error!("Unsupported window: {:?}", other);
|
||||||
@ -1087,7 +1090,7 @@ impl crate::Surface<super::Api> for Surface {
|
|||||||
wl_window = Some(window);
|
wl_window = Some(window);
|
||||||
window
|
window
|
||||||
}
|
}
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
(WindowKind::Unknown, Rwh::Web(handle)) => handle.id as *mut std::ffi::c_void,
|
(WindowKind::Unknown, Rwh::Web(handle)) => handle.id as *mut std::ffi::c_void,
|
||||||
(WindowKind::Unknown, Rwh::Win32(handle)) => handle.hwnd,
|
(WindowKind::Unknown, Rwh::Win32(handle)) => handle.hwnd,
|
||||||
(WindowKind::Unknown, Rwh::AppKit(handle)) => {
|
(WindowKind::Unknown, Rwh::AppKit(handle)) => {
|
||||||
@ -1140,10 +1143,10 @@ impl crate::Surface<super::Api> for Surface {
|
|||||||
}
|
}
|
||||||
attributes.push(egl::ATTRIB_NONE as i32);
|
attributes.push(egl::ATTRIB_NONE as i32);
|
||||||
|
|
||||||
#[cfg(not(feature = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
let egl1_5 = self.egl.instance.upcast::<egl::EGL1_5>();
|
let egl1_5 = self.egl.instance.upcast::<egl::EGL1_5>();
|
||||||
|
|
||||||
#[cfg(feature = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
let egl1_5: Option<&Arc<EglInstance>> = Some(&self.egl.instance);
|
let egl1_5: Option<&Arc<EglInstance>> = Some(&self.egl.instance);
|
||||||
|
|
||||||
// Careful, we can still be in 1.4 version even if `upcast` succeeds
|
// Careful, we can still be in 1.4 version even if `upcast` succeeds
|
||||||
|
@ -57,9 +57,9 @@ To address this, we invalidate the vertex buffers based on:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
///cbindgen:ignore
|
///cbindgen:ignore
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
mod egl;
|
mod egl;
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
mod web;
|
mod web;
|
||||||
|
|
||||||
mod adapter;
|
mod adapter;
|
||||||
@ -70,14 +70,14 @@ mod queue;
|
|||||||
|
|
||||||
use crate::{CopyExtent, TextureDescriptor};
|
use crate::{CopyExtent, TextureDescriptor};
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub use self::egl::{AdapterContext, AdapterContextLock};
|
pub use self::egl::{AdapterContext, AdapterContextLock};
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
use self::egl::{Instance, Surface};
|
use self::egl::{Instance, Surface};
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub use self::web::AdapterContext;
|
pub use self::web::AdapterContext;
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
use self::web::{Instance, Surface};
|
use self::web::{Instance, Surface};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
@ -680,7 +680,7 @@ enum Command {
|
|||||||
dst_target: BindTarget,
|
dst_target: BindTarget,
|
||||||
copy: crate::BufferCopy,
|
copy: crate::BufferCopy,
|
||||||
},
|
},
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
CopyExternalImageToTexture {
|
CopyExternalImageToTexture {
|
||||||
src: wgt::ImageCopyExternalImage,
|
src: wgt::ImageCopyExternalImage,
|
||||||
dst: glow::Texture,
|
dst: glow::Texture,
|
||||||
|
@ -379,7 +379,7 @@ impl super::Queue {
|
|||||||
unsafe { gl.bind_buffer(copy_dst_target, None) };
|
unsafe { gl.bind_buffer(copy_dst_target, None) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
C::CopyExternalImageToTexture {
|
C::CopyExternalImageToTexture {
|
||||||
ref src,
|
ref src,
|
||||||
dst,
|
dst,
|
||||||
@ -1554,10 +1554,10 @@ impl crate::Queue<super::Api> for super::Queue {
|
|||||||
surface: &mut super::Surface,
|
surface: &mut super::Surface,
|
||||||
texture: super::Texture,
|
texture: super::Texture,
|
||||||
) -> Result<(), crate::SurfaceError> {
|
) -> Result<(), crate::SurfaceError> {
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
let gl = unsafe { &self.shared.context.get_without_egl_lock() };
|
let gl = unsafe { &self.shared.context.get_without_egl_lock() };
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
let gl = &self.shared.context.glow_context;
|
let gl = &self.shared.context.glow_context;
|
||||||
|
|
||||||
unsafe { surface.present(texture, gl) }
|
unsafe { surface.present(texture, gl) }
|
||||||
|
@ -407,7 +407,7 @@ pub trait CommandEncoder<A: Api>: Send + Sync + fmt::Debug {
|
|||||||
/// Works with a single array layer.
|
/// Works with a single array layer.
|
||||||
/// Note: `dst` current usage has to be `TextureUses::COPY_DST`.
|
/// Note: `dst` current usage has to be `TextureUses::COPY_DST`.
|
||||||
/// Note: the copy extent is in physical size (rounded to the block size)
|
/// Note: the copy extent is in physical size (rounded to the block size)
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
unsafe fn copy_external_image_to_texture<T>(
|
unsafe fn copy_external_image_to_texture<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
src: &wgt::ImageCopyExternalImage,
|
src: &wgt::ImageCopyExternalImage,
|
||||||
|
@ -97,7 +97,6 @@ trace = ["serde", "wgc/trace"]
|
|||||||
replay = ["serde", "wgc/replay"]
|
replay = ["serde", "wgc/replay"]
|
||||||
angle = ["wgc/angle"]
|
angle = ["wgc/angle"]
|
||||||
webgl = ["hal", "wgc"]
|
webgl = ["hal", "wgc"]
|
||||||
emscripten = ["webgl"]
|
|
||||||
vulkan-portability = ["wgc/vulkan"]
|
vulkan-portability = ["wgc/vulkan"]
|
||||||
expose-ids = []
|
expose-ids = []
|
||||||
|
|
||||||
@ -128,14 +127,10 @@ workspace = true
|
|||||||
features = ["dx11", "dx12"]
|
features = ["dx11", "dx12"]
|
||||||
|
|
||||||
# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
|
# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
|
||||||
[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
|
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["vulkan"]
|
features = ["vulkan"]
|
||||||
|
|
||||||
[target.'cfg(target_os = "emscripten")'.dependencies.wgc]
|
|
||||||
workspace = true
|
|
||||||
features = ["emscripten"]
|
|
||||||
|
|
||||||
[dependencies.wgt]
|
[dependencies.wgt]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ impl fmt::Debug for Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
|
||||||
pub unsafe fn from_hal_instance<A: wgc::hub::HalApi>(hal_instance: A::Instance) -> Self {
|
pub unsafe fn from_hal_instance<A: wgc::hub::HalApi>(hal_instance: A::Instance) -> Self {
|
||||||
Self(unsafe {
|
Self(unsafe {
|
||||||
wgc::hub::Global::from_hal_instance::<A>(
|
wgc::hub::Global::from_hal_instance::<A>(
|
||||||
@ -69,13 +68,13 @@ impl Context {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub fn enumerate_adapters(&self, backends: wgt::Backends) -> Vec<wgc::id::AdapterId> {
|
pub fn enumerate_adapters(&self, backends: wgt::Backends) -> Vec<wgc::id::AdapterId> {
|
||||||
self.0
|
self.0
|
||||||
.enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| ()))
|
.enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn create_adapter_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_adapter_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
hal_adapter: hal::ExposedAdapter<A>,
|
hal_adapter: hal::ExposedAdapter<A>,
|
||||||
@ -94,7 +93,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn create_device_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_device_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
adapter: &wgc::id::AdapterId,
|
adapter: &wgc::id::AdapterId,
|
||||||
@ -128,7 +127,6 @@ impl Context {
|
|||||||
Ok((device, queue))
|
Ok((device, queue))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten", feature = "webgl"))]
|
|
||||||
pub unsafe fn create_texture_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_texture_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
hal_texture: A::Texture,
|
hal_texture: A::Texture,
|
||||||
@ -154,7 +152,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn device_as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Device>) -> R, R>(
|
pub unsafe fn device_as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Device>) -> R, R>(
|
||||||
&self,
|
&self,
|
||||||
device: &Device,
|
device: &Device,
|
||||||
@ -166,7 +164,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn surface_as_hal_mut<
|
pub unsafe fn surface_as_hal_mut<
|
||||||
A: wgc::hub::HalApi,
|
A: wgc::hub::HalApi,
|
||||||
F: FnOnce(Option<&mut A::Surface>) -> R,
|
F: FnOnce(Option<&mut A::Surface>) -> R,
|
||||||
@ -182,7 +180,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn texture_as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Texture>)>(
|
pub unsafe fn texture_as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Texture>)>(
|
||||||
&self,
|
&self,
|
||||||
texture: &Texture,
|
texture: &Texture,
|
||||||
@ -194,7 +192,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
|
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
|
||||||
self.0.generate_report()
|
self.0.generate_report()
|
||||||
}
|
}
|
||||||
@ -211,7 +209,11 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl", not(feature = "emscripten")))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
feature = "webgl",
|
||||||
|
not(target_os = "emscripten")
|
||||||
|
))]
|
||||||
pub fn instance_create_surface_from_canvas(
|
pub fn instance_create_surface_from_canvas(
|
||||||
&self,
|
&self,
|
||||||
canvas: &web_sys::HtmlCanvasElement,
|
canvas: &web_sys::HtmlCanvasElement,
|
||||||
@ -226,7 +228,11 @@ impl Context {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl", not(feature = "emscripten")))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
feature = "webgl",
|
||||||
|
not(target_os = "emscripten")
|
||||||
|
))]
|
||||||
pub fn instance_create_surface_from_offscreen_canvas(
|
pub fn instance_create_surface_from_offscreen_canvas(
|
||||||
&self,
|
&self,
|
||||||
canvas: &web_sys::OffscreenCanvas,
|
canvas: &web_sys::OffscreenCanvas,
|
||||||
@ -353,7 +359,7 @@ fn map_texture_copy_view(view: crate::ImageCopyTexture) -> wgc::command::ImageCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
any(not(target_arch = "wasm32"), feature = "emscripten"),
|
any(not(target_arch = "wasm32"), target_os = "emscripten"),
|
||||||
allow(unused)
|
allow(unused)
|
||||||
)]
|
)]
|
||||||
fn map_texture_tagged_copy_view(
|
fn map_texture_tagged_copy_view(
|
||||||
@ -1408,7 +1414,7 @@ impl crate::Context for Context {
|
|||||||
fn device_drop(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) {
|
fn device_drop(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) {
|
||||||
let global = &self.0;
|
let global = &self.0;
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
{
|
{
|
||||||
match wgc::gfx_select!(device => global.device_poll(*device, wgt::Maintain::Wait)) {
|
match wgc::gfx_select!(device => global.device_poll(*device, wgt::Maintain::Wait)) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
@ -2219,7 +2225,7 @@ impl crate::Context for Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
fn queue_copy_external_image_to_texture(
|
fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &Self::QueueId,
|
queue: &Self::QueueId,
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
not(any(target_os = "emscripten", feature = "webgl"))
|
||||||
|
))]
|
||||||
mod web;
|
mod web;
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
not(any(target_os = "emscripten", feature = "webgl"))
|
||||||
|
))]
|
||||||
pub(crate) use web::Context;
|
pub(crate) use web::Context;
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
mod direct;
|
mod direct;
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub(crate) use direct::Context;
|
pub(crate) use direct::Context;
|
||||||
|
@ -2394,7 +2394,6 @@ impl crate::context::Context for Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
|
||||||
fn queue_copy_external_image_to_texture(
|
fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &Self::QueueId,
|
queue: &Self::QueueId,
|
||||||
|
@ -561,7 +561,7 @@ pub trait Context: Debug + Send + Sized + Sync {
|
|||||||
data_layout: ImageDataLayout,
|
data_layout: ImageDataLayout,
|
||||||
size: Extent3d,
|
size: Extent3d,
|
||||||
);
|
);
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
fn queue_copy_external_image_to_texture(
|
fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &Self::QueueId,
|
queue: &Self::QueueId,
|
||||||
@ -1488,7 +1488,7 @@ pub(crate) trait DynContext: Debug + Send + Sync {
|
|||||||
data_layout: ImageDataLayout,
|
data_layout: ImageDataLayout,
|
||||||
size: Extent3d,
|
size: Extent3d,
|
||||||
);
|
);
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
fn queue_copy_external_image_to_texture(
|
fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &ObjectId,
|
queue: &ObjectId,
|
||||||
@ -2884,7 +2884,7 @@ where
|
|||||||
Context::queue_write_texture(self, &queue, queue_data, texture, data, data_layout, size)
|
Context::queue_write_texture(self, &queue, queue_data, texture, data, data_layout, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
fn queue_copy_external_image_to_texture(
|
fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &ObjectId,
|
queue: &ObjectId,
|
||||||
|
@ -49,9 +49,9 @@ pub use wgt::{
|
|||||||
|
|
||||||
// wasm-only types, we try to keep as many types non-platform
|
// wasm-only types, we try to keep as many types non-platform
|
||||||
// specific, but these need to depend on web-sys.
|
// specific, but these need to depend on web-sys.
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub use wgt::{ExternalImageSource, ImageCopyExternalImage};
|
pub use wgt::{ExternalImageSource, ImageCopyExternalImage};
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
static_assertions::assert_impl_all!(ExternalImageSource: Send, Sync);
|
static_assertions::assert_impl_all!(ExternalImageSource: Send, Sync);
|
||||||
|
|
||||||
/// Filter for error scopes.
|
/// Filter for error scopes.
|
||||||
@ -1341,7 +1341,11 @@ impl Instance {
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// Refer to the creation of wgpu-hal Instance for every backend.
|
/// Refer to the creation of wgpu-hal Instance for every backend.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub unsafe fn from_hal<A: wgc::hub::HalApi>(hal_instance: A::Instance) -> Self {
|
pub unsafe fn from_hal<A: wgc::hub::HalApi>(hal_instance: A::Instance) -> Self {
|
||||||
Self {
|
Self {
|
||||||
context: Arc::new(unsafe {
|
context: Arc::new(unsafe {
|
||||||
@ -1360,7 +1364,11 @@ impl Instance {
|
|||||||
/// - The raw instance handle returned must not be manually destroyed.
|
/// - The raw instance handle returned must not be manually destroyed.
|
||||||
///
|
///
|
||||||
/// [`Instance`]: hal::Api::Instance
|
/// [`Instance`]: hal::Api::Instance
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub unsafe fn as_hal<A: wgc::hub::HalApi>(&self) -> Option<&A::Instance> {
|
pub unsafe fn as_hal<A: wgc::hub::HalApi>(&self) -> Option<&A::Instance> {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.context
|
self.context
|
||||||
@ -1380,7 +1388,11 @@ impl Instance {
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// Refer to the creation of wgpu-core Instance.
|
/// Refer to the creation of wgpu-core Instance.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub unsafe fn from_core(core_instance: wgc::instance::Instance) -> Self {
|
pub unsafe fn from_core(core_instance: wgc::instance::Instance) -> Self {
|
||||||
Self {
|
Self {
|
||||||
context: Arc::new(unsafe {
|
context: Arc::new(unsafe {
|
||||||
@ -1394,7 +1406,7 @@ impl Instance {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// - `backends` - Backends from which to enumerate adapters.
|
/// - `backends` - Backends from which to enumerate adapters.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub fn enumerate_adapters(&self, backends: Backends) -> impl Iterator<Item = Adapter> {
|
pub fn enumerate_adapters(&self, backends: Backends) -> impl Iterator<Item = Adapter> {
|
||||||
let context = Arc::clone(&self.context);
|
let context = Arc::clone(&self.context);
|
||||||
self.context
|
self.context
|
||||||
@ -1433,7 +1445,7 @@ impl Instance {
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// `hal_adapter` must be created from this instance internal handle.
|
/// `hal_adapter` must be created from this instance internal handle.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn create_adapter_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_adapter_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
hal_adapter: hal::ExposedAdapter<A>,
|
hal_adapter: hal::ExposedAdapter<A>,
|
||||||
@ -1575,7 +1587,7 @@ impl Instance {
|
|||||||
///
|
///
|
||||||
/// - On WebGL2: Will return an error if the browser does not support WebGL2,
|
/// - On WebGL2: Will return an error if the browser does not support WebGL2,
|
||||||
/// or declines to provide GPU access (such as due to a resource shortage).
|
/// or declines to provide GPU access (such as due to a resource shortage).
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub fn create_surface_from_canvas(
|
pub fn create_surface_from_canvas(
|
||||||
&self,
|
&self,
|
||||||
canvas: &web_sys::HtmlCanvasElement,
|
canvas: &web_sys::HtmlCanvasElement,
|
||||||
@ -1611,7 +1623,7 @@ impl Instance {
|
|||||||
///
|
///
|
||||||
/// - On WebGL2: Will return an error if the browser does not support WebGL2,
|
/// - On WebGL2: Will return an error if the browser does not support WebGL2,
|
||||||
/// or declines to provide GPU access (such as due to a resource shortage).
|
/// or declines to provide GPU access (such as due to a resource shortage).
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub fn create_surface_from_offscreen_canvas(
|
pub fn create_surface_from_offscreen_canvas(
|
||||||
&self,
|
&self,
|
||||||
canvas: &web_sys::OffscreenCanvas,
|
canvas: &web_sys::OffscreenCanvas,
|
||||||
@ -1659,7 +1671,7 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Generates memory report.
|
/// Generates memory report.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
|
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
|
||||||
self.context
|
self.context
|
||||||
.as_any()
|
.as_any()
|
||||||
@ -1730,7 +1742,7 @@ impl Adapter {
|
|||||||
///
|
///
|
||||||
/// - `hal_device` must be created from this adapter internal handle.
|
/// - `hal_device` must be created from this adapter internal handle.
|
||||||
/// - `desc.features` must be a subset of `hal_device` features.
|
/// - `desc.features` must be a subset of `hal_device` features.
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn create_device_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_device_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
hal_device: hal::OpenDevice<A>,
|
hal_device: hal::OpenDevice<A>,
|
||||||
@ -1780,7 +1792,11 @@ impl Adapter {
|
|||||||
/// - The raw handle passed to the callback must not be manually destroyed.
|
/// - The raw handle passed to the callback must not be manually destroyed.
|
||||||
///
|
///
|
||||||
/// [`A::Adapter`]: hal::Api::Adapter
|
/// [`A::Adapter`]: hal::Api::Adapter
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Adapter>) -> R, R>(
|
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Adapter>) -> R, R>(
|
||||||
&self,
|
&self,
|
||||||
hal_adapter_callback: F,
|
hal_adapter_callback: F,
|
||||||
@ -2125,7 +2141,11 @@ impl Device {
|
|||||||
/// - `hal_texture` must be created from this device internal handle
|
/// - `hal_texture` must be created from this device internal handle
|
||||||
/// - `hal_texture` must be created respecting `desc`
|
/// - `hal_texture` must be created respecting `desc`
|
||||||
/// - `hal_texture` must be initialized
|
/// - `hal_texture` must be initialized
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten", feature = "webgl"))]
|
#[cfg(any(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
target_os = "emscripten",
|
||||||
|
feature = "webgl"
|
||||||
|
))]
|
||||||
pub unsafe fn create_texture_from_hal<A: wgc::hub::HalApi>(
|
pub unsafe fn create_texture_from_hal<A: wgc::hub::HalApi>(
|
||||||
&self,
|
&self,
|
||||||
hal_texture: A::Texture,
|
hal_texture: A::Texture,
|
||||||
@ -2226,7 +2246,7 @@ impl Device {
|
|||||||
/// - The raw handle passed to the callback must not be manually destroyed.
|
/// - The raw handle passed to the callback must not be manually destroyed.
|
||||||
///
|
///
|
||||||
/// [`A::Device`]: hal::Api::Device
|
/// [`A::Device`]: hal::Api::Device
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Device>) -> R, R>(
|
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Device>) -> R, R>(
|
||||||
&self,
|
&self,
|
||||||
hal_device_callback: F,
|
hal_device_callback: F,
|
||||||
@ -2564,7 +2584,7 @@ impl Texture {
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// - The raw handle obtained from the hal Texture must not be manually destroyed
|
/// - The raw handle obtained from the hal Texture must not be manually destroyed
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Texture>)>(
|
pub unsafe fn as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&A::Texture>)>(
|
||||||
&self,
|
&self,
|
||||||
hal_texture_callback: F,
|
hal_texture_callback: F,
|
||||||
@ -3961,7 +3981,7 @@ impl Queue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule a copy of data from `image` into `texture`.
|
/// Schedule a copy of data from `image` into `texture`.
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub fn copy_external_image_to_texture(
|
pub fn copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
source: &wgt::ImageCopyExternalImage,
|
source: &wgt::ImageCopyExternalImage,
|
||||||
@ -4173,7 +4193,7 @@ impl Surface {
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// - The raw handle obtained from the hal Surface must not be manually destroyed
|
/// - The raw handle obtained from the hal Surface must not be manually destroyed
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
|
||||||
pub unsafe fn as_hal_mut<A: wgc::hub::HalApi, F: FnOnce(Option<&mut A::Surface>) -> R, R>(
|
pub unsafe fn as_hal_mut<A: wgc::hub::HalApi, F: FnOnce(Option<&mut A::Surface>) -> R, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
hal_surface_callback: F,
|
hal_surface_callback: F,
|
||||||
|
@ -340,12 +340,18 @@ fn initialize_adapter() -> (Adapter, SurfaceGuard) {
|
|||||||
let surface_guard;
|
let surface_guard;
|
||||||
let compatible_surface;
|
let compatible_surface;
|
||||||
|
|
||||||
#[cfg(not(all(target_arch = "wasm32", feature = "webgl")))]
|
#[cfg(not(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
)))]
|
||||||
{
|
{
|
||||||
surface_guard = SurfaceGuard {};
|
surface_guard = SurfaceGuard {};
|
||||||
compatible_surface = None;
|
compatible_surface = None;
|
||||||
}
|
}
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl"))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
))]
|
||||||
{
|
{
|
||||||
// On wasm, append a canvas to the document body for initializing the adapter
|
// On wasm, append a canvas to the document body for initializing the adapter
|
||||||
let canvas = create_html_canvas();
|
let canvas = create_html_canvas();
|
||||||
@ -371,14 +377,17 @@ fn initialize_adapter() -> (Adapter, SurfaceGuard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SurfaceGuard {
|
struct SurfaceGuard {
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl"))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
))]
|
||||||
canvas: web_sys::HtmlCanvasElement,
|
canvas: web_sys::HtmlCanvasElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SurfaceGuard {
|
impl SurfaceGuard {
|
||||||
fn check_for_unreported_errors(&self) -> bool {
|
fn check_for_unreported_errors(&self) -> bool {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(all(target_arch = "wasm32", feature = "webgl"))] {
|
if #[cfg(all(target_arch = "wasm32", any(target_os = "emscripten", feature = "webgl")))] {
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
self.canvas
|
self.canvas
|
||||||
@ -396,14 +405,20 @@ impl SurfaceGuard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl"))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
))]
|
||||||
impl Drop for SurfaceGuard {
|
impl Drop for SurfaceGuard {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
delete_html_canvas();
|
delete_html_canvas();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl"))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
))]
|
||||||
fn create_html_canvas() -> web_sys::HtmlCanvasElement {
|
fn create_html_canvas() -> web_sys::HtmlCanvasElement {
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
@ -419,7 +434,10 @@ fn create_html_canvas() -> web_sys::HtmlCanvasElement {
|
|||||||
.expect("couldn't append canvas to document body")
|
.expect("couldn't append canvas to document body")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", feature = "webgl"))]
|
#[cfg(all(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
any(target_os = "emscripten", feature = "webgl")
|
||||||
|
))]
|
||||||
fn delete_html_canvas() {
|
fn delete_html_canvas() {
|
||||||
if let Some(document) = web_sys::window().and_then(|win| win.document()) {
|
if let Some(document) = web_sys::window().and_then(|win| win.document()) {
|
||||||
if let Some(element) = document.get_element_by_id(CANVAS_ID) {
|
if let Some(element) = document.get_element_by_id(CANVAS_ID) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![cfg(all(target_arch = "wasm32", not(features = "emscripten")))]
|
#![cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
|
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user