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