Commit Graph

3050 Commits

Author SHA1 Message Date
James Price e04d0f40de Remove passing HLSL expected files for vk-gl-cts
We don't keep expected files for tests that pass in this
directory. Changes that add deprecation warnings make them fail, and
changes to the generated code produces unnecessary churn.

Change-Id: Id41309b57b91ebce80ec953a5c984672f79d145f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77562
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-20 22:11:07 +00:00
Ben Clayton 198417097f Clang format the entire tint codebase
Change-Id: I8e6ae93d0d4449e38cd32672e714ef07e1075d75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77441
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-20 20:40:18 +00:00
Ben Clayton 01e4b6fc18 wgsl: Replace [[decoration]] with @decoration
Deprecate the old syntax. Migrate everything to the new syntax.

Bug: tint:1382
Change-Id: Ide12b2e927b17dc93b9714c7049090864cc568d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77260
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-19 22:46:57 +00:00
James Price 8f1d5224ee cmake: Link diagnostic sources into tint_utils_io
Splits these sources out into a separate library target to make sure
that it is only built once.

Many of these symbols are used by tint_utils_io, and building with
shared libraries enabled fails if they are not present.

Change-Id: I501d302b2502b22357f5691f012cd56ebcfde478
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75600
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-19 21:40:20 +00:00
James Price b28c5ad3c6 msl: Fix non-struct runtime-sized array codegen
When these are used inside a function, we were not unwrapping the
array from the struct that we wrapped it in.

Fixed: tint:1385
Change-Id: Ide7bbd802394bf09819265be48d978ec9346adfe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-01-19 19:36:17 +00:00
James Price 6b1e5f552b wgsl: Do not require a semicolon after a struct
Don't generate them either, which generated a lot of test churn.

Fixed: tint:1380
Change-Id: I0a7cfdd2ef0ffe8e7fda111fbc57997b36b949e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77165
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 18:11:17 +00:00
James Price ecf43d69d0 Add non-struct buffer types to the release notes
Fixed: tint:1372
Change-Id: I394c33eb80ea1ce347794bc63965f6080ca92c61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76165
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price 5085438423 inspector: Add support for non-struct buffers
Use the sem::Type size instead of the sem::Struct size.

Some binding numbers in MSL expected outputs changed since these
buffers were previously not being reported in the resource list that
the Tint exe uses to automatically remap bindings.

Bug: tint:1372
Change-Id: I14479ddc5129d91b91449cc2d68ee37bd99d2f7e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76220
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price ae8c65620e glsl: Wrap non-struct buffer types in structs
Use the AddSpirvBlockDecoration transform to do this.

Add expected results for all of the new E2E tests. The arrayLength()
tests all fail as this is not yet implemented for the GLSL
backend. The other tests all pass except two that assign whole structs
to buffers, which is also a pre-existing issue.

Bug: tint:1372
Change-Id: I230197b43a5561e619866419d642ffc1ed085aac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76164
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price 51e55b244e transform: Handle arrayLength for non-struct buffers
These two transforms previously assumed that the argument to
arrayLength had the form `&struct_var.array_member`. We now also need
to handle the case where it is just `&array_var`.

Bug: tint:1372
Change-Id: I173a84bd32c324445573a295b281a51e291c2ae2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76163
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
James Price 7395e29e70 Allow non-struct buffer store types
For SPIR-V, wrap non-struct types in structs in the
AddSpirvBlockDecoration transform.

For MSL, wrap runtime-sized arrays in structs in the
ModuleScopeVarToEntryPointParam transform.

Bug: tint:1372
Change-Id: Icced5d77b4538e816aa9fab57a634a9f4c52fdab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76162
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-19 15:55:56 +00:00
Ben Clayton c3cec4d901 inspector: Re-add inspector::SamplerTexturePair
The tint -> dawn roll is failing as dawn is using tint::inspector::SamplerTexturePair.
We need to land this change, fix dawn, then revert this change.

Bug: tint:1366
Change-Id: I3a3849ddd9416a06d0be394e295603de59594ead
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-18 23:51:56 +00:00
Ben Clayton be2362b18c benchmarks: Add a basic set of benchmarks
Add google benchmark to the DEPs.

Implement a basic set of benchmarks for each of the writers and the WGSL parser.

Add build rules for CMake. GN build rules TODO.

Add a simple go tool (ported from Marl) to diff two benchmarks. Less
noisy than the one provided by google benchmark.

Bug: tint:1378
Change-Id: I73cf92c5d9fd2d3bfac8f264864fd774afbd5d01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-01-18 18:58:16 +00:00
Ryan Harrison dcb24cea41 Provide build override for SPIRV options
Without this, the fuzzing framework will fall back to the default and
copies in random bits without consideration of range restrictions on
specific fields.

