We have `GlobalLet()`, `Let()`, `Var()`, so this just
keeps things consistent
Change-Id: Ie9f79b62e737a15b995c5a2b19f84621a5ac3cc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94604
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
GlobalConst() is going to mean a module-scope `const`, once we
support `const`. `GlobalLet()` will then be removed.
Bug: tint:1580
Change-Id: Ie00e9ccdee8c111266850bfe1e1e24f022a59a06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94603
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Use the constant evaluated value instead of manually traversing
variables to find the literal value. This is a small step towards
supporting 'const' values for array sizes.
Also make our OOB-byte related error diagnostics consistent.
Bug: tint:1580
Change-Id: Idf9eb22cdbf69d750218c554e9f826c30458c6b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94600
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
The following operations are supported:
OpAtomicLoad
OpAtomicStore
OpAtomicExchange
OpAtomicCompareExchange
OpAtomicCompareExchangeWeak
OpAtomicIIncrement
OpAtomicIDecrement
OpAtomicIAdd
OpAtomicISub
OpAtomicSMin
OpAtomicUMin
OpAtomicSMax
OpAtomicUMax
OpAtomicAnd
OpAtomicOr
OpAtomicXor
These are not, but may be supported in the future:
OpAtomicFlagTestAndSet
OpAtomicFlagClear
OpAtomicFMinEXT
OpAtomicFMaxEXT
OpAtomicFAddEXT
Bug: tint:1441
Change-Id: Ifd53643b38d43664905a0dddfca609add4914670
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94121
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Split tests up by variable type, and group them.
Change-Id: I4a9ae620883cd2acc05745b54f85df7b3fe7ac3d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94602
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Gives us a place to put `const` and `override` tests.
Bug: tint:1580
Change-Id: I0340c37e96f796d2f879d4045623b35927e45c78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94601
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Also store expression object in MemberAccessorExpression, as well as the
struct on sem::StructMember.
These are used to implement spir-v reader atomics in a follow-up CL.
Bug: tint:1441
Change-Id: Iea49cfb7f9d2e7898d89d2dac6a16a14022c546f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94523
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Once 'const' is introduced, let will no longer resolve to a
creation-time constant value.
Add temporary code into each of the writers to prevent constants that
originate from a 'let' from being inlined. This will reduce the amount
of noise in later CLs.
Bug: tint:1580
Change-Id: Id3493a43ac09fe9f042ff2d517d04b2ae854d43e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94541
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This patch fix the issue of identity matrix constructors in HLSL. This
patch also fix dawn e2e tests for identity matrix constructors and zero
matrix constructors.
Bug: tint:1596, tint:1545
Change-Id: I6c41eb299c1d5f89cf18720611f450abae26d3f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94042
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
And remove the WrapArraysInStructs transform.
Wrapping arrays in structures becomes troublesome for `const` arrays, as
currently WGSL does not allow `const` structures.
MSL 2.0+ has a builtin array<> helper, but we're targetting MSL 1.2, so
we have to emit our own. Fortunately, it can be done with a few lines of
templated code.
This produces significantly cleaner output.
Change-Id: Ifc92ef21e09befa252a07c856c4b5afdc51cc2e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94540
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
https://github.com/gpuweb/gpuweb/issues/3056 proposes that creation-time
constant expressions should support arrays. We have verbal agreement to
update to spec to support const arrays.
Bug: tint:1580
Change-Id: If460f729384d700a1c2149c5b7dbe8613a960184
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94330
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Check more stuff.
Change-Id: I99ba3200bb72975e9b0a740d632f7766d38e9a84
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94334
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Remove duplicate tests.
Use a common pattern of sanitizing, building and dumping the whole
module instead of calling individual methods. There's too much internal
state being tracked in the tests for my liking.
Split most tests into three:
* Const_* tests will check the emission of creation-time-constant
expressions.
* Runtime_* tests will check the emission of runtime expressions, where
indexing operates with a constant index.
* Dynamic_* tests will check the emission of runtime expressions, where
indexing operates with a runtime index.
Bug: tint:1580
Change-Id: I0f92aaaa570cbd917d2b6937c6396605c6b542c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94333
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Aside from more SPIR-V using OpConstantNull, this is a no-op change.
By refactoring these methods, they're easier to read, and contain less
lambda-heavy code.
Change-Id: I89c26b2b9f1cd0785d86fb3293f7cfda550bef2e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94331
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
If the object and index are both constant expressions, resolve the
index as a constant.
Note: Expectations have been updated for indexing on 'let's. Once
'const' is introduced, 'let' will no longer be treated as a constant
expression, and these expectations will be reverted.
Bug: tint:1580
Change-Id: I42793d36c1a5f82890ccaa5dbbb71b4346493bef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94329
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Also fix HLSL generator to unwrap the ref type when emitting the
comparator value.
Bug: tint:1185
Change-Id: I01d04ca6357e72fd5ead0f25012ab39794e65da5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94522
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL moves the Tint unittest code behind a build flag in order
to hide the //testing/test.gni dependency from downstream consumers.
The unittests are enabled by default and can be disabled by setting
`tint_build_unittests` to false.
Bug: dawn:1517
Change-Id: Id560ed98416ba0725b62a93ddd27caf341699e75
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94481
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Checks whether the range of elements are all zero.
Change-Id: I22b91bff25f3fb7fd0e89abd690f139614300e81
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94328
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Return the column vector type, instead of the column vector element
type. This matches what you'd get if you were to index the matrix.
DeepestElementOf() can be used to easily obtain the matrix column
element type.
Change-Id: I5293f4cca205c9e378253ac67880bf9d998814aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94327
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
These functions do not return an error - however they might return an
invalid Constant value (if a constant cannot be evaluated), which is
correctly handled by the resolver. So, drop the Result, just emit a
sem::Constant.
Change-Id: I0dd37125c0dba4ba6dcace5ee5f8b1c53cb34d33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94326
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Like `ElementOf()`, but returns the most nested element type.
Change-Id: Ieb97f830293d4714d0d5ddc0c9304e41e994f61b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94324
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Nothing currently generates or consumes these (yet).
Bug: tint:1580
Change-Id: I892956d33fcd587be85659781108a236b2839b3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94323
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
If the abstract numeric cannot materialize to the target type, we could
ICE before the validation handles this bad case. To fix, simply hoist
the validation earlier.
Bug: chromium:1337524
Change-Id: Icc603b056900131cfdb029b517f1c3d030b2ecb4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94322
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Split the logic out of Resolver::Variable().
Primes the resolver for the introduction of 'const'
Bug: tint:1580
Change-Id: Id67280ed5c8c73a69c62728fb5a81a08f13628a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93785
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Split the logic out of Resolver::Variable().
Also correctly allows type inference of module-scoped 'var's.
Fixed: tint:1584
Change-Id: I32eb11f0a847775137fef937da6f4032a3b3c2b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93784
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
For this transform, this will help when we promote private variables
to function scope when only referenced by a single function.
Bug: tint:1509
Change-Id: I04f7b8e1a8531a13317617604a49cafe4f7d47f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94001
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Split the main Process() function up into smaller functions to make it
less unwieldy.
Change-Id: Ibbe3141a82221879b9d4ed232eebdd0344f1698c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94000
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
The depot_tools cpplint.py has been updated to accept the c++17 headers
so we no-longer need to mark with NOLINT.
Bug: dawn:1379
Change-Id: I938a4cac5ca881cd1b556f4b8d58741b6a1e6af1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94240
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Now that we have untyped literals, we can just add `1` rather than
adding either `1u` or `1i`.
Bug: tint:1488
Change-Id: I59512be8fc67b1bf45088478da7c93bed37a69b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94141
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This patch make VectorizeScalarMatrixConstructors transform run for
reference to scalar as well as scalar types node, i.e. run for
`mat2x2<f32>(v[2])`, where `v` is a f32 vector, as well as
`mat2x2<f32>(1.0)`.
Bug: tint:1589
Change-Id: I5d3e367ee6a9826b3e1add3495aaac0ae326be14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94023
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This Cl moves the contents of the test/tint/BUILD.gn file into the
src/tint/BUILD.gn file. This moves the tests into the same build file as
what is being tested. This is more in line with how the CMakeLists.txt
file is setup.
This removes the need to update 2 BUILD.gn files when adding new files
and tests to tint.
Bug: tint:1517
Change-Id: I9beb8a8bff7c10ac875647246ad4362f7e60f7da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94040
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Validating sampled and multisampled texture types does not belong in Validator::Variable().
Change-Id: Ie0f2502508c28af6fb6d3f4d7803171d946c511b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93783
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Add the new classes:
* `ast::Let`
* `ast::Override`
* `ast::Parameter`
* `ast::Var`
Limit the fields to those that are only applicable for their type.
Note: The resolver and validator is a tangled mess for each of the
variable types. This CL tries to keep the functionality exactly the
same. I'll clean this up in another change.
Bug: tint:1582
Change-Id: Iee83324167ffd4d92ae3032b2134677629c90079
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93780
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This patch fix the issue that HLSL generator emit wrong constant
element index for vectors with all elements being the same, which may
cause error when emitting a matrix constant with sub columns having
identical elements.
Corresponding unit test is implemented.
Bug: tint:1588
Change-Id: Ia40b3f1a676d84aadaa5ce900677547fb15abe7f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94041
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
The generators were not setting `emit_continuing_` when emitting while
loops. This caused a crash when a `continue` was encountered. This CL
adds the `emit_continuing_` setup to the while emission. It also guards
the `emit_continuing_` usage with making sure the function is setup.
Bug: tint:1490
Change-Id: Ia89c49e567acda71a1f851a582103723cff71d49
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93960
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
The while loop and let error message landed about the same time and there were
merging issues that didn't get caught by CQ.
Change-Id: I5cd606f1809cc29fa2366d3b78883fa0cfc3b394
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93961
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Standarize the messages, using 'let', 'override' or 'var'.
Module-scope 'let' needs to be replaced with 'const', but baby steps.
Bug: tint:1582
Change-Id: I290aede118a30ab0f4294c89ec43005371c87b45
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93446
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This patch change DependencyAnalysis::SortGlobals() to make sure that
'enable' directive nodes go before any other global declarations in the
sorted global node list, and thus ensure that all extensions will be
registered by reslover before dealing with any other global declarations.
This is necessary because some transforms will add AST nodes before any
other global nodes, and these added nodes should be handled by resolver
after 'enable' nodes are handled.
Bug: tint:1472
Change-Id: Idc2253fc055b0f121cb0cafcaca5275c23ed7b0d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93760
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Copy/pasting this transform as a starting point for new transforms
causes the `State` classes to clash, and weird things happen. This
prevents that from happening.
Change-Id: Ia1c6b2b96e4d6375309aed535d7a87372b839792
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93880
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
The new spelling `smoothstep` was introduced in M102.
Fixed: tint:1483
Change-Id: Ia5e1401f8f09450a3a767b0bb975216bd85be8db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93360
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Currently nothing in Tint uses a different allocator type, but this
allows the CloneContext to support different allocators, the day we do.
Change-Id: I70367bd3710128d0708b3369f66b441344b789f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93602
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Parameters don't have storage classes or access qualifiers. This was
just (ab)using the fact that a parameter uses the same AST type as a
'var'.
Also simplify the parameter disable validation logic.
Bug: tint:1582
Change-Id: Ic218078a410f991e7956e6cb23621a94a69b75a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93603
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This is currently identical to ast::VariableList, but once we break
ast::Variable up, this will become a different vector type.
Bug: tint:1580
Change-Id: Ib2db5772996a63cd1989e36f1034dc1fbd3b371a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93601
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Drop the vector typename from the initializer lists. These don't really
provide any significant help in understanding the arguments types, as
the list of element types can be easily inferred.
This is done to simplify the refactor ast::VariableList ->
ast::ParameterList.
Bug: tint:1580
Change-Id: Ibf8564ca9b2bafd2eaa2e4aa54c29be6bbe7a682
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93600
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This patch fix two implicit type conversion to make Kokoro green.
Bug: tint:1473, tint:1502
Change-Id: I7f4d1d71e45a3d8e834625a9f71acc72a8816685
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93343
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This patch
1. Add F16 literal support in WGSL lexer and parser for both decimal and
hex form. Also fix the f16::Quantize method to deal with subnormal cases
correctly.
2. Fix exactly-representable check for hex f32 literal to deal with
subnormal cases.
3. Implement and fix related unitests for f16 and f32.
Bug: tint:1473, tint:1502
Change-Id: Ia4a7c9144ef9323fb23b2200a64e1ca8afb6c334
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93100
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: David Neto <dneto@google.com>
This PR enables the deprecation warnings for the @stage builtin.
Bug: tint:1503
Change-Id: I4a560f451a9ad56bc712f6a04c18eba6ae67ab64
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93121
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Headers exposing functionality from the core Tint library should be
included via include/tint/tint.h.
This fixes the google3 build.
Change-Id: I82a9d0105b3b44fb4c4c89b59e9282290dd49c61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
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>
Attempting to return an abstract-numeric when the function had no return type would trigger an ICE, as an abstract numeric cannot materialize to a void type.
Bug: chromium:1332613
Change-Id: I635ebb8dddb2e7628939607a4f964be62b616745
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL adds the ability to parse the `@compute`, `@fragment` and
`@vertex` attrbutes. The `@stage(...)` are still accepted and are not
marked as deprecated yet.
Most tests are still using `@stage(..)` except for a testing one.
Bug: tint:1503
Change-Id: I85cad5996605035e83109b021ffb13db98b1a144
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92480
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Add support for @const to builtins in intrinsics.def.
Propagate this flag through to the intrinsic table.
Handle builtins that are @const annotated in the resolver.
Currently no intrinsics are decorated with @const, so there's nothing to
test (yet).
Bug: tint:1504
Change-Id: I172483688617782bd7c58b70e3f38d0222a5d1af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92323
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
If the builtin has values passed by literal, let or const, then they may
be evaluated at shader-creation time, which makes the tests almost useless.
Bug: tint:1504
Change-Id: I004f49ec4b3430c8015e65d3fde1f5fa4fdd10f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92322
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Turn on resolving of abstract-integer and abstract-float types, as well
as materialization to their concrete types.
Bug: tint:1504
Bug: chromium:1330805
Fixed: tint:1572
Change-Id: I09c95406e11b64bb0267fe7b1ed08af986dbd553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91840
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This was always constructing the elements with AFloat, when it should pick between AInt / AFloat based on the type T.
Bug: tint:1504
Change-Id: I2dd4a9bcd829c47c9b0e8d730c5f58a5266d3626
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This is required to handle materialized values, and for constant
expressions.
Bug: tint:1504
Change-Id: If0a49e9b03566c06aa6e4e4c284fc427e1541e91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92082
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Constant::AnyZero(), Constant::AllZero() now consider -0.0 as non-zero,
as this is different from WGSL's zero-initializer value for floating
point numbers.
Also consider FP sign for Constant::AllEqual().
Bug: tint:1504
Change-Id: I00503880ee29bd741b94cc98909a8a823e32522a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92243
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This is required to handle materialized values, and for constant
expressions.
Bug: tint:1504
Change-Id: I79ad567954de2d1cfea09dda255894e4e2aa678e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92081
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
In this patch NumWorkgroupsFromUniform::Config changed to storage
std::optional<sem::BindingPoint>, and if it has no value,
NumWorkgroupsFromUniform will choose a free binding group, i.e.
binding 0 of the largest used group plus 1 is used if at least one
resource is bound, otherwise group 0 binding 0 is used. Tint CLI
is also changed to provide a --hlsl-root-constant-binding-point
option allowing user to specify the binding point for num_workgroups
uniform buffer.
Bug: tint:1566
Change-Id: I3b8c22a4276bab722d901f5b07d23a268786c417
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91980
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This is required to handle materialized values, and for constant
expressions.
Bug: tint:1504
Change-Id: Ic3ac62317241fa6f7009360128f222aeb56f62e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This is required to handle materialized values, and for constant
expressions.
Bug: tint:1504
Change-Id: Ie0177f148e08a0e1a3f4d7e06e283f121655804b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92080
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
We were missing an `UnwrapRef` when generating the return type, and
were generating invalid SPIR-V when the value being stored was a
reference. The auto-generated builtin tests only test with literal
values.
Fixed: tint:1573
Change-Id: If42280b3cc8ad3fba7355d333e02400c6db843fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92144
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Once abstract-numerics are supported, we encounter our first ambiguous
overloads which need resolving. Implement this.
Bug: tint:1504
Change-Id: I79ade04ac3c7ae754b92cb0691b46f449766824a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91964
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Many backends can produce cleaner code if all the elements are zero or
the same value.
Bug: tint:1504
Change-Id: Iff3227884473b0be42395e4a637a7fe0b7a1b238
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91966
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
If the literal was constructed with an 'f', make sure we print it.
Bug: tint:1504
Change-Id: I6f04e31a166919c07574db56b0a2063ce5b8ca5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91965
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Also fixed implementation of this atomic in GLSL. It was emitting code
that would not compile because, as for HLSL, we must pass in the
variable directly to atomic funcs, not via an in/out arg to a function.
Bug: tint:1185
Change-Id: Id0e9f99d6368717511ef3a94473634c512e10cb8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91881
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This CL removes some forward declarations which are no longer needed
and adds one missing declaration which was pulled in from other headers.
These were found by the clang-tidy bugprone-forward-declaration-namespace
check.
Bug: dawn:1414
Change-Id: I8906861e472f2d64a1547c8c6de348cd4151ffb5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91742
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Check that the parsed number fits in an abstract-integer.
Refactor the unit tests so that they're maintainable. Add missing tests.
Bug: tint:1504
Change-Id: I04b6604820d527da66e3f6fcb47391efc0c3330a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91701
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
These are tests for when there's no explicit target type for a
materialization. In this case we expect an abstract-int to
materialize to an i32 and an abstract-float to materialize to a
f32.
Fix a bug uncovered where we were creating a transposed matrix.
Bug: tint:1504
Change-Id: Ie69dd7ec47174d3d7bef20315fd3780dade3a325
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91845
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Try and make things a little clearer.
Change-Id: I66b051e71d4fc8366afe8b2b90067c7c0708d7cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91844
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
CollectTextureSamplerPairs() makes assumptions that the argument types are correct. If they're not, you can end up with NPEs.
Bug: chromium:1327698
Change-Id: Ic9b14126c4b7129bb080f01c90f692b59cd1631e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91850
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
And remove lexer errors about float magnitudes been too small.
Also add tests for non-hex float literal overflow.
Bug: tint:1504
Bug: tint:1564
Change-Id: Ia26817d4f2a99af694e9935692b98ef91f97d2b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91428
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
C++17 supports hex float literals. Use these to simplifty the test expectations.
Bug: tint:1504
Change-Id: Id47b0963da93f3b5da261c72fe863e791c16af1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91427
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Scale up the hex float parsing to support doubles.
Also make it an error if the hex float resolves to an inf or NaN.
See: https://github.com/gpuweb/gpuweb/issues/2953
Bug: tint:1504
Change-Id: Ie923bb5f660285fb7563cfe8dafa07d87b898a7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91426
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
When converting values between two concrete types, handle the case that
the value is unrepresentable by the target type.
For integers, the converted value will be either the maximum or minimum
value for the integer type.
For floats, the converted value will be positive or negative infinity.
Bug: tint:1504
Change-Id: Ia56fb8170c0ea994632194f166062823d9507249
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91621
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
No-op change. Just makes it easier to migrate to float64.
Bug: tint:1504
Change-Id: Ice5bf40514bc7f7faf30e51e4b1e22e6cf2375ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91424
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>