Commit Graph

118 Commits

Author SHA1 Message Date
Corentin Wallez bed7a32b3b type_determiner: use f32 as the subtype for u/norm storage texture.
Fixes: tint:367
Change-Id: I311f5b9524d6251c88ae774dc8dc80f6d52e457d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33922
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-25 13:58:47 +00:00
Ben Clayton 7e4ffa0064 Add create<T>() method to Module for types
Migrate all uses to use this and the new `unique_type<T>()` and `types()` methods.

Remove the `type_mgr()` accessor. `TypeManager` is now an implementation detail of the module, allowing us to unify the allocation of types and nodes (if we so wish).

Fixes: tint:337
Bug: tint:307
Change-Id: I233fa9dc73d60515dd721f02ea7ba089ef7d374f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33667
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:58:55 +00:00
Ben Clayton 0fb5168fc7 Move TypeManager from tint::Context to ast::Module
Bug: tint:307
Bug: tint:337
Change-Id: I726cdf89182813ba6f468f8ac35e5d44b22e1e1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33666
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:50:55 +00:00
Ben Clayton 3ea3c997b5 Implement textureSample builtins
Handle wsgl parsing and spirv writing of:
  textureSample(), textureSampleBias(), textureSampleLevel(),
  textureSampleGrad(), textureSampleCompare()

Handle the different signature for array texture types.
Includes offset overloads.

Change-Id: I6802d97cd9a7083f12439b32725b9a4b666b8c63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32985
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 21:19:22 +00:00
Ben Clayton b053acf796 Replace use of std::unique_ptr<T> with T* for AST nodes
This is a minimal effort to fix up the code. There's substantial code
cleanup which can now be done, which is done in the next change.

Bug: tint:322
Change-Id: Iafcf5e814837d9534889e8c21333de4931a19cfa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32864
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:31:07 +00:00
Sarah Mashayekhi 112314b73d [validation] add error number to invalid member accessor error: v-0007
Bug: tint:6
Change-Id: Ia92ed8a328ff3c7986d8e5298b13f5d1db33935b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32384
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:35:17 +00:00
dan sinclair d5fd7e02ba Fixup lint errors.
This CL fixes up the various lint errors.

Change-Id: If4d3077b55aadec33980452c43917194d803fac6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31680
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:26:09 +00:00
Ben Clayton 5bee67fced Add File & Range information to tint::Source
This is the first step in improving the error messages produced while parsing.

The `line` and `column` information of `Source` has been moved to `Source::Location`.

`Source::Range` has been added that contains a `Location` interval - allowing error messages to highlight the full region of the error.

The `File` information provides an optional file path, and pre-splits the content into lines. These lines can be used to print the full line containing an error.

This CL contains a few temporary changes that help split up this work, and to ease integration with Tint.

Bug: tint:282
Change-Id: I7aa501b0a9631f286e8e93fd7396bdbe38175727
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-10-30 20:44:53 +00:00
dan sinclair 512ecc2762 Rename unwrap helpers.
With the addition of the AccessControlType we want to look through the
access control as well as the aliases as we work through the type tree.
This CL renames UnwrapAliasesIfNeeded to be UnwrapIfNeeded and
UnwrapAliasPtrAlias to UnwrapAll.

Change-Id: I5b027919c3143a89be24c4d87b8106f70358c03b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31104
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-28 20:32:22 +00:00
dan sinclair ff267ca60e [type-determiner] Fixup handling of unknown identifiers.
This Cl updates the identifier type determination check to fail if the
identifier is not found and is not an intrinsic method.

Bug: tint:139
Change-Id: I332dd7fb42dae62bdee459c4a8819bdb5685c903
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30081
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-10-14 18:26:31 +00:00
dan sinclair 4311dd05c8 [spirv-writer] Fix accessing array of non-scalars.
Currently, if we access an array of non-scalar items we'll incorrectly
emit an OpVectorExtractDynamic which will fail as the result is not
scalar.

