Only evaluate the LHS once, and then manually "load" from the
referenced variable to emulate the desugared implementation. Do the
same for increment/decrement statements.
Fixed: tint:1869
Change-Id: If0dc96bebd52485cfe222ae09305264ffc8b9329
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123640
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This CL adds an `ir::Builtin` which holds the builtin function
information and arguments for a builtin call.
Bug: tint:1718
Change-Id: If08df9f7a9f7edd2781f82d4a4955635290f3f9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122607
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
The Vulkan spec mandates the use of a fragment shader unless
rasterizer discard is enabled. For now, enable the placeholder
fragment shader in all cases, with a bug logged to optimize it
for the rasterizer discard case.
Bug: dawn:1696 dawn:1698
Change-Id: I9e85e6308a9952fc505382488c618897bd9abc7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123503
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Improve the error message when declaring a module-scope var without an address space, with an initializer.
Fixed: tint:1870
Change-Id: If087ae7dadb512c7050e89a0c75990080668e27d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123600
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL adds a `writer/ExternalTextureOptions` to allow providing
external texture information to the generators. The generators are
updated to have the option in their config, but do not use it yet.
Bug: tint:1855 chromium:1421379
Change-Id: I99b122c5cae145e8527158f300da81743f89775a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This header is used by TINT_BUILD_SPV_READER not TINT_BUILD_SPV_WRITER
Change-Id: Ia42e4f2bf2ad37f426d2bf14e962abed9de147a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122520
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Conversion can happen for structure materialization (modf, frexp).
If both structure members are the same type and value, then a constant::Splat will be constructed, which needs to handle conversion.
Bug: chromium:1417515
Change-Id: Iadd14ce00b8d5c22226c601ec5af9a84e6c0c5cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122900
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Bug: dawn:1696
Change-Id: Ie14e3d124342228edef17a122f380e2bdfaf1e57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123502
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Auto-Submit: Stephen White <senorblanco@chromium.org>
Reviewed-by: dan sinclair <dsinclair@google.com>
Should fix dawn -> chromium roll
Change-Id: If4bf1ed6795dc55c4c5a45e8ba8fa2eb0da7270a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123521
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
And vectors of those types.
Fixed: tint:1866
Change-Id: Ic0b5061232c5eb5a67d43dde1cd9599c580f4388
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123201
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
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>
This removes the number of function calls made in non-optimized builds.
Reduces the optimized, all-features-enabled 'tint' executable size by
about 1%.
This change removes the bloom filter optimizations which provided
substantial performance gains with the old recursive implementation,
however this still appears to be ~1% faster than the optimized version.
Change-Id: Ic2bb82e9182459e37907f9e0d0b4771bde218f9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123440
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
castable.h is bigger than it needs to be, and pretty much every tint .cc file includes castable.h
Reduce the amount of code that .cc files that don't use Switch() need to compile.
Change-Id: Ibb4e8b0bc7104ad33a7f2f39587c7d9e749fee97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123401
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL moves `sem::BuiltinType` to `builtin::Function`. This makes it
available for use in the IR. The `Function` name better maps to the
usage in that it contains the builtin functions.
Bug: tint:1834
Change-Id: Ic1a26525d7845d79eb6239bdeb2b73e05f586c24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122606
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL updates the IR builder to convert materialized call expressions
directly into the resulting constant values.
Bug: tint:1718
Change-Id: I184478996afdd11b00ca946775eab6801b777f3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122605
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
- Adds an e2e test to test writing to outputs when at the limit.
Bug: dawn:1665
Change-Id: I2b2b9c2d700be0e454dc945ed8e3e1fe6b191974
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122801
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
mix of ivec is not core until later GLSL versions.
Just polyfill in the writer with ternary ops.
Change-Id: Ia0c35bf95842e03ef8447019f3264d01c11fd384
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123240
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
Evaluate the LHS before the RHS.
Fixed: tint:1867
Change-Id: Ib63903ed4b1425007197a6da37f3bf54a495d88a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123120
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL adds a `add_error` to the IR builder.
Bug: tint:1718
Change-Id: Ifd7a2f6e015d423dbe23405816dba00f237a6c8c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122602
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL adds user function calls, value constructors and value
converters into the IR.
Bug: tint:1718
Change-Id: Iab59aa7d01b9d7831299d785f6e45e9fba12f7b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122600
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
GLSL has the same behavior as MSL, in that -2147483648 is parsed as
a unary minus on '2147483648'. 2147483648 overflows an i32, so this
actually gets treated as -0.
Change-Id: Ibebd8b78a8840f18c438ed1d3d24dee486a65816
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123202
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Move the bulk of the logic into the State class.
Reduces deep indentation, and likely improves performance by reducing the number of variable that require lambda capture.
Change-Id: I85c87298157f34645d0ae064439bb640f7af7c80
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123200
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This replicates a subset of the flow control CTS tests. The purpose of
this is to provide relatively easy-to-repro cases to demonstrate flow
control bugs on Intel Graphics UHD 630 GPUs.
Bug: tint:1868
Change-Id: I34d692230b44d8a0a917dc773cc748bbf288d55a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This CL moves the `using` statement for `BindingPoint` out to its own
file in `src/tint/writer/binding_point.h`. Usages of
`tint::transform::BindingPoint` have been updated to
`tint::writer::BindingPoint`.
Bug: tint:1855
Change-Id: Ife7d92807e0a65b93f21158d73a60d5068fc5da9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123000
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
... overloads for texture cube arrays
FXC is telling porkies, when it says "The array element count
of GetDimensions on TextureCubeArray objects is unavailable
on ps_5_1".
The actual issue, as identified by Teodor Tanasoaia at Mozilla,
is that the argument needs to be unsigned.
In fact, *all* the texture queries should have used an unsigned
scalar or vector for the output value. This has been broken
forever!
This reverts commit bd9f6e6684.
Change-Id: I3e217bec17c6fd203cff618b143ebef3d8a61927
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122980
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
- Suppresses maxStorageTexturesPerShaderStage CTS test because it needs
to be modified to adhere to the new limit as well.
Bug: dawn:1665
Change-Id: I66c62bd94b613059633888210ec7e7b42dc3a1dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122461
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL switches Tint to use `absl::from_chars` instead of `strtod` in
order to have locale independent parsing of floats.
Bug: tint:1686
Change-Id: Icb3d9a40928a1cb154b32629f7e39173d80e4563
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122780
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
The `array_length_from_uniform_options.h` is being included directly by
Dawn. This CL moves the include to the `tint.h` file and has the dawn
usage include that instead.
Change-Id: Iaa77d76bc62fe5038f5b6b93d51478ceed85ac9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122781
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
spvtools_headers are not available without tint_build_spv_writer
Change-Id: If4539715b0e685c9b54bf24719a905fb0265a402
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122820
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This CL add Instance and Adapter toggle stage, and promote
DisallowUnsafeAPIs as an instance toggle, and can be required using
DawnTogglesDescriptor chained in instance descriptor when creating
instance. The instance's toggles state will get inherited to adapters
and devices it create. Related tests are implemented and updated.
Toggles inheritance can be overriden if not forced, so requiring
DisallowUnsafeAPIs when creating device is still available and working
like before.
Note that currently we don't have toggle of adapter stage, and can not
require toggles when creating adapter, until follow up CLs implement it.
Currently the toggles state of a adapter is simply inherited from
instance.
Bug: dawn:1495
Change-Id: I6bf7aa0f950a99451afcc2cab5322c924b7d9520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122021
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This patch uses VK_QUEUE_FAMILY_IGNORED on buffer barriers to align
with what we are doing on image barriers.
Bug: dawn:1688
Change-Id: Icabae22270fc9c92a69ce18e0a63db49de9d7481
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122444
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
There are some scenarios where buffers can be used in pending
commands that are not retained by a command buffer.
They must be retained in the set of mappable buffers for eager
transition to prevent a use-after-free violation.
Fixed: chromium:1421170
Change-Id: I452d80b2513a7726a003d44e2a7850292d798bb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122580
Auto-Submit: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
This change overhauls the Robustness transform to support three modes,
per address space:
* ignore - Disable robustness checks for the address space
* clamp - Clamp indices / texture args to ensure they're in
bounds. This was the old behavior, and continues to
be the default.
* predicate - Condition all indexing / textureLoad / textureStore /
atomic* operations on the bounds check. If any
dependent value is out of bounds, then the operation
is skipped.
This change also fixes multiple expression evaluation of the texture
builtin 'level' argument.
Change-Id: I2e300ddff2c8d3183a9701f06985ce1b262baf2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122343
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This reverts commit a753ad47a4.
Reason for revert: This seems to be breaking `gn check` when the option is not enabled. Not sure why the preprocessor guard isn't working. Will fix and reland later.
Original change's description:
> Add writer to emit the AST.
>
> This CL adds a new `SyntaxTree` writer and a `dump-syntax-tree` option
> to the `tint` program which emits a copy of the AST to the terminal.
>
> Change-Id: I83f6cd7aad3413b0a823728e8aac0d551421b33a
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122540
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>
TBR=dsinclair@chromium.org,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: Icaac76f8daba6034658cf05e15f15676ce2bf155
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122760
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL updates the lexer to use `std::from_chars` which is locale
independent over `strtoll` which honours locale.
Bug: tint:1686
Change-Id: Ic773038fffaa9e2042dec9d94e310c73d05180b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122603
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Currently in the middle of some functions, we execute callbacks
immediately such as inside Buffer::APIMapAsync(), Device::HandleError()
or Queue::Submit().
Firstly, this has risks. The functions might be in a middle of modifying
internal states. By triggering callbacks, users might call API
functions again which could further modify the internal states
unexpectedly or access the states in an inconsistent way.
Secondly, upcoming thread safe API which locks the public functions with
a mutex might encounter deadlock. Because callbacks might cause
re-entrances which would unexpectedly lock the public function again.
This CL attempts to limit number of functions that are allowed to
trigger callbacks. Other functions that want to trigger callbacks will
instead enqueue a request to execute callbacks in the next
Device::APITick() call.
Currently the functions that will be allowed to trigger callbacks are:
- Device::WillDropLastExternalRef()
- Device::APITick()
- Device::APISetLoggingCallback()
- Device::APISetUncapturedErrorCallback()
- Device::APISetDeviceLostCallback()
Bug: dawn:1672
Change-Id: Iabca00f1b6f8f69eb5e966ffaa43dda5ae20fa8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120940
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL adds a new `SyntaxTree` writer and a `dump-syntax-tree` option
to the `tint` program which emits a copy of the AST to the terminal.
Change-Id: I83f6cd7aad3413b0a823728e8aac0d551421b33a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122540
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Recent changes to DecomposeMemoryAccess meant we lost the dependency information between the user of a module-scope variable of the storage / uniform address space and the variable.
Add dependency information to ast::InternalAttribute so this can be tracked.
This change also means that symbol renaming after the DecomposeMemoryAccess should work.
Fixed: tint:1860
Change-Id: Icfa2925f95c2ac50702522df514cd11bde727546
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122660
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
The texture_storage_3d overload should allow for unsigned coordinates.
Change-Id: I6278571fb9dc7bba644a4ba88cce6b8bd7c790bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122521
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Print the input program, and the output of each run transform.
Significantly reduces stdout spam, and also shows you transform input - which is what you really want.
Issue: tint:1853
Change-Id: Iaea0dc16de63daffcf0b0c715af14d194b700468
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122480
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This does not belong in the public header - the spirv writer public header does not depend on it.
Change-Id: Id1b2107c3a2003632e1868c2d6a337ddbb0c8b48
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122382
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>