Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit a96a5fa

Browse files
Merge #200
200: Derive `Hash` and `PartialEq` for unique identifier wrapper types r=kvark a=mitchmindtree This is particularly useful downstream for distinguishing between instances of these types. I was unsure about `Device` as I noticed it has a `Temp` field that looks like it might eventually store some non-PartialEq/Hash-friendly fields. Let me know if you'd like me to add a derive for `Device` or if there are any issues with those I have updated. Co-authored-by: mitchmindtree <[email protected]>
2 parents 76ffea3 + cf5fcc4 commit a96a5fa

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct Temp {
5454
///
5555
/// An `Adapter` can be used to open a connection to the corresponding device on the host system,
5656
/// yielding a [`Device`] object.
57-
#[derive(Debug)]
57+
#[derive(Debug, Hash, PartialEq)]
5858
pub struct Adapter {
5959
id: wgc::id::AdapterId,
6060
}
@@ -70,14 +70,14 @@ pub struct Device {
7070
}
7171

7272
/// A handle to a GPU-accessible buffer.
73-
#[derive(Debug)]
73+
#[derive(Debug, Hash, PartialEq)]
7474
pub struct Buffer {
7575
id: wgc::id::BufferId,
7676
device_id: wgc::id::DeviceId,
7777
}
7878

7979
/// A handle to a texture on the GPU.
80-
#[derive(Debug)]
80+
#[derive(Debug, Hash, PartialEq)]
8181
pub struct Texture {
8282
id: wgc::id::TextureId,
8383
owned: bool,
@@ -87,7 +87,7 @@ pub struct Texture {
8787
///
8888
/// A `TextureView` object describes a texture and associated metadata needed by a
8989
/// [`RenderPipeline`] or [`BindGroup`].
90-
#[derive(Debug)]
90+
#[derive(Debug, Hash, PartialEq)]
9191
pub struct TextureView {
9292
id: wgc::id::TextureViewId,
9393
owned: bool,
@@ -98,7 +98,7 @@ pub struct TextureView {
9898
/// A `Sampler` object defines how a pipeline will sample from a [`TextureView`]. Samplers define
9999
/// image filters (including anisotropy) and address (wrapping) modes, among other things. See
100100
/// the documentation for [`SamplerDescriptor`] for more information.
101-
#[derive(Debug)]
101+
#[derive(Debug, Hash, PartialEq)]
102102
pub struct Sampler {
103103
id: wgc::id::SamplerId,
104104
}
@@ -107,7 +107,7 @@ pub struct Sampler {
107107
///
108108
/// A `Surface` represents a platform-specific surface (e.g. a window) to which rendered images may
109109
/// be presented. A `Surface` may be created with [`Surface::create`].
110-
#[derive(Debug)]
110+
#[derive(Debug, Hash, PartialEq)]
111111
pub struct Surface {
112112
id: wgc::id::SurfaceId,
113113
}
@@ -116,7 +116,7 @@ pub struct Surface {
116116
///
117117
/// A `SwapChain` represents the image or series of images that will be presented to a [`Surface`].
118118
/// A `SwapChain` may be created with [`Device::create_swap_chain`].
119-
#[derive(Debug)]
119+
#[derive(Debug, Hash, PartialEq)]
120120
pub struct SwapChain {
121121
id: wgc::id::SwapChainId,
122122
}
@@ -127,7 +127,7 @@ pub struct SwapChain {
127127
/// create a [`BindGroupDescriptor`] object, which in turn can be used to create a [`BindGroup`]
128128
/// object with [`Device::create_bind_group`]. A series of `BindGroupLayout`s can also be used to
129129
/// create a [`PipelineLayoutDescriptor`], which can be used to create a [`PipelineLayout`].
130-
#[derive(Debug)]
130+
#[derive(Debug, Hash, PartialEq)]
131131
pub struct BindGroupLayout {
132132
id: wgc::id::BindGroupLayoutId,
133133
}
@@ -138,7 +138,7 @@ pub struct BindGroupLayout {
138138
/// [`BindGroupLayout`]. It can be created with [`Device::create_bind_group`]. A `BindGroup` can
139139
/// be bound to a particular [`RenderPass`] with [`RenderPass::set_bind_group`], or to a
140140
/// [`ComputePass`] with [`ComputePass::set_bind_group`].
141-
#[derive(Debug)]
141+
#[derive(Debug, Hash, PartialEq)]
142142
pub struct BindGroup {
143143
id: wgc::id::BindGroupId,
144144
}
@@ -154,15 +154,15 @@ impl Drop for BindGroup {
154154
/// A `ShaderModule` represents a compiled shader module on the GPU. It can be created by passing
155155
/// valid SPIR-V source code to [`Device::create_shader_module`]. Shader modules are used to define
156156
/// programmable stages of a pipeline.
157-
#[derive(Debug)]
157+
#[derive(Debug, Hash, PartialEq)]
158158
pub struct ShaderModule {
159159
id: wgc::id::ShaderModuleId,
160160
}
161161

162162
/// An opaque handle to a pipeline layout.
163163
///
164164
/// A `PipelineLayout` object describes the available binding groups of a pipeline.
165-
#[derive(Debug)]
165+
#[derive(Debug, Hash, PartialEq)]
166166
pub struct PipelineLayout {
167167
id: wgc::id::PipelineLayoutId,
168168
}
@@ -171,13 +171,13 @@ pub struct PipelineLayout {
171171
///
172172
/// A `RenderPipeline` object represents a graphics pipeline and its stages, bindings, vertex
173173
/// buffers and targets. A `RenderPipeline` may be created with [`Device::create_render_pipeline`].
174-
#[derive(Debug)]
174+
#[derive(Debug, Hash, PartialEq)]
175175
pub struct RenderPipeline {
176176
id: wgc::id::RenderPipelineId,
177177
}
178178

179179
/// A handle to a compute pipeline.
180-
#[derive(Debug)]
180+
#[derive(Debug, Hash, PartialEq)]
181181
pub struct ComputePipeline {
182182
id: wgc::id::ComputePipelineId,
183183
}
@@ -187,7 +187,7 @@ pub struct ComputePipeline {
187187
/// A `CommandBuffer` represents a complete sequence of commands that may be submitted to a command
188188
/// queue with [`Queue::submit`]. A `CommandBuffer` is obtained by recording a series of commands to
189189
/// a [`CommandEncoder`] and then calling [`CommandEncoder::finish`].
190-
#[derive(Debug)]
190+
#[derive(Debug, Hash, PartialEq)]
191191
pub struct CommandBuffer {
192192
id: wgc::id::CommandBufferId,
193193
}
@@ -224,7 +224,7 @@ pub struct ComputePass<'a> {
224224
/// A handle to a command queue on a device.
225225
///
226226
/// A `Queue` executes recorded [`CommandBuffer`] objects.
227-
#[derive(Debug)]
227+
#[derive(Debug, Hash, PartialEq)]
228228
pub struct Queue {
229229
id: wgc::id::QueueId,
230230
}

0 commit comments

Comments
 (0)