This CL updates the array accessor code such that if the base array is
an array of non-scalars we'll do load of the array and then access chain
into the loaded variable.

Bug: tint:267
Change-Id: Ia4d7052b57d8b31b835714b7b922c7859e3dce1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29844
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 21:34:25 +00:00
dan sinclair 007dc42cbb [type-determiner][spirv-writer] Add arrayLength support
This CL adds support for retrieving the array length of a Runtime Array
in the SPIR-V backend.

Bug: tint:252
Change-Id: Ic13c4a99da5760738d57702c45f52c6a194a172d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29220
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 17:01:55 +00:00
dan sinclair 3c02592718 Remove cast operator.
This CL removes the cast operator and converts the tests over to using
type constructors.

Bug: tint:241
Change-Id: I2526acb61f5624b2e1c068612a2ddcc748c92aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28860
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:38:44 +00:00
dan sinclair a7d498e060 Rename 'as' to 'bitcast'
This CL updates Tint to use 'bitcast' instead of 'as' for the OpBitcast
conversions.

Bug: tint:241
Change-Id: I53a80de10421b2d9cc009527eebe5ff07e1285c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28801
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-22 22:07:13 +00:00
dan sinclair b4fee2f824 Update builtin methods.
This CL removes the import mechanism, the identifier paths and updates
all of the standard library methods to be builtins.

Bug: tint:242
Change-Id: If09b98a155ae49ced3986ba2c9b517a060693006
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28720
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-22 19:42:13 +00:00
dan sinclair 5f8126271d Remove EntryPoint.
This CL removes the EntryPoint node and transitions everything to the
stage decoration.

Change-Id: Ib2840155905c8fa60ff35870f0c4b6705efb73ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28705
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-22 14:53:03 +00:00
dan sinclair a8274b2fef [spirv-writer] Emit entrypoint from function decoration.
This CL updates the SPIRV-Writer to emit entry point information based
on the function stage as well as EntryPoint nodes.

Change-Id: I1fa937cbb2159b31516b0189216d679e03f0384d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28702
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 18:49:01 +00:00
dan sinclair 0592643782 [type-determiner] Update to work with entry point and function stages.
This Cl updates the type determiner to work with both styles of entry
point definition.

Change-Id: Ic48f1a5f0a5820821f9a74380896426a97483049
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28666
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 17:51:31 +00:00
dan sinclair 43d17780ca [spirv-writer] Add multisampled textureLoad test.
This CL adds a test for multisampled textureLoad and fixes up a few type
determiner issues for multisampled textures.

Bug: tint:237
Change-Id: I5c33797b197b6f092842b22aa93d2076b0779766
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28582
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-21 15:52:10 +00:00
dan sinclair 5e989306e5 [type-determiner] Handle pointer arguments.
Currently if the type determiner is determining an identifier it will
wrap it into a pointer if it isn't a constant. This CL updates to make
sure we don't already have a pointer as otherwise we endup with a double
pointer.

Bug: tint:216
Change-Id: I2f8c83bd8680df6c3aef31e1cbb754fdff709b4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28442
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-16 21:20:36 +00:00
Tomek Ponitka ed0527a016 Adding a TODO for updating textureLoad on storage images
Change-Id: I1d724a1743caa94ba040aca804dfac6abbb2d6e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-09-10 14:15:37 +00:00
Tomek Ponitka 03f5e2fc9d [wgsl-reader] Parsing image storage type
Bug: tint:147
Change-Id: I79713b5dfa0a4b219cff7a6bb3c514557cf4f261
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28121
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:38:39 +00:00
Tomek Ponitka 4e2d2484f8 [ast] Change intrinsic function names to camel case
Change-Id: I227eade96ccf84a4ed006cc5e98ac9e47f44129a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28163
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:30:29 +00:00
Tomek Ponitka 1a61fc4dc7 [type-determination] Adding builtin texture operations
That includes texture_load, texture_sample, texture_sample_level,
texture_sample_bias, texture_sample_compare. Also determining the
result type.

