Commit Graph

80 Commits

Author SHA1 Message Date
Ryan Harrison 433670b576 Add usage of main from chromium when part of a chromium build
BUG=tint:123

Change-Id: Ic7a8694cefd0dbee2a1855e84f4ffaaf75ad6e7a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25520
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-22 17:36:39 +00:00
Sarah Mashayekhi fbf4506356 [validation] Add a disabled test for assignment statement.
Bug: tint:6
Change-Id: I37fe9f69917a007b9e3325de324e719637b192e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-07-22 12:59:19 +00:00
dan sinclair a0b73e8aca [hlsl-writer] Add assignment statement.
This CL adds the assign statement emission to the HLSL backend.

Bug: tint:7
Change-Id: I3e46ac09170ea1af7444ae89267a82e1d1c42c52
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25224
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:56 +00:00
dan sinclair 41aa1a1ed8 [hlsl-writer] Add switch statement support
This CL adds emission of switch statements to the HLSL backend.

Bug: tint:7
Change-Id: Ie6f41031878a1f5a945f9310429d28fb0e4a98c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25223
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:50 +00:00
dan sinclair 557a0f8e63 [hlsl-writer] Emit case statements.
This CL adds emission of case statements to the HLSL backend.

Bug: tint:7
Change-Id: I5d0dd7ecfe4ef032a03777c29f3d0d00e584a93a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25222
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:43 +00:00
dan sinclair 6dab73b5c6 [hlsl-writer] Emit unary operators.
This CL emits unary operators from the HLSL backend.

Bug: tint:7
Change-Id: I997d89d62d279fc7440ba6045c56e290ec7601c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25221
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:36 +00:00
dan sinclair abfdd22acc [hlsl-writer] Emit break, return and continue.
This CL updates the HLSL writer to emit break, return and continue
statements.

Bug: tint:7
Change-Id: I03eafc343e57e9e8d1efaf930023099d6f85fc57
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25220
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:29 +00:00
dan sinclair dee9136c20 [hlsl-writer] Add binary operator emission.
Emits the binary operators.

Bug: tint:7
Change-Id: I6f4fce3b6fb646b8340e39538b041715a676ac28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25164
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 15:58:20 +00:00
dan sinclair fbbc617888 Parse void function call.
This CL updates the WGSL parser to handle a void function call.

Fixes: tint:45
Change-Id: If5b2a4b9e62f0b10e0f2e2e10c0ca2586c5268e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25322
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-21 15:13:36 +00:00
dan sinclair e5228407f4 [hlsl-writer] Add emission of identifiers
This CL adds identifier emission and an HLSL namer to guard against
names using reserved words.

Bug: tint:7
Change-Id: Id3d73ff683048c26ac99451d21c3dd7ef3c620a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25001
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 14:51:33 +00:00
dan sinclair 2e40491467 Add a call ast statement.
This CL adds CallStatement to the AST to allow wrapping a CallExpression
into a statement.

Bug: tint:45
Change-Id: I5a9525514344fcc2cf9900eb2cd78c1fb94ca2ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25320
Reviewed-by: David Neto <dneto@google.com>
2020-07-21 13:42:05 +00:00
David Neto c29bad28ad [spirv-reader] Support function calls, except returning void
Functions returning void are blocked on https://crbug.com/tint/45

Change-Id: I15ec9cf0e267571bbfab921c678a59e25d0e3619
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 22:19:01 +00:00
dan sinclair feffa9d887 [hlsl-writer] Scaffold the HLSL backend.
This CL adds the scaffolding for the HLSL backend.

Bug: tint:7
Change-Id: Iaf9f5159bc409f3ac71fcec281229258bdfa021b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25000
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 22:13:37 +00:00
dan sinclair 26c8a216e8 [msl-writer] Add import emission.
This CL adds emission of import function calls to the MSL backend.

Bug: tint:8
Change-Id: Ib8b8638b11caee2ff3557d551447b215ef2a4c69
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25262
Reviewed-by: David Neto <dneto@google.com>
2020-07-20 22:13:00 +00:00
Ryan Harrison c8af502c01 Fix issues with BUILD.gn
Couple of little style issues, and a path to a file that was incorrect.

Change-Id: I21d1a4ca41bc36163602378086989ac712f54469
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25265
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-20 19:54:23 +00:00
Ryan Harrison 31cfdb111e Clean up how deps are defined in BUILD.gn
gn gen --check is failing in chromium due to how includes are propagated
out of deps. Re-organizing them to resolve this.

Change-Id: I3c21bbb0cb8b5bc5bdad4ab97d557d718a3cdc33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25120
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-16 20:13:16 +00:00
dan sinclair 4264af9d3d [msl-writer] Emitting of program constants.
This CL adds code to emit program constants in the MSL backend.

