Commit Graph

8578 Commits

Author SHA1 Message Date
Colin Blundell a406959e50 Add transient attachments and initial Metal support
This CL does the following:

* Adds a "transient attachment" bit to texture usage. This bit
  specifies that the created texture will be used only during
  this render pass.
* Adds a TransientAttachments Feature that gates the usage of
  transient attachments.
* Adds support for transient attachments on Metal, where they're
  used to create textures as memoryless.
* Adds validation tests and an E2T test of the feature.

A followup CL will add support in Vulkan.

Bug: dawn:1695
Change-Id: I3c7322dd1e4bee113062aae2e0494d292ee8cbc3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129080
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-27 14:55:09 +00:00
Sunny Sachanandani c820dcc53e d3d12: Remove keyed mutex support
Keyed mutex support was deprecated and the only known client using it,
Chromium, has migrated to fences. Remove all related keyed mutex related
code and tests. The useFenceSynchronization field is still present in
the external image descriptor since it's set by Chromium (to true) -
it'll be removed once Chromium stops setting it.

Bug: dawn:1612
Change-Id: Iaec3c16b18bb8ddbde55a7f54eaf4b944d0f06c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129300
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-04-27 14:46:56 +00:00
Ben Clayton df218948ba Run clang-format
Change-Id: I9f93208a6670d9dc32a8900d03e0cfbc076adc41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-27 14:00:57 +00:00
dan sinclair f00679fd72 [ir] Make ir::Instruction a ir::Value.
This CL removes the `ir::Runtime` and inherits `ir::Instruction` from
`ir::Value`. This means that any `Value` can be an `Instruction`. The
instruction id is used for debugging purposes.

Bug: tint:1895
Change-Id: I2b79cd6721268712d78a47d383a30f82aa3aa07e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-27 14:00:06 +00:00
Takahiro 5e4aad952e Make maxBindingsPerBindGroup 1000
To follow the WebGPU spec update
https://github.com/gpuweb/gpuweb/pull/4050

Bug: dawn:1767
Change-Id: Iec5c60de7af5cb8b8e1baa7fc378a6551c6b5bd1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Takahiro <hogehoge@gachapin.jp>
2023-04-27 13:51:54 +00:00
dan sinclair 5e344a338f [ir] Split AST and SEM sources out of core ir.
This CL moves the need to pull in SEM and AST into a specific
`libtint_ir_builder_src` library. This will make it a GN error if we
accidentally try to use the SEM or AST inside the IR after the initial
construction.

This required move the `ToProgram`/`FromProgram` methods out of
`ir::Module` and into an `ir::Converter` class.

Bug: tint:1921
Change-Id: I2e6ae195f9a100030b43f35a2c5dad634433147f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129661
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-27 11:56:58 +00:00
Austin Eng 3a0a827ebe Revert "Disable SamplerTests on NVIDIA D3D11"
This reverts commit f8ef5e95ac.

Reason for revert: Not the cause of flakes.

Original change's description:
> Disable SamplerTests on NVIDIA D3D11
>
> Suspect to be causing flakes in D3D12 sampler tests
>
> Bug: dawn:1779
> Change-Id: I7a8518683142191e05c7befed078d69abdaf9b77
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129280
> Reviewed-by: Loko Kung <lokokung@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Austin Eng <enga@chromium.org>

Change-Id: I72630f21d861acd9e266a0ac0c80e917f4f440bb
Bug: dawn:1779
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129600
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-04-26 22:21:23 +00:00
James Price 9d3af6521b tint/ir: Add GN option for building the IR
This currently requires that we are not building with Chromium.

Bug: tint:1911
Change-Id: I6c37afe6c2b8250b30d244e8cc2274253b6ce8f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129560
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-04-26 22:05:42 +00:00
Brandon Jones 1040f0e087 Show encoder in command buffer/render bundle messages
Having labels like [CommandBuffer from CommandEncoder "B"] will
provide greater context when developers don't provide labels to
every tier of object.

Bug: dawn:1746
Change-Id: Ibf72f97e054ff943b33c210e457422466e46a013
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127120
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 21:19:29 +00:00
Ben Clayton 47dd30117d tint/resolver: Resolve builtin structs
Allow the resolver to understand builtin structures, like
__frexp_result_f16. This allows backend transforms to declare the types,
even if they're "untypable" by the user.

Bug: chromium:1430309
Change-Id: I392709118182a058f737ccf1b7b46fc6b0b7264d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129482
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-26 18:27:53 +00:00
Ben Clayton d3b09b90e3 tint/resolver: Add builtin_structs.h / .cc
Contains the builtin structure creation logic moved out from
intrinsic_table.cc.

Bug: chromium:1430309
Change-Id: I2207f9ae42c6d7343c2f2ffa81effde59e6023fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129481
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 18:25:03 +00:00
Loko Kung aae9f6bc5f Fully deprecates DawnTogglesDeviceDescriptor.
Change-Id: I81ac6e70e086e1f5839733d2dd35c283ed6eba68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128681
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2023-04-26 17:50:55 +00:00
James Price 72d1ea4ac2 tint/resolver: Remove duplicate nullptr check
Change-Id: If4226d5427c2be270701b7b8d29e9f2ba5aa5ed5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129500
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 17:35:51 +00:00
Le Hoang Quyen 759238b962 Suppress MultithreadTests.Device_Dropped*OnAnotherThread
These tests seem to cause flakiness in other sampling tests on NVIDIA.

Bug: dawn:1779
Change-Id: Ide341033a4f13d8294021752ad3d18850a7369d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129400
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 17:18:13 +00:00
dan sinclair 135ab2b39f [ir] Rename instr.
This Cl renames the `instr` variables to `inst`.

Bug: tint:1718
Change-Id: Icf3b8c2f612c8dfe4b469d90327fef90ad813a0d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129460
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-26 14:46:03 +00:00
Loko Kung abfa45baa4 Deprecates use of filter mode for mipmap filters.
Change-Id: I77044ee7f0ce1b066dd8c8a1ee1b34e07f5e9766
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128660
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 08:03:20 +00:00
David Neto 97d3554f99 dawn/node: fix binding for GPUBufferMapState
This fixes a linking problem.
The conversion function should be a member of the Convert class,
not a freestanding function.

Change-Id: Ifa351e4ba6fb0e95fed311a11e9dc56e13eb1a0b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129260
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-26 00:34:53 +00:00
Austin Eng f8ef5e95ac Disable SamplerTests on NVIDIA D3D11
Suspect to be causing flakes in D3D12 sampler tests

Bug: dawn:1779
Change-Id: I7a8518683142191e05c7befed078d69abdaf9b77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129280
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-04-26 00:21:14 +00:00
dan sinclair aa97bb5327 [ir] Add assignment statements
This CL adds Assignment and CompoundAssignment statements to the IR
builder.

Bug: tint:1718
Change-Id: I3037da0115c7f4fe68941565b7e48866d421bbbf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129201
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-26 00:15:31 +00:00
dan sinclair 5b541ff3c2 [ir] Mark const variable as skipped.
The const variables should all have been const-eval'd and turned into
`constants` at the usage sites. This CL updates the IR to skip constants
when emitting.

A TODO is added to validate they aren't used when identifier expressions
are supported.

Bug: tint:1718
Change-Id: I77328a0cbd3d7f6692d1d1057d6953fcf762cfd7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-26 00:10:40 +00:00
dan sinclair 5aa7ef2bc0 [ir] Add Unary expressions
This CL adds support for UnaryOpExpressions and converts them into Unary
instructions in the IR.

Bug: tint:1718

Change-Id: I736e29cec5e722b7c7f1b0f4f22ce55a3d3e4109
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129221
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-26 00:08:35 +00:00
Loko Kung d2aaf76eb9 Removes maxFragmentCombinedOutputResources limit and tests.
Bug: dawn:1756
Change-Id: I1fe73eb7987cdffdb2653e1072c4946b5bc3ef4c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127660
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-04-25 22:46:23 +00:00
dan sinclair 339719967e [ir] Remove internal `bool` returns.
This CL updates the IR builder implementation to remove the `bool`
return values and use the diagnostics as the source of truth for if the
conversion works.

This requires disabling a couple tests as they depend on identifiers
which aren't implemented. Previously the `worked` because it would just
return an ID value that would be emitted, but now they end up being an
error.

Bug: tint:1718
Change-Id: I00bc8845393cf4fae7b3eb0f5cfffb8c5fc1dec0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129220
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-25 22:02:22 +00:00
Austin Eng d0d6fc911c Return a pointer to a global static for zero-length GetMappedRange
Bug: chromium:1430985
Change-Id: Iaca7a21487a5a7e2b41dd9a363a7efd913a0f208
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Brendon Tiszka <tiszka@google.com>
2023-04-25 21:33:22 +00:00
dan sinclair 69108d048b [ir] Add ir::Discard
This CL adds support for discard into the IR. The `discard` statement is
handled as an instruction in the current block. The `discard` is a
`demote_to_helper` in WGSL so control flow has to continue after the
discard, it just predicates writes. So, an instruction seems like the
most logical way to express.

Bug: tint:1718
Change-Id: I0d2fb029631523d72a7811d0be0715732427c302
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129200
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-25 20:44:18 +00:00
Peng Huang 65786ac998 d3d11: unmmap staging buffer before copy from it
D3D11 requires that buffers are unmapped before being used in a copy.

Bug: dawn:1772
Change-Id: I58c6d587538836a6aa70abecd8a764fc50c1e9ec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128740
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-25 19:33:04 +00:00
James Price ae39e6d628 spirv-reader: Declare multiuse constant composites
When an OpConstantComposite result is used by multiple instructions,
declare it as a module-scope `const` instead of inlining the constant
at each use site. This fixes an issue whereby the spirv-reader was
massively inflating the size of the WGSL it produces, which was caught
via an OOM fuzzer bug.

Bug: oss-fuzz:57795
Change-Id: Iac8c6a2147a7e2ebfddbaacae9fcb1dbe0b59e9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128881
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2023-04-25 19:16:25 +00:00
James Price a41693babb tint/msl: Avoid cloning a built-in struct
This prevents us from crashing when a module-scope private variable
has an inferred type that is a built-in struct. We instead fail to
resolve the generated code.

Bug: chromium:1430309
Change-Id: I71c6eacf28096380227ed1043821ecc3d33ffb40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129140
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-04-25 18:15:40 +00:00
James Price 99a0ded622 tint: Use type::Struct::Name in CreateASTTypeFor
The declaration may be nullptr, so doing this avoids a potential
nullptr deref when the struct is an internal type (e.g. frexp
result). In these cases we will now fail to resolve the resulting
code, which is a little better than just crashing.

A future change will update the resolver to allow us to use the
internal struct names from our transforms.

Bug: chromium:1430309
Change-Id: Ic72b5105bf3159c448c20dd9228d73b25a632b69
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129120
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-25 18:10:19 +00:00
Austin Eng 2dc9fe842d Return static pointer address for zero-length GetMappedRange
Bug: chromium:1430985
Change-Id: I0d13fce695bd999dd9e6a8127b91cea15276df22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128960
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-04-25 16:46:40 +00:00
Le Hoang Quyen 648db6cfb2 Add "MSAA resolve to mip lvl 1" multithread test.
Bug: dawn:1662
Bug: dawn:462
Change-Id: I13743fcd6f66c515c43b380b00b9235a24fa5a65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127080
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-04-25 16:19:30 +00:00
dan sinclair 03f9f5f538 [ir] Rename ir::Temp
This CL renames ir::Temp to ir::Runtime to better reflect that this is a
runtime generated ID.

Bug: tint:1718
Change-Id: I24edbe0e2e19303f50355117ec7cd4b5b8f45aef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129100
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-25 15:07:26 +00:00
Ben Clayton 41428ad681 dawn/node: Updates for latest IDL
Change-Id: I5028187160fabe8217a39ffc0d20a6fbb59d3cc8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129001
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-25 14:45:38 +00:00
Peng Huang 96b09d29b2 d3d11: enable ColorStateTests and CommandEncoderTests
Bug: dawn:1705
Change-Id: I2d477ea3d9a42332f21c61c9b2b1d2ac48d8e631
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128760
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-25 10:58:29 +00:00
Yan,Shaobo 90d5154b5f Fix Cmake build on Android
Update CMakeList.txt for Dawn cmake build on Android platform

Bug: dawn:1765
Change-Id: I559dddcf378ccaa0868bfccac904b627e3ea22c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Albin Bernhardsson <albin.bernhardsson@arm.com>
2023-04-25 10:12:48 +00:00
Corentin Wallez 154bb3460c Use a reasonable workgroup size for ComputeBoids.
Bug: None
Change-Id: I7fb1d37173fe234e5bcdc33645d0cbc7b7ca3021
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-04-25 10:05:18 +00:00
Le Hoang Quyen 20e3e34ce7 Disable some whitebox tests if implicit device sync is enabled.
Whitebox tests call internal functions directly. However, when
implicit device synchronization feature is turned on, some of these
functions will expect that the device is already locked. Thus leading
to assertion failures.

So we need to disable the tests when this feature is turned on.

Bug: dawn:1662
Change-Id: I1d65b4779c933313b5835f1bddbc57703b3ced53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-25 09:08:34 +00:00
Peng Huang c1b3c74316 d3d11: use Texture::Copy for copy data to staging texture used in CopyTextureToBuffer
Bug: dawn:1768
Change-Id: I7f6488cf54764585eef61766c3d2a829ef186783
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128580
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-25 03:08:31 +00:00
Le Hoang Quyen 23f4396177 Add more multithread tests.
Bug: dawn:1662
Change-Id: I2b2c66c6f9a7b512ae9f8010a082e7306feaa6f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122060
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-24 20:12:00 +00:00
Peng Huang 653e99478e d3d11: enable some d3d11 end2end tests
Bug: dawn:1705
Change-Id: Id990739ec3905f146aeff2086b4c019b21798fdf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-24 19:48:47 +00:00
James Price d36740509f spirv-reader: Error on multiple Position built-ins
Produce a meaningful error instead of just crashing.

