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>
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>
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>
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>
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>
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>
Change-Id: I0df2677cfd454a2f38e580acd08089694486f6ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128680
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
- 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>
- 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>