BUG=chromium:1287344

Change-Id: Ifbde471074a2f68e1d9fd8215174814d2f465f93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76880
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-01-18 15:37:56 +00:00
Antonio Maiorano e232e35723 Factor out structure layout print function
Simplifies Resolver::ValidateStorageClassLayout and would allow us to
use this function for displaying structure layout in a language server,
for example.

Bug: tint:1348
Change-Id: I9d83329f0a168e5d8c094b3282d07cd1ab321dca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76080
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-01-14 21:57:22 +00:00
Stephen White 65112dc77c Move SamplerTexturePair from inspector to sem.
The plan is to reuse this datatype for the combine-samplers transform.

Bug: tint:1366
Change-Id: Icd2f4bd45b662f32fe9803e3485f1a54a2c42265
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-14 20:08:42 +00:00
Ben Clayton e5919ac115 validation: Error on obviously infinite loops
Most of this change is fixing up the numerious tests that violated this rule.

Fixed: tint:1365
Issue: tint:1374
Change-Id: I38da27c7367277fe60857208170fec017e80bd25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 17:16:32 +00:00
Ben Clayton 8dd9a56f91 inspector: Remove DEPRECATED texel format APIs.
Dawn has been updated to use the new APIs.

Bug: tint:1361
Change-Id: I0eb501132b896385b21648bad8466342569317bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76520
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 14:26:32 +00:00
Ben Clayton 51e37c6f91 Fixes for bugs around unreachable code
Remove the ICE check for expression behaviors always being either `{Next}` or `{Next, Discard}`. Unreachable code may be result in something else.

Add the RemoveUnreachableStatements transform to the SPIR-V writer sanitizer transform list. The writer cannot correctly handle unreachable statements.

Bug: tint:1369
Bug: chromium:1285622
Change-Id: I9fa54c6d2096b1ee633dd551b628c7dd3ba64fb5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 10:16:24 +00:00
Brandon Jones d6e962b437 Add Multiplanar External Texture Transform To Tint Header
Adds src/transform/multiplanar_external_texture.h to the Tint header.
This is needed to access the MultiplanarExternalTexture::BindingsMap
type from Dawn.

Bug: dawn:1082
Change-Id: Ie6e14e3553af96dc0110bf95bc6a4fc76dcea26d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-14 10:11:47 +00:00
James Price db2f5fcf10 resolver: Reject non-storage runtime-sized arrays
There were several cases where we were not rejecting these which were
leading to ICEs or bad codegen.

Fixed: tint:1248
Change-Id: I7cdf3b74d92b81b1067ad908af423ea0b5442328
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-12 20:51:36 +00:00
James Price 13c79bef23 validation: Reject var<function> at module-scope
Fixed: tint:1368
Change-Id: I15fd0d2cbd9600500213e3140e9ac4500d179eb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-01-12 20:51:36 +00:00
Stephen White 3e354fd524 Resolver: collect unique texture/samplers pairs.
GLSL does not support separate textures and samplers, so they must be
replaced with combined samplers. This is the first stage of that change,
where we collect the unique texture/sampler pairs. Within a function,
texture and sampler must be either a global variable or a function
parameter. At the entry point level, all references must resolve to global
variables, so by recursing the call graph we can determine all of the
global pairs required.

This information will be used by an upcoming transform to modify the AST
to be GLSL-compliant: modifying function signatures, call sites, removing
separate globals and adding combined globals. It will also eventually
replace the pair-gathering currently performed by
Inspector::GetSamplerTextureUses().

Bug: tint:1366
Change-Id: I89451b195649da26e45641ea2f6955683ae9fc66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75960
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-10 20:46:35 +00:00
Ben Clayton d1efb5d48c reader/wgsl: Replace std::result_of with std::invoke_result
With C++17, std::result_of has been deprecated and superceeded with std::invoke_result.
std::result_of triggers a compiler warning about use of a deprecated feature, which is causing the ossfuzz builds to fail

Issue: oss-fuzz:43441
Change-Id: Ie4ed670dd5b25b9059d5feb8056e37a22dad3cbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75981
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-10 20:44:25 +00:00
Stephen White 16e8df4467 Update GLSL expectations.
Bug: tint:1358
Change-Id: I161bc350d7c16cbe690c39a2ccda344a2535670c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-07 09:38:45 +00:00
Ben Clayton e4e7485854 transform: Fix PromoteInitializersToConstVar handling of for-loops
PromoteInitializersToConstVar was erroring on for loops that contained array or structure constructor expressions.

Added lots more tests.

Fixed: tint:1364
Change-Id: I033eaad94756ea496fc8bc5f03f39c6dba4e3a88
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75580
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 21:32:41 +00:00
Ben Clayton 4d245d9a36 ast: Remove unsupported texel formats
Fixed: tint:1361
Change-Id: Idcf98713d9a380e56811bea6419913714d602103
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75582
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 18:37:01 +00:00
Ben Clayton 3cbb136b8a Re-allow dynamic indexing of 'let' arrays and matrices
Spec change: https://github.com/gpuweb/gpuweb/pull/2427
Reverses: tint:867

This reverts and fixes commits:
 b6fdcc54df
 10442eff7d

Added a bunch of end-to-end tests.

Fixed: tint:1352
Change-Id: I34968243bbec1cab838c8ba50a6f027146bbfd06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75401
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 18:11:01 +00:00
Ben Clayton 294ce9394f ast: Rename ImageFormat to TexelFormat
This is what its called in the spec.

Issue: tint:1361
Change-Id: I512c4224191fd2bbf04522da2093872f79ee02a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75581
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 17:20:22 +00:00
Stephen White c1faee9395 Add new GLSL test expectations.
All failures are now SKIP'ed.

Bug: tint:1358
Change-Id: If04d57b9e0b71dd877468b5dc277fbff82f36692
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-06 15:31:21 +00:00
Ben Clayton 6165cca1a6 reader/wgsl: Remove texel format names as keywords
These were removed in https://github.com/gpuweb/gpuweb/pull/2474.
`read`, `write` and `read_write` were already excluded as keywords.

Fixed: tint:1359
Change-Id: I5424f780f4bd67bb336320a22dd2097ed03b4bd6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75360
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-01-06 12:16:11 +00:00
Ben Clayton 7b0686a922 build: Update tint to use C++17.
Mirrors changes and DEPS toolchain SHAs found in https://dawn-review.googlesource.com/c/dawn/+/75061

Change-Id: I69a3b6bb091e00207d81d5dbc288b9b68fc961fc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-06 09:23:11 +00:00
Ben Clayton 7dc901fa4f tools roll-release: Bump branchLegacyCutoff to M96
The tool was getting slow, due to the number of branches being examined.
M96 is the latest stable release. We aren't applying fixes to this or older branches.

Also avoids an issue where the M95 branch was missing a cherry-pick, which the tool wanted to merge with each run.

Change-Id: I8a8b1466c10633d9539725cd4f9b1b0514e41e93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75067
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-01-05 21:03:10 +00:00
Ben Clayton c00cc43e53 reader/spirv: Optimize FindUnusedDerivedName()
Store the last search id suffix so that we don't research the same suffixes over and over again.

Bug: oss-fuzz:38098
Bug: oss-fuzz:38606
Bug: oss-fuzz:39300
Bug: oss-fuzz:40339
Change-Id: I295147d91bb9f805170c49114267033bbb781e4d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75427
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:42:50 +00:00
Ben Clayton 1c4f8de30b reader/spirv: Optimize MakeNullValue()
Constructing a null vector, matrix or array does not need to provide an explicit list of null elements. `T()` is a more efficient and readable equivalent.

Fuzzers like to generate enormous pathological composite types, which has been triggering OOM failures.

Bug: oss-fuzz:38095
Bug: oss-fuzz:39235
Bug: oss-fuzz:39246
Bug: oss-fuzz:39874
Change-Id: I910bb04bdd0e80532c09fc038be895ec37d3d380
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75426
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:24:22 +00:00
Ben Clayton 4a143a40a3 reader/spirv: Prevent nullptrs being passed to ast::CallExpression.
nullptrs are caused by errors. Detect and return before passing nullptrs to places they shouldn't go.

Also: Rename 'params' to 'args'. These are arguments, not parameters.

Bug: oss-fuzz:38074
Fixed: tint:1355
Change-Id: I77f97b4a8e5dab21802b300ba3eedad767ac2ad5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75425
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:11:41 +00:00
Ben Clayton 5c99ed046a intrinsics: Add degrees() and radians()
Fixed: tint:1329
Change-Id: I5fb927268fc9cb8047a2b365d26e813a8546605a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75423
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-05 20:11:00 +00:00
David Neto 4beeaea9da spirv-reader: support OpImageDrefGather
Also, issue an error when a gather or dref-gather operation
is used with a Bias or Grad image operand.

Fixed: tint:1336
Change-Id: Ife11d2f52a1a2d1b75e26269373db5cc4b3440bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74801
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2022-01-04 22:00:59 +00:00
David Neto 5791197e80 fix spirv-reader test: add Block decoration
Fixes a SPIR-V validation error.

Change-Id: I51bf887d1e2b55760e5512648074ae349a90a15e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74802
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-04 20:23:19 +00:00
Ben Clayton 1372222215 wgsl: Replace 'elseif' with 'else if'
Bug: tint:1289
Change-Id: I72432391e60cf5ff173aa51a6d4a2bc8ef58fbf2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75240
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-01-04 20:06:49 +00:00
David Neto 7d88368c56 spirv-reader: support OpImageGather
Bug: tint:1336
Change-Id: I771b09e7568f1f022a316f2ba0bc72c03f735aa1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74800
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2022-01-04 15:46:39 +00:00
Corentin Wallez f09a23a3f7 Fix MSVC narrowing warnings in newer MSVC versions.
Bug: dawn:824
Change-Id: I4be68ab47e5aa846583240c1024e286d7ec2e115
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75073
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-04 15:31:24 +00:00
Corentin Wallez 09c49b34d9 Fix -Wunreachable-code-return with newer clang version.
When the emit_continuing lambda always returns true, clang is able to
detect it and finds that some code is unreachable.

This commit changes places that use the lambdas directly to instead use
the stored emit_continuing_ member.

Bud: dawn:824
Change-Id: Idfd804a6ec53ac793e8988dce79991c659fbbc36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75060
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2022-01-04 10:18:39 +00:00
David Neto 7913982f87 wgsl reader: Allow 0X as a hex prefix for ints and floats
Fixed: tint:1353
Change-Id: I8252cc9d055657e361c4bceadcc59f7703f98c23
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74380
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-12-23 22:25:21 +00:00
Antonio Maiorano 9943de6813 Fix FXC compile errors on modulo by zero
Just like for divide, FXC fails with the exact same error when
performing a modulo on a value that FXC determines to be zero. We
address it in the same way as we do for divide.

This also fixes a couple of the vk-gl-cts tests for which I manually
generated expectation files for.

Bug: tint:1083
Change-Id: Ia388bf002112afded542adb791d37e88e35a77ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74220
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-22 15:02:09 +00:00
Stephen White cc4d97b6e3 GLSL: use "Offset" forms of texture intrinsics when appropriate.
Also ensure correct paramter ordering: bias is always after offset.

Bug: tint:1351

Change-Id: I41ee66b86cd9d912f3857e5377b660c50d035c6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-12-21 16:53:36 +00:00
Antonio Maiorano 821f9bb525 Fix FXC compile errors on divide by zero
FXC fails to compile when it determines that the rhs of an integral
division is zero with "error X4010: Unsigned integer divide by zero".

bclayton's fix (https://dawn-review.googlesource.com/c/tint/+/60500)
addressed cases for division by an integer constant 0. This CL adds the
missing support for division by integral vectors with 0 components.

FXC also fails on division by integral expressions that it can fold to
0. To handle these cases, we now emit a runtime check for 0 and replace
by 1. In the cases I've tested, FXC seems able to optimize these checks
away.

Bug: tint:1083
Change-Id: I02f08e9077882f03c1e42b62dacb742a48fa48ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-21 14:48:26 +00:00
Stephen White 5965c6ed1f Update GLSL expected results.
Change-Id: I32aaefe71ea728ae5118de08e5dd9073ddf2269e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73740
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-12-21 01:48:13 +00:00
Antonio Maiorano c5f2fe4c78 CMake: fix clang-cl build
Add two more warnings to ignore. These show up when including glslang
headers in samples/main.cc.

Change-Id: Icdb9fa9914bfe6fdafb4727ed8bf774fe9b930bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73660
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-12-20 21:39:35 +00:00
David Neto 66e7569e15 spirv-writer: Fix termination of basic blocks
There are a few places where a branch or return is created,
conditionally on whether a terminator was the last thing seen.
The goal is to generate a SPIR-V basic block terminator exactly
when needed, and to avoid generating a branch or return immediately
after a prior terminator.

Previously, the decision was based on the last thing seen in the AST.
But we should instead check the emitted SPIR-V instead.

This fixes cases such as a break or return inside an else-if.
That's because an if/elseif is actually a selection inside a selection.
Looking at the AST only works when trying to terminate the *inside*
selection.  In the outer recursive call, the last AST node is
no longer a terminator, and we would skip generating the branch
to the merge block.

Fixed: tint:1315
Change-Id: I6b886ce85d1d681f2063997e469e0c1b4e5973a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/73480
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-12-20 16:46:55 +00:00