2022-01-20 02:10:16 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
use deno_core::error::AnyError;
|
2021-04-28 12:41:50 -04:00
|
|
|
use deno_core::include_js_files;
|
|
|
|
use deno_core::op_async;
|
|
|
|
use deno_core::op_sync;
|
|
|
|
use deno_core::Extension;
|
|
|
|
use deno_core::OpFn;
|
2021-03-01 05:31:13 -05:00
|
|
|
use deno_core::OpState;
|
2021-04-02 09:47:57 -04:00
|
|
|
use deno_core::Resource;
|
2021-03-19 13:25:37 -04:00
|
|
|
use deno_core::ResourceId;
|
2021-03-01 05:31:13 -05:00
|
|
|
use serde::Deserialize;
|
2021-04-05 12:40:24 -04:00
|
|
|
use serde::Serialize;
|
2021-03-01 05:31:13 -05:00
|
|
|
use std::borrow::Cow;
|
|
|
|
use std::cell::RefCell;
|
2021-08-24 14:32:25 -04:00
|
|
|
use std::collections::HashSet;
|
2021-03-01 05:31:13 -05:00
|
|
|
use std::rc::Rc;
|
|
|
|
pub use wgpu_core;
|
|
|
|
pub use wgpu_types;
|
2021-08-24 14:32:25 -04:00
|
|
|
use wgpu_types::PowerPreference;
|
2021-03-01 05:31:13 -05:00
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
use error::DomExceptionOperationError;
|
2021-04-05 12:40:24 -04:00
|
|
|
use error::WebGpuResult;
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod macros {
|
|
|
|
macro_rules! gfx_select {
|
|
|
|
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
|
|
|
|
match $id.backend() {
|
2021-05-03 10:42:59 -04:00
|
|
|
#[cfg(not(target_os = "macos"))]
|
2021-08-24 07:29:42 -04:00
|
|
|
wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::api::Vulkan>( $($param),* ),
|
2021-05-03 10:42:59 -04:00
|
|
|
#[cfg(target_os = "macos")]
|
2021-08-24 07:29:42 -04:00
|
|
|
wgpu_types::Backend::Metal => $global.$method::<wgpu_core::api::Metal>( $($param),* ),
|
2021-05-03 10:42:59 -04:00
|
|
|
#[cfg(windows)]
|
2021-08-24 07:29:42 -04:00
|
|
|
wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::api::Dx12>( $($param),* ),
|
2021-05-03 10:42:59 -04:00
|
|
|
#[cfg(all(unix, not(target_os = "macos")))]
|
2021-08-24 07:29:42 -04:00
|
|
|
wgpu_types::Backend::Gl => $global.$method::<wgpu_core::api::Gles>( $($param),+ ),
|
2021-03-01 05:31:13 -05:00
|
|
|
other => panic!("Unexpected backend {:?}", other),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-05-03 10:42:59 -04:00
|
|
|
|
|
|
|
macro_rules! gfx_put {
|
|
|
|
($id:expr => $global:ident.$method:ident( $($param:expr),* ) => $state:expr, $rc:expr) => {{
|
|
|
|
let (val, maybe_err) = gfx_select!($id => $global.$method($($param),*));
|
|
|
|
let rid = $state.resource_table.add($rc(val));
|
|
|
|
Ok(WebGpuResult::rid_err(rid, maybe_err))
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! gfx_ok {
|
|
|
|
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {{
|
|
|
|
let maybe_err = gfx_select!($id => $global.$method($($param),*)).err();
|
|
|
|
Ok(WebGpuResult::maybe_err(maybe_err))
|
|
|
|
}};
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub mod binding;
|
|
|
|
pub mod buffer;
|
|
|
|
pub mod bundle;
|
|
|
|
pub mod command_encoder;
|
|
|
|
pub mod compute_pass;
|
|
|
|
pub mod error;
|
|
|
|
pub mod pipeline;
|
|
|
|
pub mod queue;
|
|
|
|
pub mod render_pass;
|
|
|
|
pub mod sampler;
|
|
|
|
pub mod shader;
|
|
|
|
pub mod texture;
|
|
|
|
|
|
|
|
pub struct Unstable(pub bool);
|
|
|
|
|
|
|
|
fn check_unstable(state: &OpState, api_name: &str) {
|
|
|
|
let unstable = state.borrow::<Unstable>();
|
|
|
|
if !unstable.0 {
|
|
|
|
eprintln!(
|
|
|
|
"Unstable API '{}'. The --unstable flag must be provided.",
|
|
|
|
api_name
|
|
|
|
);
|
|
|
|
std::process::exit(70);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Instance = wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>;
|
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
struct WebGpuAdapter(wgpu_core::id::AdapterId);
|
|
|
|
impl Resource for WebGpuAdapter {
|
2021-03-01 05:31:13 -05:00
|
|
|
fn name(&self) -> Cow<str> {
|
|
|
|
"webGPUAdapter".into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
struct WebGpuDevice(wgpu_core::id::DeviceId);
|
|
|
|
impl Resource for WebGpuDevice {
|
2021-03-01 05:31:13 -05:00
|
|
|
fn name(&self) -> Cow<str> {
|
|
|
|
"webGPUDevice".into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
struct WebGpuQuerySet(wgpu_core::id::QuerySetId);
|
|
|
|
impl Resource for WebGpuQuerySet {
|
2021-03-01 05:31:13 -05:00
|
|
|
fn name(&self) -> Cow<str> {
|
|
|
|
"webGPUQuerySet".into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-28 12:41:50 -04:00
|
|
|
pub fn init(unstable: bool) -> Extension {
|
2021-04-28 18:16:45 -04:00
|
|
|
Extension::builder()
|
|
|
|
.js(include_js_files!(
|
2021-08-11 06:27:05 -04:00
|
|
|
prefix "deno:ext/webgpu",
|
2021-04-28 12:41:50 -04:00
|
|
|
"01_webgpu.js",
|
|
|
|
"02_idl_types.js",
|
2021-04-28 18:16:45 -04:00
|
|
|
))
|
|
|
|
.ops(declare_webgpu_ops())
|
|
|
|
.state(move |state| {
|
2021-04-28 12:41:50 -04:00
|
|
|
// TODO: check & possibly streamline this
|
|
|
|
// Unstable might be able to be OpMiddleware
|
|
|
|
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
|
|
|
// let unstable = unstable_checker.unstable;
|
|
|
|
state.put(Unstable(unstable));
|
|
|
|
Ok(())
|
2021-04-28 18:16:45 -04:00
|
|
|
})
|
|
|
|
.build()
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 12:40:24 -04:00
|
|
|
fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
|
|
|
|
let mut return_features: Vec<&'static str> = vec![];
|
2021-03-01 05:31:13 -05:00
|
|
|
|
2022-01-24 17:47:05 -05:00
|
|
|
if features.contains(wgpu_types::Features::DEPTH_CLIP_CONTROL) {
|
|
|
|
return_features.push("depth-clip-control");
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::PIPELINE_STATISTICS_QUERY) {
|
|
|
|
return_features.push("pipeline-statistics-query");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::TEXTURE_COMPRESSION_BC) {
|
|
|
|
return_features.push("texture-compression-bc");
|
|
|
|
}
|
2022-01-24 17:47:05 -05:00
|
|
|
if features.contains(wgpu_types::Features::TEXTURE_COMPRESSION_ETC2) {
|
|
|
|
return_features.push("texture-compression-etc2");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::TEXTURE_COMPRESSION_ASTC_LDR) {
|
|
|
|
return_features.push("texture-compression-astc");
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
if features.contains(wgpu_types::Features::TIMESTAMP_QUERY) {
|
|
|
|
return_features.push("timestamp-query");
|
|
|
|
}
|
2022-01-24 17:47:05 -05:00
|
|
|
if features.contains(wgpu_types::Features::INDIRECT_FIRST_INSTANCE) {
|
|
|
|
return_features.push("indirect-first-instance");
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
// extended from spec
|
|
|
|
if features.contains(wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS) {
|
|
|
|
return_features.push("mappable-primary-buffers");
|
|
|
|
}
|
2021-08-24 07:29:42 -04:00
|
|
|
if features.contains(wgpu_types::Features::TEXTURE_BINDING_ARRAY) {
|
|
|
|
return_features.push("texture-binding-array");
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
2021-08-24 07:29:42 -04:00
|
|
|
if features.contains(wgpu_types::Features::BUFFER_BINDING_ARRAY) {
|
|
|
|
return_features.push("buffer-binding-array");
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
2021-08-24 07:29:42 -04:00
|
|
|
if features.contains(wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY) {
|
|
|
|
return_features.push("storage-resource-binding-array");
|
|
|
|
}
|
2022-01-24 17:47:05 -05:00
|
|
|
if features.contains(
|
|
|
|
wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
|
|
|
|
) {
|
|
|
|
return_features.push("sampled-texture-and-storage-buffer-array-non-uniform-indexing");
|
|
|
|
}
|
|
|
|
if features.contains(
|
|
|
|
wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
|
|
|
|
) {
|
|
|
|
return_features.push("uniform-buffer-and-storage-buffer-texture-non-uniform-indexing");
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
if features.contains(wgpu_types::Features::UNSIZED_BINDING_ARRAY) {
|
|
|
|
return_features.push("unsized-binding-array");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::MULTI_DRAW_INDIRECT) {
|
|
|
|
return_features.push("multi-draw-indirect");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::MULTI_DRAW_INDIRECT_COUNT) {
|
|
|
|
return_features.push("multi-draw-indirect-count");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::PUSH_CONSTANTS) {
|
|
|
|
return_features.push("push-constants");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::ADDRESS_MODE_CLAMP_TO_BORDER) {
|
|
|
|
return_features.push("address-mode-clamp-to-border");
|
|
|
|
}
|
|
|
|
if features
|
|
|
|
.contains(wgpu_types::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES)
|
|
|
|
{
|
|
|
|
return_features.push("texture-adapter-specific-format-features");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::SHADER_FLOAT64) {
|
|
|
|
return_features.push("shader-float64");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT) {
|
|
|
|
return_features.push("vertex-attribute-64bit");
|
|
|
|
}
|
2021-08-24 07:29:42 -04:00
|
|
|
if features.contains(wgpu_types::Features::CONSERVATIVE_RASTERIZATION) {
|
|
|
|
return_features.push("conservative-rasterization");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::VERTEX_WRITABLE_STORAGE) {
|
|
|
|
return_features.push("vertex-writable-storage");
|
|
|
|
}
|
2022-01-20 09:23:53 -05:00
|
|
|
if features.contains(wgpu_types::Features::CLEAR_COMMANDS) {
|
2022-01-24 17:47:05 -05:00
|
|
|
return_features.push("clear-texture");
|
2021-08-24 07:29:42 -04:00
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH) {
|
|
|
|
return_features.push("spirv-shader-passthrough");
|
|
|
|
}
|
|
|
|
if features.contains(wgpu_types::Features::SHADER_PRIMITIVE_INDEX) {
|
|
|
|
return_features.push("shader-primitive-index");
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
return_features
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct RequestAdapterArgs {
|
2022-01-24 17:47:05 -05:00
|
|
|
power_preference: Option<wgpu_types::PowerPreference>,
|
|
|
|
force_fallback_adapter: bool,
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 12:40:24 -04:00
|
|
|
#[derive(Serialize)]
|
|
|
|
#[serde(untagged)]
|
|
|
|
pub enum GpuAdapterDeviceOrErr {
|
|
|
|
Error { err: String },
|
|
|
|
Features(GpuAdapterDevice),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct GpuAdapterDevice {
|
|
|
|
rid: ResourceId,
|
|
|
|
name: Option<String>,
|
|
|
|
limits: wgpu_types::Limits,
|
|
|
|
features: Vec<&'static str>,
|
2021-07-08 05:07:49 -04:00
|
|
|
is_software: bool,
|
2021-04-05 12:40:24 -04:00
|
|
|
}
|
|
|
|
|
2021-03-01 05:31:13 -05:00
|
|
|
pub async fn op_webgpu_request_adapter(
|
|
|
|
state: Rc<RefCell<OpState>>,
|
|
|
|
args: RequestAdapterArgs,
|
2021-05-08 08:37:42 -04:00
|
|
|
_: (),
|
2021-04-05 12:40:24 -04:00
|
|
|
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
|
2021-03-01 05:31:13 -05:00
|
|
|
let mut state = state.borrow_mut();
|
|
|
|
check_unstable(&state, "navigator.gpu.requestAdapter");
|
2022-01-24 17:47:05 -05:00
|
|
|
let backends = std::env::var("DENO_WEBGPU_BACKEND")
|
|
|
|
.ok()
|
|
|
|
.map_or_else(wgpu_types::Backends::all, |s| {
|
|
|
|
wgpu_core::instance::parse_backends_from_comma_list(&s)
|
|
|
|
});
|
2021-03-19 19:43:54 -04:00
|
|
|
let instance = if let Some(instance) = state.try_borrow::<Instance>() {
|
|
|
|
instance
|
|
|
|
} else {
|
|
|
|
state.put(wgpu_core::hub::Global::new(
|
|
|
|
"webgpu",
|
|
|
|
wgpu_core::hub::IdentityManagerFactory,
|
2022-01-24 17:47:05 -05:00
|
|
|
backends,
|
2021-03-19 19:43:54 -04:00
|
|
|
));
|
|
|
|
state.borrow::<Instance>()
|
|
|
|
};
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
let descriptor = wgpu_core::instance::RequestAdapterOptions {
|
|
|
|
power_preference: match args.power_preference {
|
2022-01-24 17:47:05 -05:00
|
|
|
Some(power_preference) => power_preference,
|
2021-08-24 14:32:25 -04:00
|
|
|
None => PowerPreference::default(),
|
2021-03-01 05:31:13 -05:00
|
|
|
},
|
2022-01-24 17:47:05 -05:00
|
|
|
force_fallback_adapter: args.force_fallback_adapter,
|
2021-03-01 05:31:13 -05:00
|
|
|
compatible_surface: None, // windowless
|
|
|
|
};
|
|
|
|
let res = instance.request_adapter(
|
|
|
|
&descriptor,
|
2022-01-24 17:47:05 -05:00
|
|
|
wgpu_core::instance::AdapterInputs::Mask(backends, |_| {
|
|
|
|
std::marker::PhantomData
|
|
|
|
}),
|
2021-03-01 05:31:13 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
let adapter = match res {
|
|
|
|
Ok(adapter) => adapter,
|
|
|
|
Err(err) => {
|
2021-04-05 12:40:24 -04:00
|
|
|
return Ok(GpuAdapterDeviceOrErr::Error {
|
|
|
|
err: err.to_string(),
|
|
|
|
})
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
let name = gfx_select!(adapter => instance.adapter_get_info(adapter))?.name;
|
|
|
|
let adapter_features =
|
|
|
|
gfx_select!(adapter => instance.adapter_features(adapter))?;
|
|
|
|
let features = deserialize_features(&adapter_features);
|
|
|
|
let adapter_limits =
|
|
|
|
gfx_select!(adapter => instance.adapter_limits(adapter))?;
|
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
let rid = state.resource_table.add(WebGpuAdapter(adapter));
|
2021-03-01 05:31:13 -05:00
|
|
|
|
2021-04-05 12:40:24 -04:00
|
|
|
Ok(GpuAdapterDeviceOrErr::Features(GpuAdapterDevice {
|
|
|
|
rid,
|
|
|
|
name: Some(name),
|
|
|
|
features,
|
|
|
|
limits: adapter_limits,
|
2021-07-08 05:07:49 -04:00
|
|
|
is_software: false,
|
2021-03-01 05:31:13 -05:00
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct RequestDeviceArgs {
|
2021-03-19 13:25:37 -04:00
|
|
|
adapter_rid: ResourceId,
|
2021-03-01 05:31:13 -05:00
|
|
|
label: Option<String>,
|
2021-08-24 14:32:25 -04:00
|
|
|
required_features: Option<GpuRequiredFeatures>,
|
2022-01-24 17:47:05 -05:00
|
|
|
required_limits: Option<wgpu_types::Limits>,
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
2021-08-24 14:32:25 -04:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct GpuRequiredFeatures(HashSet<String>);
|
2021-03-01 05:31:13 -05:00
|
|
|
|
2021-08-24 14:32:25 -04:00
|
|
|
impl From<GpuRequiredFeatures> for wgpu_types::Features {
|
|
|
|
fn from(required_features: GpuRequiredFeatures) -> wgpu_types::Features {
|
|
|
|
let mut features: wgpu_types::Features = wgpu_types::Features::empty();
|
2022-01-24 17:47:05 -05:00
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::DEPTH_CLIP_CONTROL,
|
|
|
|
required_features.0.contains("depth-clip-control"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::PIPELINE_STATISTICS_QUERY,
|
|
|
|
required_features.0.contains("pipeline-statistics-query"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TEXTURE_COMPRESSION_BC,
|
|
|
|
required_features.0.contains("texture-compression-bc"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TEXTURE_COMPRESSION_ETC2,
|
|
|
|
required_features.0.contains("texture-compression-etc2"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TEXTURE_COMPRESSION_ASTC_LDR,
|
|
|
|
required_features.0.contains("texture-compression-astc"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TIMESTAMP_QUERY,
|
|
|
|
required_features.0.contains("timestamp-query"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::INDIRECT_FIRST_INSTANCE,
|
|
|
|
required_features.0.contains("indirect-first-instance"),
|
|
|
|
);
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
// extended from spec
|
2022-01-24 17:47:05 -05:00
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS,
|
|
|
|
required_features.0.contains("mappable-primary-buffers"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TEXTURE_BINDING_ARRAY,
|
|
|
|
required_features.0.contains("texture-binding-array"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::BUFFER_BINDING_ARRAY,
|
|
|
|
required_features.0.contains("buffer-binding-array"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY,
|
|
|
|
required_features
|
|
|
|
.0
|
|
|
|
.contains("storage-resource-binding-array"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
|
|
|
|
required_features
|
|
|
|
.0
|
|
|
|
.contains("sampled-texture-and-storage-buffer-array-non-uniform-indexing"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
|
|
|
|
required_features
|
|
|
|
.0
|
|
|
|
.contains("uniform-buffer-and-storage-buffer-texture-non-uniform-indexing"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::UNSIZED_BINDING_ARRAY,
|
|
|
|
required_features.0.contains("unsized-binding-array"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::MULTI_DRAW_INDIRECT,
|
|
|
|
required_features.0.contains("multi-draw-indirect"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::MULTI_DRAW_INDIRECT_COUNT,
|
|
|
|
required_features.0.contains("multi-draw-indirect-count"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::PUSH_CONSTANTS,
|
|
|
|
required_features.0.contains("push-constants"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::ADDRESS_MODE_CLAMP_TO_BORDER,
|
|
|
|
required_features.0.contains("address-mode-clamp-to-border"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
|
|
|
|
required_features
|
|
|
|
.0
|
|
|
|
.contains("texture-adapter-specific-format-features"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::SHADER_FLOAT64,
|
|
|
|
required_features.0.contains("shader-float64"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT,
|
|
|
|
required_features.0.contains("vertex-attribute-64bit"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::CONSERVATIVE_RASTERIZATION,
|
|
|
|
required_features.0.contains("conservative-rasterization"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::VERTEX_WRITABLE_STORAGE,
|
|
|
|
required_features.0.contains("vertex-writable-storage"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::CLEAR_COMMANDS,
|
|
|
|
required_features.0.contains("clear-commands"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH,
|
|
|
|
required_features.0.contains("spirv-shader-passthrough"),
|
|
|
|
);
|
|
|
|
features.set(
|
|
|
|
wgpu_types::Features::SHADER_PRIMITIVE_INDEX,
|
|
|
|
required_features.0.contains("shader-primitive-index"),
|
|
|
|
);
|
2021-08-24 14:32:25 -04:00
|
|
|
|
|
|
|
features
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
2021-08-24 14:32:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn op_webgpu_request_device(
|
|
|
|
state: Rc<RefCell<OpState>>,
|
|
|
|
args: RequestDeviceArgs,
|
|
|
|
_: (),
|
|
|
|
) -> Result<GpuAdapterDevice, AnyError> {
|
|
|
|
let mut state = state.borrow_mut();
|
|
|
|
let adapter_resource = state
|
|
|
|
.resource_table
|
|
|
|
.get::<WebGpuAdapter>(args.adapter_rid)?;
|
|
|
|
let adapter = adapter_resource.0;
|
|
|
|
let instance = state.borrow::<Instance>();
|
2021-03-01 05:31:13 -05:00
|
|
|
|
|
|
|
let descriptor = wgpu_types::DeviceDescriptor {
|
|
|
|
label: args.label.map(Cow::from),
|
2021-08-24 14:32:25 -04:00
|
|
|
features: args.required_features.map(Into::into).unwrap_or_default(),
|
|
|
|
limits: args.required_limits.map(Into::into).unwrap_or_default(),
|
2021-03-01 05:31:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
let (device, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(
|
|
|
|
adapter,
|
|
|
|
&descriptor,
|
|
|
|
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
|
|
|
|
std::marker::PhantomData
|
|
|
|
));
|
|
|
|
if let Some(err) = maybe_err {
|
2021-03-25 14:17:37 -04:00
|
|
|
return Err(DomExceptionOperationError::new(&err.to_string()).into());
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
let device_features =
|
|
|
|
gfx_select!(device => instance.device_features(device))?;
|
|
|
|
let features = deserialize_features(&device_features);
|
|
|
|
let limits = gfx_select!(device => instance.device_limits(device))?;
|
|
|
|
|
2021-03-25 14:17:37 -04:00
|
|
|
let rid = state.resource_table.add(WebGpuDevice(device));
|
2021-03-01 05:31:13 -05:00
|
|
|
|
2021-04-05 12:40:24 -04:00
|
|
|
Ok(GpuAdapterDevice {
|
|
|
|
rid,
|
|
|
|
name: None,
|
|
|
|
features,
|
|
|
|
limits,
|
2021-07-08 05:07:49 -04:00
|
|
|
// TODO(lucacasonato): report correctly from wgpu
|
|
|
|
is_software: false,
|
2021-04-05 12:40:24 -04:00
|
|
|
})
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct CreateQuerySetArgs {
|
2021-03-19 13:25:37 -04:00
|
|
|
device_rid: ResourceId,
|
2021-08-24 07:29:42 -04:00
|
|
|
label: Option<String>,
|
2021-08-24 14:32:25 -04:00
|
|
|
#[serde(flatten)]
|
|
|
|
r#type: GpuQueryType,
|
2021-03-01 05:31:13 -05:00
|
|
|
count: u32,
|
2021-08-24 14:32:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
#[serde(rename_all = "kebab-case", tag = "type")]
|
|
|
|
enum GpuQueryType {
|
|
|
|
Occlusion,
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
PipelineStatistics {
|
|
|
|
pipeline_statistics: HashSet<String>,
|
|
|
|
},
|
|
|
|
Timestamp,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<GpuQueryType> for wgpu_types::QueryType {
|
|
|
|
fn from(query_type: GpuQueryType) -> Self {
|
|
|
|
match query_type {
|
|
|
|
GpuQueryType::Occlusion => wgpu_types::QueryType::Occlusion,
|
|
|
|
GpuQueryType::PipelineStatistics {
|
|
|
|
pipeline_statistics,
|
|
|
|
} => {
|
|
|
|
use wgpu_types::PipelineStatisticsTypes;
|
|
|
|
|
|
|
|
let mut types = PipelineStatisticsTypes::empty();
|
|
|
|
|
|
|
|
if pipeline_statistics.contains("vertex-shader-invocations") {
|
|
|
|
types.set(PipelineStatisticsTypes::VERTEX_SHADER_INVOCATIONS, true);
|
|
|
|
}
|
|
|
|
if pipeline_statistics.contains("clipper-invocations") {
|
|
|
|
types.set(PipelineStatisticsTypes::CLIPPER_INVOCATIONS, true);
|
|
|
|
}
|
|
|
|
if pipeline_statistics.contains("clipper-primitives-out") {
|
|
|
|
types.set(PipelineStatisticsTypes::CLIPPER_PRIMITIVES_OUT, true);
|
|
|
|
}
|
|
|
|
if pipeline_statistics.contains("fragment-shader-invocations") {
|
|
|
|
types.set(PipelineStatisticsTypes::FRAGMENT_SHADER_INVOCATIONS, true);
|
|
|
|
}
|
|
|
|
if pipeline_statistics.contains("compute-shader-invocations") {
|
|
|
|
types.set(PipelineStatisticsTypes::COMPUTE_SHADER_INVOCATIONS, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
wgpu_types::QueryType::PipelineStatistics(types)
|
|
|
|
}
|
|
|
|
GpuQueryType::Timestamp => wgpu_types::QueryType::Timestamp,
|
|
|
|
}
|
|
|
|
}
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn op_webgpu_create_query_set(
|
|
|
|
state: &mut OpState,
|
|
|
|
args: CreateQuerySetArgs,
|
2021-05-08 08:37:42 -04:00
|
|
|
_: (),
|
2021-04-05 12:40:24 -04:00
|
|
|
) -> Result<WebGpuResult, AnyError> {
|
2021-08-15 07:29:19 -04:00
|
|
|
let device_resource =
|
|
|
|
state.resource_table.get::<WebGpuDevice>(args.device_rid)?;
|
2021-03-01 05:31:13 -05:00
|
|
|
let device = device_resource.0;
|
|
|
|
let instance = &state.borrow::<Instance>();
|
|
|
|
|
|
|
|
let descriptor = wgpu_types::QuerySetDescriptor {
|
2021-08-24 07:29:42 -04:00
|
|
|
label: args.label.map(Cow::from),
|
2021-08-24 14:32:25 -04:00
|
|
|
ty: args.r#type.into(),
|
2021-03-01 05:31:13 -05:00
|
|
|
count: args.count,
|
|
|
|
};
|
|
|
|
|
2021-05-03 10:42:59 -04:00
|
|
|
gfx_put!(device => instance.device_create_query_set(
|
2021-03-01 05:31:13 -05:00
|
|
|
device,
|
|
|
|
&descriptor,
|
|
|
|
std::marker::PhantomData
|
2021-05-03 10:42:59 -04:00
|
|
|
) => state, WebGpuQuerySet)
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
2021-04-28 12:41:50 -04:00
|
|
|
|
|
|
|
fn declare_webgpu_ops() -> Vec<(&'static str, Box<OpFn>)> {
|
|
|
|
vec![
|
|
|
|
// Request device/adapter
|
|
|
|
(
|
|
|
|
"op_webgpu_request_adapter",
|
|
|
|
op_async(op_webgpu_request_adapter),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_request_device",
|
|
|
|
op_async(op_webgpu_request_device),
|
|
|
|
),
|
|
|
|
// Query Set
|
|
|
|
(
|
|
|
|
"op_webgpu_create_query_set",
|
|
|
|
op_sync(op_webgpu_create_query_set),
|
|
|
|
),
|
|
|
|
// buffer
|
|
|
|
(
|
|
|
|
"op_webgpu_create_buffer",
|
|
|
|
op_sync(buffer::op_webgpu_create_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_buffer_get_mapped_range",
|
|
|
|
op_sync(buffer::op_webgpu_buffer_get_mapped_range),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_buffer_unmap",
|
|
|
|
op_sync(buffer::op_webgpu_buffer_unmap),
|
|
|
|
),
|
|
|
|
// buffer async
|
|
|
|
(
|
|
|
|
"op_webgpu_buffer_get_map_async",
|
|
|
|
op_async(buffer::op_webgpu_buffer_get_map_async),
|
|
|
|
),
|
|
|
|
// remaining sync ops
|
|
|
|
|
|
|
|
// texture
|
|
|
|
(
|
|
|
|
"op_webgpu_create_texture",
|
|
|
|
op_sync(texture::op_webgpu_create_texture),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_create_texture_view",
|
|
|
|
op_sync(texture::op_webgpu_create_texture_view),
|
|
|
|
),
|
|
|
|
// sampler
|
|
|
|
(
|
|
|
|
"op_webgpu_create_sampler",
|
|
|
|
op_sync(sampler::op_webgpu_create_sampler),
|
|
|
|
),
|
|
|
|
// binding
|
|
|
|
(
|
|
|
|
"op_webgpu_create_bind_group_layout",
|
|
|
|
op_sync(binding::op_webgpu_create_bind_group_layout),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_create_pipeline_layout",
|
|
|
|
op_sync(binding::op_webgpu_create_pipeline_layout),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_create_bind_group",
|
|
|
|
op_sync(binding::op_webgpu_create_bind_group),
|
|
|
|
),
|
|
|
|
// pipeline
|
|
|
|
(
|
|
|
|
"op_webgpu_create_compute_pipeline",
|
|
|
|
op_sync(pipeline::op_webgpu_create_compute_pipeline),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pipeline_get_bind_group_layout",
|
|
|
|
op_sync(pipeline::op_webgpu_compute_pipeline_get_bind_group_layout),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_create_render_pipeline",
|
|
|
|
op_sync(pipeline::op_webgpu_create_render_pipeline),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pipeline_get_bind_group_layout",
|
|
|
|
op_sync(pipeline::op_webgpu_render_pipeline_get_bind_group_layout),
|
|
|
|
),
|
|
|
|
// command_encoder
|
|
|
|
(
|
|
|
|
"op_webgpu_create_command_encoder",
|
|
|
|
op_sync(command_encoder::op_webgpu_create_command_encoder),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_begin_render_pass",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_begin_render_pass),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_begin_compute_pass",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_begin_compute_pass),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_copy_buffer_to_buffer",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_copy_buffer_to_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_copy_buffer_to_texture",
|
|
|
|
op_sync(
|
|
|
|
command_encoder::op_webgpu_command_encoder_copy_buffer_to_texture,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_copy_texture_to_buffer",
|
|
|
|
op_sync(
|
|
|
|
command_encoder::op_webgpu_command_encoder_copy_texture_to_buffer,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_copy_texture_to_texture",
|
|
|
|
op_sync(
|
|
|
|
command_encoder::op_webgpu_command_encoder_copy_texture_to_texture,
|
|
|
|
),
|
|
|
|
),
|
2022-01-24 17:47:05 -05:00
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_clear_buffer",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_clear_buffer),
|
|
|
|
),
|
2021-04-28 12:41:50 -04:00
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_push_debug_group",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_push_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_pop_debug_group",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_pop_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_insert_debug_marker",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_insert_debug_marker),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_write_timestamp",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_write_timestamp),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_resolve_query_set",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_resolve_query_set),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_command_encoder_finish",
|
|
|
|
op_sync(command_encoder::op_webgpu_command_encoder_finish),
|
|
|
|
),
|
|
|
|
// render_pass
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_viewport",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_viewport),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_scissor_rect",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_scissor_rect),
|
|
|
|
),
|
|
|
|
(
|
2021-05-06 10:48:45 -04:00
|
|
|
"op_webgpu_render_pass_set_blend_constant",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_blend_constant),
|
2021-04-28 12:41:50 -04:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_stencil_reference",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_stencil_reference),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_begin_pipeline_statistics_query",
|
|
|
|
op_sync(
|
|
|
|
render_pass::op_webgpu_render_pass_begin_pipeline_statistics_query,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_end_pipeline_statistics_query",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_end_pipeline_statistics_query),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_write_timestamp",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_write_timestamp),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_execute_bundles",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_execute_bundles),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_end_pass",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_end_pass),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_bind_group",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_bind_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_push_debug_group",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_push_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_pop_debug_group",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_pop_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_insert_debug_marker",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_insert_debug_marker),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_pipeline",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_pipeline),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_index_buffer",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_index_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_set_vertex_buffer",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_set_vertex_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_draw",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_draw),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_draw_indexed",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_draw_indexed),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_draw_indirect",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_draw_indirect),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_pass_draw_indexed_indirect",
|
|
|
|
op_sync(render_pass::op_webgpu_render_pass_draw_indexed_indirect),
|
|
|
|
),
|
|
|
|
// compute_pass
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_set_pipeline",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_set_pipeline),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_dispatch",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_dispatch),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_dispatch_indirect",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_dispatch_indirect),
|
|
|
|
),
|
2022-01-24 17:47:05 -05:00
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_begin_pipeline_statistics_query",
|
|
|
|
op_sync(
|
|
|
|
compute_pass::op_webgpu_compute_pass_begin_pipeline_statistics_query,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_end_pipeline_statistics_query",
|
|
|
|
op_sync(
|
|
|
|
compute_pass::op_webgpu_compute_pass_end_pipeline_statistics_query,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_write_timestamp",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_write_timestamp),
|
|
|
|
),
|
2021-04-28 12:41:50 -04:00
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_end_pass",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_end_pass),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_set_bind_group",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_set_bind_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_push_debug_group",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_push_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_pop_debug_group",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_pop_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_compute_pass_insert_debug_marker",
|
|
|
|
op_sync(compute_pass::op_webgpu_compute_pass_insert_debug_marker),
|
|
|
|
),
|
|
|
|
// bundle
|
|
|
|
(
|
|
|
|
"op_webgpu_create_render_bundle_encoder",
|
|
|
|
op_sync(bundle::op_webgpu_create_render_bundle_encoder),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_finish",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_finish),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_set_bind_group",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_set_bind_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_push_debug_group",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_push_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_pop_debug_group",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_pop_debug_group),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_insert_debug_marker",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_insert_debug_marker),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_set_pipeline",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_set_pipeline),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_set_index_buffer",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_set_index_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_set_vertex_buffer",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_set_vertex_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_draw",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_draw),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_draw_indexed",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_draw_indexed),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_render_bundle_encoder_draw_indirect",
|
|
|
|
op_sync(bundle::op_webgpu_render_bundle_encoder_draw_indirect),
|
|
|
|
),
|
|
|
|
// queue
|
|
|
|
(
|
|
|
|
"op_webgpu_queue_submit",
|
|
|
|
op_sync(queue::op_webgpu_queue_submit),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_write_buffer",
|
|
|
|
op_sync(queue::op_webgpu_write_buffer),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"op_webgpu_write_texture",
|
|
|
|
op_sync(queue::op_webgpu_write_texture),
|
|
|
|
),
|
|
|
|
// shader
|
|
|
|
(
|
|
|
|
"op_webgpu_create_shader_module",
|
|
|
|
op_sync(shader::op_webgpu_create_shader_module),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
}
|