When converting an AST expression to IR, check for a sem::Load node
and emit a load instruction if present.
Update conversion of compound assignment and increment/decrement to
load from the LHS.
Convert load instructions to inline variable references when going
back to the AST.
Bug: tint:1718
Change-Id: Ib2b850efb304a71eff95aadac825f015623b6eb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133220
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Only Constants.h remains in no namespace; but it may be addressed
in the future as well.
Bug: dawn:302
Change-Id: Ib9b9ab4b974ad1de1bb9f2302f4d24d8216f55e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132841
Kokoro: Austin Eng <enga@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Change the type of a `var` to a pointer. Fold away address-of and
indirection.
Fixed: tint:1912
Change-Id: Ib1f07538c63df9349c5b6171062b6f79750c1439
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133400
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Adds support for both `If` and `Block` flow nodes as branch
targets. Also support a nullptr branch target by emitting
OpUnreachable.
Bug: tint:1906
Change-Id: I1adea83ce6c7c85c6a2e2dae9327499cb7f850bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132861
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Use it in the SPIR-V writer.
Bug: tint:1718, tint:1906
Change-Id: If8f29300712c457a02ddc9eb2fd76e0b49ee8fea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132682
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Enable the transform manager to run a pipeline that mixes AST and IR
transforms, automatically converting the current program as necessary.
Bug: tint:1718
Change-Id: I8df76db61edd94e0b1d7c2aaabc18b394db3d8de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132502
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: James Price <jrprice@google.com>
The RHS of a compound assignment statement may need to be
materialized. This was showing up when converting things like `i += 1`
to IR, as abstract types were creeping into the IR.
Change-Id: Idf9b1523d1751e26c28a795af07769ca85a65f14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133221
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This CL adds phony assignment to the IR. The assignment part is ignored
and the RHS of the expression is generated. This creates a result value
which is then never used.
Bug: tint:1918
Change-Id: Ic87fdcb387cb4d9783c4dbbe26ebc76f67a3cdd9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133260
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
The Instructions are now inheriting from Value so they can use the value
block allocator. Remove the instruction allocator.
Bug: tint:1718
Change-Id: Ia8f3b8b106d03883b3c72ebead392ae972a86c4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133164
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
This CL adds the ability to add parameters to blocks and emits the
params as needed in the disassembly.
The ShortCircuit is updated to use block arguments instead of creating
a return value.
Bug: tint:1909
Change-Id: I92afa6cf8ff4e01bfa3de46e76c26c465f0d6062
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133200
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
The address space and access mode both exist on the type of the Var,
storing the information into Var is redundant. This CL removes them from
var in favour of the type fields.
Bug: tint:1718
Change-Id: I0198a8794d6359834592562251b2788e8a0347ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133163
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
And implement functions with return values.
Bug: tint:1902
Change-Id: Id4015aa83bf75de2a0f3dfdbfe19f728c05226c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133142
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Returns with values requires fleshing out of functions, which comes next
Bug: tint:1902
Change-Id: I5f956805441b99038f2d48758d1bd767ea4e1a1d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
Traverse the block nodes, and if statements.
Bug: tint:1902
Change-Id: Ie5533acdc65378bfea91b46a62090c4d3216b303
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133100
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This CL adds increment and decrement statement support into the IR.
Bug: tint:1718
Change-Id: Ieba2ab7a4c9232dc9d76a8605637cd5ea46b0e08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133162
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This change updates the Device descriptor to allow a device lost
callback to be passed in at device creation time. This will be
important for allowing the API to return devices which have
already been lost in a future CL, which is the behavior required
by the spec.
This change does not yet deprecate the old method for setting the
callback, as there's still some tricky scenarios that will need to
be worked around to enable that and this CL is already fairly
large. (The uses in question pass the device or a value created
from the device as the userdata.)
Bug: chromium:1234617
Change-Id: I1adea5ceffdfdcfedff9fff4960f12303abba29c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121041
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This will allow for both AST transforms and IR transforms to be used
in the same transform manager.
The transform manager is no longer a Tranform subclass.
Bug: tint:1718
Change-Id: I59bd87806090fa365ce4b575710c5ffcfc657bd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132501
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Adds a script to help with adding or removing Dawn milestones.
Bug: chromium:1432491
Change-Id: I0882503f4ceb7ba3454e13ec1669c053055ac975
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133165
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Garrett Beaty <gbeaty@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This is the first commit to implementing an IR -> AST conversion path.
Not much currently implemented, but enough to start building upon.
Started implementing AST -> IR -> AST roundtrip tests.
Bug: tint:1902
Change-Id: I17fa9f3bc609b48ecb916ab47ae61bfa36821b44
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131180
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL updates the disassembly output to make it clearer when
instructions are flow node traversals, and when they're actual
instructions in a block.
Bug: tint:1718
Change-Id: I95e103a5672b5579081b73e9633bf07b31e51187
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Builders all use python3 only now
Fixed: dawn:1530
Change-Id: I4038e24376d468b8f45966ba46ad31446b1b6877
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133180
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
The scope stack for a loop is slightly different from other constructs
as the block for the body and the block for the continuing need to share
the scope. This CL fixes the loop conversion to special case the scope
stack for the loop body so the continuing block can see the variables.
Bug: tint:1718
Change-Id: I2e4898b36f1541b48a4e349955833b155332947a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This is unneeded, as we can now determine if a function is an entry
point by checking its pipeline stage.
Bug: tint:1718
Change-Id: Icb09b39b7a63cf9a9a36ccad5e144eceec1dfdeb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131521
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This CL adds the pipeline stage and workgroup_size as optional
parameters when creating a function in the IR.
Bug: tint:1718
Change-Id: Iae65dcb9557a644a17ec67fc5269d0c2db3f8aba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133001
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL updates the SPIRV IR generator tests to use the `Branch` method
of the builder.
Bug: tint:1718
Change-Id: I16961382b797dc90277529f706ee240be282d623
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133000
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: James Price <jrprice@google.com>
Parses the CL descriptions and adds missing hashtags to Gerrit changes.
Also add ./tools/push-to-gerrit which runs this after pushing the local branch's changes to 'main'.
Use this for the VSCode 'push' task.
Change-Id: I4c3f5982f6fdc7c1c6ebe770fc7811b1b38795d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133061
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Black-box the BuilderImpl by putting the BuilderImpl into the
from_program.cc file.
Why:
* It means there's only a single definition of all the methods that need
to be maintained, instead of pointlessly splitting code between two
files (.cc / .h).
* It removes all the implementation details from the header.
* It removes a whole bunch of transitive includes, slowing compiles.
* It prevents the temptation for future #includes to
private-implementation details.
* It reduces the amount of symbols declared outside of anonymous
namespaces, reducing symbol polution and the amount of work on the
linker.
Bug: tint:1718
Change-Id: I82838089f784ab003dae4ef06545bba1ca2401cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132321
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Notes:
- Separates ChainedStruct to be reusable without cpp header. (Also
updates native structs to directly use it.)
- Manually implements the descriptor in DawnNative.
- Reworks ChainUtils with mapping from struct to STypes.
- Updates the tests to use either SetPlatformForTesting which is still
required because DawnTest uses a "global" instance for all tests and
some tests require setting (and cleaning up) a test specific platform.
Bug: dawn:1374
Change-Id: I078c78f22c5137030cf3cf0e8358fe4373ee9c6c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132268
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Add custom C++ serializer for methods that need to be handwritten
Bug: chromium:1374747
Change-Id: I438db05b6fd6d1a1542d847c4b40f22b9143b0d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114721
Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
RTV and UAV in d3d11 pixel shaders share the same resource slots. To
avoid any potential conflicts, this assigns UAV slots reversely.
Bug: dawn:1807
Bug: dawn:1705
Change-Id: Ie0ca20aa0e532736c0534c6810b8a807dde6f972
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132274
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
For the `if`, `switch` and `function` flow nodes this Cl makes a few
required fields part of the constructor. This cuts down boilerplate when
creating new nodes.
Bug: tint:1718
Change-Id: I739bcefc2ed36b0203b57974b50bb2b79f6e1684
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132980
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>