Commit Graph
367 Commits
Author SHA1 Message Date
Dzmitry Malyshau f6a63b65da HLSL: rewrite handling of interface matching rules (#1276)
* [hlsl-out] flatten the entry point inputs

Previously, the logic was re-ordering the inputs according to the binding.
This breaks if one of the inputs is a struct. With this change, the struct
fields are also flattened into the fake entry point struct. We also
construct the original arguments at the beginning of the function.

* hlsl-out: completely separate the flattened IO structs from the original IR structs

Previously, we had heuristics to detect if a particular struct needs the fields
to be re-ordered. We'd re-order interface structs without layout, and the detection
was very fragile and easily wrong.
The new logic is spawning separate struct types if we need any re-ordering to happen.
It's solid, there are no heuristics.
2021-08-24 18:17:02 -04:00
Jim Blandy 7637f4d83a [wgsl-in] Print errors nicely in convert_wgsl snapshot tests. (#1274) 2021-08-24 18:17:02 -04:00
Igor Shaposhnik 02c74b5002 [hlsl-out] Implement switch statement (#1265)
* [hlsl-out] Implement switch statement

* [hlsl-out] Implement switch statement

* Add switch tests to control-flow snapshot
2021-08-24 18:17:02 -04:00
Dzmitry Malyshau 83ec5f6f14 [hlsl-out] fix array arguments in functions 2021-08-24 18:17:02 -04:00
João Capucho b05ca6e403 [glsl-in] Builtin redefinition and calls fixes 2021-08-17 22:22:30 -04:00
Dzmitry Malyshau 79d899fe4c Support num_workgroups builtin 2021-08-17 22:22:22 -04:00
Connor Fitzgerald 73be8c7454 [hlsl-out] Implicitly transpose all matrices 2021-08-17 14:05:27 -04:00
João Capucho b11f094287 [wgsl-out] Write pointers types and loads 2021-08-17 13:39:31 -04:00
Dzmitry Malyshau ab1e932e16 [glsl-out] use common bake prefix 2021-08-17 00:22:51 -04:00
Dzmitry Malyshau 5415d8c7c4 Fix atomics in workgroup storage 2021-08-13 23:01:25 -04:00
Dzmitry Malyshau 69b70f8cc3 [hlsl-out] reorder fields when composing structs 2021-08-13 01:45:43 -04:00
Dzmitry Malyshau 27e4ba59e4 Validate that SampleLevel::Exact isn't used for comparisons 2021-08-13 01:45:43 -04:00
Dzmitry Malyshau 0feea58a34 [hlsl-out] re-order interface struct fields (#1189) 2021-08-12 13:08:29 -04:00
Jim Blandy 47b9f4a2e5 [spv-out] Writer::write_texture_coordinates: Fix result type. (#1188)
Some SPIR-V texture access instructions take coordinates as integers, others as
floats. The types of coordinates in Naga expressions generally match those in
SPIR-V, but Naga indices for arrayed textures are always integers, whereas
SPIR-V combines coordinates and array indices into a single vector, so indices
need to be cast to match the coordinate component type.

This commit makes `write_texture_coordinates` properly cast array indices to
match the coordinates' component type before combining them all into a single
result vector.

Fixes #1186.
2021-08-11 14:55:54 -07:00
Jim Blandy e2fc7ffd03 [spv-out]: Use OpCompositeConstruct's schmear behavior.
In `back::spv::Writer::write_texture_coordinates`, OpCompositeConstruct can
concatenate scalars and vectors, so when combining coordinates with an array
index, there is no need to extract the coordinate vector's components
individually: once the index has been converted to the appropriate component
type, it can be combined with the coordinates in a single instruction.
2021-08-11 11:22:43 -04:00
Dzmitry Malyshau 67dd604b0c [wgsl-out] atomic load/stores, [glsl-out] revert the prefix 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 1121a815ac Separate enum for atomic binary operations 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 78f225a37a Implemented atomics in HLSL-out 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau bc4576c0a2 Make atomic operations to be statements 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 88c1c9037d Add atomic exchange function 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 8c371e8063 Atomic expressions, support in backends except HLSL and the validator. 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 021bfd5289 [hlsl-out] fix member offset consideration for storage buffers 2021-08-09 16:45:07 -04:00
João Capucho 1aaf77489b [glsl-in] Improve error api and make more errors deferred 2021-08-09 10:51:15 -04:00
João Capucho a8a316da15 [glsl-in] API revamp
The new api allows for reuse while keeping some allocations and to
please the borrow checker in future work, it also splits the parser into
logical modules to make it easier to work on.
2021-08-09 10:51:15 -04:00
Dzmitry Malyshau 7c3cc904a0 [spv-in] fix storage buffer access decorations 2021-08-05 12:59:19 -04:00
Gordon-F 4080bfe502 Add vec select to operators snapshot 2021-08-05 09:43:47 -04:00
João Capucho a1395ddb99 [glsl-in] Fix matrix constructor with a scalar
Glsl defines that if a matrix constructor is called with only a scalar
it's result will be the matrix where the scalar is used if the row and
column are equal and everywhere else a zero
2021-08-04 12:39:36 -04:00
João Capucho de6399a9c7 [glsl-in] Follow spec when choosing default layout 2021-08-04 12:39:36 -04:00
Dzmitry Malyshau 6f21004369 Allow mixing on a scalar selector 2021-08-04 12:09:05 -04:00
João Capucho a90aa9817b [glsl-in] Add support for non constant global init
Glsl allows things such as

```glsl
layout (location = 0) in vec4 a;
vec4 b = a;
```

In this case `b` depends on `a` which can't be known at compile time,
so it's necessary to add a small prologue to the entry point to
initialize it.
2021-08-04 12:07:17 -04:00
João Capucho 057dc3100d [glsl-in] Remove support for multiple entry points 2021-08-04 11:06:57 -04:00
João Capucho 56ce439ff5 [glsl-in] Implement layouting for composite types 2021-07-31 23:25:22 -04:00
pyrotechnickandDzmitry Malyshau 2f516c0932 [wgsl] Storage buffer/texture access (#1142)
* Resurrect texture_storage_* tests
* Test parsing of `var<storage,write>`
* Default storage textures to READ
* Restore default features
* Fix glsl/hlsl/msl/spv front and back ends
* Add missing test outputs
* All-around fixes for the storage access

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-28 01:47:18 -04:00
João Capucho 677e040462 [glsl-in] Long form matrix support 2021-07-27 11:35:47 -04:00
Dzmitry Malyshau a7ac13a61d hlsl: special constants for base vertex/index 2021-07-27 01:49:03 -04:00
Gordon-F d3243bd774 [glsl-out] Enable access snapshot testing 2021-07-26 13:53:48 -04:00
Dzmitry Malyshau e97c8f9441 hlsl: fix storage offset, continuing statement 2021-07-26 01:29:42 -04:00
Dzmitry Malyshau a5c2cef9ab hlsl: transpose storage matrices 2021-07-26 01:29:42 -04:00
Dzmitry Malyshau 284cfcce47 hlsl: storage writes 2021-07-26 01:29:42 -04:00
Dzmitry Malyshau 4b6846d5da hlsl: storage reads support, array length 2021-07-26 01:29:42 -04:00
Gordon-F 526a29e2b8 [glsl-out] Fix array type writing and zero initialization for local variables 2021-07-24 17:53:24 -04:00
Dzmitry Malyshau bbfa9a0f9e hlsl: remove the boolean casts for unary operators 2021-07-23 10:41:36 -04:00
Dzmitry Malyshau cc91c77f7a hlsl: fix vector multiplication 2021-07-23 02:11:32 -04:00
Dzmitry Malyshau c526383cf8 hlsl-out: write StructuredBuffer 2021-07-22 15:44:26 -04:00
Dzmitry Malyshau 20c4d2c3d1 Add MSAA depth texture type 2021-07-22 10:39:24 -04:00
Gordon-F 82b2fe4410 [glsl-out] Fix zero initialization 2021-07-20 16:28:44 -04:00
Gordon-F e017cb402e [glsl-out] Add stage postfix for block structs 2021-07-20 16:28:44 -04:00
Zicklag 34b486f74b Add Explicit Int Precision for GLSL ES Backend 2021-07-20 10:16:33 -04:00
Dzmitry Malyshau 7b9b56a6ab hlsl-out: use * for vector by vector multiplication 2021-07-20 09:57:59 -04:00
Gordon-F 3c98cc5ae1 [hlsl-out] Validate all entry points in Makefile 2021-07-20 01:03:58 -04:00