Bug: oss-fuzz:55170
Change-Id: I09d94a910835839ce9407849446cf2928231a114
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128540
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2023-04-24 19:48:23 +00:00
dan sinclair bdc2d24900 Fix MSL invariant translation.
When `invariant` is enabled on MSL was was incorrectly setting
`@invariant` instead of `[[invariant]]`. We test with metal1.2 which
does not have invariant, so this only showed up when using metal2.1 or
higher.

Bug: chromium:1439273
Change-Id: Iab866608195e697b0370d465f350b25277d904a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128880
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-24 19:41:41 +00:00
Le Hoang Quyen c5c2fce3ed Lock ApiObjectBase::APIRealease()
Normal behavior of ApiObjectBase's APIRelease() which only locks the
device when last ref dropped is not thread safe if the object is cached
as raw pointers by the device. Example of cached objects: bind group
layout, pipeline, sampler, shader module.

The following scenario could happen:
 - thread A:
    - shaderModuleA.APIRealease()
    - shaderModuleA.refCount.Decrement() == true (ref count has reached zero)
    - going to call shaderModuleA.LockAndDeleteThis().
 - thread B:
    - device.CreateShaderModule().
    - lock()
    - device.GetOrCreateShaderModule()
    - shaderModuleA is in the cache, so return it.
    - unlock()
 - thread A:
    - starting to call shaderModuleA.LockAndDeleteThis()
    - lock()
    - erase shaderModuleA from the cache.
    - delete shaderModuleA.
    - unlock()

This CL fixes this bug by locking the entire APIRelease() method until
we find a better solution.

Bug: dawn:1769
Change-Id: I1161af66fc24f3a7bafee22b9614b783e0dc4503
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128441
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-24 17:33:37 +00:00
Peng Huang 0c33c143dc d3d11: implement copy between non-mappable buffer and texture
Also enable TextureFormatTest

Bug: dawn:1768
Change-Id: I7bf54e05cd8510c28ea57304d084b93386d6c502
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128340
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-24 16:21:47 +00:00
dan sinclair 378a1f51a2 Use optional in Lexer.
This Cl updates the lexer to only create tokens when needed, in the case
of no match an empty optional is returned.

Change-Id: Ie4ba45d72cfb263beb8d9c83e3098ff11beeecd2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128620
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-24 16:20:43 +00:00
dan sinclair 889edb18b2 Add simple program for perf testing.
This CL adds a simple program which can be set to loop over specific
parts of the tint pipeline to generate profiling data.

Change-Id: I6375940619b7ef2f7e66540d4f740e6e0b9b3132
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128541
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-24 16:17:56 +00:00
Peng Huang 11822d9c63 d3d11: enable MemoryAllocationStressTests end2end test
Change-Id: I295ee3aa32e7b7edd4f7edbf64fd1da5fdf33977
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128861
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-24 15:59:50 +00:00
Ben Clayton d14a9fbb6e tint/resolver: Fix null deref
When attempting to member-access a non-value expression.

GetVal() ensures the expression resolves to a value expression, and errors accordingly.

Bug: chromium:1436467
Change-Id: I77ebb44f836be3b99db4b5c26ff41db2ee3fe30a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128840
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-24 13:49:00 +00:00
jchen10 2fd411f7fe d3d11: Fix the failing BufferMapping cases.
This adds buffer usage tracking and corrects the usage of pending
command context.

Bug: dawn:1705
Change-Id: If327169429d4e0909bbcaa87a14bac9ef01ac2ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128180
Reviewed-by: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-04-22 02:33:45 +00:00
dan sinclair 9b726858ff Fast path ASCII in unicode decode.
In the case of ASCII characters, which a lot of WGSL source is, the
decoder can early out after a checking the value.

Change-Id: Iff655565dde23b143fddb95c6c353a917e25e916
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128120
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-22 01:04:40 +00:00
Loko Kung 89c89b7640 Removes deprecation period code for renamed APIs (i.e. endPass/dispatch)
- Note that by default these are already errors, not warnings.

Change-Id: If35284041963cd387839fe102efe4dca73e594dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128064
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-04-22 00:33:51 +00:00
Stephan Hartmann ca1b904456 IWYU: add stdint.h for int types in tint::utils
Bug: chromium:957519
Change-Id: I867cdff638388c3f2a35f58b67763413a4e50df2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128520
Auto-Submit: Stephan Hartmann <stha09@googlemail.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 22:32:17 +00:00
Ben Clayton de42feb949 tint: Add vec2(), vec3(), vec4()
Fixed: tint:1892
Change-Id: I3e823dd84cb7feb58b16c7763b520f149714576e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128380
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-04-21 12:19:49 +00:00
dan sinclair 5a5b7dfe92 Add builtin information to Symbol.
This CL extends the Symbol class to store if the content of the symbol could parse as a builtin.

Change-Id: I7e14ad944c1c9c43d900f9ccf8be6539ac9ea667
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127460
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-21 11:54:23 +00:00
Peng Huang cc7028ba3f d3d11: suppress BufferMappedAtCreationTests.NonMappable*
BufferBase uses a staging buffer to upload data for non-mappable
buffer created with mappedAtCreation. However BufferBase doesn't
unmap staging buffer before copy data from it.  But d3d11 debug
layer complain this illegal usage. It causes test failures.

Bug: dawn:1772
Change-Id: Id1c386ac7c45f41487f9cc7ef4e431eab87ba1c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128480
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-21 11:15:39 +00:00
dan sinclair d1d1bf7135 Split base_src apart.
This CL splits the base_src set in the GN build into a symbols_src and a
utils_src.

Change-Id: I39036a4ba5163aa816233b42d9a2ebfe34ddf038
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128361
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 10:54:13 +00:00
Loko Kung 2f845021d8 Removes/unifies deprecation period code for depthStencilReadOnly ops.
- Note that by default these are already errors, not warnings.

Change-Id: Iab9ecf3cfd54c0219777c2d1587a7752c3173595
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128102
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 10:44:13 +00:00
Loko Kung c421a4b0ce Removes deprecation period code for maxBufferSize.
- Note that by default these are already errors, not warnings.

Change-Id: I46afa6e54e7915ba54aa6990cd641288609108c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128101
Reviewed-by: Shrek Shao <shrekshao@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-04-21 08:40:54 +00:00
Loko Kung 003e879fd9 Removes deprecation period code for multisampled float sample type.
- Note that by default these are already errors, not warnings.

Change-Id: I4eadbb6f71b2d2a39efe5755dbb6b8c329f1674f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128063
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
2023-04-21 05:57:20 +00:00
Loko Kung f9719b7588 Removes deprecation period code for maxColorAttachmentBytesPerSample.
- Note that by default these are already errors, not warnings.

Change-Id: I33202a0cca8167c4c79e4aeee680b6b7cf1ff830
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128062
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 04:43:13 +00:00
Quyen Le 87f51237b4 Revert "Disable frontend cache when implicit device sync is on."
This reverts commit 8cc6205bf7.

Reason for revert: Graphite actually reuses the bind groups between
draw calls using different pipelines and this change prevents it
from happening.

Original change's description:
> Disable frontend cache when implicit device sync is on.
>
> Normal behavior of ApiObjectBase's APIRelease() which only locks the
> device when last ref dropped is not thread safe if the object is cached
> as raw pointers by the device. Example of cached objects: bind group
> layout, pipeline, sampler, shader module.
>
> The following scenario could happen:
>  - thread A:
>     - shaderModuleA.APIRealease()
>     - shaderModuleA.refCount.Decrement() == true (ref count has reached zero)
>     - going to call shaderModuleA.LockAndDeleteThis().
>  - thread B:
>     - device.CreateShaderModule().
>     - lock()
>     - device.GetOrCreateShaderModule()
>     - shaderModuleA is in the cache, so return it.
>     - unlock()
>  - thread A:
>     - starting to call shaderModuleA.LockAndDeleteThis()
>     - lock()
>     - erase shaderModuleA from the cache.
>     - delete shaderModuleA.
>     - unlock()
>
> This CL disables caching when ImplicitDeviceSynchronization is turned on
> until we find a better solution.
>
> Bug: dawn:1769
> Change-Id: Ideb2a717ece0a40e18bd1c2bef00817262bd25da
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127900
> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>

TBR=cwallez@chromium.org,enga@chromium.org,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com,lehoangquyen@chromium.org

Change-Id: Ib13bba8005402d06963865fae919388a91e718f0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1769
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128440
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-21 03:10:12 +00:00
Jiawei Shao cd4b42b5a2 dawn/node: Implement Adapter.GetAdapterInfo()
Bug: dawn:1761
Change-Id: Ia1bf7841052897b69de50d6db41b05ee5645be47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128104
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 01:49:38 +00:00
Jiawei Shao 2d1136281e Add missing default return values to slience Wreturn-type
This patch adds two missing default return values to slience the
compilation warning "Wreturn-type" when building dawn.node.

Bug: dawn:1761
Change-Id: I87c8566cabba4c2e14174bf9f38f53ed3c0fdb74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128103
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-21 00:29:43 +00:00
Peng Huang cf5aa73f81 d3d11: remove a noreached `break`
Bug: dawn:1795
Change-Id: I32e1407a5d9054ac81d672202b0597334aa7721e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-20 23:52:56 +00:00
Ben Clayton 7883a0cb8d tint: Add two-token form for diagnostics rule names.
Fixed: tint:1891
Change-Id: Ia3737c29b111d7b6e6b00fbd68da7f85a5a49bca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128301
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-20 23:51:53 +00:00
Brandon Jones 6cb055b6aa Retain descriptor labels for error objects
Since these objects are more likely to be included in error messages
it's important that we keep the labels that the developer has given
them.

Bug: dawn:1771
Change-Id: I78f4ccc23ce40d8eeceed8ca7dd563dff949b4fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128420
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2023-04-20 23:35:14 +00:00
Le Hoang Quyen 8cc6205bf7 Disable frontend cache when implicit device sync is on.
Normal behavior of ApiObjectBase's APIRelease() which only locks the
device when last ref dropped is not thread safe if the object is cached
as raw pointers by the device. Example of cached objects: bind group
layout, pipeline, sampler, shader module.

The following scenario could happen:
 - thread A:
    - shaderModuleA.APIRealease()
    - shaderModuleA.refCount.Decrement() == true (ref count has reached zero)
    - going to call shaderModuleA.LockAndDeleteThis().
 - thread B:
    - device.CreateShaderModule().
    - lock()
    - device.GetOrCreateShaderModule()
    - shaderModuleA is in the cache, so return it.
    - unlock()
 - thread A:
    - starting to call shaderModuleA.LockAndDeleteThis()
    - lock()
    - erase shaderModuleA from the cache.
    - delete shaderModuleA.
    - unlock()

This CL disables caching when ImplicitDeviceSynchronization is turned on
until we find a better solution.

Bug: dawn:1769
Change-Id: Ideb2a717ece0a40e18bd1c2bef00817262bd25da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127900
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-20 21:12:25 +00:00
Le Hoang Quyen 335573116c Add Device::GetSupportedSurfaceUsage() method.
This method will return supported usage flags that can be used to create
a swap chain.

Bug: dawn:1760
Change-Id: I7699c2c4ef7142c6bd06e72239d6e4f9112f15a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127440
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-20 20:42:05 +00:00
Ben Clayton 7eb37948ab tint/reader/wgsl: Have expect_identifier return an ast::Identifier
Instead of a std::string. This avoids unnecessary string allocations, and follows the pattern of all other AST nodes.

Change-Id: I3faf534090a2033d671b2ef463d8b9ed3e47eecd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128300
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-04-20 20:08:44 +00:00
Peng Huang 91a23a3ac3 d3d11: CommandBuffer: implement render pass
Bug: dawn:1705
Change-Id: I21c6a8550f098cb1e97d5f0c9a93da53600fa8a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127700
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
2023-04-20 18:07:20 +00:00
AlbinBernhardssonARM ce2cdb4b4d Fix Dawn Native Android build
Fixes 2 CMake issues:
1. GLFW subdirectory was added regardless of
   DAWN_SUPPORTS_GLFW_FOR_WINDOWING.
2. Android uses the AHardwareBuffer implementation of
   memory service. But in the CMake MemoryServiceOpaqueFD.cpp
   was added instead of MemoryServiceAHardwareBuffer.cpp .

Bug: dawn:286
Change-Id: I6d81976a5c12717b3e565c4d9f8d5ae54f4e0446
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-20 17:58:59 +00:00
Peng Huang bd696e91d2 d3d11: fix several OOM end2end test on trybot
BufferTests.CreateBufferOOM/D3D11_Intel_R_UHD_Graphics_630 fails on
trybots due to buffer size overflow UINT which is used as size for
create ID3D11Buffer.

This CL fixes above issue and also uses CheckOutOfMemoryHRESULT()
to handle hresult from texture and buffer creation. It makes OOM
an allowed error.

Bug: dawn:1705
Change-Id: I2c4a4841cac15934fe83b7f7d6e568e9f3c8d210
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128280
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-20 17:27:17 +00:00
dan sinclair 45ff7a8c4a Remove extra work from `is_reserved`
Currently the `is_reserved` method in the WGSL parser uses the
`operator==` on the token to check the reserved words. This ends up
re-doing a bunch of work as it checks the token type, then gets the
`string_view` or `string` from the variant, then compares.

This CL adds a precondition that the token is an identifier (which is
true in the only case we call this method) and then extracts the string
from the token once and uses that for all the comparisons.