Change-Id: I9e6fb19964fa171ee9b0594633b2dfe95e3e38b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27360
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 15:24:54 +00:00
Tomek Ponitka a454ef9024 [ast] Determining subtype of StorageTextureType
It's determined at the beginning of TypeDeterminer::Determine().

Bug: tint:141
Change-Id: I761199db0c9813dbd42c6cb4ecb3532d1a39f49f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27460
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 15:11:23 +00:00
dan sinclair df503f0e85 [hlsl-writer] Refactor output emission.
This CL updates the HLSL backend to take the output stream as a
parameter. This is needed because there are cases where we have to
generate the resulting stream out of order. This will allow that to
happen.

Bug: tint:7
Change-Id: Id1877a07e536a84da0555f207d1030588d44c034
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27440
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:05:46 +00:00
dan sinclair bdb86723e8 [hlsl-writer] StorageBuffer support.
This Cl adds support for storage buffers to the HLSL backend.

Bug: tint:7
Change-Id: I7adb655de8ccfcb6771fa661ff205c543b4efe66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27001
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-25 21:22:37 +00:00
Sarah Mashayekhi 844f632785 [type-determiner] return false when type determining an undeclared function
Change-Id: Ia7e43be64675528037f92026a6c239d1e5220fc0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26941
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-18 02:10:03 +00:00
dan sinclair 37c0970d51 Convert LoopStatement to use BlockStatement.
This CL converts the LoopStatement class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: Ied4b82f0ef49c7b92caa040bcf73050093022df7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25723
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 0975dd5663 [spirv-writer] Add BlockStatement emission.
This CL adds BlockStatement support to the spirv-writer. The type
determiner is also updated as needed.

Bug: tint:134
Change-Id: I91e08c3acafd67401a010fff21abde7feec46e8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25609
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 8f3c6356d4 Remove KillStatement
This CL removes the KillStatement from the AST and replaces all test
usage with DiscardStatement.

Bug: tint:169
Change-Id: Ie68dd3cdd54056f144d10506f05cc1f6903d1cda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25605
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:50 +00:00
dan sinclair 16a2ea11d3 Add type determination for the select intrinsic.
This CL adds type determination for a `select` intrinsic.

Bug: tint:106
Change-Id: Ie5c051cb42c72ae732579e3064561a4544a90473
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25380
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 17:44:44 +00:00
dan sinclair 50080b74e1 Type determine the call statement.
This CL adds type determination for the call statement.

Bug: tint:45
Change-Id: I2460fe6c6103bdf7e5d0367cded1d78ca5d671d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25321
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 13:42:13 +00:00
dan sinclair de2dd68f2b Inherit refererenced globals up the call stack.
A given caller should inherit the globals referenced from a callee. This
way, a given entry point will have a list of all the variables used up
the stack which it needs to reference.

Change-Id: Ib6efcdd5c3347749ad2d54aecfa425bd966a62fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24762
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:28 +00:00
dan sinclair 16890b9ce8 Add determination of entrypoint callees.
This Cl updates the type determiner to annotate each function with the
name of any entry points which call into the given function. This will
allow determining in the backends if we need to duplicate the function
due to differing entry point parameter requirements.

Bug: tint:8
Change-Id: Icd7c4ccab72dd6eabcf0abaf1159319949c4ecf5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24760
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 19:45:47 +00:00
dan sinclair 13d2a3b96c [spirv-writer] Only add used variables to entry point.
This Cl updates the entry point code to only output Input/Output
variabes which are referenced by the function instead of all
Input/Output variables.

Bug: tint:28
Change-Id: Idc429e02cac8dac7fc7b609cbd7f88039695829e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23623
Reviewed-by: David Neto <dneto@google.com>
2020-06-22 20:52:24 +00:00
David Neto 9c88ea5988 type determine accessor on aliased array
Change-Id: I8084bf6c30649acb2d6d7639fa6bf78cdd0a4a6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23581
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-22 20:33:12 +00:00
David Neto 32a4f957b4 Add type alias unwrapping methods
Change-Id: I8dbd3bba48ae95d76f75a5eba3e97ed4e091ed01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23580
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-22 20:30:33 +00:00
dan sinclair 011aed9b82 [spirv-writer] Add function calls
This CL adds calls to functions to the SPIR-V writer.

