diff options
author | Samson <16504129+sagudev@users.noreply.github.com> | 2024-09-05 21:48:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 19:48:16 +0000 |
commit | ebed9218f2907767ba3c9dd9f27f30a6a6e9f225 (patch) | |
tree | 72e9817a359a1606415555514db9f1013aa5931f /components/script/dom/gpuconvert.rs | |
parent | 312cf0df08e8a5044d286734bfdf3d6f0caff8dd (diff) | |
download | servo-ebed9218f2907767ba3c9dd9f27f30a6a6e9f225.tar.gz servo-ebed9218f2907767ba3c9dd9f27f30a6a6e9f225.zip |
webgpu: Move actual Create* implementations from `GPUDevice` to Self (#33320)
* Move actual Create* implementations from `GPUDevice` to Self
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* move Create*Pipeline to Self::create
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* `parse_render_pipeline` outside`GPURenderPipeline::create`
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'components/script/dom/gpuconvert.rs')
-rw-r--r-- | components/script/dom/gpuconvert.rs | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/components/script/dom/gpuconvert.rs b/components/script/dom/gpuconvert.rs index acba9634787..1eb7c9fb977 100644 --- a/components/script/dom/gpuconvert.rs +++ b/components/script/dom/gpuconvert.rs @@ -5,20 +5,23 @@ use std::borrow::Cow; use std::num::NonZeroU64; +use webgpu::wgc::binding_model::{BindGroupEntry, BindingResource, BufferBinding}; use webgpu::wgc::command as wgpu_com; use webgpu::wgc::pipeline::ProgrammableStageDescriptor; use webgpu::wgt::{self, AstcBlock, AstcChannel}; -use super::bindings::codegen::Bindings::WebGPUBinding::GPUProgrammableStage; +use super::bindings::codegen::Bindings::WebGPUBinding::{ + GPUProgrammableStage, GPUTextureDimension, +}; use super::bindings::error::Error; use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ - GPUAddressMode, GPUBindGroupLayoutEntry, GPUBlendComponent, GPUBlendFactor, GPUBlendOperation, - GPUBufferBindingType, GPUColor, GPUCompareFunction, GPUCullMode, GPUExtent3D, GPUFilterMode, - GPUFrontFace, GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, GPUIndexFormat, - GPULoadOp, GPUObjectDescriptorBase, GPUOrigin3D, GPUPrimitiveState, GPUPrimitiveTopology, - GPUSamplerBindingType, GPUStencilOperation, GPUStorageTextureAccess, GPUStoreOp, - GPUTextureAspect, GPUTextureFormat, GPUTextureSampleType, GPUTextureViewDimension, - GPUVertexFormat, + GPUAddressMode, GPUBindGroupEntry, GPUBindGroupLayoutEntry, GPUBindingResource, + GPUBlendComponent, GPUBlendFactor, GPUBlendOperation, GPUBufferBindingType, GPUColor, + GPUCompareFunction, GPUCullMode, GPUExtent3D, GPUFilterMode, GPUFrontFace, GPUImageCopyBuffer, + GPUImageCopyTexture, GPUImageDataLayout, GPUIndexFormat, GPULoadOp, GPUObjectDescriptorBase, + GPUOrigin3D, GPUPrimitiveState, GPUPrimitiveTopology, GPUSamplerBindingType, + GPUStencilOperation, GPUStorageTextureAccess, GPUStoreOp, GPUTextureAspect, GPUTextureFormat, + GPUTextureSampleType, GPUTextureViewDimension, GPUVertexFormat, }; use crate::dom::bindings::error::Fallible; use crate::dom::types::GPUDevice; @@ -624,3 +627,32 @@ impl<'a> From<&GPUProgrammableStage> for ProgrammableStageDescriptor<'a> { } } } + +impl From<&GPUBindGroupEntry> for BindGroupEntry<'_> { + fn from(entry: &GPUBindGroupEntry) -> Self { + Self { + binding: entry.binding, + resource: match entry.resource { + GPUBindingResource::GPUSampler(ref s) => BindingResource::Sampler(s.id().0), + GPUBindingResource::GPUTextureView(ref t) => BindingResource::TextureView(t.id().0), + GPUBindingResource::GPUBufferBinding(ref b) => { + BindingResource::Buffer(BufferBinding { + buffer_id: b.buffer.id().0, + offset: b.offset, + size: b.size.and_then(wgt::BufferSize::new), + }) + }, + }, + } + } +} + +impl From<GPUTextureDimension> for wgt::TextureDimension { + fn from(dimension: GPUTextureDimension) -> Self { + match dimension { + GPUTextureDimension::_1d => wgt::TextureDimension::D1, + GPUTextureDimension::_2d => wgt::TextureDimension::D2, + GPUTextureDimension::_3d => wgt::TextureDimension::D3, + } + } +} |