Commit Graph

9 Commits

Author SHA1 Message Date
Ben Clayton f1f56b2d3c tint/writer/glsl: Set default precision to highp
WGSL states that `f32` is a IEEE-754 binary32. mediump precision guarantees are much smaller than highp, and using mediump can break code generated by tint.

Change-Id: I8a129c4c8ac078c785e0d5d7d21f19ed6b3620b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123400
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2023-03-09 19:58:23 +00:00
dan sinclair 6cc183c85a Generic template and forward in stringstream.
This CL updates the templates in the StringStream to match more types.
All of the internal `operator<<` methods have been converted over to
StringStream. The precision was increased in order to better match the
precision needed to read back as a double.

Bug: tint:1686
Change-Id: Iaa15cf247f174967dd1014647ba5a74804997c22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122080
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-02 21:28:45 +00:00
Ben Clayton d6daefc379 wgsl: Print abstract-floats with full precision.
Change-Id: Ie95547f065b896983b90ffd5455538fdd843b81a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104824
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-10-12 19:13:38 +00:00
Ben Clayton 7d34de88f1 tint/test-runner: Split expectations for FXC and DXC
Change tint's `--fxc` flag to take the path of the FXC compiler DLL.
Have tint attempt to validate with both FXC and DXC if `--validate` is
passed.

Fix the 'dirsWithNoPassExpectations' logic which looks like it got
broken with the tint -> dawn merge. It also incorrectly applied
filepath.FromSlash() on windows.

Change-Id: I0f46aa5c21bc48a2abc48402c41f846aff4a8633
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96800
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-22 17:43:27 +00:00
Zhaoming Jiang 66d4f6e6fb tint/writer/spirv: Support for F16 type, constructor, and convertor
This patch make SPIRV writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

Currently SPIRV writer will require 4 capabilities in generated SPIRV:
`Float16`, `UniformAndStorageBuffer16BitAccess`,
`StorageBuffer16BitAccess`, and `storageInputOutput16`.

Bug: tint:1473, tint:1502
Change-Id: Ia1af04f1f4a02bf1b1c2599a5d89791854eabc16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-12 12:35:09 +00:00
Zhaoming Jiang 0d3d3210d4 tint/writer/glsl: Support for F16 type, constructor, and convertor
This patch make GLSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented, and
end-to-end testcases are updated for GLSL extension requirement.

The GLSL writer will require `GL_AMD_gpu_shader_half_float` extension if
f16 WGSL extension is enabled, emit f16 literal as `1.23hf`, and map f16
types as follow:
WGSL type   -> GLSL type
f16         -> float16_t
vec2<f16>   -> f16vec2
vec3<f16>   -> f16vec3
vec4<f16>   -> f16vec4
mat2x2<f16> -> f16mat2
mat2x3<f16> -> f16mat2x3
mat2x4<f16> -> f16mat2x4
mat3x2<f16> -> f16mat3x2
mat3x3<f16> -> f16mat3
mat3x4<f16> -> f16mat3x4
mat4x2<f16> -> f16mat4x2
mat4x3<f16> -> f16mat4x3
mat4x4<f16> -> f16mat4

Bug: tint:1473, tint:1502
Change-Id: I7e788f82be2873911961c891a644200c1cbb74db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95684
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-11 03:02:28 +00:00
dan sinclair b29892be09 Update src/tint unittests to new @stage format.
This CL updates all of the Tint unittests to the new @stage shorter
syntax. This also updates the WGSL writer to emit the new short forms
instead of using the deprecated form.

Bug: tint:1503
Change-Id: I8c49e5319a19cccb5b4b5078f3ab39c50f31a9a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92483
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-07 13:55:34 +00:00
Ben Clayton 7f2b8cd8fc tint: Refactor Extensions / Enables.
* Extract ast::Enable::ExtensionKind to ast::Extension.
* Move the parsing out of ast::Enable and next to ast/extension.h
* Change the ast::Enable constructor to take the Extension, instead of
  a std::string. It's the WGSL parser's responsibility to parse, not the
  AST nodes.
* Add ProgramBuilder::Enable() helper.
* Keep ast::Module simple - keep track of the declared AST Enable nodes,
  don't do any deduplicating of the enabled extensions.
* Add the de-duplicated ast::Extensions to the sem::Module.
* Remove the kInternalExtensionForTesting enum value - we have kF16
  now, which can be used instead for testing.
* Rename kNoExtension to kNone.

Bug: tint:1472
Change-Id: I9af635e95d36991ea468e6e0bf6798bb50937edc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90523
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-18 22:41:48 +00:00
Zhaoming Jiang 7098d3d692 tint: Add enable directive for extensions
In this CL the enable directive is implemented.
1. Add AST node for enable directive, assign a ExtensionKind (enum) for
each supported extension.
2. Use an unorder_set in ast::Module to record all required extensions'
kind.
3. Provide inspector methods for getting names of used extension, and
getting all used enable directives' extension names and location.
4. For different writer, the extension nodes are handled in different
ways. MSL and HLSL writers will just ignore the extension nodes, while
SPIRV and GLSL writers will emit corresponding code.
5. Implement unittests and end2end test for enable directive and
inspector, using a reserved extension name `InternalExtensionForTesting`.

Bug: tint:1472
Change-Id: I40cb4061554deb477bc2005d7e38c9718385f825
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-04-27 02:27:52 +00:00