Bug: tint:8
Change-Id: I63e40983253349d2e293904fbe9b6f543b885b34
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24940
Reviewed-by: David Neto <dneto@google.com>
2020-07-16 17:54:26 +00:00
dan sinclair c5a5f9666f [msl-writer] Handle emitting user function calls.
This CL adds support for calling user defined functions from the MSL
backend. Intrinsics and imports are not handled yet.

Bug: tint:8
Change-Id: I45c3078d014ab89cc0eec76dd626759077e1a890
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24763
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:38 +00:00
dan sinclair a2eb8c52b2 [msl-writer] Generate input/output structs
This CL adds generation of the input/output structures for entry points.

Bug: tint:8
Change-Id: I93942496bcea0a2eea944e5e1cd0baf383530f5e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24721
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:20 +00:00
dan sinclair 45101598a1 [msl-writer] Add variable declarations.
This CL adds variable declarations to the MSL backend.

Bug: tint:7
Change-Id: Icf63ad44a217213e5036eb76429e25a3031822eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24540
Reviewed-by: David Neto <dneto@google.com>
2020-07-08 20:52:46 +00:00
Ryan Harrison 7b819aa162 Multiple fixes to get BUILD.gn builds working again
Change-Id: I00c8050d85e25c4e926c06b4df1381434de92f34
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24460
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-07-07 19:11:07 +00:00
dan sinclair 6002a3345f [msl-writer] Add namer class.
This CL adds a namer class to prevent collisions with builtin names in
MSL. The MSL generator has been updated to use the namer anywhere that
names are emitted.

Bug: tint:8
Change-Id: I820f226a7286be1d5b0d613bd0fa41b68cb9f8ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24184
Reviewed-by: David Neto <dneto@google.com>
2020-07-02 20:53:45 +00:00
dan sinclair 53b3283c6a [msl-writer] Emit switch statements.
This CL adds support for switch and case statements into the MSL writer.

Bug: tint:8
Change-Id: Ib51f943e8476c0ecfd45e9131404f96934c6e21f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24180
Reviewed-by: David Neto <dneto@google.com>
2020-06-30 21:33:20 +00:00
dan sinclair e88c0f6f8a [msl-writer] Emit loop statements.
This CL adds the code to convert a loop/continuing statement into MSL.

Bug: tint:8
Change-Id: I9fa595908c6d834d9543b583c8baf8c19f8cae6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24122
Reviewed-by: David Neto <dneto@google.com>
2020-06-30 17:40:28 +00:00
dan sinclair 57b3b1d117 [msl-writer] Add break and continue emission.
This CL adds writting of break and continue statements to the MSL
backend.

Bug: tint:8
Change-Id: If2443c036fa82f54708d209d924192ee7a159e76
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24121
Reviewed-by: David Neto <dneto@google.com>
2020-06-29 21:17:54 +00:00
dan sinclair fa1659a3ef [msl-writer] Emit member accessors.
This CL adds emission of member accessor expressions to the MSL writer.

Bug: tint:8
Change-Id: I21d8564880c44d719c89dca2a10cd97ccb1e2cd7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24120
Reviewed-by: David Neto <dneto@google.com>
2020-06-29 21:17:44 +00:00
dan sinclair d4eafb631d [msl-writer] Emit alias types.
This CL adds emission of alias types to the MSL writer. They are output
as `typedef`s.

Bug: tint:8
Change-Id: I18b839ed0238c4636e3975f35f5d88badd412fe4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24001
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair dc841f1bf2 [msl-writer] Add array accessors.
This CL adds the code to emit array accessors from the MSL backend..

Bug: tint:8
Change-Id: Ia6b49c11602d39aa559feac31fcfd592ab54928c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24000
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair d1bf87b9d8 [msl-writer] Add unary op emission.
This CL adds emission of the unary `-` and `!` operators.

Bug: tint:8
Change-Id: I9dda066111cc8f115b593127cf070c6ca37bdc66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23842
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair 24a46e8e69 [msl-writer] Emit kill statement.
This Cl adds emission of the Kill statement as `discard_fragment`. This
may need to be revised when the semantics of Kill are agreed upon.

Bug: tint:8
Change-Id: I2d09f09143b2acd0139d876e873e3c70abbc84a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23841
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair 28d4a94bee [msl-writer] Add emission of if statements.
This Cl adds emission of `if`, `else if` and `else` statements to the
MSL backend.

Bug: tint:8
Change-Id: I8c22d70f2afa0a1d86cf475f5c98127504a6dc0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23840
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair b1de84316c [msl-writer] Add cast conversion.
This CL adds conversion of casts to MSL.

Bug: tint:8
Change-Id: Iecfb9a5b413b1d10372b4d2fec31c0956b1475a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23822
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair 3dbc8378fa [msl-writer] Add generation of as casts.
This CL adds the MSL conversion of as casts to `as_cast`.

