Commit Graph

2 Commits

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