Commit Graph

419 Commits

Author SHA1 Message Date
Ben Clayton db89595550 tint: Add a Count() method to BlockAllocator.
Tells you how many things you've allocated.
Will be used for various optimizations.

Change-Id: I8a31bb06e2b23781245bbfd16fabc9b85e440d14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96142
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 23:42:14 +00:00
Ben Clayton 6a80ce6c66 tint/resolver: Use the intrinsic table for type const dispatch
Use the @const annotations to more efficently dispatch to the right
method of the ConstEval class.

Reduces a whole lot of dynamic casting logic.

Change-Id: I6791aac51b935b46d63af29abd1e577b3306a0ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95950
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2022-07-15 22:27:50 +00:00
Ben Clayton 8b0ceea0b1 tint: Clean up legacy type cruft
Fix TODOs dating back to when types were an AST / SEM hybrid concept.
Bring the `arch.md` to reflect how things work today.

Bug: tint:724
Change-Id: I6bf4174158cf490f2839aeed78164b66e3410f27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96141
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 17:16:49 +00:00
Ben Clayton f19cb029b8 tint: Remove single scalar matrix constructors.
These were never part of the spec, and they were not correctly
implemented for all backends.

Fixed: tint:1597
Change-Id: If1a23f1619c61c53baae277f1cf37aee4460ab7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95952
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 15:25:30 +00:00
Ben Clayton 65c5c9d92b tint/resolver: Add ConstEval class
Extract out the methods of Resolver::EvaluateXXXValue() to a new
tint::resolver::ConstEval class.

Removes more bloat from Resolver, and creates a centralized class for
constant evaluation, which can be referred to by the IntrinsicTable.

Change-Id: I3b58882ef293fe07f019ad2138a7e9dbbac8de53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95951
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-15 14:14:09 +00:00
Ben Clayton cfe07a1b33 tint/resolver: Shuffle validation code
Restructure the logic so there's less, pointless dynamic casting, and the complexity is reduced.

This alters the order in which variables are validated, hence the change of test.

Change-Id: I9a3120c0278faa5ac9f1db65eeb71a8e4a705596
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95948
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 13:01:49 +00:00
Zhaoming Jiang e0ecd86e73 tint/writer/glsl: Fix emitting float modulo with mixing type
This patch fix the GLSL writer issue that emit only one helper function
when using both `v % s`, `s % v` and `v % vs in the shader, where `s` is
of `f32` and `v` is a vector of `f32`. Unittests are added for GLSL.

Bug: tint:1614
Change-Id: Ia89ae010341b9c88b8101cc6febab7d83c96bb17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96085
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-07-15 11:05:29 +00:00
Ben Clayton 32bdf41ed3 tint/resolver: Remove logic for module-scope let
This has been replaced with module-scope const.

Change-Id: I03d5e076cf150d2931c9cfb1c6025e98200d91a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95947
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-15 09:17:29 +00:00
Ben Clayton 6c098baedf tint: Implement constant expression structures
Bug: tint:1611
Change-Id: Id04c31ade297a68e7e2941efafbd812ba631fc41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95946
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-14 20:46:39 +00:00
Ben Clayton 2a8c00f53a tint: Limit const expr vector reserve size
The `el_count` will match the WGSL declared array size *before validation*.
Fuzzers have started triggering out-of-memory cases by constructing large constant arrays, just to then error out.

Bug: chromium:1343963
Change-Id: I537ff3a570fe56b40e510b3bc6dfcd9b9752386a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96102
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-07-13 14:28:23 +00:00
Zhaoming Jiang 9a32a720ac tint/writer/wgsl: Support for F16 type, constructor, and convertor
This patch make WGSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

Bug: tint:1473, tint:1502
Change-Id: Id2a5eec54b95add330366cf141b36999e604a63b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95990
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-13 08:49:20 +00:00
Ben Clayton 51719ccc01 tint: Fix SPIR-V validation around interpolation decorations
SPIRV-Val has tightended up validation around input / output interpolation decorations.
This change ensures that the parser and writer do the right thing.

Change-Id: I29c97fdcc48c62aa77b106c42e64fbc54204d607
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-12 19:10:39 +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
Ben Clayton 8ce7183e68 tint: Remove public include of ast include
ast::PipelineStage is private API. Duplicate the enum for the inspector.
Change-Id: Ib79600d2ef86cc13f409c7c800f98ea42bb3ace4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95943
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-07-11 17:17:23 +00:00
Zhaoming Jiang a5988a3058 tint/writer/hlsl: Support for F16 type, constructor, and convertor
This patch make HLSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

The HLSL writer will emit f16 literal as `float16_t(1.23h)`, making the
type explicit, and map f16 types as follow. The generated code require
DXC with SM6.0 or higher, and `-enable-16bit-types`.
WGSL type   -> HLSL type
f16         -> float16_t
vec2<f16>   -> vector<float16_t, 2>
vec3<f16>   -> vector<float16_t, 3>
vec4<f16>   -> vector<float16_t, 4>
mat2x2<f16> -> matrix<float16_t, 2, 2>
mat2x3<f16> -> matrix<float16_t, 2, 3>
mat2x4<f16> -> matrix<float16_t, 2, 4>
mat3x2<f16> -> matrix<float16_t, 3, 2>
mat3x3<f16> -> matrix<float16_t, 3, 3>
mat3x4<f16> -> matrix<float16_t, 3, 4>
mat4x2<f16> -> matrix<float16_t, 4, 2>
mat4x3<f16> -> matrix<float16_t, 4, 3>
mat4x4<f16> -> matrix<float16_t, 4, 4>

Bug: tint:1473, tint:1502
Change-Id: Iaf564f3ce29ace2984cef19d7df5a7dfb0fab2ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95685
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-11 15:43:38 +00:00
Zhaoming Jiang e9c5070348 tint/writer/msl: Support for F16 type, constructor, and convertor
This patch make MSL writer support emitting f16 types, f16 literals,
f16 constructor and convertor. Unittests are also implemented.

The MSL writer will emit f16 literal as `1.23h`, and map f16 types as
follow:
WGSL type   -> MSL type
f16         -> half
vec2<f16>   -> half2
vec3<f16>   -> half3
vec4<f16>   -> half4
mat2x2<f16> -> half2x2
mat2x3<f16> -> half2x3
mat2x4<f16> -> half2x4
mat3x2<f16> -> half3x2
mat3x3<f16> -> half3x3
mat3x4<f16> -> half3x4
mat4x2<f16> -> half4x2
mat4x3<f16> -> half4x3
mat4x4<f16> -> half4x4

Bug: tint:1473, tint:1502
Change-Id: Id91821e1a32d48c80bad9a0753faa5247835b0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95686
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-07-11 03:03:11 +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
Zhaoming Jiang 9c71174f38 tint/resolver: Temporally ban f16 in buffer, pipeline IO and override
This patch make resolver reject using f16 types in uniform or storage
buffer, pipeline IO or overridable variable, since these are not
implemented yet. This can help prevent hitting invalid path in writers.

Bug: tint:1473, tint:1502
Change-Id: I5ea753e4254276a6d141d7012a6d0987423a61cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95827
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-08 19:35:05 +00:00
Ben Clayton d31838aff1 tint: Fix x86 build
Change-Id: Idb2002dd59cf12e49f75af6174e08258b4331137
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95840
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-07-08 12:17:34 +00:00
Ben Clayton 63e6f820d8 tint/resolver: Evaluate const-expr swizzles
Bug: chromium:1341475
Change-Id: I2ac44824b08c460df759a96d0ba96f6045b60f74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95765
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-07 17:49:02 +00:00
Ben Clayton d5f53ab580 tint/resolver: Optimize constant evaluation methods
Materialize() was re-evaluating the constant values for the incoming
semantic expression, despite this already being evaluated. Just use the
sem::Expression::ConstantValue().

resolver.cc already has all the semantic pointers, so pass them in
instead of pointlessly hitting the ast -> sem map.

Change-Id: If2bc7cd10f79079fb811e9d83c5150dd3c0c244c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95764
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-07 17:30:11 +00:00
Ben Clayton 51265542e9 tint/sem: Remove TypeMappings for derived expressions
Any AST expression may map to a sem::Materialize, so the inferred
mapping is bug-prone (the implicit sem type may mismatch and Get() may
return nullptr).

Change-Id: I34485a4a067635df930a407316fae8b2e9628c3d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95763
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-07 17:15:01 +00:00
Ben Clayton b6c8ea9624 tint/resolver: Fix calling of builtins at module-scope
No builtins are implemented as `@const` yet, but validation handles this already.

Bug: chromium:1341472
Change-Id: Id85893345299ba3414e2d15b85dd071c326f481d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95762
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-07-07 17:04:21 +00:00
Ben Clayton 89bdea0f77 tint/resolver: Fix null-deref
Materialize() can return nullptr, if there's an error.
Check the returned pointer for nullptr, before continuing on to using the pointer.

Bug: chromium:1341313
Change-Id: Ib7c9e593fbf2bb4374305c341c2b04e34e7487e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95761
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-07 16:56:21 +00:00
Zhaoming Jiang 2c7440a13f tint: Implement f16 value binary representation
This CL add methods that return the binary16 bit pattern for a
constructed Number<detail::NumberKindF16>. This is required for
generating SIPR-V oprand.

Bug: tint:1473, tint:1502
Change-Id: Ia3680cdb5a0e64d31bfe2f48432cda3850c1f5a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95240
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-07-07 03:29:11 +00:00
David Neto 760c399cfb Delete tests with invalid SPIR-V inputs
The structured CFG rule was revised/clarified in SPIR-V 1.6 Rev2
Validation now rejects a few cases.

SpvParserTest, ValueFromBlockNotInBlockOrder
SpvParserFunctionVarTest, EmitStatement_Phi_ValueFromBlockNotInBlockOrderIgnored
SpvParserFunctionVarTest_EmitStatement_Phi_ValueFromBlockNotInBlockOrderIgnored
  - Originally from crbug.com/tint/804
    Invalid by SPIR-V 1.6 Rev2 update to validation rules:
     - Block 80 is a structurally reachable continue target
     - Block 25 is not structually reachable, and not part of the loop,
       but branches to 80.

vk-gl-cts/graphicsfuzz/cov-dead-branch-func-return-arg/0-opt.*
  -  The continue construct with the continue target 37[%37]
     is not structurally post dominated by the back-edge block 64[%64]
  - The SPIRV-Tools inliner no longer creates such cases.  It splits the
    single-block loop and pushes the continue target down.

vk-gl-cts/graphicsfuzz/nested-for-loops-with-return/0-opt.spvasm
  - The loop headed at block 46 does not structurally dominate its merge
    block 44.  There is a continue-target edge from 41 to 44.

SpvParserCFGTest_ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsHeader.spvasm
SpvParserCFGTest_EmitBody_Loop_MultiBlockContinueIsEntireLoop.spvasm
SpvParserCFGTest_LabelControlFlowConstructs_MultiBlockLoop_HeaderIsContinue.spvasm
SpvParserCFGTest_SiblingLoopConstruct_ContinueIsWholeMultiBlockLoop.spvasm
SpvParserCFGTest, ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsHeader
SpvParserCFGTest, EmitBody_Loop_MultiBlockContinueIsEntireLoop
SpvParserCFGTest, LabelControlFlowConstructs_MultiBlockLoop_HeaderIsContinue
SpvParserCFGTest, SiblingLoopConstruct_ContinueIsWholeMultiBlockLoop
 - Continue target 20 also its own loop header, but is not structurally
   post-dominated by the backedge block.
 - Delete the end-to-end test.
 - Keep the unit test because it's about classifying edges, but disable dumping
   into the end2end suites.

Change-Id: I9ec2504aadd2fec9ea463901af7dc1b5f47481b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2022-07-06 01:45:30 +00:00
dan sinclair cfa951a662 tint: Remove semicolon as struct member delimeter
Fixup a couple of internal Dawn shaders that used this syntax.

Fixed: tint:1475
Change-Id: Ibd6b3309944bfd955e724fef5d71d1297a84ef5f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93361
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-07-04 16:58:00 +00:00
dan sinclair 5286ea9d16 tint: Disallow write-only storage buffers
These have not been in the spec for a long time. The read_write access
mode can be used instead.

Fixed: tint:1342
Change-Id: I01ffc343d2d2f9df9d7028bba4548c749616c65c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93500
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-07-04 15:17:00 +00:00
Antonio Maiorano c0d51f1cd8 tint: spirv reader: detect and replace loads and stores of atomic variables with atomicLoad/Store
Bug: tint:1441
Change-Id: Iee89cb87ca063d8a98ff8ad789ba14dee65c036a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95140
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-06-29 22:21:31 +00:00
Ben Clayton c7d6ab6c5a tint: Prevent function calls at module-scope
Bug: chromium:1339723
Bug: tint:1606
Change-Id: Ia2e10d6ac38fde0a9c851d279fe07f50f108546e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95081
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-29 19:19:31 +00:00
Ben Clayton aa037ac489 tint: Refactor sem::Constant to be less memory-hungry
Change sem::Constant to be an interface to the constant data. Implement
this so that zero-initialized data doesn't need to allocate the full
size of the type.

This also makes usage a lot cleaner (no more flattened-list of
elements!), and gives us a clear path for supporting constant
structures if/when we want to support them.

Bug: chromium:1339558
Bug: chromium:1339561
Bug: chromium:1339580
Bug: chromium:1339597
Change-Id: Ifcd456f69aee18d5b84befa896d7b0189d68c2dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94942
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-29 19:07:30 +00:00
Ben Clayton cf52af7b0f tint: Have Number equality consider sign
Sign is important for equality when it comes to backend generation
of floating point numbers.

Change-Id: I1e2610fe9bae98a5c5f756a55385e092919b5aa3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95080
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-29 17:09:11 +00:00
dan sinclair 3a2a279714 Fixup various warnings in Tint which were accidentally suppressed.
When enabling the SPIR-V reader or SPIR-V writer we were suppressing
-Wnewline-eof, -Wold-style-cast, -Wsign-conversion, and -Wweak-vtables
for the `libtint` cmake target and anything that depended on that
target. Because we'd build all readers/ writers by default this caused
us to never hit those warnings.

A recent change to the cmake build sets the Tint backend based on
the Dawn backend. So, there is a much higher chance of not building
the SPIR-V support if you're on a Mac or Windows machine.

This CL removes the suppression of the warnings, adds specific pragmas
into the SPIR-V reader code which imports the SPIRV-Tools headers
and fixes up the warnings which were then firing due to checking
for the new warnings.

Change-Id: I0d0be6aa3d0b692e939ce8ff924dfb82c82792fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94901
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-29 14:38:15 +00:00
Ben Clayton 2b4df78891 tint/number: Fix CheckedConvert() logic
This function was attempting to pick a higher-precision type by using
the decltype() of FROM + TO. This doesn't work if FROM and TO are both
similar bit-widths, and of a different signness, as the picked type may
not be wide enough to hold both the signed and unsigned representation.

Just use AInt or AFloat (both 64-bit), which are the largest types
supported by WGSL.

Change-Id: Ic76475d98bad8def12a0283a1c83c62f2ed58b5d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95041
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2022-06-29 11:31:41 +00:00
Ben Clayton 72876c14c3 tint/sem/constant.h: Remove #include to program_builder.h
This pulls in the entire world, and isn't needed from this header.
Remove it. Fix all the places that were transtively depending on
program_builder.h's includes.

Change-Id: I5209dcd387fb47dd6744a3d676997338b8f45473
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95040
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-06-29 10:58:41 +00:00
Ben Clayton c64ca23d94 tint: Deprecated module-scope 'let' for 'const'
Enable the parsing of 'const'.
Warn on use of module-scope 'let', and automatically replace with 'const'.

Fixed: tint:1580
Change-Id: I214aabca80686dc6b60ae21a7a57fbfb4898ea83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93786
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-29 00:55:36 +00:00
dan sinclair d23f296a9a tint: Implement acosh, asinh, atanh
Polyfill them completely for HLSL.

For the other backends, just add range checks for acosh and atanh.

Fixed: tint:1465
Change-Id: I3abda99b474d9f5ba09abf400381467dc28ea0bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94380
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 15:27:44 +00:00
Zhaoming Jiang 6058882d4b tint/resolver: Add f16 types, constructor, and conversions
This patch add f16 types and their constructors and conversions in
resolver and intrinsic table. Also implement relating unit tests.

Bug: tint:1473, tint:1502
Change-Id: Ida1336193a72a73959e50e6a3eb12be44c0396b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94642
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 14:03:36 +00:00
Ben Clayton 53af158366 tint/reader: Allow module-scope 'var' type inferencing
Fixed: tint:1584
Change-Id: I193ad2c00faa4ae2001d981bb38a55d4d6a4c269
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94687
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-28 12:53:56 +00:00
Ben Clayton 19576e9015 tint/writer: Handle and emit 'const' variables
Bug: tint:1580
Change-Id: Ib3a5ff5c567e19eca1ba8fb3c2f7e83dee68e2a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94686
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-06-28 12:44:16 +00:00
dan sinclair 6c167a0dc7 msl: Promote local private vars to function scope
If a module-scope private variable is only referenced within a single
function, promote it to a function scope declaration instead of
passing it as a parameter. This reduces the number of a function
parameters that are needed in some cases.

Bug: tint:1509
Change-Id: I8951f6216bc7e4cf5abfda314bea1e9ed3ded560
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94002
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-28 02:06:05 +00:00
Ben Clayton 7ebcfc7e0e tint/transform: PromoteInitializersToLet
Rename PromoteInitializersToConstVar to PromoteInitializersToLet, and
implement promotion of 'const' variables that resolve to array types.

This is required, as the backends will inline variables that resolve to
'const' variables, and so we need to promote any 'const' values that
would emit an array constructor.

Bug: tint:1580
Change-Id: I1b7f5459512b0043385ba741d644ec776c912899
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94684
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-27 20:20:25 +00:00
Antonio Maiorano ce466c0df3 tint: spir-v writer: Fix matrix constructor from matrix variable
Bug: tint:1603
Change-Id: I580a450daa9392316cb628ceeb16490ec591deba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94860
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2022-06-27 20:07:45 +00:00
Ben Clayton 54b3da95f8 tint/transform: Handle 'const' for Unshadow.
Bug: tint:1580
Change-Id: I0af473ac13abde1f1890851aeb92812be6a52933
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94682
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-26 14:38:30 +00:00
Ben Clayton fcf9fdcad8 tint/writer/wgsl: Emit 'const' variables
Bug: tint:1580
Change-Id: Iea2a38814757f79ba645c94cfa89fe84b5d200d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94681
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-26 12:40:40 +00:00
Ben Clayton f90313396b tint/reader/wgsl: Drop const_expr parsing
The WGSL specification changed so that the enforcing of
initializers being only const-expr is no longer done by the
grammar. This is change is required to allow for 'const' expressions to
reference each other.

Bug: tint:1580
Change-Id: Ia95b6a0bc86ce391a38f4248f20898dd9a6cf27f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94683
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-06-26 11:36:10 +00:00
Ben Clayton e48ef8ef90 tint/reader: Enable 'const' parsing for unit-tests
This enables the WGSL parsing of 'const' for only tint_unittests,
allowing code to be split up into smaller chunks for review.

Once all the logic is submitted to handle 'const', the test-only
flag will be removed, and 'const' will be enabled for production.

Bug: tint:1580
Change-Id: I3189b6bd15445ecc3fa1cd6f568885e7ba3c91c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94680
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-26 10:52:50 +00:00
Ben Clayton 511529f082 tint/resolver: Clean up workgroup-size error diagnostic
Change-Id: I09cc3e15c1f62d7a104e9727a104f3b2bfc9c973
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94607
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-26 09:05:00 +00:00
Ben Clayton 410a3bd19a tint/resolver: Propagate constant values between 'const's
Required for 'const' values that use other 'const' values in their
expressions.

Bug: tint:1580
Change-Id: I1d86281bec19340fdc0c60dc5b22eb3d6dc04cf5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94606
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-06-26 08:40:00 +00:00
Ben Clayton e3834c4760 tint/resolver: Resolve 'const' variables
The frontends do not currently emit these, nor do the backends currently
handle them.

Bug: tint:1580
Change-Id: I469a5379663c2802145b28a94f5c1e348cc14ff3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94605
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2022-06-25 23:21:39 +00:00