mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
parent
c5d5dbc7eb
commit
cd6eb2db36
@ -11,12 +11,11 @@ publish = false
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_console = "0.35.0"
|
deno_console = "0.42.0"
|
||||||
deno_core = "0.117.0"
|
deno_core = "0.124.0"
|
||||||
deno_timers = "0.33.0"
|
deno_url = "0.42.0"
|
||||||
deno_url = "0.35.0"
|
deno_web = "0.73.0"
|
||||||
deno_web = "0.66.0"
|
deno_webidl = "0.42.0"
|
||||||
deno_webidl = "0.35.0"
|
|
||||||
deno_webgpu = { path = "../deno_webgpu" }
|
deno_webgpu = { path = "../deno_webgpu" }
|
||||||
tokio = { version = "1.15.0", features = ["full"] }
|
tokio = { version = "1.15.0", features = ["full"] }
|
||||||
termcolor = "1.1.2"
|
termcolor = "1.1.2"
|
||||||
|
@ -92,7 +92,7 @@ computePass.setPipeline(computePipeline);
|
|||||||
computePass.setBindGroup(0, bindGroup);
|
computePass.setBindGroup(0, bindGroup);
|
||||||
computePass.insertDebugMarker("compute collatz iterations");
|
computePass.insertDebugMarker("compute collatz iterations");
|
||||||
computePass.dispatch(numbers.length);
|
computePass.dispatch(numbers.length);
|
||||||
computePass.endPass();
|
computePass.end();
|
||||||
|
|
||||||
encoder.copyBufferToBuffer(storageBuffer, 0, stagingBuffer, 0, size);
|
encoder.copyBufferToBuffer(storageBuffer, 0, stagingBuffer, 0, size);
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ use std::{
|
|||||||
use deno_core::anyhow::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
|
use deno_core::op;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use deno_core::JsRuntime;
|
use deno_core::JsRuntime;
|
||||||
use deno_core::OpState;
|
|
||||||
use deno_core::RuntimeOptions;
|
use deno_core::RuntimeOptions;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use deno_web::BlobStore;
|
use deno_web::BlobStore;
|
||||||
@ -40,8 +40,7 @@ async fn run() -> Result<(), AnyError> {
|
|||||||
deno_webidl::init(),
|
deno_webidl::init(),
|
||||||
deno_console::init(),
|
deno_console::init(),
|
||||||
deno_url::init(),
|
deno_url::init(),
|
||||||
deno_web::init(BlobStore::default(), None),
|
deno_web::init::<Permissions>(BlobStore::default(), None),
|
||||||
deno_timers::init::<Permissions>(),
|
|
||||||
deno_webgpu::init(true),
|
deno_webgpu::init(true),
|
||||||
extension(),
|
extension(),
|
||||||
],
|
],
|
||||||
@ -53,10 +52,7 @@ async fn run() -> Result<(), AnyError> {
|
|||||||
let bootstrap_script = format!("globalThis.bootstrap({})", serde_json::to_string(&cfg)?);
|
let bootstrap_script = format!("globalThis.bootstrap({})", serde_json::to_string(&cfg)?);
|
||||||
isolate.execute_script(&located_script_name!(), &bootstrap_script)?;
|
isolate.execute_script(&located_script_name!(), &bootstrap_script)?;
|
||||||
|
|
||||||
isolate
|
isolate.op_state().borrow_mut().put(Permissions {});
|
||||||
.op_state()
|
|
||||||
.borrow_mut()
|
|
||||||
.put(Permissions{});
|
|
||||||
|
|
||||||
let mod_id = isolate.load_main_module(&specifier, None).await?;
|
let mod_id = isolate.load_main_module(&specifier, None).await?;
|
||||||
let mod_rx = isolate.mod_evaluate(mod_id);
|
let mod_rx = isolate.mod_evaluate(mod_id);
|
||||||
@ -77,9 +73,9 @@ async fn run() -> Result<(), AnyError> {
|
|||||||
fn extension() -> deno_core::Extension {
|
fn extension() -> deno_core::Extension {
|
||||||
deno_core::Extension::builder()
|
deno_core::Extension::builder()
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
("op_exit", deno_core::op_sync(op_exit)),
|
op_exit::decl(),
|
||||||
("op_read_file_sync", deno_core::op_sync(op_read_file_sync)),
|
op_read_file_sync::decl(),
|
||||||
("op_write_file_sync", deno_core::op_sync(op_write_file_sync)),
|
op_write_file_sync::decl(),
|
||||||
])
|
])
|
||||||
.js(deno_core::include_js_files!(
|
.js(deno_core::include_js_files!(
|
||||||
prefix "deno:cts_runner",
|
prefix "deno:cts_runner",
|
||||||
@ -88,11 +84,13 @@ fn extension() -> deno_core::Extension {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_exit(_state: &mut OpState, code: i32, _: ()) -> Result<(), AnyError> {
|
#[op]
|
||||||
|
fn op_exit(code: i32) -> Result<(), AnyError> {
|
||||||
std::process::exit(code)
|
std::process::exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_read_file_sync(_state: &mut OpState, path: String, _: ()) -> Result<ZeroCopyBuf, AnyError> {
|
#[op]
|
||||||
|
fn op_read_file_sync(path: String) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let path = std::path::Path::new(&path);
|
let path = std::path::Path::new(&path);
|
||||||
let mut file = std::fs::File::open(path)?;
|
let mut file = std::fs::File::open(path)?;
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
@ -100,11 +98,8 @@ fn op_read_file_sync(_state: &mut OpState, path: String, _: ()) -> Result<ZeroCo
|
|||||||
Ok(ZeroCopyBuf::from(buf))
|
Ok(ZeroCopyBuf::from(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_write_file_sync(
|
#[op]
|
||||||
_state: &mut OpState,
|
fn op_write_file_sync(path: String, buf: ZeroCopyBuf) -> Result<(), AnyError> {
|
||||||
path: String,
|
|
||||||
buf: ZeroCopyBuf,
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let path = std::path::Path::new(&path);
|
let path = std::path::Path::new(&path);
|
||||||
let mut file = std::fs::File::create(path)?;
|
let mut file = std::fs::File::create(path)?;
|
||||||
file.write_all(&buf)?;
|
file.write_all(&buf)?;
|
||||||
@ -153,7 +148,7 @@ fn red_bold<S: AsRef<str>>(s: S) -> impl fmt::Display {
|
|||||||
// NOP permissions
|
// NOP permissions
|
||||||
struct Permissions;
|
struct Permissions;
|
||||||
|
|
||||||
impl deno_timers::TimersPermission for Permissions {
|
impl deno_web::TimersPermission for Permissions {
|
||||||
fn allow_hrtime(&mut self) -> bool {
|
fn allow_hrtime(&mut self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
PromiseReject,
|
PromiseReject,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
|
SafeArrayIterator,
|
||||||
Set,
|
Set,
|
||||||
SetPrototypeEntries,
|
SetPrototypeEntries,
|
||||||
SetPrototypeForEach,
|
SetPrototypeForEach,
|
||||||
@ -224,10 +225,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {InnerGPUAdapter} inner
|
* @param {InnerGPUAdapter} inner
|
||||||
* @returns {GPUAdapter}
|
* @returns {GPUAdapter}
|
||||||
*/
|
*/
|
||||||
function createGPUAdapter(name, inner) {
|
function createGPUAdapter(name, inner) {
|
||||||
/** @type {GPUAdapter} */
|
/** @type {GPUAdapter} */
|
||||||
const adapter = webidl.createBranded(GPUAdapter);
|
const adapter = webidl.createBranded(GPUAdapter);
|
||||||
@ -296,7 +297,7 @@
|
|||||||
"op_webgpu_request_device",
|
"op_webgpu_request_device",
|
||||||
{
|
{
|
||||||
adapterRid: this[_adapter].rid,
|
adapterRid: this[_adapter].rid,
|
||||||
labe: descriptor.label,
|
label: descriptor.label,
|
||||||
requiredFeatures,
|
requiredFeatures,
|
||||||
requiredLimits,
|
requiredLimits,
|
||||||
},
|
},
|
||||||
@ -543,7 +544,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
||||||
return `${this.constructor.name} ${inspect([...this.values()])}`;
|
return `${this.constructor.name} ${
|
||||||
|
inspect([...new SafeArrayIterator(this.values())])
|
||||||
|
}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +556,6 @@
|
|||||||
const _message = Symbol("[[message]]");
|
const _message = Symbol("[[message]]");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param {string | undefined} reason
|
* @param {string | undefined} reason
|
||||||
* @param {string} message
|
* @param {string} message
|
||||||
* @returns {GPUDeviceLostInfo}
|
* @returns {GPUDeviceLostInfo}
|
||||||
@ -601,24 +603,26 @@
|
|||||||
* @param {any} type
|
* @param {any} type
|
||||||
*/
|
*/
|
||||||
function GPUObjectBaseMixin(name, type) {
|
function GPUObjectBaseMixin(name, type) {
|
||||||
type.prototype[_label] = null;
|
type.prototype[_label] = undefined;
|
||||||
ObjectDefineProperty(type.prototype, "label", {
|
ObjectDefineProperty(type.prototype, "label", {
|
||||||
/**
|
/**
|
||||||
* @return {string | null}
|
* @return {string | undefined}
|
||||||
*/
|
*/
|
||||||
get() {
|
get() {
|
||||||
webidl.assertBranded(this, type.prototype);
|
webidl.assertBranded(this, type.prototype);
|
||||||
return this[_label];
|
return this[_label];
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @param {string | null} label
|
* @param {string | undefined} label
|
||||||
*/
|
*/
|
||||||
set(label) {
|
set(label) {
|
||||||
webidl.assertBranded(this, type.prototype);
|
webidl.assertBranded(this, type.prototype);
|
||||||
label = webidl.converters["UVString?"](label, {
|
if (label !== undefined) {
|
||||||
prefix: `Failed to set 'label' on '${name}'`,
|
label = webidl.converters["UVString"](label, {
|
||||||
context: "Argument 1",
|
prefix: `Failed to set 'label' on '${name}'`,
|
||||||
});
|
context: "Argument 1",
|
||||||
|
});
|
||||||
|
}
|
||||||
this[_label] = label;
|
this[_label] = label;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -774,7 +778,6 @@
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(@crowlKats): https://gpuweb.github.io/gpuweb/#errors-and-debugging
|
|
||||||
class GPUDevice extends eventTarget.EventTarget {
|
class GPUDevice extends eventTarget.EventTarget {
|
||||||
/** @type {InnerGPUDevice} */
|
/** @type {InnerGPUDevice} */
|
||||||
[_device];
|
[_device];
|
||||||
@ -865,7 +868,7 @@
|
|||||||
descriptor.usage,
|
descriptor.usage,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
device.trackResource((buffer));
|
device.trackResource(buffer);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,7 +897,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((texture));
|
device.trackResource(texture);
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +924,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((sampler));
|
device.trackResource(sampler);
|
||||||
return sampler;
|
return sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,7 +967,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((bindGroupLayout));
|
device.trackResource(bindGroupLayout);
|
||||||
return bindGroupLayout;
|
return bindGroupLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,7 +1009,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((pipelineLayout));
|
device.trackResource(pipelineLayout);
|
||||||
return pipelineLayout;
|
return pipelineLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,7 +1104,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((bindGroup));
|
device.trackResource(bindGroup);
|
||||||
return bindGroup;
|
return bindGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1133,7 +1136,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((shaderModule));
|
device.trackResource(shaderModule);
|
||||||
return shaderModule;
|
return shaderModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1190,7 +1193,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((computePipeline));
|
device.trackResource(computePipeline);
|
||||||
return computePipeline;
|
return computePipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,7 +1268,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((renderPipeline));
|
device.trackResource(renderPipeline);
|
||||||
return renderPipeline;
|
return renderPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1305,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((commandEncoder));
|
device.trackResource(commandEncoder);
|
||||||
return commandEncoder;
|
return commandEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1337,7 +1340,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((renderBundleEncoder));
|
device.trackResource(renderBundleEncoder);
|
||||||
return renderBundleEncoder;
|
return renderBundleEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1369,7 +1372,7 @@
|
|||||||
rid,
|
rid,
|
||||||
descriptor,
|
descriptor,
|
||||||
);
|
);
|
||||||
device.trackResource((querySet));
|
device.trackResource(querySet);
|
||||||
return querySet;
|
return querySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1927,7 +1930,7 @@
|
|||||||
const { err } = core.opSync("op_webgpu_buffer_unmap", {
|
const { err } = core.opSync("op_webgpu_buffer_unmap", {
|
||||||
bufferRid,
|
bufferRid,
|
||||||
mappedRid,
|
mappedRid,
|
||||||
}, ...(write ? [new Uint8Array(buffer)] : []));
|
}, ...new SafeArrayIterator(write ? [new Uint8Array(buffer)] : []));
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
if (err) return;
|
if (err) return;
|
||||||
}
|
}
|
||||||
@ -2290,8 +2293,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string | null} label
|
* @param {string | null} label
|
||||||
* @param {InnerGPUDevice} device
|
* @param {InnerGPUDevice} device
|
||||||
* @param {number} rid
|
* @param {number} rid
|
||||||
* @returns {GPUBindGroup}
|
* @returns {GPUBindGroup}
|
||||||
*/
|
*/
|
||||||
function createGPUBindGroup(label, device, rid) {
|
function createGPUBindGroup(label, device, rid) {
|
||||||
@ -2333,8 +2336,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string | null} label
|
* @param {string | null} label
|
||||||
* @param {InnerGPUDevice} device
|
* @param {InnerGPUDevice} device
|
||||||
* @param {number} rid
|
* @param {number} rid
|
||||||
* @returns {GPUShaderModule}
|
* @returns {GPUShaderModule}
|
||||||
*/
|
*/
|
||||||
function createGPUShaderModule(label, device, rid) {
|
function createGPUShaderModule(label, device, rid) {
|
||||||
@ -2458,7 +2461,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((bindGroupLayout));
|
device.trackResource(bindGroupLayout);
|
||||||
return bindGroupLayout;
|
return bindGroupLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2534,7 +2537,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((bindGroupLayout));
|
device.trackResource(bindGroupLayout);
|
||||||
return bindGroupLayout;
|
return bindGroupLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2662,28 +2665,6 @@
|
|||||||
...descriptor.depthStencilAttachment,
|
...descriptor.depthStencilAttachment,
|
||||||
view,
|
view,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
|
||||||
typeof descriptor.depthStencilAttachment.depthLoadValue === "string"
|
|
||||||
) {
|
|
||||||
depthStencilAttachment.depthLoadOp =
|
|
||||||
descriptor.depthStencilAttachment.depthLoadValue;
|
|
||||||
} else {
|
|
||||||
depthStencilAttachment.depthLoadOp = {
|
|
||||||
clear: descriptor.depthStencilAttachment.depthLoadValue,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof descriptor.depthStencilAttachment.stencilLoadValue === "string"
|
|
||||||
) {
|
|
||||||
depthStencilAttachment.stencilLoadOp =
|
|
||||||
descriptor.depthStencilAttachment.stencilLoadValue;
|
|
||||||
} else {
|
|
||||||
depthStencilAttachment.stencilLoadOp = {
|
|
||||||
clear: descriptor.depthStencilAttachment.stencilLoadValue,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const colorAttachments = ArrayPrototypeMap(
|
const colorAttachments = ArrayPrototypeMap(
|
||||||
descriptor.colorAttachments,
|
descriptor.colorAttachments,
|
||||||
@ -2730,21 +2711,13 @@
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const attachment = {
|
return {
|
||||||
view: view,
|
view: view,
|
||||||
resolveTarget,
|
resolveTarget,
|
||||||
storeOp: colorAttachment.storeOp,
|
storeOp: colorAttachment.storeOp,
|
||||||
|
loadOp: colorAttachment.loadOp,
|
||||||
|
clearValue: normalizeGPUColor(colorAttachment.clearValue),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof colorAttachment.loadValue === "string") {
|
|
||||||
attachment.loadOp = colorAttachment.loadValue;
|
|
||||||
} else {
|
|
||||||
attachment.loadOp = {
|
|
||||||
clear: normalizeGPUColor(colorAttachment.loadValue),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return attachment;
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -3085,20 +3058,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {GPUBuffer} destination
|
* @param {GPUBuffer} buffer
|
||||||
* @param {GPUSize64} destinationOffset
|
* @param {GPUSize64} offset
|
||||||
* @param {GPUSize64} size
|
* @param {GPUSize64} size
|
||||||
*/
|
*/
|
||||||
clearBuffer(destination, destinationOffset, size) {
|
clearBuffer(buffer, offset = 0, size = undefined) {
|
||||||
webidl.assertBranded(this, GPUCommandEncoderPrototype);
|
webidl.assertBranded(this, GPUCommandEncoderPrototype);
|
||||||
const prefix =
|
const prefix = "Failed to execute 'clearBuffer' on 'GPUCommandEncoder'";
|
||||||
"Failed to execute 'clearBuffer' on 'GPUCommandEncoder'";
|
|
||||||
webidl.requiredArguments(arguments.length, 3, { prefix });
|
webidl.requiredArguments(arguments.length, 3, { prefix });
|
||||||
destination = webidl.converters.GPUBuffer(destination, {
|
buffer = webidl.converters.GPUBuffer(buffer, {
|
||||||
prefix,
|
prefix,
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
destinationOffset = webidl.converters.GPUSize64(destinationOffset, {
|
offset = webidl.converters.GPUSize64(offset, {
|
||||||
prefix,
|
prefix,
|
||||||
context: "Argument 2",
|
context: "Argument 2",
|
||||||
});
|
});
|
||||||
@ -3111,7 +3083,7 @@
|
|||||||
prefix,
|
prefix,
|
||||||
context: "this",
|
context: "this",
|
||||||
});
|
});
|
||||||
const destinationRid = assertResource(destination, {
|
const bufferRid = assertResource(buffer, {
|
||||||
prefix,
|
prefix,
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
@ -3119,8 +3091,8 @@
|
|||||||
"op_webgpu_command_encoder_clear_buffer",
|
"op_webgpu_command_encoder_clear_buffer",
|
||||||
{
|
{
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
destinationRid,
|
bufferRid,
|
||||||
destinationOffset,
|
offset,
|
||||||
size,
|
size,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -3344,7 +3316,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((commandBuffer));
|
device.trackResource(commandBuffer);
|
||||||
return commandBuffer;
|
return commandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3444,7 +3416,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param {number} x
|
* @param {number} x
|
||||||
* @param {number} y
|
* @param {number} y
|
||||||
* @param {number} width
|
* @param {number} width
|
||||||
@ -3690,9 +3661,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
endPass() {
|
end() {
|
||||||
webidl.assertBranded(this, GPURenderPassEncoderPrototype);
|
webidl.assertBranded(this, GPURenderPassEncoderPrototype);
|
||||||
const prefix = "Failed to execute 'endPass' on 'GPURenderPassEncoder'";
|
const prefix = "Failed to execute 'end' on 'GPURenderPassEncoder'";
|
||||||
const device = assertDevice(this[_encoder], {
|
const device = assertDevice(this[_encoder], {
|
||||||
prefix,
|
prefix,
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
@ -3702,7 +3673,7 @@
|
|||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
||||||
const { err } = core.opSync("op_webgpu_render_pass_end_pass", {
|
const { err } = core.opSync("op_webgpu_render_pass_end", {
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
});
|
});
|
||||||
@ -4247,17 +4218,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} x
|
* @param {number} workgroupCountX
|
||||||
* @param {number} y
|
* @param {number} workgroupCountY
|
||||||
* @param {number} z
|
* @param {number} workgroupCountZ
|
||||||
*/
|
*/
|
||||||
dispatch(x, y = 1, z = 1) {
|
dispatch(workgroupCountX, workgroupCountY = 1, workgroupCountZ = 1) {
|
||||||
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
|
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
|
||||||
const prefix = "Failed to execute 'dispatch' on 'GPUComputePassEncoder'";
|
const prefix = "Failed to execute 'dispatch' on 'GPUComputePassEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
x = webidl.converters.GPUSize32(x, { prefix, context: "Argument 1" });
|
workgroupCountX = webidl.converters.GPUSize32(workgroupCountX, {
|
||||||
y = webidl.converters.GPUSize32(y, { prefix, context: "Argument 2" });
|
prefix,
|
||||||
z = webidl.converters.GPUSize32(z, { prefix, context: "Argument 3" });
|
context: "Argument 1",
|
||||||
|
});
|
||||||
|
workgroupCountY = webidl.converters.GPUSize32(workgroupCountY, {
|
||||||
|
prefix,
|
||||||
|
context: "Argument 2",
|
||||||
|
});
|
||||||
|
workgroupCountZ = webidl.converters.GPUSize32(workgroupCountZ, {
|
||||||
|
prefix,
|
||||||
|
context: "Argument 3",
|
||||||
|
});
|
||||||
assertDevice(this[_encoder], {
|
assertDevice(this[_encoder], {
|
||||||
prefix,
|
prefix,
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
@ -4269,9 +4249,9 @@
|
|||||||
const computePassRid = assertResource(this, { prefix, context: "this" });
|
const computePassRid = assertResource(this, { prefix, context: "this" });
|
||||||
core.opSync("op_webgpu_compute_pass_dispatch", {
|
core.opSync("op_webgpu_compute_pass_dispatch", {
|
||||||
computePassRid,
|
computePassRid,
|
||||||
x,
|
x: workgroupCountX,
|
||||||
y,
|
y: workgroupCountY,
|
||||||
z,
|
z: workgroupCountZ,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4422,9 +4402,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
endPass() {
|
end() {
|
||||||
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
|
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
|
||||||
const prefix = "Failed to execute 'endPass' on 'GPUComputePassEncoder'";
|
const prefix = "Failed to execute 'end' on 'GPUComputePassEncoder'";
|
||||||
const device = assertDevice(this[_encoder], {
|
const device = assertDevice(this[_encoder], {
|
||||||
prefix,
|
prefix,
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
@ -4434,7 +4414,7 @@
|
|||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const computePassRid = assertResource(this, { prefix, context: "this" });
|
const computePassRid = assertResource(this, { prefix, context: "this" });
|
||||||
const { err } = core.opSync("op_webgpu_compute_pass_end_pass", {
|
const { err } = core.opSync("op_webgpu_compute_pass_end", {
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
computePassRid,
|
computePassRid,
|
||||||
});
|
});
|
||||||
@ -4682,7 +4662,7 @@
|
|||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
device.trackResource((renderBundle));
|
device.trackResource(renderBundle);
|
||||||
return renderBundle;
|
return renderBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,6 +341,8 @@
|
|||||||
"depth24plus",
|
"depth24plus",
|
||||||
"depth24plus-stencil8",
|
"depth24plus-stencil8",
|
||||||
"depth32float",
|
"depth32float",
|
||||||
|
"depth24unorm-stencil8",
|
||||||
|
"depth32float-stencil8",
|
||||||
"bc1-rgba-unorm",
|
"bc1-rgba-unorm",
|
||||||
"bc1-rgba-unorm-srgb",
|
"bc1-rgba-unorm-srgb",
|
||||||
"bc2-rgba-unorm",
|
"bc2-rgba-unorm",
|
||||||
@ -393,8 +395,6 @@
|
|||||||
"astc-12x10-unorm-srgb",
|
"astc-12x10-unorm-srgb",
|
||||||
"astc-12x12-unorm",
|
"astc-12x12-unorm",
|
||||||
"astc-12x12-unorm-srgb",
|
"astc-12x12-unorm-srgb",
|
||||||
"depth24unorm-stencil8",
|
|
||||||
"depth32float-stencil8",
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1675,6 +1675,7 @@
|
|||||||
// ENUM: GPULoadOp
|
// ENUM: GPULoadOp
|
||||||
webidl.converters["GPULoadOp"] = webidl.createEnumConverter("GPULoadOp", [
|
webidl.converters["GPULoadOp"] = webidl.createEnumConverter("GPULoadOp", [
|
||||||
"load",
|
"load",
|
||||||
|
"clear",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// DICTIONARY: GPUColorDict
|
// DICTIONARY: GPUColorDict
|
||||||
@ -1724,8 +1725,12 @@
|
|||||||
},
|
},
|
||||||
{ key: "resolveTarget", converter: webidl.converters["GPUTextureView"] },
|
{ key: "resolveTarget", converter: webidl.converters["GPUTextureView"] },
|
||||||
{
|
{
|
||||||
key: "loadValue",
|
key: "clearValue",
|
||||||
converter: webidl.converters.any, /** put union here! **/
|
converter: webidl.converters["GPUColor"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "loadOp",
|
||||||
|
converter: webidl.converters["GPULoadOp"],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1748,14 +1753,17 @@
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "depthLoadValue",
|
key: "depthClearValue",
|
||||||
converter: webidl.converters.any, /** put union here! **/
|
converter: webidl.converters["float"],
|
||||||
required: true,
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "depthLoadOp",
|
||||||
|
converter: webidl.converters["GPULoadOp"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "depthStoreOp",
|
key: "depthStoreOp",
|
||||||
converter: webidl.converters["GPUStoreOp"],
|
converter: webidl.converters["GPUStoreOp"],
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "depthReadOnly",
|
key: "depthReadOnly",
|
||||||
@ -1763,14 +1771,17 @@
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "stencilLoadValue",
|
key: "stencilClearValue",
|
||||||
converter: webidl.converters.any, /** put union here! **/
|
converter: webidl.converters["GPUStencilValue"],
|
||||||
required: true,
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "stencilLoadOp",
|
||||||
|
converter: webidl.converters["GPULoadOp"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "stencilStoreOp",
|
key: "stencilStoreOp",
|
||||||
converter: webidl.converters["GPUStoreOp"],
|
converter: webidl.converters["GPUStoreOp"],
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "stencilReadOnly",
|
key: "stencilReadOnly",
|
||||||
|
@ -11,7 +11,7 @@ repository = "https://github.com/gfx-rs/wgpu"
|
|||||||
description = "WebGPU implementation for Deno"
|
description = "WebGPU implementation for Deno"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_core = "0.117.0"
|
deno_core = "0.124.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tokio = { version = "1.10", features = ["full"] }
|
tokio = { version = "1.10", features = ["full"] }
|
||||||
wgpu-core = { path = "../wgpu-core", features = ["trace", "replay", "serde"] }
|
wgpu-core = { path = "../wgpu-core", features = ["trace", "replay", "serde"] }
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::TryFrom;
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use super::error::WebGpuResult;
|
use super::error::WebGpuResult;
|
||||||
|
|
||||||
@ -169,10 +172,10 @@ pub struct CreateBindGroupLayoutArgs {
|
|||||||
entries: Vec<GpuBindGroupLayoutEntry>,
|
entries: Vec<GpuBindGroupLayoutEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_bind_group_layout(
|
pub fn op_webgpu_create_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBindGroupLayoutArgs,
|
args: CreateBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -211,10 +214,10 @@ pub struct CreatePipelineLayoutArgs {
|
|||||||
bind_group_layouts: Vec<u32>,
|
bind_group_layouts: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_pipeline_layout(
|
pub fn op_webgpu_create_pipeline_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreatePipelineLayoutArgs,
|
args: CreatePipelineLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -261,10 +264,10 @@ pub struct CreateBindGroupArgs {
|
|||||||
entries: Vec<GpuBindGroupEntry>,
|
entries: Vec<GpuBindGroupEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_bind_group(
|
pub fn op_webgpu_create_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBindGroupArgs,
|
args: CreateBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::futures::channel::oneshot;
|
use deno_core::futures::channel::oneshot;
|
||||||
|
use deno_core::op;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
@ -10,6 +11,7 @@ use deno_core::ZeroCopyBuf;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::convert::TryFrom;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@ -40,10 +42,10 @@ pub struct CreateBufferArgs {
|
|||||||
mapped_at_creation: bool,
|
mapped_at_creation: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_buffer(
|
pub fn op_webgpu_create_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBufferArgs,
|
args: CreateBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -76,10 +78,10 @@ pub struct BufferGetMapAsyncArgs {
|
|||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub async fn op_webgpu_buffer_get_map_async(
|
pub async fn op_webgpu_buffer_get_map_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: BufferGetMapAsyncArgs,
|
args: BufferGetMapAsyncArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();
|
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();
|
||||||
|
|
||||||
@ -166,6 +168,7 @@ pub struct BufferGetMappedRangeArgs {
|
|||||||
size: Option<u64>,
|
size: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_buffer_get_mapped_range(
|
pub fn op_webgpu_buffer_get_mapped_range(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: BufferGetMappedRangeArgs,
|
args: BufferGetMappedRangeArgs,
|
||||||
@ -199,6 +202,7 @@ pub struct BufferUnmapArgs {
|
|||||||
mapped_rid: ResourceId,
|
mapped_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_buffer_unmap(
|
pub fn op_webgpu_buffer_unmap(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: BufferUnmapArgs,
|
args: BufferUnmapArgs,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -37,22 +39,16 @@ pub struct CreateRenderBundleEncoderArgs {
|
|||||||
stencil_read_only: bool,
|
stencil_read_only: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_render_bundle_encoder(
|
pub fn op_webgpu_create_render_bundle_encoder(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateRenderBundleEncoderArgs,
|
args: CreateRenderBundleEncoderArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<super::WebGpuDevice>(args.device_rid)?;
|
.get::<super::WebGpuDevice>(args.device_rid)?;
|
||||||
let device = device_resource.0;
|
let device = device_resource.0;
|
||||||
|
|
||||||
let mut color_formats = vec![];
|
|
||||||
|
|
||||||
for format in args.color_formats {
|
|
||||||
color_formats.push(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
let depth_stencil = if let Some(format) = args.depth_stencil_format {
|
let depth_stencil = if let Some(format) = args.depth_stencil_format {
|
||||||
Some(wgpu_types::RenderBundleDepthStencil {
|
Some(wgpu_types::RenderBundleDepthStencil {
|
||||||
format,
|
format,
|
||||||
@ -65,7 +61,7 @@ pub fn op_webgpu_create_render_bundle_encoder(
|
|||||||
|
|
||||||
let descriptor = wgpu_core::command::RenderBundleEncoderDescriptor {
|
let descriptor = wgpu_core::command::RenderBundleEncoderDescriptor {
|
||||||
label: args.label.map(Cow::from),
|
label: args.label.map(Cow::from),
|
||||||
color_formats: Cow::from(color_formats),
|
color_formats: Cow::from(args.color_formats),
|
||||||
sample_count: args.sample_count,
|
sample_count: args.sample_count,
|
||||||
depth_stencil,
|
depth_stencil,
|
||||||
multiview: None,
|
multiview: None,
|
||||||
@ -96,10 +92,10 @@ pub struct RenderBundleEncoderFinishArgs {
|
|||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_finish(
|
pub fn op_webgpu_render_bundle_encoder_finish(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderFinishArgs,
|
args: RenderBundleEncoderFinishArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -131,10 +127,10 @@ pub struct RenderBundleEncoderSetBindGroupArgs {
|
|||||||
dynamic_offsets_data_length: usize,
|
dynamic_offsets_data_length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_bind_group(
|
pub fn op_webgpu_render_bundle_encoder_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetBindGroupArgs,
|
args: RenderBundleEncoderSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource = state
|
let bind_group_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -183,10 +179,10 @@ pub struct RenderBundleEncoderPushDebugGroupArgs {
|
|||||||
group_label: String,
|
group_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_push_debug_group(
|
pub fn op_webgpu_render_bundle_encoder_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderPushDebugGroupArgs,
|
args: RenderBundleEncoderPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -211,10 +207,10 @@ pub struct RenderBundleEncoderPopDebugGroupArgs {
|
|||||||
render_bundle_encoder_rid: ResourceId,
|
render_bundle_encoder_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
|
pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderPopDebugGroupArgs,
|
args: RenderBundleEncoderPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -234,10 +230,10 @@ pub struct RenderBundleEncoderInsertDebugMarkerArgs {
|
|||||||
marker_label: String,
|
marker_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_insert_debug_marker(
|
pub fn op_webgpu_render_bundle_encoder_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderInsertDebugMarkerArgs,
|
args: RenderBundleEncoderInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -263,10 +259,10 @@ pub struct RenderBundleEncoderSetPipelineArgs {
|
|||||||
pipeline: ResourceId,
|
pipeline: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_pipeline(
|
pub fn op_webgpu_render_bundle_encoder_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetPipelineArgs,
|
args: RenderBundleEncoderSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pipeline_resource = state
|
let render_pipeline_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -293,10 +289,10 @@ pub struct RenderBundleEncoderSetIndexBufferArgs {
|
|||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
|
pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetIndexBufferArgs,
|
args: RenderBundleEncoderSetIndexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -328,10 +324,10 @@ pub struct RenderBundleEncoderSetVertexBufferArgs {
|
|||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetVertexBufferArgs,
|
args: RenderBundleEncoderSetVertexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -361,10 +357,10 @@ pub struct RenderBundleEncoderDrawArgs {
|
|||||||
first_instance: u32,
|
first_instance: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw(
|
pub fn op_webgpu_render_bundle_encoder_draw(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawArgs,
|
args: RenderBundleEncoderDrawArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -392,10 +388,10 @@ pub struct RenderBundleEncoderDrawIndexedArgs {
|
|||||||
first_instance: u32,
|
first_instance: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw_indexed(
|
pub fn op_webgpu_render_bundle_encoder_draw_indexed(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawIndexedArgs,
|
args: RenderBundleEncoderDrawIndexedArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource = state
|
let render_bundle_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -421,10 +417,10 @@ pub struct RenderBundleEncoderDrawIndirectArgs {
|
|||||||
indirect_offset: u64,
|
indirect_offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw_indirect(
|
pub fn op_webgpu_render_bundle_encoder_draw_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawIndirectArgs,
|
args: RenderBundleEncoderDrawIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -32,10 +34,10 @@ pub struct CreateCommandEncoderArgs {
|
|||||||
_measure_execution_time: Option<bool>, // not yet implemented
|
_measure_execution_time: Option<bool>, // not yet implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_command_encoder(
|
pub fn op_webgpu_create_command_encoder(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateCommandEncoderArgs,
|
args: CreateCommandEncoderArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -59,25 +61,21 @@ pub fn op_webgpu_create_command_encoder(
|
|||||||
pub struct GpuRenderPassColorAttachment {
|
pub struct GpuRenderPassColorAttachment {
|
||||||
view: ResourceId,
|
view: ResourceId,
|
||||||
resolve_target: Option<ResourceId>,
|
resolve_target: Option<ResourceId>,
|
||||||
load_op: GpuLoadOp<wgpu_types::Color>,
|
clear_value: Option<wgpu_types::Color>,
|
||||||
|
load_op: wgpu_core::command::LoadOp,
|
||||||
store_op: wgpu_core::command::StoreOp,
|
store_op: wgpu_core::command::StoreOp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
enum GpuLoadOp<T> {
|
|
||||||
Load,
|
|
||||||
Clear(T),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct GpuRenderPassDepthStencilAttachment {
|
struct GpuRenderPassDepthStencilAttachment {
|
||||||
view: ResourceId,
|
view: ResourceId,
|
||||||
depth_load_op: GpuLoadOp<f32>,
|
depth_clear_value: f32,
|
||||||
|
depth_load_op: wgpu_core::command::LoadOp,
|
||||||
depth_store_op: wgpu_core::command::StoreOp,
|
depth_store_op: wgpu_core::command::StoreOp,
|
||||||
depth_read_only: bool,
|
depth_read_only: bool,
|
||||||
stencil_load_op: GpuLoadOp<u32>,
|
stencil_clear_value: u32,
|
||||||
|
stencil_load_op: wgpu_core::command::LoadOp,
|
||||||
stencil_store_op: wgpu_core::command::StoreOp,
|
stencil_store_op: wgpu_core::command::StoreOp,
|
||||||
stencil_read_only: bool,
|
stencil_read_only: bool,
|
||||||
}
|
}
|
||||||
@ -92,10 +90,10 @@ pub struct CommandEncoderBeginRenderPassArgs {
|
|||||||
_occlusion_query_set: Option<u32>, // not yet implemented
|
_occlusion_query_set: Option<u32>, // not yet implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_begin_render_pass(
|
pub fn op_webgpu_command_encoder_begin_render_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderBeginRenderPassArgs,
|
args: CommandEncoderBeginRenderPassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -121,19 +119,11 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
|
|||||||
let attachment = wgpu_core::command::RenderPassColorAttachment {
|
let attachment = wgpu_core::command::RenderPassColorAttachment {
|
||||||
view: texture_view_resource.0,
|
view: texture_view_resource.0,
|
||||||
resolve_target,
|
resolve_target,
|
||||||
channel: match color_attachment.load_op {
|
channel: wgpu_core::command::PassChannel {
|
||||||
GpuLoadOp::Load => wgpu_core::command::PassChannel {
|
load_op: color_attachment.load_op,
|
||||||
load_op: wgpu_core::command::LoadOp::Load,
|
store_op: color_attachment.store_op,
|
||||||
store_op: color_attachment.store_op,
|
clear_value: color_attachment.clear_value.unwrap_or_default(),
|
||||||
clear_value: Default::default(),
|
read_only: false,
|
||||||
read_only: false,
|
|
||||||
},
|
|
||||||
GpuLoadOp::Clear(color) => wgpu_core::command::PassChannel {
|
|
||||||
load_op: wgpu_core::command::LoadOp::Clear,
|
|
||||||
store_op: color_attachment.store_op,
|
|
||||||
clear_value: color,
|
|
||||||
read_only: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -149,33 +139,17 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
|
|||||||
|
|
||||||
depth_stencil_attachment = Some(wgpu_core::command::RenderPassDepthStencilAttachment {
|
depth_stencil_attachment = Some(wgpu_core::command::RenderPassDepthStencilAttachment {
|
||||||
view: texture_view_resource.0,
|
view: texture_view_resource.0,
|
||||||
depth: match attachment.depth_load_op {
|
depth: wgpu_core::command::PassChannel {
|
||||||
GpuLoadOp::Load => wgpu_core::command::PassChannel {
|
load_op: attachment.depth_load_op,
|
||||||
load_op: wgpu_core::command::LoadOp::Load,
|
store_op: attachment.depth_store_op,
|
||||||
store_op: attachment.depth_store_op,
|
clear_value: attachment.depth_clear_value,
|
||||||
clear_value: 0.0,
|
read_only: attachment.depth_read_only,
|
||||||
read_only: attachment.depth_read_only,
|
|
||||||
},
|
|
||||||
GpuLoadOp::Clear(value) => wgpu_core::command::PassChannel {
|
|
||||||
load_op: wgpu_core::command::LoadOp::Clear,
|
|
||||||
store_op: attachment.depth_store_op,
|
|
||||||
clear_value: value,
|
|
||||||
read_only: attachment.depth_read_only,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
stencil: match attachment.stencil_load_op {
|
stencil: wgpu_core::command::PassChannel {
|
||||||
GpuLoadOp::Load => wgpu_core::command::PassChannel {
|
load_op: attachment.stencil_load_op,
|
||||||
load_op: wgpu_core::command::LoadOp::Load,
|
store_op: attachment.stencil_store_op,
|
||||||
store_op: attachment.stencil_store_op,
|
clear_value: attachment.stencil_clear_value,
|
||||||
clear_value: 0,
|
read_only: attachment.stencil_read_only,
|
||||||
read_only: attachment.stencil_read_only,
|
|
||||||
},
|
|
||||||
GpuLoadOp::Clear(value) => wgpu_core::command::PassChannel {
|
|
||||||
load_op: wgpu_core::command::LoadOp::Clear,
|
|
||||||
store_op: attachment.stencil_store_op,
|
|
||||||
clear_value: value,
|
|
||||||
read_only: attachment.stencil_read_only,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -204,10 +178,10 @@ pub struct CommandEncoderBeginComputePassArgs {
|
|||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_begin_compute_pass(
|
pub fn op_webgpu_command_encoder_begin_compute_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderBeginComputePassArgs,
|
args: CommandEncoderBeginComputePassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -240,10 +214,10 @@ pub struct CommandEncoderCopyBufferToBufferArgs {
|
|||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
|
pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyBufferToBufferArgs,
|
args: CommandEncoderCopyBufferToBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -296,10 +270,10 @@ pub struct CommandEncoderCopyBufferToTextureArgs {
|
|||||||
copy_size: wgpu_types::Extent3d,
|
copy_size: wgpu_types::Extent3d,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
|
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyBufferToTextureArgs,
|
args: CommandEncoderCopyBufferToTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -344,10 +318,10 @@ pub struct CommandEncoderCopyTextureToBufferArgs {
|
|||||||
copy_size: wgpu_types::Extent3d,
|
copy_size: wgpu_types::Extent3d,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
|
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyTextureToBufferArgs,
|
args: CommandEncoderCopyTextureToBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -392,10 +366,10 @@ pub struct CommandEncoderCopyTextureToTextureArgs {
|
|||||||
copy_size: wgpu_types::Extent3d,
|
copy_size: wgpu_types::Extent3d,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
|
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyTextureToTextureArgs,
|
args: CommandEncoderCopyTextureToTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -433,15 +407,15 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CommandEncoderClearBufferArgs {
|
pub struct CommandEncoderClearBufferArgs {
|
||||||
command_encoder_rid: u32,
|
command_encoder_rid: u32,
|
||||||
destination_rid: u32,
|
buffer_rid: u32,
|
||||||
destination_offset: u64,
|
offset: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_clear_buffer(
|
pub fn op_webgpu_command_encoder_clear_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderClearBufferArgs,
|
args: CommandEncoderClearBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -450,12 +424,12 @@ pub fn op_webgpu_command_encoder_clear_buffer(
|
|||||||
let command_encoder = command_encoder_resource.0;
|
let command_encoder = command_encoder_resource.0;
|
||||||
let destination_resource = state
|
let destination_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<super::buffer::WebGpuBuffer>(args.destination_rid)?;
|
.get::<super::buffer::WebGpuBuffer>(args.buffer_rid)?;
|
||||||
|
|
||||||
gfx_ok!(command_encoder => instance.command_encoder_clear_buffer(
|
gfx_ok!(command_encoder => instance.command_encoder_clear_buffer(
|
||||||
command_encoder,
|
command_encoder,
|
||||||
destination_resource.0,
|
destination_resource.0,
|
||||||
args.destination_offset,
|
args.offset,
|
||||||
std::num::NonZeroU64::new(args.size)
|
std::num::NonZeroU64::new(args.size)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -467,10 +441,10 @@ pub struct CommandEncoderPushDebugGroupArgs {
|
|||||||
group_label: String,
|
group_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_push_debug_group(
|
pub fn op_webgpu_command_encoder_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderPushDebugGroupArgs,
|
args: CommandEncoderPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -488,10 +462,10 @@ pub struct CommandEncoderPopDebugGroupArgs {
|
|||||||
command_encoder_rid: ResourceId,
|
command_encoder_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_pop_debug_group(
|
pub fn op_webgpu_command_encoder_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderPopDebugGroupArgs,
|
args: CommandEncoderPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -509,10 +483,10 @@ pub struct CommandEncoderInsertDebugMarkerArgs {
|
|||||||
marker_label: String,
|
marker_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_insert_debug_marker(
|
pub fn op_webgpu_command_encoder_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderInsertDebugMarkerArgs,
|
args: CommandEncoderInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -534,10 +508,10 @@ pub struct CommandEncoderWriteTimestampArgs {
|
|||||||
query_index: u32,
|
query_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_write_timestamp(
|
pub fn op_webgpu_command_encoder_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderWriteTimestampArgs,
|
args: CommandEncoderWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -566,10 +540,10 @@ pub struct CommandEncoderResolveQuerySetArgs {
|
|||||||
destination_offset: u64,
|
destination_offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_resolve_query_set(
|
pub fn op_webgpu_command_encoder_resolve_query_set(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderResolveQuerySetArgs,
|
args: CommandEncoderResolveQuerySetArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
@ -600,10 +574,10 @@ pub struct CommandEncoderFinishArgs {
|
|||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_command_encoder_finish(
|
pub fn op_webgpu_command_encoder_finish(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderFinishArgs,
|
args: CommandEncoderFinishArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -24,10 +26,10 @@ pub struct ComputePassSetPipelineArgs {
|
|||||||
pipeline: ResourceId,
|
pipeline: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_set_pipeline(
|
pub fn op_webgpu_compute_pass_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassSetPipelineArgs,
|
args: ComputePassSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pipeline_resource = state
|
let compute_pipeline_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -53,10 +55,10 @@ pub struct ComputePassDispatchArgs {
|
|||||||
z: u32,
|
z: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_dispatch(
|
pub fn op_webgpu_compute_pass_dispatch(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassDispatchArgs,
|
args: ComputePassDispatchArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -80,10 +82,10 @@ pub struct ComputePassDispatchIndirectArgs {
|
|||||||
indirect_offset: u64,
|
indirect_offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_dispatch_indirect(
|
pub fn op_webgpu_compute_pass_dispatch_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassDispatchIndirectArgs,
|
args: ComputePassDispatchIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -109,10 +111,10 @@ pub struct ComputePassBeginPipelineStatisticsQueryArgs {
|
|||||||
query_index: u32,
|
query_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
|
pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassBeginPipelineStatisticsQueryArgs,
|
args: ComputePassBeginPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -136,10 +138,10 @@ pub struct ComputePassEndPipelineStatisticsQueryArgs {
|
|||||||
compute_pass_rid: ResourceId,
|
compute_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
|
pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassEndPipelineStatisticsQueryArgs,
|
args: ComputePassEndPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -160,10 +162,10 @@ pub struct ComputePassWriteTimestampArgs {
|
|||||||
query_index: u32,
|
query_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_write_timestamp(
|
pub fn op_webgpu_compute_pass_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassWriteTimestampArgs,
|
args: ComputePassWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -183,15 +185,15 @@ pub fn op_webgpu_compute_pass_write_timestamp(
|
|||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ComputePassEndPassArgs {
|
pub struct ComputePassEndArgs {
|
||||||
command_encoder_rid: ResourceId,
|
command_encoder_rid: ResourceId,
|
||||||
compute_pass_rid: ResourceId,
|
compute_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn op_webgpu_compute_pass_end_pass(
|
#[op]
|
||||||
|
pub fn op_webgpu_compute_pass_end(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassEndPassArgs,
|
args: ComputePassEndArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource =
|
let command_encoder_resource =
|
||||||
state
|
state
|
||||||
@ -221,10 +223,10 @@ pub struct ComputePassSetBindGroupArgs {
|
|||||||
dynamic_offsets_data_length: usize,
|
dynamic_offsets_data_length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_set_bind_group(
|
pub fn op_webgpu_compute_pass_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassSetBindGroupArgs,
|
args: ComputePassSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource = state
|
let bind_group_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -273,10 +275,10 @@ pub struct ComputePassPushDebugGroupArgs {
|
|||||||
group_label: String,
|
group_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_push_debug_group(
|
pub fn op_webgpu_compute_pass_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassPushDebugGroupArgs,
|
args: ComputePassPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -302,10 +304,10 @@ pub struct ComputePassPopDebugGroupArgs {
|
|||||||
compute_pass_rid: ResourceId,
|
compute_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_pop_debug_group(
|
pub fn op_webgpu_compute_pass_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassPopDebugGroupArgs,
|
args: ComputePassPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -325,10 +327,10 @@ pub struct ComputePassInsertDebugMarkerArgs {
|
|||||||
marker_label: String,
|
marker_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pass_insert_debug_marker(
|
pub fn op_webgpu_compute_pass_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassInsertDebugMarkerArgs,
|
args: ComputePassInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -31,7 +31,7 @@ use wgpu_core::resource::CreateTextureError;
|
|||||||
use wgpu_core::resource::CreateTextureViewError;
|
use wgpu_core::resource::CreateTextureViewError;
|
||||||
|
|
||||||
fn fmt_err(err: &(dyn Error + 'static)) -> String {
|
fn fmt_err(err: &(dyn Error + 'static)) -> String {
|
||||||
let mut output = String::from(err.to_string());
|
let mut output = err.to_string();
|
||||||
|
|
||||||
let mut e = err.source();
|
let mut e = err.source();
|
||||||
while let Some(source) = e {
|
while let Some(source) = e {
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op_async;
|
use deno_core::op;
|
||||||
use deno_core::op_sync;
|
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
use deno_core::OpFn;
|
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
@ -14,6 +12,7 @@ use serde::Serialize;
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::convert::TryFrom;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
pub use wgpu_core;
|
pub use wgpu_core;
|
||||||
pub use wgpu_types;
|
pub use wgpu_types;
|
||||||
@ -227,10 +226,10 @@ pub struct GpuAdapterDevice {
|
|||||||
is_software: bool,
|
is_software: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub async fn op_webgpu_request_adapter(
|
pub async fn op_webgpu_request_adapter(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RequestAdapterArgs,
|
args: RequestAdapterArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
|
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
|
||||||
let mut state = state.borrow_mut();
|
let mut state = state.borrow_mut();
|
||||||
check_unstable(&state, "navigator.gpu.requestAdapter");
|
check_unstable(&state, "navigator.gpu.requestAdapter");
|
||||||
@ -407,10 +406,10 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub async fn op_webgpu_request_device(
|
pub async fn op_webgpu_request_device(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RequestDeviceArgs,
|
args: RequestDeviceArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<GpuAdapterDevice, AnyError> {
|
) -> Result<GpuAdapterDevice, AnyError> {
|
||||||
let mut state = state.borrow_mut();
|
let mut state = state.borrow_mut();
|
||||||
let adapter_resource = state
|
let adapter_resource = state
|
||||||
@ -506,10 +505,10 @@ impl From<GpuQueryType> for wgpu_types::QueryType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_query_set(
|
pub fn op_webgpu_create_query_set(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateQuerySetArgs,
|
args: CreateQuerySetArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let device_resource = state.resource_table.get::<WebGpuDevice>(args.device_rid)?;
|
let device_resource = state.resource_table.get::<WebGpuDevice>(args.device_rid)?;
|
||||||
let device = device_resource.0;
|
let device = device_resource.0;
|
||||||
@ -528,335 +527,101 @@ pub fn op_webgpu_create_query_set(
|
|||||||
) => state, WebGpuQuerySet)
|
) => state, WebGpuQuerySet)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn declare_webgpu_ops() -> Vec<(&'static str, Box<OpFn>)> {
|
fn declare_webgpu_ops() -> Vec<deno_core::OpDecl> {
|
||||||
vec![
|
vec![
|
||||||
// Request device/adapter
|
// Request device/adapter
|
||||||
(
|
op_webgpu_request_adapter::decl(),
|
||||||
"op_webgpu_request_adapter",
|
op_webgpu_request_device::decl(),
|
||||||
op_async(op_webgpu_request_adapter),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"op_webgpu_request_device",
|
|
||||||
op_async(op_webgpu_request_device),
|
|
||||||
),
|
|
||||||
// Query Set
|
// Query Set
|
||||||
(
|
op_webgpu_create_query_set::decl(),
|
||||||
"op_webgpu_create_query_set",
|
|
||||||
op_sync(op_webgpu_create_query_set),
|
|
||||||
),
|
|
||||||
// buffer
|
// buffer
|
||||||
(
|
buffer::op_webgpu_create_buffer::decl(),
|
||||||
"op_webgpu_create_buffer",
|
buffer::op_webgpu_buffer_get_mapped_range::decl(),
|
||||||
op_sync(buffer::op_webgpu_create_buffer),
|
buffer::op_webgpu_buffer_unmap::decl(),
|
||||||
),
|
|
||||||
(
|
|
||||||
"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
|
// buffer async
|
||||||
(
|
buffer::op_webgpu_buffer_get_map_async::decl(),
|
||||||
"op_webgpu_buffer_get_map_async",
|
|
||||||
op_async(buffer::op_webgpu_buffer_get_map_async),
|
|
||||||
),
|
|
||||||
// remaining sync ops
|
// remaining sync ops
|
||||||
|
|
||||||
// texture
|
// texture
|
||||||
(
|
texture::op_webgpu_create_texture::decl(),
|
||||||
"op_webgpu_create_texture",
|
texture::op_webgpu_create_texture_view::decl(),
|
||||||
op_sync(texture::op_webgpu_create_texture),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"op_webgpu_create_texture_view",
|
|
||||||
op_sync(texture::op_webgpu_create_texture_view),
|
|
||||||
),
|
|
||||||
// sampler
|
// sampler
|
||||||
(
|
sampler::op_webgpu_create_sampler::decl(),
|
||||||
"op_webgpu_create_sampler",
|
|
||||||
op_sync(sampler::op_webgpu_create_sampler),
|
|
||||||
),
|
|
||||||
// binding
|
// binding
|
||||||
(
|
binding::op_webgpu_create_bind_group_layout::decl(),
|
||||||
"op_webgpu_create_bind_group_layout",
|
binding::op_webgpu_create_pipeline_layout::decl(),
|
||||||
op_sync(binding::op_webgpu_create_bind_group_layout),
|
binding::op_webgpu_create_bind_group::decl(),
|
||||||
),
|
|
||||||
(
|
|
||||||
"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
|
// pipeline
|
||||||
(
|
pipeline::op_webgpu_create_compute_pipeline::decl(),
|
||||||
"op_webgpu_create_compute_pipeline",
|
pipeline::op_webgpu_compute_pipeline_get_bind_group_layout::decl(),
|
||||||
op_sync(pipeline::op_webgpu_create_compute_pipeline),
|
pipeline::op_webgpu_create_render_pipeline::decl(),
|
||||||
),
|
pipeline::op_webgpu_render_pipeline_get_bind_group_layout::decl(),
|
||||||
(
|
|
||||||
"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
|
// command_encoder
|
||||||
(
|
command_encoder::op_webgpu_create_command_encoder::decl(),
|
||||||
"op_webgpu_create_command_encoder",
|
command_encoder::op_webgpu_command_encoder_begin_render_pass::decl(),
|
||||||
op_sync(command_encoder::op_webgpu_create_command_encoder),
|
command_encoder::op_webgpu_command_encoder_begin_compute_pass::decl(),
|
||||||
),
|
command_encoder::op_webgpu_command_encoder_copy_buffer_to_buffer::decl(),
|
||||||
(
|
command_encoder::op_webgpu_command_encoder_copy_buffer_to_texture::decl(),
|
||||||
"op_webgpu_command_encoder_begin_render_pass",
|
command_encoder::op_webgpu_command_encoder_copy_texture_to_buffer::decl(),
|
||||||
op_sync(command_encoder::op_webgpu_command_encoder_begin_render_pass),
|
command_encoder::op_webgpu_command_encoder_copy_texture_to_texture::decl(),
|
||||||
),
|
command_encoder::op_webgpu_command_encoder_clear_buffer::decl(),
|
||||||
(
|
command_encoder::op_webgpu_command_encoder_push_debug_group::decl(),
|
||||||
"op_webgpu_command_encoder_begin_compute_pass",
|
command_encoder::op_webgpu_command_encoder_pop_debug_group::decl(),
|
||||||
op_sync(command_encoder::op_webgpu_command_encoder_begin_compute_pass),
|
command_encoder::op_webgpu_command_encoder_insert_debug_marker::decl(),
|
||||||
),
|
command_encoder::op_webgpu_command_encoder_write_timestamp::decl(),
|
||||||
(
|
command_encoder::op_webgpu_command_encoder_resolve_query_set::decl(),
|
||||||
"op_webgpu_command_encoder_copy_buffer_to_buffer",
|
command_encoder::op_webgpu_command_encoder_finish::decl(),
|
||||||
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),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"op_webgpu_command_encoder_clear_buffer",
|
|
||||||
op_sync(command_encoder::op_webgpu_command_encoder_clear_buffer),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"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
|
// render_pass
|
||||||
(
|
render_pass::op_webgpu_render_pass_set_viewport::decl(),
|
||||||
"op_webgpu_render_pass_set_viewport",
|
render_pass::op_webgpu_render_pass_set_scissor_rect::decl(),
|
||||||
op_sync(render_pass::op_webgpu_render_pass_set_viewport),
|
render_pass::op_webgpu_render_pass_set_blend_constant::decl(),
|
||||||
),
|
render_pass::op_webgpu_render_pass_set_stencil_reference::decl(),
|
||||||
(
|
render_pass::op_webgpu_render_pass_begin_pipeline_statistics_query::decl(),
|
||||||
"op_webgpu_render_pass_set_scissor_rect",
|
render_pass::op_webgpu_render_pass_end_pipeline_statistics_query::decl(),
|
||||||
op_sync(render_pass::op_webgpu_render_pass_set_scissor_rect),
|
render_pass::op_webgpu_render_pass_write_timestamp::decl(),
|
||||||
),
|
render_pass::op_webgpu_render_pass_execute_bundles::decl(),
|
||||||
(
|
render_pass::op_webgpu_render_pass_end::decl(),
|
||||||
"op_webgpu_render_pass_set_blend_constant",
|
render_pass::op_webgpu_render_pass_set_bind_group::decl(),
|
||||||
op_sync(render_pass::op_webgpu_render_pass_set_blend_constant),
|
render_pass::op_webgpu_render_pass_push_debug_group::decl(),
|
||||||
),
|
render_pass::op_webgpu_render_pass_pop_debug_group::decl(),
|
||||||
(
|
render_pass::op_webgpu_render_pass_insert_debug_marker::decl(),
|
||||||
"op_webgpu_render_pass_set_stencil_reference",
|
render_pass::op_webgpu_render_pass_set_pipeline::decl(),
|
||||||
op_sync(render_pass::op_webgpu_render_pass_set_stencil_reference),
|
render_pass::op_webgpu_render_pass_set_index_buffer::decl(),
|
||||||
),
|
render_pass::op_webgpu_render_pass_set_vertex_buffer::decl(),
|
||||||
(
|
render_pass::op_webgpu_render_pass_draw::decl(),
|
||||||
"op_webgpu_render_pass_begin_pipeline_statistics_query",
|
render_pass::op_webgpu_render_pass_draw_indexed::decl(),
|
||||||
op_sync(render_pass::op_webgpu_render_pass_begin_pipeline_statistics_query),
|
render_pass::op_webgpu_render_pass_draw_indirect::decl(),
|
||||||
),
|
render_pass::op_webgpu_render_pass_draw_indexed_indirect::decl(),
|
||||||
(
|
|
||||||
"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
|
// compute_pass
|
||||||
(
|
compute_pass::op_webgpu_compute_pass_set_pipeline::decl(),
|
||||||
"op_webgpu_compute_pass_set_pipeline",
|
compute_pass::op_webgpu_compute_pass_dispatch::decl(),
|
||||||
op_sync(compute_pass::op_webgpu_compute_pass_set_pipeline),
|
compute_pass::op_webgpu_compute_pass_dispatch_indirect::decl(),
|
||||||
),
|
compute_pass::op_webgpu_compute_pass_begin_pipeline_statistics_query::decl(),
|
||||||
(
|
compute_pass::op_webgpu_compute_pass_end_pipeline_statistics_query::decl(),
|
||||||
"op_webgpu_compute_pass_dispatch",
|
compute_pass::op_webgpu_compute_pass_write_timestamp::decl(),
|
||||||
op_sync(compute_pass::op_webgpu_compute_pass_dispatch),
|
compute_pass::op_webgpu_compute_pass_end::decl(),
|
||||||
),
|
compute_pass::op_webgpu_compute_pass_set_bind_group::decl(),
|
||||||
(
|
compute_pass::op_webgpu_compute_pass_push_debug_group::decl(),
|
||||||
"op_webgpu_compute_pass_dispatch_indirect",
|
compute_pass::op_webgpu_compute_pass_pop_debug_group::decl(),
|
||||||
op_sync(compute_pass::op_webgpu_compute_pass_dispatch_indirect),
|
compute_pass::op_webgpu_compute_pass_insert_debug_marker::decl(),
|
||||||
),
|
|
||||||
(
|
|
||||||
"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),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"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
|
// bundle
|
||||||
(
|
bundle::op_webgpu_create_render_bundle_encoder::decl(),
|
||||||
"op_webgpu_create_render_bundle_encoder",
|
bundle::op_webgpu_render_bundle_encoder_finish::decl(),
|
||||||
op_sync(bundle::op_webgpu_create_render_bundle_encoder),
|
bundle::op_webgpu_render_bundle_encoder_set_bind_group::decl(),
|
||||||
),
|
bundle::op_webgpu_render_bundle_encoder_push_debug_group::decl(),
|
||||||
(
|
bundle::op_webgpu_render_bundle_encoder_pop_debug_group::decl(),
|
||||||
"op_webgpu_render_bundle_encoder_finish",
|
bundle::op_webgpu_render_bundle_encoder_insert_debug_marker::decl(),
|
||||||
op_sync(bundle::op_webgpu_render_bundle_encoder_finish),
|
bundle::op_webgpu_render_bundle_encoder_set_pipeline::decl(),
|
||||||
),
|
bundle::op_webgpu_render_bundle_encoder_set_index_buffer::decl(),
|
||||||
(
|
bundle::op_webgpu_render_bundle_encoder_set_vertex_buffer::decl(),
|
||||||
"op_webgpu_render_bundle_encoder_set_bind_group",
|
bundle::op_webgpu_render_bundle_encoder_draw::decl(),
|
||||||
op_sync(bundle::op_webgpu_render_bundle_encoder_set_bind_group),
|
bundle::op_webgpu_render_bundle_encoder_draw_indexed::decl(),
|
||||||
),
|
bundle::op_webgpu_render_bundle_encoder_draw_indirect::decl(),
|
||||||
(
|
|
||||||
"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
|
// queue
|
||||||
(
|
queue::op_webgpu_queue_submit::decl(),
|
||||||
"op_webgpu_queue_submit",
|
queue::op_webgpu_write_buffer::decl(),
|
||||||
op_sync(queue::op_webgpu_queue_submit),
|
queue::op_webgpu_write_texture::decl(),
|
||||||
),
|
|
||||||
(
|
|
||||||
"op_webgpu_write_buffer",
|
|
||||||
op_sync(queue::op_webgpu_write_buffer),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"op_webgpu_write_texture",
|
|
||||||
op_sync(queue::op_webgpu_write_texture),
|
|
||||||
),
|
|
||||||
// shader
|
// shader
|
||||||
(
|
shader::op_webgpu_create_shader_module::decl(),
|
||||||
"op_webgpu_create_shader_module",
|
|
||||||
op_sync(shader::op_webgpu_create_shader_module),
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::TryFrom;
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use super::error::WebGpuError;
|
use super::error::WebGpuError;
|
||||||
use super::error::WebGpuResult;
|
use super::error::WebGpuResult;
|
||||||
@ -51,10 +54,10 @@ pub struct CreateComputePipelineArgs {
|
|||||||
compute: GpuProgrammableStage,
|
compute: GpuProgrammableStage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_compute_pipeline(
|
pub fn op_webgpu_create_compute_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateComputePipelineArgs,
|
args: CreateComputePipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -119,10 +122,10 @@ pub struct PipelineLayout {
|
|||||||
err: Option<WebGpuError>,
|
err: Option<WebGpuError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
|
pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePipelineGetBindGroupLayoutArgs,
|
args: ComputePipelineGetBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<PipelineLayout, AnyError> {
|
) -> Result<PipelineLayout, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let compute_pipeline_resource = state
|
let compute_pipeline_resource = state
|
||||||
@ -291,10 +294,10 @@ pub struct CreateRenderPipelineArgs {
|
|||||||
fragment: Option<GpuFragmentState>,
|
fragment: Option<GpuFragmentState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_render_pipeline(
|
pub fn op_webgpu_create_render_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateRenderPipelineArgs,
|
args: CreateRenderPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -319,18 +322,12 @@ pub fn op_webgpu_create_render_pipeline(
|
|||||||
.resource_table
|
.resource_table
|
||||||
.get::<super::shader::WebGpuShaderModule>(fragment.module)?;
|
.get::<super::shader::WebGpuShaderModule>(fragment.module)?;
|
||||||
|
|
||||||
let mut targets = Vec::with_capacity(fragment.targets.len());
|
|
||||||
|
|
||||||
for target in fragment.targets {
|
|
||||||
targets.push(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(wgpu_core::pipeline::FragmentState {
|
Some(wgpu_core::pipeline::FragmentState {
|
||||||
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
||||||
module: fragment_shader_module_resource.0,
|
module: fragment_shader_module_resource.0,
|
||||||
entry_point: Cow::from(fragment.entry_point),
|
entry_point: Cow::from(fragment.entry_point),
|
||||||
},
|
},
|
||||||
targets: Cow::from(targets),
|
targets: Cow::from(fragment.targets),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -390,10 +387,10 @@ pub struct RenderPipelineGetBindGroupLayoutArgs {
|
|||||||
index: u32,
|
index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pipeline_get_bind_group_layout(
|
pub fn op_webgpu_render_pipeline_get_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPipelineGetBindGroupLayoutArgs,
|
args: RenderPipelineGetBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<PipelineLayout, AnyError> {
|
) -> Result<PipelineLayout, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let render_pipeline_resource = state
|
let render_pipeline_resource = state
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
@ -19,10 +20,10 @@ pub struct QueueSubmitArgs {
|
|||||||
command_buffers: Vec<ResourceId>,
|
command_buffers: Vec<ResourceId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_queue_submit(
|
pub fn op_webgpu_queue_submit(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: QueueSubmitArgs,
|
args: QueueSubmitArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let queue_resource = state.resource_table.get::<WebGpuQueue>(args.queue_rid)?;
|
let queue_resource = state.resource_table.get::<WebGpuQueue>(args.queue_rid)?;
|
||||||
@ -74,6 +75,7 @@ pub struct QueueWriteBufferArgs {
|
|||||||
size: Option<usize>,
|
size: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_write_buffer(
|
pub fn op_webgpu_write_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: QueueWriteBufferArgs,
|
args: QueueWriteBufferArgs,
|
||||||
@ -111,6 +113,7 @@ pub struct QueueWriteTextureArgs {
|
|||||||
size: wgpu_types::Extent3d,
|
size: wgpu_types::Extent3d,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_write_texture(
|
pub fn op_webgpu_write_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: QueueWriteTextureArgs,
|
args: QueueWriteTextureArgs,
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -30,10 +32,10 @@ pub struct RenderPassSetViewportArgs {
|
|||||||
max_depth: f32,
|
max_depth: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_viewport(
|
pub fn op_webgpu_render_pass_set_viewport(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetViewportArgs,
|
args: RenderPassSetViewportArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -62,10 +64,10 @@ pub struct RenderPassSetScissorRectArgs {
|
|||||||
height: u32,
|
height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_scissor_rect(
|
pub fn op_webgpu_render_pass_set_scissor_rect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetScissorRectArgs,
|
args: RenderPassSetScissorRectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -89,10 +91,10 @@ pub struct RenderPassSetBlendConstantArgs {
|
|||||||
color: wgpu_types::Color,
|
color: wgpu_types::Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_blend_constant(
|
pub fn op_webgpu_render_pass_set_blend_constant(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetBlendConstantArgs,
|
args: RenderPassSetBlendConstantArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -113,10 +115,10 @@ pub struct RenderPassSetStencilReferenceArgs {
|
|||||||
reference: u32,
|
reference: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_stencil_reference(
|
pub fn op_webgpu_render_pass_set_stencil_reference(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetStencilReferenceArgs,
|
args: RenderPassSetStencilReferenceArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -138,10 +140,10 @@ pub struct RenderPassBeginPipelineStatisticsQueryArgs {
|
|||||||
query_index: u32,
|
query_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
|
pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassBeginPipelineStatisticsQueryArgs,
|
args: RenderPassBeginPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -165,10 +167,10 @@ pub struct RenderPassEndPipelineStatisticsQueryArgs {
|
|||||||
render_pass_rid: ResourceId,
|
render_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
|
pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassEndPipelineStatisticsQueryArgs,
|
args: RenderPassEndPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -189,10 +191,10 @@ pub struct RenderPassWriteTimestampArgs {
|
|||||||
query_index: u32,
|
query_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_write_timestamp(
|
pub fn op_webgpu_render_pass_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassWriteTimestampArgs,
|
args: RenderPassWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -217,10 +219,10 @@ pub struct RenderPassExecuteBundlesArgs {
|
|||||||
bundles: Vec<u32>,
|
bundles: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_execute_bundles(
|
pub fn op_webgpu_render_pass_execute_bundles(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassExecuteBundlesArgs,
|
args: RenderPassExecuteBundlesArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let mut render_bundle_ids = vec![];
|
let mut render_bundle_ids = vec![];
|
||||||
|
|
||||||
@ -250,15 +252,15 @@ pub fn op_webgpu_render_pass_execute_bundles(
|
|||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RenderPassEndPassArgs {
|
pub struct RenderPassEndArgs {
|
||||||
command_encoder_rid: ResourceId,
|
command_encoder_rid: ResourceId,
|
||||||
render_pass_rid: ResourceId,
|
render_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn op_webgpu_render_pass_end_pass(
|
#[op]
|
||||||
|
pub fn op_webgpu_render_pass_end(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassEndPassArgs,
|
args: RenderPassEndArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource =
|
let command_encoder_resource =
|
||||||
state
|
state
|
||||||
@ -285,10 +287,10 @@ pub struct RenderPassSetBindGroupArgs {
|
|||||||
dynamic_offsets_data_length: usize,
|
dynamic_offsets_data_length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_bind_group(
|
pub fn op_webgpu_render_pass_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetBindGroupArgs,
|
args: RenderPassSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource = state
|
let bind_group_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -337,10 +339,10 @@ pub struct RenderPassPushDebugGroupArgs {
|
|||||||
group_label: String,
|
group_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_push_debug_group(
|
pub fn op_webgpu_render_pass_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassPushDebugGroupArgs,
|
args: RenderPassPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -366,10 +368,10 @@ pub struct RenderPassPopDebugGroupArgs {
|
|||||||
render_pass_rid: ResourceId,
|
render_pass_rid: ResourceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_pop_debug_group(
|
pub fn op_webgpu_render_pass_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassPopDebugGroupArgs,
|
args: RenderPassPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -389,10 +391,10 @@ pub struct RenderPassInsertDebugMarkerArgs {
|
|||||||
marker_label: String,
|
marker_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_insert_debug_marker(
|
pub fn op_webgpu_render_pass_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassInsertDebugMarkerArgs,
|
args: RenderPassInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -419,10 +421,10 @@ pub struct RenderPassSetPipelineArgs {
|
|||||||
pipeline: u32,
|
pipeline: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_pipeline(
|
pub fn op_webgpu_render_pass_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetPipelineArgs,
|
args: RenderPassSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pipeline_resource = state
|
let render_pipeline_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -449,10 +451,10 @@ pub struct RenderPassSetIndexBufferArgs {
|
|||||||
size: Option<u64>,
|
size: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_index_buffer(
|
pub fn op_webgpu_render_pass_set_index_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetIndexBufferArgs,
|
args: RenderPassSetIndexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -490,10 +492,10 @@ pub struct RenderPassSetVertexBufferArgs {
|
|||||||
size: Option<u64>,
|
size: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_set_vertex_buffer(
|
pub fn op_webgpu_render_pass_set_vertex_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetVertexBufferArgs,
|
args: RenderPassSetVertexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -532,10 +534,10 @@ pub struct RenderPassDrawArgs {
|
|||||||
first_instance: u32,
|
first_instance: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_draw(
|
pub fn op_webgpu_render_pass_draw(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawArgs,
|
args: RenderPassDrawArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -563,10 +565,10 @@ pub struct RenderPassDrawIndexedArgs {
|
|||||||
first_instance: u32,
|
first_instance: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_draw_indexed(
|
pub fn op_webgpu_render_pass_draw_indexed(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndexedArgs,
|
args: RenderPassDrawIndexedArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -592,10 +594,10 @@ pub struct RenderPassDrawIndirectArgs {
|
|||||||
indirect_offset: u64,
|
indirect_offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_draw_indirect(
|
pub fn op_webgpu_render_pass_draw_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndirectArgs,
|
args: RenderPassDrawIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
@ -621,10 +623,10 @@ pub struct RenderPassDrawIndexedIndirectArgs {
|
|||||||
indirect_offset: u64,
|
indirect_offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_render_pass_draw_indexed_indirect(
|
pub fn op_webgpu_render_pass_draw_indexed_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndexedIndirectArgs,
|
args: RenderPassDrawIndexedIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
@ -32,10 +34,10 @@ pub struct CreateSamplerArgs {
|
|||||||
max_anisotropy: u8,
|
max_anisotropy: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_sampler(
|
pub fn op_webgpu_create_sampler(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateSamplerArgs,
|
args: CreateSamplerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
@ -24,10 +26,10 @@ pub struct CreateShaderModuleArgs {
|
|||||||
_source_map: Option<()>, // not yet implemented
|
_source_map: Option<()>, // not yet implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_shader_module(
|
pub fn op_webgpu_create_shader_module(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateShaderModuleArgs,
|
args: CreateShaderModuleArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::{OpState, Resource};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
@ -34,10 +36,10 @@ pub struct CreateTextureArgs {
|
|||||||
usage: u32,
|
usage: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_texture(
|
pub fn op_webgpu_create_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateTextureArgs,
|
args: CreateTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
@ -76,10 +78,10 @@ pub struct CreateTextureViewArgs {
|
|||||||
array_layer_count: Option<u32>,
|
array_layer_count: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
pub fn op_webgpu_create_texture_view(
|
pub fn op_webgpu_create_texture_view(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateTextureViewArgs,
|
args: CreateTextureViewArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let texture_resource = state
|
let texture_resource = state
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
interface mixin GPUObjectBase {
|
interface mixin GPUObjectBase {
|
||||||
attribute USVString? label;
|
attribute (USVString or undefined) label;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUObjectDescriptorBase {
|
dictionary GPUObjectDescriptorBase {
|
||||||
@ -85,7 +85,6 @@ enum GPUFeatureName {
|
|||||||
"depth-clip-control",
|
"depth-clip-control",
|
||||||
"depth24unorm-stencil8",
|
"depth24unorm-stencil8",
|
||||||
"depth32float-stencil8",
|
"depth32float-stencil8",
|
||||||
"pipeline-statistics-query",
|
|
||||||
"texture-compression-bc",
|
"texture-compression-bc",
|
||||||
"texture-compression-etc2",
|
"texture-compression-etc2",
|
||||||
"texture-compression-astc",
|
"texture-compression-astc",
|
||||||
@ -272,13 +271,19 @@ enum GPUTextureFormat {
|
|||||||
"rgba32sint",
|
"rgba32sint",
|
||||||
"rgba32float",
|
"rgba32float",
|
||||||
|
|
||||||
// Depth and stencil formats
|
// Depth/stencil formats
|
||||||
"stencil8",
|
"stencil8",
|
||||||
"depth16unorm",
|
"depth16unorm",
|
||||||
"depth24plus",
|
"depth24plus",
|
||||||
"depth24plus-stencil8",
|
"depth24plus-stencil8",
|
||||||
"depth32float",
|
"depth32float",
|
||||||
|
|
||||||
|
// "depth24unorm-stencil8" feature
|
||||||
|
"depth24unorm-stencil8",
|
||||||
|
|
||||||
|
// "depth32float-stencil8" feature
|
||||||
|
"depth32float-stencil8",
|
||||||
|
|
||||||
// BC compressed formats usable if "texture-compression-bc" is both
|
// BC compressed formats usable if "texture-compression-bc" is both
|
||||||
// supported by the device/user agent and enabled in requestDevice.
|
// supported by the device/user agent and enabled in requestDevice.
|
||||||
"bc1-rgba-unorm",
|
"bc1-rgba-unorm",
|
||||||
@ -339,12 +344,6 @@ enum GPUTextureFormat {
|
|||||||
"astc-12x10-unorm-srgb",
|
"astc-12x10-unorm-srgb",
|
||||||
"astc-12x12-unorm",
|
"astc-12x12-unorm",
|
||||||
"astc-12x12-unorm-srgb",
|
"astc-12x12-unorm-srgb",
|
||||||
|
|
||||||
// "depth24unorm-stencil8" feature
|
|
||||||
"depth24unorm-stencil8",
|
|
||||||
|
|
||||||
// "depth32float-stencil8" feature
|
|
||||||
"depth32float-stencil8",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
@ -758,6 +757,9 @@ GPUCommandBuffer includes GPUObjectBase;
|
|||||||
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface mixin GPUCommandsMixin {
|
||||||
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUCommandEncoder {
|
interface GPUCommandEncoder {
|
||||||
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
||||||
@ -786,13 +788,9 @@ interface GPUCommandEncoder {
|
|||||||
GPUExtent3D copySize);
|
GPUExtent3D copySize);
|
||||||
|
|
||||||
undefined clearBuffer(
|
undefined clearBuffer(
|
||||||
GPUBuffer destination,
|
GPUBuffer buffer,
|
||||||
GPUSize64 destinationOffset,
|
optional GPUSize64 offset = 0,
|
||||||
GPUSize64 size);
|
optional GPUSize64 size);
|
||||||
|
|
||||||
undefined pushDebugGroup(USVString groupLabel);
|
|
||||||
undefined popDebugGroup();
|
|
||||||
undefined insertDebugMarker(USVString markerLabel);
|
|
||||||
|
|
||||||
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
||||||
|
|
||||||
@ -806,6 +804,8 @@ interface GPUCommandEncoder {
|
|||||||
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
|
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
|
||||||
};
|
};
|
||||||
GPUCommandEncoder includes GPUObjectBase;
|
GPUCommandEncoder includes GPUObjectBase;
|
||||||
|
GPUCommandEncoder includes GPUCommandsMixin;
|
||||||
|
GPUCommandEncoder includes GPUDebugCommandsMixin;
|
||||||
|
|
||||||
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
||||||
};
|
};
|
||||||
@ -835,7 +835,9 @@ interface mixin GPUProgrammablePassEncoder {
|
|||||||
Uint32Array dynamicOffsetsData,
|
Uint32Array dynamicOffsetsData,
|
||||||
GPUSize64 dynamicOffsetsDataStart,
|
GPUSize64 dynamicOffsetsDataStart,
|
||||||
GPUSize32 dynamicOffsetsDataLength);
|
GPUSize32 dynamicOffsetsDataLength);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface mixin GPUDebugCommandsMixin {
|
||||||
undefined pushDebugGroup(USVString groupLabel);
|
undefined pushDebugGroup(USVString groupLabel);
|
||||||
undefined popDebugGroup();
|
undefined popDebugGroup();
|
||||||
undefined insertDebugMarker(USVString markerLabel);
|
undefined insertDebugMarker(USVString markerLabel);
|
||||||
@ -844,7 +846,7 @@ interface mixin GPUProgrammablePassEncoder {
|
|||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUComputePassEncoder {
|
interface GPUComputePassEncoder {
|
||||||
undefined setPipeline(GPUComputePipeline pipeline);
|
undefined setPipeline(GPUComputePipeline pipeline);
|
||||||
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
|
undefined dispatch(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
|
||||||
undefined dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
undefined dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
||||||
|
|
||||||
undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
|
undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
|
||||||
@ -852,9 +854,11 @@ interface GPUComputePassEncoder {
|
|||||||
|
|
||||||
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
||||||
|
|
||||||
undefined endPass();
|
undefined end();
|
||||||
};
|
};
|
||||||
GPUComputePassEncoder includes GPUObjectBase;
|
GPUComputePassEncoder includes GPUObjectBase;
|
||||||
|
GPUComputePassEncoder includes GPUCommandsMixin;
|
||||||
|
GPUComputePassEncoder includes GPUDebugCommandsMixin;
|
||||||
GPUComputePassEncoder includes GPUProgrammablePassEncoder;
|
GPUComputePassEncoder includes GPUProgrammablePassEncoder;
|
||||||
|
|
||||||
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
|
||||||
@ -898,9 +902,11 @@ interface GPURenderPassEncoder {
|
|||||||
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
|
||||||
|
|
||||||
undefined executeBundles(sequence<GPURenderBundle> bundles);
|
undefined executeBundles(sequence<GPURenderBundle> bundles);
|
||||||
undefined endPass();
|
undefined end();
|
||||||
};
|
};
|
||||||
GPURenderPassEncoder includes GPUObjectBase;
|
GPURenderPassEncoder includes GPUObjectBase;
|
||||||
|
GPURenderPassEncoder includes GPUCommandsMixin;
|
||||||
|
GPURenderPassEncoder includes GPUDebugCommandsMixin;
|
||||||
GPURenderPassEncoder includes GPUProgrammablePassEncoder;
|
GPURenderPassEncoder includes GPUProgrammablePassEncoder;
|
||||||
GPURenderPassEncoder includes GPURenderEncoderBase;
|
GPURenderPassEncoder includes GPURenderEncoderBase;
|
||||||
|
|
||||||
@ -914,24 +920,28 @@ dictionary GPURenderPassColorAttachment {
|
|||||||
required GPUTextureView view;
|
required GPUTextureView view;
|
||||||
GPUTextureView resolveTarget;
|
GPUTextureView resolveTarget;
|
||||||
|
|
||||||
required (GPULoadOp or GPUColor) loadValue;
|
GPUColor clearValue;
|
||||||
|
required GPULoadOp loadOp;
|
||||||
required GPUStoreOp storeOp;
|
required GPUStoreOp storeOp;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPURenderPassDepthStencilAttachment {
|
dictionary GPURenderPassDepthStencilAttachment {
|
||||||
required GPUTextureView view;
|
required GPUTextureView view;
|
||||||
|
|
||||||
required (GPULoadOp or float) depthLoadValue;
|
float depthClearValue = 0;
|
||||||
required GPUStoreOp depthStoreOp;
|
GPULoadOp depthLoadOp;
|
||||||
|
GPUStoreOp depthStoreOp;
|
||||||
boolean depthReadOnly = false;
|
boolean depthReadOnly = false;
|
||||||
|
|
||||||
required (GPULoadOp or GPUStencilValue) stencilLoadValue;
|
GPUStencilValue stencilClearValue = 0;
|
||||||
required GPUStoreOp stencilStoreOp;
|
GPULoadOp stencilLoadOp;
|
||||||
|
GPUStoreOp stencilStoreOp;
|
||||||
boolean stencilReadOnly = false;
|
boolean stencilReadOnly = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPULoadOp {
|
enum GPULoadOp {
|
||||||
"load",
|
"load",
|
||||||
|
"clear",
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUStoreOp {
|
enum GPUStoreOp {
|
||||||
@ -958,6 +968,8 @@ interface GPURenderBundleEncoder {
|
|||||||
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
|
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
|
||||||
};
|
};
|
||||||
GPURenderBundleEncoder includes GPUObjectBase;
|
GPURenderBundleEncoder includes GPUObjectBase;
|
||||||
|
GPURenderBundleEncoder includes GPUCommandsMixin;
|
||||||
|
GPURenderBundleEncoder includes GPUDebugCommandsMixin;
|
||||||
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
|
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
|
||||||
GPURenderBundleEncoder includes GPURenderEncoderBase;
|
GPURenderBundleEncoder includes GPURenderEncoderBase;
|
||||||
|
|
||||||
@ -1056,7 +1068,7 @@ interface GPUUncapturedErrorEvent : Event {
|
|||||||
DOMString type,
|
DOMString type,
|
||||||
GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict
|
GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict
|
||||||
);
|
);
|
||||||
[SameObject] readonly attribute GPUError error;
|
readonly attribute GPUError error;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUUncapturedErrorEventInit : EventInit {
|
dictionary GPUUncapturedErrorEventInit : EventInit {
|
||||||
@ -1108,4 +1120,3 @@ dictionary GPUExtent3DDict {
|
|||||||
GPUIntegerCoordinate depthOrArrayLayers = 1;
|
GPUIntegerCoordinate depthOrArrayLayers = 1;
|
||||||
};
|
};
|
||||||
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;
|
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user