mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
webgpu: Clean up GPUCommandEncoders
and add some validation (#33223)
* TextureUsages::from_bits_retain Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fixup CreateBindGroupLayout Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * GPUExtent3D checking and converting Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Cleanup GPUCommandEncoders and some TODOs Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * validate gpuorigin3d Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * validate GPUColor Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * set good expect Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
83a40c5180
commit
817a91f2ac
11 changed files with 276 additions and 361 deletions
|
@ -2,26 +2,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest};
|
use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCommandBufferMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCommandBufferMethods;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::USVString;
|
use crate::dom::bindings::str::USVString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::gpubuffer::GPUBuffer;
|
|
||||||
|
|
||||||
impl Eq for DomRoot<GPUBuffer> {}
|
|
||||||
impl Hash for DomRoot<GPUBuffer> {
|
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
||||||
self.id().hash(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUCommandBuffer {
|
pub struct GPUCommandBuffer {
|
||||||
|
@ -32,14 +21,12 @@ pub struct GPUCommandBuffer {
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
command_buffer: WebGPUCommandBuffer,
|
command_buffer: WebGPUCommandBuffer,
|
||||||
buffers: DomRefCell<HashSet<Dom<GPUBuffer>>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUCommandBuffer {
|
impl GPUCommandBuffer {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
command_buffer: WebGPUCommandBuffer,
|
command_buffer: WebGPUCommandBuffer,
|
||||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -47,7 +34,6 @@ impl GPUCommandBuffer {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
command_buffer,
|
command_buffer,
|
||||||
buffers: DomRefCell::new(buffers.into_iter().map(|b| Dom::from_ref(&*b)).collect()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +41,12 @@ impl GPUCommandBuffer {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
command_buffer: WebGPUCommandBuffer,
|
command_buffer: WebGPUCommandBuffer,
|
||||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUCommandBuffer::new_inherited(
|
Box::new(GPUCommandBuffer::new_inherited(
|
||||||
channel,
|
channel,
|
||||||
command_buffer,
|
command_buffer,
|
||||||
buffers,
|
|
||||||
label,
|
label,
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::wgc::command as wgpu_com;
|
use webgpu::wgc::command as wgpu_com;
|
||||||
use webgpu::{self, wgt, WebGPU, WebGPUComputePass, WebGPURenderPass, WebGPURequest};
|
use webgpu::{self, wgt, WebGPU, WebGPUComputePass, WebGPURenderPass, WebGPURequest};
|
||||||
|
|
||||||
use super::gpuconvert::convert_label;
|
use super::bindings::error::Fallible;
|
||||||
|
use super::gpuconvert::{convert_color, convert_label};
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
GPUCommandBufferDescriptor, GPUCommandEncoderMethods, GPUComputePassDescriptor, GPUExtent3D,
|
GPUCommandBufferDescriptor, GPUCommandEncoderMethods, GPUComputePassDescriptor, GPUExtent3D,
|
||||||
GPUImageCopyBuffer, GPUImageCopyTexture, GPURenderPassDescriptor, GPUSize64,
|
GPUImageCopyBuffer, GPUImageCopyTexture, GPURenderPassDescriptor, GPUSize64,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::UnionTypes::DoubleSequenceOrGPUColorDict;
|
|
||||||
use crate::dom::bindings::num::Finite;
|
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::bindings::str::USVString;
|
use crate::dom::bindings::str::USVString;
|
||||||
|
@ -25,8 +21,7 @@ use crate::dom::gpubuffer::GPUBuffer;
|
||||||
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
|
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
|
||||||
use crate::dom::gpucomputepassencoder::GPUComputePassEncoder;
|
use crate::dom::gpucomputepassencoder::GPUComputePassEncoder;
|
||||||
use crate::dom::gpuconvert::{
|
use crate::dom::gpuconvert::{
|
||||||
convert_ic_buffer, convert_ic_texture, convert_load_op, convert_store_op,
|
convert_ic_buffer, convert_ic_texture, convert_load_op, convert_store_op, convert_texture_size,
|
||||||
convert_texture_size_to_dict, convert_texture_size_to_wgt,
|
|
||||||
};
|
};
|
||||||
use crate::dom::gpudevice::GPUDevice;
|
use crate::dom::gpudevice::GPUDevice;
|
||||||
use crate::dom::gpurenderpassencoder::GPURenderPassEncoder;
|
use crate::dom::gpurenderpassencoder::GPURenderPassEncoder;
|
||||||
|
@ -40,9 +35,7 @@ pub struct GPUCommandEncoder {
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
encoder: webgpu::WebGPUCommandEncoder,
|
encoder: webgpu::WebGPUCommandEncoder,
|
||||||
buffers: DomRefCell<HashSet<DomRoot<GPUBuffer>>>,
|
|
||||||
device: Dom<GPUDevice>,
|
device: Dom<GPUDevice>,
|
||||||
valid: Cell<bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUCommandEncoder {
|
impl GPUCommandEncoder {
|
||||||
|
@ -58,8 +51,6 @@ impl GPUCommandEncoder {
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
device: Dom::from_ref(device),
|
device: Dom::from_ref(device),
|
||||||
encoder,
|
encoder,
|
||||||
buffers: DomRefCell::new(HashSet::new()),
|
|
||||||
valid: Cell::new(true),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +123,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
fn BeginRenderPass(
|
fn BeginRenderPass(
|
||||||
&self,
|
&self,
|
||||||
descriptor: &GPURenderPassDescriptor,
|
descriptor: &GPURenderPassDescriptor,
|
||||||
) -> DomRoot<GPURenderPassEncoder> {
|
) -> Fallible<DomRoot<GPURenderPassEncoder>> {
|
||||||
let depth_stencil_attachment = descriptor.depthStencilAttachment.as_ref().map(|depth| {
|
let depth_stencil_attachment = descriptor.depthStencilAttachment.as_ref().map(|depth| {
|
||||||
wgpu_com::RenderPassDepthStencilAttachment {
|
wgpu_com::RenderPassDepthStencilAttachment {
|
||||||
depth: wgpu_com::PassChannel {
|
depth: wgpu_com::PassChannel {
|
||||||
|
@ -154,44 +145,25 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
let color_attachments = descriptor
|
let color_attachments = descriptor
|
||||||
.colorAttachments
|
.colorAttachments
|
||||||
.iter()
|
.iter()
|
||||||
.map(|color| {
|
.map(|color| -> Fallible<_> {
|
||||||
let channel = wgpu_com::PassChannel {
|
let channel = wgpu_com::PassChannel {
|
||||||
load_op: convert_load_op(Some(color.loadOp)),
|
load_op: convert_load_op(Some(color.loadOp)),
|
||||||
store_op: convert_store_op(Some(color.storeOp)),
|
store_op: convert_store_op(Some(color.storeOp)),
|
||||||
clear_value: if let Some(clear_val) = &color.clearValue {
|
clear_value: color
|
||||||
match clear_val {
|
.clearValue
|
||||||
DoubleSequenceOrGPUColorDict::DoubleSequence(s) => {
|
.as_ref()
|
||||||
let mut w = s.clone();
|
.map(|color| convert_color(color))
|
||||||
if w.len() < 3 {
|
.transpose()?
|
||||||
w.resize(3, Finite::wrap(0.0f64));
|
.unwrap_or_default(),
|
||||||
}
|
|
||||||
w.resize(4, Finite::wrap(1.0f64));
|
|
||||||
wgt::Color {
|
|
||||||
r: *w[0],
|
|
||||||
g: *w[1],
|
|
||||||
b: *w[2],
|
|
||||||
a: *w[3],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DoubleSequenceOrGPUColorDict::GPUColorDict(d) => wgt::Color {
|
|
||||||
r: *d.r,
|
|
||||||
g: *d.g,
|
|
||||||
b: *d.b,
|
|
||||||
a: *d.a,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
wgt::Color::TRANSPARENT
|
|
||||||
},
|
|
||||||
read_only: false,
|
read_only: false,
|
||||||
};
|
};
|
||||||
Some(wgpu_com::RenderPassColorAttachment {
|
Ok(Some(wgpu_com::RenderPassColorAttachment {
|
||||||
resolve_target: color.resolveTarget.as_ref().map(|t| t.id().0),
|
resolve_target: color.resolveTarget.as_ref().map(|t| t.id().0),
|
||||||
channel,
|
channel,
|
||||||
view: color.view.id().0,
|
view: color.view.id().0,
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
})
|
.collect::<Fallible<Vec<_>>>()?;
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let render_pass_id = self
|
let render_pass_id = self
|
||||||
.global()
|
.global()
|
||||||
.wgpu_id_hub()
|
.wgpu_id_hub()
|
||||||
|
@ -208,13 +180,13 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
warn!("Failed to send WebGPURequest::BeginRenderPass {e:?}");
|
warn!("Failed to send WebGPURequest::BeginRenderPass {e:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
GPURenderPassEncoder::new(
|
Ok(GPURenderPassEncoder::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
self.channel.clone(),
|
self.channel.clone(),
|
||||||
WebGPURenderPass(render_pass_id),
|
WebGPURenderPass(render_pass_id),
|
||||||
self,
|
self,
|
||||||
descriptor.parent.label.clone(),
|
descriptor.parent.label.clone(),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-copybuffertobuffer>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-copybuffertobuffer>
|
||||||
|
@ -226,10 +198,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
destination_offset: GPUSize64,
|
destination_offset: GPUSize64,
|
||||||
size: GPUSize64,
|
size: GPUSize64,
|
||||||
) {
|
) {
|
||||||
self.buffers.borrow_mut().insert(DomRoot::from_ref(source));
|
|
||||||
self.buffers
|
|
||||||
.borrow_mut()
|
|
||||||
.insert(DomRoot::from_ref(destination));
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CopyBufferToBuffer {
|
.send(WebGPURequest::CopyBufferToBuffer {
|
||||||
|
@ -249,20 +217,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
source: &GPUImageCopyBuffer,
|
source: &GPUImageCopyBuffer,
|
||||||
destination: &GPUImageCopyTexture,
|
destination: &GPUImageCopyTexture,
|
||||||
copy_size: GPUExtent3D,
|
copy_size: GPUExtent3D,
|
||||||
) {
|
) -> Fallible<()> {
|
||||||
self.buffers
|
|
||||||
.borrow_mut()
|
|
||||||
.insert(DomRoot::from_ref(&*source.buffer));
|
|
||||||
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CopyBufferToTexture {
|
.send(WebGPURequest::CopyBufferToTexture {
|
||||||
command_encoder_id: self.encoder.0,
|
command_encoder_id: self.encoder.0,
|
||||||
source: convert_ic_buffer(source),
|
source: convert_ic_buffer(source),
|
||||||
destination: convert_ic_texture(destination),
|
destination: convert_ic_texture(destination)?,
|
||||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
copy_size: convert_texture_size(©_size)?,
|
||||||
})
|
})
|
||||||
.expect("Failed to send CopyBufferToTexture");
|
.expect("Failed to send CopyBufferToTexture");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-copybuffertotexture>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-copybuffertotexture>
|
||||||
|
@ -271,20 +237,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
source: &GPUImageCopyTexture,
|
source: &GPUImageCopyTexture,
|
||||||
destination: &GPUImageCopyBuffer,
|
destination: &GPUImageCopyBuffer,
|
||||||
copy_size: GPUExtent3D,
|
copy_size: GPUExtent3D,
|
||||||
) {
|
) -> Fallible<()> {
|
||||||
self.buffers
|
|
||||||
.borrow_mut()
|
|
||||||
.insert(DomRoot::from_ref(&*destination.buffer));
|
|
||||||
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CopyTextureToBuffer {
|
.send(WebGPURequest::CopyTextureToBuffer {
|
||||||
command_encoder_id: self.encoder.0,
|
command_encoder_id: self.encoder.0,
|
||||||
source: convert_ic_texture(source),
|
source: convert_ic_texture(source)?,
|
||||||
destination: convert_ic_buffer(destination),
|
destination: convert_ic_buffer(destination),
|
||||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
copy_size: convert_texture_size(©_size)?,
|
||||||
})
|
})
|
||||||
.expect("Failed to send CopyTextureToBuffer");
|
.expect("Failed to send CopyTextureToBuffer");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#GPUCommandEncoder-copyTextureToTexture>
|
/// <https://gpuweb.github.io/gpuweb/#GPUCommandEncoder-copyTextureToTexture>
|
||||||
|
@ -293,16 +257,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
source: &GPUImageCopyTexture,
|
source: &GPUImageCopyTexture,
|
||||||
destination: &GPUImageCopyTexture,
|
destination: &GPUImageCopyTexture,
|
||||||
copy_size: GPUExtent3D,
|
copy_size: GPUExtent3D,
|
||||||
) {
|
) -> Fallible<()> {
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CopyTextureToTexture {
|
.send(WebGPURequest::CopyTextureToTexture {
|
||||||
command_encoder_id: self.encoder.0,
|
command_encoder_id: self.encoder.0,
|
||||||
source: convert_ic_texture(source),
|
source: convert_ic_texture(source)?,
|
||||||
destination: convert_ic_texture(destination),
|
destination: convert_ic_texture(destination)?,
|
||||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
copy_size: convert_texture_size(©_size)?,
|
||||||
})
|
})
|
||||||
.expect("Failed to send CopyTextureToTexture");
|
.expect("Failed to send CopyTextureToTexture");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-finish>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-finish>
|
||||||
|
@ -312,9 +278,9 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
.send(WebGPURequest::CommandEncoderFinish {
|
.send(WebGPURequest::CommandEncoderFinish {
|
||||||
command_encoder_id: self.encoder.0,
|
command_encoder_id: self.encoder.0,
|
||||||
device_id: self.device.id().0,
|
device_id: self.device.id().0,
|
||||||
is_error: !self.valid.get(),
|
desc: wgt::CommandBufferDescriptor {
|
||||||
// TODO(zakorgy): We should use `_descriptor` here after it's not empty
|
label: convert_label(&descriptor.parent),
|
||||||
// and the underlying wgpu-core struct is serializable
|
},
|
||||||
})
|
})
|
||||||
.expect("Failed to send Finish");
|
.expect("Failed to send Finish");
|
||||||
|
|
||||||
|
@ -323,7 +289,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
&self.global(),
|
&self.global(),
|
||||||
self.channel.clone(),
|
self.channel.clone(),
|
||||||
buffer,
|
buffer,
|
||||||
self.buffers.borrow_mut().drain().collect(),
|
|
||||||
descriptor.parent.label.clone(),
|
descriptor.parent.label.clone(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,23 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::num::NonZeroU64;
|
||||||
|
|
||||||
use webgpu::wgc::command as wgpu_com;
|
use webgpu::wgc::command as wgpu_com;
|
||||||
use webgpu::wgt::{self, AstcBlock, AstcChannel};
|
use webgpu::wgt::{self, AstcBlock, AstcChannel};
|
||||||
|
|
||||||
|
use super::bindings::error::Error;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
GPUAddressMode, GPUBlendComponent, GPUBlendFactor, GPUBlendOperation, GPUCompareFunction,
|
GPUAddressMode, GPUBindGroupLayoutEntry, GPUBlendComponent, GPUBlendFactor, GPUBlendOperation,
|
||||||
GPUCullMode, GPUExtent3D, GPUExtent3DDict, GPUFilterMode, GPUFrontFace, GPUImageCopyBuffer,
|
GPUBufferBindingType, GPUColor, GPUCompareFunction, GPUCullMode, GPUExtent3D, GPUFilterMode,
|
||||||
GPUImageCopyTexture, GPUImageDataLayout, GPUIndexFormat, GPULoadOp, GPUObjectDescriptorBase,
|
GPUFrontFace, GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, GPUIndexFormat,
|
||||||
GPUOrigin3D, GPUPrimitiveState, GPUPrimitiveTopology, GPUStencilOperation, GPUStoreOp,
|
GPULoadOp, GPUObjectDescriptorBase, GPUOrigin3D, GPUPrimitiveState, GPUPrimitiveTopology,
|
||||||
GPUTextureAspect, GPUTextureFormat, GPUTextureViewDimension, GPUVertexFormat,
|
GPUSamplerBindingType, GPUStencilOperation, GPUStorageTextureAccess, GPUStoreOp,
|
||||||
|
GPUTextureAspect, GPUTextureFormat, GPUTextureSampleType, GPUTextureViewDimension,
|
||||||
|
GPUVertexFormat,
|
||||||
};
|
};
|
||||||
|
use crate::dom::bindings::error::Fallible;
|
||||||
|
use crate::dom::types::GPUDevice;
|
||||||
|
|
||||||
pub fn convert_texture_format(format: GPUTextureFormat) -> wgt::TextureFormat {
|
pub fn convert_texture_format(format: GPUTextureFormat) -> wgt::TextureFormat {
|
||||||
match format {
|
match format {
|
||||||
|
@ -212,33 +218,30 @@ pub fn convert_texture_view_dimension(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_texture_size_to_dict(size: &GPUExtent3D) -> GPUExtent3DDict {
|
pub fn convert_texture_size(size: &GPUExtent3D) -> Fallible<wgt::Extent3d> {
|
||||||
match *size {
|
match *size {
|
||||||
GPUExtent3D::GPUExtent3DDict(ref dict) => GPUExtent3DDict {
|
GPUExtent3D::GPUExtent3DDict(ref dict) => Ok(wgt::Extent3d {
|
||||||
width: dict.width,
|
width: dict.width,
|
||||||
height: dict.height,
|
height: dict.height,
|
||||||
depthOrArrayLayers: dict.depthOrArrayLayers,
|
depth_or_array_layers: dict.depthOrArrayLayers,
|
||||||
},
|
}),
|
||||||
GPUExtent3D::RangeEnforcedUnsignedLongSequence(ref v) => {
|
GPUExtent3D::RangeEnforcedUnsignedLongSequence(ref v) => {
|
||||||
let mut w = v.clone();
|
// https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-gpuextent3d-shape
|
||||||
w.resize(3, 1);
|
if v.len() < 1 || v.len() > 3 {
|
||||||
GPUExtent3DDict {
|
Err(Error::Type(
|
||||||
width: w[0],
|
"GPUExtent3D size must be between 1 and 3 (inclusive)".to_string(),
|
||||||
height: w[1],
|
))
|
||||||
depthOrArrayLayers: w[2],
|
} else {
|
||||||
|
Ok(wgt::Extent3d {
|
||||||
|
width: v[0],
|
||||||
|
height: v.get(1).copied().unwrap_or(1),
|
||||||
|
depth_or_array_layers: v.get(2).copied().unwrap_or(1),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_texture_size_to_wgt(size: &GPUExtent3DDict) -> wgt::Extent3d {
|
|
||||||
wgt::Extent3d {
|
|
||||||
width: size.width,
|
|
||||||
height: size.height,
|
|
||||||
depth_or_array_layers: size.depthOrArrayLayers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn convert_image_data_layout(data_layout: &GPUImageDataLayout) -> wgt::ImageDataLayout {
|
pub fn convert_image_data_layout(data_layout: &GPUImageDataLayout) -> wgt::ImageDataLayout {
|
||||||
wgt::ImageDataLayout {
|
wgt::ImageDataLayout {
|
||||||
offset: data_layout.offset as wgt::BufferAddress,
|
offset: data_layout.offset as wgt::BufferAddress,
|
||||||
|
@ -426,33 +429,48 @@ pub fn convert_ic_buffer(ic_buffer: &GPUImageCopyBuffer) -> wgpu_com::ImageCopyB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_ic_texture(ic_texture: &GPUImageCopyTexture) -> wgpu_com::ImageCopyTexture {
|
pub fn convert_origin3d(origin: &GPUOrigin3D) -> Fallible<wgt::Origin3d> {
|
||||||
wgpu_com::ImageCopyTexture {
|
match origin {
|
||||||
texture: ic_texture.texture.id().0,
|
GPUOrigin3D::RangeEnforcedUnsignedLongSequence(v) => {
|
||||||
mip_level: ic_texture.mipLevel,
|
// https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-gpuorigin3d-shape
|
||||||
origin: match ic_texture.origin {
|
if v.len() > 3 {
|
||||||
Some(GPUOrigin3D::RangeEnforcedUnsignedLongSequence(ref v)) => {
|
Err(Error::Type(
|
||||||
let mut w = v.clone();
|
"sequence is too long for GPUOrigin3D".to_string(),
|
||||||
w.resize(3, 0);
|
))
|
||||||
wgt::Origin3d {
|
} else {
|
||||||
x: w[0],
|
Ok(wgt::Origin3d {
|
||||||
y: w[1],
|
x: v.get(0).copied().unwrap_or(0),
|
||||||
z: w[2],
|
y: v.get(1).copied().unwrap_or(0),
|
||||||
|
z: v.get(2).copied().unwrap_or(0),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(GPUOrigin3D::GPUOrigin3DDict(ref d)) => wgt::Origin3d {
|
GPUOrigin3D::GPUOrigin3DDict(d) => Ok(wgt::Origin3d {
|
||||||
x: d.x,
|
x: d.x,
|
||||||
y: d.y,
|
y: d.y,
|
||||||
z: d.z,
|
z: d.z,
|
||||||
},
|
}),
|
||||||
None => wgt::Origin3d::default(),
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
pub fn convert_ic_texture(
|
||||||
|
ic_texture: &GPUImageCopyTexture,
|
||||||
|
) -> Fallible<wgpu_com::ImageCopyTexture> {
|
||||||
|
Ok(wgpu_com::ImageCopyTexture {
|
||||||
|
texture: ic_texture.texture.id().0,
|
||||||
|
mip_level: ic_texture.mipLevel,
|
||||||
|
origin: ic_texture
|
||||||
|
.origin
|
||||||
|
.as_ref()
|
||||||
|
.map(|origin| convert_origin3d(origin))
|
||||||
|
.transpose()?
|
||||||
|
.unwrap_or_default(),
|
||||||
aspect: match ic_texture.aspect {
|
aspect: match ic_texture.aspect {
|
||||||
GPUTextureAspect::All => wgt::TextureAspect::All,
|
GPUTextureAspect::All => wgt::TextureAspect::All,
|
||||||
GPUTextureAspect::Stencil_only => wgt::TextureAspect::StencilOnly,
|
GPUTextureAspect::Stencil_only => wgt::TextureAspect::StencilOnly,
|
||||||
GPUTextureAspect::Depth_only => wgt::TextureAspect::DepthOnly,
|
GPUTextureAspect::Depth_only => wgt::TextureAspect::DepthOnly,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_label(parent: &GPUObjectDescriptorBase) -> Option<Cow<'static, str>> {
|
pub fn convert_label(parent: &GPUObjectDescriptorBase) -> Option<Cow<'static, str>> {
|
||||||
|
@ -462,3 +480,102 @@ pub fn convert_label(parent: &GPUObjectDescriptorBase) -> Option<Cow<'static, st
|
||||||
Some(Cow::Owned(parent.label.to_string()))
|
Some(Cow::Owned(parent.label.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn convert_bind_group_layout_entry(
|
||||||
|
bgle: &GPUBindGroupLayoutEntry,
|
||||||
|
device: &GPUDevice,
|
||||||
|
) -> Fallible<Result<wgt::BindGroupLayoutEntry, webgpu::Error>> {
|
||||||
|
let number_of_provided_bindings = bgle.buffer.is_some() as u8 +
|
||||||
|
bgle.sampler.is_some() as u8 +
|
||||||
|
bgle.storageTexture.is_some() as u8 +
|
||||||
|
bgle.texture.is_some() as u8;
|
||||||
|
let ty = if let Some(buffer) = &bgle.buffer {
|
||||||
|
Some(wgt::BindingType::Buffer {
|
||||||
|
ty: match buffer.type_ {
|
||||||
|
GPUBufferBindingType::Uniform => wgt::BufferBindingType::Uniform,
|
||||||
|
GPUBufferBindingType::Storage => {
|
||||||
|
wgt::BufferBindingType::Storage { read_only: false }
|
||||||
|
},
|
||||||
|
GPUBufferBindingType::Read_only_storage => {
|
||||||
|
wgt::BufferBindingType::Storage { read_only: true }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
has_dynamic_offset: buffer.hasDynamicOffset,
|
||||||
|
min_binding_size: NonZeroU64::new(buffer.minBindingSize),
|
||||||
|
})
|
||||||
|
} else if let Some(sampler) = &bgle.sampler {
|
||||||
|
Some(wgt::BindingType::Sampler(match sampler.type_ {
|
||||||
|
GPUSamplerBindingType::Filtering => wgt::SamplerBindingType::Filtering,
|
||||||
|
GPUSamplerBindingType::Non_filtering => wgt::SamplerBindingType::NonFiltering,
|
||||||
|
GPUSamplerBindingType::Comparison => wgt::SamplerBindingType::Comparison,
|
||||||
|
}))
|
||||||
|
} else if let Some(storage) = &bgle.storageTexture {
|
||||||
|
Some(wgt::BindingType::StorageTexture {
|
||||||
|
access: match storage.access {
|
||||||
|
GPUStorageTextureAccess::Write_only => wgt::StorageTextureAccess::WriteOnly,
|
||||||
|
GPUStorageTextureAccess::Read_only => wgt::StorageTextureAccess::ReadOnly,
|
||||||
|
GPUStorageTextureAccess::Read_write => wgt::StorageTextureAccess::ReadWrite,
|
||||||
|
},
|
||||||
|
format: device.validate_texture_format_required_features(&storage.format)?,
|
||||||
|
view_dimension: convert_view_dimension(storage.viewDimension),
|
||||||
|
})
|
||||||
|
} else if let Some(texture) = &bgle.texture {
|
||||||
|
Some(wgt::BindingType::Texture {
|
||||||
|
sample_type: match texture.sampleType {
|
||||||
|
GPUTextureSampleType::Float => wgt::TextureSampleType::Float { filterable: true },
|
||||||
|
GPUTextureSampleType::Unfilterable_float => {
|
||||||
|
wgt::TextureSampleType::Float { filterable: false }
|
||||||
|
},
|
||||||
|
GPUTextureSampleType::Depth => wgt::TextureSampleType::Depth,
|
||||||
|
GPUTextureSampleType::Sint => wgt::TextureSampleType::Sint,
|
||||||
|
GPUTextureSampleType::Uint => wgt::TextureSampleType::Uint,
|
||||||
|
},
|
||||||
|
view_dimension: convert_view_dimension(texture.viewDimension),
|
||||||
|
multisampled: texture.multisampled,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
assert_eq!(number_of_provided_bindings, 0);
|
||||||
|
None
|
||||||
|
};
|
||||||
|
// Check for number of bindings should actually be done in device-timeline,
|
||||||
|
// but we do it last on content-timeline to have some visible effect
|
||||||
|
let ty = if number_of_provided_bindings != 1 {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
ty
|
||||||
|
}
|
||||||
|
.ok_or(webgpu::Error::Validation(
|
||||||
|
"Exactly on entry type must be provided".to_string(),
|
||||||
|
));
|
||||||
|
|
||||||
|
Ok(ty.map(|ty| wgt::BindGroupLayoutEntry {
|
||||||
|
binding: bgle.binding,
|
||||||
|
visibility: wgt::ShaderStages::from_bits_retain(bgle.visibility),
|
||||||
|
ty,
|
||||||
|
count: None,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_color(color: &GPUColor) -> Fallible<wgt::Color> {
|
||||||
|
match color {
|
||||||
|
GPUColor::DoubleSequence(s) => {
|
||||||
|
// https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-gpucolor-shape
|
||||||
|
if s.len() != 4 {
|
||||||
|
Err(Error::Type("GPUColor sequence must be len 4".to_string()))
|
||||||
|
} else {
|
||||||
|
Ok(wgt::Color {
|
||||||
|
r: *s[0],
|
||||||
|
g: *s[1],
|
||||||
|
b: *s[2],
|
||||||
|
a: *s[3],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
GPUColor::GPUColorDict(d) => Ok(wgt::Color {
|
||||||
|
r: *d.r,
|
||||||
|
g: *d.g,
|
||||||
|
b: *d.b,
|
||||||
|
a: *d.a,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::num::NonZeroU64;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -29,6 +28,7 @@ use super::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode;
|
use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode;
|
||||||
use super::bindings::error::Fallible;
|
use super::bindings::error::Fallible;
|
||||||
use super::gpu::AsyncWGPUListener;
|
use super::gpu::AsyncWGPUListener;
|
||||||
|
use super::gpuconvert::convert_bind_group_layout_entry;
|
||||||
use super::gpudevicelostinfo::GPUDeviceLostInfo;
|
use super::gpudevicelostinfo::GPUDeviceLostInfo;
|
||||||
use super::gpupipelineerror::GPUPipelineError;
|
use super::gpupipelineerror::GPUPipelineError;
|
||||||
use super::gpusupportedlimits::GPUSupportedLimits;
|
use super::gpusupportedlimits::GPUSupportedLimits;
|
||||||
|
@ -37,13 +37,12 @@ use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::EventBinding::EventInit;
|
use crate::dom::bindings::codegen::Bindings::EventBinding::EventInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
GPUBindGroupDescriptor, GPUBindGroupLayoutDescriptor, GPUBindingResource, GPUBufferBindingType,
|
GPUBindGroupDescriptor, GPUBindGroupLayoutDescriptor, GPUBindingResource, GPUBufferDescriptor,
|
||||||
GPUBufferDescriptor, GPUCommandEncoderDescriptor, GPUComputePipelineDescriptor,
|
GPUCommandEncoderDescriptor, GPUComputePipelineDescriptor, GPUDeviceLostReason,
|
||||||
GPUDeviceLostReason, GPUDeviceMethods, GPUErrorFilter, GPUPipelineLayoutDescriptor,
|
GPUDeviceMethods, GPUErrorFilter, GPUPipelineLayoutDescriptor,
|
||||||
GPURenderBundleEncoderDescriptor, GPURenderPipelineDescriptor, GPUSamplerBindingType,
|
GPURenderBundleEncoderDescriptor, GPURenderPipelineDescriptor, GPUSamplerDescriptor,
|
||||||
GPUSamplerDescriptor, GPUShaderModuleDescriptor, GPUStorageTextureAccess,
|
GPUShaderModuleDescriptor, GPUSupportedLimitsMethods, GPUTextureDescriptor,
|
||||||
GPUSupportedLimitsMethods, GPUTextureDescriptor, GPUTextureDimension, GPUTextureSampleType,
|
GPUTextureDimension, GPUUncapturedErrorEventInit, GPUVertexStepMode,
|
||||||
GPUUncapturedErrorEventInit, GPUVertexStepMode,
|
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::error::Error;
|
use crate::dom::bindings::error::Error;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||||
|
@ -62,8 +61,7 @@ use crate::dom::gpucomputepipeline::GPUComputePipeline;
|
||||||
use crate::dom::gpuconvert::{
|
use crate::dom::gpuconvert::{
|
||||||
convert_address_mode, convert_blend_component, convert_compare_function, convert_filter_mode,
|
convert_address_mode, convert_blend_component, convert_compare_function, convert_filter_mode,
|
||||||
convert_label, convert_primitive_state, convert_stencil_op, convert_texture_format,
|
convert_label, convert_primitive_state, convert_stencil_op, convert_texture_format,
|
||||||
convert_texture_size_to_dict, convert_texture_size_to_wgt, convert_vertex_format,
|
convert_texture_size, convert_vertex_format,
|
||||||
convert_view_dimension,
|
|
||||||
};
|
};
|
||||||
use crate::dom::gpupipelinelayout::GPUPipelineLayout;
|
use crate::dom::gpupipelinelayout::GPUPipelineLayout;
|
||||||
use crate::dom::gpuqueue::GPUQueue;
|
use crate::dom::gpuqueue::GPUQueue;
|
||||||
|
@ -484,91 +482,21 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
&self,
|
&self,
|
||||||
descriptor: &GPUBindGroupLayoutDescriptor,
|
descriptor: &GPUBindGroupLayoutDescriptor,
|
||||||
) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||||
// TODO(sagudev): pass invalid bits to wgpu
|
|
||||||
let mut valid = true;
|
|
||||||
let entries = descriptor
|
let entries = descriptor
|
||||||
.entries
|
.entries
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bind| {
|
.map(|bgle| convert_bind_group_layout_entry(bgle, &self))
|
||||||
let visibility = match wgt::ShaderStages::from_bits(bind.visibility) {
|
.collect::<Fallible<Result<Vec<_>, _>>>()?;
|
||||||
Some(visibility) => visibility,
|
|
||||||
None => {
|
|
||||||
valid = false;
|
|
||||||
wgt::ShaderStages::empty()
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let ty = if let Some(buffer) = &bind.buffer {
|
|
||||||
wgt::BindingType::Buffer {
|
|
||||||
ty: match buffer.type_ {
|
|
||||||
GPUBufferBindingType::Uniform => wgt::BufferBindingType::Uniform,
|
|
||||||
GPUBufferBindingType::Storage => {
|
|
||||||
wgt::BufferBindingType::Storage { read_only: false }
|
|
||||||
},
|
|
||||||
GPUBufferBindingType::Read_only_storage => {
|
|
||||||
wgt::BufferBindingType::Storage { read_only: true }
|
|
||||||
},
|
|
||||||
},
|
|
||||||
has_dynamic_offset: buffer.hasDynamicOffset,
|
|
||||||
min_binding_size: NonZeroU64::new(buffer.minBindingSize),
|
|
||||||
}
|
|
||||||
} else if let Some(sampler) = &bind.sampler {
|
|
||||||
wgt::BindingType::Sampler(match sampler.type_ {
|
|
||||||
GPUSamplerBindingType::Filtering => wgt::SamplerBindingType::Filtering,
|
|
||||||
GPUSamplerBindingType::Non_filtering => {
|
|
||||||
wgt::SamplerBindingType::NonFiltering
|
|
||||||
},
|
|
||||||
GPUSamplerBindingType::Comparison => wgt::SamplerBindingType::Comparison,
|
|
||||||
})
|
|
||||||
} else if let Some(storage) = &bind.storageTexture {
|
|
||||||
wgt::BindingType::StorageTexture {
|
|
||||||
access: match storage.access {
|
|
||||||
GPUStorageTextureAccess::Write_only => {
|
|
||||||
wgt::StorageTextureAccess::WriteOnly
|
|
||||||
},
|
|
||||||
},
|
|
||||||
format: self.validate_texture_format_required_features(&storage.format)?,
|
|
||||||
view_dimension: convert_view_dimension(storage.viewDimension),
|
|
||||||
}
|
|
||||||
} else if let Some(texture) = &bind.texture {
|
|
||||||
wgt::BindingType::Texture {
|
|
||||||
sample_type: match texture.sampleType {
|
|
||||||
GPUTextureSampleType::Float => {
|
|
||||||
wgt::TextureSampleType::Float { filterable: true }
|
|
||||||
},
|
|
||||||
GPUTextureSampleType::Unfilterable_float => {
|
|
||||||
wgt::TextureSampleType::Float { filterable: false }
|
|
||||||
},
|
|
||||||
GPUTextureSampleType::Depth => wgt::TextureSampleType::Depth,
|
|
||||||
GPUTextureSampleType::Sint => wgt::TextureSampleType::Sint,
|
|
||||||
GPUTextureSampleType::Uint => wgt::TextureSampleType::Uint,
|
|
||||||
},
|
|
||||||
view_dimension: convert_view_dimension(texture.viewDimension),
|
|
||||||
multisampled: texture.multisampled,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
valid = false;
|
|
||||||
todo!("Handle error");
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(wgt::BindGroupLayoutEntry {
|
let desc = match entries {
|
||||||
binding: bind.binding,
|
Ok(entries) => Some(wgpu_bind::BindGroupLayoutDescriptor {
|
||||||
visibility,
|
|
||||||
ty,
|
|
||||||
count: None,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect::<Fallible<Vec<_>>>()?;
|
|
||||||
|
|
||||||
let desc = if valid {
|
|
||||||
Some(wgpu_bind::BindGroupLayoutDescriptor {
|
|
||||||
label: convert_label(&descriptor.parent),
|
label: convert_label(&descriptor.parent),
|
||||||
entries: Cow::Owned(entries),
|
entries: Cow::Owned(entries),
|
||||||
})
|
}),
|
||||||
} else {
|
Err(error) => {
|
||||||
self.dispatch_error(webgpu::Error::Validation(String::from(
|
self.dispatch_error(error);
|
||||||
"Invalid GPUShaderStage",
|
|
||||||
)));
|
|
||||||
None
|
None
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let bind_group_layout_id = self
|
let bind_group_layout_id = self
|
||||||
|
@ -833,7 +761,9 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
.send(WebGPURequest::CreateCommandEncoder {
|
.send(WebGPURequest::CreateCommandEncoder {
|
||||||
device_id: self.device.0,
|
device_id: self.device.0,
|
||||||
command_encoder_id,
|
command_encoder_id,
|
||||||
|
desc: wgt::CommandEncoderDescriptor {
|
||||||
label: convert_label(&descriptor.parent),
|
label: convert_label(&descriptor.parent),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.expect("Failed to create WebGPU command encoder");
|
.expect("Failed to create WebGPU command encoder");
|
||||||
|
|
||||||
|
@ -850,14 +780,10 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
||||||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> Fallible<DomRoot<GPUTexture>> {
|
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> Fallible<DomRoot<GPUTexture>> {
|
||||||
// TODO(sagudev): This should be https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-gpuextent3d-shape
|
let size = convert_texture_size(&descriptor.size)?;
|
||||||
let size = convert_texture_size_to_dict(&descriptor.size);
|
let desc = wgpu_res::TextureDescriptor {
|
||||||
// TODO(sagudev): We should pass invalid bits to wgpu
|
|
||||||
let desc = wgt::TextureUsages::from_bits(descriptor.usage)
|
|
||||||
.map(|usg| -> Fallible<_> {
|
|
||||||
Ok(wgpu_res::TextureDescriptor {
|
|
||||||
label: convert_label(&descriptor.parent),
|
label: convert_label(&descriptor.parent),
|
||||||
size: convert_texture_size_to_wgt(&size),
|
size,
|
||||||
mip_level_count: descriptor.mipLevelCount,
|
mip_level_count: descriptor.mipLevelCount,
|
||||||
sample_count: descriptor.sampleCount,
|
sample_count: descriptor.sampleCount,
|
||||||
dimension: match descriptor.dimension {
|
dimension: match descriptor.dimension {
|
||||||
|
@ -866,24 +792,19 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
GPUTextureDimension::_3d => wgt::TextureDimension::D3,
|
GPUTextureDimension::_3d => wgt::TextureDimension::D3,
|
||||||
},
|
},
|
||||||
format: self.validate_texture_format_required_features(&descriptor.format)?,
|
format: self.validate_texture_format_required_features(&descriptor.format)?,
|
||||||
usage: usg,
|
usage: wgt::TextureUsages::from_bits_retain(descriptor.usage),
|
||||||
view_formats: descriptor
|
view_formats: descriptor
|
||||||
.viewFormats
|
.viewFormats
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tf| self.validate_texture_format_required_features(tf))
|
.map(|tf| self.validate_texture_format_required_features(tf))
|
||||||
.collect::<Fallible<_>>()?,
|
.collect::<Fallible<_>>()?,
|
||||||
})
|
};
|
||||||
})
|
|
||||||
.transpose()?;
|
|
||||||
|
|
||||||
let texture_id = self
|
let texture_id = self
|
||||||
.global()
|
.global()
|
||||||
.wgpu_id_hub()
|
.wgpu_id_hub()
|
||||||
.create_texture_id(self.device.0.backend());
|
.create_texture_id(self.device.0.backend());
|
||||||
|
|
||||||
if desc.is_none() {
|
|
||||||
return Err(Error::Type(String::from("Invalid GPUTextureUsage")));
|
|
||||||
}
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CreateTexture {
|
.send(WebGPURequest::CreateTexture {
|
||||||
|
|
|
@ -22,10 +22,7 @@ use crate::dom::bindings::str::USVString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::gpubuffer::GPUBuffer;
|
use crate::dom::gpubuffer::GPUBuffer;
|
||||||
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
|
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
|
||||||
use crate::dom::gpuconvert::{
|
use crate::dom::gpuconvert::{convert_ic_texture, convert_image_data_layout, convert_texture_size};
|
||||||
convert_ic_texture, convert_image_data_layout, convert_texture_size_to_dict,
|
|
||||||
convert_texture_size_to_wgt,
|
|
||||||
};
|
|
||||||
use crate::dom::gpudevice::GPUDevice;
|
use crate::dom::gpudevice::GPUDevice;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
|
||||||
|
@ -166,9 +163,9 @@ impl GPUQueueMethods for GPUQueue {
|
||||||
return Err(Error::Operation);
|
return Err(Error::Operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
let texture_cv = convert_ic_texture(destination);
|
let texture_cv = convert_ic_texture(destination)?;
|
||||||
let texture_layout = convert_image_data_layout(data_layout);
|
let texture_layout = convert_image_data_layout(data_layout);
|
||||||
let write_size = convert_texture_size_to_wgt(&convert_texture_size_to_dict(&size));
|
let write_size = convert_texture_size(&size)?;
|
||||||
let final_data = IpcSharedMemory::from_bytes(&bytes);
|
let final_data = IpcSharedMemory::from_bytes(&bytes);
|
||||||
|
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::WriteTexture {
|
if let Err(e) = self.channel.0.send(WebGPURequest::WriteTexture {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use dom_struct::dom_struct;
|
||||||
use webgpu::{wgt, RenderCommand, WebGPU, WebGPURenderPass, WebGPURequest};
|
use webgpu::{wgt, RenderCommand, WebGPU, WebGPURenderPass, WebGPURequest};
|
||||||
|
|
||||||
use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat;
|
use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat;
|
||||||
|
use super::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
GPUColor, GPURenderPassEncoderMethods,
|
GPUColor, GPURenderPassEncoderMethods,
|
||||||
|
@ -18,6 +19,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::gpubindgroup::GPUBindGroup;
|
use crate::dom::gpubindgroup::GPUBindGroup;
|
||||||
use crate::dom::gpubuffer::GPUBuffer;
|
use crate::dom::gpubuffer::GPUBuffer;
|
||||||
use crate::dom::gpucommandencoder::GPUCommandEncoder;
|
use crate::dom::gpucommandencoder::GPUCommandEncoder;
|
||||||
|
use crate::dom::gpuconvert::convert_color;
|
||||||
use crate::dom::gpurenderbundle::GPURenderBundle;
|
use crate::dom::gpurenderbundle::GPURenderBundle;
|
||||||
use crate::dom::gpurenderpipeline::GPURenderPipeline;
|
use crate::dom::gpurenderpipeline::GPURenderPipeline;
|
||||||
|
|
||||||
|
@ -129,28 +131,9 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-setblendcolor>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-setblendcolor>
|
||||||
fn SetBlendConstant(&self, color: GPUColor) {
|
fn SetBlendConstant(&self, color: GPUColor) -> Fallible<()> {
|
||||||
let color = match color {
|
self.send_render_command(RenderCommand::SetBlendConstant(convert_color(&color)?));
|
||||||
GPUColor::GPUColorDict(d) => wgt::Color {
|
Ok(())
|
||||||
r: *d.r,
|
|
||||||
g: *d.g,
|
|
||||||
b: *d.b,
|
|
||||||
a: *d.a,
|
|
||||||
},
|
|
||||||
GPUColor::DoubleSequence(mut s) => {
|
|
||||||
if s.len() < 3 {
|
|
||||||
s.resize(3, Finite::wrap(0.0f64));
|
|
||||||
}
|
|
||||||
s.resize(4, Finite::wrap(1.0f64));
|
|
||||||
wgt::Color {
|
|
||||||
r: *s[0],
|
|
||||||
g: *s[1],
|
|
||||||
b: *s[2],
|
|
||||||
a: *s[3],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
self.send_render_command(RenderCommand::SetBlendConstant(color))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-setstencilreference>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-setstencilreference>
|
||||||
|
|
|
@ -12,7 +12,7 @@ use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
|
||||||
use super::bindings::error::Fallible;
|
use super::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||||
GPUExtent3DDict, GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
|
GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
|
||||||
GPUTextureViewDescriptor,
|
GPUTextureViewDescriptor,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||||
|
@ -33,8 +33,9 @@ pub struct GPUTexture {
|
||||||
#[ignore_malloc_size_of = "channels are hard"]
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
#[ignore_malloc_size_of = "defined in wgpu"]
|
||||||
texture_size: GPUExtent3DDict,
|
#[no_trace]
|
||||||
|
texture_size: wgt::Extent3d,
|
||||||
mip_level_count: u32,
|
mip_level_count: u32,
|
||||||
sample_count: u32,
|
sample_count: u32,
|
||||||
dimension: GPUTextureDimension,
|
dimension: GPUTextureDimension,
|
||||||
|
@ -49,7 +50,7 @@ impl GPUTexture {
|
||||||
texture: WebGPUTexture,
|
texture: WebGPUTexture,
|
||||||
device: &GPUDevice,
|
device: &GPUDevice,
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
texture_size: GPUExtent3DDict,
|
texture_size: wgt::Extent3d,
|
||||||
mip_level_count: u32,
|
mip_level_count: u32,
|
||||||
sample_count: u32,
|
sample_count: u32,
|
||||||
dimension: GPUTextureDimension,
|
dimension: GPUTextureDimension,
|
||||||
|
@ -79,7 +80,7 @@ impl GPUTexture {
|
||||||
texture: WebGPUTexture,
|
texture: WebGPUTexture,
|
||||||
device: &GPUDevice,
|
device: &GPUDevice,
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
texture_size: GPUExtent3DDict,
|
texture_size: wgt::Extent3d,
|
||||||
mip_level_count: u32,
|
mip_level_count: u32,
|
||||||
sample_count: u32,
|
sample_count: u32,
|
||||||
dimension: GPUTextureDimension,
|
dimension: GPUTextureDimension,
|
||||||
|
@ -230,7 +231,7 @@ impl GPUTextureMethods for GPUTexture {
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-depthorarraylayers>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-depthorarraylayers>
|
||||||
fn DepthOrArrayLayers(&self) -> u32 {
|
fn DepthOrArrayLayers(&self) -> u32 {
|
||||||
self.texture_size.depthOrArrayLayers
|
self.texture_size.depth_or_array_layers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-miplevelcount>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-miplevelcount>
|
||||||
|
|
|
@ -462,10 +462,12 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
|
||||||
dictionary GPUBindGroupLayoutEntry {
|
dictionary GPUBindGroupLayoutEntry {
|
||||||
required GPUIndex32 binding;
|
required GPUIndex32 binding;
|
||||||
required GPUShaderStageFlags visibility;
|
required GPUShaderStageFlags visibility;
|
||||||
|
|
||||||
GPUBufferBindingLayout buffer;
|
GPUBufferBindingLayout buffer;
|
||||||
GPUSamplerBindingLayout sampler;
|
GPUSamplerBindingLayout sampler;
|
||||||
GPUTextureBindingLayout texture;
|
GPUTextureBindingLayout texture;
|
||||||
GPUStorageTextureBindingLayout storageTexture;
|
GPUStorageTextureBindingLayout storageTexture;
|
||||||
|
GPUExternalTextureBindingLayout externalTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
|
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
|
||||||
|
@ -514,6 +516,8 @@ dictionary GPUTextureBindingLayout {
|
||||||
|
|
||||||
enum GPUStorageTextureAccess {
|
enum GPUStorageTextureAccess {
|
||||||
"write-only",
|
"write-only",
|
||||||
|
"read-only",
|
||||||
|
"read-write",
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUStorageTextureBindingLayout {
|
dictionary GPUStorageTextureBindingLayout {
|
||||||
|
@ -522,6 +526,9 @@ dictionary GPUStorageTextureBindingLayout {
|
||||||
GPUTextureViewDimension viewDimension = "2d";
|
GPUTextureViewDimension viewDimension = "2d";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary GPUExternalTextureBindingLayout {
|
||||||
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
|
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
|
||||||
interface GPUBindGroup {
|
interface GPUBindGroup {
|
||||||
};
|
};
|
||||||
|
@ -867,7 +874,7 @@ dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
||||||
interface GPUCommandEncoder {
|
interface GPUCommandEncoder {
|
||||||
[NewObject]
|
[NewObject]
|
||||||
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
|
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
|
||||||
[NewObject]
|
[NewObject, Throws]
|
||||||
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
||||||
|
|
||||||
undefined copyBufferToBuffer(
|
undefined copyBufferToBuffer(
|
||||||
|
@ -877,16 +884,19 @@ interface GPUCommandEncoder {
|
||||||
GPUSize64 destinationOffset,
|
GPUSize64 destinationOffset,
|
||||||
GPUSize64 size);
|
GPUSize64 size);
|
||||||
|
|
||||||
|
[Throws]
|
||||||
undefined copyBufferToTexture(
|
undefined copyBufferToTexture(
|
||||||
GPUImageCopyBuffer source,
|
GPUImageCopyBuffer source,
|
||||||
GPUImageCopyTexture destination,
|
GPUImageCopyTexture destination,
|
||||||
GPUExtent3D copySize);
|
GPUExtent3D copySize);
|
||||||
|
|
||||||
|
[Throws]
|
||||||
undefined copyTextureToBuffer(
|
undefined copyTextureToBuffer(
|
||||||
GPUImageCopyTexture source,
|
GPUImageCopyTexture source,
|
||||||
GPUImageCopyBuffer destination,
|
GPUImageCopyBuffer destination,
|
||||||
GPUExtent3D copySize);
|
GPUExtent3D copySize);
|
||||||
|
|
||||||
|
[Throws]
|
||||||
undefined copyTextureToTexture(
|
undefined copyTextureToTexture(
|
||||||
GPUImageCopyTexture source,
|
GPUImageCopyTexture source,
|
||||||
GPUImageCopyTexture destination,
|
GPUImageCopyTexture destination,
|
||||||
|
@ -942,6 +952,7 @@ interface GPURenderPassEncoder {
|
||||||
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
|
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
|
||||||
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
|
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
|
||||||
|
|
||||||
|
[Throws]
|
||||||
undefined setBlendConstant(GPUColor color);
|
undefined setBlendConstant(GPUColor color);
|
||||||
undefined setStencilReference(GPUStencilValue reference);
|
undefined setStencilReference(GPUStencilValue reference);
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
//! IPC messages that are received in wgpu thread
|
//! IPC messages that are received in wgpu thread
|
||||||
//! (usually from script thread more specifically from dom objects)
|
//! (usually from script thread more specifically from dom objects)
|
||||||
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
|
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
|
||||||
|
@ -27,6 +25,7 @@ use wgc::resource::{
|
||||||
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||||
};
|
};
|
||||||
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
|
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
|
||||||
|
use wgpu_core::Label;
|
||||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||||
|
|
||||||
use crate::identity::*;
|
use crate::identity::*;
|
||||||
|
@ -46,9 +45,7 @@ pub enum WebGPURequest {
|
||||||
CommandEncoderFinish {
|
CommandEncoderFinish {
|
||||||
command_encoder_id: id::CommandEncoderId,
|
command_encoder_id: id::CommandEncoderId,
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
is_error: bool,
|
desc: wgt::CommandBufferDescriptor<Label<'static>>,
|
||||||
// TODO(zakorgy): Serialize CommandBufferDescriptor in wgpu-core
|
|
||||||
// wgc::command::CommandBufferDescriptor,
|
|
||||||
},
|
},
|
||||||
CopyBufferToBuffer {
|
CopyBufferToBuffer {
|
||||||
command_encoder_id: id::CommandEncoderId,
|
command_encoder_id: id::CommandEncoderId,
|
||||||
|
@ -93,10 +90,8 @@ pub enum WebGPURequest {
|
||||||
},
|
},
|
||||||
CreateCommandEncoder {
|
CreateCommandEncoder {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
|
|
||||||
// wgc::command::CommandEncoderDescriptor,
|
|
||||||
command_encoder_id: id::CommandEncoderId,
|
command_encoder_id: id::CommandEncoderId,
|
||||||
label: Option<Cow<'static, str>>,
|
desc: wgt::CommandEncoderDescriptor<Label<'static>>,
|
||||||
},
|
},
|
||||||
CreateComputePipeline {
|
CreateComputePipeline {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
|
@ -144,7 +139,7 @@ pub enum WebGPURequest {
|
||||||
CreateTexture {
|
CreateTexture {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
texture_id: id::TextureId,
|
texture_id: id::TextureId,
|
||||||
descriptor: Option<TextureDescriptor<'static>>,
|
descriptor: TextureDescriptor<'static>,
|
||||||
},
|
},
|
||||||
CreateTextureView {
|
CreateTextureView {
|
||||||
texture_id: id::TextureId,
|
texture_id: id::TextureId,
|
||||||
|
@ -203,7 +198,7 @@ pub enum WebGPURequest {
|
||||||
BeginComputePass {
|
BeginComputePass {
|
||||||
command_encoder_id: id::CommandEncoderId,
|
command_encoder_id: id::CommandEncoderId,
|
||||||
compute_pass_id: ComputePassId,
|
compute_pass_id: ComputePassId,
|
||||||
label: Option<Cow<'static, str>>,
|
label: Label<'static>,
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
},
|
},
|
||||||
ComputePassSetPipeline {
|
ComputePassSetPipeline {
|
||||||
|
@ -240,7 +235,7 @@ pub enum WebGPURequest {
|
||||||
BeginRenderPass {
|
BeginRenderPass {
|
||||||
command_encoder_id: id::CommandEncoderId,
|
command_encoder_id: id::CommandEncoderId,
|
||||||
render_pass_id: RenderPassId,
|
render_pass_id: RenderPassId,
|
||||||
label: Option<Cow<'static, str>>,
|
label: Label<'static>,
|
||||||
color_attachments: Vec<Option<RenderPassColorAttachment>>,
|
color_attachments: Vec<Option<RenderPassColorAttachment>>,
|
||||||
depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
|
depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
|
|
|
@ -230,21 +230,15 @@ impl WGPU {
|
||||||
WebGPURequest::CommandEncoderFinish {
|
WebGPURequest::CommandEncoderFinish {
|
||||||
command_encoder_id,
|
command_encoder_id,
|
||||||
device_id,
|
device_id,
|
||||||
is_error,
|
desc,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let result = if is_error {
|
let result = if let Some(err) =
|
||||||
Err(Error::Validation(String::from("Invalid GPUCommandEncoder")))
|
|
||||||
} else if let Some(err) =
|
|
||||||
self.error_command_encoders.get(&command_encoder_id)
|
self.error_command_encoders.get(&command_encoder_id)
|
||||||
{
|
{
|
||||||
Err(Error::Validation(err.clone()))
|
Err(Error::Validation(err.clone()))
|
||||||
} else if let Some(error) = global
|
} else if let Some(error) =
|
||||||
.command_encoder_finish(
|
global.command_encoder_finish(command_encoder_id, &desc).1
|
||||||
command_encoder_id,
|
|
||||||
&wgt::CommandBufferDescriptor::default(),
|
|
||||||
)
|
|
||||||
.1
|
|
||||||
{
|
{
|
||||||
Err(Error::from_error(error))
|
Err(Error::from_error(error))
|
||||||
} else {
|
} else {
|
||||||
|
@ -363,10 +357,9 @@ impl WGPU {
|
||||||
WebGPURequest::CreateCommandEncoder {
|
WebGPURequest::CreateCommandEncoder {
|
||||||
device_id,
|
device_id,
|
||||||
command_encoder_id,
|
command_encoder_id,
|
||||||
label,
|
desc,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let desc = wgt::CommandEncoderDescriptor { label };
|
|
||||||
let (_, error) = global.device_create_command_encoder(
|
let (_, error) = global.device_create_command_encoder(
|
||||||
device_id,
|
device_id,
|
||||||
&desc,
|
&desc,
|
||||||
|
@ -579,11 +572,9 @@ impl WGPU {
|
||||||
descriptor,
|
descriptor,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
if let Some(desc) = descriptor {
|
|
||||||
let (_, error) =
|
let (_, error) =
|
||||||
global.device_create_texture(device_id, &desc, Some(texture_id));
|
global.device_create_texture(device_id, &descriptor, Some(texture_id));
|
||||||
self.maybe_dispatch_wgpu_error(device_id, error);
|
self.maybe_dispatch_wgpu_error(device_id, error);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
WebGPURequest::CreateTextureView {
|
WebGPURequest::CreateTextureView {
|
||||||
texture_id,
|
texture_id,
|
||||||
|
|
50
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
50
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
|
@ -20514,8 +20514,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rg32float";access="read-write"]
|
[:format="rg32float";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rg32float";access="write-only"]
|
[:format="rg32float";access="write-only"]
|
||||||
|
|
||||||
|
@ -20524,8 +20522,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rg32sint";access="read-write"]
|
[:format="rg32sint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rg32sint";access="write-only"]
|
[:format="rg32sint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20534,8 +20530,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rg32uint";access="read-write"]
|
[:format="rg32uint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rg32uint";access="write-only"]
|
[:format="rg32uint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20586,8 +20580,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba16float";access="read-write"]
|
[:format="rgba16float";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba16float";access="write-only"]
|
[:format="rgba16float";access="write-only"]
|
||||||
|
|
||||||
|
@ -20596,8 +20588,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba16sint";access="read-write"]
|
[:format="rgba16sint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba16sint";access="write-only"]
|
[:format="rgba16sint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20606,8 +20596,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba16uint";access="read-write"]
|
[:format="rgba16uint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba16uint";access="write-only"]
|
[:format="rgba16uint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20616,8 +20604,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba32float";access="read-write"]
|
[:format="rgba32float";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba32float";access="write-only"]
|
[:format="rgba32float";access="write-only"]
|
||||||
|
|
||||||
|
@ -20626,8 +20612,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba32sint";access="read-write"]
|
[:format="rgba32sint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba32sint";access="write-only"]
|
[:format="rgba32sint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20636,8 +20620,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba32uint";access="read-write"]
|
[:format="rgba32uint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba32uint";access="write-only"]
|
[:format="rgba32uint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20646,8 +20628,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba8sint";access="read-write"]
|
[:format="rgba8sint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba8sint";access="write-only"]
|
[:format="rgba8sint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20656,8 +20636,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba8snorm";access="read-write"]
|
[:format="rgba8snorm";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba8snorm";access="write-only"]
|
[:format="rgba8snorm";access="write-only"]
|
||||||
|
|
||||||
|
@ -20666,8 +20644,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba8uint";access="read-write"]
|
[:format="rgba8uint";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba8uint";access="write-only"]
|
[:format="rgba8uint";access="write-only"]
|
||||||
|
|
||||||
|
@ -20676,8 +20652,6 @@
|
||||||
if os == "linux" and not debug: FAIL
|
if os == "linux" and not debug: FAIL
|
||||||
|
|
||||||
[:format="rgba8unorm";access="read-write"]
|
[:format="rgba8unorm";access="read-write"]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:format="rgba8unorm";access="write-only"]
|
[:format="rgba8unorm";access="write-only"]
|
||||||
|
|
||||||
|
@ -60688,20 +60662,12 @@
|
||||||
[:resourceType="nonFiltSamp";entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
[:resourceType="nonFiltSamp";entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
||||||
|
|
||||||
[:resourceType="readonlyStorageTex";entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
[:resourceType="readonlyStorageTex";entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:resourceType="readonlyStorageTex";entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
[:resourceType="readonlyStorageTex";entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:resourceType="readwriteStorageTex";entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
[:resourceType="readwriteStorageTex";entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:resourceType="readwriteStorageTex";entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
[:resourceType="readwriteStorageTex";entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:resourceType="sampledTex";entry={"texture":{"multisampled":false,"sampleType":"unfilterable-float"}};awaitLost=false]
|
[:resourceType="sampledTex";entry={"texture":{"multisampled":false,"sampleType":"unfilterable-float"}};awaitLost=false]
|
||||||
|
|
||||||
|
@ -60754,20 +60720,12 @@
|
||||||
[:entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
[:entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"write-only","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"write-only","format":"r32float"}};awaitLost=false]
|
||||||
|
|
||||||
|
@ -61056,20 +61014,12 @@
|
||||||
[:entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
[:entry={"sampler":{"type":"non-filtering"}};awaitLost=true]
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
[:entry={"storageTexture":{"access":"read-only","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=false]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
[:entry={"storageTexture":{"access":"read-write","format":"r32float"}};awaitLost=true]
|
||||||
expected:
|
|
||||||
if os == "linux" and not debug: FAIL
|
|
||||||
|
|
||||||
[:entry={"storageTexture":{"access":"write-only","format":"r32float"}};awaitLost=false]
|
[:entry={"storageTexture":{"access":"write-only","format":"r32float"}};awaitLost=false]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue