Commit Graph

4 Commits

Author SHA1 Message Date
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