Change-Id: If425afea38e727169de7991a84f6fa1e47f660ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128140
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-20 16:50:29 +00:00
Peng Huang 03d68fa33f d3d11: CommandBuffer: implement compute pass
Bug: dawn:1705
Change-Id: I0d935a9ce42b08e436d68f1400ee9faf1ab00cc3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127560
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-20 15:27:01 +00:00
dan sinclair 517278ac08 Move text/unicode into utils.
This CL consolidates the unicode code into utils. These are utility
libraries, so the extra namespace doesn't add much.

Change-Id: Id0de612b6be036392a3cb018bfe66733f2f1ebcb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127403
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-20 10:06:25 +00:00
Peng Huang 9e9c456075 d3d11: CommandBuffer: implement buffer and texture related cmd
This CL also enables several buffer end2end tests

Bug: dawn:1705
Change-Id: I16c23346a60f3f15dbfbb96b2cb8dc0f5ba8c89c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127405
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-20 03:24:55 +00:00
dan sinclair 12fa303899 Move castable into utils.
The Castable class is used by utils/. This Cl moves the implementation
into the utils/ folder. The `Is` and `As` methods are added into the
`tint` namespace to make usage shorter.

Change-Id: I0decedb92ebed01b6aa12d2e3efa7190742e9a33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127402
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-19 23:52:33 +00:00
Shrek Shao a965f520f9 Add alphaToCoverage validation aligning with WebGPU V1
Add alphaToCoverage validation regards to targets[0] has alpha channel.

This change reflecting WebGPU V1 spec update is aimed to ship together
with WebGPU in Chromium.

Bug: dawn:1759
Change-Id: I0aef60cf8c4dc828e05d6027644ffed35b33f652
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128061
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-04-19 23:42:36 +00:00
Peng Huang ff75ab9a87 d3d11: set object labels
Change-Id: I26b7accf973b03cef7ba113b0ee3672b99e41338
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126861
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-19 23:26:15 +00:00
dan sinclair e6e5998e2b Cleanup GLSL writer.
This Cl removes the boolean return values from most of the GLSL
writer methods. The diagnostics are used to determine if the generation
was successful. The writer itself just continues until complete.

Change-Id: Ia64968eaa6a0aa39a9713fa78f3e743f2de38b44
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127020
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-19 20:32:13 +00:00
dan sinclair c480632ed6 Setup ArrayLength transform for MSL benchmark
Some of the benchmark shaders when run with the MSL backend are
currently failing because the robustness transform is injecting the
arrayLength method but there is no configuration for running the
arrayLength transform.

This Cl adds some default configuration to the MSL bench to make a slot
available for each possible value. It just always makes them available
such that all shaders work correctly.

Change-Id: Ie8a15abc0b7da7d2f46be11274e66302406be019
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128060
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-19 20:14:50 +00:00
dan sinclair e16ed7ccc2 Make more SymbolTable methods string_view.
This CL updates more of the SymbolTable to use string views.

Change-Id: I0d9c7817ba4e3b0d0e73cfc02406481eb796c3c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127320
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-19 16:58:12 +00:00
dan sinclair 0559005494 Move traits into utils.
This CL moves the tint/traits file into tint/utils/traits. Traits is one
of the few items not in utils which is referred to by utils.

Change-Id: Ie955398f24e949b7618fdc868dbcb903fe20b3f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127400
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-19 16:52:46 +00:00
Peng Huang b7285f3c9e d3d11: implement Buffer
Bug: dawn:1705
Change-Id: I4542cc2e0f4f6a7f0d13c5f071bfb25897350008
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126440
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-19 15:52:32 +00:00
dan sinclair d21e2d64ec Convert VariableUser vector over to utils::Vector.
This vector was causing a lot of small allocations to happen, this CL
converts over to a utils::Vector to take advantage of the better
allocation strategy

Change-Id: Id740bd2a50a8d0bdd84f4b6e7c7ad4607436c7f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-19 15:06:24 +00:00
Ben Clayton 8fc9b86214 CMake: Add TINT_EXTERNAL_BENCHMARK_CORPUS_DIR
If specified, CMake will glob all the .wgsl files in this directory, and add these to the list of benchmarks to run.

Change-Id: I75b2754a6561dcd931c42bd47649c4f625e1c581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127980
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-04-19 15:03:19 +00:00
Ben Clayton 5f4847c23e tint/sem: Make BindingPoint optional
Reduces hops from sem -> ast, just to know whether the variable has a binding point.

Change-Id: I5620198e6f08b73d5a0171d95874f1a2dae5d93e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127060
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-04-19 13:24:27 +00:00
Loko Kung c47e05ae50 Rolls third_party/gpuweb to 2e75d5e
- Needed to remove maxFragmentCombinedOutputResources limit.

Bug: dawn:1756
Change-Id: Ia7c87d845a79fafee45ab7d1e2b7798e3157945f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127940
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-19 09:08:42 +00:00
Jiawei Shao f4b9f95b68 dawn/node: Implement GPUBuffer.getMapState()
Bug: dawn:1761
Change-Id: Id01789a2df8afd5726f6fc776e7d825153fd0f85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127722
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2023-04-19 01:47:52 +00:00
Ben Clayton 692846d0a0 tint/resolver: Fix use after move
Bug: chromium:1434271
Change-Id: Ib70f9468c60fe00ca7bf9346b6ee8a71a819b59d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127681
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-04-18 21:15:44 +00:00
Antonio Maiorano bacf44f964 Workaround dawn_wire_server_and_frontend_fuzzer ASAN false positive
When discovering Vulkan adapters, if none is found, the vulkan loader
DLL is loaded and then unloaded, which results in ASAN false positives
when the loader's previously allocated memory is re-used, which happens
in fuzzer::TracePC::ClearInlineCounters.

Bug: chromium:1427723
Bug: chromium:1038952
Change-Id: Idb205607426a0af22daba363e2679afaa33204b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127840
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-04-18 20:10:51 +00:00
dan sinclair d026e13f48 Remove `SymbolTable::NameFor`
This CL removes the `NameFor` method from SymbolTable and accesses the
symbols name directly.

Change-Id: Ic4ad6eecfa78efb946d97aeaecf2d784af2e6f16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127301
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-18 19:38:25 +00:00
dan sinclair b353ebe752 Add an allocator to store the symbol names.
This CL adds an allocator, owned by the SymbolTable, which stores the
names of all the symbols in the table. The Symbols then have a
`string_view` to their name.

Change-Id: I28e5b2aefcf9f67c1877b7ebab52416f780bd8c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127300
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-18 19:31:21 +00:00
dan sinclair fa3c08d112 Add a bump allocator.
This CL adds a simple allocator which will provide a chunk of memory of
the given size. It allocates out of slabs of memory.

Change-Id: I9acf59fac88cd6bef260b7ebae7d7b77fd939754
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127302
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-18 16:15:44 +00:00
shrekshao 8f0607a8c8 Fix D3D12 shader interstage truncating transform
Don't skip the TruncateInterstageVariables transform when
user defined interstage attribute input for fragment stage
is empty. Because builtin inputs could also cause register
mismatch for D3D12 HLSL compiler.

Add a boolean flag to Tint hlsl generator option to indicate
whether to run TruncateInterstageVariables or not.
This defaults to false in Tint, while Dawn always set
this to true for vertex stage.

Bug: dawn:1733
Change-Id: Ie4c3648b226513bf15f0e03ae4ce7f3cc09fdef4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127206
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2023-04-18 01:34:41 +00:00
Austin Eng 6a7bba54fa Add basic Dawn microbenchmarks using Google benchmark
The initial test tests bind group layout creation of
different sizes, cache / no-cache hit, with and without
multiple threads.

Change-Id: Ic9ed6c6f1c298d35cd1358c7ff492027c83649a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127346
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-17 18:11:51 +00:00
Ben Clayton 559e5a2cde tint/transform: Fix ICE in HLSL backend
When referencing a pointer parameter with a 'let', but not using that
let.

Also fix a bunch of places where we used the old names for the pointer
transforms.

Bug: chromium:1433499

Change-Id: I8decefeacd6150bd6f7637f80e62b9cb62936235
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127540
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-04-17 14:24:58 +00:00
Le Hoang Quyen 7532f6665e Disable OOM tests when TSAN is enabled.
Bug: dawn:1725
Change-Id: I83ddaaf0d98d2831f95abbfbf5adfad268ebdba5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-14 22:38:28 +00:00
Peng Huang f5966b09e1 d3d11: enable d3d11 if dawn is not build with chromium
This CL enable build d3d11 by default, if dawn is not build with
chromium. d3d11 backend is not full implemented yet, so no tests
will run against d3d11 backend.

Bug: dawn:1705
Change-Id: Id689ab5168511af0f75f0b3537f246713de5ca45
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-14 02:05:17 +00:00
Peng Huang 34d52ffa4c Revert "d3d11: add d3d11 backend in end2end tests"
This reverts commit 3fcf96dd8c.

Reason for revert: want to enable end2end test piece by piece on bots for d3d11

Original change's description:
> d3d11: add d3d11 backend in end2end tests
>
> Right now, many tests are not passed becasue unimplemented
> features in d3d11 backend. HoweverD3D11 backend is disabled on
> bots by default, so this CL will not break out bots.
>
> Bug: dawn:1705
> Change-Id: I57321b86a404bc245b71c467479fdee0464dee9b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126260
> Commit-Queue: Peng Huang <penghuang@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>

Bug: dawn:1705
Change-Id: I95a1cc9a0962b01a6b31ea32b6129f109f4b3e42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-13 22:45:28 +00:00
dan sinclair c4cc6ec038 Remove the demangler.
The demangler is no longer used by the Tint executable, and nothing else
calls it, so delete it.

Change-Id: Ic47238e4a6126e5daacd81dfc6f5986524b648ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127280
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-13 21:17:12 +00:00
Brian Sheedy c0398e4174 Skip logging on Win official builds
Skips logging in sandboxed processes on Windows
official builds since the file handles will not
be set properly, causing crashes when we try to
write to stdout/stderr.

Bug: chromium:1429665
Change-Id: Ie70d0cc2e096bd22490dc3538467752b448f213b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127205
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@google.com>
2023-04-13 20:41:23 +00:00
Le Hoang Quyen c405dddf5e Add missing locks to indirect draw validation & timestamp query.
Also added new multithreaded tests to verify them.

Bug: dawn:1662
Change-Id: I58ebe265edf58e0c4eb5d9337d3441a6bb972ed4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126781
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-13 15:59:15 +00:00
Peng Huang b08d87c06e d3d11: implement SwapChain
This CL also abstracts common code from d3d12::SwapChain to
d3d::SwapChain base class for sharing.

Bug: dawn:1705
Change-Id: I7b6ac8770b3c517fe552061de3c5589174ba5814
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126665
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-13 15:36:52 +00:00
dan sinclair 2200823afd Allow building SPIRV_WRITER without READER
Currently the SPIR-V headers are only included when building the
SPIRV_READER. This means the build breaks if the SPIRV_WRITER is enabled
but not the reader.

This CL fixes the conditionals to include the SPIR-V header for both the
reader and the writer.

Change-Id: I8690e3e42dbe3071dcaa3ed467d6eac8f62a7bbc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127160
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-13 12:59:33 +00:00
Le Hoang Quyen a4866d0d97 D3D12's external image: Add multithread support.
Bug: dawn:1662
Change-Id: Id2d720af4e5e654b5f34aebf485bededc6d247ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122740
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-13 08:44:34 +00:00
dan sinclair 541138b11b Cleanup SyntaxTree writer.
This Cl removes the boolean return values from most of the SyntaxTree
writer methods. The diagnostics are used to determine if the generation
was successful. The writer itself just continues until complete.

Change-Id: I87d85e2cbe061306a4598a498ccad4510f62e8c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124681
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-13 04:18:55 +00:00
dan sinclair 27c7722620 Cleanup WGSL writer.
This Cl removes the boolean return values from most of the WGSL writer
methods. The diagnostics are used to determine if the generation was
successful. The writer itself just continues until complete.

Change-Id: Iff33128c1df286cab799f08dab8c3defc5651d76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124680
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-13 02:57:27 +00:00
Le Hoang Quyen 3e7a114a6e Add missing lock to APIBeginRender/ComputePass.
Add tests to verify multithreading behaviors of encoding render/compute
passes.

Bug: dawn:1662
Change-Id: I9bc6a0dd5d94b53b59e7e49a4611d4d55cc36e60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126980
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-12 21:07:31 +00:00
Peng Huang 3dba94c1d4 d3d11: implement RenderPipeline
Bug: dawn:1705
Change-Id: If6de0d18c4da530ba63637aa095ae2f4a957c2f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126663
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-04-12 19:05:00 +00:00
dan sinclair 0b3fc055d3 Update samples to process events.
This CL updates the `dawn/sample` programs to call the
`dawn::native::InstanceProcessEvents` which allows things like shader
validation errors to be emitted.

Without this change the errors are never displayed.

Change-Id: I054bb4f7177c5d0c110e97409852143b2bef1e02
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-12 13:19:35 +00:00
dan sinclair 8a435a2a4b Remove `error` from TextGenerator.
This CL removes the `error()` method from the TextGenerator in favour of
using `Diagnostics().str()`.

Change-Id: If20261ac839d11f6d29890cb17f95f2d4df5db2d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126923
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-12 11:59:24 +00:00
dan sinclair 585f395e66 Simplify MultiplanarExternalTexture::ShouldRun.
Currently the multiplanar `ShouldRun` function is scanning all objects
looking for an external texture. This CL switches to using the type
manager and attempts to find an `ExternalTexture` type in the system. If
found, then the transform should run.

