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

No-op backend, for application logic + validation testing #5236

Open
kpreid opened this issue Feb 10, 2024 · 0 comments
Open

No-op backend, for application logic + validation testing #5236

kpreid opened this issue Feb 10, 2024 · 0 comments
Labels
area: api Issues related to API surface area: tests Improvements or issues with our test suite type: enhancement New feature or request

Comments

@kpreid
Copy link
Contributor

kpreid commented Feb 10, 2024

Is your feature request related to a problem? Please describe.
I'd like to be able to write #[test]s for code that manages one or more wgpu objects, without needing to make the test conditional on the presence of a GPU or software render driver.

Describe the solution you'd like
I'd like a way to create a Device and Queue that always succeeds, and the resulting device would always allow creating objects such as Textures (subject to wgpu validation checks), but where all operations that would read the results of computations (i.e. mapping buffers for read) always fail since they have no real implementation. Perhaps this would look like a special backend bit to pass to wgpu::Instance::new().

Tests written using this mechanism would be able to test that the application code succeeds on all CPU-side matters while ignoring the GPU state, and also that it does not trigger any wgpu validation errors.

Describe alternatives you've considered
An alternative approach to this problem would be a software renderer backend that's an optional dependency of wgpu (rather than being an OS driver that might be absent), but while that would be nifty, it's more than we need here.

In individual cases, the application code could be modified to allow skipping all wgpu operations, but that would often be awkward and require providing alternative data storage used only for testing (e.g. for Texture::size()).

#2291 "Add a Dummy backend" is similar, but if I understand correctly, is asking only for a way to compile applications with no backends (presumably Instance::request_adapter() would always fail). This feature would subsume that feature.

@cwfitzgerald cwfitzgerald added type: enhancement New feature or request area: api Issues related to API surface area: tests Improvements or issues with our test suite labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface area: tests Improvements or issues with our test suite type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants