/* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ use dom_struct::dom_struct; use webgpu::wgt::Limits; use GPUSupportedLimits_Binding::GPUSupportedLimitsMethods; use super::bindings::codegen::Bindings::WebGPUBinding::GPUSupportedLimits_Binding; use super::bindings::reflector::reflect_dom_object; use super::bindings::root::DomRoot; use crate::dom::bindings::reflector::Reflector; use crate::dom::globalscope::GlobalScope; #[dom_struct] pub struct GPUSupportedLimits { reflector_: Reflector, #[ignore_malloc_size_of = "defined in wgpu-types"] #[no_trace] limits: Limits, } impl GPUSupportedLimits { fn new_inherited(limits: Limits) -> Self { Self { reflector_: Reflector::new(), limits, } } pub fn new(global: &GlobalScope, limits: Limits) -> DomRoot { reflect_dom_object(Box::new(Self::new_inherited(limits)), global) } } impl GPUSupportedLimitsMethods for GPUSupportedLimits { /// fn MaxTextureDimension1D(&self) -> u32 { self.limits.max_texture_dimension_1d } /// fn MaxTextureDimension2D(&self) -> u32 { self.limits.max_texture_dimension_2d } /// fn MaxTextureDimension3D(&self) -> u32 { self.limits.max_texture_dimension_3d } /// fn MaxTextureArrayLayers(&self) -> u32 { self.limits.max_texture_array_layers } /// fn MaxBindGroups(&self) -> u32 { self.limits.max_bind_groups } /// fn MaxBindingsPerBindGroup(&self) -> u32 { self.limits.max_bindings_per_bind_group } /// fn MaxDynamicUniformBuffersPerPipelineLayout(&self) -> u32 { self.limits.max_dynamic_uniform_buffers_per_pipeline_layout } /// fn MaxDynamicStorageBuffersPerPipelineLayout(&self) -> u32 { self.limits.max_dynamic_storage_buffers_per_pipeline_layout } /// fn MaxSampledTexturesPerShaderStage(&self) -> u32 { self.limits.max_sampled_textures_per_shader_stage } /// fn MaxSamplersPerShaderStage(&self) -> u32 { self.limits.max_samplers_per_shader_stage } /// fn MaxStorageBuffersPerShaderStage(&self) -> u32 { self.limits.max_storage_buffers_per_shader_stage } /// fn MaxStorageTexturesPerShaderStage(&self) -> u32 { self.limits.max_storage_textures_per_shader_stage } /// fn MaxUniformBuffersPerShaderStage(&self) -> u32 { self.limits.max_uniform_buffers_per_shader_stage } /// fn MaxUniformBufferBindingSize(&self) -> u64 { self.limits.max_uniform_buffer_binding_size as u64 } /// fn MaxStorageBufferBindingSize(&self) -> u64 { self.limits.max_storage_buffer_binding_size as u64 } /// fn MinUniformBufferOffsetAlignment(&self) -> u32 { self.limits.min_uniform_buffer_offset_alignment } /// fn MinStorageBufferOffsetAlignment(&self) -> u32 { self.limits.min_storage_buffer_offset_alignment } /// fn MaxVertexBuffers(&self) -> u32 { self.limits.max_vertex_buffers } /// fn MaxBufferSize(&self) -> u64 { self.limits.max_buffer_size } /// fn MaxVertexAttributes(&self) -> u32 { self.limits.max_vertex_attributes } /// fn MaxVertexBufferArrayStride(&self) -> u32 { self.limits.max_vertex_buffer_array_stride } /// fn MaxInterStageShaderComponents(&self) -> u32 { self.limits.max_inter_stage_shader_components } /// fn MaxComputeWorkgroupStorageSize(&self) -> u32 { self.limits.max_compute_workgroup_storage_size } /// fn MaxComputeInvocationsPerWorkgroup(&self) -> u32 { self.limits.max_compute_invocations_per_workgroup } /// fn MaxComputeWorkgroupSizeX(&self) -> u32 { self.limits.max_compute_workgroup_size_x } /// fn MaxComputeWorkgroupSizeY(&self) -> u32 { self.limits.max_compute_workgroup_size_y } /// fn MaxComputeWorkgroupSizeZ(&self) -> u32 { self.limits.max_compute_workgroup_size_z } /// fn MaxComputeWorkgroupsPerDimension(&self) -> u32 { self.limits.max_compute_workgroups_per_dimension } }