Change-Id: I28b8fa1835a83f2bff5d804e95bcbaa73d3d2124
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126922
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-04-12 00:44:20 +00:00
Peng Huang c3cc75067e d3d11: implement ComputePipeline
Bug: dawn:1705
Change-Id: I915000a747cc913ed52a423940d20e169b829315
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126664
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-12 00:02:30 +00:00
dan sinclair 04d61c85cd Always run Multiplanar transform.
Currently the multiplanar transform is only run if a global variable is
seen with a `texture_external`. There are cases where a function with a
`texture_external` can exist (the fuzzers do this, the tint command line
can do this as well). These will fail when hitting the backend.

This CL makes the running of multiplanar unconditional. This causes the
logic to process the function parameters to run and the external texture
is removed.

Bug: chromium:1431610
Change-Id: I1793142e803e864c744b38cf843931521e6a449f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126921
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-11 23:02:45 +00:00
dan sinclair d146c8a7a2 Enable multiplanar for SPIRV fuzzers.
This CL updates the common fuzzer code to enable the multiplanar
extension for the SPIR-V backend.

Bug: chromium:1427801
Change-Id: Ie03d3e10f7831ca851aa11c00cbac0aa474ccabb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126920
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-04-11 23:02:38 +00:00
Peng Huang defda09e3c d3d11: implement Texture
Bug: dawn:1705
Change-Id: Iff5e301c04120a86ccf4eba33281233e4d972981
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126662
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-11 20:42:23 +00:00
Le Hoang Quyen dc626d357d Add missing lock when creating new pipeline during encoding.
This was unsafe when encoding indirect draws with validations on
multiple threads.

Bug: dawn:1662
Change-Id: I479bb35bc98dd314860955b3c30df788d18ed84e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-10 10:09:57 +00:00
Le Hoang Quyen 3dce55a6fe MetalBackend: Enable multithread support.
Bug: dawn:1662
Change-Id: If2f74b4bbce9d108fcd5906c2105f9ebd95845fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-10 09:33:43 +00:00
Corentin Wallez 087deedbc8 dawn.json: remove leftovers from implementation-based swapchains.
This also removes the need for special casing the swapchain creation
proc in the fuzzers because it is no longer possible to have a valid
CreateSwapChain call since the wire can't create a surface (which is no
longer optional).

Bug: dawn:269
Change-Id: Icc6ed5e82c1d5382628d71d212640d238cfba348
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126425
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-04-07 14:59:55 +00:00
Corentin Wallez a48ba981ea Remove dawn_wsi.h
Bug: dawn:269
Change-Id: Ie1fb1a8109ff646b880c3e27762300167776d050
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126424
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-07 13:33:26 +00:00
Corentin Wallez 1226684b09 Merge NewSwapChainBase in SwapChainBase
Bug: dawn:269
Change-Id: I514c210f88e2bf1f501e2d814f8ab931c5ed724f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126423
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-07 13:30:50 +00:00
Peng Huang 6635b965b9 d3d11: implement ShaderModule
Bug: dawn:1705
Change-Id: I621a561e1b61762bb8347a74b24cb18a7c808ba3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126303
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-06 22:37:26 +00:00
Peng Huang 86e6a13649 d3d11: add BindGroup, BindGroupLayout and PipelineLayout
Bug: dawn:1705
Change-Id: I9bc7545328409c7ce8fd8adc26a35b872cda1420
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126302
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-06 19:59:05 +00:00
Peng Huang 4faf3d31ba d3d11: add Device, Queue, Sampler, etc
Bug: dawn:1705
Change-Id: I0cfc54a3be2c9dc4471d0b5b9cb7d6066519bcf1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126300
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-06 18:02:13 +00:00
Peng Huang ac77863352 d3d: supports more errors in HRESULTAsString()
Bug: dawn:1705
Change-Id: I811ed5867399fa417a0a542f3d4e706e989f0a23
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126660
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-06 17:12:04 +00:00
Le Hoang Quyen b7a3cbe8ca end2end tests: add --enable-implicit-device-sync option.
This option will allow tests to be run with
ImplicitiDeviceSynchronization feature.

Bug: dawn:1662
Change-Id: Ic001b2fa175f63e8d77eeb3b23d4d2cf52bb224e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-06 16:03:13 +00:00
Le Hoang Quyen c173a0ea88 Fix TRACE_EVENT wasn't thread safe.
TRACE_EVENT uses INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO and
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO reads and writes to a static
variable on multiple threads.

Fix by using std::atomic for the static variable.

Bug: dawn:1700
Change-Id: I914bb73352e400f0adeafb64518d61099276270d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123680
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-04-06 08:08:00 +00:00
Le Hoang Quyen 7971bfe16f Add an option to enable implicit device synchronization.
1. Auto-generate mutex locking code in DawnNative's ProcTable's
functions. Using a mutex owned by the related Device.
  - Unless the function/class has "no autolock" attribute (new) in
  dawn.json. In which cases, no locking code will be auto-generated.
  - Currently Instance, Adapter, Surface, Encoder classes and
  Reference/Release method have "no autolock".

2. Added Feature::ImplicitDeviceSynchronization to enable Device's
mutex.
  - If this feature is disabled, lock/unlock Device's mutex is no-op.
  Auto-generated locking code will have no effect. This is the default.
  - This approach is used instead of generating two sets of ProcTable
  because it's cleaner and the internal code doesn't need to care about
  whether there is a mutex being locked or not. Furthermore, if there
  were two sets of ProcTable, and user used dawnProcSetProcs() to set
  global ProcTable, it would affect all other modules using different
  Devices. Even though those modules don't need thread safety.

Bug: dawn:1662
Change-Id: I75f0d28959f333318e4159916b259131581f79f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119940
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-05 19:35:07 +00:00
Austin Eng 78c496395c Always flush device callbacks when the callbacks are changed
With the wire, callbacks reference device-related data which is
freed when the device is unregistered from the wire. However,
the device that the wire refers to can live longer than this
and have its callbacks invoked at a later time, leading to a
use-after-free. Always flush the callbacks so that when the
wire unregisters a device and clears its callbacks, they are
called immediately and no dangling pointers remain.

Bug: chromium:1430221
Change-Id: Ib753b58cee5e7cb4d90ebd703958a0ddd5873573
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126481
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-05 17:10:58 +00:00
Corentin Wallez 8a6ed63809 Remove OldSwapChain*
Bug: dawn:269
Change-Id: I5bc6f5f8b98a88c5d0bd69e0d2eaf1e4bbd12e2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126422
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-04-05 10:13:01 +00:00
Corentin Wallez 961f7eae70 Remove all NativeSwapChain*
These were helpers to avoid the need for users of implementation-based
swapchains to implement them themselves. They are no longer used and can
be removed.

Also removes SwapChainuUtils.h that's no longer used.

Bug: dawn:269
Change-Id: I3c563edaf107e9ce04f708e8bacae9d231b0f40d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-04-05 07:24:44 +00:00
Corentin Wallez 974802d17c Remove BackendBinding and its implementations.
These were helpers for implementation-based swapchains that are getting
removed.

Bug: dawn:269
Change-Id: I44b0f9a9d221b9370c3eb2625c68e540b6e2ef46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126420
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-04-05 07:23:09 +00:00
Yan,Shaobo 2c4847e59a Fix bug about requiring unexpected files when compiling on Android
In MemoryService implementation, Dawn uses DAWN_PLATFORM_IS() to choose
required header files for different OS platform.

On Android platform, both DAWN_PLATFORM_IS(LINUX) and DAWN_PLATFORM_IS(ANDROID) are true. This caused some linux platform header files and implementations has been included unexpected when compiling on Android platform.

This CL strict the macro condition to ensure Android platform include AHardwareBuffer related files only.

Bug:dawn:1593
Change-Id: If64567edf99cd25a3783d8c456a1fc3f6a7dccf2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126323
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2023-04-04 08:57:46 +00:00
Peng Huang 3fcf96dd8c d3d11: add d3d11 backend in end2end tests
Right now, many tests are not passed becasue unimplemented
features in d3d11 backend. HoweverD3D11 backend is disabled on
bots by default, so this CL will not break out bots.

Bug: dawn:1705
Change-Id: I57321b86a404bc245b71c467479fdee0464dee9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126260
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-04 00:27:36 +00:00
Peng Huang ebfd505d29 d3d11: implement Adaptor, Backend, etc
This CL also moves some comman code in d3d12::Adapter and
d3d11::Backend to d3d::Adapter and d3d::Backend, so it can be
shared with d3d11 backend.

Bug: dawn:1705
Change-Id: Ica3bf33232d3380b7d4799c77bf9b43a8374a66e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-04-03 21:33:54 +00:00
Stephan Hartmann a7423b3d83 IWYU: add cstdint for uint8_t dawn::native::stream::ByteVectorSink
Bug: chromium:957519
Change-Id: I48436db0e203d793e47d717bfb75977c67145e94
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126120
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephan Hartmann <stha09@googlemail.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-03 13:51:27 +00:00
Le Hoang Quyen 44afd7112f Fix APIGetInstance() didn't increase external ref.
InstanceBase has two seperate ref counts: external & internal.
When we return it to the external user, we need to increase external
ref count as well.

Bug: chromium:1429835
Change-Id: I4b585d04149180418bd620e6e4d86522e033b64e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126080
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-03 10:04:42 +00:00
Yan,Shaobo 07b88f3aef MemoryService Choose Implementation based on ExternalImageType
This CL add supports for MemoryService choosing implementation based on
ExternalImageType in runtime instead of choosing in compile time.

This CL also removes MemoryServiceNull.cpp.

Bug: dawn:1593
Change-Id: Iddec1f5cf03a7d962ef12b8fd6293ffbb7dc064d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-04-03 02:14:21 +00:00
Peng Huang c00ff7f3c7 [tint] do not emit space for binding group 0
D3D11 only supports HLSL SM5.0 which doesn't support `space`
(binding group in WGSL). So for D3D11, only one binding group will be
used, and tint will not emit `space` for HLSL, so shaders can be used
with D3D11.

Bug: dawn:1705
Change-Id: Ie0e9868137f10762c5243e188d76f5e41879c2bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125080
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
2023-03-31 17:55:19 +00:00
Peng Huang 70d8711973 [d3d] Move some texture format convert methods to d3d folder
Bug: dawn:1705
Change-Id: I08a348666785ab25110b179e37b6a2869313d998
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125241
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-31 17:24:31 +00:00
Peng Huang 3f76570d9a Print FPS for sample Animometer
Change-Id: I21ae60077638944258436c4cab14cc1d98e7f169
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125881
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-31 16:44:51 +00:00
Antonio Maiorano d8f0f44b54 dawn: enable IEEE strictness for compute pipeline to match render pipeline
This is the only flag we set for FXC compilation of render pipelines that we don't set for compute.

This fixes a (potentially unrelated) bug I've been looking into it (tint:1887

Bug: tint:1887
Change-Id: Iaf67ebe9221cd1d6e4e20afe0bcd3e5aa6e89366
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125820
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-31 12:24:10 +00:00
Antonio Maiorano 51249b83e6 tint/hlsl: don't use min16float to implement quantizeToF16
min16float is not required to convert its input to an 16-bit float.
Instead, use f32tof16, and f16tof32.

This is also required to be able to enable the IEEE strictness option on
FXC, otherwise FXC emits an error X4028: expression has a minimum
precision type and cannot be marked precise

Bug: tint:1887
Change-Id: I2268c9336b8e873b36e6532984838054fe4dedbd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125920
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-31 08:00:33 +00:00
Peng Huang 151e67b5d1 Support D3D11 backend for dawn samples also add toggle options
Bug: dawn:1705
Change-Id: I192ea2e8f85df8f995855109ef20eaf3bfd1ffa0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125840
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-31 01:03:42 +00:00
Le Hoang Quyen 947a7deb99 DawnNative: Add dawn::native::InstanceProcessEvents()
Make this a standalone function instead of a dawn::native::Instance's
member method.

Some code base don't use dawn::native::Instance but instead use
wgpu::Instance. And InstanceProcessEvents() function actually returns
a bool unlike wgpu::Instance::ProcessEvents() which returns void.

Bug: dawn:752
Change-Id: Ia354a4ed5b5568ee23bcc70935c104059a9f6fc8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125660
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-03-29 07:06:18 +00:00
Yan,Shaobo 8e414572be Add ServiceImplementation class in external_memory
This CL introduced ServiceImplementation class. Service class deleate
its work to ServiceImplementation class.

Different platforms inherit ServiceImplementation class and implement
it to support Service class. It helps isolate implementaion and
interface. And it's the base for supporting choosing implementation
in runtime.

Bug: dawn:1593
Change-Id: Ib18dfaa41ef4a1ce9554a5241cac1ef0fede8dd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125481
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-28 06:33:41 +00:00
Yan,Shaobo ef62a88f89 Rename Service Files in external_memory and external_semaphore
This CL do a pure rename work as the base of External memory
service refactory.

Bug: dawn:1593
Change-Id: If9595e8d8be97f5eb725acff8891e0bd1baf8928
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125480
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2023-03-28 01:17:19 +00:00
Antonio Maiorano 5cf943e797 tint/hlsl: implement trunc in terms of floor/ceil to work around FXC bug
Bug: tint:1883
Change-Id: If6c160da0684353a873428a08063aa91ee7a01c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125420
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-03-27 18:55:25 +00:00
Antonio Maiorano deb2ec9785 tint: fix UB const-eval div by zero
Bug: oss-fuzz:56904
Change-Id: I2f47fcfa238b28e1148b0b36ccbe2166445964a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125380
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-03-24 18:44:02 +00:00
Ben Clayton aff2b43596 tint/resolver: Fix ICE when using template args with builtin enums
Fixes an 'unreachable AST node' ICE which is otherwise completely harmless.

