Commit Graph

606 Commits

Author SHA1 Message Date
David Neto 14cfcd707d Add conversion of SpvExecutionModel
Bug: tint:3
Change-Id: I2b1a12beea9343ab3a8db50308e2f6fd790c654b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17581
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 22:53:42 +00:00
David Neto 1ae8e85144 reader::spirv::Parser: register user names
Bug: tint:3
Change-Id: I4391aa733079d24fb19ff2cba9f612406e63a203
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17580
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 21:40:23 +00:00
dan sinclair dc200f7d1d Add SPIR-V dump to the SPIR-V generator
This Cl adds utility classes to dump out SPIR-V disassembly of the
builder and instructions.

Bug: tint:5
Change-Id: Ib4c57025ac63cb0be456bd819461c98ffa94367f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17560
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 20:59:12 +00:00
dan sinclair 781a4acb6f Generate errors from the SPIR-V builder.
This Cl adds error messages into the SPIR-V generator.

Bug: tint:5
Change-Id: I45c0d286dd8ec251773ff5e036322090647d780c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17521
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 20:07:34 +00:00
dan sinclair 248170ae44 Generate entry point instructions in SPIR-V writer.
This CL updates the SPIR-V generator to create entry point instructions.

Bug: tint:5
Change-Id: I04394bd508c0871ae9563cc811b4e49e42c2bb3a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17322
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 18:08:41 +00:00
David Neto 23dceb46fc Add reader::spv::ResolveMemberNamesForStruct
Bug: tint:3
Change-Id: If778e98416c19c518261c68d4afdfdc99724967f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17440
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:48:03 +00:00
David Neto ad90ee2ec3 Add reader::spirv:SuggestSanitizedMemberName
Also reader::spirv::GetMemberName

Bug: tint:3
Change-Id: I4cf2dce0703eb17a9d49452294ed0c28ea158a07
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17423
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:45:57 +00:00
David Neto ca8e6dd48d Add reader::spv::SuggestSanitizedName
Bug: tint:3
Change-Id: Ie53bbb7a0b2523a2098b485b6a5bb3d5fa4e52f9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17422
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:45:01 +00:00
David Neto 8af12f7503 Add reader::spv::Namer::FindUnusedDerivedName
Bug: tint:3
Change-Id: I0a0e5646d7bcdc89fdaaf8b956dd61ed6148c7e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17421
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:43:41 +00:00
David Neto bd1d142134 Add reader::spv::Namer::Sanitize
Bug: tint:3
Change-Id: I4d554755dacecac0f2dacf191d85f8e339e87923
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17420
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:42:21 +00:00
dan sinclair 7b7ff741c5 Generate OpExtInstImport
This CL updates the SPIR-V generator to only create the GLSL import if
it's requested.

Bug: tint:5
Change-Id: I96a9100adf0a0c59dcdd82c12ac27c566ea2663f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17341
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:27:05 +00:00
David Neto d854fc1543 Rename method RegisterExtendedInstructionImports
Bug: tint:3
Change-Id: If92bd97f9a71bd676ba40430fd736cf721c38747
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17360
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-20 19:24:48 +00:00
David Neto be4c89a4d2 Add reader::spirv::Namer
A Namer is a place for saving and looking up names
based on SPIR-V IDs.

Bug: tint:3
Change-Id: I6aeb2f5f7ba63c2e0a816dcbac88f964beafabc6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17284
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-20 19:24:23 +00:00
dan sinclair 3740fd2d46 Emit functions.
This Cl adds functions to the WGSL generator.

Bug: tint:4
Change-Id: Ibc7d27597c6c0d63c82931d0fa016856359d21b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17340
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:09:04 +00:00
dan sinclair c574295a42 Emit If statements.
This CL adds emitting of if statements to the WGSL generator.

Bug: tint:4
Change-Id: Ie79b40779a028dd40eac99c5459c971ead6cc43e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17286
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:08:56 +00:00
dan sinclair eaf2689a44 Emit else statements.
This Cl updates the WGSL writer to generate else statements.

Bug: tint:4
Change-Id: I72f6bbb6a2ab00bec3933083fd12c5da1a3dd5f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17285
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:08:07 +00:00
dan sinclair 0d00402124 Emit loop statement.
This CL emits the loop statement from the WGSL generator.

Bug: tint:4
Change-Id: I45be066ed306a71df053f7e61e6201a10a3d1056
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17283
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:07:00 +00:00
dan sinclair 5f64aee763 Emit switch statements.
This CL updates the WGSL generator to output switch statements.

Bug: tint:4
Change-Id: I4450b10932960691c76e76869105ade01fdd5a79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17282
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:06:52 +00:00
dan sinclair 4202d7d016 Emit variable statements
This Cl updates the WGSL writer to output variable statements.

Bug: tint:4
Change-Id: Ic557ea0c1b366644a8496dd43e4cfd85b9e8a84f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17281
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:06:45 +00:00
dan sinclair 187f9165a5 Emit Unless statement.
This CL adds unless statement to the WGSL generator.

Bug: tint:4
Change-Id: Id171cb1438d290938f1da946c23992bdae688359
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17280
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:32 +00:00
dan sinclair b42c76c47d Emit regardless.
This Cl updates the WGSL writer to emit the regardless statement.

Bug: tint:4
Change-Id: Iab35f3f0d956bd6cdd1411a06b4ca022147b0f87
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17261
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:22 +00:00
dan sinclair 2a6e275057 Emit Return statements.
This CL adds emitting return statements into the WGSL writer.

Bug: tint:4
Change-Id: Ia2331f7c20e3a3e3af1aa1553cef83bec315eae3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17260
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:10 +00:00
dan sinclair c083af83ea Add Kill, Nop and Fallthrough to WGSL writer
This CL adds the Kill, Nop and Fallthrough statements to the WGSL
writer.

Bug: tint:4
Change-Id: Ic0c635cfa7ca4c3195c593b119f9436ffeb1f9dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17201
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:02 +00:00
dan sinclair 17686fc57c Emit WGSL continue statement.
This Cl adds support for emitting the WGSL continue statement.

Bug: tint:4
Change-Id: I20f87d46e707bdd7ae2a517983e779988892c445
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17200
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:04:54 +00:00
dan sinclair 37f4fb0f75 Emit case statement
This CL adds case statements to the WGSL generator.

Bug: tint:4
Change-Id: Ic7945646d79b7c3e9e1cb1cf57d1633a28f45fc0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17180
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:04:45 +00:00
dan sinclair bf5ab65e98 Emit WGSL Break statement.
This CL adds emitting of the break statement to the WGSL writer.

Bug: tint:4
Change-Id: Iceae8cf8c1c77d63455621ea23f566af57c9e717
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17163
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:02:05 +00:00
dan sinclair 7f9d570a5a Emit assignment statement.
This CL updates the WGSL writer to emit the assignment statement nodes.

Bug: tint:4
Change-Id: I8a52f4e96c61ecb9e97cd3da41f4a1aa718e8d37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17162
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:57 +00:00
dan sinclair daff3e2616 Emit UnaryOp expression.
This CL updates the WGSL generator to emit the UnaryOpExpression node.

Bug: tint:4
Change-Id: I54046b5238a45994f7a4ed27941bd22b0c75f836
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17161
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:47 +00:00
dan sinclair 09671ab6f1 Emit UnaryMethod expressions.
This CL updates the WGSL generator to output UnaryMethodExpression
nodes.

Bug: tint:4
Change-Id: If43c0e5c12a967f08cc23e816d292353490404cf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17160
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:38 +00:00
dan sinclair cbabfa8ca1 Emit UnaryDerivative in WGSL writer.
This CL updates the WGSL writer to emit the unary derivative expression.

Bug: tint:4
Change-Id: I18c0fd56d88f98a6c5d37e176d98ab7b3077a50c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17120
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:29 +00:00
dan sinclair 49568e162d Emit relation expressions.
This CL updates the WGSL writer to emit the relational expressions.

Bug: tint:4
Change-Id: I2b2f5e40f2091ce2b7715773f3811aed7ed61f6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17100
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:19 +00:00
David Neto 2920659a47 Rolling 3 dependencies
Roll third_party/googletest/ e588eb1ff..482ac6ee6 (8 commits)

e588eb1ff9..482ac6ee63

