Commit Graph

3031 Commits

Author SHA1 Message Date
dan sinclair 15cbc98a8c [spirv-writer] Start global variable output
This CL starts adding global variable output to the SPIR-V writer. This
does not handle constants or initializers at this point.

Bug: tint:5
Change-Id: Id06533b2ec1f61feadf66f3e43a484f6f3765546
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17922
Reviewed-by: David Neto <dneto@google.com>
2020-03-30 19:49:01 +00:00
David Neto 5556b4acdd ast::Literal constructor is explicit
Fixes a lint issue

Change-Id: I98225fe5bf966c6fbf9b3b0c88e3d4dcc6a91cca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18041
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-28 00:44:50 +00:00
David Neto a8bcec3ac1 [spirv-reader] Add TODO for ArrayStride
Bug: tint:3
Change-Id: I9655ddbe48f2660f88be68bc52c9467d805043ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18080
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-03-27 21:11:05 +00:00
David Neto 48442a6cee Fix compilation errors
Change-Id: I4cb46d93559089894d8cecb4ff24b87d208b0f85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18021
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 17:20:20 +00:00
dan sinclair 136fa11d53 Fixup compilation issues with type manager.
This CL fixes up some issues with the type manager.

TBR=dneto@google.com

Change-Id: I2d05935f26490fd8d20b1b6b1b61692a45e4a0f3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17940
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-27 01:50:13 +00:00
David Neto 288674904d [reader-spirv] Convert array, runtime array types
Bug: tint:3
Change-Id: If0d7d38cc777bce3d86dfd83669c1572331d4ed6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17800
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-27 00:49:03 +00:00
David Neto a8cd18e9e7 Context object owns a TypeManager
Add a Context::Reset method to clear state.

Hide the member behind an accessor.

Change-Id: Iafb7c39249f66f70c5a99a8ed1c69f2c0238834f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17742
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-27 00:47:16 +00:00
dan sinclair 20145170fc [spirv-writer] Generate pointer types
This CL adds the type generation for OpTypePointer.

Bug: tint:5
Change-Id: I9cfe6c4fbd9173df925421f278abd1afbda50fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17840
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 00:47:03 +00:00
dan sinclair 083def41c0 [spirv-writer] Add array type generation.
This CL adds generation of OpTypeArray and OpTypeRuntimeArray to the
SPIR-V writer.

Bug: tint:5
Change-Id: If3764ddb2499b8a196039521b8d9f80842626bcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17821
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 00:46:43 +00:00
dan sinclair 113fb07071 [spirv-writer] Generate constants
This CL updates the SPIR-V writer to generate the OpConstantTrue,
OpConstantFalse and OpConstant instructions.

Bug: tint:5
Change-Id: I660554c491e4eb569e3902fce0973fae3f27e6c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17820
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 00:45:34 +00:00
dan sinclair bf46de42ad [spirv-writer] Emit struct names
This CL changes the struct generation to emit the `OpName` for the
struct instead of doing it in a separate type alias pass. The struct
name was the only thing that needed to be output in the type alias pass
and this makes sure it's only emitted if used.

Bug: tint:5
Change-Id: I7389a3cd61812171fceeaae99253610152aa523d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17860
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-03-26 15:49:06 +00:00
dan sinclair 989cee6d33 Move tests into anonymous namespace.
This CL moves all test files to the anonymous namespace.

Change-Id: Ie5ae0efe907c03eeb441e90f31c976844172b594
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17900
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-03-26 15:31:43 +00:00
dan sinclair f26d9a8f26 Cleanup doc and lint warnings.
This CL fixes up several documentation and linter warnings.

Change-Id: Ic367ba1937f20dfe47a8c8e4035c17e8a3d0f2e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17880
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-03-26 15:31:36 +00:00
dan sinclair 33d34650e8 [spirv-writer] Emit function signatures.
This CL updates the SPIR-V writer to emit the OpTypeFunction and
OpFunction instructions.

Bug: tint:5
Change-Id: I85ead161ca37304a977213257a825ff268d29f2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17741
Reviewed-by: David Neto <dneto@google.com>
2020-03-25 19:43:20 +00:00
dan sinclair 9981b63fa4 Use a context object instead of a singleton
This Cl replaces the TypeManager singleton with a context object.

Bug: tint:29
Change-Id: Ia662709db1b562c34955633977ce4363f28f238e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17780
Reviewed-by: David Neto <dneto@google.com>
2020-03-25 19:16:36 +00:00
dan sinclair 0984214d8b [wgsl-writer] Add statement writer helper.
This CL adds a helper to emit a block of statements from the WGSL
writer.

Change-Id: I6fe62d894882c0a0fdc8865967bfa4887f3a65a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17761
Reviewed-by: David Neto <dneto@google.com>
2020-03-25 18:54:01 +00:00
dan sinclair 235ceebe37 Add type manager synchronization comment.
This Cl adds a comment about the type manager being a singleton and
synchronization requirements.

Change-Id: I91618516b26c18aa6b47e7e564b4b3a8eecc1009
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17740
Reviewed-by: David Neto <dneto@google.com>
2020-03-25 15:56:43 +00:00
David Neto 5e6d033a9e [reader-spirv] Convert vector, matrix types
Bug: tint:3
Change-Id: I4857d36da65fce7a413258f33d7dc4f3d9501c9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17702
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-25 14:33:45 +00:00
David Neto 71e1d81654 Add reader::spirv::ParserImpl::ConvertType
For now, it only handles scalar types

Bug: tint:3
Change-Id: Ic20e18a4f80790e6cd10d4c06dd2abfd8f67a304
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17700
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-24 21:42:16 +00:00
dan sinclair 69b9c1b8e0 [spirv-writer] Generate struct types
This CL adds generation of Struct types to the SPIR-V writer.

Bug: tint:5
Change-Id: Ibcabf7b1a688026297de682f4825d5195d8007d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17701
Reviewed-by: David Neto <dneto@google.com>
2020-03-24 21:40:10 +00:00
David Neto 6cd52e30ef Fix typo
Change-Id: Ic5845cff3e6e708ce88670f3d6038e339a94f33e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17660
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-24 19:55:29 +00:00
dan sinclair 7a480f4313 [spirv-writer] Start emitting types
This CL starts the emitting of SPIR-V types. This CL adds code to emit
the `AliasType`, `BoolType`, `F32Type`, `I32Type`, `MatrixType`,
`U32Type`, `VectorType` and `VoidType`.

Bug: tint:5
Change-Id: Ic13026ca9006fc0a253d019b1a6dd984ae992fba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17561
Reviewed-by: David Neto <dneto@google.com>
2020-03-24 15:03:29 +00:00
David Neto 7c6e8ded7d reader::spirv: Fix entry point test fixture name
Bug: tint:3
Change-Id: Ie7cd4f4f45b7be527b8d38a3dd76fac860a65ad8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17563
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-03-24 14:39:02 +00:00
David Neto a65ea31910 reader::spirv fix entry point tests
Define the ID targeted by the entry point.  Do this to avoid
asserts in the optimizer code

Bug: tint:3
Change-Id: Idbd4c8a058f2d51ff44696d2029502044d01b424
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17562
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-24 12:46:20 +00:00
David Neto a14fec951e readers::spirv: Emit entry points
Bug: tint:3
Change-Id: I66b99ad6ecb3f409f9df7bfa9aa6c4da65e3f66b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17582
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 22:54:36 +00:00
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