Commit Graph

5 Commits

Author SHA1 Message Date
Stephen White b1d2b84f7d GLSL: fix clip space mismatch in gl_Position.
OpenGL clips against [-w, w], while WebGPU uses [0, w]. The fix is to
modify gl_Position.z on output to match GLSL semantics. (This is the
same code used by SPIRV-Cross under the fixup_clipspace option.)

Bug: tint:1401
Change-Id: I1b1511352eee11cd9b095cd809aa8e1263c6cf4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78261
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-26 14:45:55 +00:00
Stephen White fc792989e1 GLSL: implement image format qualifiers for storage textures.
Bug: tint:1397
Change-Id: Ifd6870b3e7cba151c361bd21f9d3d42642ff6c26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78060
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Stephen White <senorblanco@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-25 19:20:04 +00:00
Stephen White f9b8b6104d GLSL: implement CombineSamplers transform (string version).
This transform converts all separate texture/sampler references
in a program into combined texture/samplers. This is required for GLSL,
which does not support separate texture/samplers.

As input, the transform requires a map from the unique sampler/texture
pairs previously gathered by the Resolver to strings, which will be
used as the names of the newly-generated combined samplers. Note that
binding points are unused by GLSL, and so are set to (0, 0) with
collision detection disabled.

All function signatures containing textures or samplers are rewritten,
as well as function calls and texture intrinsic calls. For texture
intrinsic calls, a placeholder sampler is used to satisfy the subsequent
Resolver pass (GLSL texture intrinsics do not require a separate sampler,
but WGSL intrinsics do). The placeholder is also used if the shader
contains only texture references (e.g., textureLoad).

Bug: tint:1366

Change-Id: Iff8407d28fdc2a8adac5cb655707a08c8553c389
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77080
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-24 17:17:22 +00:00
Stephen White 0ff3050c6c GLSL: a grab bag of texture fixes.
Use imageSize() on images, not textureSize().
In GLSL, the LOD parameter to textureSize() is mandatory for
sampled textures, so emit a default 0 if not supplied. (Also, don't pack
the level into the coords argument; that's an HLSLism.)
GLSL returns the array size of array textures in the final component
of textureSize(); remove it for WGSL.
Write the subtype of storage images correctly (uimage*, iimage*, etc).
This required a bit of cleanup to move "writeonly" ahead of subtype
emission.

Bug: tint:1298
Change-Id: Ica1cec0f833a9b684143c8b0cf6d090fb511a7d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70140
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-11-19 19:06:23 +00:00
Stephen White 2fe0f4b42b GLSL: add .expected.glsl files for all tests.
Bug: tint:1301
Change-Id: Id3a591a2fa0dfdb112046d5c57defbae07483e0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69480
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-11-16 15:15:36 +00:00