Bug: chromium:1427389
Change-Id: Id5a75b76ca27e00b9e44336a8dd303abed950333
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125400
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2023-03-24 17:27:42 +00:00
Le Hoang Quyen 99b8081e31 Add AdapterBase::APIGetInstance
This method is useful for Chrome to query the Instance from Device
by calling device.GetAdapter().GetInstance(). Then
instance.ProcessEvents() can be used to poll for events instead of
device.Tick().

Bug: dawn:1726
Change-Id: I45b5760bc07869a191ae3fd02ec25b99d78b068b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-24 15:50:50 +00:00
Yan,Shaobo 8150d1cf81 Add natural size in imageCopyExternalTexture
CopyExternalTextureForBrowser() uses external texture visible rect
as source size in previous.

But video frame natural size is the only one developer could get
from HTMLVideoElement and it means the size browser present video
on screen.

This CL add "natural size" in imageCopyExternalTexture and uses this
size as CopyExternalTextureForBrowser() source size.

Bug:dawn:1694

Change-Id: I2a3bfa8e689df11d1d13320d40ad02c7090425e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123380
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-24 03:43:56 +00:00
Peng Huang 35cab288aa [d3d] Move DumpCompiledShader to d3d folder
It will be shared between D3D11 and D3D12.

Bug: dawn:1705
Change-Id: If38122484a9063f158e83d364e2615a4ff10ead7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124884
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-24 00:08:29 +00:00
dan sinclair 5ab6dcb59b Update AST Fuzzers to initialize MultiPlanar transform.
When the fuzzers execute they need to make sure that, if there is data
effecting the MultiPlanar transform that the configuration is provided.
This used to be done by the generator, but is now the requirement of the
caller to initialize.

ThiS CL updates the AST Fuzzer common code to initialize the
`ExternalTextureOptions` with the same logic that is done by the tint
command.

Bug: chromium:1421379
Change-Id: Id957d73fe1317558edfdfcec3c0e2eaee48625bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125280
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-23 19:35:02 +00:00
Peng Huang 88daf92d34 [d3d] Move shader translation and compile code to d3d
So it can be shared between d3d11 and d3d12 backends

Bug: dawn:1705
Change-Id: Iffabe8d77a0ac3713da985c0cac5839299dc2a47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124883
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-23 18:32:00 +00:00
Brendon Tiszka a045643361 Add Dawn Wire Server LPM Fuzzer [2/N]
Add generators for protobuf files.

This CL contains the basic logic required to generate the protobuf
files from dawn.json and the newly added dawn_lpm.json for
libprotobuf-mutator.

Bug: chromium:1374747
Change-Id: I5dd207ed94ecdac365306c26e79b6cc18d3978f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114640
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brendon Tiszka <tiszka@chromium.org>
2023-03-23 16:02:20 +00:00
Le Hoang Quyen de078bad8d Forward callbacks to Instance after Device is destroyed.
When InstanceBase::ProcessEvents() iterates through list of devices, one
device might be being destructed on another thread. Even if we try to
increase ref count of that device inside the ProcessEvents(), the device
might be in the middle of destructor call on another thread, increasing
the ref count is invalid in this case.

This CL attempts to fix this issue by removing the device's pointer
from InstanceBase earlier: when DeviceBase::WillDropLastExternalRef()
is called. After this point, any callback registered to this device will
be forwarded to InstanceBase's callback queue instead.

Bug: dawn:752
Change-Id: I8ae86575e34f753e52a76f5fc774bbb5366a1b85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124281
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-03-23 15:16:46 +00:00
Austin Eng 0dc09c01a4 Workaround empty occlusion queries on Apple GPUs
Fixed: dawn:1707
Change-Id: I73f2b595c57830266e7d34ca9e483d803a00d331
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2023-03-23 07:15:03 +00:00
Austin Eng fa2d3851a8 Remove D3D12/NVIDIA occlusion query suppressions
This was fixed a while ago in
https://dawn-review.googlesource.com/c/dawn/+/48320
which filled the resolve buffer with 0 and only
resolved the available queries.

Bug: dawn:973
Change-Id: Icf6f83eeca65507ba3e6dda9e9f910d684465622
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
2023-03-23 07:11:23 +00:00
Austin Eng 7605d59518 Add a test that an empty occlusion query is 0 if preceded by non-empty
Bug: dawn:1707
Change-Id: I89910d418780c714975b8b9e237bc9cdedfe91c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125101
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-03-22 19:04:35 +00:00
dan sinclair 86216f5180 Add ability to use `{EXPECT|ASSERT}_THAT` with Diagnostics.
This CL adds the ability to use the `EXPECT_THAT` and `ASSERT_THAT`
macros with a `Diagnostics::List` object. The diagnostic string will be
emitted as part of the error message.

The `Resolver` is updated to provide access to the `Diagnostics` and the
`AppendVector` tests are updated to use the resolvers diagnostics
instead of the `error()` method.

Change-Id: I94682311fe6f135b7fceae9ec7a5108379fd32be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125060
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-22 16:47:44 +00:00
jchen10 4cd9a62b36 Add VulkanClearGen12TextureWithCCSAmbiguateOnCreation toggle
This works around an Intel Gen12 mesa driver bug by clearing some
R8 textures on creation to mitigate the buggy CCS ambiguates.

Bug: chromium:1361662

Change-Id: I7311275d0c9fc5928985e2a51b4eb7b30459b493
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124200
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-22 03:15:27 +00:00
Peng Huang ff023dcc4b Move D3DCompliationRequest struct to d3d folder
So it can be shared between D3D11 and D3D12 backends.

Bug: dawn:1705
Change-Id: Iafd2a1d66a9989229892f86a61a0d4df26f3d672
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124881
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-21 17:17:48 +00:00
Austin Eng 9a73375ddd Set depth clear value to 0 if it is unused (load op load)
VVL complains if it is NaN (the default value)

Fixed: dawn:1718
Include-Ci-Only-Tests: true
Change-Id: I397ad15dc7d5c142d7bd29f4301de27331aa7141
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124820
Kokoro: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
2023-03-20 22:37:17 +00:00
James Price 0e22bdbae7 tint/msl: Fix emission of private variables
In order to avoid declaring too many function parameters, we
previously modified this transform to redeclare private variables that
are only used inside a single function as function-scope
variables. This was broken as it meant that their values did not
persist across multiple calls to the same function.

Instead, wrap all private variables in a structure and pass it around
as a pointer.

Fixed: tint:1875
Change-Id: I83f5eb1071d57b9c6af56d6cf21b3a32c6e94260
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-20 21:46:01 +00:00
Zhaoming Jiang 6af073cecc Tint&Dawn: Enable f16 override
This CL enable using f16 override, and also fix related tests in Dawn
and Tint.

Bug: tint:1473, tint:1502
Change-Id: I8336770e8a73e5023c1aba224b7b5f21692fbaa6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124544
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-20 10:32:45 +00:00
Jiawei Shao 6b41ccc6ec Vulkan: Disable suballocation for 2D textures in some situation on Intel Mesa
This patch disables resource sub-allocation for the 2D textures with
CopyDst or RenderAttachment usage on Intel Gen12 GPUs using Mesa
driver on Linux and ChromeOS because of the driver issues about rebinding a
VkDeviceMemory from a VkImage to another VkImage.

Bug: dawn:1688
Change-Id: I28bb01a2d641a9024330ed761d27e0145d6b8aad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124382
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-18 02:54:58 +00:00
Austin Eng a66fa9b06f d3d12: track graphics/compute state independently
Fixes a bug where Dawn incorrectly did not re-apply state
when transitioning between compute and render passes. If
a compute and render pipeline share the same pipeline layout,
all of the resources for the graphics pipeline need to be rebound
since the graphics state in D3D12 is disjoint from the compute
state.

Fixed: dawn:1689
Change-Id: I7d25a1c7954039c4130e67b682ebc05324353e9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
2023-03-17 18:42:52 +00:00
Peng Huang b4c5e0d32a Refactor some common code from d3d12::Device to base d3d::Device
Bug: dawn:1705
Change-Id: Ibb69e4a60f77810b688dbd64d3ccf3b07478bad3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124522
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-17 18:14:38 +00:00
dan sinclair 6c34e11e43 Support float values where the zeros change the exponent
When underflow is detected in float parsing, WGSL returns `0.0`.
Currently, if the number of `0`s following a `.` shifts the exponent
from a positive to a negative we were not correctly identify the
underflow and returning 0. This CL updates the float parsing to detect
undeflow in this case and return `0.0` as expected.

Bug: tint:1863
Change-Id: I164063cebf70f825fdf2753dff8a4f016939c38e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124341
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-17 15:08:06 +00:00
Corentin Wallez d6b601790f dawn.node: Remove unnecessary check that TypedArrays are in bounds
This should be done by V8 on the creation of TypedArray anyways.

Bug: None
Change-Id: Ia0eacfe3a0434acf81b7d0d6473db9aa97c78c09
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122121
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-17 10:39:33 +00:00
Antonio Maiorano 52cd8caa07 tint/hlsl: fix frexp always returning positive values for fractional part
Bug: tint:1876
Change-Id: Ic56b37918fd1a2a42442b517985a49f10d85159d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124501
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-16 21:31:15 +00:00
James Price 8cf01eef04 tint: Support @diagnostic on switch body
Bug: tint:1809
Change-Id: I33259080c143b0cf7afe01343a1f179f61078dd3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124520
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-16 19:48:20 +00:00
Zhaoming Jiang 981d5a6f08 Dawn: Refactor adapter features, part 1
This CL make adapter base holds it supported features set as private
instead of protected and provide a method to set features enabled. This
CL also rename SetSupportedFeatures in null adapter to
SetSupportedFeaturesForTesting.
This is a pre-CL for implementing UseDXC as instance toggle, which may
require further refactor and adapter features logic to handle the toggles.

Bug: dawn:1495
Change-Id: I0a07e5653b43f18278cb4a2fe90985cc90b66068
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124421
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-16 19:06:33 +00:00
James Price 498e91826e tint: Support @diagnostic on continuing statements
Bug: tint:1809
Change-Id: I01725dc3b5aa3a91f7a3d3b0077667a1072debce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124360
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-16 18:19:25 +00:00
Ben Clayton d493c0f314 Dawn: Break dependency on ANGLE
Fixed: dawn:1715
Change-Id: I6d7965a9a73c42a2aca59b03379aa68aea1695c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124460
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-16 14:31:25 +00:00
James Price d7d8b80c81 tint: Support @diagnostic on loop and loop body
Bug: tint:1809
Change-Id: Ib3ccfd823f9cccb67bebbf04927d54f193a4e281
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124321
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-16 12:21:44 +00:00
Antonio Maiorano 81d11b3cf1 tint/spirv-reader: cast offset and count args to u32 for insertBits/extractBits
Bug: tint:1874
Change-Id: Ieadbfcb7fc61a0404dd988df42e0cfe0c8693b02
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124320
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 21:10:00 +00:00
Le Hoang Quyen 8a237d9566 Fix dawn_wire_server_and_frontend_fuzzer's timeout
This was caused by DeviceNull's APITick() always returning true leading
to the Instance.ProcessEvents() polling code looping forever.

Until we fix the DeviceNull's implementation, only call
Instance.ProcessEvents() once for now.

Bug: chromium:1424846
Bug: dawn:1712
Change-Id: Ieead95230cfd9a5ee7c977a7da2a98e7486ea4ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124282
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
2023-03-15 20:16:51 +00:00
Ben Clayton d3c9e8c0fe tint: Fix RemovePhonies with @must_use fns
Fixed: tint:1873
Change-Id: I72b47d5d3e406345fee16073e612b0f0cf19798e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124300
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2023-03-15 20:14:32 +00:00
Ben Clayton 9313aab0fd tint/reader/wgsl: Remove case_body()
This was not used.

Change-Id: Ic79993be201a2f02c6dc2dc8d92d1aea2f382fe4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124221
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-03-15 15:54:25 +00:00
Ben Clayton 2fc56a1c63 tint: Use std::string_view for diagnostics
And also prevent diagnostics (not just errors) in the WGSL parser when resyncing.

Change-Id: I54f433b7581a5ff1f4ec288121e23a4dc5880092
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124220
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-15 15:45:21 +00:00
Ben Clayton 9a56b25a31 tint/ast: Remove move-constructors for AST nodes
These are not used, as the nodes are constructed with a block allocator and always passed by pointer.

Reduces the Tint binary a bit:
7,759,776 -> 7,758,800
Makes some files have 100% code coverage which didn't before.

Bug: tint:1833
Change-Id: Iff4652deba92663677cc53e9506a829d0a4c12bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124180
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-15 14:09:40 +00:00
dan sinclair 39d4065653 Move BindingRemapper and MultiplanarExternalTexture to a backend transform.
In most backends, MultiplanarExternalTexture must run before the
BindingRemapper. The exception is the Vulkan SPIR-V backend where
it has to run before Multiplanar. This CL moves both of the transforms
to backend transforms and sets up the ordering as needed in the
generators.

Bug: tint:1855 chromium:1421379
Change-Id: I8223bce40babe901fe08bb1e8f033243837d7b18
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 13:41:46 +00:00
dan sinclair 0551c4f40f Move MSL configuration for `ArrayLengthFromUniform` transform.
The configuration for the `ArrayLengthFromUniform` transform was pulled
out to generator options in a previous CL. The HLSL backend was updated
to pass this information into the generator. The MSL backend was using
the deprecated path of having the transform determine the values.

This CL updates the MSL backend to pass the information into the
generator and removes the deprecated code from the transform.

Bug: tint:1855 chromium:1421379

