Commit Graph

574 Commits

Author SHA1 Message Date
Erich Gubler
4fa2fbb5aa fix(dx12): don't depend on BG{,L} entry order
This isn't guaranteed by `wgpu-core`; we should try to match by binding
slot index instead.
2024-04-01 17:51:36 -04:00
Andreas Reich
ed7d9de439
Fix indexed drawing with RenderBundle (#5441)
* enhance vertex_indices test to also run with render bundles

* fix render bundle index limit check

* changelog entry
2024-03-30 10:19:17 +01:00
李祥煜
b34219ca21
Implement the device_set_device_lost_callback method for ContextWebGpu (#5438)
* impl device_set_device_lost_callback for ContextWebGpu

* merge changelog

---------

Co-authored-by: lixiangyu.ava <lixiangyu.ava@bytedance.com>
2024-03-26 15:12:50 +00:00
Lukas Herzberger
a9ccbc7dea
Add support for storage texture access modes ReadOnly and ReadWrite on WebGPU backend (#5434)
* add support for all storage texture access modes

* update changelog

* fix typo
2024-03-26 14:57:24 +01:00
Sludge
6b996dd9c7
Avoid recursive snatch lock acquisitions (#5426)
* Avoid recursive snatch lock acquisitions

* Always acquire the snatch lock before the fence lock

* Address review comments

* Add changelog entry
2024-03-23 21:29:00 +01:00
robtfm
ed95dfe9b4
Pool tracker vecs (#5414)
* pool tracker vecs

* pool

* ci

* move pool to device

* use pool ref, cleanup and comment

* suspect all the future suspects (#5413)

* suspect all the future suspects

* changelog

* changelog

* review feedback

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-03-23 11:42:08 +00:00
Brad Werth
00e0e72596
Invoke a DeviceLostClosure immediately if set on an invalid device. (#5358)
Invoke a DeviceLostClosure immediately if set on an invalid device.

To make the device invalid, this defines an explicit, test-only method
make_invalid. It also modifies calls that expect to always retrieve a
valid device.

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-03-21 13:33:25 -04:00
robtfm
152a94bc6c
suspect all the future suspects (#5413)
* suspect all the future suspects

* changelog
2024-03-18 10:53:41 -04:00
Andreas Reich
e68e62801f
Add patch release notes from 0.19.1/2/3 and remove redundant changelog entries (#5405) 2024-03-16 18:47:56 -04:00
Bruce Mitchener
fe91958010
Give short example of WGSL push_constant syntax. (#5393) 2024-03-15 21:20:21 -04:00
Patrick Cleavelin
a63bec8cd6 add cli arg to choose metal version 2024-03-15 10:39:40 +01:00
stefnotch
6a5418b93f
Fix 5385 by updating the documentation (#5386)
* Fix 5385 by updating the documentation

* Update changelog
2024-03-13 21:30:50 -04:00
vero
4e6f873da5
Add shader I64 and U64 support (#5154)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-03-12 12:34:06 +01:00
Eshed Schacham
8e15707631
gles: fix crash when holding multiple devices on wayland/surfaceless. (#5351) 2024-03-10 21:12:51 +01:00
Nathan Adams
f78e2f7800
GL actually supports DEPTH32FLOAT_STENCIL8 (#5370) 2024-03-10 20:56:58 +01:00
caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat
5e1227343a
docs: mention primitive restart in the description of strip_index_format (#5350)
* docs: mention primitive restart in the description of strip_index_format

* update changelog for #5350
2024-03-09 10:20:23 +01:00
Nathan Adams
2234fd681d
Cache MAX_SAMPLES on gles backend (#5346) 2024-03-09 10:16:31 +01:00
Nathan Adams
f86898ffeb
Don't create shader-clear program on GLES if it's not needed (#5348)
* Store GLES shader clear program in its own struct

* Make shader_clear_program optional on GLES, only created if needed
2024-03-08 20:36:12 +01:00
Erik Zivkovic
d417433e0c Naga: GLSL 410 does not support layout(binding = ...)
Naga assumed that GLSL 410 supported layout(binding = ...) but it does not,
it only supports layout(location = ...). It is not possible to enable only
layout(location = ...) currently, so we need to predicate the feature on GLSL
420 instead.
2024-03-07 12:28:26 +01:00
Daniel McNab
5162fd440d Add a changelog entry 2024-03-06 12:47:42 -08:00
multisn8
badb3c88ea
feat: const feature defaults (#5343)
* feat: make downlevel feature defaults const

* docs: add 5343 to changelog
2024-03-05 15:01:38 +01:00
Erik Živković
19cc9d9776
Revert "Add OpenGL support for TEXTURE_FORMAT_16BIT_NORM on supported versions (#5330)" (#5339)
This reverts commit 352cb3d40b.
2024-03-04 09:19:57 +01:00
Erik Živković
352cb3d40b
Add OpenGL support for TEXTURE_FORMAT_16BIT_NORM on supported versions (#5330) 2024-03-03 21:38:38 +00:00
Erik Živković
f0ed4cf520
Add support for running on OpenGL 4.1 with a core profile on macOS (#5331)
When running wgpu with an OpenGL context on macOS that is created with a core
profile and with the forward-compatibility bit set, the MAX_VARYING_COMPONENTS
constant returns 0 when queried. The default value is 60, so we return the
default value if the query returns 0.

We also need to use `#version 140` on macOS since `#version 130` isn't accepted.
Since `#version 140` should be available from OpenGL 3.1, we use that everywhere.
That way we don't need any specific macOS flags or features.
2024-03-03 22:22:20 +01:00
Eshed Schacham
2d8d045453
wgpu-hal: add ndk-sys dependency to fix linking error. (#5326) 2024-03-01 21:16:09 +00:00
Connor Fitzgerald
aaf6db6a3d
Vendor WebGPU Bindings from web_sys (#5325) 2024-03-01 21:13:14 +00:00
Connor Fitzgerald
a5c0181c3a
Bitfield Fixes (#5305) 2024-02-29 20:50:42 +00:00
Connor Fitzgerald
8129897ccb Nested loop test 2024-02-28 13:54:27 +01:00
Erich Gubler
023b0e063f feat!: make ProgrammableStage::entry_point optional in wgpu-core 2024-02-27 13:57:17 -05:00
Nicolas Silva
c77b4d3f56
Use a unique tracker index per resource instead of the ID in trackers (#5244)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-26 20:25:12 +00:00
Connor Fitzgerald
38419a9cf2
Fix Integer Clamp (#5300)
* Fix Integer Clamp

* Changelog
2024-02-26 20:28:23 +01:00
Erich Gubler
9747a0ed23 fix: always check buffer clear offset for OOB
Fuzz testing in Firefox encountered crashes for calls of
`Global::command_encoder_clear_buffer` where:

* `offset` is greater than `buffer.size`, but…
* `size` is `None`.

Oops! We should _always_ check this (i.e., even when `size` is `None`),
because we have no guarantee that `offset` and the fallback value of
`size` is in bounds. 😅 So, we change validation here to unconditionally
compute `size` and run checks we previously gated behind `if let
Some(size) = size { … }`.

For convenience, the spec. link for this method:
<https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-clearbuffer>
2024-02-26 09:32:26 -05:00
Bartłomiej Maryńczak
2e9ee0aa56
[wgpu-hal.gles] Error log for failed GLES heuristics (#5266)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-19 20:33:47 +00:00
Nicolas Silva
004e3efe84
Simplify the ID allocation in IdentityValues (#5229)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-15 20:55:55 +00:00
Imbris
b704132b4c Remove unnecessary "gl_PerVertex" name check so unused builtins will be
handled even when this name is not in the input SPIRV.
2024-02-15 18:12:25 +01:00
Erich Gubler
18b7904b8e fix: discard cmd. enc. buf. on wgpu_core::Global::command_encoder_drop 2024-02-15 10:45:32 -05:00
Nicolas Silva
e4ef3b401a
Add an advanced_debugging preset including wgpu base validation (#5248)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-02-13 16:42:02 +00:00
Andreas Reich
f350f28c35
Separate native-only feature for wgpu::CommandEncoder::write_timestamp (#5188)
* split out TIMESTAMP_QUERY_INSIDE_ENCODERS from TIMESTAMP_QUERY

* changelog entry

* update changelog change number

* fix web warnings

* single line changelog

* note on followup issue
2024-02-13 16:03:33 +00:00
Erich Gubler
95c026b2df docs: note that GPU_BASED_VALIDATION implies VALIDATION 2024-02-12 10:23:07 -05:00
Erich Gubler
31ac63ce3e feat(vulkan): enable GPU-based validation for Vulkan backend
If [`VK_LAYER_KHRONOS_validation`] is present, and it supports
[`VK_EXT_validation_features`], we can configure it with another instance
creation info. element of type [`VkValidationFeaturesEXT`] to enable
GPU-based validation. Wire `InstanceFlags::GPU_BASED_VALIDATION` to do
this in the Vulkan backend. It's even already finding issues in our
`examples` and other tests! But…we'd like to handle those later, since
this is so important for users. So, I've broken that out to separate
issues. The instances we're aware of:

* `water` is running into sync. validation issues: see
  <https://github.com/gfx-rs/wgpu/issues/5231>
* `wgpu_test::shader::struct_layout::uniform_input` is failing to
    instrument shaders now; see
    <https://github.com/gfx-rs/wgpu/issues/5245>

It is apparent from this and the [DX12 implementation of GPU-based
validation] that we will need to communicate clearly to users that
`InstanceFlags::GPU_BASED_VALIDATION` implies
`InstanceFlags::VALIDATION`. Not all backends enforce this yet; I have
[split out this work][follow-up for flag implication].

Note that `VK_EXT_validation_features` has been deprecated in favor of
the more general layer configuration mechanism offered by
[`VK_EXT_layer_settings`].

[DX12 implementation of GPU-based validation]: https://github.com/gfx-rs/wgpu/pull/5146
[`VK_EXT_layer_settings`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_layer_settings.html
[`VK_EXT_validation_features`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_validation_features.html
[`VK_LAYER_KHRONOS_validation`]:https://vulkan.lunarg.com/doc/sdk/1.3.275.0/linux/khronos_validation_layer.html
[`VkValidationFeaturesEXT`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkValidationFeaturesEXT.html
[follow-up for flag implication]: https://github.com/gfx-rs/wgpu/pull/5232
2024-02-12 10:23:07 -05:00
Bruce Mitchener
665c075fa0
Remove TextureInner::Surface::has_work. (#5200)
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes #3189.

This flag was added in #1892 with a note that it was going to be
temporary until #1688 landed.
2024-02-09 11:36:24 +00:00
David Huculak
245d2da2fd
add test that verifies that we can drop the queue before using the device to create a command encoder (#5211) 2024-02-09 12:16:48 +01:00
Jim Blandy
4af531cf69
[wgpu-core] Compute minimum binding size correctly for arrays. (#5222)
* [wgpu-core] Add tests for minimum binding size validation.

* [wgpu-core] Compute minimum binding size correctly for arrays.

In early versions of WGSL, `storage` or `uniform` global variables had
to be either structs or runtime-sized arrays. This rule was relaxed,
and now globals can have any type; Naga automatically wraps such
variables in structs when required by the backend shading language.

Under the old rules, whenever wgpu-core saw a `storage` or `uniform`
global variable with an array type, it could assume it was a
runtime-sized array, and take the stride as the minimum binding size.
Under the new rules, wgpu-core must consider fixed-sized and
runtime-sized arrays separately.
2024-02-09 03:08:01 +00:00
Christian Schwarz
2382c8e74f
Fix glsl backend errors regarding samplerCubeArrayShadow (#5171)
* add GL_EXT_texture_shadow_lod feature detection

* allow more cases of cube depth texture sampling in glsl

* add test for sampling a cubemap array depth texture with lod

* add test for chosing GL_EXT_texture_shadow_lod over the grad workaround if instructed

* add changelog entry for GL_EXT_texture_shadow_lod

* fix criteria for requiring and using TEXTURE_SHADOW_LOD

* require gles 320 for textureSampling over cubeArrayShadow

* prevent false positives in TEXTURE_SHADOW_LOD in checks

* make workaround_lod_with_grad usecase selection less context dependant

* move 3d array texture error into the validator

* correct ImageSample logic errors
2024-02-08 18:27:58 +01:00
Connor Fitzgerald
faed98b45c
Add typos to Repository CI (#5191)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-02-05 12:30:29 -05:00
Connor Fitzgerald
d0c52d70fd
Ord for Id (#5176) 2024-02-01 09:29:34 +01:00
Andreas Reich
62cc81cbfd
Allow wgpu::Instance to report which backends were enabled (#5167)
* Replace `Instance::any_backend_feature_enabled` with `Instance::enabled_backend_features` which reports all available backends instead of just reporting if none is available.

* add changelog entry

* update enabled_backend_features in doc

* fix not enabling any backend on android, fix related doc issues
2024-01-31 09:17:59 +00:00
Andreas Reich
45957088ad
Fix panic when creating a surface while no backend is available (#5166)
* Fix panic when creating a surface while no backend is available

* changelog entry
2024-01-31 08:48:33 +00:00
Brad Werth
0888a630a0
Call device lost callback when it is replaced, or when the global is dropped. (#5168)
This fixes two cases where a DeviceLostClosureC might not be consumed
before it is dropped, which is a requirement:

1) When the closure is replaced, this ensures the to-be-dropped closure
is invoked.
2)  When the global is dropped, this ensures that the closure is invoked
before it is dropped.

The first of these two cases is tested in a new test,
DEVICE_LOST_REPLACED_CALLBACK. The second case has a stub,
always-skipped test, DROPPED_GLOBAL_THEN_DEVICE_LOST. The test is
always-skipped because there does not appear to be a way to drop the
global from within a test. Nor is there any other way to reach
Device.prepare_to_die without having first dropping the device.
2024-01-31 08:15:45 +01:00
Erich Gubler
c28466cc21 feat: make GPU-based validation opt-in with new InstanceFlags::GPU_BASED_VALIDATION 2024-01-30 21:57:01 -05:00
Erich Gubler
c559be933b feat(const_eval): impl. min 2024-01-30 10:53:03 +01:00
Erich Gubler
abcc6ddff3 feat(const_eval): impl. max 2024-01-30 10:53:03 +01:00
Erich Gubler
18f50092a6 feat(const_eval): impl. trunc 2024-01-30 10:53:03 +01:00
Erich Gubler
2d3005b745 feat(const_eval): impl. sign with new component_wise_signed 2024-01-30 10:53:03 +01:00
Erich Gubler
0bd5f77601 feat(const_eval): impl. reverseBits 2024-01-30 10:53:03 +01:00
Erich Gubler
7dedd002c0 feat(const_eval): impl. radians 2024-01-30 10:53:03 +01:00
Erich Gubler
e6f6eb7036 feat(const_eval): impl. log2 2024-01-30 10:53:03 +01:00
Erich Gubler
39cb92cf88 feat(const_eval): impl. log 2024-01-30 10:53:03 +01:00
Erich Gubler
4db02d1962 feat(const_eval): impl. fract 2024-01-30 10:53:03 +01:00
Erich Gubler
fc04518750 feat(const_eval): impl. inverseSqrt 2024-01-30 10:53:03 +01:00
Erich Gubler
19f5e4d5e4 feat(const_eval): impl. fma 2024-01-30 10:53:03 +01:00
Erich Gubler
7b274fc161 feat(const_eval): impl. exp2 2024-01-30 10:53:03 +01:00
Erich Gubler
0f8adae123 feat(const_eval): impl. degrees 2024-01-30 10:53:03 +01:00
Erich Gubler
01d02caca3 feat(const_eval): impl. exp 2024-01-30 10:53:03 +01:00
Erich Gubler
66fd1872ab feat(const_eval): impl. countTrailingZeros 2024-01-30 10:53:03 +01:00
Erich Gubler
2ccc4f49ee feat(const_eval): impl. countOneBits 2024-01-30 10:53:03 +01:00
Erich Gubler
ea044f039c feat(const_eval): impl. countLeadingZeros with new component_wise_concrete_int 2024-01-30 10:53:03 +01:00
Erich Gubler
7f70df0c47 feat(const_eval): impl. floor 2024-01-30 10:53:03 +01:00
Erich Gubler
a05cc37e3c feat(const_eval): impl. ceil 2024-01-30 10:53:03 +01:00
Nicolas Silva
6e020a079e
Fix the validation for vertex limits for regular render passes (#5156) 2024-01-29 14:01:03 +01:00
Bude
4face1c2ba
Feature/serde feature (#5149)
* Add serde, serialize, deserialize features to wgpu and wgpu-core
Remove trace, replay features from wgpu-types

* Do not use trace, replay in wgpu-types anymore

* Make use of deserialize, serialize features in wgpu-core

* Make use of serialize, deserialize features in wgpu

* Run cargo fmt

* Use serde(default) for deserialize only

* Fix serial-pass feature

* Add a comment for new features

* Add CHANGELOG entry

* Run cargo fmt

* serial-pass also needs serde features for Id<T>

* Add feature documentation to lib.rs docs

* wgpu-types implicit serde feature

* wgpu-core explicit serde feature

* wgpu explicit serde feature

* Update CHANGELOG.md

* Fix compilation with default features

* Address review comments
2024-01-28 20:13:04 +00:00
vero
0003db18c4
Refactor tests to be feature flag bit-width agnostic (#5155) 2024-01-28 01:42:02 +00:00
Okko Hakola
b3490de69d
[d3d12] Avoid panic on instance drop (#5134) 2024-01-24 12:49:18 +01:00
Jim Blandy
6440af03a6
Join threads in MULTITHREADED_COMPUTE example. (#5129)
Join all threads before returning from the test case, to ensure that
we don't return from `main` until all open `Device`s have been
dropped.

This avoids a race condition in glibc in which a thread calling
`dlclose` can unmap a shared library's code even while the main thread
is still running its finalization functions. (See #5084 for details.)
Joining all threads before returning from the test ensures that the
Vulkan loader has finished `dlclose`-ing the Vulkan validation layer
shared library before `main` returns.

Remove `skip` for this test on GL/llvmpipe. With this change, that has
not been observed to crash. Without it, the test crashes within ten
runs or so.

Fixes #5084.
Fixed #4285.
2024-01-23 22:18:21 -05:00
Brad Werth
ac8756c2d3
Release GPU resources from device.trackers, not from lifetime_tracker. (#5075) 2024-01-22 17:55:42 +01:00
i509VCB
886dc94f57
Document Wayland specifics related to SurfaceTexture::present (#5093)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-01-21 18:10:56 -05:00
Imbris
6c7c6fb999
Make sure to unset current context in wgl Surface::configure/present (#5087) 2024-01-20 22:26:54 -05:00
Erich Gubler
c2f110ed0c feat(const_eval): impl. atanh 2024-01-18 16:57:46 -05:00
Erich Gubler
262c07f40c feat(const_eval): impl. atan 2024-01-18 16:57:46 -05:00
Erich Gubler
f8113c55b7 feat(const_eval): impl. asinh 2024-01-18 16:57:46 -05:00
Erich Gubler
e2783c7d45 feat(const_eval): impl. asin 2024-01-18 16:57:46 -05:00
Erich Gubler
afb54d58ba feat(const_eval): impl. acosh 2024-01-18 16:57:46 -05:00
Erich Gubler
6654c68950 feat(const_eval): impl. acos 2024-01-18 16:57:46 -05:00
Erich Gubler
12b11f870b feat(const_eval): impl. cosh 2024-01-18 16:57:46 -05:00
Erich Gubler
7528b22e57 feat(const_eval): impl. cos 2024-01-18 16:57:46 -05:00
Erich Gubler
3ab9a80815 feat(const_eval): impl. tanh 2024-01-18 16:57:46 -05:00
Erich Gubler
bdf1cb4ec3 feat(const_eval): impl. tan 2024-01-18 16:57:46 -05:00
Erich Gubler
6f5b2a64e2 feat(const_eval): impl. step 2024-01-18 16:57:46 -05:00
Erich Gubler
f2dbdfcdc6 feat(const_eval): impl. sqrt 2024-01-18 16:57:46 -05:00
Erich Gubler
133b573133 feat(const_eval): impl. sinh 2024-01-18 16:57:46 -05:00
Erich Gubler
99a38c7b7c feat(const_eval): impl. sin 2024-01-18 16:57:46 -05:00
Erich Gubler
5dc1038124 feat(const_eval): impl. saturate 2024-01-18 16:57:46 -05:00
Erich Gubler
87dafb645a feat(const_eval): impl. round 2024-01-18 16:57:46 -05:00
Erich Gubler
fc27b08dca feat(const_eval): impl. abs with new component_wise_scalar 2024-01-18 16:57:46 -05:00
Connor Fitzgerald
8b2098bd4e
Release 0.19 (#5082) 2024-01-17 14:42:11 -05:00
Andreas Reich
4c18e283d1
polish changelog for upcoming release (#5078)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-01-17 18:24:43 +00:00
Andreas Reich
b8f27c7284
Expose maximum_frame_latency (#4899)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-17 12:46:34 -05:00
Connor Fitzgerald
2e38187954
Re-export public dependencies (#5063) 2024-01-16 19:21:51 +00:00
Andreas Reich
7774f31021
Allow WebGPU & WebGL in same wasm and detect WebGPU availability (#5044)
* Rename backends: web -> webgpu, direct -> wgpu_core

* rename context objects for web & core

* allow webgpu & webgl features side-by-side

* make sure webgl ci doesn't use webgpu

* update any_backend_feature_enabled

* add panicing generate_report method for compatibility

* RequestDeviceErrorKind::Web rename, fixup various cfg attributes

* automatic webgpu support detection

* changelog entry

* fix emscripten

* fix weird cfg, fix comment typo

* remove try_generate_report again

* Make get_mapped_range_as_array_buffer WebGPU only again
2024-01-14 09:45:52 +00:00
Brad Werth
f89bd3b978
Make DeviceLostClosure.from_c consume the closure before dropping it. (#5032)
This clarifies that the Rust and C-style callbacks/closures need to be
consumed (not called) before they are dropped. It also makes the from_c
function consume the param closure so that it can be dropped without
panicking.

It also relaxes the restriction that the callback/closure can only be
called once.
2024-01-14 02:53:40 -05:00