Skip to content

Commit

Permalink
webgpu: Refactor webgpu crate (#32255)
Browse files Browse the repository at this point in the history
* wgpu(_core) -> wgc

* Refactor webgpu crate

split lib.rs into multiple modules
  • Loading branch information
sagudev committed May 8, 2024
1 parent c4f8599 commit 168d43f
Show file tree
Hide file tree
Showing 21 changed files with 1,475 additions and 1,413 deletions.
3 changes: 1 addition & 2 deletions components/script/dom/globalscope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ use script_traits::{
};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use uuid::Uuid;
use webgpu::identity::WebGPUOpResult;
use webgpu::{ErrorScopeId, WebGPUDevice};
use webgpu::{ErrorScopeId, WebGPUDevice, WebGPUOpResult};

use super::bindings::trace::HashMapTracedValues;
use crate::dom::bindings::cell::{DomRefCell, RefMut};
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ipc_channel::router::ROUTER;
use js::jsapi::Heap;
use script_traits::ScriptMsg;
use webgpu::wgt::PowerPreference;
use webgpu::{wgpu, WebGPUResponse, WebGPUResponseResult};
use webgpu::{wgc, WebGPUResponse, WebGPUResponseResult};

use super::bindings::codegen::Bindings::WebGPUBinding::GPUTextureFormat;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
Expand Down Expand Up @@ -117,7 +117,7 @@ impl GPUMethods for GPU {
if script_to_constellation_chan
.send(ScriptMsg::RequestAdapter(
sender,
wgpu::instance::RequestAdapterOptions {
wgc::instance::RequestAdapterOptions {
power_preference,
compatible_surface: None,
force_fallback_adapter: options.forceFallbackAdapter,
Expand Down
7 changes: 4 additions & 3 deletions components/script/dom/gpubuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ use std::sync::{Arc, Mutex};
use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSharedMemory;
use js::typedarray::{ArrayBuffer, ArrayBufferU8};
use webgpu::identity::WebGPUOpResult;
use webgpu::wgpu::device::HostMap;
use webgpu::{WebGPU, WebGPUBuffer, WebGPURequest, WebGPUResponse, WebGPUResponseResult};
use webgpu::wgc::device::HostMap;
use webgpu::{
WebGPU, WebGPUBuffer, WebGPUOpResult, WebGPURequest, WebGPUResponse, WebGPUResponseResult,
};

use super::bindings::buffer_source::{create_new_external_array_buffer, HeapBufferSource};
use crate::dom::bindings::cell::DomRefCell;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpucanvascontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dom_struct::dom_struct;
use euclid::default::Size2D;
use ipc_channel::ipc;
use script_layout_interface::HTMLCanvasDataSource;
use webgpu::wgpu::id;
use webgpu::wgc::id;
use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, PRESENTATION_BUFFER_COUNT};
use webrender_api::{
units, ExternalImageData, ExternalImageId, ExternalImageType, ImageData, ImageDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpucommandencoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::cell::Cell;
use std::collections::HashSet;

use dom_struct::dom_struct;
use webgpu::wgpu::command as wgpu_com;
use webgpu::wgc::command as wgpu_com;
use webgpu::{self, wgt, WebGPU, WebGPURequest};

use crate::dom::bindings::cell::DomRefCell;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpucomputepassencoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use dom_struct::dom_struct;
use webgpu::wgpu::command::{compute_commands as wgpu_comp, ComputePass};
use webgpu::wgc::command::{compute_commands as wgpu_comp, ComputePass};
use webgpu::{WebGPU, WebGPURequest};

use super::bindings::error::Fallible;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpuconvert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use std::borrow::Cow;

use webgpu::wgpu::command as wgpu_com;
use webgpu::wgc::command as wgpu_com;
use webgpu::wgt;

use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
Expand Down
7 changes: 3 additions & 4 deletions components/script/dom/gpudevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use std::sync::{Arc, Mutex};

use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject};
use webgpu::identity::WebGPUOpResult;
use webgpu::wgpu::id::{BindGroupLayoutId, PipelineLayoutId};
use webgpu::wgpu::{
use webgpu::wgc::id::{BindGroupLayoutId, PipelineLayoutId};
use webgpu::wgc::{
binding_model as wgpu_bind, command as wgpu_com, pipeline as wgpu_pipe, resource as wgpu_res,
};
use webgpu::{self, wgt, ErrorScopeId, WebGPU, WebGPURequest};
use webgpu::{self, wgt, ErrorScopeId, WebGPU, WebGPUOpResult, WebGPURequest};

use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode;
use super::bindings::error::Fallible;
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/gpuqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::rc::Rc;

use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSharedMemory;
use webgpu::identity::WebGPUOpResult;
use webgpu::{wgt, WebGPU, WebGPUQueue, WebGPURequest, WebGPUResponse};
use webgpu::{wgt, WebGPU, WebGPUOpResult, WebGPUQueue, WebGPURequest, WebGPUResponse};

use super::bindings::codegen::Bindings::WebGPUBinding::{GPUImageCopyTexture, GPUImageDataLayout};
use super::gpu::{response_async, AsyncWGPUListener};
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpurenderbundleencoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use dom_struct::dom_struct;
use webgpu::wgpu::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder};
use webgpu::wgc::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder};
use webgpu::{wgt, WebGPU, WebGPURenderBundle, WebGPURequest};

use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gpurenderpassencoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use dom_struct::dom_struct;
use webgpu::wgpu::command::{render_commands as wgpu_render, RenderPass};
use webgpu::wgc::command::{render_commands as wgpu_render, RenderPass};
use webgpu::{wgt, WebGPU, WebGPURequest};

use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat;
Expand Down
5 changes: 2 additions & 3 deletions components/script/dom/gputexture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use std::cell::Cell;
use std::string::String;

use dom_struct::dom_struct;
use webgpu::identity::WebGPUOpResult;
use webgpu::wgpu::resource;
use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
use webgpu::wgc::resource;
use webgpu::{wgt, WebGPU, WebGPUOpResult, WebGPURequest, WebGPUTexture, WebGPUTextureView};

use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/identityhub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use smallvec::SmallVec;
use webgpu::wgpu::id::markers::{
use webgpu::wgc::id::markers::{
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
PipelineLayout, RenderBundle, RenderPipeline, Sampler, ShaderModule, Texture, TextureView,
};
use webgpu::wgpu::id::{
use webgpu::wgc::id::{
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
TextureId, TextureViewId,
};
use webgpu::wgpu::identity::IdentityManager;
use webgpu::wgc::identity::IdentityManager;
use webgpu::wgt::Backend;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion components/script/script_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use style::dom::OpaqueNode;
use style::thread_state::{self, ThreadState};
use time::precise_time_ns;
use url::Position;
use webgpu::identity::WebGPUMsg;
use webgpu::WebGPUMsg;
use webrender_api::units::LayoutPixel;
use webrender_api::DocumentId;

Expand Down
2 changes: 1 addition & 1 deletion components/shared/script/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use servo_atoms::Atom;
use servo_url::{ImmutableOrigin, ServoUrl};
use style_traits::{CSSPixel, SpeculativePainter};
use webgpu::identity::WebGPUMsg;
use webgpu::WebGPUMsg;
use webrender_api::units::{DeviceIntSize, DevicePixel, DevicePoint, LayoutPixel, LayoutPoint};
use webrender_api::{
BuiltDisplayList, BuiltDisplayListDescriptor, DocumentId, ExternalImageData, ExternalScrollId,
Expand Down
6 changes: 3 additions & 3 deletions components/shared/script/script_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use serde::{Deserialize, Serialize};
use servo_url::{ImmutableOrigin, ServoUrl};
use smallvec::SmallVec;
use style_traits::CSSPixel;
use webgpu::{wgpu, WebGPU, WebGPUResponseResult};
use webgpu::{wgc, WebGPU, WebGPUResponseResult};
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};

use crate::{
Expand Down Expand Up @@ -258,8 +258,8 @@ pub enum ScriptMsg {
/// Create a WebGPU Adapter instance
RequestAdapter(
IpcSender<Option<WebGPUResponseResult>>,
wgpu::instance::RequestAdapterOptions,
SmallVec<[wgpu::id::AdapterId; 4]>,
wgc::instance::RequestAdapterOptions,
SmallVec<[wgc::id::AdapterId; 4]>,
),
/// Get WebGPU channel
GetWebGPUChan(IpcSender<Option<WebGPU>>),
Expand Down

0 comments on commit 168d43f

Please sign in to comment.