Change-Id: I679c57914d575a758a9ff03b9db27a051d55fe17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 11:07:26 +00:00
Ben Clayton 8f80d999c4 tint: Support multiple extensions per 'enable'
Fixed: tint:1865
Change-Id: I245bd36b12ff23977c2e69deee27f976db820849
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123900
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 05:06:57 +00:00
James Price ed28de3c53 tint: Support @diagnostic on for loops
Bug: tint:1809
Change-Id: I0c6ce482a6d91ddfbcd3e69938ff09de79823e05
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124101
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-15 02:44:47 +00:00
Peng Huang 242e1efc98 Refactor comman code from d3d12::Adapter to base class d3d::Adapter
Bug: dawn:1705
Change-Id: Ib11c25cdb2ecffe6fa27c1c1945b02cfa69810c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124080
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-15 00:43:24 +00:00
James Price 9536ced014 tint: Support @diagnostic on while statements
Bug: tint:1809
Change-Id: I9593539d258d16a68c9ff1cfd2cad52e28fad65a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124100
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-15 00:33:38 +00:00
James Price d0ed63eb64 tint: Support @diagnostic on switch statements
Bug: tint:1809
Change-Id: I9dc0ff97aef1914d53799259339b7fc2cd01f615
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124061
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-14 22:49:51 +00:00
James Price 0607796ef8 tint: Support @diagnostic on if statements
Bug: tint:1809
Change-Id: I4137fc2c68c37193bd03e6a752edf0d80a4430c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124060
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-14 21:11:53 +00:00
Peng Huang 6118351432 Refactor common code out from BackendD3D12 to BackendD3D
Those common code will be shared between BackendD3D11 and
BackendD3D12. And this change will not change any logic.

Change-Id: I52a7b1932983d988e1b9656283a123b1c1c82531
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124062
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-14 20:04:14 +00:00
Le Hoang Quyen 69e1c4b638 DawnNative: implement Instance::ProcessEvents
Since https://dawn-review.googlesource.com/c/dawn/+/120940, callbacks
will be deferred to be executed in next device.APITick() instead of
immediately.
However, if the device is already destroyed (last ref dropped),
user/wire_server has no chance to call device.APITick() anymore, leading
to the callbacks waiting in queue forever.

This is also possibly the cause of memory leaks in cluserfuzz tests.

This CL attempt to fix it by implementing Instance::ProcessEvents():
In this method, every created device will invoke APITick() even if it is
already lost/externally released.

bug: chromium:1422507
bug: dawn:752
Change-Id: Iec69ad3b547a7e88c6e1a2225b13ad060a501a4f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123420
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-14 19:03:10 +00:00
Antonio Maiorano a370186824 tint: Fix compilation on latest MSVC
Change-Id: Ia0ebf98e5dc0c05f65af1593bb62e6a6971785b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124040
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-14 17:33:34 +00:00
dan sinclair 1f6ce67ed2 Move `clamp_frag_depth` transformer to backend.
This CL moves the `clamp_frag_depth` transform to be controlled by the
SPIR-V backend.

Bug: tint:1855 chromium:1421379
Change-Id: Ia439d812d4baf35d4d4955595938a2bd5e647167
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-14 16:33:55 +00:00
dan sinclair 6521a357f5 Convert generators over to use external texture options.
This CL updates the generators to receive the exteral texture options
instead of generating them.

Bug: tint:1855 chromium:1421379
Change-Id: Ib38b902aa441e33d394f947d753075ca6a8fe73b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-14 16:18:24 +00:00
Peng Huang a56069b03d Remove some unnecessary #include
Change-Id: I51382e4b4d68da55631d37b1b72fecaaef2b16ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124020
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-14 15:47:02 +00:00
Ben Clayton 97382d96f5 tint: Validate no template args with functions / builtin calls
This was already handled when resolving regular identifiers, but calls special case this resolving, and failed to check for template arguments.

Bug: chromium:1424273
Change-Id: Id756c7fbca93afcd9fd3792466471aa43d3dff04
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123980
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-14 11:32:54 +00:00
Loko Kung ebf8b7fd91 Flips the default deprecated code path to error instead of logging.
Bug: dawn:1677
Change-Id: I833b024fa89ee2eeed1dda80ad6e39f52bbcf8ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117535
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-14 07:12:53 +00:00
Peng Huang fb27a0a3e4 Move some files from d3d12 to d3d folder
Those files will be shared between d3d11 and d3d12 backends.

Change-Id: I0ec01365ccc465dfb0e9843a313d87ce649c940e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123740
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
2023-03-14 01:12:29 +00:00
dan sinclair 6784a52766 Sync keyword/reserved word list.
This CL updates the keyword/reserved word list in Tint to match latest
spec. The two differences are:

* `bitcast` is left as a keyword until we make the grammar update
* `fallthrough` is left a keyword for error purposes.

Bug: tint:1823
Change-Id: I5a33c78d21f56e0d0e2efa0114af810f2ebb8c87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122960
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-13 22:23:38 +00:00
James Price 7bca4d7293 tint: Remove constant::Value::AllEqual()
The only uses of this method were to check for splats when emitting
vector constants in some backends, and they can just check for
constant::Splat instead.

Change-Id: I12f5ecdd4a7c1191a3a516d4fd3f349230e42631
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122803
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-13 19:05:16 +00:00
James Price 69253ee8a5 tint/uniformity: Move recently added tests
The uniformity tests are (very loosely) grouped into categories, so
move the recently added assignment, compound assignment, and
increment/decrement tests to be with the other statement tests instead
of with the tests for diagnostic quality.

Change-Id: I133da4b83b7faba3e43752d45bcebb822d08625f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123641
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-13 18:14:56 +00:00
James Price 8cb5ed8c2c tint/uniformity: Fix compound assignment LHS eval
Only evaluate the LHS once, and then manually "load" from the
referenced variable to emulate the desugared implementation. Do the
same for increment/decrement statements.

Fixed: tint:1869
Change-Id: If0dc96bebd52485cfe222ae09305264ffc8b9329
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123640
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-13 17:03:04 +00:00
dan sinclair 79d0f2b784 [ir] Add `ir::Builtin`
This CL adds an `ir::Builtin` which holds the builtin function
information and arguments for a builtin call.

Bug: tint:1718
Change-Id: If08df9f7a9f7edd2781f82d4a4955635290f3f9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122607
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-13 15:42:12 +00:00
Stephen White 76cd4332cc Vulkan: enable frag shader placeholder.
The Vulkan spec mandates the use of a fragment shader unless
rasterizer discard is enabled. For now, enable the placeholder
fragment shader in all cases, with a bug logged to optimize it
for the rasterizer discard case.

Bug: dawn:1696 dawn:1698
Change-Id: I9e85e6308a9952fc505382488c618897bd9abc7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123503
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-03-10 19:20:15 +00:00
Ben Clayton cd097f40a3 tint: Improve module scope var diagnostic
Improve the error message when declaring a module-scope var without an address space, with an initializer.

Fixed: tint:1870
Change-Id: If087ae7dadb512c7050e89a0c75990080668e27d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123600
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-10 13:10:52 +00:00
dan sinclair e95b59c34d Add ExternalTextureOptions
This CL adds a `writer/ExternalTextureOptions` to allow providing
external texture information to the generators. The generators are
updated to have the option in their config, but do not use it yet.

Bug: tint:1855 chromium:1421379
Change-Id: I99b122c5cae145e8527158f300da81743f89775a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123160
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-10 11:34:26 +00:00
James Price 55509fae00 Roll third_party/gpuweb to 1f8a05a
Fixup Dawn node as necessary.

Change-Id: I96b9a078adba1c8988f9bc5835e1f7645c67a57d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123501
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-10 11:06:36 +00:00
Ben Clayton a36fa42dd7 tint/cmd: Use correct preprocessor guard for libspriv.hpp
This header is used by TINT_BUILD_SPV_READER not TINT_BUILD_SPV_WRITER

Change-Id: Ia42e4f2bf2ad37f426d2bf14e962abed9de147a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122520
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-09 23:46:59 +00:00
Ben Clayton 574b4b1996 tint: Fix constant::Splat conversion of struct types
Conversion can happen for structure materialization (modf, frexp).
If both structure members are the same type and value, then a constant::Splat will be constructed, which needs to handle conversion.

Bug: chromium:1417515
Change-Id: Iadd14ce00b8d5c22226c601ec5af9a84e6c0c5cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122900
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-09 23:22:27 +00:00
Stephen White cc2e9eca1a Vulkan: skip a test that's failing with newer VVL.
Bug: dawn:1696
Change-Id: Ie14e3d124342228edef17a122f380e2bdfaf1e57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123502
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Auto-Submit: Stephen White <senorblanco@chromium.org>
Reviewed-by: dan sinclair <dsinclair@google.com>
2023-03-09 22:59:38 +00:00
Ben Clayton 7972a10aa8 tint: Add missing include
Should fix dawn -> chromium roll

Change-Id: If4bf1ed6795dc55c4c5a45e8ba8fa2eb0da7270a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123521
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2023-03-09 21:33:13 +00:00
Ben Clayton cc3f851ad8 tint/transform: Polyfill f32 conversion to i32 or u32
And vectors of those types.

Fixed: tint:1866
Change-Id: Ic0b5061232c5eb5a67d43dde1cd9599c580f4388
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123201
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2023-03-09 21:26:12 +00:00
Ben Clayton f1f56b2d3c tint/writer/glsl: Set default precision to highp
WGSL states that `f32` is a IEEE-754 binary32. mediump precision guarantees are much smaller than highp, and using mediump can break code generated by tint.

Change-Id: I8a129c4c8ac078c785e0d5d7d21f19ed6b3620b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123400
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2023-03-09 19:58:23 +00:00
Ben Clayton 4fea9d0fbb tint: Implement Switch() without recursion
This removes the number of function calls made in non-optimized builds.

Reduces the optimized, all-features-enabled 'tint' executable size by
about 1%.

This change removes the bloom filter optimizations which provided
substantial performance gains with the old recursive implementation,
however this still appears to be ~1% faster than the optimized version.

Change-Id: Ic2bb82e9182459e37907f9e0d0b4771bde218f9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123440
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2023-03-09 18:24:19 +00:00
Ben Clayton 23946b3606 tint: Move Switch() to own header
castable.h is bigger than it needs to be, and pretty much every tint .cc file includes castable.h
Reduce the amount of code that .cc files that don't use Switch() need to compile.

Change-Id: Ibb4e8b0bc7104ad33a7f2f39587c7d9e749fee97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123401
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-09 16:50:19 +00:00
dan sinclair 9543f74739 Move sem::BuiltinType to builtin::Function.
This CL moves `sem::BuiltinType` to `builtin::Function`. This makes it
available for use in the IR. The `Function` name better maps to the
usage in that it contains the builtin functions.

Bug: tint:1834
Change-Id: Ic1a26525d7845d79eb6239bdeb2b73e05f586c24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122606
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-09 01:20:16 +00:00
dan sinclair 03ee23ea9e [ir] Convert materialized nodes to constants
This CL updates the IR builder to convert materialized call expressions
directly into the resulting constant values.

Bug: tint:1718
Change-Id: I184478996afdd11b00ca946775eab6801b777f3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122605
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-08 23:22:27 +00:00
Loko Kung af4ca3891f Update maxFragmentCombinedOutputResources on the different backends.
- Adds an e2e test to test writing to outputs when at the limit.

Bug: dawn:1665
Change-Id: I2b2b9c2d700be0e454dc945ed8e3e1fe6b191974
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122801
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-08 22:38:40 +00:00
Ben Clayton 2657b923c9 tint/writer/glsl: Fix vector `select`
mix of ivec is not core until later GLSL versions.
Just polyfill in the writer with ternary ops.

Change-Id: Ia0c35bf95842e03ef8447019f3264d01c11fd384
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123240
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
2023-03-08 22:29:38 +00:00
Ben Clayton da353b4b39 tint: Flip evaluation order of assignment statements
Evaluate the LHS before the RHS.

Fixed: tint:1867
Change-Id: Ib63903ed4b1425007197a6da37f3bf54a495d88a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123120
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-08 21:48:45 +00:00
dan sinclair 43c5efa7e8 [ir] Add error helper to ir builder.
This CL adds a `add_error` to the IR builder.

Bug: tint:1718
Change-Id: Ifd7a2f6e015d423dbe23405816dba00f237a6c8c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122602
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-08 21:22:47 +00:00
dan sinclair 724a70f7a1 [ir] Add user functions, value constructors and value converters
This CL adds user function calls, value constructors and value
converters into the IR.

Bug: tint:1718
Change-Id: Iab59aa7d01b9d7831299d785f6e45e9fba12f7b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122600
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-08 21:19:13 +00:00
Ben Clayton 51be3420b8 tint/writer/glsl: Fix emission of lowest i32 value
GLSL has the same behavior as MSL, in that -2147483648 is parsed as
a unary minus on '2147483648'. 2147483648 overflows an i32, so this
actually gets treated as -0.

Change-Id: Ibebd8b78a8840f18c438ed1d3d24dee486a65816
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123202
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-08 21:13:22 +00:00
Ben Clayton ce2578bc99 tint/transform: Refactor BuiltinPolyfill transform
Move the bulk of the logic into the State class.
Reduces deep indentation, and likely improves performance by reducing the number of variable that require lambda capture.

Change-Id: I85c87298157f34645d0ae064439bb640f7af7c80
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123200
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-03-08 19:40:09 +00:00
Antonio Maiorano 22895dbe40 Add end2end tests for compute flow control
This replicates a subset of the flow control CTS tests. The purpose of
this is to provide relatively easy-to-repro cases to demonstrate flow
control bugs on Intel Graphics UHD 630 GPUs.

Bug: tint:1868
Change-Id: I34d692230b44d8a0a917dc773cc748bbf288d55a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-03-08 18:23:51 +00:00
dan sinclair eebbdef81a Split `BindingPoint` out of MultiplanarExternalTexture.
This CL moves the `using` statement for `BindingPoint` out to its own
file in `src/tint/writer/binding_point.h`. Usages of
`tint::transform::BindingPoint` have been updated to
`tint::writer::BindingPoint`.

