Commit Graph

620 Commits

Author SHA1 Message Date
Sarah Mashayekhi f70065f622 [validation] Validate if entry point functions accept parameters
Bug: tint: 6
Change-Id: I7e9f50759e65ed6ef3dc25a6c004bec3dfbd4648
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27122
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-24 16:03:36 +00:00
Sarah Mashayekhi c3038ddfa6 [validation] Adds disable test for v-0023, entry point functions accept no params
Bug: tint: 6
Change-Id: I7ea874e90f4dbd213ff35275823342027340e348
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27121
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-24 15:00:46 +00:00
Tomek Ponitka 43c2a6c7d4 [wgsl-reader] Adding body_statement to statement grammar
Block statements will now be parsed in ParserImpl::statement()

Change-Id: I28f63d4a53c85c0306c57df545f78b4562c6ea7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-24 13:43:16 +00:00
David Neto c189b1d479 Re-enable float emission tests
Test a value that should stably convert to decimal exponent
representation.  This might be working around a bug in the MSVC runtime
library.

Bug: tint:201
Change-Id: I37200cef815cafc35284c8c873dfbb8a5312360e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27160
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-21 21:19:33 +00:00
Sarah Mashayekhi e871e48df0 [validation] validate if entry point functions return void
This CL validates following validation rule:
v-0024: Entry point functions return void

Bug: tint: 6
Change-Id: I420781008016af110cb0d3d65fc018a1301efeae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27120
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-21 15:40:43 +00:00
Sarah Mashayekhi 1026fe3d27 [validation] Add disabled test for v-0024-entry point functions return void
Bug: tint: 6
Change-Id: Iae865125b30952a9422261fbfe14e9b6fb74e16f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27101
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-20 21:51:39 +00:00
Sarah Mashayekhi 3c9fee13b9 [validation] checks if function used in entry point exists
This CL check validation rule v-0019: Functions used in entry points must exist.

Bug: tint: 6
Change-Id: Ic4d4702cac53dcdaa1207425a6214d53cacb2442
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27100
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-20 21:25:39 +00:00
Sarah Mashayekhi 255cfe829f [validation] Add disabled test for v-0019-entry point functions must exist
Bug: tint: 6
Change-Id: I303fab6e0cd4a807173bef8f69e14220480fbb9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27080
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-20 20:52:29 +00:00
Sarah Mashayekhi 8db00dffa2 [validation] Checks if recursions exist
This CL validates the following rule. ie. As functions must be defined before use (v-0005), self-recursion is only case that has to be invalidated.
v-0004: Recursions are not allowed.

Bug: tint: 6
Change-Id: Icfb040907c5ea0abb6359dade74dcfc30a0db7d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26980
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-20 17:00:09 +00:00
dan sinclair d38df397e3 [hlsl-writer] Add support for import statements.
This Cl adds support for imported methods to the HLSL backend.

Bug: tint:7
Change-Id: Ib906542915670dcc916d48d9e5d64d7032ba829a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26928
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:19:04 +00:00
dan sinclair a1087ee513 [hlsl-writer] Generate intrinsics.
This CL adds the beginning of intrinsic emission for the HLSL backend.
The `outer_product`, `is_normal` and `select` intrinsics are currently
missing.

Bug: tint:7
Change-Id: Ice7a2b285eeb52041e3accd9751e127d6c5a0177
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26927
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:17:54 +00:00
dan sinclair 3739a23f24 [hlsl-writer] Emit cast expressions.
This CL adds support for cast expressions to the HLSL backend.

Bug: tint:7
Change-Id: Ie7e180dc89abf137ab7d9b8790cc4206b3d5a672
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26926
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:14:44 +00:00
dan sinclair 10585f0ac3 [hlsl-writer] Add tests for entry point data.
This CL adds the missing tests for emission of Entry Point Data
structures.

Bug: tint:7
Change-Id: If21071b07584780243ccd0629a92efa653640251
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26925
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:04:54 +00:00
dan sinclair 6fdc77a966 [hlsl-writer] Emit module constants.
This CL adds emission of module constants to the HLSL backend.

Bug: tint:7
Change-Id: Iff07b0c0de7351f400dc35ca2ac07b44b22f8499
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26924
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:03:24 +00:00
dan sinclair 1811639709 [hlsl-writer] Fix emission of struct aliases.
You can only typedef builtin types in HLSL. This Cl updates the struct
emission to emit named structs instead of typedef'd structs.

Bug: tint:7
Change-Id: I835b7f4d23bc225c730ef3f39c4572c043a58156
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26921
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 19:00:21 +00:00
dan sinclair bfaa6f8e57 [hlsl-writer] Emit uniform variables.
This CL adds emission of uniform storage class variables to the HLSL
backend. If the variable is a base type (float, int, etc) it is emitted
as a `cbuffer`. If the variable is a struct it will emit as a
`ConstantBuffer`.

