Commit Graph

53 Commits

Author SHA1 Message Date
teoxoy
ca252b9e74 allow private variables to have an override-expression initializer 2024-04-05 18:07:41 +02:00
teoxoy
3abdfde0ba evaluate override-expressions in functions 2024-04-05 18:07:41 +02:00
teoxoy
e9eb703941 rename const_expressions to global_expressions 2024-04-05 18:07:41 +02:00
teoxoy
d6ebd88f42 implement override-expression evaluation for initializers of override declarations 2024-04-05 18:07:41 +02:00
teoxoy
ff332afdef [const-eval] fix evaluation of bool constuctors 2024-04-05 18:07:41 +02:00
teoxoy
2929ec333c [spv/msl/hlsl-out] support pipeline constant value replacements 2024-04-05 18:07:41 +02:00
Teodor Tanasoaia
f949ea69c4 [wgsl-in] add support for override declarations (#4793)
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-04-05 18:07:41 +02:00
Jim Blandy
b3dfc40c9d [naga] Delete Constant::override and Override. 2024-04-05 18:07:41 +02:00
Dzmitry Malyshau
3a467ad93d spv-out: Support arrayLength of a dynamically indexed bindings array 2024-04-02 19:22:34 +02:00
Dzmitry Malyshau
bfe0b90740 spv-out: implement OpArrayLength on array buffer bindings 2024-04-02 19:22:34 +02:00
Christian Legnitto
0f4839c466
Include the glsl global name in entrypoint arguments. (#5418) 2024-03-28 18:19:51 +01: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
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
Imbris
abc0b30dfc Add test case for builtin only accessed in function parsed after the entry point function 2024-02-15 18:12:25 +01:00
Imbris
ae22743326 Add test case to naga/spv-in for an unnamed glPerVertex struct 2024-02-15 18:12:25 +01:00
Imbris
4554f852c1 [spv-in] Remove providing "perVertexStruct" for certain unnamed inputs
since we probably shouldn't be naming things if they don't have a name
in the input.

As requested here: https://github.com/gfx-rs/wgpu/pull/5227#issuecomment-1936027091
2024-02-15 18:12:25 +01: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
Erich Gubler
2d3005b745 feat(const_eval): impl. sign with new component_wise_signed 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
ea044f039c feat(const_eval): impl. countLeadingZeros with new component_wise_concrete_int 2024-01-30 10:53:03 +01:00
Erich Gubler
a05cc37e3c feat(const_eval): impl. ceil 2024-01-30 10:53:03 +01:00
Erich Gubler
7528b22e57 feat(const_eval): impl. cos 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
fc27b08dca feat(const_eval): impl. abs with new component_wise_scalar 2024-01-18 16:57:46 -05:00
Patryk Wychowaniec
e7c7017d2e [naga wgsl-in] Fix parsing break ifs
Closes https://github.com/gfx-rs/wgpu/issues/4982.
2024-01-08 10:50:38 +01:00
teoxoy
b47d4924a8 [glsl-in] fix swizzle in a global const context 2024-01-03 11:34:10 +01:00
Jim Blandy
d9d051b7a5 [naga wgsl] Let unary operators accept and produce abstract types.
Fixes #4445.
Fixes #4492.
Fixes #4435.
2023-12-14 10:54:46 +01:00
Jim Blandy
c4b43875e5 [naga wgsl-in] Support abstract operands to binary operators. 2023-12-13 08:42:26 -08:00
Jim Blandy
3ffd5a1e56 [naga wgsl-out] Include the f suffix on f32 literals.
Without the suffix, `Expression::Literal(Literal::F32)` expressions
get written without any suffix on the number, meaning that they get
re-parsed as `AbstractFloat` values. In theory, this should always be
fine, but since we don't actually support abstract types yet in all
the places we should, having them appear in the output causes
validation problems.

See also: #4863, which did the same for `i32` literals.
2023-12-13 13:42:05 +01:00
Jim Blandy
6dc9ccab85
[naga wgsl-out] Include the i suffix on i32 literals. (#4863)
Without the suffix, `Expression::Literal(Literal::I32)` expressions
get written without any suffix on the decimal number, meaning that
they get re-parsed as AbstractInt values. In theory, this should
always be fine, but since we don't actually support abstract types yet
in all the places we should, having them appear in the output causes
validation problems.
2023-12-12 12:07:10 +00:00
Jim Blandy
4b6a2d1dfa [naga] Teach the constant evaluator vector/vector operators.
Allow constant evaluation of binary operators whose left and right
operands are both vectors.
2023-12-12 12:48:10 +01:00
Jim Blandy
0e41cfe4ca [naga] Change operators.wgsl to use values that matter.
Change `splat` to take run-time values as arguments, to prevent
constant evaluation from boiling everything away.
2023-12-12 12:48:10 +01:00
teoxoy
411c1e5b21 [spv-out] Decorate all non-uniform binding array access chains as NonUniform, not just buffer binding arrays.
Apply the `NonUniform` decoration to the results of all access chains rooted in binding arrays that use non-uniform values as indices, regardless of the binding array's element type and address space. Previously, Naga only decorated non-uniform access chains for binding arrays of buffers.
2023-12-07 19:01:04 +01:00
Jim Blandy
f470103874 [naga wgsl-in] Automatic conversions for local var initializers. 2023-12-06 10:35:21 +01:00
Jim Blandy
1676ee0dc0 [naga wgsl-in] Automatic conversions for global var initializers. 2023-12-06 10:35:21 +01:00
Jim Blandy
19702108ab [naga] Rename abstract-types snapshots abstract-types-const.
This prepares for introducing a similar test for global variables.
2023-12-06 10:35:21 +01:00
Jim Blandy
fe4d412aea [naga wgsl-in] Matrix constructors have only float overloads. 2023-11-29 08:58:47 +01:00
Jim Blandy
601f235b34 [naga wgsl-in] Implement abstract types for consts, constructors. 2023-11-29 08:58:47 +01:00
Jim Blandy
86562e69a6 [naga] Support casting to f64 in the constant evaluator. 2023-11-23 12:17:21 +01:00
Jim Blandy
eb92ab2878 [naga wgsl] Experimental 64-bit floating-point literals.
In the WGSL front and back ends, support an `lf` suffix on
floating-point literals to yield 64-bit integer literals.
2023-11-23 12:17:21 +01:00
Jim Blandy
4f9cc288e3 [naga] Make compaction preserve named types, even if unused.
Have `compact::compact` preserve entries in the `Module::types` arena
if they have names.

Future abstract type support will require the WGSL front end to
compact the module before validation. Without this change, that will
drop `alias` declarations, making it harder to test type validation.
2023-11-22 18:33:59 +01:00
Erich Gubler
1cf0fe841a test(naga): add struct-layout test 2023-11-22 03:54:16 -07:00
Erich Gubler
611da6da2d fix(msl-out): emit and init struct member padding always
Previously, implicit padding members of `struct`s were suppressed from
structure definitions in Metal output if they had a binding specified
for them (i.e., `@location(0)`). This padding is, however, is necessary
for correct access of member fields passed into shaders by uniform and
storage buffers. Unconditionally emit padding members for `struct`s.

Resolves
[`gfx-rs/wgpu`#4701](https://github.com/gfx-rs/wgpu/pull/4701).
2023-11-22 03:54:16 -07:00
Connor Fitzgerald
1df98d9888
Test And Normalize Vertex Behavior on All Backends (#4723)
Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-11-21 22:11:24 +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
fd53ea90e6 [naga] Let constant evaluation of As preserve Splat expressions.
When asked to evaluate an `Expression::As` cast applied to a `Splat`
expression, change `ConstantEvaluator::cast` to preserve the `Splat`,
rather than expanding it out to a `Compose` expression.
2023-11-17 16:20:11 -08:00
Fredrik Fornwall
a5c93caa56
Add more metal keywords (#4707) 2023-11-17 17:02:36 +01:00
Jim Blandy
b7dd59e1dc [naga] Let constant evaluation handle Compose of Splat.
When consuming a `Compose` expression that constructs a vector,
flatten `Splat` subexpressions out into their components.

Fixes #4581.
2023-11-16 13:34:27 +01:00
Jim Blandy
ecb522e4e3 [naga] New tests for GLSL double-precision builtin functions. 2023-11-14 20:12:31 -08:00