Bug: tint:1855
Change-Id: Ife7d92807e0a65b93f21158d73a60d5068fc5da9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123000
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-08 02:48:42 +00:00
Ben Clayton 068eb3ebda tint: Fix HLSL texture queries and re-add textureNumLayers()
... overloads for texture cube arrays

FXC is telling porkies, when it says "The array element count
of GetDimensions on TextureCubeArray objects is unavailable
on ps_5_1".

The actual issue, as identified by Teodor Tanasoaia at Mozilla,
is that the argument needs to be unsigned.

In fact, *all* the texture queries should have used an unsigned
scalar or vector for the output value. This has been broken
forever!

This reverts commit bd9f6e6684.

Change-Id: I3e217bec17c6fd203cff618b143ebef3d8a61927
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122980
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-08 02:48:34 +00:00
Loko Kung 4f98dd4706 Add maxFragmentCombinedOutputResources and validation for it.
- Suppresses maxStorageTexturesPerShaderStage CTS test because it needs
  to be modified to adhere to the new limit as well.

Bug: dawn:1665
Change-Id: I66c62bd94b613059633888210ec7e7b42dc3a1dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122461
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-08 02:45:50 +00:00
dan sinclair 0917fbb147 Reland "Add writer to emit the AST."
This reverts commit 5e56551551.

Change-Id: I2c3da583090ebef87cc71a743746d741345847c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122782
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-07 18:28:38 +00:00
dan sinclair 2fe7f19026 Use `absl::from_chars` instead of `strtod`
This CL switches Tint to use `absl::from_chars` instead of `strtod` in
order to have locale independent parsing of floats.

Bug: tint:1686
Change-Id: Icb3d9a40928a1cb154b32629f7e39173d80e4563
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122780
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-07 18:20:23 +00:00
dan sinclair 64196ad60a Add array length options header to `tint.h`.
The `array_length_from_uniform_options.h` is being included directly by
Dawn. This CL moves the include to the `tint.h` file and has the dawn
usage include that instead.

Change-Id: Iaa77d76bc62fe5038f5b6b93d51478ceed85ac9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122781
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-07 16:51:01 +00:00
Austin Eng 142bddf7da Fix #ifdefs for spvtools
Change-Id: I76d8d983e44e04be4abfbb25678cab8d926fbd6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122840
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-07 09:27:45 +00:00
Austin Eng f244bffdd5 Fix build of tint_cmd_helper
spvtools_headers are not available without tint_build_spv_writer

Change-Id: If4539715b0e685c9b54bf24719a905fb0265a402
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122820
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-03-07 02:41:45 +00:00
Zhaoming Jiang c2657b21d5 Dawn: Promote DisallowUnsafeAPIs as instance toggle
This CL add Instance and Adapter toggle stage, and promote
DisallowUnsafeAPIs as an instance toggle, and can be required using
DawnTogglesDescriptor chained in instance descriptor when creating
instance. The instance's toggles state will get inherited to adapters
and devices it create. Related tests are implemented and updated.

Toggles inheritance can be overriden if not forced, so requiring
DisallowUnsafeAPIs when creating device is still available and working
like before.

Note that currently we don't have toggle of adapter stage, and can not
require toggles when creating adapter, until follow up CLs implement it.
Currently the toggles state of a adapter is simply inherited from
instance.

Bug: dawn:1495
Change-Id: I6bf7aa0f950a99451afcc2cab5322c924b7d9520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122021
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-07 02:03:54 +00:00
Jiawei Shao e5ca66806f Vulkan: Use VK_QUEUE_FAMILY_IGNORED on buffer barriers
This patch uses VK_QUEUE_FAMILY_IGNORED on buffer barriers to align
with what we are doing on image barriers.

Bug: dawn:1688
Change-Id: Icabae22270fc9c92a69ce18e0a63db49de9d7481
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122444
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-07 00:43:08 +00:00
Austin Eng aaae3ffada Vulkan: make mappableBuffersForEagerTransition ref buffers
There are some scenarios where buffers can be used in pending
commands that are not retained by a command buffer.

They must be retained in the set of mappable buffers for eager
transition to prevent a use-after-free violation.

Fixed: chromium:1421170
Change-Id: I452d80b2513a7726a003d44e2a7850292d798bb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122580
Auto-Submit: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
2023-03-06 22:09:26 +00:00
Ben Clayton 8525ff29da tint/transform/robustness: Implement predicated mode
This change overhauls the Robustness transform to support three modes,
per address space:
* ignore    - Disable robustness checks for the address space
* clamp     - Clamp indices / texture args to ensure they're in
              bounds. This was the old behavior, and continues to
              be the default.
* predicate - Condition all indexing / textureLoad / textureStore /
              atomic* operations on the bounds check. If any
              dependent value is out of bounds, then the operation
              is skipped.

This change also fixes multiple expression evaluation of the texture
builtin 'level' argument.

Change-Id: I2e300ddff2c8d3183a9701f06985ce1b262baf2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122343
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-03-06 21:05:01 +00:00
Dan Sinclair 5e56551551 Revert "Add writer to emit the AST."
This reverts commit a753ad47a4.

Reason for revert: This seems to be breaking `gn check` when the option is not enabled. Not sure why the preprocessor guard isn't working. Will fix and reland later.

Original change's description:
> Add writer to emit the AST.
>
> This CL adds a new `SyntaxTree` writer and a `dump-syntax-tree` option
> to the `tint` program which emits a copy of the AST to the terminal.
>
> Change-Id: I83f6cd7aad3413b0a823728e8aac0d551421b33a
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122540
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
> Kokoro: Kokoro <noreply+kokoro@google.com>

TBR=dsinclair@chromium.org,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Icaac76f8daba6034658cf05e15f15676ce2bf155
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122760
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-03-06 20:30:23 +00:00
dan sinclair 5ab2928f6a Convert `strtoll` to use `std::from_chars`.
This CL updates the lexer to use `std::from_chars` which is locale
independent over `strtoll` which honours locale.

Bug: tint:1686
Change-Id: Ic773038fffaa9e2042dec9d94e310c73d05180b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122603
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-06 20:21:52 +00:00
Le Hoang Quyen 8ab7dbe424 DawnNative: Defer callbacks' triggerings to APITick().
Currently in the middle of some functions, we execute callbacks
immediately such as inside Buffer::APIMapAsync(), Device::HandleError()
or Queue::Submit().

Firstly, this has risks. The functions might be in a middle of modifying
internal states. By triggering callbacks, users might call API
functions again which could further modify the internal states
unexpectedly or access the states in an inconsistent way.

Secondly, upcoming thread safe API which locks the public functions with
a mutex might encounter deadlock. Because callbacks might cause
re-entrances which would unexpectedly lock the public function again.

This CL attempts to limit number of functions that are allowed to
trigger callbacks. Other functions that want to trigger callbacks will
instead enqueue a request to execute callbacks in the next
Device::APITick() call.

Currently the functions that will be allowed to trigger callbacks are:
- Device::WillDropLastExternalRef()
- Device::APITick()
- Device::APISetLoggingCallback()
- Device::APISetUncapturedErrorCallback()
- Device::APISetDeviceLostCallback()

Bug: dawn:1672
Change-Id: Iabca00f1b6f8f69eb5e966ffaa43dda5ae20fa8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120940
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-06 19:03:26 +00:00
dan sinclair a753ad47a4 Add writer to emit the AST.
This CL adds a new `SyntaxTree` writer and a `dump-syntax-tree` option
to the `tint` program which emits a copy of the AST to the terminal.

Change-Id: I83f6cd7aad3413b0a823728e8aac0d551421b33a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122540
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-06 17:48:33 +00:00
Ben Clayton 63d0fabeb1 tint: Fix HLSL emission for out-of-order storage / uniform buffers
Recent changes to DecomposeMemoryAccess meant we lost the dependency information between the user of a module-scope variable of the storage / uniform address space and the variable.

Add dependency information to ast::InternalAttribute so this can be tracked.
This change also means that symbol renaming after the DecomposeMemoryAccess should work.

Fixed: tint:1860
Change-Id: Icfa2925f95c2ac50702522df514cd11bde727546
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122660
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-06 15:43:16 +00:00
Ben Clayton fd387a37c3 tint: Fix WGSL emission of const_assert
Fixed: tint:1858
Change-Id: I5cd2fc4d7dc0a9a0bd48330366a99dd726e42659
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122661
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-03-06 14:03:08 +00:00
Ben Clayton bd9f6e6684 tint: Remove textureNumLayers() overloads for texture cube arrays
These are not supported in HLSL shader model 5.1

See: https://github.com/gpuweb/gpuweb/issues/3913
Change-Id: Ic33666ff910f04e3f561cbc40c9db14c5de59284
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122524
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-03-04 00:55:16 +00:00
Ben Clayton 3a431d71be tint/intrinsics.def: Fix textureStore overload
The texture_storage_3d overload should allow for unsigned coordinates.

Change-Id: I6278571fb9dc7bba644a4ba88cce6b8bd7c790bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122521
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2023-03-04 00:43:21 +00:00
Ben Clayton 472815d3c1 tint: Fix build on windows + cmake
Change-Id: Id24e6c27a00700123e1677585ff7759c0bbcfe07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122523
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-03-04 00:15:24 +00:00
Ben Clayton 67e1de42c2 tint/transform: Reduce verbosity of TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM
Print the input program, and the output of each run transform.

Significantly reduces stdout spam, and also shows you transform input - which is what you really want.

Issue: tint:1853
Change-Id: Iaea0dc16de63daffcf0b0c715af14d194b700468
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122480
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-03 18:38:38 +00:00
Marshall Greenblatt 1fb13a7fd4 win: assert non-empty $windows_sdk_version
BUG=chromium:1420723
Change-Id: I90c248bb7ad89b6def9782af41e5ec04a99adea7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122440
Commit-Queue: Marshall Greenblatt <marshall@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-03 15:21:47 +00:00
Ben Clayton a5193704f6 dawn/native: Initialize tint
Bug: tint:1853
Change-Id: Id6242163f0670a62ed94ac01dcd575b403145b4e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122383
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-03 14:23:39 +00:00
Ben Clayton f7910f5b95 tint.h: Remove 'libspirv.hpp' include
This does not belong in the public header - the spirv writer public header does not depend on it.

Change-Id: Id1b2107c3a2003632e1868c2d6a337ddbb0c8b48
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122382
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2023-03-03 14:20:53 +00:00
Ben Clayton b902e56ae7 dawn/test: Display an error message if toggles aren't recognised
Instead of cryptically crashing in release builds.

Change-Id: I22d222c6d6550010c3484e1f18397cef22602b92
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122384
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-03 11:21:52 +00:00
shrekshao ffe4c6fbaa Add label info for storage binding aliasing error msg
Bug: dawn:1642, dawn:840
Change-Id: Ice1661539b40d605a93e805acf7609fd3315606d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122460
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2023-03-03 01:19:26 +00:00
Loko Kung 861dfd89e8 Removes duplicated maxBufferSize in limit macros.
- Note the duplication (in LIMITS_MAX_BUFFER_SIZE and LIMITS_OTHER)
  caused tiering to be overridden.
- Also updated binding size test to align buffer sizes properly since
  the test was failing locally for me.

Fixes: dawn:1683
Change-Id: I8d05f863ea9bf4dc8e620b7803bedb913af9f67b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122260
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-02 21:51:03 +00:00
dan sinclair 6cc183c85a Generic template and forward in stringstream.
This CL updates the templates in the StringStream to match more types.
All of the internal `operator<<` methods have been converted over to
StringStream. The precision was increased in order to better match the
precision needed to read back as a double.

Bug: tint:1686
Change-Id: Iaa15cf247f174967dd1014647ba5a74804997c22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122080
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-03-02 21:28:45 +00:00
Ben Clayton 03de0e83ae Move tint::transform::Robustness to a santizier transform
There's no good reason for this to be public.
Move it into the writers, and expose a 'disable_robustness' option to
turn it off. This can be expanded to hold more fine-grain control in the
future.

Change-Id: I6ea6e54a27b2ae0fbcba5fdf45539063045cc15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122203
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-02 20:48:48 +00:00
Ben Clayton d7ee9c1510 tint/sem: Add Declaration() override for IndexAccessorExpression
Convenience overload to return ast::IndexAccessorExpression instead of ast::Expression

Change-Id: Ib239fd6d5742425a629fc76e1b564a3c7781ca2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122342
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2023-03-02 18:29:38 +00:00
Ben Clayton 1edc272904 tint/transform: Implement CreateASTTypeFor() for pointers
Change-Id: I83b0bb28194be559e6e60caca6f2dc1871e65743
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122340
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
2023-03-02 17:47:24 +00:00
Ben Clayton 57be2ff2eb tint: Change CloneContext::Replace() to replace the map entry
instead of silently being a no-op on second call.

This allows for repeated updates of a node's mapping, which is useful
for immediate-mode style cloning.

Change-Id: I6bd2851cbe67d3886d37cefc3ef9de488d4b0878
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122300
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-03-02 17:45:21 +00:00
Ben Clayton 26157557e8 tint/transform/utils: Add HoistToDeclBefore::Replace()
Handles statement replacement of for-loop initializer and continuing
statements.

Change-Id: I83ddf6fbd9b19f5022f7b02d7aebcbd95ab4c1f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122302
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-03-02 17:37:53 +00:00
Ben Clayton c0c8abc569 tint/resolver: Add missing ResolvedIdentifier case for 'let'
Prevents an ICE.
I had this trigger, but I'm now struggling to find a reproduction.

Only used to print a diagnostic when things go wrong.

Change-Id: Iab78c3bcaaf1afb2f556247f8a419f93a727ec96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122341
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2023-03-02 17:36:37 +00:00
Ben Clayton 3cde73cb1a tint/transform/utils: Correctly scope for-loop init
When using HoistToDeclBefore on a for-loop initializer, the inserted
statement would be scoped outside the for-loop. This was incorrect.

