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]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
source = "git+https://github.com/gfx-rs/wgpu#fc4baa31072f96479f691a8d134eaf4ceb418df3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.5.1",
|
"arrayvec 0.5.1",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -6841,6 +6842,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
source = "git+https://github.com/gfx-rs/wgpu#fc4baa31072f96479f691a8d134eaf4ceb418df3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"serde",
|
"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"]
|
[patch."https://github.com/servo/webrender"]
|
||||||
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
|
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
|
||||||
webrender_api = { 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 uuid::Uuid;
|
||||||
use webgpu::{
|
use webgpu::{
|
||||||
wgpu::command::{ComputePass, RenderPass},
|
wgpu::command::{ComputePass, RenderPass},
|
||||||
|
wgt::BindGroupLayoutEntry,
|
||||||
WebGPU, WebGPUAdapter, WebGPUBindGroup, WebGPUBindGroupLayout, WebGPUBuffer,
|
WebGPU, WebGPUAdapter, WebGPUBindGroup, WebGPUBindGroupLayout, WebGPUBuffer,
|
||||||
WebGPUCommandBuffer, WebGPUCommandEncoder, WebGPUComputePipeline, WebGPUDevice,
|
WebGPUCommandBuffer, WebGPUCommandEncoder, WebGPUComputePipeline, WebGPUDevice,
|
||||||
WebGPUPipelineLayout, WebGPUQueue, WebGPURenderPipeline, WebGPUSampler, WebGPUShaderModule,
|
WebGPUPipelineLayout, WebGPUQueue, WebGPURenderPipeline, WebGPUSampler, WebGPUShaderModule,
|
||||||
|
@ -579,6 +580,7 @@ unsafe_no_jsmanaged_fields!(WebGPUContextId);
|
||||||
unsafe_no_jsmanaged_fields!(WebGPUCommandBuffer);
|
unsafe_no_jsmanaged_fields!(WebGPUCommandBuffer);
|
||||||
unsafe_no_jsmanaged_fields!(WebGPUCommandEncoder);
|
unsafe_no_jsmanaged_fields!(WebGPUCommandEncoder);
|
||||||
unsafe_no_jsmanaged_fields!(WebGPUDevice);
|
unsafe_no_jsmanaged_fields!(WebGPUDevice);
|
||||||
|
unsafe_no_jsmanaged_fields!(BindGroupLayoutEntry);
|
||||||
unsafe_no_jsmanaged_fields!(Option<RenderPass>);
|
unsafe_no_jsmanaged_fields!(Option<RenderPass>);
|
||||||
unsafe_no_jsmanaged_fields!(Option<ComputePass>);
|
unsafe_no_jsmanaged_fields!(Option<ComputePass>);
|
||||||
unsafe_no_jsmanaged_fields!(GPUBufferState);
|
unsafe_no_jsmanaged_fields!(GPUBufferState);
|
||||||
|
|
|
@ -95,6 +95,8 @@ pub struct GPUDevice {
|
||||||
next_scope_id: Cell<u64>,
|
next_scope_id: Cell<u64>,
|
||||||
#[ignore_malloc_size_of = "promises are hard"]
|
#[ignore_malloc_size_of = "promises are hard"]
|
||||||
lost_promise: DomRefCell<Option<Rc<Promise>>>,
|
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 {
|
impl GPUDevice {
|
||||||
|
@ -119,6 +121,7 @@ impl GPUDevice {
|
||||||
scope_stack: DomRefCell::new(Vec::new()),
|
scope_stack: DomRefCell::new(Vec::new()),
|
||||||
next_scope_id: Cell::new(0),
|
next_scope_id: Cell::new(0),
|
||||||
lost_promise: DomRefCell::new(None),
|
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);
|
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
|
let bind_group_layout_id = self
|
||||||
.global()
|
.global()
|
||||||
|
@ -373,14 +388,20 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
.send(WebGPURequest::CreateBindGroupLayout {
|
.send(WebGPURequest::CreateBindGroupLayout {
|
||||||
device_id: self.device.0,
|
device_id: self.device.0,
|
||||||
bind_group_layout_id,
|
bind_group_layout_id,
|
||||||
entries,
|
entries: entries.clone(),
|
||||||
scope_id,
|
scope_id,
|
||||||
})
|
})
|
||||||
.expect("Failed to create WebGPU BindGroupLayout");
|
.expect("Failed to create WebGPU BindGroupLayout");
|
||||||
|
|
||||||
let bgl = webgpu::WebGPUBindGroupLayout(bind_group_layout_id);
|
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
|
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createpipelinelayout
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue