Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added WebIDL bindings for `GPUQueue`. Implemented the `submit` function of `GPUQueue` and `defaultQueue` function of `GPUDevice`.
- Loading branch information
Zakor
authored and
Istvan Miklos
committed
Feb 13, 2020
1 parent
0790c85
commit a3c6810
Showing
11 changed files
with
181 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* 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 crate::dom::bindings::cell::DomRefCell; | ||
use crate::dom::bindings::codegen::Bindings::GPUQueueBinding::{self, GPUQueueMethods}; | ||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; | ||
use crate::dom::bindings::root::DomRoot; | ||
use crate::dom::bindings::str::DOMString; | ||
use crate::dom::globalscope::GlobalScope; | ||
use crate::dom::gpubuffer::GPUBufferState; | ||
use crate::dom::gpucommandbuffer::GPUCommandBuffer; | ||
use dom_struct::dom_struct; | ||
use webgpu::{WebGPU, WebGPUQueue, WebGPURequest}; | ||
|
||
#[dom_struct] | ||
pub struct GPUQueue { | ||
reflector_: Reflector, | ||
#[ignore_malloc_size_of = "defined in webgpu"] | ||
channel: WebGPU, | ||
label: DomRefCell<Option<DOMString>>, | ||
queue: WebGPUQueue, | ||
} | ||
|
||
impl GPUQueue { | ||
fn new_inherited(channel: WebGPU, queue: WebGPUQueue) -> GPUQueue { | ||
GPUQueue { | ||
channel, | ||
reflector_: Reflector::new(), | ||
label: DomRefCell::new(None), | ||
queue, | ||
} | ||
} | ||
|
||
pub fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<GPUQueue> { | ||
reflect_dom_object( | ||
Box::new(GPUQueue::new_inherited(channel, queue)), | ||
global, | ||
GPUQueueBinding::Wrap, | ||
) | ||
} | ||
} | ||
|
||
impl GPUQueueMethods for GPUQueue { | ||
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label | ||
fn GetLabel(&self) -> Option<DOMString> { | ||
self.label.borrow().clone() | ||
} | ||
|
||
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label | ||
fn SetLabel(&self, value: Option<DOMString>) { | ||
*self.label.borrow_mut() = value; | ||
} | ||
|
||
/// https://gpuweb.github.io/gpuweb/#dom-gpuqueue-submit | ||
fn Submit(&self, command_buffers: Vec<DomRoot<GPUCommandBuffer>>) { | ||
let valid = command_buffers.iter().all(|cb| { | ||
cb.buffers().iter().all(|b| match *b.state() { | ||
GPUBufferState::Unmapped => true, | ||
_ => false, | ||
}) | ||
}); | ||
if !valid { | ||
// TODO: Generate error to the ErrorScope | ||
return; | ||
} | ||
let buffer_ids = command_buffers.iter().map(|cb| cb.id().0).collect(); | ||
self.channel | ||
.0 | ||
.send(WebGPURequest::Submit(self.queue.0, buffer_ids)) | ||
.unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* 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/. */ | ||
|
||
// https://gpuweb.github.io/gpuweb/#gpuqueue | ||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] | ||
interface GPUQueue { | ||
void submit(sequence<GPUCommandBuffer> commandBuffers); | ||
|
||
// GPUFence createFence(optional GPUFenceDescriptor descriptor = {}); | ||
// void signal(GPUFence fence, unsigned long long signalValue); | ||
|
||
// void copyImageBitmapToTexture( | ||
// GPUImageBitmapCopyView source, | ||
// GPUTextureCopyView destination, | ||
// GPUExtent3D copySize); | ||
}; | ||
GPUQueue includes GPUObjectBase; |
Oops, something went wrong.