Skip to content

Commit

Permalink
remove backend from ID (#6263)
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored Sep 13, 2024
1 parent ff52b86 commit c8beade
Show file tree
Hide file tree
Showing 23 changed files with 280 additions and 542 deletions.
5 changes: 1 addition & 4 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ pub fn op_webgpu_request_adapter(
force_fallback_adapter,
compatible_surface: None, // windowless
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(backends, |_| None),
);
let res = instance.request_adapter(&descriptor, backends, None);

let adapter = match res {
Ok(adapter) => adapter,
Expand Down
9 changes: 5 additions & 4 deletions player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
global.instance_create_surface(
window.display_handle().unwrap().into(),
window.window_handle().unwrap().into(),
Some(wgc::id::Id::zip(0, 1, wgt::Backend::Empty)),
Some(wgc::id::Id::zip(0, 1)),
)
}
.unwrap();
Expand All @@ -74,14 +74,15 @@ fn main() {
#[cfg(not(feature = "winit"))]
compatible_surface: None,
},
wgc::instance::AdapterInputs::IdSet(&[wgc::id::AdapterId::zip(0, 0, backend)]),
wgt::Backends::from(backend),
Some(wgc::id::AdapterId::zip(0, 1)),
)
.expect("Unable to find an adapter for selected backend");