Bug: tint:7
Change-Id: I9932d30df24c023c58d3a2ba4167bcb7ccb85dae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26920
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 18:57:09 +00:00
dan sinclair 7df4a845d9 [hlsl-writer] Add CallExpression.
This Cl adds support for call expressions into the HLSL backend.

Bug: tint:7
Change-Id: Id07e3d95e745aa016a658c3ec5d099f74f21a80e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26781
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-08-19 17:44:45 +00:00
dan sinclair 34fd95ced0 [hlsl-writer] Add support for input locations and builtins.
This CL adds the beginning of support for input/output locations and
builtins in the HLSL backend.

Bug: tint:7
Change-Id: I8fb01707b50635a800b0d7317cf4a8f62f12cfca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26780
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-19 17:37:25 +00:00
dan sinclair be89a06b03 [hlsl-writer] Add function handling.
This CL adds the beginning of function handling to the HLSL generator.

Bug: tint:7
Change-Id: Id40109c342e7a128b1fe79a0c50967e1dbd125eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26662
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-19 17:32:25 +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
Sarah Mashayekhi 8fcf269d4b [validation] Add Disabled test for detecting recursion
This CL adds a disabled test for validating following rule:
v-0004: Recursion is not allowed

Bug: tint: 6
Change-Id: I35d51b08174ac23a4b1def9f762e80c5950a726d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26942
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 21:01:28 +00:00
dan sinclair dd99471420 [spirv-writer] Output name for constant global variables.
When emitting a global constant we'd early exit the emission code before
emitting the debug statement for the constants name. This Cl adds the
needed code to emit names for global constants.

Change-Id: I1a7a3660b4ff31879393a6a776a9f00e895de216
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26923
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-17 20:00:48 +00:00
Sarah Mashayekhi b08e253886 [validation] Validates if return statement type matches function return type
This CL checks if the return statement type matches the function return type

Bug: tint 6
Change-Id: I621d67086291c392b68261673a25c0e6caca71ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26860
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 15:46:07 +00:00
Sarah Mashayekhi eec1a6e628 [validation] Validates function name uniqueness
This CL implements and add a test for the following validation rule:
v-0016: Function names must be unique

Bug: tint: 6
Change-Id: I9f135dd577863e41f03a2d02adebe4347a9922eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26782
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-17 15:32:38 +00:00
Sarah Mashayekhi 23c3fee354 [validation]: Add disabled test for validating return statement type matches function types
Bug: tint: 6
Change-Id: I573cd4fb5759f1d72dd2e0f04a1dd183879745d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26723
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 19:17:49 +00:00
Sarah Mashayekhi d73f812c84 [validation] Validates return statement
This CL checks if functions end with a return statement (v-0002)
reworks previously added tests to pass
enables related tests

Bug: tint: 6
Change-Id: Iafe46581ccc50e146b33d33f9577d995a7f80d77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26722
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 18:09:59 +00:00
Ryan Harrison a532ac55d9 Fix handling of .spvasm inputs
BUG=tint:207

Change-Id: Ic429a909d092423908409678b7256bd88de10a99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26760
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 17:33:59 +00:00
Sarah Mashayekhi 5e7ef27ca7 [ast] Adds get last statement to ast::Function
This CL adds a function which returns the last statement of a ast::Function

Change-Id: I1dc68b7f4669c17a24a62c03a87dcc95866a428d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 20:06:29 +00:00
Sarah Mashayekhi f16250b8ac [validation] Validates functions return statement
This CL adds a disabled test for validation rule v-0002: functions must
end with a return statement

Bug: Tint: 6
Change-Id: I127aa1bd7d236ff353fd89024b274c9f9b463f15
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26680
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 19:31:42 +00:00
dan sinclair 633b1a7463 Minor updates to fix compilation.
This CL adds the needed `memory` include for clang on windows and fixes
up some issues to make doxygen happy again.

Change-Id: I2c3f21aa086b079d3b861786834bcf4370123a7d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26703
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 19:28:59 +00:00
Idan Raiter eca0eaa006 Find un-named entry points, change set number
Finds entry points, and uses set 4 intentionally as it is bigger than
the maximum set for users.

Bug: dawn:480
Change-Id: I24f01d770ba43796233aeb40b3b6b2ae9b3c3663
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26520
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:44:01 +00:00
Idan Raiter ef6a4af7b5 Add instance step mode to vertex pulling transform
Bug: dawn:480
Change-Id: Icf650b7f340528e6a49d68d155fd9becc212e623
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26440
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:30:08 +00:00
Idan Raiter 63551e3b2f Add vertex pulling transform
Adds a first-pass version of vertex pulling. This is missing several important things such as buffer offsets, support for more types, and clamping.

Bug: dawn:480, tint:206
Change-Id: Ia8a3abc446bca4c5a40e064f85fb59de1c3f5af9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-12 17:23:58 +00:00
Sarah Mashayekhi d3107bdbaa [validation] Validates declaration name uniqueness
This CL adds implementations and tests for these validation rules:
v-0011: Global variable names must be unique
v-0013: Variables declared in a function must be unique between that function and any global variables.
v-0014: Variables declared in a function must have unique names

