mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use existing BindGroupLayout if an equivalent BGL already exists
This commit is contained in:
parent
0dc1514d57
commit
d1c13e8df7
4 changed files with 27 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -6814,6 +6814,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#fc4baa31072f96479f691a8d134eaf4ceb418df3"
|
||||
dependencies = [
|
||||
"arrayvec 0.5.1",
|
||||
"bitflags",
|
||||
|
@ -6841,6 +6842,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#fc4baa31072f96479f691a8d134eaf4ceb418df3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"serde",
|
||||
|
|
|
@ -33,7 +33,3 @@ mio = { git = "https://github.com/servo/mio.git", branch = "servo-mio-0.6.22" }
|
|||
[patch."https://github.com/servo/webrender"]
|
||||
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
|
||||
webrender_api = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
|
||||
|
||||
[patch."https://github.com/gfx-rs/wgpu"]
|
||||
wgpu-core = {path="../wgpu/wgpu-core"}
|
||||
wgpu-types = {path="../wgpu/wgpu-types"}
|
||||
|
|
|
@ -165,6 +165,7 @@ use time::{Duration, Timespec, Tm};
|
|||
use uuid::Uuid;
|
||||
use webgpu::{
|
||||
wgpu::command::{ComputePass, RenderPass},
|
||||
wgt::BindGroupLayoutEntry,
|
||||
WebGPU, WebGPUAdapter, WebGPUBindGroup, WebGPUBindGroupLayout, WebGPUBuffer,
|
||||
WebGPUCommandBuffer, WebGPUCommandEncoder, WebGPUComputePipeline, WebGPUDevice,
|
||||
WebGPUPipelineLayout, WebGPUQueue, WebGPURenderPipeline, WebGPUSampler, WebGPUShaderModule,
|
||||
|
@ -579,6 +580,7 @@ unsafe_no_jsmanaged_fields!(WebGPUContextId);
|
|||
unsafe_no_jsmanaged_fields!(WebGPUCommandBuffer);
|
||||
unsafe_no_jsmanaged_fields!(WebGPUCommandEncoder);
|
||||
unsafe_no_jsmanaged_fields!(WebGPUDevice);
|
||||
unsafe_no_jsmanaged_fields!(BindGroupLayoutEntry);
|
||||
unsafe_no_jsmanaged_fields!(Option<RenderPass>);
|
||||
unsafe_no_jsmanaged_fields!(Option<ComputePass>);
|
||||
unsafe_no_jsmanaged_fields!(GPUBufferState);
|
||||
|
|
|
@ -95,6 +95,8 @@ pub struct GPUDevice {
|
|||
next_scope_id: Cell<u64>,
|
||||
#[ignore_malloc_size_of = "promises are hard"]
|
||||
lost_promise: DomRefCell<Option<Rc<Promise>>>,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
bind_group_layouts: DomRefCell<Vec<(Vec<wgt::BindGroupLayoutEntry>, Dom<GPUBindGroupLayout>)>>,
|
||||
}
|
||||
|
||||
impl GPUDevice {
|
||||
|
@ -119,6 +121,7 @@ impl GPUDevice {
|
|||
scope_stack: DomRefCell::new(Vec::new()),
|
||||
next_scope_id: Cell::new(0),
|
||||
lost_promise: DomRefCell::new(None),
|
||||
bind_group_layouts: DomRefCell::new(Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,6 +365,18 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
warn!("Could not find Error Scope for id {}", s_id);
|
||||
}
|
||||
}
|
||||
// Check for equivalent GPUBindGroupLayout
|
||||
{
|
||||
for (bgl_ent, bgl) in self.bind_group_layouts.borrow().iter() {
|
||||
if *bgl_ent == entries {
|
||||
let layout = DomRoot::from_ref(&**bgl);
|
||||
if let Some(i) = scope_id {
|
||||
self.handle_server_msg(i, Ok(()));
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let bind_group_layout_id = self
|
||||
.global()
|
||||
|
@ -373,14 +388,20 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
.send(WebGPURequest::CreateBindGroupLayout {
|
||||
device_id: self.device.0,
|
||||
bind_group_layout_id,
|
||||
entries,
|
||||
entries: entries.clone(),
|
||||
scope_id,
|
||||
})
|
||||
.expect("Failed to create WebGPU BindGroupLayout");
|
||||
|
||||
let bgl = webgpu::WebGPUBindGroupLayout(bind_group_layout_id);
|
||||
|
||||
GPUBindGroupLayout::new(&self.global(), bgl, true)
|
||||
let layout = GPUBindGroupLayout::new(&self.global(), bgl, true);
|
||||
|
||||
self.bind_group_layouts
|
||||
.borrow_mut()
|
||||
.push((entries, Dom::from_ref(&*layout)));
|
||||
|
||||
layout
|
||||
}
|
||||
|
||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createpipelinelayout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue