Declare the list of transforms once, and use this for the usage message and when a transform does not match.
Simplifies adding new transforms to the command line tool.
Change-Id: I57ec433d8a570dae465d1837f5a4c1d89b8cff05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79280
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Also make tests more idiomatic by removing diamonds in the Node
hierarchy.
Bug: tint:1300
Change-Id: I681f4251bd8d9bdef169dcdf5de345792c927436
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79680
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Other shader types don't need this.
Also fix code style of member var.
Bug: tint:1360
Change-Id: Ic3600ec7c6da9b85b57655fabbf1f2e44b0ea7d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79640
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
We'll need this to build the GLSL backend in Dawn, since we don't want
glslang there.
Bug: tint:1217
Change-Id: Ied44ca89286c1d53a2e58a7083f0bfb859976770
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Currently contains a subset of ast nodes to make it easier to debug.
Bug: tint:1331
Change-Id: I27afe3c57aa752bdf823120e31585100c8adbe36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79460
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Bug: dawn:545
Change-Id: I7cb48813e0a582a6b7314c6fa726800b146ea6be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79243
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This is not 100% correct (the exceptions for mat2 and friends are not
implemented yet), but gets more tests passing in Dawn.
Bug: tint:1415
Change-Id: Ia11c63a5236f35e724431a65ddb6ef3c598775d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Use the TypeInfo already obtained from the object instead of calling As<T>() again, which would trigger another virtual call.
Bug: tint:1383
Change-Id: I0394ea049589b0f7f72c80509ac8e9536196f368
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79302
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Promote up some build rules from the root CMakeLists.txt file that are
specific to Dawn.
Bug: dawn:1275
Change-Id: I11e9261ac595f6d71742b20d54dc658a5fa7e996
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79105
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Use a bloom-filter-style early rejection to eliminate whole blocks of
case statements from the switch type checks. Much like IsAnyOf(), the
list of types considered are recursively tested as a whole and
then binary-chopped if there's a potential match, until we test the
individual switch case types.
Bug: tint:1383
Change-Id: I5b30f19ea070e8352bf6b9363f133da906013182
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78544
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This has already been moved once, but with more consideration, there's far less fuzzer-related stuff to put in the same root directory here.
Bug: dawn:1275
Change-Id: Ic4bb556d9a9f104293cca3316cae84b66a6362b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79104
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
The MSL headers have annotations that requires that the lod for 1D
textures is a constexpr with value 0. This affects .get_width() and
.read().
Bug: dawn:814
Change-Id: Ic21d32067061afe67a16fbbeee222ab695b53066
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79301
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
The output library names should keep the 'dawn_' prefix, even when the target doesn't have this.
Bug: dawn:1275
Change-Id: I153c64b96594a05f599d847e455dca967e8ce0f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79360
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
In GLSL, gl_SampleID and gl_SampleMask[In] require the
GL_OES_sample_variables extension, so output:
"#extension GL_OES_sample_variables : require"
in the header if those builtins is used.
Note that extensions must be inserted before the default precision
declaration, but helpers must be inserted after it, so we set a flag
and emit extensions, then the precision declaration, then helpers.
Further fixes:
- use gl_SampleMaskIn for input builtins, gl_SampleMask for output,
necessitating the addition of a storage class to GLSLBuiltinToString()
- fix the handling of gl_SampleMaskIn: it's array<i32> in GLSL, not
array<u32> as in SPIR-V
- centralize conversions for GLSL builtins used as input variables in
FromGLSLBuiltin()
- implement bitcasts on assignment to GLSL builtin output variables,
centralized in ToGLSLBuiltin()
- update the extension handling in the GLSL writer to check for both
sample_index and sample_mask.
- call UnwrapRef() in GLSL's EmitBitcast(). In the test case, we were
not recognizing the argument as a uint, yielding float() instead of
uintBitsToFloat().
Bug: tint:1408, tint:1412, tint:1414
Change-Id: Ie01541eb6e7cdf4e21347341f988bff916346797
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78920
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Transform any SPIR-V that has an array with a custom stride:
@stride(S) array<T, N>
into:
struct strided_arr {
@size(S) er : T;
};
array<strided_arr, N>
Also remove any @stride decorations that match the default array stride.
Bug: tint:1394
Bug: tint:1381
Change-Id: I8be8f3a76c5335fdb2bc5183388366091dbc7642
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78781
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
A type dispatch helper with replaces chains of:
if (auto* a = obj->As<A>()) {
...
} else if (auto* b = obj->As<B>()) {
...
} else {
...
}
with:
Switch(obj,
[&](A* a) { ... },
[&](B* b) { ... },
[&](Default) { ... });
This new helper provides greater opportunities for optimizations, avoids
scoping issues with if-else blocks, and is slightly cleaner (IMO).
Bug: tint:1383
Change-Id: Ice469a03342ef57cbcf65f69753e4b528ac50137
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78543
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
If the target name matches the package directory.
Reduces stuttering in target names.
Change-Id: I6cf01ac22c4998f4b862135b13b8503bdd92bdd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Also remove stuttering from the target names by dropping the 'dawn_' prefix.
Bug: dawn:1275
Change-Id: I3263f1236f71bf23795b4b12670ad3535822a537
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79062
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Also remove stuttering from the target names by dropping the 'dawn_' prefix.
Bug: dawn:1275
Change-Id: Iac79f9927010b8e5edeb7e0949092b34431d54dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79061
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
The fields `has_location_decoration` and `location_decoration` are references to `has_location_attribute` and `location_attribute`, respectively, which act as an alias for a field-rename.
The default copy-constructor was copying across the reference (pointer) to the source StageVariable, instead of making a reference to the target's fields. This is causing Bad Things™ to happen in downstream projects.
Credit to dneto@ for identifying the issue, and for making this fix (which I've stolen for this CL).
Change-Id: Id0570e4e389f28980fa5aea29ad63b5100373dc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79200
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
- Adds a test to sample a 1D texture.
- Adds a test writing to a 1D texture as a storage texture.
- Reworks some of the StorageTextureTests helper code to allow passing
custom sizes (since 1D textures must have height=1).
- Deletes some dead code leftover from readonly storage textures.
- Adds validation tests for 1D texture view creation.
Bug: dawn:814
Change-Id: I279856569f4fc6c9a7a5023a42bfa50d444158ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79106
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
The CombineSamplers transform was incorrectly flagging StorageTexture
(which in GLSL ends up as image2D) as needing to be combined with a
sampler, or at least renamed. This is incorrect: StorageTexture never
has an associated sampler, so don't try to pair it up and just output
it as image* in GLSL.
In GLSL, textureLoad (aka texelFetch) of depth textures is not allowed.
The fix is to bind the depth texture as the corresponding f32 texture
instead (e.g., texture_depth_2d -> texture_2d<f32>,
texture_depth_cube -> texture_cube<f32>, etc). This requires changing
both the uniform globals and function parameter types. We're now going
to receive a vec4 instead of a float from texelFetch, so add a ".x"
member accessor to retrieve the first component. (Note that we don't
do this inside a CallStatement since this gives the CloneContext
indigestion, and CallStatement is going to ignore the result of the
call anyway.)
We were failing to find the dummy samplers that Dawn creates for the
calls that actually do require a dummy sampler, since the old Inspector
implementation of GetSamplerTextureUses() does not find them. The fix
is to implement a new Inspector call to return the texture/sampler
pairs the Resolver found during resolution. This will include the
dummy sampler as a null variable pointer.
In order to identify the placeholder sampler, we pass in a BindingPair
to represent it. When we discover a null sampler in the variable pair,
we return the passed-in placeholder binding point to the caller (Dawn).
(Dawn will use a group of kMaxBindGroups, to ensure that it never
collides with an existing sampler.)
Bug: tint:1298
Change-Id: I82e142c2b4318608c27a9fa9521c27f15a6214cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78820
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
BUG=tint:1413
Change-Id: I6a4735a97f64003cb4999d6a64b64666d0ce08ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79140
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Ryan Harrison <rharrison@chromium.org>