mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update wgpu-core and wgpu-types
This commit is contained in:
parent
00b3f785c4
commit
48ef306bd3
13 changed files with 244 additions and 366 deletions
|
@ -3,8 +3,10 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewDescriptor;
|
||||
use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::GPUTextureFormat;
|
||||
use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::{
|
||||
GPUTextureViewDimension, GPUTextureViewMethods,
|
||||
};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
|
@ -12,34 +14,8 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::dom::gputexture::GPUTexture;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use webgpu::WebGPUTextureView;
|
||||
|
||||
#[derive(MallocSizeOf, JSTraceable)]
|
||||
pub struct TextureSubresource {
|
||||
pub texture: DomRoot<GPUTexture>,
|
||||
pub mipmap_level: u32,
|
||||
pub array_layer: u32,
|
||||
}
|
||||
|
||||
impl PartialEq for TextureSubresource {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.texture.id().0 == other.texture.id().0 &&
|
||||
self.mipmap_level == other.mipmap_level &&
|
||||
self.array_layer == other.array_layer
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for TextureSubresource {}
|
||||
|
||||
impl Hash for TextureSubresource {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.texture.id().0.hash(state);
|
||||
self.mipmap_level.hash(state);
|
||||
self.array_layer.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
pub struct GPUTextureView {
|
||||
reflector_: Reflector,
|
||||
|
@ -47,8 +23,8 @@ pub struct GPUTextureView {
|
|||
texture_view: WebGPUTextureView,
|
||||
texture: Dom<GPUTexture>,
|
||||
valid: Cell<bool>,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
descriptor: GPUTextureViewDescriptor,
|
||||
dimension: GPUTextureViewDimension,
|
||||
format: GPUTextureFormat,
|
||||
}
|
||||
|
||||
impl GPUTextureView {
|
||||
|
@ -56,7 +32,8 @@ impl GPUTextureView {
|
|||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
valid: bool,
|
||||
descriptor: GPUTextureViewDescriptor,
|
||||
dimension: GPUTextureViewDimension,
|
||||
format: GPUTextureFormat,
|
||||
) -> GPUTextureView {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
|
@ -64,7 +41,8 @@ impl GPUTextureView {
|
|||
label: DomRefCell::new(None),
|
||||
texture_view,
|
||||
valid: Cell::new(valid),
|
||||
descriptor,
|
||||
dimension,
|
||||
format,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,14 +51,16 @@ impl GPUTextureView {
|
|||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
valid: bool,
|
||||
descriptor: GPUTextureViewDescriptor,
|
||||
dimension: GPUTextureViewDimension,
|
||||
format: GPUTextureFormat,
|
||||
) -> DomRoot<GPUTextureView> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUTextureView::new_inherited(
|
||||
texture_view,
|
||||
texture,
|
||||
valid,
|
||||
descriptor,
|
||||
dimension,
|
||||
format,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
|
@ -96,8 +76,12 @@ impl GPUTextureView {
|
|||
self.valid.get()
|
||||
}
|
||||
|
||||
pub fn descriptor(&self) -> &GPUTextureViewDescriptor {
|
||||
&self.descriptor
|
||||
pub fn dimension(&self) -> GPUTextureViewDimension {
|
||||
self.dimension
|
||||
}
|
||||
|
||||
pub fn format(&self) -> GPUTextureFormat {
|
||||
self.format
|
||||
}
|
||||
|
||||
pub fn texture(&self) -> &GPUTexture {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue