@@ -20,97 +20,103 @@ use crate::texture::GPUTextureView;
20
20
use crate :: Instance ;
21
21
22
22
pub struct GPUBindGroup {
23
- pub instance : Instance ,
24
- pub id : wgpu_core:: id:: BindGroupId ,
25
- pub label : String ,
23
+ pub instance : Instance ,
24
+ pub id : wgpu_core:: id:: BindGroupId ,
25
+ pub label : String ,
26
26
}
27
27
28
28
impl Drop for GPUBindGroup {
29
- fn drop ( & mut self ) {
30
- self . instance . bind_group_drop ( self . id ) ;
31
- }
29
+ fn drop ( & mut self ) {
30
+ self . instance . bind_group_drop ( self . id ) ;
31
+ }
32
32
}
33
33
34
34
impl WebIdlInterfaceConverter for GPUBindGroup {
35
- const NAME : & ' static str = "GPUBindGroup" ;
35
+ const NAME : & ' static str = "GPUBindGroup" ;
36
36
}
37
37
38
38
impl GarbageCollected for GPUBindGroup { }
39
39
40
40
#[ op2]
41
41
impl GPUBindGroup {
42
- #[ getter]
43
- #[ string]
44
- fn label ( & self ) -> String {
45
- self . label . clone ( )
46
- }
47
- #[ setter]
48
- #[ string]
49
- fn label ( & self , #[ webidl] _label : String ) {
50
- // TODO(@crowlKats): no-op, needs wpgu to implement changing the label
51
- }
42
+ #[ getter]
43
+ #[ string]
44
+ fn label ( & self ) -> String {
45
+ self . label . clone ( )
46
+ }
47
+ #[ setter]
48
+ #[ string]
49
+ fn label ( & self , #[ webidl] _label : String ) {
50
+ // TODO(@crowlKats): no-op, needs wpgu to implement changing the label
51
+ }
52
52
}
53
53
54
54
#[ derive( WebIDL ) ]
55
55
#[ webidl( dictionary) ]
56
56
pub ( crate ) struct GPUBindGroupDescriptor {
57
- #[ webidl( default = String :: new( ) ) ]
58
- pub label : String ,
57
+ #[ webidl( default = String :: new( ) ) ]
58
+ pub label : String ,
59
59
60
- pub layout : Ptr < super :: bind_group_layout:: GPUBindGroupLayout > ,
61
- pub entries : Vec < GPUBindGroupEntry > ,
60
+ pub layout : Ptr < super :: bind_group_layout:: GPUBindGroupLayout > ,
61
+ pub entries : Vec < GPUBindGroupEntry > ,
62
62
}
63
63
64
64
#[ derive( WebIDL ) ]
65
65
#[ webidl( dictionary) ]
66
66
pub ( crate ) struct GPUBindGroupEntry {
67
- #[ options( enforce_range = true ) ]
68
- pub binding : u32 ,
69
- pub resource : GPUBindingResource ,
67
+ #[ options( enforce_range = true ) ]
68
+ pub binding : u32 ,
69
+ pub resource : GPUBindingResource ,
70
70
}
71
71
72
72
#[ derive( WebIDL ) ]
73
73
#[ webidl( dictionary) ]
74
74
pub ( crate ) struct GPUBufferBinding {
75
- pub buffer : Ptr < GPUBuffer > ,
76
- #[ webidl( default = 0 ) ]
77
- #[ options( enforce_range = true ) ]
78
- pub offset : u64 ,
79
- #[ options( enforce_range = true ) ]
80
- pub size : Option < u64 > ,
75
+ pub buffer : Ptr < GPUBuffer > ,
76
+ #[ webidl( default = 0 ) ]
77
+ #[ options( enforce_range = true ) ]
78
+ pub offset : u64 ,
79
+ #[ options( enforce_range = true ) ]
80
+ pub size : Option < u64 > ,
81
81
}
82
82
83
83
pub ( crate ) enum GPUBindingResource {
84
- Sampler ( Ptr < GPUSampler > ) ,
85
- TextureView ( Ptr < GPUTextureView > ) ,
86
- BufferBinding ( GPUBufferBinding ) ,
84
+ Sampler ( Ptr < GPUSampler > ) ,
85
+ TextureView ( Ptr < GPUTextureView > ) ,
86
+ BufferBinding ( GPUBufferBinding ) ,
87
87
}
88
88
89
89
impl < ' a > WebIdlConverter < ' a > for GPUBindingResource {
90
- type Options = ( ) ;
90
+ type Options = ( ) ;
91
91
92
- fn convert < ' b > (
93
- scope : & mut HandleScope < ' a > ,
94
- value : Local < ' a , Value > ,
95
- prefix : Cow < ' static , str > ,
96
- context : ContextFn < ' b > ,
97
- options : & Self :: Options ,
98
- ) -> Result < Self , WebIdlError > {
99
- <Ptr < GPUSampler > >:: convert ( scope, value, prefix. clone ( ) , context. borrowed ( ) , options)
100
- . map ( Self :: Sampler )
101
- . or_else ( |_| {
102
- <Ptr < GPUTextureView > >:: convert (
103
- scope,
104
- value,
105
- prefix. clone ( ) ,
106
- context. borrowed ( ) ,
107
- options,
108
- )
109
- . map ( Self :: TextureView )
110
- } )
111
- . or_else ( |_| {
112
- GPUBufferBinding :: convert ( scope, value, prefix, context, options)
113
- . map ( Self :: BufferBinding )
114
- } )
115
- }
92
+ fn convert < ' b > (
93
+ scope : & mut HandleScope < ' a > ,
94
+ value : Local < ' a , Value > ,
95
+ prefix : Cow < ' static , str > ,
96
+ context : ContextFn < ' b > ,
97
+ options : & Self :: Options ,
98
+ ) -> Result < Self , WebIdlError > {
99
+ <Ptr < GPUSampler > >:: convert (
100
+ scope,
101
+ value,
102
+ prefix. clone ( ) ,
103
+ context. borrowed ( ) ,
104
+ options,
105
+ )
106
+ . map ( Self :: Sampler )
107
+ . or_else ( |_| {
108
+ <Ptr < GPUTextureView > >:: convert (
109
+ scope,
110
+ value,
111
+ prefix. clone ( ) ,
112
+ context. borrowed ( ) ,
113
+ options,
114
+ )
115
+ . map ( Self :: TextureView )
116
+ } )
117
+ . or_else ( |_| {
118
+ GPUBufferBinding :: convert ( scope, value, prefix, context, options)
119
+ . map ( Self :: BufferBinding )
120
+ } )
121
+ }
116
122
}
0 commit comments