let info = global.adapter_get_info(adapter);
log::info!("Picked '{}'", info.name);
let device_id = wgc::id::Id::zip(1, 0, backend);
let queue_id = wgc::id::Id::zip(1, 0, backend);
let device_id = wgc::id::Id::zip(0, 1);
let queue_id = wgc::id::Id::zip(0, 1);
let res = global.adapter_request_device(
adapter,
&desc,
Expand Down
6 changes: 1 addition & 5 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ impl GlobalPlay for wgc::global::Global {
let (encoder, error) = self.device_create_command_encoder(
device,
&wgt::CommandEncoderDescriptor { label: None },
Some(
comb_manager
.process(device.backend())
.into_command_encoder_id(),
),
Some(comb_manager.process().into_command_encoder_id()),
);
if let Some(e) = error {
panic!("{e}");
Expand Down
26 changes: 13 additions & 13 deletions player/tests/data/bind-group.ron
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
features: [],
expectations: [], //not crash!
actions: [
CreateBuffer(Id(0, 1, Empty), (
CreateBuffer(Id(0, 1), (
label: None,
size: 16,
usage: 64,
mapped_at_creation: false,
)),
CreateBindGroupLayout(Id(0, 1, Empty), (
CreateBindGroupLayout(Id(0, 1), (
label: None,
entries: [
(
Expand All @@ -20,42 +20,42 @@
),
],
)),
CreateBindGroup(Id(0, 1, Empty), (
CreateBindGroup(Id(0, 1), (
label: None,
layout: Id(0, 1, Empty),
layout: Id(0, 1),
entries: [
(
binding: 0,
resource: Buffer((
buffer_id: Id(0, 1, Empty),
buffer_id: Id(0, 1),
offset: 0,
size: None,
)),
)
],
)),
CreatePipelineLayout(Id(0, 1, Empty), (
CreatePipelineLayout(Id(0, 1), (
label: Some("empty"),
bind_group_layouts: [
Id(0, 1, Empty),
Id(0, 1),
],
push_constant_ranges: [],
)),
CreateShaderModule(
id: Id(0, 1, Empty),
id: Id(0, 1),
desc: (
label: None,
flags: (bits: 3),
),
data: "empty.wgsl",
),
CreateComputePipeline(
id: Id(0, 1, Empty),
id: Id(0, 1),
desc: (
label: None,
layout: Some(Id(0, 1, Empty)),
layout: Some(Id(0, 1)),
stage: (
module: Id(0, 1, Empty),
module: Id(0, 1),
entry_point: None,
constants: {},
zero_initialize_workgroup_memory: true,
Expand All @@ -70,9 +70,9 @@
SetBindGroup(
index: 0,
num_dynamic_offsets: 0,
bind_group_id: Some(Id(0, 1, Empty)),
bind_group_id: Some(Id(0, 1)),
),
SetPipeline(Id(0, 1, Empty)),
SetPipeline(Id(0, 1)),
],
dynamic_offsets: [],
string_data: [],
Expand Down
4 changes: 2 additions & 2 deletions player/tests/data/buffer-copy.ron
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
actions: [
CreateBuffer(
Id(0, 1, Empty),
Id(0, 1),
(
label: Some("dummy"),
size: 16,
Expand All @@ -19,7 +19,7 @@
),
),
WriteBuffer(
id: Id(0, 1, Empty),
id: Id(0, 1),
data: "data1.bin",
range: (
start: 0,
Expand Down
18 changes: 9 additions & 9 deletions player/tests/data/clear-buffer-texture.ron
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
],
actions: [
CreateTexture(Id(0, 1, Empty), (
CreateTexture(Id(0, 1), (
label: Some("Output Texture"),
size: (
width: 64,
Expand All @@ -36,7 +36,7 @@
// First fill the texture to ensure it wasn't just zero initialized or "happened" to be zero.
WriteTexture(
to: (
texture: Id(0, 1, Empty),
texture: Id(0, 1),
mip_level: 0,
array_layer: 0,
),
Expand All @@ -52,7 +52,7 @@
),
),
CreateBuffer(
Id(0, 1, Empty),
Id(0, 1),
(
label: Some("Output Buffer"),
size: 16384,
Expand All @@ -62,7 +62,7 @@
),

CreateBuffer(
Id(1, 1, Empty),
Id(1, 1),
(
label: Some("Buffer to be cleared"),
size: 16,
Expand All @@ -72,7 +72,7 @@
),
// Make sure there is something in the buffer, otherwise it might be just zero init!
WriteBuffer(
id: Id(1, 1, Empty),
id: Id(1, 1),
data: "data1.bin",
range: (
start: 0,
Expand All @@ -82,7 +82,7 @@
),
Submit(1, [
ClearTexture(
dst: Id(0, 1, Empty),
dst: Id(0, 1),
subresource_range: ImageSubresourceRange(
aspect: all,
baseMipLevel: 0,
Expand All @@ -93,12 +93,12 @@
),
CopyTextureToBuffer(
src: (
texture: Id(0, 1, Empty),
texture: Id(0, 1),
mip_level: 0,
array_layer: 0,
),
dst: (
buffer: Id(0, 1, Empty),
buffer: Id(0, 1),
layout: (
offset: 0,
bytes_per_row: Some(256),
Expand All @@ -112,7 +112,7 @@
),
// Partial clear to prove
ClearBuffer(
dst: Id(1, 1, Empty),
dst: Id(1, 1),
offset: 4,
size: Some(8),
)
Expand Down
22 changes: 11 additions & 11 deletions player/tests/data/pipeline-statistics-query.ron
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
),
],
actions: [
CreatePipelineLayout(Id(0, 1, Empty), (
CreatePipelineLayout(Id(0, 1), (
label: Some("empty"),
bind_group_layouts: [],
push_constant_ranges: [],
)),
CreateShaderModule(
id: Id(0, 1, Empty),
id: Id(0, 1),
desc: (
label: None,
flags: (bits: 3),
),
data: "empty.wgsl",
),
CreateComputePipeline(
id: Id(0, 1, Empty),
id: Id(0, 1),
desc: (
label: None,
layout: Some(Id(0, 1, Empty)),
layout: Some(Id(0, 1)),
stage: (
module: Id(0, 1, Empty),
module: Id(0, 1),
entry_point: None,
constants: {},
zero_initialize_workgroup_memory: true,
Expand All @@ -37,15 +37,15 @@
),
),
CreateQuerySet(
id: Id(0, 1, Empty),
id: Id(0, 1),
desc: (
label: Some("Compute Invocation QuerySet"),
count: 2,
ty: PipelineStatistics(0x18), // FRAGMENT_SHADER_INVOCATIONS | COMPUTE_SHADER_INVOCATIONS
),
),
CreateBuffer(
Id(0, 1, Empty),
Id(0, 1),
(
label: Some("Compute Invocation Result Buffer"),
size: 16,
Expand All @@ -57,9 +57,9 @@
RunComputePass(
base: (
commands: [
SetPipeline(Id(0, 1, Empty)),
SetPipeline(Id(0, 1)),
BeginPipelineStatisticsQuery(
query_set_id: Id(0, 1, Empty),
query_set_id: Id(0, 1),
query_index: 0,
),
Dispatch((2, 3, 7,)),
Expand All @@ -71,10 +71,10 @@
),
),
ResolveQuerySet(
query_set_id: Id(0, 1, Empty),
query_set_id: Id(0, 1),
start_query: 0,
query_count: 1,
destination: Id(0, 1, Empty),
destination: Id(0, 1),
destination_offset: 0,
)
]),
Expand Down
Loading

0 comments on commit c8beade

Please sign in to comment.