Commit Graph

589 Commits

Author SHA1 Message Date
teoxoy
9f34acd567 [wgpu-hal] return None in Adapter.surface_capabilities() if the Surface and the Adapter don't share the same WebGL2 context 2024-07-04 10:17:07 +02:00
teoxoy
7910fd8059 [wgpu-hal] require a Surface to be passed to Instance.enumerate_adapters() on WebGL2
Also makes wgpu's `enumerate_adapters()` native only.
2024-07-04 10:17:07 +02:00
Imbris
3a6814770a
Allow unconsumed inputs in fragment shaders (#5531)
* Allow unconsumed inputs in fragment shaders by removing them from vertex
outputs when generating HLSL.

Fixes https://github.com/gfx-rs/wgpu/issues/3748

* Add naga:🔙:hlsl::FragmentEntryPoint for providing information
  about the fragment entry point when generating vertex entry points via
  naga:🔙:hlsl::Writer::write. Vertex outputs not consumed by the
  fragment entry point are omitted in the final output struct.
* Add naga snapshot test for this new feature,
* Remove Features::SHADER_UNUSED_VERTEX_OUTPUT,
  StageError::InputNotConsumed, and associated validation logic.
* Make wgpu dx12 backend pass fragment shader info when generating
  vertex HLSL.
* Add wgpu regression test for allowing unconsumed inputs.

* Address review

* Add note that nesting structs for the inter-stage interface can't
  happen.
* Remove new TODO notes (some addressed and some transferred to an issue
  https://github.com/gfx-rs/wgpu/issues/5577)
* Changed issue that regression test refers to 3748 -> 5553
* Add debug_assert that binding.is_some() in hlsl writer
* Fix typos caught in CI

Also, fix compiling snapshot test when hlsl-out feature is not enabled.
2024-07-04 09:08:46 +02:00
Andreas Reich
0a76c0fa84
Renderpass take resource ownership (#5884)
* share timestamp write struct

* Make name of set_push_constants methods consistently plural

* remove lifetime bounds of resources passed into render pass

* first render pass resource ownership test

* introduce dynrenderpass & immediately create ArcCommands and take ownership of resources passed on pass creation

* Use of dynrenderpass in deno

* Separate active occlusion & pipeline statitics query

* resolve render/compute command is now behind `replay` feature

* add vertex & index buffer to ownership test

* test for pipeline statistics query

* add occlusion query set to pass resource test

* add tests for resource ownership of render pass query timestamps

* RenderPass can now be made 'static just like ComputePass. Add respective test

* Extend encoder_operations_fail_while_pass_alive test to also check encoder locking errors with render passes

* improve changelog entry on lifetime bounds
2024-07-01 18:36:24 +02:00
9SMTM6
a7d4d2c79f
Allow using include_wgsl! in const contexts (#5872)
* include_wgsl! Switch from into() call to construction

This allows usage in const contexts.

* Describe constification of include_wgsl! in changelog
2024-06-24 17:46:30 +00:00
Nicolas Silva
ddff69ba21
Avoid leaking submitted command encoders (#5141)
* Avoid leaking submitted command encoders

* changelog
2024-06-24 12:16:55 +00:00
Kamil Jarosz
355613342e [naga] Add packed as a keyword for GLSL
Turns out that sometimes `packed` is a keyword,
and the produced GLSL had syntax errors due to that.
2024-06-24 11:21:24 +02:00
Erich Gubler
f227ca1258 docs(CHANGELOG): add entry for #5812
Permalink: <https://github.com/gfx-rs/wgpu/issues/5812>
2024-06-23 03:40:32 -07:00
Théo Monnom
0f6abc99ee
[naga-cli] add --defines options for the glsl parser (#5859) 2024-06-23 07:21:56 +00:00
Schell Carl Scivally
6405dcf611 [naga spv-in] Adjust types of globals used by atomic instructions.
To support atomic instructions in the SPIR-V front end, observe which
global variables the input accesses using atomic instructions, and
adjust their types from ordinary scalars to atomic values.

See comments in `naga::front::atomic_upgrade`.
2024-06-21 21:51:25 -07:00
Christofer Nolander
fe31966fdf
ensure that wgpu::Error is Sync (#5820)
* ensure that `wgpu::Error` is `Sync`

This makes it possible to wrap the error in `anyhow::Error` and
`eyre::Report`, which require the inner error to be `Sync`.

* update changelog
2024-06-16 19:48:35 -04:00
Andreas Reich
eb24be47e1
Validate for device mismatch during compute pass recording (#5779)
* compute pass recording device validation

* add changelog entry

* validate device of timestamp query set as well
2024-06-10 12:19:50 +02:00
Vecvec
73401ede25
Fix double decoration if a binding array contains a struct with a runtime array (#5776) 2024-06-10 11:20:33 +02:00
Atlas Dostal
abba12ae4e Add support for 64 bit integer atomic operations in shaders.
Add the following flags to `wgpu_types::Features`:

- `SHADER_INT64_ATOMIC_ALL_OPS` enables all atomic operations on `atomic<i64>` and
  `atomic<u64>` values.

- `SHADER_INT64_ATOMIC_MIN_MAX` is a subset of the above, enabling only
  `AtomicFunction::Min` and `AtomicFunction::Max` operations on `atomic<i64>` and
  `atomic<u64>` values in the `Storage` address space. These are the only 64-bit
  atomic operations available on Metal as of 3.1.

Add corresponding flags to `naga::valid::Capabilities`. These are supported by the
WGSL front end, and all Naga backends.

Platform support:

- On Direct3d 12, in `D3D12_FEATURE_DATA_D3D12_OPTIONS9`, if
  `AtomicInt64OnTypedResourceSupported` and `AtomicInt64OnGroupSharedSupported` are
  both available, then both wgpu features described above are available.

- On Metal, `SHADER_INT64_ATOMIC_MIN_MAX` is available on Apple9 hardware, and on
  hardware that advertises both Apple8 and Mac2 support. This also requires Metal
  Shading Language 2.4 or later. Metal does not yet support the more general
  `SHADER_INT64_ATOMIC_ALL_OPS`.

- On Vulkan, if the `VK_KHR_shader_atomic_int64` extension is available with both the
  `shader_buffer_int64_atomics` and `shader_shared_int64_atomics` features, then both
  wgpu features described above are available.
2024-06-08 18:36:26 -07:00
Andreas Reich
9a27ba53ca
Fix QuerySet ownership of ComputePass (#5671)
* add new tests for checking on query set lifetime

* Fix ownership management of query sets on compute passes for write_timestamp, timestamp_writes (on desc) and pipeline statistic queries

* changelog entry
2024-06-04 07:47:27 +00:00
Andreas Reich
aa2821bff6
Reintroduce computepass->encoder lifetime constraint and make it opt-out via wgpu::ComputePass::forget_lifetime (#5768)
* Reintroduce computepass->encoder lifetime constraint and make it opt-out via `wgpu::ComputePass::make_static`

* improve comments based on review feedback

* use the same lifetime name for all usages of `ComputePass<'encoder>`

* comment improvement that I missed earlier

* more review based comment improvements

* use suggested zero-overhead lifetime removal

* rename make_static to forge_lifetime

* missed comma
2024-06-03 20:04:12 +02:00
Schell Carl Scivally
480d4dbd73
spv-in parsing Op::AtomicIIncrement (#5702)
Parse spirv::Op::AtomicIIncrement, add atomic_i_increment test.
2024-05-30 04:39:32 +00:00
Mads Marquart
60a14c67fb
Remove the link Cargo feature (#5752) 2024-05-29 15:55:33 -07:00
Andreas Reich
588950110a
Remove lifetime dependency of ComputePass to its parent command encoder (#5620)
* lift encoder->computepass lifetime constraint and add now failing test
* compute passes now take an arc to their parent command encoder, thus removing compile time dependency to it
* Command encoder goes now into locked state while compute pass is open
* changelog entry
* share most of the code between get_encoder and lock_encoder
2024-05-29 22:43:24 +00:00
Douglas Dwyer
071fb14e15
Add support for pipeline-overridable constants in web backend (#5688)
* Add support for pipeline-overridable constants in WebGPU

* Add utility function for setting constants map

* Panic on failure to set constants map

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-05-29 19:33:04 +00:00
Valaphee The Meerkat
23307e1dc3
gles: Return the version as driver_info (#5753) 2024-05-29 14:01:32 -04:00
Vladas Zakrevskis
de809c8f96
Fix missing family check flag (#5754)
Co-authored-by: Jim Blandy <jimb@red-bean.com>
Co-authored-by: Xiaopeng Li <x.friday@outlook.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Valaphee The Meerkat <32491319+valaphee@users.noreply.github.com>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-05-29 14:00:32 -04:00
Jason de Wolff
cd744ef68b
Buffer as hal (#5724)
* Add `as_hal` for `Buffer`

* fmt & CHANGELOG.md update

* Update CHANGELOG.md

* fixed callback name

* allow nested buffer as_hal callbacks
2024-05-26 08:58:30 +02:00
Andreas Reich
2fd09945cd
Make compute pass end consume the pass (#5575)
* rename `command_encoder_run_*_pass` to `*_pass_end` and make it a method of compute/render pass instead of encoder

* executing a compute pass consumes it now such that it can't be executed again

* use handle_error instead of handle_error_nolabel for wgpu compute pass

* use handle_error instead of handle_error_nolabel for render_pass_end

* changelog addition

* feat: `compute_pass_set_push_constant`: move panics to error variants

Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>

---------

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-05-25 18:54:48 +02:00
Erich Gubler
447e3eee8d fix: ensure render pipelines have at least 1 target 2024-05-17 17:45:03 -04:00
Daniel McNab
4902e470ce
Pipeline cache API and implementation for Vulkan (#5319)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-05-16 13:52:56 +00:00
Andreas Reich
77a83fb0dd
Remove lifetime constraints from wgpu::ComputePass methods (#5570)
* basic test setup

* remove lifetime and drop resources on test - test fails now just as expected

* compute pass recording is now hub dependent (needs gfx_select)

* compute pass recording now bumps reference count of uses resources directly on recording

TODO:
* bind groups don't work because the Binder gets an id only
* wgpu level error handling is missing

* simplify compute pass state flush, compute pass execution no longer needs to lock bind_group storage

* wgpu sided error handling

* make ComputePass hal dependent, removing command cast hack. Introduce DynComputePass on wgpu side

* remove stray repr(C)

* changelog entry

* fix deno issues -> move DynComputePass into wgc

* split out resources setup from test
2024-05-14 20:05:17 +00:00
Vladislav
00456cfb37 Add parsing support for un/pack4xI/U8 2024-05-14 17:57:04 +02:00
Connor Fitzgerald
7078b0a061
Fix Subgroup Ops on VK 1.2 Device (#5624) 2024-05-14 14:21:53 +00:00
Nick Guletskii
65d8c94afd
Issue SetDrawColorBuffers before clearing buffers in GLES, use clear_buffer_f32_slice instead of clear (#5666)
* Issue SetDrawColorBuffers commands before issuing ClearColor

This is necessary for glClearBuffer calls to work correctly on some machines (e.g. AMD Renoir graphics running on Linux). Without this, glClearBuffer calls are ignored.

* Use clear_buffer_f32_slice instead of gl.clear to suppress WebGL warnings

This fixes the following WebGL warning: "WebGL warning: drawBuffers: `buffers[i]` must be NONE or COLOR_ATTACHMENTi."

When using native OpenGL, it is acceptable to call glDrawBuffers with an array of buffers where i != COLOR_ATTACHMENTi. In WebGL, this is not allowed.

* Run cargo fmt

* Add changes for PR GH-5666 to the CHANGELOG
2024-05-14 05:57:18 -04:00
Marijn Suijten
8879733875
[wgpu-hal] Upgrade to ash 0.38 (#5504) 2024-05-13 11:57:44 -04:00
bjorn3
fa48562229
Avoid introducing spurious features for optional dependencies (#5691)
* Avoid introducing spurious features for optional dependencies

If a feature depends on an optional dependency without using the dep:
prefix, a feature with the same name as the optional dependency is
introduced. This feature almost certainly won't have any effect when
enabled other than increasing compile times and polutes the feature list
shown by cargo add. Consistently use dep: for all optional dependencies
to avoid this problem.

* Add changelog entry
2024-05-12 08:45:35 +02:00
Xiaopeng Li
d5d683d3c4
Clean up weak references to texture views and bind groups (#5595)
* Clean up weak references to texture views

* add change to CHANGELOG.md

* drop texture view before clean up

* cleanup weak ref to bind groups

* update changelog

* Trim weak backlinks in their holders' triage functions.

---------

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-05-06 12:53:03 +02:00
Valaphee The Meerkat
565a0310e9
Fix OpenGL non-srgb on Linux (#5642) 2024-05-03 22:29:27 +02:00
Andreas Reich
08efa72a83 move shader compilation error query out of 0.20 changelog - it didn't get released with it 2024-04-29 14:29:18 +02:00
stefnotch
f874ed061c
Add get_compilation_info (#5410)
* Add get_compilation_info API

* Rename glsl ParseError to ParseErrors

* Document ParseError label order

* Update line_position to count UTF-8 bytes
2024-04-29 11:35:36 +02:00
Connor Fitzgerald
4521502da6
Release v0.20.0 (#5619) 2024-04-28 18:06:35 -04:00
Jim Blandy
a2cd2b92b3
[hal] Fix cargo doc --document-private-items. Check in CI. (#5617) 2024-04-27 20:21:29 +00:00
vero
9eb1b71d33
Add some more changelog entries (#5611)
* Add some more changelog entries

* Address feedback
2024-04-26 15:06:34 +02:00
Imbris
ae758be2ec
Reword / reclassify a few changelog entries. (#5607) 2024-04-25 05:10:32 +00:00
vero
671a2a8227
Update my username in the changelog (#5602) 2024-04-24 22:30:44 -04:00
Andreas Reich
d00a69615b
Prepare changelog for 0.20 (#5599) 2024-04-24 20:21:54 -04:00
Imbris
82fa580152
[hlsl-out] Fix accesses on zero value expressions (#5587) 2024-04-24 10:40:08 +02:00
Luna
7840e75bf7
Add check to ensure vulkan::CommandEncoder::discard_encoding is not called multiple times in a row (#5557)
Document that `wgpu_hal::CommandEncoder::discard_encoding` must not be called multiple times.

Assert in `wgpu_hal::vulkan::CommandEncoder::discard_encoding` that encoding is actually in progress.

Fixes #5255.
2024-04-22 19:39:08 +00:00
Valaphee The Meerkat
53dd49f839
Allow ETC2 in OpenGL if ES3 compatible (#5568)
* Allow ETC on OpenGL if ES3 compatible

* Update changelog
2024-04-20 15:38:53 +02:00
matt rice
e0ac24aeab
[naga-cli] Add input-kind and shader-stage args (#5411) 2024-04-18 12:41:18 +02:00
Connor Fitzgerald
638fc9db7f
Backport changelog from 0.19.4 (#5552) 2024-04-18 08:20:52 +02:00
Andreas Reich
ad6774f7bb
Remove exposed C symbols from renderpass/computepass recording (#5409)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-04-17 20:48:45 +00:00
Connor Fitzgerald
c1291bd131
Fix Merge Issues Between #5301 and #5508 (#5549) 2024-04-17 16:31:20 -04:00
Daniel McNab
965b00c06b
Allow configuring whether workgroup memory is zero initialised (#5508) 2024-04-17 15:50:31 -04:00