Bug: tint 6
Change-Id: I793485c981f67abc6a3dc81d35be743ccc18db5b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26480
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-11 20:44:06 +00:00
dan sinclair a5e7ead0c6 Disable failing tests
A few of the tests depend on floating point string output which is
slightly different on MSVC. Disable for now.

Bug: tint:201
Change-Id: I51510a1192488f4e391dfb3560b5b6a2915ebcd1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26220
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-11 20:23:40 +00:00
David Neto bc80805c4b [spirv-writer] Infer and emit matrix layout
WGSL matrices are always column major, with tightly packed columns.
We need to infer that layout and decorate the containing structure
members, if those members require a layout.

Bug: tint:200
Change-Id: Ieceb460ed6c7eeb1244beecbf4e0eee0b8b8e373
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26180
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-09 15:45:37 +00:00
Sarah Mashayekhi e88f1c388c [validation] v-0021: cannot re-assign constants
Bug: tint: 6
Change-Id: Ib5cd57478b35c8dbf04136eb4167a3c3bce1c954
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26420
Reviewed-by: David Neto <dneto@google.com>
2020-08-07 14:34:34 +00:00
Sarah Mashayekhi 65f88d6f1d [Validation] v-0006: variables must be defined before use
Bug:tint 6
Change-Id: I22f3117a8d59eaba97166de1f188156a9e3cd7a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26381
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-08-06 21:24:14 +00:00
David Neto 6eb2a85adf [spirv-reader] Remove support for NumWorkgroups builtin variable
It was removed from WGSL MVP
https://github.com/gpuweb/gpuweb/issues/920

Bug: tint:3
Change-Id: I94a584feec88dda7e310ee5d7fa01e93e26cd31d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25526
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-05 21:16:59 +00:00
Sarah Mashayekhi b77399cbad [validator] implement variable_stack_
Change-Id: I388847770de8dc703e92030f0fab8f9001643f95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26006
Reviewed-by: David Neto <dneto@google.com>
2020-08-05 15:23:47 +00:00
dan sinclair 3125a8d73f [ast] Add texture types to the AST.
This CL adds the texture types into the AST.

Bug: tint:141
Change-Id: I8e95aa23849af737e63d9cacc8c57f23aedec73d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26123
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 23:26:28 +00:00
dan sinclair fe8c59ace9 Add SamplerType to AST.
This CL adds the sampler type into the AST.

Bug: tint:141
Change-Id: Id2f7678a2df677cb7dae47f05543c1e0a1999eed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26080
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:27:25 +00:00
dan sinclair 8278f2c6f0 [hlsl-writer] Add loop support.
This CL adds support for the LoopStatement emission in HLSL.

Bug: tint:7
Change-Id: Ie42b24abff3a69c9cbfe3d3c8ab6fb9b1823e61d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25849
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:27:09 +00:00
dan sinclair 97bc4ad8d6 [hlsl-writer] Add if/else statements.
This CL adds if/else statement emission to the HLSL writer.

Bug: tint:7
Change-Id: Idd6e6d8c329ed270676fa0276474a68c715dd9eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25847
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:26:55 +00:00
dan sinclair cbe0668f9b [hlsl-writer] Emit variable declarations.
This CL adds variable declarations to the HLSL backend.

Bug: tint:7
Change-Id: I5c1e42ca26029f1595bf4f23b3b867a492ddacc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25846
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 22:26:46 +00:00
dan sinclair 753f40b869 Fixup build warnings
Change-Id: I7a61bd4363b01bf186e235bf76e97bd513d2fd12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26081
Reviewed-by: Ryan Harrison <rharrison@google.com>
2020-07-30 18:18:46 +00:00
dan sinclair c8a85aa5a9 [wgsl-reader] Add stride support.
This CL adds stride support to the WGSL reader.

Bug: tint:178
Change-Id: Id6b5163438e562a371255ad3fb992d0a716543e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26040
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 16:50:25 +00:00
dan sinclair ac4a2894fe [wgsl-writer] Emit array stride decoration.
This CL adds array stride decorations to the WGSL writer.

Bug: tint:179
Change-Id: I39d7625e1bdc876bbf9a83da7af76eb98bd09c28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26002
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 16:48:36 +00:00
Idan Raiter a8e4e2ad5d Add BlockStatement insert and non-const global_variables
Insert will be used for adding code at the beginning of a function, and
non-const global_variables to edit decorations.

Bug: dawn:480
Change-Id: I9fbb0210a95b8488c9ce6d9a536a68f169b0cc33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25850
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-30 13:59:00 +00:00
Sarah Mashayekhi a3f9778ee6 [Validator] Using pointers instead of refs
Change-Id: I19a1cd27b6cbbc5d5d88a46bc5dd43c66a318b7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26004
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-30 02:27:03 +00:00