$ git log e588eb1ff..482ac6ee6 --date=short --no-merges --format='%ad %ae %s'
2020-03-17 absl-team Googletest export
2020-03-16 dmauro Googletest export
2020-03-13 absl-team Googletest export
2020-03-06 absl-team Googletest export
2020-03-03 absl-team Googletest export
2020-03-03 absl-team Googletest export
2020-02-21 johan.mabille Fixed warnings
2020-01-29 krystian.kuzniarek remove a dead reference to the Autotools script

Roll third_party/spirv-headers/ 0a7fc4525..f8bf11a02 (9 commits)

0a7fc45259..f8bf11a025

$ git log 0a7fc4525..f8bf11a02 --date=short --no-merges --format='%ad %ae %s'
2020-03-17 dkoch Add shadercalls scope
2020-03-03 ntorosda Added ray flags, primitive culling flags, queries
2020-03-17 cepheus Non-functional: Update header build to match Khronos spec. builder.
2020-02-14 alele Update headers for SPV_KHR_ray_tracing.
2020-03-13 jmadill Add missing header to BUILD.gn.
2020-03-09 stevenperron Export NonSemanticDebugPrintf.h in bazel build
2020-03-02 jbolz Add NonSemantic.DebugPrintf JSON/header
2020-03-02 jbolz Fix max enum value
2020-01-01 xanto Also propagate SPIRV-Headers version to CMakeLists.txt

Roll third_party/spirv-tools/ e1688b60c..60104cd97 (18 commits)

e1688b60ca..60104cd974

