Commit Graph
125 Commits
Author SHA1 Message Date
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::back::hlsl::FragmentEntryPoint for providing information
  about the fragment entry point when generating vertex entry points via
  naga::back::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
Christofer Nolander c9a2d972ad buffer size mismatch: more detail in error message (#5858)
* buffer size mismatch: more detail in error message

* wrong buffer size: change name of fields
2024-07-01 13:10:37 +02:00
teoxoy 862f19524f make check_texture_usage a texture method 2024-06-20 16:34:17 +02:00
teoxoy 87382d7133 make check_buffer_usage a buffer method 2024-06-20 16:34:17 +02:00
Teodor Tanasoaia b5b39f670d remove redundant code in module interface validation
`TypeInner.size()` already handles the array case
2024-05-28 14:09:56 -04:00
Erich Gubler ca91744955 chore: apply unused_qualifications lint via cargo +1.78.0 fix && cargo fmt 2024-05-13 10:10:54 -04:00
Chase MacDonnell 3db0e46f7d Implement Unorm10_10_10_2 VertexFormat (#5477) 2024-04-03 19:43:54 +00:00
dependabot[bot]andConnor Fitzgerald 744454b9e2 Bump Many Dependencies and MSRV (#5241)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-27 14:43:05 -05:00
Erich Gubler 023b0e063f feat!: make ProgrammableStage::entry_point optional in wgpu-core 2024-02-27 13:57:17 -05:00
Erich Gubler 2c66504a59 refactor(valid): factor out shader_stage_from_stage_bit helper 2024-02-27 13:57:17 -05:00
andristarr a7d76743a8 MissingBufferUsageError now has an id prop (#5203) 2024-02-14 13:27:58 +01:00
Nicolas Silva 990324fc33 Add max_color_attachments and max_color_attachment_bytes_per_sample (#5218) 2024-02-09 09:39:29 +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
Connor Fitzgerald e26a853654 BGL Weak Pointer Deduplication Pool (#4927)
* Ho boy

* BGL pool finished

* Remove id32 feature

* Add BGL Test

* Iteration

* Working Dedupe

* Tests

* Iteration

* Re-iteration

* Hash Cleanup

* Add large slew of tests

* Whoops
2024-01-02 09:27:22 -05:00
Andrew Farkas 2993650ede Fix typo "layout pipeline layout" -> "pipeline layout" (#4921) 2023-12-22 01:02:41 +00:00
Jim Blandy 276c978b70 [naga] Introduce ScalarKind::AbstractInt and AbstractFloat.
Introduce new variants of `naga::ScalarKind`, `AbstractInt` and
`AbstractFloat`, for representing WGSL abstract types.
2023-11-29 08:58:47 +01:00
Xiaopeng LiandConnor Fitzgerald a6503e59c9 Support nv12 texture format (#4573)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-11-28 16:11:26 +00:00
Jim Blandy 72462267e8 [naga]: Let TypeInner::Matrix hold a Scalar, not just a width.
Let `naga::TypeInner::Matrix` hold a full `Scalar`, with a kind and
byte width, not merely a byte width, to make it possible to represent
matrices of AbstractFloats for WGSL.
2023-11-21 12:02:50 +01:00
Jim Blandy 9f91c95c24 [naga] Introduce Scalar type to IR.
Introduce a new struct type, `Scalar`, combining a `ScalarKind` and a
`Bytes` width, and use this whenever such pairs of values are passed
around.

In particular, use `Scalar` in `TypeInner` variants `Scalar`, `Vector`,
`Atomic`, and `ValuePointer`.

Introduce associated `Scalar` constants `I32`, `U32`, `F32`, `BOOL`
and `F64`, for common cases.

Introduce a helper function `Scalar::float` for constructing `Float`
scalars of a given width, for dealing with `TypeInner::Matrix`, which
only supplies the scalar width of its elements, not a kind.

Introduce helper functions on `Literal` and `TypeInner`, to produce
the `Scalar` describing elements' values.

Use `Scalar` in `wgpu_core::validation::NumericType` as well.
2023-11-14 14:21:27 +01:00
ff306d20e0 Add support for bgra8unorm-storage (#4228)
* Add `BGRA8UNORM_STORAGE` extension

* Leave a comment in the backends that don't support bgra8unorm-storage

* Pass the appropriate storage format to naga

* Check for bgra8unorm storage support in the vulkan backend

* Add a test

Co-authored-by: Jinlei Li <jinleili0@outlook.com>
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-10-13 10:07:11 +00:00
Nicolas Silva 2664da88b0 Update naga to 0.13.0@git:3c7dbc4016b84a35c69b30305b12abaeefc21fd9 (#4221) 2023-10-09 16:39:22 +00:00
Teodor Tanasoaia 422c636877 Add Rgb10a2Uint format (#4199) 2023-10-03 14:56:21 +02:00
Aaron Hill 2b4a8b318f wgpu-core: Only produce StageError::InputNotConsumed on DX11/DX12 (#4116)
* wgpu-core: Only produce StageError::InputNotConsumed on DX11/DX12

This error only exists due to an issue with naga's HLSL support:
https://github.com/gfx-rs/naga/issues/1945
The WGPU spec itself allows vertex shader outputs that are
not consumed by the fragment shader.

Until the issue is fixed, we can allow unconsumed outputs on
all platforms other than DX11/DX12.

* Add Features::SHADER_UNUSED_VERTEX_OUTPUT to allow disabling check

* Pick an unused feature id
2023-09-20 21:02:37 -04:00
Frederik Magnus Johansen VestreandTeodor Tanasoaia dc5beac8c9 Support dual source blending (#4022)
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-09-19 13:26:30 +02:00
Nicolas SilvaandNicolas Silva 012304ea11 Update naga to 0.13.0@git:cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c (#4130)
Co-authored-by: Nicolas Silva <nical@fastnmail.com>
2023-09-11 15:57:43 +02:00
Teodor Tanasoaia 48078a800a Derive storage bindings via naga::StorageAccess instead of naga::GlobalUse (#3985)
Removes the feature check for read-only and read-write storage textures as it's later checked by `create_bind_group_layout`.

https://github.com/gfx-rs/wgpu/blob/335f40f85a492a5d9a69eda6835a30173f2e6b03/wgpu-core/src/device/resource.rs#L1505-L1518

Also removes the `GlobalUse` checks from `check_binding_use` as naga is already checking those.

https://github.com/gfx-rs/naga/blob/535701f6b2f38f7e0088701ee4cf6d8024f74a21/src/valid/interface.rs#L639-L669
2023-07-31 15:30:47 +02:00
Teodor Tanasoaia 01160c3ad1 Revert "Make shader write&read storage buffers match non readonly layouts" (#3984) 2023-07-27 12:33:05 -04:00
Fredrik Fornwall 17143c149c Make shader write&read storage buffers match non readonly layouts (#3893) 2023-06-29 22:30:34 +00:00
Teodor Tanasoaia dcad7dfba9 Update naga to 0.12.0@git:76003dc0035d53a474d366dcdf49d2e4d12e921f (#3866) 2023-06-14 18:55:33 +02:00
Connor FitzgeraldandConnor Fitzgerald a7defb723f Cleanups for WebGPU (#3671)
Co-authored-by: Connor Fitzgerald <connor@modyfi.io>
2023-04-12 21:27:30 +00:00
Connor FitzgeraldandConnor Fitzgerald 51bf95bbd6 Make wgpu-core errors non-exhaustive (#3652)
Co-authored-by: Connor Fitzgerald <connor@modyfi.io>
2023-04-07 19:18:29 +02:00
Connor Fitzgerald db3be88f90 Uppercase all error strings 2023-03-03 11:33:20 -05:00
Nicolas Silva a3e3d2503f Update naga to 1be8024. (#3405) 2023-01-19 15:25:25 +00:00
JMS55 ad4dac87fb Allow non-filtering integer texture sampling (#3362)
* Allow non-filtering integer texture sampling

* Add changelog entry
2023-01-09 11:08:14 +01:00
Nathan Adams 186a29c34d Implement TextureFormat::Stencil8 + add stencil example (#3343)
* Implement TextureFormat::Stencil8

* Add stencil-triangles demo to test Stencil8 and show how to use stencil testing

* Added changelog for Stencil8
2023-01-02 13:47:10 +01:00
Harald ReingruberandConnor Fitzgerald 51b34c5b51 Improve compute shader validation error message (#3139)
* Improve compute shader validation error message

* Add entry to changelog.

* Improve error message wording (by cwfitzgerald)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Add credit and PR link to changelog

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-29 17:49:03 -04:00
Jim Blandy 215884184b Reformat comments in wgpu-core. (#3102) 2022-10-13 18:34:44 +00:00
Mauro GentileandMauro Gentile cdf6ee0c87 Updating TextureFormat matching specs (#2954)
Co-authored-by: Mauro Gentile <Mauro.Gentile@ubisoft.com>
2022-09-20 12:08:06 -04:00
Connor Fitzgerald 537c6bed4e Add warning when using CompareFunction::*Equal without an invariant Attribute (#2887) 2022-07-21 02:24:49 -04:00
Jinlei Li 8063edc648 Add DEPTH24UNORM_STENCIL8 feature (#2689) 2022-05-30 15:29:12 -04:00
Connor Fitzgerald c12ae0880f Check that all vertex outputs are consumed by the fragment shader (#2704) 2022-05-29 23:38:11 +00:00
Jinlei Li 26f96c7dfe Add DEPTH32FLOAT_STENCIL8 featue (#2664) 2022-05-17 02:11:05 -04:00
Connor Fitzgerald e54a36ee78 Move texture-array example over to wgsl (#2618) 2022-04-25 18:32:53 +00:00
Connor Fitzgerald bc850d2a0e Bind group deduplication (#2623) 2022-04-25 04:19:25 +00:00
Jim Blandy 06ee8a6862 Permit non-struct, non-array types as buffers.
Fixes #2583.
2022-04-18 09:50:51 -07:00
Igor Shaposhnik eff50436f5 Update to Naga rev 1720725 2022-04-15 22:22:48 +03:00
Jim Blandy a47b5c554f Update to Naga rev 7aaac25f. 2022-04-13 14:41:26 -07:00
Jinlei Li 1c17d15507 Metal backend ASTC HDR formats support (#2477) 2022-02-15 09:43:16 -05:00
Samuel Hurel 3e0305d27d Allow non struct buffers in wgsl (#2451)
* Bump naga

* Update examples
2022-02-05 09:53:04 -05:00
Dzmitry Malyshau 3960658529 Remove block decorations (#2292) 2021-12-15 12:29:37 -05:00