Bug: tint:8
Change-Id: Iaa8ee1fa3077e4471bbead9d24fcf1e2d68998b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23821
Reviewed-by: David Neto <dneto@google.com>
2020-06-26 21:27:59 +00:00
dan sinclair 6366f68121 [metal-writer] Emit constructors.
This Cl adds the code to emit scalar and type constructors from the
Metal backend.

Bug: tint:8
Change-Id: I95c713568ae3a73b82f8c9e10119e29e3469893e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23707
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 18:22:21 +00:00
dan sinclair 7f269e5bcb [metal-writer] Emit binary operations.
This CL adds emission of binary operations to the Metal backend.

Bug: tint:8
Change-Id: I797daadd238b718b081842b63ccefab3294bc20c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23706
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 18:22:05 +00:00
dan sinclair 70c605fc47 [metal-writer] Emit assignment statements.
This CL adds assignment statements to the Metal backend.

Bug: tint:8
Change-Id: Iaf4faa62124948fd0e785d5bebd20aae778ba050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23705
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:54:33 +00:00
dan sinclair e66d6a6745 [metal-writer] Emit functions
This Cl adds the code to emit functions from the metal writer. Note,
this does not handle entry points yet.

Bug: tint:8
Change-Id: Ie665771169261f6839de5eb1b66dc511bf47616a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23704
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:54:25 +00:00
dan sinclair 646fb23c1f [metal-writer] Add identifier expression.
This CL adds the start of identifier expressions to the Metal backend.
Identifiers with paths are currently not supported.

Bug: tint:8
Change-Id: I4df8b6a3c32251d454d3dae5fa8933dad36094f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23703
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:49:08 +00:00
dan sinclair 8cd87513b3 [metal-writer] Add return generation.
This CL adds generation of the return statement.

Bug: tint:8
Change-Id: Iffee600e77a485649b987d39aab47742968e438e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23702
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:49:00 +00:00
dan sinclair 5dd37b2e6c [metal-writer] Add basic type emission.
This CL adds the start of type emission for the Metal backend. A few
types like pointers and structs aren't complete yet.

Bug: tint:8
Change-Id: I648e9275ef1b9dc6fa63b6ab328fe018a5f620ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23701
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:48:53 +00:00
dan sinclair 2a59901483 [metal-writer] Stub out the Metal Shading Language backend.
This CL adds the basis of the Metal Shading Language backend.

Bug: tint:8
Change-Id: I85976250eb41ac12203a5db116444e993c3d09d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23700
Reviewed-by: David Neto <dneto@google.com>
2020-06-23 17:48:40 +00:00
David Neto fd3700c0a7 [spirv-reader] Support Undef, mapping to null
Bug: tint:3
Change-Id: I1549f0445c92312b0d20292ff9d60736300d5378
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23600
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-22 20:48:59 +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
Ryan Harrison b8f4930055 Make #define values public in BUILD.gn
This is needed to allow users to actually use tint/tint.h

BUG=tint:87

Change-Id: I70c9397a0497feca88ccf8879a3d0e8a03ab8471
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23260
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-16 17:26:59 +00:00
David Neto c7d1ac3361 [spirv-reader] Add OpCompositeConstruct
Bug: tint:3
Change-Id: Ibb1a4124e7e7b7a5b95bdd4e7c7e7f1c570e641c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23127
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-12 15:09:56 +00:00
David Neto 0335adbc9a [spirv-reader] First GLSL.std.450 instructions
This supports the extended instructions used by the compute_boids
example.

Bug: tint:3
Change-Id: I364c343217139e489377dd2a9330058114023caa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23126
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-12 15:09:14 +00:00
Ryan Harrison be45ff5081 Create tint.h for external users
tint.h selectively includes headers depending on what features are enabled. It
is based off of the original sample code, so should give users access to all of
the functionality demonstrated in there.

This is located in include/tint/, so that users can have a pretty include of
tint/tint.h.

BUG=tint:87

Change-Id: I8659c789c154349e4e8e7730dc334da4fb6eba70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23124
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-11 19:35:20 +00:00
Ryan Harrison 3f3483be14 Fix BUILD.gn based builds
Change-Id: Iec5c7ee8d6f614f7a7301c023703650d4c4068d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23061
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-10 19:45:00 +00:00
dan sinclair 3e7dc82b35 [spirv-writer] Generate any intrinsic
This CL adds the necessary code to generate an OpAny instruction.

Bug: tint:5
Change-Id: I558b2cbf4bade3b4ab17997d24dcffddc32e2b41
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22620
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:05:35 +00:00
dan sinclair 2b23e4bd70 Remove unless_stmt
The `unless` statement was removed from the WGSL grammar so remove it
from Tint.

Change-Id: I31a185f5c5e3e88b667caea1c9a88aee80c0b810
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22581
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-06-03 16:11:37 +00:00