$ git log e1688b60c..60104cd97 --date=short --no-merges --format='%ad %ae %s'
2020-03-19 dneto Add opt::Operand::AsCString and AsString (#3240)
2020-03-20 lujiao Add RayQueryProvisionalKHR to opt types (#3239)
2020-03-17 ehsannas Whitelist SPV_EXT_demote_to_helper_invocation for opt passes (#3236)
2020-03-17 dgkoch Add support for KHR_ray_{query,tracing} extensions (#3235)
2020-03-16 jmadill Roll external/spirv-headers/ 30ef660ce..a17e17e36 (1 commit) (#3230)
2020-03-13 vasniktel Update dependencies (#3228)
2020-03-12 greg Instrument: Debug Printf support (#3215)
2020-03-12 vasniktel spirv-fuzz: Support OpPhi when adding dead break and continue (#3225)
2020-03-12 afdx spirv-fuzz: Fix vector width issue in 'add equation instructions' pass (#3223)
2020-03-09 jbolz Allow sampledimage types as operand of OpCopyObject (#3222)
2020-03-09 vasniktel spirv-fuzz: Remove duplicated functionality (#3220)
2020-03-09 andreperezmaselco.developer spirv-fuzz: Allow OpPhi operand to be replaced with a composite synonym (#3221)
2020-03-08 andreperezmaselco.developer spirv-fuzz: Add toggle access chain instruction transformation (#3211)
2020-03-08 vasniktel spirv-fuzz: Add fuzzer pass to permute function parameters (#3212)
2020-03-06 afdx spirv-fuzz: Use better function name (#3207)
2020-03-05 afdx spirv-fuzz: Add swap commutable operands transformation (#3205)
2020-03-04 afdx spirv-fuzz: Fuzzer pass to add equation instructions (#3202)
2020-03-04 andreperezmaselco.developer Refactor FuzzerPass::ApplyTransformation code duplication. (#3206)

Created with:
  roll-dep third_party/googletest third_party/spirv-headers third_party/spirv-tools

Change-Id: I7f0e82cf5bbd38f6473757c74689ac35d23e53c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17342
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-19 18:31:59 +00:00
dan sinclair b595052ea3 Set root folder for linter.
This CL sets the root folder to be used by the linter when determining
header guards.

Bug: tint:23
Change-Id: I52ce8d3cd67e9882d4ea8a2c9cbd2d5d5650d5b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17205
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 13:03:35 +00:00
dan sinclair 2c56dd9099 Emit member accessor in WGSL generator.
This CL adds MemberAccessor handling into the WGSL generator.

Bug: tint:4
Change-Id: Ib84f9ca1969fec48f167433af957dc1ed4de3415
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17063
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:55:19 +00:00
dan sinclair 62a2002b4e Emit Cast expression.
This CL adds Cast Expression emission to the WGSL generator.

Bug: tint:4
Change-Id: Ib48290d53423be5770cfb8f1b5f1ccb93b53a4df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17062
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:53:30 +00:00
dan sinclair c80d5ed70a Add WGSL writer support for call.
This CL adds call expressions to the WGSL writer support.

Bug: tint:4
Change-Id: I1caa2f5f81ac2e2ab89755c1721e96d44c331853
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17060
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:51:27 +00:00
dan sinclair cd49b59c78 Add generation of the 'as' expression.
This CL adds 'as' generation into the WGSL generator.

Bug: tint:4
Change-Id: Ica9e615e30aae1882681d8da74b26a51cff6dc30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16880
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:33:00 +00:00
David Neto 4a19eeff2c Fixing include-what-you-use in SPIR-V parser
Change-Id: If9eeb92dd50bd88e3dcc8b0a8966812a96a153a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17287
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-18 20:32:49 +00:00
dan sinclair 8347687117 Split WGSL generator tests to individual files.
This makes it easier to find and track tests as the generator grows.

Bug: tint:4
Change-Id: I9660e459f3ffd33f3048a331f23623318af013e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16840
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:10:44 +00:00
David Neto 0afb943ebf add ast::Module::to_str
This makes it easier to see the bug.

Bug: tint:22
Change-Id: Ic5acc0b8299ef31eb73b49863bc42ac09de6e9bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17203
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-18 20:09:44 +00:00
dan sinclair 9d9d7cd29d Add ArrayAccessor to output expressions.
This CL extends the WGSL writer to output ArrayAccessorExpression the
initializers are also output so we can test the array[5] syntax..

Bug: tint:4
Change-Id: I560ca6af4d714e13b136f6ded2fb3329e309c9ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16820
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:05:44 +00:00
dan sinclair 4b71b9ed2b Expand build flags for Tint.
This CL extends the build options to Tint to make the various readers
and writers all optional.

Change-Id: I913e1830b1bb2243eff5deb4b8079ba592dd52e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16801
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 14:08:48 +00:00
dan sinclair e4392c9ab5 Create SPIR-V writer skeleton.
This CL creates the skeleton for the SPIR-V writer.

Bug: tint:5
Change-Id: I849d8766d32d48314a51096710272f9821e2c1c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16641
Reviewed-by: David Neto <dneto@google.com>
2020-03-17 21:00:22 +00:00
dan sinclair 3040f618a5 Remove assert in test.
The `assert` will compile out in Release builds so we don't actually
parse the module, which means we're always testing against an empty
module and the tests fail.

Bug: tint:22
Change-Id: I49a1f8fc8ec6231a65f4f17e385cff576c4f0d06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17204
Reviewed-by: David Neto <dneto@google.com>
2020-03-17 20:38:18 +00:00
David Neto 881cdede29 Fix include guards for SPV -> SPIRV
Bug: tint:3
Change-Id: I34a7c8e7dd0116968d2614441b3bcb81d7e5c4e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17202
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:08:25 +00:00
David Neto 4df5d409c4 Rename tint::reader::spv -> tint::reader::spirv
Bug: tint:3
Change-Id: Iabee55bc75f60c04d00cd1560721def903052359
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17001
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:08:06 +00:00
David Neto 4e7f7da729 Rename reader/spv to reader/spirv
Bug: tint:3
Change-Id: I7707e2f9e51c1574e5dde18c83957573671dac70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17000
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:07:41 +00:00
David Neto 3ac99398b5 spv: Parse OpExtInst for GLSL.std.450
It will always use the "std::glsl" import name.

Remember all the IDs of such imports.

Never add more than one GLSL.std.450 import to the AST.

Also refactor the Assemble test helper into its own file.

Bug: tint:3
Change-Id: I5b2b70ea0f00d44aacf553aa009756dff2a4cecf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16662
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 16:14:10 +00:00
dan sinclair c83578038a Disable lint warnings in fail stream test.
This CL marks the specific `bool` test as NOLINT in fail_stream to stop
the linter from emitting errors.

Change-Id: Ifa3d9b0a2e0f06bcd0d48cbe79f8dbe91fe7b4ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17061
Reviewed-by: David Neto <dneto@google.com>
2020-03-17 16:13:31 +00:00
Dan Sinclair 45d585f5ae Add unit test for VariableStatement.
This CL adds unit tests for the VariableStatement AST element.

Bug: tint:11
Change-Id: I36d1b134e4c1c93ee414c29e8bb8d5e7e9704da6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16760
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:59:46 +00:00