Change-Id: I764d07068e907cc203145ac8d6f0110b1b73e667
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122301
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2023-03-02 17:18:27 +00:00
Loko Kung d81aca7106 Make ConsumedError require handling the returned bool.
This change makes it harder to misuse ConsumedError which can cause
device loss. When it is a known error, instead use HandleError to
bypass the "unlikely" if clause.

Bug: dawn:1336
Change-Id: I3052db343fe4080b257f1c2f9535f743a0e78526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120384
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-02 01:24:03 +00:00
Loko Kung e11208e9ce Handle/log errors when initializing pipeline caches in Vulkan.
Note that we can just log these errors and avoid bubbling them up since
cache creation failure should not be fatal in Vulkan.

Bug: dawn:1336
Change-Id: Ie49d433f9b991508859f4969f2d4bf3b7c9e66d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122024
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-03-02 00:27:50 +00:00
Loko Kung 02e456c9fb Bubble up errors from EnsureSubresourceContentInitialized.
Bug: dawn:1336
Change-Id: I1fd189bd6e3689df6f10351e8ba19fee569bda23
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122023
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2023-03-01 21:53:31 +00:00
shrekshao 84532462f6 Validate writable storage texture bindings don't alias
Followup of storage buffer bindings aliasing validation.

Bug: dawn:1642
Change-Id: I84bf33895320053630ed80d3503ff53d1eaa83b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2023-03-01 21:04:28 +00:00
Yuly Novikov bda18d2b8d Skip MaxBufferBindingSize on Metal AMD
Fails on MacBook Pro 2019

Bug: dawn:1683
Change-Id: I335df3ae7e7cd9432d937a3b7d117f77b6143fa4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122200
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
2023-03-01 20:21:44 +00:00
Takahiro 9754bc42f4 Make properties required
This commit makes depthWriteEnabled and depthCompare required and
makes depthClearValue conditionally required for the spec change
in WebGPU V1.

https://github.com/gpuweb/gpuweb/pull/3849

depthClearValue is required if depthLoadOp is clear and the
attachment has a depth aspect. To simulate it, this commit lets
NAN represent unspecified depthClearValue and lets the default
value of depthClearValue be NAN.

Bug: dawn:1669
Change-Id: I469338e909b1d3c345bc2642ee47daee858909ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-03-01 13:34:59 +00:00
Corentin Wallez 383b5b3f8d Remove some dead code in TextureVk.
Found via the code coverage reports.

Bug: None
Change-Id: I3cd5911a627932cfde1bafd8353eef28993bbd42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2023-03-01 03:39:58 +00:00
James Price d623182c33 tint/PromoteInitializers: Do not hoist abstracts
Hoisting them would cause premature materialization. This will only
happen in cases where we do not actually need to hoist (e.g. assigning
to a phony), so we can safely skip these.

Fixed: tint:1852
Change-Id: Ifcbe3e13496daa0a6aaceb58540e60cb037885ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122104
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-03-01 00:20:49 +00:00
dan sinclair dee884c925 Convert most remaining usages to utils::StringStream.
This CL converts most of the remaining Tint usages (leaving out the
fuzzer code and some float_to_string code).

Bug: tint:1686
Change-Id: I4d5cef176c15479250861903870ec5bec0f95b5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122002
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-28 22:22:58 +00:00
James Price 7c21fe5d92 tint/uniformity: Fix struct member partial pointers
This assertion was mistakenly changed to only allow index accessors
when the ast::AccessorExpression base class was added.

Bug: chromium:1420257
Change-Id: Ic2b695dd7605c8852ab6d822602dca5d28ecf2d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122103
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-28 21:04:41 +00:00
James Price b7c2aed189 tint: Skip short-circuited array init const eval
Otherwise we will dereference the nullptr constant::Value constructor
arguments.

Bug: chromium:1420256
Change-Id: I5cace9c7c4bab7815f319793fdd88be294cd0ceb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122101
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-02-28 19:28:50 +00:00
Loko Kung f93f7ae8b1 Bubble up potential errors during buffer.unmap().
Bug: dawn:1336
Change-Id: I715904874311349b4e996665dccc9d2d31959717
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122022
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
2023-02-28 19:02:00 +00:00
Loko Kung c2683a9459 Fix AllowedErrorTests by returning error via move.
Bug: dawn:1336
Change-Id: I966a2385e2a7e8a81ef97cd116b85a8036312e31
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122027
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-02-28 19:01:40 +00:00
dan sinclair 0723a3c7f8 Convert WGSL reader to utils::StringStream.
This CL updates the WGSL reader to use utils::StringStream internally.

Bug: tint:1686
Change-Id: I203c764bbb86e99da323fde2be2af555f158b7bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122001
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 18:47:20 +00:00
dan sinclair 0c184c2856 Convert SPIR-V reader to utils::StringStream.
This CL updates the SPIR-V reader to use utils::StringStream internally.

Bug: tint:1686
Change-Id: I619c2aa56b85e6c24b933ffa2a1a409d63846f5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122000
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-02-28 17:36:43 +00:00
dan sinclair b23cda4bc2 Convert the resolver over to utils::StringStream.
This CL updates the resolver to use utils::StringStream instead of
std::stringstream.

Bug: tint:1686
Change-Id: Ib15a9ae3228757bbddcf787fa9130ca19bc9eab7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121980
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-02-28 17:31:54 +00:00
Austin Eng e143338f65 Add limit tier for larger workgroup sizes
Up to 1024 threads in the X and Y dimensions. This is supported on all
Mac, all Windows, and most Vulkan devices.

Bug: dawn:685
Change-Id: I067a492bdfc32d6a186d6875e545238babca8784
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122003
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 17:10:04 +00:00
dan sinclair b2ba57b15d Convert TextGenerator over to utils::StringStream.
This CL updates the TextGenerator base class to use utils::StringStream.

Bug: tint:1686
Change-Id: Ie36f55cf32e63773c4bee2cf89cdef19ab1fba28
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121960
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 15:14:09 +00:00
dan sinclair 88fea2a9c3 Convert the WGSL generator to utils::StringStream.
This CL updates the WGSL generator to use utils::StringStream
internally.

Bug: tint:1686
Change-Id: I7387a583f9cba3c6a955f5be376adc141e3ee394
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121941
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 15:06:19 +00:00
dan sinclair ec24bb2f0c Convert SPIR-V Writer over to utils::StringStream.
This CL updates the spir-v writer to use utils::StringStream.

Bug: tint:1686
Change-Id: I0b1367991de9ecb9fe02bdd0d1827aeba633f2fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121940
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 14:58:36 +00:00
dan sinclair 52fa68b1a7 Convert MSL generator over to utils::StringStream.
This CL converts the MSL generator to use utils::StringStream
internally.

Bug: tint:1686
Change-Id: I4225ebb87fd5281a3527bf2a9067651b60b114a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121920
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-02-28 14:54:51 +00:00
dan sinclair 2b9d5b338a Convert HLSL generator over to utils::StringStream.
This CL converts the HLSL generator to use utils::StringStream instead
of std::stringstream.

Bug: tint:1686
Change-Id: I69d4deec9b65bbcba6afe319cc1266879cd7c373
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121900
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2023-02-28 14:49:25 +00:00
dan sinclair dba03d30fb Convert GLSL Generator over to utils::StringStream.
This CL switches the GLSL Generator to use utils::StringStream. The line
writer is converted internally as well, although it converts to
`std::ostream` for now. This caused a couple of the MSL, HLSL and GLSL
tests to generate slightly fewer decimal points in a couple tests.

Bug: tint:1686
Change-Id: I9ec8c1a5ef49679fc1c9a9aece86ab3390e103fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121880
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-28 14:41:45 +00:00
dan sinclair a4637ad8a3 Convert IR over to `utils::StringStream`.
This Cl updates the IR to use the `utils::StringStream` instead of
`std::stringstream`.

Bug: tint:1686
Change-Id: Iee9063db554bc75e7a730a8629d7f3403ff1a190
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121860
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 13:09:06 +00:00
dan sinclair 7ca41fffb7 Add a utils/string_stream class.
This CL adds `utils::StringStream`. This is a wrapper over
std::stringstream which forces the locale to always be `classic`. The
logic to format floats and doubles as expected is moved from
`float_to_string` and handled in the StreamStream. This will make all of
our float emission the same.

Bug: tint:1686
Change-Id: If51868f577580d3ea6ab94d3910393e239fd55e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121800
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-28 13:05:21 +00:00
Loko Kung 53893a3d77 Adds error promoting to device loss when disallowed error occurs in a scope.
- Defaults consume error calls to only allow validation and device loss
  errors.
- Allows OOM errors on Buffers, QuerySets, and Textures only.
- Adds initial suite of unit tests (and any necessary updates to mock
  framework).

Bug: dawn:1336
Change-Id: I82112ea6c147e894280e605bf8ae0ce00488c9f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119800
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-28 04:34:32 +00:00
James Price 7680bc0a89 dawn/test: Test padding byte preservation
The Dawn E2E tests for memory layout now check that padding bytes are
preserved, instead of skipping them.

Bug: tint:1571
Change-Id: I02edbe140e7025937a3188106da5e43ff03ad078
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121602
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 22:31:35 +00:00
Stephen White 25e1f12228 OpenGL: add support for GL_ANGLE_base_vertex_base_instance.
Change-Id: Ib327cb2e66bd5f02cce9c5321207483e16b40a40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121500
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2023-02-27 21:43:57 +00:00
James Price ae3e9adc1b dawn/node: Fix array buffer view conversion
A Napi::TypedArray may have a non-zero offset on its underlying
ArrayBuffer backing buffer. Also use the length of the typed array,
not the backing buffer.

Change-Id: Icaa310ef8f87393b4d7582ba0a0afb2b87318664
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121820
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2023-02-27 21:21:02 +00:00
Austin Eng 148e7fab1c Raise maxStorageTexturesPerShaderStage to 8
The higher tier for this limit is available on all D3D12, all Metal,
and most Vulkan devices.

Bug: dawn:685
Change-Id: Ic2a39ad7908ea178e7aac48b7bb54b262d7039cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121543
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2023-02-27 20:22:51 +00:00
James Price 4d3af66bbd tint/msl: Preserve trailing vec3 padding
In order to preserve padding properly for MSL, we need to use its
packed_vec type for all vec3 types in storage buffers, not just struct
members. This commit includes a complete rewrite of the PackedVec3
transform to achieve this. The key details are:

* An internal `__packed_vec3<>` type was added, which corresponds to a
  `type::Vector` with an additional flag to indicate that it will be
  emitted as packed vector.

* The `PackedVec3` transform replaces all vec3 types used in
  host-shareable address spaces with the internal `__packed_vec3`
  type. This includes vec3 types that appear as the store type of a
  pointer.

* When used as an array element, these `__packed_vec3` types are
  wrapped in a struct that contains a single `__packed_vec3`
  member. This allows us to add an `@align()` attribute that ensures
  that `array<vec3<T>>` still has the correct array element stride.

* When the `vec3<T>` appears as a struct member in the input program,
  we apply the `@align()` to that member to ensure that we do not
  change its offset.

* Matrix types with three rows that are used in memory are replaced
  with an array of columns, where each column uses a `__packed_vec3`
  inside an aligned wrapper structure as above.

* Accesses to host-shareable memory that involve any of these types
  invoke a "pack" or "unpack" helper function to convert them to the
  equivalent type that uses `__packed_vec3` or a regular `vec3` as
  required.

* The `chromium_internal_relaxed_uniform_layout` extension is used to
  avoid issues where modifying a type in the uniform address space
  triggers stricter layout validation rules.

Bug: tint:1571
Fixed: tint:1837
Change-Id: Idaf2da2f5bcb2be00c85ec657edfb614186476bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121200
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 20:21:03 +00:00
Stephen White 55183e6c3a OpenGL: only load extension procs if extension supported.
Only load extension entry points if the extension is supported.

From the eglGetProcAddress manpage:

"A non-NULL return value does not guarantee that an extension function
is actually supported at runtime. The client must also make a
corresponding query, such as glGetString(GL_EXTENSIONS) for OpenGL and
OpenGL ES extensions [...] to determine if a function is supported by
EGL or a specific client API context."

This required moving extension initialization from OpenGLFunctions
into OpenGLFunctionsBase.

Change-Id: Ib4e8360ba455818701990b4476689b651d097ca8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121760
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-02-27 19:31:08 +00:00
Antonio Maiorano 43ffb09247 tint: validate max number of case selectors in a switch statement
Bug: tint:1209
Change-Id: Id91901125e7caf9b8b0e297305c26587edaa44d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121741
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-27 19:04:23 +00:00
Antonio Maiorano 1bb5be9789 tint: improve error message about function paramter limit
Bug: tint:1209
Change-Id: I0d3b188069e91488a482f529c962bfa054ad6d36
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121740
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2023-02-27 19:04:23 +00:00
Antonio Maiorano 6b304e9ffd tint: validate max nesting depth of composite types
Also increased stack size for windows + debug GN builds of
tint_unittests to 4 MB, which matches what we do in the CMake build.
Required, otherwise some of my new tests stack overflow.

Bug: tint:1209
Change-Id: I3b98000a989aa8b42b20cc4e2219c91887e52451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121360
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 19:04:23 +00:00
James Price 0b3400c56e tint: Add chromium_internal_relaxed_uniform_layout
This will be used by the PackedVec3 transform to avoid triggering
stricter layout validation rules for the uniform address space when
mutating types.

Bug: tint:1571
Change-Id: Ib15737fbe3cab4a8fbe453bcaf96ef2acc595921
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121601
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 18:39:20 +00:00