Skip to content

Commit

Permalink
Use () instead of PhantomData as IdentityManager's Input type. (#2972)
Browse files Browse the repository at this point in the history
* Use () instead of PhantomData as IdentityManager's Input type.

PhantomData suggests that there's some sort of persuasion required
for lifetime variance inference or other sorts of arcana, but it
doesn't seem to be necessary at all. `()` works just fine.
  • Loading branch information
jimblandy authored Sep 2, 2022
1 parent ee7fd47 commit 701564d
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 63 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ the same every time it is rendered, we now warn if it is missing.
- Added downlevel restriction error message for `InvalidFormatUsages` error by @Seamooo in [#2886](https://github.com/gfx-rs/wgpu/pull/2886)
- Add warning when using CompareFunction::*Equal with vertex shader that is missing @invariant tag by @cwfitzgerald in [#2887](https://github.com/gfx-rs/wgpu/pull/2887)
- Update Winit to version 0.27 and raw-window-handle to 0.5 by @wyatt-herkamp in [#2918](https://github.com/gfx-rs/wgpu/pull/2918)
- Address Clippy 0.1.63 complaints. By @jimb in [#2977](https://github.com/gfx-rs/wgpu/pull/2977)
- Address Clippy 0.1.63 complaints. By @jimblandy in [#2977](https://github.com/gfx-rs/wgpu/pull/2977)
- Don't use `PhantomData` for `IdentityManager`'s `Input` type. By @jimblandy in [#2972](https://github.com/gfx-rs/wgpu/pull/2972)
#### Metal
- Extract the generic code into `get_metal_layer` by @jinleili in [#2826](https://github.com/gfx-rs/wgpu/pull/2826)

Expand Down
6 changes: 3 additions & 3 deletions deno_webgpu/src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn op_webgpu_create_bind_group_layout(
gfx_put!(device => instance.device_create_bind_group_layout(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuBindGroupLayout)
}

Expand Down Expand Up @@ -226,7 +226,7 @@ pub fn op_webgpu_create_pipeline_layout(
gfx_put!(device => instance.device_create_pipeline_layout(
device,
&descriptor,
std::marker::PhantomData
()
) => state, super::pipeline::WebGpuPipelineLayout)
}

Expand Down Expand Up @@ -304,6 +304,6 @@ pub fn op_webgpu_create_bind_group(
gfx_put!(device => instance.device_create_bind_group(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuBindGroup)
}
2 changes: 1 addition & 1 deletion deno_webgpu/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn op_webgpu_create_buffer(
gfx_put!(device => instance.device_create_buffer(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuBuffer)
}

Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn op_webgpu_render_bundle_encoder_finish(
&wgpu_core::command::RenderBundleDescriptor {
label: label.map(Cow::from),
},
std::marker::PhantomData
()
) => state, WebGpuRenderBundle)
}

Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/src/command_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn op_webgpu_create_command_encoder(
gfx_put!(device => instance.device_create_command_encoder(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuCommandEncoder)
}

Expand Down
6 changes: 3 additions & 3 deletions deno_webgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub async fn op_webgpu_request_adapter(
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(backends, |_| std::marker::PhantomData),
wgpu_core::instance::AdapterInputs::Mask(backends, |_| ()),
);

let adapter = match res {
Expand Down Expand Up @@ -413,7 +413,7 @@ pub async fn op_webgpu_request_device(
adapter,
&descriptor,
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
std::marker::PhantomData
()
));
if let Some(err) = maybe_err {
return Err(DomExceptionOperationError::new(&err.to_string()).into());
Expand Down Expand Up @@ -536,7 +536,7 @@ pub fn op_webgpu_create_query_set(
gfx_put!(device => instance.device_create_query_set(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuQuerySet)
}

Expand Down
16 changes: 8 additions & 8 deletions deno_webgpu/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ pub fn op_webgpu_create_compute_pipeline(
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
root_id: (),
group_ids: &[(); MAX_BIND_GROUPS],
})
}
};

let (compute_pipeline, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
device,
&descriptor,
std::marker::PhantomData,
(),
implicit_pipelines
));

Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
.get::<WebGpuComputePipeline>(compute_pipeline_rid)?;
let compute_pipeline = compute_pipeline_resource.0;

let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, std::marker::PhantomData));
let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, ()));

let label =
gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
Expand Down Expand Up @@ -364,16 +364,16 @@ pub fn op_webgpu_create_render_pipeline(
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
root_id: (),
group_ids: &[(); MAX_BIND_GROUPS],
})
}
};

let (render_pipeline, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
device,
&descriptor,
std::marker::PhantomData,
(),
implicit_pipelines
));

Expand All @@ -396,7 +396,7 @@ pub fn op_webgpu_render_pipeline_get_bind_group_layout(
.get::<WebGpuRenderPipeline>(render_pipeline_rid)?;
let render_pipeline = render_pipeline_resource.0;

let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, std::marker::PhantomData));
let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, ()));

let label =
gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ pub fn op_webgpu_create_sampler(
gfx_put!(device => instance.device_create_sampler(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuSampler)
}
2 changes: 1 addition & 1 deletion deno_webgpu/src/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ pub fn op_webgpu_create_shader_module(
device,
&descriptor,
source,
std::marker::PhantomData
()
) => state, WebGpuShaderModule)
}
4 changes: 2 additions & 2 deletions deno_webgpu/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn op_webgpu_create_texture(
gfx_put!(device => instance.device_create_texture(
device,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuTexture)
}

Expand Down Expand Up @@ -105,6 +105,6 @@ pub fn op_webgpu_create_texture_view(
gfx_put!(texture => instance.texture_create_view(
texture,
&descriptor,
std::marker::PhantomData
()
) => state, WebGpuTextureView)
}
2 changes: 1 addition & 1 deletion wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ pub trait IdentityHandler<I>: Debug {
}

impl<I: id::TypedId + Debug> IdentityHandler<I> for Mutex<IdentityManager> {
type Input = PhantomData<I>;
type Input = ();
fn process(&self, _id: Self::Input, backend: Backend) -> I {
self.lock().alloc(backend)
}
Expand Down
Loading

0 comments on commit 701564d

Please sign in to comment.