Bug: tint:5
Change-Id: Id6f3e41deba937edb85fa6ec2f2db8d1f4241944
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23621
Reviewed-by: David Neto <dneto@google.com>
2020-06-22 20:18:17 +00:00
dan sinclair e9598d697a Add support for sclamp and uclamp GLSL methods.
This CL adds support for type determination of the SClamp and UClamp
GLSL methods.

Change-Id: I974e80127f0e256285f126136270ac5131334a92
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23500
Reviewed-by: David Neto <dneto@google.com>
2020-06-18 18:03:00 +00:00
dan sinclair 8b48b26f73 [spirv-writer] Add as casts.
This CL adds the conversion of `as<f32>(b)` to SPIR-V.

Bug: tint:5
Change-Id: If1e04db2fe5520940527f4dcf52a89628b11b518
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23461
Reviewed-by: David Neto <dneto@google.com>
2020-06-18 18:02:46 +00:00
dan sinclair 3238eaa3b1 Add GLSL MatrixInverse type determination.
This CL adds type determination for the MatrixInverse GLSL method call.

Change-Id: I976beb00bb5c869407a0c9f522789112ff22bf6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23400
Reviewed-by: David Neto <dneto@google.com>
2020-06-17 20:22:08 +00:00
dan sinclair 3819c260de Add type determination for GLSL determinant.
This CL adds the type determination code for the GLSL determinant call.

Change-Id: I46bc57f4fd5f4f43021b20ee511b0b8fc809f4f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23360
Reviewed-by: David Neto <dneto@google.com>
2020-06-17 18:39:17 +00:00
dan sinclair c7b66da6ad Cleanup formatting and linter.
This CL cleans up various formatting and lint errors.

Change-Id: Ieee14db90e36acc8b469d58abb84fcf3595321bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23224
Reviewed-by: David Neto <dneto@google.com>
2020-06-16 15:02:50 +00:00
dan sinclair 7be237aa8f Determine types for module scoped variable constructors.
This CL updates the type determination code to determine the types of
module scoped variable constructors.

Bug: tint:89
Change-Id: Icd5d65409fcf17a0cbf0b34b9919f8d9e1577354
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23220
Reviewed-by: David Neto <dneto@google.com>
2020-06-15 20:55:09 +00:00
dan sinclair af5df70c7b Add GLSL FindILsb, FindUMsb, FindSMsb and InterpolateAtCentroid.
This CL adds the type determination for the GLSL methods FindILsb,
FindUMsb, FindSMsb and InterpolateAtCentroid.

Change-Id: I2b1e9d021e6799ffe6b5b71c5cca947b8e6ccfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22843
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:26 +00:00
dan sinclair ee39225c0b Add support for GLSL cross.
This CL adds support for the GLSL cross method.

Change-Id: Ib2e83a2ef2e580c6ca257851a76f3f66fa377d6f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22842
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:15 +00:00
dan sinclair 92bb55777c Add GLSL umin, umax, smin and smax support.
This CL adds type determination for the umin, umax, smin and smax GLSL
methods.

Change-Id: Ib301da41baf718e309a940f4a3560088daa10741
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22841
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:07 +00:00
dan sinclair 5e5fb9cf37 Add ssign and sabs GLSL support.
This CL adds the SSign and SAbs GLSL methods to the type determination.

Change-Id: If0e25cd153bd3aaef1cb031d647a86e98ff917bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22840
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 19:01:07 +00:00
dan sinclair 53352044df Refactor GLSL type determination code.
This Cl cleanups and simplifies the type determination for the GLSL
imports.

Change-Id: I9dd85ac390ef37c91d9493f840f81ceb6736fc06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22820
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 18:49:31 +00:00