@@ -74,18 +74,11 @@ pub use wgc::instance::{
74
74
DeviceType ,
75
75
} ;
76
76
77
- //TODO: avoid heap allocating vectors during resource creation.
78
- #[ derive( Default , Debug ) ]
79
- struct Temp {
80
- //bind_group_descriptors: Vec<wgn::BindGroupDescriptor>,
81
- //vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
82
- }
83
-
84
77
/// A handle to a physical graphics and/or compute device.
85
78
///
86
79
/// An `Adapter` can be used to open a connection to the corresponding device on the host system,
87
80
/// yielding a [`Device`] object.
88
- #[ derive( Debug , PartialEq ) ]
81
+ #[ derive( Debug , PartialEq , Eq ) ]
89
82
pub struct Adapter {
90
83
id : wgc:: id:: AdapterId ,
91
84
}
@@ -103,10 +96,9 @@ pub struct RequestAdapterOptions<'a> {
103
96
///
104
97
/// The `Device` is the responsible for the creation of most rendering and compute resources, as
105
98
/// well as exposing [`Queue`] objects.
106
- #[ derive( Debug ) ]
99
+ #[ derive( Debug , PartialEq , Eq ) ]
107
100
pub struct Device {
108
101
id : wgc:: id:: DeviceId ,
109
- temp : Temp ,
110
102
}
111
103
112
104
/// This is passed to `Device::poll` to control whether
@@ -118,14 +110,14 @@ pub enum Maintain {
118
110
}
119
111
120
112
/// A handle to a GPU-accessible buffer.
121
- #[ derive( Debug , PartialEq ) ]
113
+ #[ derive( Debug , PartialEq , Eq ) ]
122
114
pub struct Buffer {
123
115
id : wgc:: id:: BufferId ,
124
116
device_id : wgc:: id:: DeviceId ,
125
117
}
126
118
127
119
/// A handle to a texture on the GPU.
128
- #[ derive( Debug , PartialEq ) ]
120
+ #[ derive( Debug , PartialEq , Eq ) ]
129
121
pub struct Texture {
130
122
id : wgc:: id:: TextureId ,
131
123
owned : bool ,
@@ -135,7 +127,7 @@ pub struct Texture {
135
127
///
136
128
/// A `TextureView` object describes a texture and associated metadata needed by a
137
129
/// [`RenderPipeline`] or [`BindGroup`].
138
- #[ derive( Debug , PartialEq ) ]
130
+ #[ derive( Debug , PartialEq , Eq ) ]
139
131
pub struct TextureView {
140
132
id : wgc:: id:: TextureViewId ,
141
133
owned : bool ,
@@ -146,7 +138,7 @@ pub struct TextureView {
146
138
/// A `Sampler` object defines how a pipeline will sample from a [`TextureView`]. Samplers define
147
139
/// image filters (including anisotropy) and address (wrapping) modes, among other things. See
148
140
/// the documentation for [`SamplerDescriptor`] for more information.
149
- #[ derive( Debug , PartialEq ) ]
141
+ #[ derive( Debug , PartialEq , Eq ) ]
150
142
pub struct Sampler {
151
143
id : wgc:: id:: SamplerId ,
152
144
}
@@ -155,7 +147,7 @@ pub struct Sampler {
155
147
///
156
148
/// A `Surface` represents a platform-specific surface (e.g. a window) to which rendered images may
157
149
/// be presented. A `Surface` may be created with [`Surface::create`].
158
- #[ derive( Debug , PartialEq ) ]
150
+ #[ derive( Debug , PartialEq , Eq ) ]
159
151
pub struct Surface {
160
152
id : wgc:: id:: SurfaceId ,
161
153
}
@@ -164,7 +156,7 @@ pub struct Surface {
164
156
///
165
157
/// A `SwapChain` represents the image or series of images that will be presented to a [`Surface`].
166
158
/// A `SwapChain` may be created with [`Device::create_swap_chain`].
167
- #[ derive( Debug , PartialEq ) ]
159
+ #[ derive( Debug , PartialEq , Eq ) ]
168
160
pub struct SwapChain {
169
161
id : wgc:: id:: SwapChainId ,
170
162
}
@@ -175,7 +167,7 @@ pub struct SwapChain {
175
167
/// create a [`BindGroupDescriptor`] object, which in turn can be used to create a [`BindGroup`]
176
168
/// object with [`Device::create_bind_group`]. A series of `BindGroupLayout`s can also be used to
177
169
/// create a [`PipelineLayoutDescriptor`], which can be used to create a [`PipelineLayout`].
178
- #[ derive( Debug , PartialEq ) ]
170
+ #[ derive( Debug , PartialEq , Eq ) ]
179
171
pub struct BindGroupLayout {
180
172
id : wgc:: id:: BindGroupLayoutId ,
181
173
}
@@ -186,7 +178,7 @@ pub struct BindGroupLayout {
186
178
/// [`BindGroupLayout`]. It can be created with [`Device::create_bind_group`]. A `BindGroup` can
187
179
/// be bound to a particular [`RenderPass`] with [`RenderPass::set_bind_group`], or to a
188
180
/// [`ComputePass`] with [`ComputePass::set_bind_group`].
189
- #[ derive( Debug , PartialEq ) ]
181
+ #[ derive( Debug , PartialEq , Eq ) ]
190
182
pub struct BindGroup {
191
183
id : wgc:: id:: BindGroupId ,
192
184
}
@@ -202,15 +194,15 @@ impl Drop for BindGroup {
202
194
/// A `ShaderModule` represents a compiled shader module on the GPU. It can be created by passing
203
195
/// valid SPIR-V source code to [`Device::create_shader_module`]. Shader modules are used to define
204
196
/// programmable stages of a pipeline.
205
- #[ derive( Debug , PartialEq ) ]
197
+ #[ derive( Debug , PartialEq , Eq ) ]
206
198
pub struct ShaderModule {
207
199
id : wgc:: id:: ShaderModuleId ,
208
200
}
209
201
210
202
/// An opaque handle to a pipeline layout.
211
203
///
212
204
/// A `PipelineLayout` object describes the available binding groups of a pipeline.
213
- #[ derive( Debug , PartialEq ) ]
205
+ #[ derive( Debug , PartialEq , Eq ) ]
214
206
pub struct PipelineLayout {
215
207
id : wgc:: id:: PipelineLayoutId ,
216
208
}
@@ -219,13 +211,13 @@ pub struct PipelineLayout {
219
211
///
220
212
/// A `RenderPipeline` object represents a graphics pipeline and its stages, bindings, vertex
221
213
/// buffers and targets. A `RenderPipeline` may be created with [`Device::create_render_pipeline`].
222
- #[ derive( Debug , PartialEq ) ]
214
+ #[ derive( Debug , PartialEq , Eq ) ]
223
215
pub struct RenderPipeline {
224
216
id : wgc:: id:: RenderPipelineId ,
225
217
}
226
218
227
219
/// A handle to a compute pipeline.
228
- #[ derive( Debug , PartialEq ) ]
220
+ #[ derive( Debug , PartialEq , Eq ) ]
229
221
pub struct ComputePipeline {
230
222
id : wgc:: id:: ComputePipelineId ,
231
223
}
@@ -235,7 +227,7 @@ pub struct ComputePipeline {
235
227
/// A `CommandBuffer` represents a complete sequence of commands that may be submitted to a command
236
228
/// queue with [`Queue::submit`]. A `CommandBuffer` is obtained by recording a series of commands to
237
229
/// a [`CommandEncoder`] and then calling [`CommandEncoder::finish`].
238
- #[ derive( Debug , PartialEq ) ]
230
+ #[ derive( Debug , PartialEq , Eq ) ]
239
231
pub struct CommandBuffer {
240
232
id : wgc:: id:: CommandBufferId ,
241
233
}
@@ -247,7 +239,7 @@ pub struct CommandBuffer {
247
239
///
248
240
/// When finished recording, call [`CommandEncoder::finish`] to obtain a [`CommandBuffer`] which may
249
241
/// be submitted for execution.
250
- #[ derive( Debug ) ]
242
+ #[ derive( Debug , PartialEq , Eq ) ]
251
243
pub struct CommandEncoder {
252
244
id : wgc:: id:: CommandEncoderId ,
253
245
/// This type should be !Send !Sync, because it represents an allocation on this thread's
@@ -256,14 +248,14 @@ pub struct CommandEncoder {
256
248
}
257
249
258
250
/// An in-progress recording of a render pass.
259
- #[ derive( Debug ) ]
251
+ #[ derive( Debug , PartialEq , Eq ) ]
260
252
pub struct RenderPass < ' a > {
261
253
id : wgc:: id:: RenderPassId ,
262
254
_parent : & ' a mut CommandEncoder ,
263
255
}
264
256
265
257
/// An in-progress recording of a compute pass.
266
- #[ derive( Debug ) ]
258
+ #[ derive( Debug , PartialEq , Eq ) ]
267
259
pub struct ComputePass < ' a > {
268
260
id : wgc:: id:: ComputePassId ,
269
261
_parent : & ' a mut CommandEncoder ,
@@ -272,13 +264,13 @@ pub struct ComputePass<'a> {
272
264
/// A handle to a command queue on a device.
273
265
///
274
266
/// A `Queue` executes recorded [`CommandBuffer`] objects.
275
- #[ derive( Debug , PartialEq ) ]
267
+ #[ derive( Debug , PartialEq , Eq ) ]
276
268
pub struct Queue {
277
269
id : wgc:: id:: QueueId ,
278
270
}
279
271
280
272
/// A resource that can be bound to a pipeline.
281
- #[ derive( Clone , Debug ) ]
273
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
282
274
pub enum BindingResource < ' a > {
283
275
Buffer {
284
276
buffer : & ' a Buffer ,
@@ -289,7 +281,7 @@ pub enum BindingResource<'a> {
289
281
}
290
282
291
283
/// A bindable resource and the slot to bind it to.
292
- #[ derive( Clone , Debug ) ]
284
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
293
285
pub struct Binding < ' a > {
294
286
pub binding : u32 ,
295
287
pub resource : BindingResource < ' a > ,
@@ -322,15 +314,15 @@ pub enum BindingType {
322
314
}
323
315
324
316
/// A description of a single binding inside a bind group.
325
- #[ derive( Clone , Debug , Hash ) ]
317
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
326
318
pub struct BindGroupLayoutEntry {
327
319
pub binding : u32 ,
328
320
pub visibility : ShaderStage ,
329
321
pub ty : BindingType ,
330
322
}
331
323
332
324
/// A description of a bind group layout.
333
- #[ derive( Clone , Debug ) ]
325
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
334
326
pub struct BindGroupLayoutDescriptor < ' a > {
335
327
pub bindings : & ' a [ BindGroupLayoutEntry ] ,
336
328
@@ -340,7 +332,7 @@ pub struct BindGroupLayoutDescriptor<'a> {
340
332
}
341
333
342
334
/// A description of a group of bindings and the resources to be bound.
343
- #[ derive( Clone , Debug ) ]
335
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
344
336
pub struct BindGroupDescriptor < ' a > {
345
337
/// The layout for this bind group.
346
338
pub layout : & ' a BindGroupLayout ,
@@ -357,13 +349,13 @@ pub struct BindGroupDescriptor<'a> {
357
349
///
358
350
/// A `PipelineLayoutDescriptor` can be passed to [`Device::create_pipeline_layout`] to obtain a
359
351
/// [`PipelineLayout`].
360
- #[ derive( Clone , Debug ) ]
352
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
361
353
pub struct PipelineLayoutDescriptor < ' a > {
362
354
pub bind_group_layouts : & ' a [ & ' a BindGroupLayout ] ,
363
355
}
364
356
365
357
/// A description of a programmable pipeline stage.
366
- #[ derive( Clone , Debug ) ]
358
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
367
359
pub struct ProgrammableStageDescriptor < ' a > {
368
360
/// The compiled shader module for this stage.
369
361
pub module : & ' a ShaderModule ,
@@ -383,7 +375,7 @@ pub struct VertexStateDescriptor<'a> {
383
375
}
384
376
385
377
/// A description of a vertex buffer.
386
- #[ derive( Clone , Debug ) ]
378
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
387
379
pub struct VertexBufferDescriptor < ' a > {
388
380
/// The stride, in bytes, between elements of this buffer.
389
381
pub stride : BufferAddress ,
@@ -513,14 +505,14 @@ pub struct TextureDescriptor<'a> {
513
505
}
514
506
515
507
/// A swap chain image that can be rendered to.
516
- #[ derive( Debug ) ]
508
+ #[ derive( Debug , PartialEq , Eq ) ]
517
509
pub struct SwapChainOutput {
518
510
pub view : TextureView ,
519
511
swap_chain_id : wgc:: id:: SwapChainId ,
520
512
}
521
513
522
514
/// A view of a buffer which can be used to copy to or from a texture.
523
- #[ derive( Clone , Debug ) ]
515
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
524
516
pub struct BufferCopyView < ' a > {
525
517
/// The buffer to be copied to or from.
526
518
pub buffer : & ' a Buffer ,
@@ -550,7 +542,7 @@ impl BufferCopyView<'_> {
550
542
}
551
543
552
544
/// A view of a texture which can be used to copy to or from a buffer or another texture.
553
- #[ derive( Clone , Debug ) ]
545
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
554
546
pub struct TextureCopyView < ' a > {
555
547
/// The texture to be copied to or from.
556
548
pub texture : & ' a Texture ,
@@ -654,7 +646,6 @@ impl Adapter {
654
646
pub async fn request_device ( & self , desc : & DeviceDescriptor ) -> ( Device , Queue ) {
655
647
let device = Device {
656
648
id : wgn:: wgpu_adapter_request_device ( self . id , Some ( desc) ) ,
657
- temp : Temp :: default ( ) ,
658
649
} ;
659
650
let queue = Queue {
660
651
id : wgn:: wgpu_device_get_default_queue ( device. id ) ,
0 commit comments