Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove G parameter in Global<G> and generic IdentityHandlerFactory #5159

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deno_webgpu/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn op_webgpu_create_bind_group_layout(
gfx_put!(device => instance.device_create_bind_group_layout(
device,
&descriptor,
()
None
) => state, WebGpuBindGroupLayout)
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn op_webgpu_render_bundle_encoder_finish(
&wgpu_core::command::RenderBundleDescriptor {
label: Some(label),
},
()
None
) => state, WebGpuRenderBundle)
}

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

Expand Down
12 changes: 5 additions & 7 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ fn check_unstable(state: &OpState, api_name: &str) {
}
}

pub type Instance =
std::sync::Arc<wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>>;
pub type Instance = std::sync::Arc<wgpu_core::global::Global>;

struct WebGpuAdapter(Instance, wgpu_core::id::AdapterId);
impl Resource for WebGpuAdapter {
Expand Down Expand Up @@ -410,7 +409,6 @@ pub async fn op_webgpu_request_adapter(
} else {
state.put(std::sync::Arc::new(wgpu_core::global::Global::new(
"webgpu",
wgpu_core::identity::IdentityManagerFactory,
wgpu_types::InstanceDescriptor {
backends,
flags: wgpu_types::InstanceFlags::from_build_config(),
Expand All @@ -428,7 +426,7 @@ pub async fn op_webgpu_request_adapter(
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(backends, |_| ()),
wgpu_core::instance::AdapterInputs::Mask(backends, |_| None),
);

let adapter = match res {
Expand Down Expand Up @@ -675,8 +673,8 @@ pub async fn op_webgpu_request_device(
adapter,
&descriptor,
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
(),
()
None,
None
));
if let Some(err) = maybe_err {
return Err(DomExceptionOperationError::new(&err.to_string()).into());
Expand Down Expand Up @@ -773,6 +771,6 @@ pub fn op_webgpu_create_query_set(
gfx_put!(device => instance.device_create_query_set(
device,
&descriptor,
()
None
) => state, WebGpuQuerySet)
}
16 changes: 8 additions & 8 deletions deno_webgpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ pub fn op_webgpu_create_compute_pipeline(
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
Some(wgpu_core::device::ImplicitPipelineIds {
root_id: (),
group_ids: &[(); MAX_BIND_GROUPS],
root_id: None,
group_ids: &[None; MAX_BIND_GROUPS],
})
}
};

let (compute_pipeline, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
device,
&descriptor,
(),
None,
implicit_pipelines
));

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

let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, ()));
let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, None));

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

let (render_pipeline, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
device,
&descriptor,
(),
None,
implicit_pipelines
));

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

let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, ()));
let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, None));

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/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ pub fn op_webgpu_create_sampler(
gfx_put!(device => instance.device_create_sampler(
device,
&descriptor,
()
None
) => state, WebGpuSampler)
}
2 changes: 1 addition & 1 deletion deno_webgpu/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ pub fn op_webgpu_create_shader_module(
device,
&descriptor,
source,
()
None
) => state, WebGpuShaderModule)
}
3 changes: 2 additions & 1 deletion deno_webgpu/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub fn op_webgpu_surface_configure(
present_mode: args.present_mode.unwrap_or_default(),
alpha_mode: args.alpha_mode,
view_formats: args.view_formats,
desired_maximum_frame_latency: 2,
};

let err = gfx_select!(device => instance.surface_configure(surface, device, &conf));
Expand All @@ -97,7 +98,7 @@ pub fn op_webgpu_surface_get_current_texture(
let surface_resource = state.resource_table.get::<WebGpuSurface>(surface_rid)?;
let surface = surface_resource.1;

let output = gfx_select!(device => instance.surface_get_current_texture(surface, ()))?;
let output = gfx_select!(device => instance.surface_get_current_texture(surface, None))?;

match output.status {
SurfaceStatus::Good | SurfaceStatus::Suboptimal => {
Expand Down
4 changes: 2 additions & 2 deletions deno_webgpu/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn op_webgpu_create_texture(
let (val, maybe_err) = gfx_select!(device => instance.device_create_texture(
device,
&descriptor,
()
None
));

let rid = state.resource_table.add(WebGpuTexture {
Expand Down Expand Up @@ -128,6 +128,6 @@ pub fn op_webgpu_create_texture_view(
gfx_put!(texture => instance.texture_create_view(
texture,
&descriptor,
()
None
) => state, WebGpuTextureView)
}
18 changes: 6 additions & 12 deletions player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#[cfg(not(target_arch = "wasm32"))]
fn main() {
use player::{GlobalPlay as _, IdentityPassThroughFactory};
use player::GlobalPlay as _;
use wgc::{device::trace, gfx_select};

use std::{
Expand Down Expand Up @@ -49,19 +49,15 @@ fn main() {
.build(&event_loop)
.unwrap();

let global = wgc::global::Global::new(
"player",
IdentityPassThroughFactory,
wgt::InstanceDescriptor::default(),
);
let global = wgc::global::Global::new("player", wgt::InstanceDescriptor::default());
let mut command_buffer_id_manager = wgc::identity::IdentityManager::new();

#[cfg(feature = "winit")]
let surface = unsafe {
global.instance_create_surface(
window.display_handle().unwrap().into(),
window.window_handle().unwrap().into(),
wgc::id::Id::zip(0, 1, wgt::Backend::Empty),
Some(wgc::id::Id::zip(0, 1, wgt::Backend::Empty)),
)
}
.unwrap();
Expand All @@ -79,9 +75,7 @@ fn main() {
#[cfg(not(feature = "winit"))]
compatible_surface: None,
},
wgc::instance::AdapterInputs::IdSet(&[wgc::id::Id::zip(0, 0, backend)], |id| {
id.backend()
}),
wgc::instance::AdapterInputs::IdSet(&[wgc::id::AdapterId::zip(0, 0, backend)]),
)
.expect("Unable to find an adapter for selected backend");

Expand All @@ -92,8 +86,8 @@ fn main() {
adapter,
&desc,
None,
id,
id.transmute()
Some(id),
Some(id.transmute())
));
if let Some(e) = error {
panic!("{:?}", e);
Expand Down
Loading