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

Arcanization of wgpu core resources #3626

Merged
merged 204 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 161 commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
548cb51
First Arcanization no refcount, no lifetime
gents83 Mar 30, 2023
d685726
Keeping Arc only outside and not inside resource
gents83 Mar 30, 2023
ec28fc3
Merge pull request #1 from gfx-rs/master
gents83 Mar 31, 2023
44413ca
Fixing clippy errors
gents83 Apr 1, 2023
95141e7
Merge branch 'master' of https://github.com/gents83/wgpu
gents83 Apr 1, 2023
a9b3bcb
Removing unneeded replay feature
gents83 Apr 1, 2023
17b8e71
string::new doesn't take any arguments
Elabajaba Apr 2, 2023
c7e1c54
Changed doc to align to moved files
gents83 Apr 2, 2023
60d3070
Merge pull request #2 from Elabajaba/arc-release-mode-fix
gents83 Apr 2, 2023
ecd0cc2
Correct texture view creation for render pass
gents83 Apr 2, 2023
a1b6b81
Merge pull request #3 from gfx-rs/master
gents83 Apr 2, 2023
a4b83a5
Fixing staging buffer issue
gents83 Apr 4, 2023
4961a49
Merge branch 'master' of https://github.com/gents83/wgpu
gents83 Apr 4, 2023
aa4424e
Merge pull request #4 from gfx-rs/master
gents83 Apr 4, 2023
e1c9b91
Fix compiler errors for Metal backend
niklaskorz Apr 7, 2023
9077b43
Fix usage of active_submission_index.fetch_add
niklaskorz Apr 7, 2023
f72ff9d
Fix release build
niklaskorz Apr 7, 2023
669636a
Merge pull request #5 from niklaskorz/master
gents83 Apr 7, 2023
c7b08db
Merge pull request #6 from niklaskorz/atomic-fetch-add
gents83 Apr 7, 2023
c935ea2
Merge pull request #7 from niklaskorz/debug-assertions
gents83 Apr 7, 2023
b8e08db
Merge branch 'trunk' into master
gents83 Apr 7, 2023
0fc93d8
Fixing integration issues
gents83 Apr 7, 2023
2c09b19
Fixing doc, fmt and gles
gents83 Apr 7, 2023
cda59c6
Merge branch 'trunk' into master
gents83 Apr 7, 2023
fd92db5
Missing doc changes
gents83 Apr 7, 2023
b6a5d2a
Added _ due to non-exauhstive pattern addition
gents83 Apr 7, 2023
ea3120e
Avoid using `WasmAbi` functions on WebGPU backend
grovesNL Apr 8, 2023
c6c8259
Clippy
grovesNL Apr 8, 2023
42b1199
Changelog entry
grovesNL Apr 8, 2023
96e1f50
Remove wrongly created license in subfolders
gents83 Apr 9, 2023
e12a5f2
Merge pull request #9 from grovesNL/dynamic-dispatch-workaround
gents83 Apr 9, 2023
df9801b
Updating according to trace::Action::CreateTexture
gents83 Apr 9, 2023
b9d3c59
Moving set_id from registry to storage
gents83 Apr 9, 2023
1c2112f
Expose cleare fence for device polling
gents83 Apr 11, 2023
a9518cd
Merge branch 'trunk' into master
gents83 Apr 11, 2023
4a2ff45
Merge pull request #10 from gfx-rs/trunk
gents83 Apr 12, 2023
ffa0802
Fix format
gents83 Apr 12, 2023
5875645
Merge branch 'master' of https://github.com/gents83/wgpu
gents83 Apr 12, 2023
b0a80ea
Merge branch 'trunk' into master
gents83 Apr 15, 2023
ea90aa4
Integrating (#3686)
gents83 Apr 15, 2023
2f18676
Fixing integration
gents83 Apr 15, 2023
de80b11
Fixing wat on gles
gents83 Apr 15, 2023
e49aff2
Bumping extern libs
gents83 Apr 15, 2023
73fecae
Active submission will drop only its own stuff
gents83 Apr 16, 2023
faf3efb
Increasing wait time for multithreaded test
gents83 Apr 16, 2023
a1f8651
Reverting test and reducing cleanup time
gents83 Apr 16, 2023
6bc0ecf
Separating info from debug to get debug details
gents83 Apr 25, 2023
cd9022a
Merge branch 'trunk' into master
gents83 Apr 25, 2023
f2736e5
Fix merge issue
gents83 Apr 25, 2023
4529f73
Fix clippy wasm
gents83 Apr 25, 2023
8d6f531
Merge pull request #11 from gfx-rs/trunk
gents83 Apr 29, 2023
fbd23cc
Fixing temp suspected clear order
gents83 Apr 29, 2023
6c370d4
Merge branch 'master' of https://github.com/gents83/wgpu
gents83 Apr 29, 2023
2a3c78a
Adding drop to staging buffer
gents83 Apr 29, 2023
011ed1b
Better log info
gents83 Apr 29, 2023
404e888
Active submission index incremented only at submit
gents83 Apr 30, 2023
ddc015c
Fix fmt
gents83 Apr 30, 2023
be6cb83
Merge pull request #12 from gfx-rs/trunk
gents83 Apr 30, 2023
c5280f5
Merge branch 'trunk' into master
gents83 May 4, 2023
7778e1a
Drain submissions again
gents83 May 4, 2023
feae1b5
Merge branch 'trunk' into master
gents83 May 20, 2023
4640ec0
Integrating fix multiview rendering in resource.rs
gents83 May 20, 2023
15e3145
Readding licenses and helper functions
gents83 May 20, 2023
a0af81a
Fixing format
gents83 May 20, 2023
106b51b
Fixing wrong merge of create_render_bundle_error
gents83 May 23, 2023
dbd708e
Merge pull request #14 from gfx-rs/trunk
gents83 May 23, 2023
07c14e6
Use symlinks for wgpu{,-core,-hal,-types}/LICENSE.{APACHE,MIT}.
jimblandy May 22, 2023
3a5b0bd
Merge branch 'trunk' into arcanization
jimblandy May 24, 2023
cf74dc2
Merge branch 'trunk' into arcanization
jimblandy May 24, 2023
a07a1b3
Remove ResourceMetadataProvider::Resource and logs
gents83 May 27, 2023
9af2d0c
Adding some doc info
gents83 May 27, 2023
c498c28
Add missing dependency device\adapter
gents83 Jun 5, 2023
f9acbd3
Removing useless typo code
gents83 Jun 5, 2023
0bffddb
Merge branch 'trunk' into master
gents83 Jun 5, 2023
a3f4643
Fix merge conflicts errors
gents83 Jun 5, 2023
bfca2cd
Fix format
gents83 Jun 5, 2023
8850c89
Removing wait of specific submission index
gents83 Jun 6, 2023
9b47cb3
Merge branch 'trunk' into master
gents83 Jun 6, 2023
3a6fdc7
rustup update
gents83 Jun 6, 2023
0ebf406
Merge branch 'trunk' into master
gents83 Jun 6, 2023
e0e2297
Document abandoned buffer conditions more explicitly.
jimblandy May 31, 2023
252fbf3
Merge branch 'trunk' into master
gents83 Jun 10, 2023
8bdc4b9
Fixing CI
gents83 Jun 10, 2023
8c0de8c
Merge branch 'trunk' into master
gents83 Jun 17, 2023
dcf751b
Move trackers locks after the pending_writes lock
gents83 Jun 17, 2023
e219604
Adding additional doc
gents83 Jun 17, 2023
2ce35f1
Adding deadlock detection in tests
gents83 Jun 17, 2023
c6e9de8
Fixed wrong check
gents83 Jun 17, 2023
5b34df5
Merge branch 'trunk' into master
gents83 Jun 24, 2023
7469572
Updating changelog
gents83 Jun 24, 2023
91d872e
Merge branch 'trunk' into master
gents83 Jul 7, 2023
f2ca336
Using mutex on pending_writes
Jul 7, 2023
9243a92
Pending writes locked before textures transitions
Jul 7, 2023
b2113b6
Merge branch 'trunk' into master
gents83 Jul 15, 2023
52cf370
Fixing merge integration resolve conflicts
Jul 15, 2023
71b2af6
Fix fmt
Jul 15, 2023
a65bb07
Adding more info on resource tracking
gents83 Jul 24, 2023
dcea4dd
Merge branch 'trunk' into master
gents83 Jul 24, 2023
633035f
Fix fmt
gents83 Jul 24, 2023
94801a5
Aligning to workspace
gents83 Jul 24, 2023
94180a3
Merge branch 'trunk' into master
gents83 Jul 27, 2023
6babd06
Clearing temp_suspected once moved to suspected
gents83 Jul 27, 2023
2e0baad
Merge branch 'trunk' into master
gents83 Jul 27, 2023
d5943e7
Restoring Action::CreateTexture for Player
gents83 Jul 31, 2023
0cb20d4
Merge branch 'trunk' into master
gents83 Jul 31, 2023
c7ed2c1
Merge branch 'trunk' into master
gents83 Aug 1, 2023
b763431
Fix memleaks due to duplicated items + drain usage
gents83 Aug 1, 2023
7b28fe4
Adding proper release of surface texture view
gents83 Aug 2, 2023
8da3493
Merge branch 'trunk' into master
gents83 Aug 17, 2023
481c914
Fix integration issues
gents83 Aug 17, 2023
1312b26
Using always is_unique()
gents83 Aug 17, 2023
6690fe4
Queue is now keeping device alive till needed
gents83 Aug 18, 2023
4b93702
RenderBundle has strong reference to its device
gents83 Aug 18, 2023
a483132
Removing check for test on wasm
gents83 Aug 18, 2023
27d2efa
Merge branch 'trunk' into master
gents83 Aug 18, 2023
586c1bb
Apply cargo fmt
gents83 Aug 18, 2023
b175774
Let Presentation hold a strong reference to its Device.
jimblandy Aug 19, 2023
028726e
Merge pull request #15 from jimblandy/presentation-arc-device
gents83 Aug 19, 2023
f71b2dc
Introducing AnySurface
gents83 Aug 19, 2023
007a53d
Fixing clippy
gents83 Aug 19, 2023
4f46d49
Merge branch 'trunk' into master
gents83 Aug 19, 2023
c108c9a
When clearing a Hub, remember to remove the surface's presentation.
jimblandy Aug 19, 2023
e65bdd2
Improving error msg
gents83 Aug 25, 2023
38eb9ac
TypeId should be debuggable
gents83 Aug 25, 2023
50e326d
Merge branch 'master' of https://github.com/gents83/wgpu into wgpu/ma…
gents83 Aug 25, 2023
f974beb
Improving log
gents83 Aug 25, 2023
ad03f83
Merge branch 'trunk' into master
gents83 Aug 26, 2023
579edb6
Fix integration issues
gents83 Aug 26, 2023
b9b1556
Removing valid and adding is_valid
gents83 Aug 26, 2023
865910f
Merge branch 'master' into Creating-AnySurface
gents83 Aug 26, 2023
9e2a0ed
Merge pull request #16 from gents83/Creating-AnySurface
gents83 Aug 26, 2023
da588ff
Keep resources in registry till user release them
gents83 Aug 26, 2023
1765710
First anysurface will win
gents83 Aug 26, 2023
c4f150d
Fixing locking
gents83 Aug 26, 2023
4f1bcab
Fix compilation error
gents83 Aug 26, 2023
969e411
Fixing wasm32
gents83 Aug 27, 2023
27d5a68
Fix wasm compilation
gents83 Aug 27, 2023
7394fd7
Storage is now only for user - wgpu use arcs
gents83 Sep 8, 2023
c235de4
Merge branch 'trunk' into master
gents83 Sep 8, 2023
490b2b7
Fixing integration issues and merge conflicts
gents83 Sep 8, 2023
451dfba
Fixing clippy wasm32
gents83 Sep 8, 2023
6839dba
Fixing mem_leaks on wasm
gents83 Sep 8, 2023
058c8af
Updating doc
gents83 Sep 8, 2023
6a66746
Fix format
gents83 Sep 9, 2023
f83fdad
Fix fmt
gents83 Sep 9, 2023
c5aa05f
Improving resource dropping in device poll
gents83 Sep 10, 2023
9a24345
Add release of buffer and description on texture
gents83 Sep 13, 2023
e52c747
Fix format
gents83 Sep 16, 2023
90c118d
Merge branch 'trunk' into master
gents83 Sep 16, 2023
45a618f
Fix merge conflicts and improve id mngmnt
gents83 Sep 16, 2023
88dc35c
Fixing surface present issue
gents83 Sep 18, 2023
8ca3cb0
Fixing texture leaking due to clear view
gents83 Sep 19, 2023
0220754
Merge branch 'trunk' into master
gents83 Sep 19, 2023
d1fe60c
QuerySet error drop not failing
gents83 Sep 19, 2023
fb13cc8
Better resource triage_suspected
gents83 Sep 21, 2023
ac30622
Fix test
gents83 Sep 22, 2023
4e68258
Fix format
gents83 Sep 22, 2023
0eac205
Improving tracker management
gents83 Sep 23, 2023
3530dcb
Releasing bind group resources fix missing leaks
gents83 Sep 23, 2023
b2d5462
Merge branch 'trunk' into master
gents83 Oct 1, 2023
d4a8689
Resolve merge conflicts
gents83 Oct 1, 2023
af51987
Fixing command order issue
gents83 Oct 7, 2023
c66473a
Merge branch 'trunk' into master
gents83 Oct 7, 2023
877ef94
Fix integration and simply layout groups dedup
gents83 Oct 7, 2023
a7de4da
Fixing clippy doc
gents83 Oct 7, 2023
b31ddb0
Merge branch 'trunk' into master
gents83 Oct 8, 2023
5d08672
Fix clippy fmt
gents83 Oct 8, 2023
b7e518a
Fix wrong checks on is_valid and is_incompatible
gents83 Oct 8, 2023
b997eaf
Merge branch 'trunk' into master
gents83 Oct 9, 2023
cbf8860
Applying cargo fmt
gents83 Oct 9, 2023
cc4d15c
Merge branch 'trunk' into master
gents83 Oct 9, 2023
804f1da
Fix integration issues
gents83 Oct 9, 2023
b33c1c2
Merge branch 'trunk' into master
gents83 Oct 9, 2023
092fd3e
Merge branch 'trunk' into master
gents83 Oct 12, 2023
41f8171
Fix format
gents83 Oct 12, 2023
ad0109a
Fix integration
gents83 Oct 12, 2023
dbde6dd
Fix merge
gents83 Oct 12, 2023
2af22cd
Fix compilation
gents83 Oct 12, 2023
d5fdf2c
Merge branch 'trunk' into master
gents83 Oct 14, 2023
22b1471
Fix integration
gents83 Oct 14, 2023
2fb0218
Removing wrong merge
gents83 Oct 14, 2023
12d16ee
Fixing issue on zero_init_texture test
gents83 Oct 15, 2023
b0984ef
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Oct 21, 2023
7f727b0
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Oct 23, 2023
c6e1e28
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Oct 25, 2023
b140f6a
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Oct 30, 2023
93cffd2
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Oct 30, 2023
535011b
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 3, 2023
aa1a05f
Fixing double lock on buffer destroy + test added
gents83 Nov 5, 2023
1198114
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 5, 2023
ae0b777
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 10, 2023
673af75
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 10, 2023
2710cdd
Merge branch 'trunk' into master
gents83 Nov 10, 2023
8bc7140
Merge branch 'master' of https://github.com/gents83/wgpu into wgpu/ma…
gents83 Nov 10, 2023
2cfa766
Fixing wrong merge
gents83 Nov 10, 2023
090c9c3
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 13, 2023
715bd00
Fixing changelog integration
gents83 Nov 13, 2023
b6d61da
Fix insert_impl and take_and_mark_destroyed
gents83 Nov 13, 2023
c8a60e2
Fix fmt
gents83 Nov 13, 2023
ff042c4
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu
Nov 16, 2023
24393a4
Merge branch 'trunk' of https://github.com/gfx-rs/wgpu into wgpu/master
gents83 Nov 18, 2023
0e437be
Updated changelog
gents83 Nov 18, 2023
724fc1a
Shorten lock durations to avoid deadlocks
SludgePhD Nov 18, 2023
e4cec38
Merge pull request #17 from SludgePhD/arcanization
gents83 Nov 19, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
env:
CARGO_INCREMENTAL: false
CARGO_TERM_COLOR: always
RUST_LOG: info
RUST_BACKTRACE: full
RUST_LOG: info #needed to understand what's going on when tests fail
MSRV: 1.65
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Bottom level categories:
## Unreleased

### Major changes
- Arcanization of wgpu core resources: Removed 'Token' and 'LifeTime' related management,
removed 'RefCount' and 'MultiRefCount' in favour of using only 'Arc' internal reference count, removing mut from resources and added instead internal members locks on demand or atomics operations, resources now implement Drop and destroy stuff when last 'Arc' resources is released, resources hold an 'Arc' in order to be able to implement Drop, resources have an utility to retrieve the id of the resource itself, removed all guards and just retrive the 'Arc' needed on-demand to unlock registry of resources asap removing locking from hot paths. By @gents83 in [#3626](https://github.com/gfx-rs/wgpu/pull/3626) and tnx also to @jimblandy

#### Pass timestamp queries

Expand Down Expand Up @@ -197,12 +199,17 @@ By @fornwall in [#3904](https://github.com/gfx-rs/wgpu/pull/3904) and [#3905](ht
#### Misc Breaking Changes

- Change `AdapterInfo::{device,vendor}` to be `u32` instead of `usize`. By @ameknite in [#3760](https://github.com/gfx-rs/wgpu/pull/3760)
- Remove the `backend_bits` parameter in `initialize_adapter_from_env` and `initialize_adapter_from_env_or_default` - use [InstanceDescriptor::backends](https://docs.rs/wgpu/latest/wgpu/struct.InstanceDescriptor.html#structfield.backends) instead. By @fornwall in [#3904](https://github.com/gfx-rs/wgpu/pull/3904)

#### DX12

- Increase the `max_storage_buffers_per_shader_stage` and `max_storage_textures_per_shader_stage` limits based on what the hardware supports. by @Elabajaba in [#3798]https://github.com/gfx-rs/wgpu/pull/3798
- Add a `compatible_surface` parameter to `initialize_adapter_from_env` and use that to make `initialize_adapter_from_env_or_default` always respect its `compatible_surface` parameter. By @fornwall in [#3905](https://github.com/gfx-rs/wgpu/pull/3905)
gents83 marked this conversation as resolved.
Show resolved Hide resolved
gents83 marked this conversation as resolved.
Show resolved Hide resolved

### Changes

- Added support for importing external buffers using `buffer_from_raw` (Dx12, Metal, Vulkan) and `create_buffer_from_hal`. By @AdrianEddy in [#3355](https://github.com/gfx-rs/wgpu/pull/3355)


#### Vulkan

- Work around [Vulkan-ValidationLayers#5671](https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671) by ignoring reports of violations of [VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912](https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912). By @jimblandy in [#3809](https://github.com/gfx-rs/wgpu/pull/3809).
Expand Down
29 changes: 26 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deno_webgpu/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn op_webgpu_buffer_get_map_async(
2 => wgpu_core::device::HostMap::Write,
_ => unreachable!(),
},
callback: wgpu_core::resource::BufferMapCallback::from_rust(callback),
callback: Some(wgpu_core::resource::BufferMapCallback::from_rust(callback)),
}
))
.err();
Expand Down
4 changes: 1 addition & 3 deletions deno_webgpu/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ impl From<DeviceError> for WebGpuError {
match err {
DeviceError::Lost => WebGpuError::Lost,
DeviceError::OutOfMemory => WebGpuError::OutOfMemory,
DeviceError::ResourceCreationFailed | DeviceError::Invalid => {
WebGpuError::Validation(fmt_err(&err))
}
_ => WebGpuError::Validation(fmt_err(&err)),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,11 @@ pub async fn op_webgpu_request_device(
limits: required_limits.unwrap_or_default(),
};

let (device, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(
let (device, _queue, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(
adapter,
&descriptor,
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
(),
()
));
if let Some(err) = maybe_err {
Expand Down
5 changes: 3 additions & 2 deletions player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() {
IdentityPassThroughFactory,
wgt::InstanceDescriptor::default(),
);
let mut command_buffer_id_manager = wgc::identity::IdentityManager::default();
let mut command_buffer_id_manager = wgc::identity::IdentityManager::new();

#[cfg(feature = "winit")]
let surface = global.instance_create_surface(
Expand Down Expand Up @@ -81,10 +81,11 @@ fn main() {
let info = gfx_select!(adapter => global.adapter_get_info(adapter)).unwrap();
log::info!("Picked '{}'", info.name);
let id = wgc::id::TypedId::zip(1, 0, backend);
let (_, error) = gfx_select!(adapter => global.adapter_request_device(
let (_, _, error) = gfx_select!(adapter => global.adapter_request_device(
adapter,
&desc,
None,
id,
id
));
if let Some(e) = error {
Expand Down
41 changes: 13 additions & 28 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,22 @@

use wgc::device::trace;

use std::{borrow::Cow, fmt::Debug, fs, marker::PhantomData, path::Path};
use std::{borrow::Cow, fs, path::Path};

#[derive(Debug)]
pub struct IdentityPassThrough<I>(PhantomData<I>);
pub struct IdentityPassThroughFactory;

impl<I: Clone + Debug + wgc::id::TypedId> wgc::identity::IdentityHandler<I>
for IdentityPassThrough<I>
{
impl<I: wgc::id::TypedId> wgc::identity::IdentityHandlerFactory<I> for IdentityPassThroughFactory {
type Input = I;
fn process(&self, id: I, backend: wgt::Backend) -> I {
let (index, epoch, _backend) = id.unzip();
I::zip(index, epoch, backend)
}
fn free(&self, _id: I) {}
}

pub struct IdentityPassThroughFactory;

impl<I: Clone + Debug + wgc::id::TypedId> wgc::identity::IdentityHandlerFactory<I>
for IdentityPassThroughFactory
{
type Filter = IdentityPassThrough<I>;
fn spawn(&self) -> Self::Filter {
IdentityPassThrough(PhantomData)
fn input_to_id(id_in: Self::Input) -> I {
id_in
}
}
impl wgc::identity::GlobalIdentityHandlerFactory for IdentityPassThroughFactory {
fn ids_are_generated_in_wgpu() -> bool {

fn autogenerate_ids() -> bool {
false
}
}
impl wgc::identity::GlobalIdentityHandlerFactory for IdentityPassThroughFactory {}

pub trait GlobalPlay {
fn encode_commands<A: wgc::hal_api::HalApi>(
Expand All @@ -53,7 +38,7 @@ pub trait GlobalPlay {
device: wgc::id::DeviceId,
action: trace::Action,
dir: &Path,
comb_manager: &mut wgc::identity::IdentityManager,
comb_manager: &mut wgc::identity::IdentityManager<wgc::id::CommandBufferId>,
);
}

Expand Down Expand Up @@ -168,10 +153,10 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
device: wgc::id::DeviceId,
action: trace::Action,
dir: &Path,
comb_manager: &mut wgc::identity::IdentityManager,
comb_manager: &mut wgc::identity::IdentityManager<wgc::id::CommandBufferId>,
) {
use wgc::device::trace::Action;
log::info!("action {:?}", action);
log::debug!("action {:?}", action);
//TODO: find a way to force ID perishing without excessive `maintain()` calls.
match action {
Action::Init { .. } => {
Expand Down Expand Up @@ -269,7 +254,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.bind_group_drop::<A>(id);
}
Action::CreateShaderModule { id, desc, data } => {
log::info!("Creating shader from {}", data);
log::debug!("Creating shader from {}", data);
let code = fs::read_to_string(dir.join(&data)).unwrap();
let source = if data.ends_with(".wgsl") {
wgc::pipeline::ShaderModuleSource::Wgsl(Cow::Owned(code.clone()))
Expand Down Expand Up @@ -390,7 +375,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
let (encoder, error) = self.device_create_command_encoder::<A>(
device,
&wgt::CommandEncoderDescriptor { label: None },
comb_manager.alloc(device.backend()),
comb_manager.process(device.backend()),
);
if let Some(e) = error {
panic!("{e}");
Expand Down
2 changes: 1 addition & 1 deletion player/tests/data/zero-init-texture-binding.ron
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
format: "rgba8unorm",
usage: 9, // STORAGE + COPY_SRC
view_formats: [],
)),
)),
CreateTextureView(
id: Id(1, 1, Empty),
parent_id: Id(1, 1, Empty),
Expand Down
23 changes: 12 additions & 11 deletions player/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,50 +84,51 @@ impl Test<'_> {
test_num: u32,
) {
let backend = adapter.backend();
let device = wgc::id::TypedId::zip(test_num, 0, backend);
let (_, error) = wgc::gfx_select!(adapter => global.adapter_request_device(
let device_id = wgc::id::TypedId::zip(test_num, 0, backend);
let (_, _, error) = wgc::gfx_select!(adapter => global.adapter_request_device(
adapter,
&wgt::DeviceDescriptor {
label: None,
features: self.features,
limits: wgt::Limits::default(),
},
None,
device
device_id,
device_id
));
if let Some(e) = error {
panic!("{:?}", e);
}

let mut command_buffer_id_manager = wgc::identity::IdentityManager::default();
let mut command_buffer_id_manager = wgc::identity::IdentityManager::new();
println!("\t\t\tRunning...");
for action in self.actions {
wgc::gfx_select!(device => global.process(device, action, dir, &mut command_buffer_id_manager));
wgc::gfx_select!(device_id => global.process(device_id, action, dir, &mut command_buffer_id_manager));
}
println!("\t\t\tMapping...");
for expect in &self.expectations {
let buffer = wgc::id::TypedId::zip(expect.buffer.index, expect.buffer.epoch, backend);
wgc::gfx_select!(device => global.buffer_map_async(
wgc::gfx_select!(device_id => global.buffer_map_async(
buffer,
expect.offset .. expect.offset+expect.data.len() as wgt::BufferAddress,
wgc::resource::BufferMapOperation {
host: wgc::device::HostMap::Read,
callback: wgc::resource::BufferMapCallback::from_rust(
callback: Some(wgc::resource::BufferMapCallback::from_rust(
Box::new(map_callback)
),
)),
}
))
.unwrap();
}

println!("\t\t\tWaiting...");
wgc::gfx_select!(device => global.device_poll(device, wgt::Maintain::Wait)).unwrap();
wgc::gfx_select!(device_id => global.device_poll(device_id, wgt::Maintain::Wait)).unwrap();

for expect in self.expectations {
println!("\t\t\tChecking {}", expect.name);
let buffer = wgc::id::TypedId::zip(expect.buffer.index, expect.buffer.epoch, backend);
let (ptr, size) =
wgc::gfx_select!(device => global.buffer_get_mapped_range(buffer, expect.offset, Some(expect.data.len() as wgt::BufferAddress)))
wgc::gfx_select!(device_id => global.buffer_get_mapped_range(buffer, expect.offset, Some(expect.data.len() as wgt::BufferAddress)))
.unwrap();
let contents = unsafe { slice::from_raw_parts(ptr, size as usize) };
let expected_data = match expect.data {
Expand Down Expand Up @@ -155,7 +156,7 @@ impl Test<'_> {
}
}

wgc::gfx_select!(device => global.clear_backend(()));
wgc::gfx_select!(device_id => global.clear_backend(()));
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ wgt.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
nv-flip.workspace = true
parking_lot = { workspace = true, features = ["deadlock_detection"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log.workspace = true
Expand Down
Loading