mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
webgpu: Update wgpu to 0.19 (#31995)
* Update wgpu to 32e70bc163
(0.19)
* Update expect only good
* reexpect
* remove dbg stuff
* Remove all occurrences of dx11_hub
This commit is contained in:
parent
81c4f2ae7a
commit
4af413cd04
28 changed files with 3422 additions and 9526 deletions
|
@ -86,6 +86,21 @@ impl GPUAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUAdapter {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropAdapter(self.adapter.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropAdapter({:?}) ({})",
|
||||
self.adapter.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
impl GPUAdapterMethods for GPUAdapter {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice>
|
||||
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
||||
|
@ -106,69 +121,83 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
}
|
||||
|
||||
let mut desc = wgt::DeviceDescriptor {
|
||||
features,
|
||||
limits: wgt::Limits::default(),
|
||||
required_features: features,
|
||||
required_limits: wgt::Limits::default(),
|
||||
label: None,
|
||||
};
|
||||
if let Some(limits) = &descriptor.requiredLimits {
|
||||
for (limit, value) in (*limits).iter() {
|
||||
let v = u32::try_from(*value).unwrap_or(u32::MAX);
|
||||
match limit.as_ref() {
|
||||
"maxTextureDimension1D" => desc.limits.max_texture_dimension_1d = v,
|
||||
"maxTextureDimension2D" => desc.limits.max_texture_dimension_2d = v,
|
||||
"maxTextureDimension3D" => desc.limits.max_texture_dimension_3d = v,
|
||||
"maxTextureArrayLayers" => desc.limits.max_texture_array_layers = v,
|
||||
"maxBindGroups" => desc.limits.max_bind_groups = v,
|
||||
"maxBindingsPerBindGroup" => desc.limits.max_bindings_per_bind_group = v,
|
||||
"maxTextureDimension1D" => desc.required_limits.max_texture_dimension_1d = v,
|
||||
"maxTextureDimension2D" => desc.required_limits.max_texture_dimension_2d = v,
|
||||
"maxTextureDimension3D" => desc.required_limits.max_texture_dimension_3d = v,
|
||||
"maxTextureArrayLayers" => desc.required_limits.max_texture_array_layers = v,
|
||||
"maxBindGroups" => desc.required_limits.max_bind_groups = v,
|
||||
"maxBindingsPerBindGroup" => {
|
||||
desc.required_limits.max_bindings_per_bind_group = v
|
||||
},
|
||||
"maxDynamicUniformBuffersPerPipelineLayout" => {
|
||||
desc.limits.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
||||
desc.required_limits
|
||||
.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
||||
},
|
||||
"maxDynamicStorageBuffersPerPipelineLayout" => {
|
||||
desc.limits.max_dynamic_storage_buffers_per_pipeline_layout = v
|
||||
desc.required_limits
|
||||
.max_dynamic_storage_buffers_per_pipeline_layout = v
|
||||
},
|
||||
"maxSampledTexturesPerShaderStage" => {
|
||||
desc.limits.max_sampled_textures_per_shader_stage = v
|
||||
desc.required_limits.max_sampled_textures_per_shader_stage = v
|
||||
},
|
||||
"maxSamplersPerShaderStage" => {
|
||||
desc.required_limits.max_samplers_per_shader_stage = v
|
||||
},
|
||||
"maxSamplersPerShaderStage" => desc.limits.max_samplers_per_shader_stage = v,
|
||||
"maxStorageBuffersPerShaderStage" => {
|
||||
desc.limits.max_storage_buffers_per_shader_stage = v
|
||||
desc.required_limits.max_storage_buffers_per_shader_stage = v
|
||||
},
|
||||
"maxStorageTexturesPerShaderStage" => {
|
||||
desc.limits.max_storage_textures_per_shader_stage = v
|
||||
desc.required_limits.max_storage_textures_per_shader_stage = v
|
||||
},
|
||||
"maxUniformBuffersPerShaderStage" => {
|
||||
desc.limits.max_uniform_buffers_per_shader_stage = v
|
||||
desc.required_limits.max_uniform_buffers_per_shader_stage = v
|
||||
},
|
||||
"maxUniformBufferBindingSize" => {
|
||||
desc.limits.max_uniform_buffer_binding_size = v
|
||||
desc.required_limits.max_uniform_buffer_binding_size = v
|
||||
},
|
||||
"maxStorageBufferBindingSize" => {
|
||||
desc.limits.max_storage_buffer_binding_size = v
|
||||
desc.required_limits.max_storage_buffer_binding_size = v
|
||||
},
|
||||
"minUniformBufferOffsetAlignment" => {
|
||||
desc.limits.min_uniform_buffer_offset_alignment = v
|
||||
desc.required_limits.min_uniform_buffer_offset_alignment = v
|
||||
},
|
||||
"minStorageBufferOffsetAlignment" => {
|
||||
desc.limits.min_storage_buffer_offset_alignment = v
|
||||
desc.required_limits.min_storage_buffer_offset_alignment = v
|
||||
},
|
||||
"maxVertexBuffers" => desc.required_limits.max_vertex_buffers = v,
|
||||
"maxBufferSize" => desc.required_limits.max_buffer_size = *value,
|
||||
"maxVertexAttributes" => desc.required_limits.max_vertex_attributes = v,
|
||||
"maxVertexBufferArrayStride" => {
|
||||
desc.required_limits.max_vertex_buffer_array_stride = v
|
||||
},
|
||||
"maxVertexBuffers" => desc.limits.max_vertex_buffers = v,
|
||||
"maxBufferSize" => desc.limits.max_buffer_size = *value,
|
||||
"maxVertexAttributes" => desc.limits.max_vertex_attributes = v,
|
||||
"maxVertexBufferArrayStride" => desc.limits.max_vertex_buffer_array_stride = v,
|
||||
"maxInterStageShaderComponents" => {
|
||||
desc.limits.max_inter_stage_shader_components = v
|
||||
desc.required_limits.max_inter_stage_shader_components = v
|
||||
},
|
||||
"maxComputeWorkgroupStorageSize" => {
|
||||
desc.limits.max_compute_workgroup_storage_size = v
|
||||
desc.required_limits.max_compute_workgroup_storage_size = v
|
||||
},
|
||||
"maxComputeInvocationsPerWorkgroup" => {
|
||||
desc.limits.max_compute_invocations_per_workgroup = v
|
||||
desc.required_limits.max_compute_invocations_per_workgroup = v
|
||||
},
|
||||
"maxComputeWorkgroupSizeX" => {
|
||||
desc.required_limits.max_compute_workgroup_size_x = v
|
||||
},
|
||||
"maxComputeWorkgroupSizeY" => {
|
||||
desc.required_limits.max_compute_workgroup_size_y = v
|
||||
},
|
||||
"maxComputeWorkgroupSizeZ" => {
|
||||
desc.required_limits.max_compute_workgroup_size_z = v
|
||||
},
|
||||
"maxComputeWorkgroupSizeX" => desc.limits.max_compute_workgroup_size_x = v,
|
||||
"maxComputeWorkgroupSizeY" => desc.limits.max_compute_workgroup_size_y = v,
|
||||
"maxComputeWorkgroupSizeZ" => desc.limits.max_compute_workgroup_size_z = v,
|
||||
"maxComputeWorkgroupsPerDimension" => {
|
||||
desc.limits.max_compute_workgroups_per_dimension = v
|
||||
desc.required_limits.max_compute_workgroups_per_dimension = v
|
||||
},
|
||||
_ => {
|
||||
error!("Unknown required limit: {limit} with value {value}");
|
||||
|
@ -251,8 +280,8 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
self.channel.clone(),
|
||||
self,
|
||||
Heap::default(),
|
||||
descriptor.features,
|
||||
descriptor.limits,
|
||||
descriptor.required_features,
|
||||
descriptor.required_limits,
|
||||
device_id,
|
||||
queue_id,
|
||||
descriptor.label.unwrap_or_default(),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUBindGroup, WebGPUDevice};
|
||||
use webgpu::{WebGPU, WebGPUBindGroup, WebGPUDevice, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupMethods;
|
||||
|
@ -16,6 +16,9 @@ use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
|
|||
#[dom_struct]
|
||||
pub struct GPUBindGroup {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
bind_group: WebGPUBindGroup,
|
||||
|
@ -26,6 +29,7 @@ pub struct GPUBindGroup {
|
|||
|
||||
impl GPUBindGroup {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
bind_group: WebGPUBindGroup,
|
||||
device: WebGPUDevice,
|
||||
layout: &GPUBindGroupLayout,
|
||||
|
@ -33,6 +37,7 @@ impl GPUBindGroup {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
bind_group,
|
||||
device,
|
||||
|
@ -42,6 +47,7 @@ impl GPUBindGroup {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
bind_group: WebGPUBindGroup,
|
||||
device: WebGPUDevice,
|
||||
layout: &GPUBindGroupLayout,
|
||||
|
@ -49,7 +55,7 @@ impl GPUBindGroup {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUBindGroup::new_inherited(
|
||||
bind_group, device, layout, label,
|
||||
channel, bind_group, device, layout, label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
|
@ -62,6 +68,21 @@ impl GPUBindGroup {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUBindGroup {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropBindGroup(self.bind_group.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropBindGroup({:?}) ({})",
|
||||
self.bind_group.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
impl GPUBindGroupMethods for GPUBindGroup {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||
fn Label(&self) -> USVString {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::WebGPUBindGroupLayout;
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupLayoutMethods;
|
||||
|
@ -15,15 +15,23 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUBindGroupLayout {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
bind_group_layout: WebGPUBindGroupLayout,
|
||||
}
|
||||
|
||||
impl GPUBindGroupLayout {
|
||||
fn new_inherited(bind_group_layout: WebGPUBindGroupLayout, label: USVString) -> Self {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
bind_group_layout: WebGPUBindGroupLayout,
|
||||
label: USVString,
|
||||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
bind_group_layout,
|
||||
}
|
||||
|
@ -31,11 +39,16 @@ impl GPUBindGroupLayout {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
bind_group_layout: WebGPUBindGroupLayout,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, label)),
|
||||
Box::new(GPUBindGroupLayout::new_inherited(
|
||||
channel,
|
||||
bind_group_layout,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
@ -47,6 +60,20 @@ impl GPUBindGroupLayout {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUBindGroupLayout {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DropBindGroupLayout(self.bind_group_layout.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropBindGroupLayout({:?}) ({})",
|
||||
self.bind_group_layout.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||
fn Label(&self) -> USVString {
|
||||
|
|
|
@ -130,8 +130,18 @@ impl GPUBuffer {
|
|||
|
||||
impl Drop for GPUBuffer {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.Destroy() {
|
||||
error!("GPUBuffer destruction failed with {e:?}!"); // TODO: should we allow panic here?
|
||||
if matches!(self.state(), GPUBufferState::Destroyed) {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropBuffer(self.buffer.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropBuffer({:?}) ({})",
|
||||
self.buffer.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
|
|||
.expect("Failed to create WebGPU SwapChain");
|
||||
|
||||
self.texture
|
||||
.set(Some(&descriptor.device.CreateTexture(&text_desc)));
|
||||
.set(Some(&descriptor.device.CreateTexture(&text_desc).unwrap()));
|
||||
|
||||
self.webrender_image.set(Some(receiver.recv().unwrap()));
|
||||
}
|
||||
|
|
|
@ -74,10 +74,10 @@ impl Drop for GPUCommandBuffer {
|
|||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::FreeCommandBuffer(self.command_buffer.0),
|
||||
WebGPURequest::DropCommandBuffer(self.command_buffer.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send FreeCommandBuffer({:?}) ({})",
|
||||
"Failed to send DropCommandBuffer({:?}) ({})",
|
||||
self.command_buffer.0, e
|
||||
);
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.expect("Failed to send Finish");
|
||||
|
||||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0);
|
||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0.transmute());
|
||||
GPUCommandBuffer::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use std::string::String;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUBindGroupLayout, WebGPUComputePipeline};
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPUComputePipeline, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUComputePipelineMethods;
|
||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
|||
#[dom_struct]
|
||||
pub struct GPUComputePipeline {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
|
@ -30,6 +33,7 @@ pub struct GPUComputePipeline {
|
|||
|
||||
impl GPUComputePipeline {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
|
@ -37,6 +41,7 @@ impl GPUComputePipeline {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
compute_pipeline,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -46,6 +51,7 @@ impl GPUComputePipeline {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
|
@ -53,6 +59,7 @@ impl GPUComputePipeline {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUComputePipeline::new_inherited(
|
||||
channel,
|
||||
compute_pipeline,
|
||||
label,
|
||||
bgls,
|
||||
|
@ -87,8 +94,23 @@ impl GPUComputePipelineMethods for GPUComputePipeline {
|
|||
}
|
||||
Ok(GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.bind_group_layouts[index as usize],
|
||||
USVString::default(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUComputePipeline {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DropComputePipeline(self.compute_pipeline.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropComputePipeline({:?}) ({})",
|
||||
self.compute_pipeline.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,6 +176,10 @@ impl GPUDevice {
|
|||
self.device
|
||||
}
|
||||
|
||||
pub fn channel(&self) -> WebGPU {
|
||||
self.channel.clone()
|
||||
}
|
||||
|
||||
pub fn handle_server_msg(&self, scope: Option<ErrorScopeId>, result: WebGPUOpResult) {
|
||||
let result = match result {
|
||||
WebGPUOpResult::Success => Ok(()),
|
||||
|
@ -542,6 +546,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
bgl,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
|
@ -591,6 +596,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
|
||||
GPUPipelineLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
pipeline_layout,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
bgls,
|
||||
|
@ -651,6 +657,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUBindGroup::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
bind_group,
|
||||
self.device,
|
||||
&descriptor.layout,
|
||||
|
@ -686,6 +693,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let shader_module = webgpu::WebGPUShaderModule(program_id);
|
||||
GPUShaderModule::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
shader_module,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
|
@ -730,6 +738,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
|
||||
GPUComputePipeline::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
compute_pipeline,
|
||||
descriptor.parent.parent.label.clone().unwrap_or_default(),
|
||||
bgls,
|
||||
|
@ -783,7 +792,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
||||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> DomRoot<GPUTexture> {
|
||||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> Fallible<DomRoot<GPUTexture>> {
|
||||
let size = convert_texture_size_to_dict(&descriptor.size);
|
||||
let desc = wgt::TextureUsages::from_bits(descriptor.usage).map(|usg| {
|
||||
wgpu_res::TextureDescriptor {
|
||||
|
@ -814,10 +823,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
let scope_id = self.use_current_scope();
|
||||
if desc.is_none() {
|
||||
self.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from("Invalid GPUTextureUsage")),
|
||||
);
|
||||
return Err(Error::Type(String::from("Invalid GPUTextureUsage")));
|
||||
}
|
||||
self.channel
|
||||
.0
|
||||
|
@ -833,7 +839,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
let texture = webgpu::WebGPUTexture(texture_id);
|
||||
|
||||
GPUTexture::new(
|
||||
Ok(GPUTexture::new(
|
||||
&self.global(),
|
||||
texture,
|
||||
self,
|
||||
|
@ -845,7 +851,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
descriptor.format,
|
||||
descriptor.usage,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
||||
|
@ -890,6 +896,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUSampler::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.device,
|
||||
compare_enable,
|
||||
sampler,
|
||||
|
@ -1173,8 +1180,20 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
}
|
||||
|
||||
impl Drop for GPUDevice {
|
||||
// not sure about this but this is non failable version of destroy
|
||||
fn drop(&mut self) {
|
||||
self.Destroy()
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DestroyDevice(self.device.0)))
|
||||
{
|
||||
warn!("Failed to send DestroyDevice ({:?}) ({})", self.device.0, e);
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropDevice(self.device.0)))
|
||||
{
|
||||
warn!("Failed to send DropDevice ({:?}) ({})", self.device.0, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUBindGroupLayout, WebGPUPipelineLayout};
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPUPipelineLayout, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUPipelineLayoutMethods;
|
||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUPipelineLayout {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
|
@ -24,12 +27,14 @@ pub struct GPUPipelineLayout {
|
|||
|
||||
impl GPUPipelineLayout {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
pipeline_layout,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -38,12 +43,14 @@ impl GPUPipelineLayout {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUPipelineLayout::new_inherited(
|
||||
channel,
|
||||
pipeline_layout,
|
||||
label,
|
||||
bgls,
|
||||
|
@ -74,3 +81,17 @@ impl GPUPipelineLayoutMethods for GPUPipelineLayout {
|
|||
*self.label.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUPipelineLayout {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DropPipelineLayout(self.pipeline_layout.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send DropPipelineLayout ({:?}) ({})",
|
||||
self.pipeline_layout.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle};
|
||||
use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderBundleMethods;
|
||||
|
@ -77,3 +77,18 @@ impl GPURenderBundleMethods for GPURenderBundle {
|
|||
*self.label.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPURenderBundle {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropRenderBundle(self.render_bundle.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send DropRenderBundle ({:?}) ({})",
|
||||
self.render_bundle.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use std::string::String;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline};
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
|
||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
|||
#[dom_struct]
|
||||
pub struct GPURenderPipeline {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
render_pipeline: WebGPURenderPipeline,
|
||||
|
@ -37,6 +40,7 @@ impl GPURenderPipeline {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel: device.channel(),
|
||||
label: DomRefCell::new(label),
|
||||
render_pipeline,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -87,8 +91,23 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
|
|||
}
|
||||
Ok(GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.bind_group_layouts[index as usize],
|
||||
USVString::default(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPURenderPipeline {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DropRenderPipeline(self.render_pipeline.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropRenderPipeline({:?}) ({})",
|
||||
self.render_pipeline.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUDevice, WebGPUSampler};
|
||||
use webgpu::{WebGPU, WebGPUDevice, WebGPURequest, WebGPUSampler};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUSamplerMethods;
|
||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUSampler {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
device: WebGPUDevice,
|
||||
|
@ -25,6 +28,7 @@ pub struct GPUSampler {
|
|||
|
||||
impl GPUSampler {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
device: WebGPUDevice,
|
||||
compare_enable: bool,
|
||||
sampler: WebGPUSampler,
|
||||
|
@ -32,6 +36,7 @@ impl GPUSampler {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
device,
|
||||
sampler,
|
||||
|
@ -41,6 +46,7 @@ impl GPUSampler {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
device: WebGPUDevice,
|
||||
compare_enable: bool,
|
||||
sampler: WebGPUSampler,
|
||||
|
@ -48,6 +54,7 @@ impl GPUSampler {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUSampler::new_inherited(
|
||||
channel,
|
||||
device,
|
||||
compare_enable,
|
||||
sampler,
|
||||
|
@ -75,3 +82,15 @@ impl GPUSamplerMethods for GPUSampler {
|
|||
*self.label.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUSampler {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropSampler(self.sampler.0)))
|
||||
{
|
||||
warn!("Failed to send DropSampler ({:?}) ({})", self.sampler.0, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::WebGPUShaderModule;
|
||||
use webgpu::{WebGPU, WebGPURequest, WebGPUShaderModule};
|
||||
|
||||
use super::bindings::error::Fallible;
|
||||
use super::promise::Promise;
|
||||
|
@ -19,15 +19,19 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUShaderModule {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
shader_module: WebGPUShaderModule,
|
||||
}
|
||||
|
||||
impl GPUShaderModule {
|
||||
fn new_inherited(shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
||||
fn new_inherited(channel: WebGPU, shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
shader_module,
|
||||
}
|
||||
|
@ -35,11 +39,16 @@ impl GPUShaderModule {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
shader_module: WebGPUShaderModule,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUShaderModule::new_inherited(shader_module, label)),
|
||||
Box::new(GPUShaderModule::new_inherited(
|
||||
channel,
|
||||
shader_module,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
@ -67,3 +76,18 @@ impl GPUShaderModuleMethods for GPUShaderModule {
|
|||
todo!("Missing in wgpu: https://github.com/gfx-rs/wgpu/issues/2170")
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUShaderModule {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropShaderModule(self.shader_module.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send DropShaderModule ({:?}) ({})",
|
||||
self.shader_module.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,19 @@ impl GPUTexture {
|
|||
|
||||
impl Drop for GPUTexture {
|
||||
fn drop(&mut self) {
|
||||
self.Destroy()
|
||||
if self.destroyed.get() {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropTexture(self.texture.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DropTexture({:?}) ({})",
|
||||
self.texture.0, e
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +198,7 @@ impl GPUTextureMethods for GPUTexture {
|
|||
|
||||
GPUTextureView::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
texture_view,
|
||||
self,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
|
@ -197,11 +210,13 @@ impl GPUTextureMethods for GPUTexture {
|
|||
if self.destroyed.get() {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DestroyTexture(self.texture.0)))
|
||||
{
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DestroyTexture {
|
||||
device_id: self.device.id().0,
|
||||
texture_id: self.texture.0,
|
||||
},
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
||||
self.texture.0, e
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::WebGPUTextureView;
|
||||
use webgpu::{WebGPU, WebGPURequest, WebGPUTextureView};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods;
|
||||
|
@ -16,6 +16,9 @@ use crate::dom::gputexture::GPUTexture;
|
|||
#[dom_struct]
|
||||
pub struct GPUTextureView {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
texture_view: WebGPUTextureView,
|
||||
|
@ -24,12 +27,14 @@ pub struct GPUTextureView {
|
|||
|
||||
impl GPUTextureView {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
label: USVString,
|
||||
) -> GPUTextureView {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
texture: Dom::from_ref(texture),
|
||||
label: DomRefCell::new(label),
|
||||
texture_view,
|
||||
|
@ -38,12 +43,18 @@ impl GPUTextureView {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
label: USVString,
|
||||
) -> DomRoot<GPUTextureView> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUTextureView::new_inherited(texture_view, texture, label)),
|
||||
Box::new(GPUTextureView::new_inherited(
|
||||
channel,
|
||||
texture_view,
|
||||
texture,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
@ -66,3 +77,18 @@ impl GPUTextureViewMethods for GPUTextureView {
|
|||
*self.label.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUTextureView {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DropTextureView(self.texture_view.0)))
|
||||
{
|
||||
warn!(
|
||||
"Failed to send DropTextureView ({:?}) ({})",
|
||||
self.texture_view.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use webgpu::wgpu::id::markers::{
|
||||
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
|
||||
PipelineLayout, RenderBundle, RenderPipeline, Sampler, ShaderModule, Texture, TextureView,
|
||||
};
|
||||
use webgpu::wgpu::id::{
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
|
||||
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
|
||||
|
@ -11,47 +15,75 @@ use webgpu::wgpu::id::{
|
|||
use webgpu::wgpu::identity::IdentityManager;
|
||||
use webgpu::wgt::Backend;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct IdentityHub {
|
||||
adapters: IdentityManager,
|
||||
devices: IdentityManager,
|
||||
buffers: IdentityManager,
|
||||
bind_groups: IdentityManager,
|
||||
bind_group_layouts: IdentityManager,
|
||||
compute_pipelines: IdentityManager,
|
||||
pipeline_layouts: IdentityManager,
|
||||
shader_modules: IdentityManager,
|
||||
command_encoders: IdentityManager,
|
||||
textures: IdentityManager,
|
||||
texture_views: IdentityManager,
|
||||
samplers: IdentityManager,
|
||||
render_pipelines: IdentityManager,
|
||||
render_bundles: IdentityManager,
|
||||
adapters: IdentityManager<Adapter>,
|
||||
devices: IdentityManager<Device>,
|
||||
buffers: IdentityManager<Buffer>,
|
||||
bind_groups: IdentityManager<BindGroup>,
|
||||
bind_group_layouts: IdentityManager<BindGroupLayout>,
|
||||
compute_pipelines: IdentityManager<ComputePipeline>,
|
||||
pipeline_layouts: IdentityManager<PipelineLayout>,
|
||||
shader_modules: IdentityManager<ShaderModule>,
|
||||
command_encoders: IdentityManager<CommandEncoder>,
|
||||
textures: IdentityManager<Texture>,
|
||||
texture_views: IdentityManager<TextureView>,
|
||||
samplers: IdentityManager<Sampler>,
|
||||
render_pipelines: IdentityManager<RenderPipeline>,
|
||||
render_bundles: IdentityManager<RenderBundle>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
impl IdentityHub {
|
||||
fn new() -> Self {
|
||||
IdentityHub {
|
||||
adapters: IdentityManager::new(),
|
||||
devices: IdentityManager::new(),
|
||||
buffers: IdentityManager::new(),
|
||||
bind_groups: IdentityManager::new(),
|
||||
bind_group_layouts: IdentityManager::new(),
|
||||
compute_pipelines: IdentityManager::new(),
|
||||
pipeline_layouts: IdentityManager::new(),
|
||||
shader_modules: IdentityManager::new(),
|
||||
command_encoders: IdentityManager::new(),
|
||||
textures: IdentityManager::new(),
|
||||
texture_views: IdentityManager::new(),
|
||||
samplers: IdentityManager::new(),
|
||||
render_pipelines: IdentityManager::new(),
|
||||
render_bundles: IdentityManager::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Identities {
|
||||
_surface: IdentityManager,
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
vk_hub: IdentityHub,
|
||||
#[cfg(target_os = "windows")]
|
||||
dx12_hub: IdentityHub,
|
||||
#[cfg(target_os = "windows")]
|
||||
dx11_hub: IdentityHub,
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
metal_hub: IdentityHub,
|
||||
dummy_hub: IdentityHub,
|
||||
}
|
||||
|
||||
impl Identities {
|
||||
pub fn new() -> Self {
|
||||
Identities {
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
vk_hub: IdentityHub::new(),
|
||||
#[cfg(target_os = "windows")]
|
||||
dx12_hub: IdentityHub::new(),
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
metal_hub: IdentityHub::new(),
|
||||
dummy_hub: IdentityHub::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn select(&mut self, backend: Backend) -> &mut IdentityHub {
|
||||
match backend {
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
Backend::Vulkan => &mut self.vk_hub,
|
||||
#[cfg(target_os = "windows")]
|
||||
Backend::Dx12 => &mut self.dx12_hub,
|
||||
#[cfg(target_os = "windows")]
|
||||
Backend::Dx11 => &mut self.dx11_hub,
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
Backend::Metal => &mut self.metal_hub,
|
||||
_ => &mut self.dummy_hub,
|
||||
|
@ -64,8 +96,6 @@ impl Identities {
|
|||
(&mut self.vk_hub, Backend::Vulkan),
|
||||
#[cfg(target_os = "windows")]
|
||||
(&mut self.dx12_hub, Backend::Dx12),
|
||||
#[cfg(target_os = "windows")]
|
||||
(&mut self.dx11_hub, Backend::Dx11),
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
(&mut self.metal_hub, Backend::Metal),
|
||||
(&mut self.dummy_hub, Backend::Empty),
|
||||
|
@ -73,7 +103,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_device_id(&mut self, backend: Backend) -> DeviceId {
|
||||
self.select(backend).devices.alloc(backend)
|
||||
self.select(backend).devices.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_device_id(&mut self, id: DeviceId) {
|
||||
|
@ -83,7 +113,7 @@ impl Identities {
|
|||
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
|
||||
let mut ids = SmallVec::new();
|
||||
for hubs in self.hubs() {
|
||||
ids.push(hubs.0.adapters.alloc(hubs.1));
|
||||
ids.push(hubs.0.adapters.process(hubs.1));
|
||||
}
|
||||
ids
|
||||
}
|
||||
|
@ -93,7 +123,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
|
||||
self.select(backend).buffers.alloc(backend)
|
||||
self.select(backend).buffers.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_buffer_id(&mut self, id: BufferId) {
|
||||
|
@ -101,7 +131,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_bind_group_id(&mut self, backend: Backend) -> BindGroupId {
|
||||
self.select(backend).bind_groups.alloc(backend)
|
||||
self.select(backend).bind_groups.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_bind_group_id(&mut self, id: BindGroupId) {
|
||||
|
@ -109,7 +139,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_bind_group_layout_id(&mut self, backend: Backend) -> BindGroupLayoutId {
|
||||
self.select(backend).bind_group_layouts.alloc(backend)
|
||||
self.select(backend).bind_group_layouts.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_bind_group_layout_id(&mut self, id: BindGroupLayoutId) {
|
||||
|
@ -117,7 +147,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_compute_pipeline_id(&mut self, backend: Backend) -> ComputePipelineId {
|
||||
self.select(backend).compute_pipelines.alloc(backend)
|
||||
self.select(backend).compute_pipelines.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_compute_pipeline_id(&mut self, id: ComputePipelineId) {
|
||||
|
@ -125,7 +155,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_pipeline_layout_id(&mut self, backend: Backend) -> PipelineLayoutId {
|
||||
self.select(backend).pipeline_layouts.alloc(backend)
|
||||
self.select(backend).pipeline_layouts.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_pipeline_layout_id(&mut self, id: PipelineLayoutId) {
|
||||
|
@ -133,7 +163,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_shader_module_id(&mut self, backend: Backend) -> ShaderModuleId {
|
||||
self.select(backend).shader_modules.alloc(backend)
|
||||
self.select(backend).shader_modules.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_shader_module_id(&mut self, id: ShaderModuleId) {
|
||||
|
@ -141,7 +171,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_command_encoder_id(&mut self, backend: Backend) -> CommandEncoderId {
|
||||
self.select(backend).command_encoders.alloc(backend)
|
||||
self.select(backend).command_encoders.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_command_buffer_id(&mut self, id: CommandEncoderId) {
|
||||
|
@ -149,7 +179,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_sampler_id(&mut self, backend: Backend) -> SamplerId {
|
||||
self.select(backend).samplers.alloc(backend)
|
||||
self.select(backend).samplers.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_sampler_id(&mut self, id: SamplerId) {
|
||||
|
@ -157,7 +187,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_render_pipeline_id(&mut self, backend: Backend) -> RenderPipelineId {
|
||||
self.select(backend).render_pipelines.alloc(backend)
|
||||
self.select(backend).render_pipelines.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_render_pipeline_id(&mut self, id: RenderPipelineId) {
|
||||
|
@ -165,7 +195,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_texture_id(&mut self, backend: Backend) -> TextureId {
|
||||
self.select(backend).textures.alloc(backend)
|
||||
self.select(backend).textures.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_texture_id(&mut self, id: TextureId) {
|
||||
|
@ -173,7 +203,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_texture_view_id(&mut self, backend: Backend) -> TextureViewId {
|
||||
self.select(backend).texture_views.alloc(backend)
|
||||
self.select(backend).texture_views.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_texture_view_id(&mut self, id: TextureViewId) {
|
||||
|
@ -181,7 +211,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
pub fn create_render_bundle_id(&mut self, backend: Backend) -> RenderBundleId {
|
||||
self.select(backend).render_bundles.alloc(backend)
|
||||
self.select(backend).render_bundles.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {
|
||||
|
|
|
@ -242,7 +242,7 @@ impl ServiceWorkerGlobalScope {
|
|||
runtime,
|
||||
from_devtools_receiver,
|
||||
closing,
|
||||
Arc::new(Mutex::new(Identities::default())),
|
||||
Arc::new(Mutex::new(Identities::new())),
|
||||
),
|
||||
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
||||
own_sender,
|
||||
|
|
|
@ -129,7 +129,7 @@ interface GPUDevice: EventTarget {
|
|||
|
||||
[NewObject, Throws]
|
||||
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
||||
[NewObject]
|
||||
[NewObject, Throws]
|
||||
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
||||
[NewObject]
|
||||
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
||||
|
|
|
@ -1430,7 +1430,7 @@ impl ScriptThread {
|
|||
|
||||
node_ids: Default::default(),
|
||||
is_user_interacting: Cell::new(false),
|
||||
gpu_id_hub: Arc::new(Mutex::new(Identities::default())),
|
||||
gpu_id_hub: Arc::new(Mutex::new(Identities::new())),
|
||||
webgpu_port: RefCell::new(None),
|
||||
inherited_secure_context: state.inherited_secure_context,
|
||||
layouts: Default::default(),
|
||||
|
@ -2122,7 +2122,10 @@ impl ScriptThread {
|
|||
WebGPUMsg::FreeBindGroupLayout(id) => {
|
||||
self.gpu_id_hub.lock().kill_bind_group_layout_id(id)
|
||||
},
|
||||
WebGPUMsg::FreeCommandBuffer(id) => self.gpu_id_hub.lock().kill_command_buffer_id(id),
|
||||
WebGPUMsg::FreeCommandBuffer(id) => self
|
||||
.gpu_id_hub
|
||||
.lock()
|
||||
.kill_command_buffer_id(id.transmute()),
|
||||
WebGPUMsg::FreeSampler(id) => self.gpu_id_hub.lock().kill_sampler_id(id),
|
||||
WebGPUMsg::FreeShaderModule(id) => self.gpu_id_hub.lock().kill_shader_module_id(id),
|
||||
WebGPUMsg::FreeRenderBundle(id) => self.gpu_id_hub.lock().kill_render_bundle_id(id),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue