Commit Graph

3047 Commits

Author SHA1 Message Date
Corentin Wallez c7203ba890 Remove deprecated ComputePipelineDescriptor.computeStage
Bug: dawn:800
Change-Id: I8d9d2a7cdba328d1cf040f7c8c622d1d7d403be2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63741
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-14 11:42:27 +00:00
Corentin Wallez 1ac4565115 Remove deprecated RenderPass*Attachment.attachment
Bug: dawn:762
Change-Id: I86144f77ffd647d2e5c01742fb67367c7a5c914e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63382
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-14 10:42:22 +00:00
jchen10 96ac969a33 Use WGPU_ARRAY_LAYER_COUNT_UNDEFINED instead of 0
This seperates the undefined 'arrayLayerCount' from 0 to
WGPU_ARRAY_LAYER_COUNT_UNDEFINED. So 0 arrayLayerCount is treated
as a validation error.

Bug: dawn:1026
Change-Id: I7b4ae024b02ac0d2aa260b2a8c64b09bd967db87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63660
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2021-09-14 02:41:49 +00:00
Brandon Jones 1934e56159 Disable multiple mip levels for r8/rg8unorm textures on Metal
Bug: dawn:1071
Change-Id: I2cc9173f0dff325e4bb2583bb27a98bbaaa61531
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63462
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-14 00:54:59 +00:00
Brian Sheedy cc3f16c437 Suppress Mac 11.5 failure
Suppresses LoadOpClearIntegerFormatsToLargeValues on Mac 11.5 with
Metal on Intel GPUs.

Bug: dawn:1109

Change-Id: Ia4316ee00ad790752fa3b5d1778d885c5eb3a188
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64160
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-13 20:35:49 +00:00
Austin Eng 02fbf168e0 Add validation, storage, and querying of limits
Adds a way to store the limits on the Adapter and the
Device. For now, adapter limits are always the default
limits, and device limits are stored but not used.

This CL also adds usage of an ErrorObjectIdResolver and
Provider in the WGPUDeviceProperties serialization and
deserialization helpers. Serializing/deserializing this
struct should never have objects.

Bug: dawn:685
Change-Id: I1479b4407b0f9ec9f9b2bff62cad7caa693c99d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63983
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-13 18:49:09 +00:00
Bryan Bernhart caf6e8b3f0 Disable remap binding test on WARP.
Adds a supression to the failing test.

BUG=dawn:1106

Change-Id: Ib0cfd49b6d1af59c60d7bc4f2e3e1bec5ae80601
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64062
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2021-09-13 17:27:29 +00:00
Jiawei Shao 42448dafb4 Remove descriptor from the parameter of ComputePipeline::Initialize()
This patch removes the parameter "descriptor" in the function
ComputePipeline::Initialize() so that we don't need to define
FlatComputePipelineDescriptor right now.

For render pipeline, as descriptor->vertex is being used for vertex
pulling (passed into vertexModule->CreateFunction()), we will first
refactor the related code in vertex pulling before removing the
parameter "descriptor" in the function RenderPipeline::Initialize().

BUG=dawn:529

Change-Id: Ib172ac0c76fa24070e78c0e57c3262acad9399b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-09-11 09:04:34 +00:00
Michael Tang b21ccebac8 D3D12: Use a separate space for the index offset constants
Tint's HLSL writer can now map sets to spaces, so we can use a dedicated
space  and register to store the index offset constants. Currently, we
use the first space (0) and find a free unused register.

Bug: dawn:1103
Change-Id: Ie1fe95ec314097baf0e0952a0c78222cad493c95
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63223
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Michael Tang <tangm@microsoft.com>
2021-09-10 23:16:33 +00:00
Austin Eng 2092a66ab5 dawn_native: Add RequestDevice to the Adapter
Adds a basic RequestDevice method to the adapter, only in
dawn_native. We will revisit this when we implement adapters
in dawn_wire.

RequestDevice allows us to have tests of the limit bounds
because it receives a callback which can return status codes
and error messages.

Bug: dawn:685
Change-Id: I7a68922b078c6a436f49a16346cb41fb9df9cfee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63982
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-10 21:07:39 +00:00
Austin Eng dc7971ce58 dawn_wire: Support deserializing s->c chained structs
Chained structs *may* contain objects which means
deserialization may need an ObjectIdResolver.
However, in practice, we never need to send chained
structs from the server to the client that contain objects for
a valid command.

The one upcoming need for chained server->client structs is to
serialize limit structs.

Because limit structs never need objects, we provide a dummy
implementation of the ObjectIdResolver which always yields an error.
An analogous change is done for ObjectIdProvider.
These classes will be used in a follow-up CL.

Bug: dawn:685
Change-Id: I1c0f3f2d080377f2e1a77bc6e896f24d3d9ab931
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63981
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-10 20:36:20 +00:00
Corentin Wallez 8ee643c9d0 Remove suppression for fixed Tint issue
Bug: tint:449
Change-Id: I7a1ee41bbd149c211096d0ce84c35ab8a0f937f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63745
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-10 17:46:29 +00:00
Bryan Bernhart d9331035a6 Skip failing CopyTexture tests on WARP
BUG=dawn:1104

Change-Id: Ie4e870fd182bcf5ec0a0007317705a0555a76e0d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63980
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2021-09-10 16:09:19 +00:00
Corentin Wallez 363c28e5d1 Remove typedefs for deprecated types.
Bug: dawn:762
Change-Id: I1581d80898d4a98010bb14c5823a1a343c229664
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63383
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@google.com>
Reviewed-by: Brandon Jones <bajones@google.com>
2021-09-10 15:50:19 +00:00
Corentin Wallez d4b85fbd76 Lift suppression for incorrect VVL image layout tracking
Fixed: dawn:785
Change-Id: I618d2d44c02ae5e256841392cb2359f3992e32dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64020
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@google.com>
Commit-Queue: Brandon Jones <bajones@google.com>
2021-09-10 15:02:24 +00:00
Corentin Wallez 7a446220a1 Reenable / delete DISABLED tests.
- We use Tint unconditionally so binding reflection is now correct.
 - WGSL disallows textureSampleCompare in compute shaders and is not
   likely to change.
 - We now support reading back stencil in tests.

Bug: dawn:439, dawn:667, dawn:216, dawn:704
Change-Id: I7ba0026bb906ce985abb495581b56977da7be2da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63680
Reviewed-by: Brandon Jones <bajones@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-09-10 14:56:09 +00:00
Jiawei Shao 6fa50b5e6c Vulkan: Support extension "depth_clamp"
This patch implements the extension "depth_clamp" on Vulkan, which
we need to test if we can correctly record "PrimitiveDepthClampingState"
in FlatRenderPipelineDescriptor - Currently FlatRenderPipelineDescriptor
fails to record this because we incorrectly ignore all the members in
"nextInChain".

BUG=dawn:529, dawn:716
TEST=dawn_end2end_tests

Change-Id: Iec407245a3f37d10a3d1428b0612f0e18e80c616
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63820
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-09-10 01:33:41 +00:00
James Price 6e1f01f32b metal: Use single-entry point transform
We only remap bindings for the target entry point, so we need to strip
all other entry points to avoid generating invalid bindings for them.

Bug: tint:1170
Change-Id: Ia1a73601e8d620341fb4f7170dfa856632a04245
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63880
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-09 20:40:31 +00:00
Jiawei Shao d7ddfb4a91 Add FlatRenderPipelineDescriptor for CreateRenderPipelineAsync
This patch implements the struct FlatRenderPipelineDescriptor to
save all the pointer members of RenderPipelineDescriptor in
CreateRenderPipelineAsync so that the render pipeline descriptor
is always valid when the render pipeline is created asynchronously.

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I99e06581f84c52d484f877ba29e8cc1ca50d68b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63368
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-09-09 00:59:29 +00:00
Zhaoming Jiang c6140d5c95 Initializing stencil reference for render pass in D3D12
When creating a new render pass in D3D12, call the OMSetStencilRef
to set the stencil reference value to zero.

Bug: dawn:1097
Change-Id: I5dd94691b1b354b601c06a02d3d5fa619d8b58ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63360
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-08 02:21:33 +00:00
Loko Kung 37a8649f92 Adds ASTC texture compression formats and Vulkan support for them.
The end to end texture tests with the binary information for the textures are generated using the open source astc-encoder tool.

Also: Refactors end2end compressed texture tests to allow for non-4x4 texel compression formats (ASTC formats are not all 4x4).

Bug: dawn:955
Change-Id: I5311a5aa7bd017de72300bf7c87fba6c869b1db5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63121
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-07 18:39:04 +00:00
Jiawei Shao ba1feb07bc Always point to own members in FlatComputePipelineDescriptor
This patch fixes a use-after-free issue in FlatComputePipelineDescriptor
by always making its pointer members point to its own members.

BUG=dawn:529, chromium:1246158, chromium:1246748
TEST=dawn_end2end_tests

Change-Id: I49b98357444edcdb1b225e961d1e4d6e5b11e978
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63366
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-06 07:46:49 +00:00
Rafael Cintron 0376ebe3df Handle failed calls to ID3D12CommandQueue::GetTimestampFrequency
ID2D12CommandQueue::GetTimestampFrequency returns an error HRESULT
when there are bugs in Windows container and vGPU implementations.

To workaround, we check the return value during adapter creation
and disable the timestamp query extension upon failure.

Device creation is still allowed to succeed when the method returns
failure.

Change-Id: Ie71f8712fc9f4f50e4ce26ecfec929b5b1a126d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63225
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
2021-09-03 17:29:20 +00:00
Corentin Wallez 10b9cce816 Remove deprecated SetBlendColor and blend factors
Bug: chromium:1199057
Change-Id: I6fdc08f0a62b579b556c4c910611d095fcb3a66f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63381
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-09-03 16:37:00 +00:00
Corentin Wallez fdfbb3aab3 Add dawn_wire/client/RequestTracker.h to build files
This was missed in a previous CL.

Bug: dawn:1092
Change-Id: I1915371c6a049d8c3b503c72194e568eb7fde95c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63384
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-03 16:09:30 +00:00
Brandon Jones 8a0b49b6d6 Add check for an invalid D3D12/Vk object in SetDebugLabel
Fixes a crash found while fuzzing by returning early when SetDebugName
is called with an empty D3D12/Vulkan object or when the device is lost.
Adds tests.

Bug: chromium:1245720
Change-Id: Ie443f690cf5635d017295a13e21c33dd2e97dc46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63363
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
2021-09-02 21:15:40 +00:00
Brandon Jones c1bcbbf357 Add Labels For Pipelines and ShaderModule for D3D12/Vk
Adds labels for Pipelines and ShaderModule. Includes tests. Backend
functionality is implemented for Pipelines, and completed to best effort
for ShaderModule.

Bug: dawn:840
Change-Id: I55024a83f66d9fc2fc0e8b79e4b9a7ebc6f3cf1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62860
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
2021-09-02 18:39:53 +00:00
Corentin Wallez 71f2214e14 vulkan: wait for fences on ErrorInjector device loss
When ErrorInjector injects a device loss, it is fake and commands are
still running on the device and we need to wait for them before we start
to deallocate stuff.

When handling the error in the frontend, call WaitForIdleForDestruction
so that all the commands are finished. In the Vulkan backend
WaitForIdleForDestruction have a special code path to no allow error
injection on vkWaitForFences in this specific case, as double error
injection would make the problem appear again.

Bug: chromium:1244408

Change-Id: I710fccbb40b4b14d84f5787be5e002b469e6e2e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63101
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-09-02 17:23:18 +00:00
Stephen White c0f20fbc54 Remove all "WithTint" suffixes from Dawn native.
The D3D12 and Metal backends no longer support any other
shading language translator, so the suffix is superfluous.

Bug: dawn:1099
Change-Id: I6a1a249a80d59dbf9cabf5d4ea917f852745e78e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-09-02 16:50:58 +00:00
Jiawei Shao 305f4df2b5 Add FlatComputePipelineDescriptor for CreateComputePipelineAsync
This patch implements the struct FlatComputePipelineDescriptor to
save all the pointer members of ComputePipelineDescriptor in
CreateComputePipelineAsyncTask to better simplify the orignal code
path.

We will also implement FlatRenderPipelineDescriptor in the next
patch, which is more important for CreateRenderPipelineAsync as
there are many more pointer members in RenderPipelineDescriptor
than those in ComputePipelineDescriptor.

BUG=dawn:529

Change-Id: I69ab0dc898f0a6dcc9886d827729e6fd7308bd2d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63280
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-09-02 00:30:31 +00:00
Brandon Jones 1f48c97353 Update default pipeline layout compatibility rules
Prevents bind group layouts created by a default pipeline layout from
being reusable with any other pipelines or layouts, as detailed in
https://github.com/gpuweb/gpuweb/pull/2068

Change-Id: Ic398eb6c6e089ac63ce6650f125dd20a9dfc8862
Bug: dawn:1094
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63220
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-01 22:15:41 +00:00
Corentin Wallez baf8df396c dawn_wire/client: Add RequestTracker helper
This helper helps ensure correct handling of request maps by:

 - Forcing erasing to happen immediately when acquiring a request. This
   prevents some cases of iterator invalidation if we later change the
   container type.
 - Implements correct closure of all callbacks, including if the
   callbacks themselves add more callbacks.

Bug: dawn:1092

Change-Id: Ia0ba9f050bbf3f0dee846f537910523bebb3bf1b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63003
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-09-01 16:40:22 +00:00
shrekshao 3fdfa82f7b Callback reentrancy tests
Some tests to make sure new requests inside user callback
is okay.

Bug: dawn:1091
Change-Id: I4c53d7fb6637f77e5af6fd0a78d879a2431d4ac8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63041
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-08-31 15:18:54 +00:00
Jiawei Shao 67fc6aeb82 Remove redundant code in CreateRenderPipeline
This patch removes the redundant code in CreateRenderPipeline so
that we can better share the common code in both CreateRenderPipeline
and CreateRenderPipelineAsync.

BUG=dawn:529

Change-Id: Ic2a7781525e5594da3d51a42b231df63c0c09339
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-08-31 07:47:57 +00:00
Loko Kung c7226a7624 Adds ETC2/EAC texture compression formats and Vulkan support for them
The end to end texture tests with the binary information for the textures are generated with a combination of the open source etc2comp tool and manual crafting of the data based on the specification in the Kronos Data Format Specifications (https://www.khronos.org/registry/DataFormat/specs/1.1/dataformat.1.1.pdf) for the compressed formats.

Also: Refactors end2end compressed texture tests and some utilities so that we can use parameterized tests for easier new format additions.

Bug: dawn:955
Change-Id: I91686f26a693a85cb076ef0eca3029111a64c50f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62740
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-08-31 00:15:45 +00:00
Corentin Wallez 6bb3f6f216 vulkan: Free "in flight" fences/commands in ShutdownImpl
There might still be fences and commands marked as in-flight in
ShutdownImpl if the device was lost. Delete them anyway because since
the device was lost, it means that all objects are no longer in the
"pending" state (from the Vulkan spec point of view)

Bug: chromium:1244454
Change-Id: I905a9a8e5174591bf93e3cdac3cdcb349d75a581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63102
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-30 20:01:04 +00:00
Corentin Wallez 52ad8f6768 client: call pending GetCompilationInfo on Disconnect
Fixed: dawn:1090
Change-Id: Ia7cf692ea41ebe85aaac58e3f3aa6727e6cc8ba4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63002
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-08-30 08:00:45 +00:00
Corentin Wallez 378ea27f39 Remove stray reference to GetDefaultQueue
Bug: dawn:22
Change-Id: Ia5c1f552317d9c35a9c09fe4e0684593cee9cacf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62940
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-08-27 07:51:00 +00:00
Li Hao c31b16f5dc Check Query API feature support by GPU counter on Metal
Currently we use gpu family to determine whether a query extension is
supported. The official document provides a way to check the feature
support by GPU counter. Update checking following the official guide.

Bug: dawn:996
Change-Id: I09cf51ed8a8209642eed71c9e4592f6eab82bfa5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60360
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-27 04:20:21 +00:00
James Price 086c44ee73 Add missing includes to SemaphoreService.h
These are needed for the VulkanDeviceInfo and VulkanFunctions structs.

Change-Id: I1d18e59cd923e5fd702ac65d505793519b3a42b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62920
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-26 17:17:35 +00:00
Corentin Wallez 21940df81b Device: Mark all commands as completed on device loss
Previously device loss would produce an assert when shutting down where
the frontend though not all commands where finished.

Bug: chromium:1242195
Change-Id: I90fe626b6930859b3fd98b660882fb11b6a9ff8c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62542
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-08-26 09:25:15 +00:00
Jiawei Shao 2aee6eef7f Refactor APICreateRenderPipelineAsync to support sync and async path
This patch refactors the implementation of APICreateRenderPipelineAsync
as a preparation of the async path of the creation of render pipeline.

Now the code path of APICreateRenderPipelineAsync() includes the
following 3 parts:
- When an error occurs in the front-end validations, the callback will
  be called at once in the main thread.
- When we can find a proper render pipeline object in the cache, the
  callback will be called at once in the main thread.
- When we cannot find the proper render pipeline object in the cache,
  the newly-created pipeline object, the callback and userdata will be
  saved into the CreatePipelineAsyncTracker, and the callback will be
  called in device.Tick(). All the logic mentioned in this section has
  been put into one function CreateRenderPipelineAsyncImpl(), which will
  be overridden by its asynchronous version on all the backends that
  support creating pipeline objects asynchronously.

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I5706224092588a8c042a952aef2591696072592d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62781
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-08-26 00:39:14 +00:00
Zhaoming Jiang 6fa34f80bd Adding VB OOB validation for zero array stride
In this patch OOB validation in draw and drawIndexed is added for vertex
buffer with zero array stride. For such case, both vertex step and
instance step mode buffer can be validated for both draw and drawIndexed,
as we don't care about actual vertex count and instance count for buffer
with zero array stride.
Related unit test is also added. Also fix the DrawIndexedVertexBufferOOB
unit test.

Bug: dawn:1065
Change-Id: Id302dc0c443dec965347c8ae9f3f4d73aeddc38c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62200
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2021-08-25 01:30:03 +00:00
Loko Kung c1d395865f Adds placeholders for ETC2/ASTC compression texture format
Compatible Vulkan backends should now enable ETC2/ASTC but no functional
changes because no TextureFormat in ETC2 or ASTC have been added yet.

Bug: dawn:955
Change-Id: I56e8ff73f931a12253fe6d21f3f4b91e3459ef13
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62701
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-25 00:53:42 +00:00
Austin Eng 20ffe9712f Fix a bug with D3D12 buffer alignment computation
We should use D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT
if the usage *contains* Uniform usage, not if it is exactly
equal.

Fixed: dawn:1085
Change-Id: I540081e550c9e88efeb08169cecdc40b68d36d14
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62242
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-08-24 01:52:03 +00:00
Brandon Jones 5ae66fbcc7 Add Tag for Unimplemented Labels to ObjectBase Constructor
Adds the LabelNotImplemented tag param to the main constructor of
ObjectBase to document objects that still require labels.

Bug: dawn:840
Change-Id: Idd19664e797e4d622401e28e5d278331acefb7a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62461
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
2021-08-23 23:14:36 +00:00
Corentin Wallez da230e5e5c Remove typedefs for passed deprecations
Bug: None
Change-Id: I922fc4b1149c94f891692e6961423162a5a131e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62360
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-08-23 10:10:11 +00:00
Brandon Jones c95e574ce0 Add Debug Label Functionality For D3D12/Vk Buffers & Textures
Adds a generic SetDebugName utility for D3D12 and Vulkan. Passes down
debug label set by user for buffers and textures to be labeled by the
appropriate backend method.

Bug: dawn:840
Change-Id: I7158b537a6e37fdf733645e6830dc33833ee683e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61588
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
2021-08-19 20:47:28 +00:00
Austin Eng ddd0a0a856 Initialize padding on buffer allocations
Buffer allocations in Dawn may be padded. This padding
could be visible, depending on how the backend
implements robust vertex buffer access. This commit
updates buffer creation to clear all padding bytes
immediately after creation.
It is not counted as a lazy clear.
And, add a test which reads off the end of a padded
vertex buffer to check that the padding bytes are also
initialized.

Also: Update Metal buffers to always allocate enough
space for Tint's vertex pulling, and pass the full
allocated size to Tint. While writing the test in this
commit, a bug was found where Tint assumes there is at
least 4 bytes in the vertex pulling buffer. The WebGPU
API currently allows zero-sized bindings, so Dawn needs
to always allocate enough space for one element.

Also: Update Vulkan vertex/index buffers to allocate
at least one more byte than requested because
vkCmdSetVertexBuffers and vkCmdSetIndexBuffer disallow
the offset to be equal to the buffer size. We need
at least one more byte to make zero-sized bindings
as the end of the buffer valid.

Lastly: Update helper so that a T2B copy of a single
row that touches all bytes in a buffer updates the
buffer state to be fully initialized. This is a small
optimization that is necessary to write the test.

Bug: dawn:837
Change-Id: I829f4764509c4ec784c5aeaaf40b6dcbd4be6866
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62161
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-08-19 18:02:36 +00:00
Michael Tang 663a16e2fe D3D12: use the WGSL binding number as shader register
Currently, the bind group layout tightly packs the shader registers for
each of the sampler and non-sampler descriptors sets. This reduces the
max shader register used and helps targeting shader model 5.0, which has
a relatively low max slot count per resource. It is safe in D3D, since a
shader register collision can be valid if the descriptor types differ.

To support Mesa's SPIR-V to DXIL compiler, we need to avoid possible
collisions between resources' shader registers because it uses SPIR-V as
an intermediate representation (which does not namespace bindings by
type). This change re-works BindGroupLayoutD3D12 to not assume the
resulting shader registers will be tightly packed and group per
descriptor type.

Change-Id: I0bb51106c4683bfe02ce15ecad71716734b7a91f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60764
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Michael Tang <tangm@microsoft.com>
2021-08-19 17:17:26 +00:00
Michael Tang 71d7c2e670 D3D12: Include serializer error messages in pipeline layout creation
Currently, Dawn ignores the output of D3D12SerializeRootSignature. This
change adds these error messages to the the CheckHRESULT context.

Change-Id: Ieeb63d7b5408ca1bc9e4ab97d777f764cdf06664
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62163
Commit-Queue: Michael Tang <tangm@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-18 00:36:37 +00:00
Stephen White 8d1ead6393 Remove unused SPIRV-Cross shader reflection bits.
The only part of mGLEntryPoints actually used is the bindings, so
replace ShaderModuleGL::mGLEntryPoints with mBindings.
This required extracting BindingInfoArray from EntryPointMetadata,
making it visible in the dawn_native namespace.
Remove all non-bindings-related reflection, and MSL-specific checks
and workarounds.

Bug: dawn:1076
Change-Id: I05657c0c89f5d8a2185e55f9ad7c8f81d89a8e60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-08-17 20:50:36 +00:00
Brandon Jones e1bdfa8d32 Remove deprecated depth texture sampling path
Removes deprecated path for sampling depth textures with
float/unfilterable-float. Attempting to do so now results in a
validation error.

Bug: dawn:1021
Change-Id: I112f45e7227ab1caaf0d6ed203194295e7022db2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61861
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-08-16 19:55:00 +00:00
Corentin Wallez e53a7cc874 Fix CMake build on macOS
Fixed: dawn:1061
Change-Id: Ie4208f32e9403220d78601ebefcc62c2c44c3485
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62040
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-16 15:32:52 +00:00
shrekshao 5486a2fba5 Remove some validation for alpha.src/dstFactor
Validation rules revised at
https://github.com/gpuweb/gpuweb/issues/2013#issuecomment-897364617

Bug: dawn:1063
Change-Id: I8ae1cd00f75c8049206a8c5f6fcdb879e1b6a469
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61821
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-08-13 00:08:50 +00:00
Bryan Bernhart 31f039350b D3D12: Cache DXGI keyed mutexes on the external image.
Maintains a 11on12 resource cache on the external image
to prevent re-creating the wrapped resource then
flushing it per produced texture. To prevent
unbounded growth, a basic cap is used which gets
cleared.

This change fixes signficant CPU time spent in the WebGPU command
decoder for video import workloads and excessive memory overhead
from swap chain buffers.

Fixed: dawn:625

Change-Id: I72c07b02f6ab6877a9f21758650962c895933bf9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51421
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-08-12 23:32:49 +00:00
Juanmi 633bb68c6b Reland "Making D3D12 accept InternalUsageDescriptors"
This is a reland of 365d40b93a

Original change's description:
> Making D3D12 accept InternalUsageDescriptors
>
> This is a follow up from two previous CLs,
> https://dawn-review.googlesource.com/c/dawn/+/58440
> and
> https://dawn-review.googlesource.com/c/dawn/+/58140
>
> This CL adds in the D3D12Backend the possibility to use Dawn Texture
> Internal Usage Descriptor, and adds a series of tests to validate it.
>
> Change-Id: I94f6b39153b60ec8af61bda22d41a865898da613
> Bug: dawn:1027, dawn:1052
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61520
> Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

Bug: dawn:1027, dawn:1052
Change-Id: I0d35cbf4dc1c6dc80e1a5dfb4770a5383ef543fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61840
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
2021-08-12 20:17:39 +00:00
Bryan Bernhart 0d6da1072c Fix ASSERT setting staging buffer label
Ensures the mapped staging buffer will
always be locked before setting the label.
Otherwise, setting the label could fail
and leave it unlocked which isn't
allowed.

BUG: chromium:1239112
Change-Id: I738f8d6fc3b20b8c8b51671d77e7014d967ffd52
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61860
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2021-08-12 19:46:18 +00:00
Austin Eng 39c4fcbdd3 Revert "Making D3D12 accept InternalUsageDescriptors"
This reverts commit 365d40b93a.

Reason for revert: Broke the ChromeOS build in the Dawn roll.
https://chromium-review.googlesource.com/c/chromium/src/+/3090302

Original change's description:
> Making D3D12 accept InternalUsageDescriptors
>
> This is a follow up from two previous CLs,
> https://dawn-review.googlesource.com/c/dawn/+/58440
> and
> https://dawn-review.googlesource.com/c/dawn/+/58140
>
> This CL adds in the D3D12Backend the possibility to use Dawn Texture
> Internal Usage Descriptor, and adds a series of tests to validate it.
>
> Change-Id: I94f6b39153b60ec8af61bda22d41a865898da613
> Bug: dawn:1027, dawn:1052
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61520
> Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=kainino@chromium.org,enga@chromium.org,juanmihd@chromium.org,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I11b246f38505df23a6c61e851d6d90e34c8d1287
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1027, dawn:1052
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61820
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-12 17:05:21 +00:00
Juanmi 365d40b93a Making D3D12 accept InternalUsageDescriptors
This is a follow up from two previous CLs,
https://dawn-review.googlesource.com/c/dawn/+/58440
and
https://dawn-review.googlesource.com/c/dawn/+/58140

This CL adds in the D3D12Backend the possibility to use Dawn Texture
Internal Usage Descriptor, and adds a series of tests to validate it.

Change-Id: I94f6b39153b60ec8af61bda22d41a865898da613
Bug: dawn:1027, dawn:1052
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61520
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-12 15:35:48 +00:00
Stephen White 1935043d35 Fix CMake build.
SpirvUtils.* are now in the dawn_native/opengl/ directory.

Bug: dawn:1067

Change-Id: I9cfb7ee52ec1f4ac321cb03978008843e33f82c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61680
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-12 15:24:48 +00:00
Austin Eng 8e402bc4c5 Suppress flaky CopyTextureForBrowserTest on Win Vulkan Intel
Bug: dawn:1070
Change-Id: Ic5dc1b334e4b006594ee950bf508057361e821bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61720
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2021-08-12 15:16:14 +00:00
Austin Eng eda73e3c4e Validate SPIRV produced by Tint
The now-removed SPIRV-Cross path used to always do this, and the
pure Tint-only path never actually validated the SPIRV. Tint
does not run SPIRV-Tools validation on its output, so add in
validation to ensure we don't pass invalid SPIRV to the driver.
The validation can probably eventually be removed when we're more
confident that Tint's SPIRV output is always correct.

Also include various cleanups for old / unused code.

Bug: dawn:1036
Change-Id: Iaab037518965e52edbd1829f6ab6ba2af0e70143
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61589
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Auto-Submit: Austin Eng <enga@chromium.org>
2021-08-12 05:20:48 +00:00
Austin Eng 5bed1ed838 More spirv-cross related removal
Bug: dawn:1036
Change-Id: Ia60c71558bd2c47a6b7148d86b8dcedfaa79ba89
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61585
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-11 21:15:26 +00:00
shrekshao 4f2edf576e Add validation for fragment output and attachment interface matching
Validation rules discussed at
https://github.com/gpuweb/gpuweb/issues/2013

Bug: dawn:1063
Change-Id: I264eecb7c548f29975e5459a7ad020105acab634
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61383
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-11 21:12:36 +00:00
Austin Eng 38534b6e74 D3D12: Only set the root signature when bind groups are applied
Dawn only reapplies bind groups that have changed on the layout
since the last draw. However, the D3D12 backend was always resetting
the root signature state upon switching pipelines. This led to a
bug where the root signature could be changed and dirtied without
reapplying the dirty bind groups.

Moving application of the root signature state to the same loop
that applies bind groups helps ensure the state stays in sync.

Fixed: dawn:1055
Change-Id: Iae89088560e83f6104c921d42de27c03095d654f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61582
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
2021-08-11 18:44:59 +00:00
Austin Eng e02bb36a2a Avoid [MTLDevice sampleTimestamps] unless the extension is enabled
This callsite was missed in a previous CL:
https://dawn-review.googlesource.com/c/dawn/+/59041

Bug: chromium:1226078
Change-Id: I3829dc16a8ec3c7b7274bc6057030bdade598ade
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61584
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-11 15:36:35 +00:00
Austin Eng 9978b2f742 Add Adapter::SupportsExternalImages
This commit adds a getter so that Chromium can check whether an
Adapter would support external images. External images are
necessary to implement the WebGPU swapchain and interop with the
rest of the web platform. We should not expose adapters that
cannot interop with the canvas and other web platform primitives
until WebGPU gains options to request more "limited" adapters.

Bug: dawn:1056
Change-Id: Iff83ac26b0e92dccdd4e29c0d854d9276a4a37bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61580
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Brian Ho <hob@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-11 14:27:55 +00:00
Stephen White bcbe2e0c94 Move SPIRV-Cross functions into OpenGL backend.
Since the other backends no longer need it, move all of the
utility functions specific to SPIRV-Cross into the OpenGL backend.
This obviates the need for the DAWN_USE_SPIRV_CROSS define, so remove it.

Bug: dawn:1036

Change-Id: I67bb5a85dc128a6f343d09876046cf559395e05f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61541
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-08-10 22:04:33 +00:00
Stephen White 5d17ed6541 Wrap all uses of SPIRV-Cross in #define.
Put all cross-platform code references to Spirv-Cross behind
ifdef DAWN_USE_SPIRV_CROSS. Hide build dependencies behind
dawn_use_spirv_cross, which itself is set from dawn_enable_opengl,
since it is the only backend which is still using SPIRV-Cross.

Bug: dawn:1036

Change-Id: Id61512230b50a32c63827a16fece40d7899968d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61400
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-10 18:30:55 +00:00
Stephen White ebbbcc7ecb Remove SPIRV-Cross support from D3D12 backend.
Bug: dawn:1036

Change-Id: If447f93f7a17ecfe73f04605a60893edb00990d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61402
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-10 14:51:27 +00:00
Brandon Jones 27e17a6aad Update deprecated TextureUsage flag names
Older names are kept around as an alias for a while. Unfortunately we
have no mechanism for producing deprecation error messages when they
are used.

Bug: dawn:1035
Change-Id: Ic6716fd526ecbedaa8e7925ab93e3ff32f642d97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61382
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-08-10 04:07:37 +00:00
Jiawei Shao f99d5aa7d4 Remove a useless comment
This patch removes the comment about adding "interpolationType" and
"interpolationSampling" to InterStageVariableInfo as they have already
added before. Sorry that we forgot to remove it in the PR of adding
these two members to InterStageVariableInfo.

BUG=dawn:802

Change-Id: Ib2f3769f2dc1c8152280a28aad77bf90abf76608
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61384
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-10 03:42:44 +00:00
Stephen White a03e847227 Remove SPIRV-Cross support from Vulkan backend.
Bug: dawn:1036

Change-Id: I463d067af03fbcd732402fd0e0cc7045669e13b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61220
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-10 02:56:03 +00:00
Bryan Bernhart c61a24b5fd D3D12: Fix crash from non-initialized adapter.
If the Adapter failed to create a D3D device, it would
attempt to access it on destruction causing the
process to crash.

Bug: dawn:460
Change-Id: I3f13043e8049cd71806ee54efa92c70e26561580
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61300
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2021-08-09 17:46:03 +00:00
Michael Tang ed9681c921 dawn_native: Fallback sorting bindings in BindGroupLayout to use the binding number
This helps us merge contiguous descriptor ranges in https://dawn-review.googlesource.com/c/dawn/+/60764

Change-Id: I772262b117087ec1f1d744596be2585a5996325f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60765
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Michael Tang <tangm@microsoft.com>
2021-08-06 22:39:21 +00:00
Jiawei Shao 8d8fadbbe4 Validate MaxInterStageShaderComponents when creating shader module
According to the discussion[1], the sum of all the user-defined
inter-stage component count and all the inter-stage builtin component
count should be no more than MaxInterStageShaderComponents (currently
in Dawn it is always 60).

[1] https://github.com/gpuweb/gpuweb/issues/1962

BUG=dawn:1032
TEST=dawn_unittests

Change-Id: Id5266b72b89c48f5b7073b8307f8f2c0512c8a33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61104
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-06 20:57:18 +00:00
Austin Eng 93011d0305 Set the Tint MSL emit_vertex_point_size option when necessary
If [[point_size]] is not emitted, it is undefined. Set the option for
Tint to explicitly set it to 1.0 when necessary.

Bug: dawn:1059
Change-Id: I27c19e88cda30aef0a8f31b213c58d5bf87feabd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61280
Commit-Queue: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-08-06 18:19:38 +00:00
Austin Eng 567e071b5b Free VkCommandPool if vkResetCommandPool fails
Bug: chromium:1234680
Change-Id: If8f5c2dc0cdf14bf8a0c713d724b883657bd1463
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61103
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-08-06 16:16:20 +00:00
Brandon Jones 9096fc290f Remove createRenderPipeline2 and GPURenderPipelineDescriptor2
Blocked on:
https://chromium-review.googlesource.com/c/chromium/src/+/3075622
https://skia-review.googlesource.com/c/skia/+/437076

Change-Id: I49773b422c0fda7c752b90c341e5a9f243fc0b36
Bug: dawn:751
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61101
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-08-06 03:58:50 +00:00
Stephen White 6ab06f8881 Remove SPIRV-Cross usage from Metal backend.
Change-Id: I456b6cc660779175afc73bbef5134fbcf4988ad3
Bug: dawn:1036
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60900
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-08-06 01:24:59 +00:00
Juanmi f00c68a216 Adding APICopyTextureToTextureInternal
This CL adds an internal method to copy textures, that will disregard
the need of having CopySrc usage.

This CL adds an intermediate helped method to be used by both
APIContextTextureToTexture and APIContextTextureToTextureInternal.

Fixed: dawn:1052
Change-Id: Icd28e0ef58ecfaa412eefe8c95e41cd2298a9acc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58440
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
2021-08-05 22:55:09 +00:00
James Price 565863e954 Fix linker error with iOS build
The IsMacOSVersionAtLeast() function is only defined on macOS, but was
being used on all Apple platforms.

Change-Id: Ie5e37fb8e408f424e55795327cca7f2a345bfdfa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61120
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-08-05 20:35:19 +00:00
Austin Eng 6c6707021a Add Buffer::GetAllocatedSize()
Buffer allocations may need padding based on backend requirements.
GetAllocatedSize returns the size of the buffer actually allocated.

This CL also updates the backends to use GetAllocatedSize for buffer
clearing and barrier operations which should operate over the
entire allocated resource.

Bug: dawn:1011
Change-Id: Ic5233214414fa090725a4f50fff70d6e178494c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60701
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-05 15:26:58 +00:00
Aleksi Sapon fef90b8a4a Fix bind groups not being applied
Fix for crbug.com/dawn/1049, where setting a pipeline without drawing can
prevent bind groups from being applied later. This occurs because the mask
for the pipeline is being saved but not its layout, because the bind
groups are never applied. This changes to only save the mask if the bind
groups are applied (the pipeline is used in a draw or dispatch).

Bug: dawn:1049
Change-Id: I4c7ae1125d1b6a06af90aea49a9dd1e4883f4826
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60740
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-05 14:45:48 +00:00
Austin Eng ae840d5e61 D3D12: Check for device lost after ID3D12Fence::GetCompletedValue
The D3D12 docs say it returns UINT64_MAX if the device was removed

Fixed: dawn:1051
Change-Id: Ide3731e9389bdb4a5a81c9f65aa9bcad1b049446
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60961
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-05 14:02:49 +00:00
Bryan Bernhart 18bc89ee62 D3D12: Enable D3D12 debug names in Dawn builds.
Labels GPU allocations by Dawn resource type so we
can debug GPU memory consumption given traces or
full memory dumps.

BUG=dawn:967

Change-Id: I7eb19b4f2f9dd4c55c9039d39ffec9f09461556f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60620
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2021-08-04 21:52:29 +00:00
Austin Eng b5e2089768 Hook up dump_shaders toggle to dump SPIRV and GLSL
Bug: none
Change-Id: I742067d70bac5b43afe38d8d39b5eb2dae647a74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60960
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-04 21:11:19 +00:00
Ben Clayton 5c19bf25e3 metal: Fix stray '\' prefix on MSL shaders
Seems harmless, but I'm assuming it was not intentional.

Change-Id: I86875f8bbe5923435b4c02cd224197ec2dc6f3a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60924
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-04 20:44:18 +00:00
Austin Eng 8ec325cfc6 Fix VVL error when creating a bind group from a destroyed texture
Fixed: dawn:1043
Change-Id: Ibc91361a984cd5d51d192d130206c20d620dff9a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60641
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-03 21:48:59 +00:00
Austin Eng 8e957160b1 Use Tint SingleEntryPoint transform in Vulkan/GL backends
Some Vulkan drivers don't handle multiple entrypoints well.
In addition, SPIRV-Cross translation can be wrong for
shader modules with multiple entrypoints. Always emit a single
SPIR-V entrypoint to workaround these issues.

This allows updating CopyTextureForBrowser to use a single
shader module, and it fixes some tests with multiple
entrypoints.

Fixed: dawn:948, dawn:959, dawn:1013
Change-Id: Ie129a32a54845316d11917331937ca44fba3d347
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60640
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-08-03 19:07:29 +00:00
Austin Eng a0b92db396 Unsuppress tests failing from crbug.com/dawn/978
Tests are no longer failing.

Fixed: dawn:978
Change-Id: I60f19935bf81e3249c94f0d8b8dcfd7de52e47fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60700
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-08-03 15:29:38 +00:00
Jiawei Shao b7c7f62829 Implement inter-stage variable matching rules - Part II
This patch implements the inter-stage variable matching rules on
the interpolation attributes ('interpolation type' and
'interpolation sampling'). WebGPU SPEC requires that the interpolation
attributes must match between vertex outputs and fragment inputs with
the same location assignment within the same pipeline.

BUG=dawn:802
TEST=dawn_unittests

Change-Id: Ied38d68f73868c30b0392954683963a801e3f3aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60160
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-30 00:40:26 +00:00
Austin Eng da3c5ef3a9 Allow creating texture views from destroyed textures
Bug: dawn:1031
Change-Id: I3af52d5c53c4ccf2c30a4eccb9c50dfe2e822f25
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60221
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-29 21:49:47 +00:00
Austin Eng d05777bd2f Support multisampled depth texture bindings
Adds support for processing texture_depth_multisampled_2d bindings
reflected from Tint, and also removes Dawn restrictions against
multisampled depth. These restrictions were originally added in
https://dawn-review.googlesource.com/c/dawn/+/30240 to validate
against using a multisampled depth texture with a
comparison sampler. This is now disallowed by the language with
distinct binding types and builtins in WGSL. Previously with
SPIR-V, we inferred Depth if the texture was used
with a comparison sampler.

Also check Vulkan limits for supported sample counts.

Bug: dawn:1021, dawn:1030
Change-Id: I7233b16c14dc80d10a851cc4e786d5b05512b57a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-29 08:06:07 +00:00
Corentin Wallez 52201303f3 Deprecate readonly storage textures
Bug: dawn:1025
Change-Id: Ie799507b534d983959d44b573436bb5421162150
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59841
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2021-07-28 18:00:56 +00:00
Li Hao 366c9d8c43 Skip noop dispatches on D3D12 backend
Execution warning is produced from D3D12 validation layers for noop
dispatches, which leads to device lost. The skip noop dispatch handling
was added to the front-end before, and moved to Metal backend due
to it gets in the way of a validation change in the follow-up CL. We
also need to add it to D3D12 backend now.

Bug: dawn:1028
Change-Id: I364f6f1e0ac79679a43c064cb402874f1e959537
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59960
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-07-28 05:00:26 +00:00
Jiawei Shao 9d92f31f21 Vulkan: Enable sampleRateShading for WGSL builtin variable [[sample_index]]
This patch enables VkPhysicalDeviceFeatures.sampleRateShading as is required
by the SPIR-V Capability (SampleRateShading) for the implementation of
WGSL built-in variable [[sample_index]] (gl_SampleID). Without enabling
smapleRateShading on the creation of VkDevice the Vulkan validation layer
will generate below error message:

Warning: Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01091 ]
Object 0: handle = xxx, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xa7bb8db6 |
vkCreateShaderModule(): The SPIR-V Capability (SampleRateShading) was declared,
but none of the requirements were met to use it. The Vulkan spec states: If
pCode declares any of the capabilities listed in the SPIR-V Environment appendix,
one of the corresponding requirements must be satisfied.

BUG=tint:471, dawn:802
TEST=dawn_end2end_tests

Change-Id: Id0c91fa48dfae37b2548ee9f3922d93dfa1da5d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-07-28 00:36:36 +00:00
Austin Eng d6af6bd7f3 Deprecate sampling depth textures with float/unfilterable-float
Dawn currently allows sampling depth textures this way, but it is
not in the WebGPU spec, and the behavior is not guaranteed with the
Metal API.

This commit also updates the stencil sampling tests to expect
(s, s, s, s) or (s, 0, 0, 1).

Bug: dawn:1021
Change-Id: I9210a2a3ff1655747a202a51f46f38faa35c85d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59320
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-27 22:08:32 +00:00
Austin Eng 0eff5987f0 Add chained DawnTextureInternalUsageDescriptor
This chained struct can be used for internally adding usages to
Dawn textures. It will affect how the texture is allocated, but
not affect frontend validation.

One use case for this is so that Chromium can use an internal
copyTextureToTexture command to implement copies from a WebGPU
texture-backed canvas to other Web platform primitives when the
swapchain texture was not explicitly created with CopySrc usage
in Javascript.

Usage:

wgpu::DawnTextureInternalUsageDescriptor internalDesc = {};
internalDesc.internalUsage = wgpu::TextureUsage::CopySrc;

wgpu::TextureDescriptor desc = {};
// set properties of desc.
desc.nextInChain = &internalDesc;

device.createTexture(&desc);

Fixed: dawn:1027
Change-Id: Id4d08b5588d4960d150d559aa11502c69f40a674
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58140
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-27 19:59:58 +00:00
Peter Kasting 7e50a7fad3 Enable -Wunused-but-set-variable.
Bug: chromium:1203071

Change-Id: I73e58baa9a581bfc72f191184998d68dba9941d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59720
Auto-Submit: Peter Kasting <pkasting@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-27 18:42:59 +00:00
Austin Eng ce15395190 Fix WGSL usage of "let"
Bug: none
Change-Id: If2e1617bc17192880aff88d8f4a52315be593553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-27 07:51:26 +00:00
Li Hao 6e5b080547 Improve buffer zero-initialization in resolveQuerySet on Vulkan
Simplify the buffer clear logic, and tolerate clear twice when resolving
unavailable queries if the destination buffer is not initialized and not
fully written.

Bug: dawn:973

Change-Id: Iaaf16acfd789787cb2f3eb18cd324c60d5f720b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59680
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-07-27 01:22:29 +00:00
Austin Eng 821b1cbf96 Validate that the color write mask is zero if there is no fragment output
Following spec change https://github.com/gpuweb/gpuweb/pull/1918

Fixed: dawn:962
Change-Id: I9d7eaee588301227736cf523bec46e5a60fe861b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59042
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2021-07-26 19:43:19 +00:00
Corentin Wallez 4840b8a518 Replace use of deprecated tint::transform::InputStepMode
Bug: dawn:1023
Change-Id: Ic5b0db7fc4a516077a62420cd97dcb09d30ee534
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59780
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-26 19:04:58 +00:00
Li Hao d812d57739 Update resolveQuerySet for unavailable queries on D3D12
Now resolving unavailable queries is undefined behaviour on D3D12, it
might cause device hangs or removal. Update to just resolve available
part like Vulkan did, and clear the destination buffer to 0s for the
unavailable part.

Bug: dawn:973

Change-Id: I7cf6808d67179425b4883e8847c76daaf8444dc2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-07-26 14:34:47 +00:00
Jiawei Shao c686a6a541 Implement inter-stage variable matching rules - Part I
This patch implements the inter-stage variable matching rules on
the attributes 'location', 'base type' and 'composition type'.

In the next patch we will implement the matching rules on the
'interpoliation type' and 'interpoliation sampling'.

BUG=dawn:802
TEST=dawn_unittests

Change-Id: Ic0a273e01dced301d437add83bad3d0c7d94a133
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58363
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-07-26 01:39:21 +00:00
Corentin Wallez ff6c9ca6f0 wgpu::InputStepMode -> VertexStepMode
See https://github.com/gpuweb/gpuweb/pull/1927

Adds a typedef to make a gradual deprecation.

Bug: dawn:1023
Change-Id: Ic81a933a95556fbf5726056530788dde017a1449
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59442
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-25 18:40:19 +00:00
Li Hao 7839647a23 Disable Timestamp Query on macOS 11+
Bug: dawn:940
Change-Id: I74f5f3814dd4eb8b3b025f32ba1eb56a197cfec2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59480
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-23 18:59:47 +00:00
Corentin Wallez 21528281fd D3D12: Fix order of Tint transforms
FirstIndexOffset must happen after BindingRemapper otherwise some
invalid AST is produced after FirstIndexOffset.

This was found running a CTS test on Windows:
validation,vertex_state:vertex_shader_type_matches_attribute_format

Also adds a regression test.

Bug: dawn:1014

Change-Id: Icbe4b3adb5e5844ffc8435e0e67056c7dff23970
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-07-23 15:49:47 +00:00
Corentin Wallez 9bb32ba330 Make vertex attrib offsets require min(4, formatSize)
Bug: dawn:1010
Change-Id: Ib7e7fe7f9fb7fbf1a7701b72ed5a1c75d5c01209
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59282
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-23 14:28:47 +00:00
Yang Gu a314f0963a Use last 2 fields as Intel graphics driver build number
After discussion with driver team, there is no need to differentiate new
driver and legacy driver for build number, so the last 2 fields are used
consistently.

Bug: None
Change-Id: I43ac2b484f84ed209d46dd9283830930908b05ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59121
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yang Gu <yang.gu@intel.com>
2021-07-23 06:48:00 +00:00
Austin Eng 01ceccb1eb Disallow timestamp query creation if disallow_unsafe_apis
Bug: chromium:1226078
Change-Id: I567522c5562d8cba616ef4315c91a0420d5146d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59044
Reviewed-by: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-22 18:13:00 +00:00
Corentin Wallez e9c8225f54 Implement render pipeline vertex format base type validation.
Bug: dawn:1008

Change-Id: I04d1ff1d46c1106147a8c50415c989db5789cbfc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59031
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-22 11:43:10 +00:00
Corentin Wallez 1384e8b163 Replace VertexFormatUtils with a dawn_native table of formats
This replaces multiple switches with a single indexing into a data
table, and also adds information about the VertexFormatBaseType for
later validation.

Bug: dawn:1008
Change-Id: Ic3f564b0dc571cc0008a54785613f962ce223452
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59030
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-07-22 08:57:29 +00:00
Ken Rockot 2d41f8c1df Enforce per-dimension dispatch size limits
Note that this is for direct dispatch calls only. Indirect dispatch
calls are still not validated.

Bug: dawn:1006
Change-Id: I061c15208a01dfb803923823ba4afd38667cad22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59122
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
2021-07-21 20:44:09 +00:00
Ken Rockot 59668e95c7 Validate workgroup size and storage requirements
We define hard limits on these attributes for compute stages. This
enforces them.

BUG: dawn:322
Change-Id: I9b279774e877b5d40d912cb9f812f23d61c20a42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56806
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-21 20:19:20 +00:00
Austin Eng e50f8c65b7 Skip BufferZeroInitTests.ResolveQuerySet if not on MacOS 10
Bug: dawn:940
Change-Id: I830cebf2247b65ea0be58a10e02fbcc0542ff73b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59040
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-21 18:34:19 +00:00
Brian Ho 4d94647e1f Vulkan: Export VkSemaphores as SYNC_FDs instead of OPAQUE_FDs
For Dawn/Chrome interop, Chrome OS differs from Linux as it uses the
NativePixmap-based SharedImageBacking which stores image memory as
dma-bufs as opposed to opaque FDs. Likewise, for synchronization,
Chrome OS wants to use sync obj FDs as opposed to opaque FDs for
more flexibility.

The motivating difference between sync obj FDs and their opaque
counterparts is how they are created. As their name suggests, Opaque
FDs are mostly meaningless outside of the Vulkan ecosystem and must
be created from a VkDevice. As a result, Linux’s
ExternalVkImageBacking needs the Vulkan implementation to create the
FD even when accessing the SharedImage as a GL texture [1]. On Chrome
OS, however, we don’t guarantee Vulkan outside of Dawn, so we aren’t
able to create the opaque FD directly in Chrome.

Instead, we are always able to create sync objs (e.g. via a
fence [2]) which can be imported as VkSemaphores by simply changing
VkImportSemaphoreFdInfoKHR::handleType. Similarly, we can export
signal VkSemaphores as sync objs as well by updating
VkSemaphoreGetFdInfoKHR::handleType.

This CL adds conditional support for using SYNC_FDs on Chrome OS
when importing/exporting VkSemaphores and renames
SemaphoreServiceOpaqueFD accordingly. With this, we can properly
wait on reads/writes on a GL SharedImage representation before
accessing the same memory in Dawn [3].

[1] https://source.chromium.org/chromium/chromium/src/+/main:gpu/command_buffer/service/external_vk_image_gl_representation.cc;l=75;drc=f887797b3b527feabd5dfe9b3f2cc7f6deade49f
[2] https://source.chromium.org/chromium/chromium/src/+/main:gpu/command_buffer/service/shared_image_backing_gl_image.cc;l=681;drc=f887797b3b527feabd5dfe9b3f2cc7f6deade49f
[3] https://chromium-review.googlesource.com/c/chromium/src/+/3042460

BUG=b:172208313
Change-Id: I5357847fea40e41d1b982054e3573d363e17530c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
2021-07-21 17:49:20 +00:00
Ben Clayton 909a3c3ccf Add toggles: disable_workgroup_init, disable_symbol_renaming
--disable_workgroup_init will disable the workgroup memory zero initiailization. Useful for benchmarking.

--disable_symbol_renaming will disable tint's symbol renamer. Useful for debugging output.

Bug: tint:1003
Fixed: dawn:1016
Change-Id: I92486ef88a2c1112d9ccb40f7920947bd2011c70
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58861
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-21 16:31:30 +00:00
Dawn Autoroller 18f63b4e16 Metal: Handle failure to allocate an MTLCommandBuffer
This requires restructuring the logic around MTLCommandBuffer allocation
so that GetPendingCommandContext is guaranteed to never fail. Logic in
the Metal backend is now similar to the Vulkan backend: the
MTLCommandBuffer is prepared at device initialization time, or after a
submission, such that it is always valid.

A new mUsed boolean is added to CommandRecordingContext to say whether
any commands have been recording. Previously mCommandBuffer was used for
that purpose, but it is now always non-null.

Bug: dawn:801

Change-Id: I5dc6747d1e6d538054010cc50533a03a49af921a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58720
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-21 15:41:29 +00:00
Corentin Wallez 03f9437ae8 Metal: Handle failures in Texture and TextureView creation.
This includes OOM as well as internal driver failures when
creating a view of an MTLTexture. This required changing the code to use
the Create-Initialize pattern used everywhere else.

Bug: dawn:801

Change-Id: Ib8a8dec74141aacfa58a55bb8201a83351b3b739
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58721
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-07-21 09:34:28 +00:00
Zhaoming Jiang 28497129d5 Fix memory issues in logging callback
1. Trigger all deferred callback tasks before registering a new
device-level callback function, making sure that these tasks won't be
invalided due to callback function changing;
2. Fix the end to end testsuit DeviceLostTests, setting the device lost
callback at the beginning of each test so that callback tasks created
during the test will not be triggered unexpectedly.

Bug: chromium:1223390
Bug: chromium:1223603
Bug: chromium:1228134
Change-Id: I2530e938d8fbb2920f3cc6fc78baa01c5d18ad5d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2021-07-21 08:59:09 +00:00
Jiawei Shao 46513c7810 Add validation to the maximum inter-shader stage variable location
This patch adds the validation rules on the maximum inter-shader
stage variable locations. According to Vulkan SPEC, "Each effective
Location must have a value less than the number of location avaiable for
the given interface", and according to Table 18 "Shader Input and Output
Locations", the number of available vertex output locations is
maxVertexOutputComponents / 4, and the number of available fragment input
locations is maxFragmentInputComponents / 4.

BUG=dawn:802
TEST=dawn_unittests

Change-Id: I73a66ad69c808fbd0b128abaed1ca84f19a7925d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58640
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-07-21 08:26:58 +00:00
shrekshao ca611e3799 Clean remaining deprecated WireServer WriteHandle interface
Bug: dawn:773

Change-Id: I94f5f338c13fea063102f97ae5b1b8f995ae8991
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59043
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-07-20 23:26:48 +00:00
Corentin Wallez 02a603b613 Metal: Handle potential OOM in other places.
This commit adds checks to (hopefully) all the remaining places in the
Metal backend where object creation can fail.

Bug: dawn:801

Change-Id: Ic27803e956beef822f94ca8449f7816ddd17c1bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58722
Commit-Queue: Stephen White <senorblanco@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-07-20 21:08:39 +00:00
Austin Eng b24e1320fc Metal: Only call UpdateTimestampPeriod if the extension is enabled
Bug: chromium:1226078
Change-Id: I75528096fe080aba4d8edd970d73e0aefa9130ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59041
Commit-Queue: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-07-20 20:48:10 +00:00
Ben Clayton 67035040f6 D3D12: Enable IEEE strictness
Bug: tint:976
Change-Id: I4e2d625adad89402774584ccff72b5e33dc69957
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58724
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-20 12:47:58 +00:00
Zhaoming Jiang 5af0a62e54 Fix memory leak in ShaderModuleBase::MakeError
Change the ShaderModuleBase::MakeError to return a Ref<ShaderModuleBase>
rather than a naked pointer. This Ref will be used and finally detached in
DeviceBase::APICreateShaderModule.

Bug: chromium:1223546
Change-Id: Ie4213f091e37fdc61c6e1f0bb742e8787bcb4eb8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2021-07-20 01:17:38 +00:00
Corentin Wallez ae5be1df34 Vulkan: ignore errors in shutdown vkWaitForFences.
There is nothing we can do when these errors happen except proceeding
with the clean shutdown of the Vulkan device by destroying all the
fences.

Bug: chromium:1230251
Change-Id: I5f14770bf71072616783afec7cf9538c9b103f23
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58398
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2021-07-20 00:26:07 +00:00
shrekshao bdc029ee39 Validate format is blendable when blending is enabled
Treat color target format with "float" capabilities as
blendable format and validate when blending is enabled.
Add helpers for checking float16 texture values.

Bug: dawn:726

Change-Id: Icf8c0182e5e9a13523970c84b5af91f395a089af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57744
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-19 23:27:27 +00:00
Brandon Jones 631b300262 Ensure correct shader reflection for texture_external
Adds some handling that ensures correct reflection of texture_external now
that Dawn uses Tint by default. Enables the previously written tests.

dawn: 1004
Change-Id: I8fd43292e9fe243aee037c70fe47b79ace8b672f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58540
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-19 22:26:47 +00:00
Corentin Wallez 0f3c35c8c1 Remove deprecated ExternalImageAccessDescriptorDXGIKeyedMutex behavior
Previously Dawn was using acquireKey + 1 for the releaseKey but we
changed the code transition to requiring a specific key. We supported
both options for a time but now that Chromium uses a releaseKey, we can
remove the deprecated option.

Bug: chromium:1213977
Change-Id: Iab253673c15b83b107dcc3635ee165cfa09efeb6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58383
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-19 14:44:06 +00:00
Austin Eng f6673d9420 Don't lose the device on shader compile failures
Losing the device makes retreiving the problematic shader source
difficult. Change compilation failures to be less severe
validation errors.

Change-Id: Ibcee9f39be66241e26cc8cfcf09c14aa7dfe2d1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58080
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-16 22:14:09 +00:00
Yunchao He cfbc4225a5 Texture::GetTextureViewDescriptorWithDefaults: fix incorrect UNREACHABLE()
Bug: chromium:1230062

Change-Id: I3ff2638724d09079106ed048464d2640e206512e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58500
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-16 20:12:27 +00:00
Austin Eng 83241616ae Validate a subresource can't be an attachment multiple times in a pass
Bug: dawn:998, dawn:1001
Change-Id: Id7cd4964ebf9589c599059cc0f853c0125fa725a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58361
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-16 17:44:59 +00:00
Antonio Maiorano 70324d89e0 Remove TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16 macro usage
This was a temporary measure to be able to roll Tint into Dawn with this
change. The macro will be removed in Tint once this lands.

Bug: tint:984
Change-Id: If599e92b16b5edd96b357ce5ee57143a2c00e22d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58365
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-07-16 17:30:50 +00:00
Zhaoming Jiang d8b3d99038 Add OOB validation in RenderPassEncoder for Draw and DrawIndexed
1. Validate the buffer range for both vertex step mode and instance step mode vertex buffers in Draw,
2. Validate the buffer range for instance step mode vertex buffers and the range of index buffer in DrawIndexed, and
3. Add related validation unit tests DrawVertexAndIndexBufferOOBValidationTests, and remove out-of-date vertex buffer robustness tests.

Bug: dawn:808
Change-Id: Ic27a95138cb1e21b72a1da392b7828368bfe2010
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56361
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-16 03:22:58 +00:00
Yunchao He 37140e7c62 Fix bugs about TextureViewDesc's default values
TextureViewDescriptor's default values for dimension and
arrayLayerCount in Dawn are not correct according to WebGPU spec.
This change fixes these bugs.

Bug: dawn:760
Change-Id: Ic1d069838d6c0f7bb1afa1dceaf73e91bdfdb20a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58020
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-07-15 18:33:48 +00:00
Ben Clayton 93a75930b1 [tests]: Register Device::SetLoggingCallback()
And print this to the Dawn logger.
Tests will now print any diagnostic logging calls from Dawn.

Change-Id: Idd4bf816303c182809924f9a432570def808e1b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57381
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-15 09:09:38 +00:00
shrekshao 813a855b54 Remove deprecated WireClient/Server handlers functions
Remove deprecated functions and change new functions to pure
virtual since they are implemented both on dawn and chromium
side.

Bug: dawn:773
Change-Id: I5adfe42ad1155276f533660b938b869c775025bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58100
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-07-15 01:13:04 +00:00
Ben Clayton d9d6e7fc40 ShaderModule: Deprecate dump_translated_shaders for dump_shaders
And print the WGSL program even when !force_wgsl_step
Shaders are often built through string concatenation.
Being able to always dump this is useful.

Change-Id: I5da3866b333e8a80931c7c2837f0247e8f38213d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57380
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-14 20:59:54 +00:00
Antonio Maiorano 58016bfb31 Make storage buffer length UBO size a multiple of 16 bytes
Conditional on whether TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16 is
defined, which it will be in a future Tint CL.

Bug: tint:984
Change-Id: I191cd59fe6947c9113a8fad7dbfbf79903969b27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57960
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-14 15:33:31 +00:00
Brandon Jones 4742fbe656 Add CompilationInfo wire test, check offset/length
Change-Id: Ifc457d6b58f20c294531444836693cb31e036ca1
Bug: dawn:746
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57941
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-07-14 02:52:42 +00:00
Austin Eng ec380e9589 Fix Vulkan buffer barriers to use VK_WHOLE_SIZE
Buffers are padded to be at least 4 bytes. Dawn would
produce invalid barriers for buffers that were "zero"
bytes large. The size for the barrier must be either
non-zero or VK_WHOLE_SIZE. Since we always intend
to transition the entire buffer, simply use
VK_WHOLE_SIZE instead of GetSize() as the size.

Fixed: dawn:969
Change-Id: Ifed4e8f9164bafa3c44917074fcf214e72919c56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57940
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-14 00:42:31 +00:00
Yunchao He 5a78bde770 Fix a bug for 3D texture clear on D3D12
When we clear an uninitialized 3D texture, we should clear all depth
slices for each mip level. The current implementation only clears one
slice (the first slice) for each mip level. This change fixes this
bug. Dawn end2end tests of NonzeroTextureCreationTests can pass with
this fix. These tests fail on D3D12 without the fix.

This change also renames arguments for GetRTVDescriptor() for 3D
texture: change baseArrayLayer/layerCount to baseSlice/sliceCount.

Bug: dawn:547
Change-Id: Ic56f28e9e6430058c31aaa2bb21f4e42f7b7621c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57840
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-07-13 15:55:15 +00:00
Austin Eng 0a58972309 Always run the Tint renamer, even with dump_translated_shaders
Not running the renamer can produce code that fails to compile
on the backend, resulting in device lost errors.

Change-Id: I4a841a281142bb8eda1402e1ebd6a5d23b77bfe0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57745
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-13 15:34:46 +00:00
Ben Clayton 4773e8d0f9 wgsl: Clean up duplicated [[block]] structs
crbug.com/tint/386 has been fixed.
We don't need these work arounds any more.

Original CL by bclayton@:
https://dawn-review.googlesource.com/c/dawn/+/54641

Bug: tint:386
Fixed: dawn:943
Fixed: dawn:975
Change-Id: I1b94d1e33b023b7d9b3153094f829885a75b5a5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57743
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-13 15:21:07 +00:00
Austin Eng 2103fa629e Pass preserveInvariance to MSL compiler if necessary
Fixed: dawn:977
Change-Id: I7df2080424a4af0b7155ee24f61bb37f0674de82
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57741
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-07-13 00:07:45 +00:00
Yunchao He b326f8c172 Remove UnsafeAPI toggle for 3D texture
3D texture implementation has already been done. It's time to remove
the UnsafeAPI toggle for it.

Bug: dawn:547

Change-Id: Ic9e0930d7906ee5274b9e412ebacb2574744b2b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56480
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-07-12 19:01:51 +00:00
Brandon Jones 966b3092e8 Suppress tests failing on Linux Intel OpenGL
Change-Id: I735d88c3f98876852bfe8a3480efb7f64a90f747
Bug: dawn:976
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57600
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-07-09 22:30:19 +00:00
Yunchao He 9749f5a9f5 Move a function to TextureFormatUtils.h|.cpp and rename these two util files
This change moves function ViewDimensionToTextureDimension() to
TextureFormatUtils.h|.cpp.

This change also renames TextureFormatUtils.h|.cpp to TextureUtils.h|.cpp
because the new name makes more sense now.

Bug: dawn:547

Change-Id: I183c68d26365a6cda722be55b8ba3556c1b4c82b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57482
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-07-09 02:47:49 +00:00
Yunchao He 3185d9ce1f Implement 3D texture read/write via storage usage on D3D12
The main part of this change is to add a few end2end tests, with
some renaming stuff like arrayLayerCount to sliceCount in order to
include both 2DArray and 3D textures.

The implementation is quite simple: just set UAV descriptor on D3D12.

The new tests can pass on Vulkan and Metal, which indicates the
implementation has been done on them.

The new tests fail on OpenGL and OpenGLES. I will take a look and
submit separate patch for GL and GLES.

Bug: dawn:547

Change-Id: Ic03eab6b06654c48341c935f64f4885be544985c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57160
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-08 23:33:37 +00:00
shrekshao 6e680fc56f MapAsync update: keep read/write handle through lifetime of mappable buffers
Change dawn read/write handle for buffer mapping to be created at buffer
creation time instead of at mapAsync time. Update related buffer mapping
tests and wire tests.

Bug: dawn:773
Change-Id: I7dd423c94e1bc15cfe561ea33ec9e348ddf2bfe0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51164
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-07-08 22:48:57 +00:00
James Price 15838b98af Switch to new Tint generator API
Tint now has a single-function API for code generation that
automatically runs the backend-specific sanitizer transforms. This API
allows for backend-specific configuration options such as the fixed
sample mask for MSL (and, in the future, information about which
compiler/version is being targeted), and returns any backend-specific
metadata such as whether a UBO of buffer sizes is required by the
shader.

This change prevents the post-sanitizer program from being exposed to
Dawn, which is a potential foot-gun (e.g. the Inspector is not
expected to be run after the sanitizer transforms, and Dawn is
currently doing this).

The old Generator class API will be removed from Tint shortly after
landing this change.

Bug: tint:697
Change-Id: I9b988d55514f810d3091ec6471731e6eb41dc27f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57103
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-08 22:35:27 +00:00
Austin Eng 31930e7287 Enable use_tint_generator by default, disable shader_float16
Float16 is not standardized in WGSL or implemented in Tint,
so remove support of the extension for now.

Bug: dawn:571, dawn:426
Change-Id: Ia26f0ddb07cabf6057c0d7db9ade547494d2cc6e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56441
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-08 18:42:37 +00:00
Yunchao He 2f51bfc74a Implement 3D texture storage binding types
This change adds storage binding type tests for 3D texture. It turns
out that it is working. There is no additional work to be done.

Bug: dawn:547

Change-Id: Ia749200e7d371ad549405ff63c198ea4a27924c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57120
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-08 07:12:24 +00:00
Austin Eng 170ea75f2a Add test for fragment outputs not covered by render attachments
Bug: dawn:962
Change-Id: I26412b8db598dc581f1c302f39e65dc0c45aa443
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56802
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-07 23:30:00 +00:00
Yang Gu c45c7a415c Extend Intel graphics driver version to 2 fields
The 4th field of Intel new graphics driver will overflow soon. For
example, the lastest driver version is 27.20.100.9466 and the 4th field,
9466, will meet the maximum 9999 soon. Future driver will bump the 3rd
field from 100 to 101. This CL extends driver version check from 4th
field to both 3rd and 4th fields.
Check below 2 documents for more details.
https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html
https://docs.google.com/document/d/1Xm4afyGR3Ow3W2G-uig9fLQR01XzmSXeanM9OXDVhlg/edit#heading=h.k8onwbxk2ig

Bug: None
Change-Id: I0ce59ca81b1edd4c63b9f3b0128788c2bf6ade17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57180
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-07 08:58:01 +00:00
Corentin Wallez f78c28dcb7 Add support for dump_translated_shaders to the Metal backend
Bug: None
Change-Id: Icecbe221970ec10e6497309108dec5ccefc0a944
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57060
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-06 14:14:00 +00:00
Ben Clayton 2583b8d459 D3D12: Improve dump_translated_shaders debugging
If enabled:
* Don't enable the renamer transform. Helps with readability.
* Emit the produced WGSL when combined with --force_wgsl_step

Change-Id: I336de6e6a4eee08805eee82847bd97cd5a942306
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57040
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-06 11:53:40 +00:00
Ben Clayton 2828f35a71 D3D12: Re-enable FXC tests
Enough FXC workaround have been added to tint that these tests now pass again.

Fixed: tint:904
Change-Id: I6dd355d131ab903ae579391c0bfce93979dfc4f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57041
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-07-06 10:49:50 +00:00
Corentin Wallez 7ae959da60 Allowed mismatch sampler/comparison sampler when using SPIRV-Cross
When SPIRV-Cross we always reflect samplers as regular samplers. A
recent change implementing proper validation broke programs using
comparison samplers in that path.

Skip that bit of validation when using SPIRV-Cross, that hack can be
removed once we use Tint unconditionally for reflection.

Also reenables some BGL-ShaderModule compatibility tests with
SPIRV-Cross to cover the "fixed" validation.

Bug: dawn:571
Bug: dawn:367
Change-Id: I2d1a65aaea717b4927ac4e838942547a1b413d33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56900
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-05 15:07:49 +00:00
Brandon Jones aeff235dc3 Drop deprecated rowsPerImage/bytesPerRow behavior
Removes the last remaining code paths supporting the old rowsPerImage
and bytesPerRow defaulting behavior, and updates all related tests to
strictly expect the spec-complaint behavior.

Change-Id: I022db0b142939d82e33d5989460488881e5a1ab3
Bug: dawn:520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56803
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-07-04 18:31:29 +00:00
Corentin Wallez fc37b32c55 Vulkan: Check for required limits when initializing adapters
Also adds the new limits for maxComputeWorkgroupSize because there are
few systems where the .Z of that limit goes above 64.

Bug: dawn:796
Change-Id: I52e85e7b7c666da15493178e170ca82922d34017
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56082
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-07-03 04:30:56 +00:00
Li Hao 551e7a1cc3 Fix internal storage buffer usage
TimestampQueryTests.ResolveTwiceToSameBuffer fails on Intel latest
driver on Windows, because the kInternalStorageBuffer is not treated
in buffer usage when adding resource barrier.

Add missed kInternalStorageBuffer in buffer usage and remove
D3D12_RESOURCE_STATE_UNORDERED_ACCESS from QueryResolve, which will be
added by kInternalStorageBuffer.

Bug: dawn:797
Change-Id: I78607002179ba443b0db09c9c3bbc85fcc97a85b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56523
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-07-02 09:51:18 +00:00
Austin Eng a5f24e590a Validate textures with filtering/non-filtering/comparison samplers
Renames dawn_native::ComponentTypeBit to SampleTypeBit and makes
the bitmask match wgpu::TextureSampleType. wgpu::TextureComponentType
should be removed in a follow-up CL.

The Format table is augmented with float/unfilterable-float information
so that textures can be validated against the BGLEntry's
TextureSampleType.

EntryPointMetadata::ShaderBindingInfo no longer inherits BindingInfo
because the two types are diverging further. Most notably, this CL
reflects from Tint the supported SampleTypeBits for texture bindings.
This bitset is validated against the bind group layout.

Adds an isFiltering getter to SamplerBase. A filtering sampler must
not be used with a non-filtering sampler binding.

Lastly, the CL reflects sampler/texture pairs from Tint and validates
an entrypoint against the pipeline layout that a filtering sampler is
not used with an unfilterable-float texture binding.

Bug: dawn:367
Change-Id: If9f2c0d8fbad5641c2ecc30615a3c68a6ed6150a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56521
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-07-02 02:29:40 +00:00
Kai Ninomiya 211b4aae7e Remove null-deref in test
Dereferencing a nullptr is UB by spec, even if the method called is
non-virtual and no memory access to nullptr appears to actually occur.
For example:

error: 'this' pointer cannot be null in well-defined C++ code;
comparison may be assumed to always evaluate to true
[-Werror,-Wtautological-undefined-compare]

Bug: b/179840737
Change-Id: I6385e157e9a883cdd65f5ef9be89bcc3a29324fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56720
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-07-01 01:43:34 +00:00
Ben Clayton bf832f07d6 Remove all use of deprecated tint APIs and WGSL syntax
Tint:
* Use the new transform::VertexFormat enum names

WGSL:
* The [[set(n)]] decoration is now [[group(n)]]
* [[builtin(vertex_idx)]] is now [[builtin(vertex_index)]]

Change-Id: I9cbf1368074488c4bb7fa81430bb12ec7581c1fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-30 11:33:04 +00:00
Peter Kasting 1ce20bf5cf Fix -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: I9e00d3707972307e1c5395156c39aa153d5e170e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peter Kasting <pkasting@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
2021-06-30 11:17:16 +00:00
Corentin Wallez 0ecfece609 Metal: make (robustness AND tint) => vertex pulling
Tint's vertex pulling transform supports the whole GPUVertexState so
we can enable it by default when robustness is necessary.

Adds a suppression for failing tests on Metal Intel.

Bug: dawn:805
Bug: dawn:966
Change-Id: Id7b2c6df2291671164647f65fc50c61e27de90b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56382
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-30 09:57:04 +00:00
Austin Eng 2a5fd58832 Remove double test instantiation with/without use_tint_generator
The test bots now instantiate separate test suites with/without
this toggle.

Bug: dawn:571
Change-Id: Ib4e8e89ac347d0030b233d1a3b14b318aa862aa6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56440
Commit-Queue: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-29 17:29:23 +00:00
Corentin Wallez 73b7cd624f Add missing WebGPU limits to Constants.h
This will help check that the Vulkan devices are enough for WebGPU in
a following CL.

In addition to additional limits this CL:

 - Change maxColorAttachments 4 -> 8 to match WebGPU
 - Renames kMinDynamicBufferOffsetAlignment to
   kMinUniformBufferOffsetAlignment.
 - Renames kMaxVertexBufferStride to kMaxVertexBufferArrayStride.
 - Changes validation of buffer offsets to use the separate uniform and
   storage limits (but no test is added because they are the same).
 - Adds validation and a test for kMaxStorageBufferBindingSize.
 - Augment the null::Device memory limit for that new test (it allocates
   a buffer of 512MB).
 - Fix the maxColorAttachment test to not use hardcoded values.

Bug: dawn:796
Change-Id: Ibe4219130a44355ae91c02aaa0a41cf5d9f9e234
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56081
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2021-06-29 08:12:00 +00:00
Li Hao 895bc934bb Implement zero-sized QuerySet
- Add zero-sized implementation in each backend.
- Test creating zero-sized query set for each type.

Bug: dawn:954
Change-Id: Ib2b8a7d890dae6ee40f5a05aac570a4600dedab8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2021-06-29 08:04:00 +00:00
Sergey Karchevsky 9b6872dd00 Fix examples linking error when building with CMake
ScopedAutoreleasePool.cpp was not added to dawn_utils library sources,
which caused unresolved externals while linking examples.

Change-Id: Ia9de3135b814663cce33b719dbbb22971b8b9d43
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56282
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-29 07:03:31 +00:00
Yunchao He 405bec157e Implement 3D texture sampling with e2e tests
This change implements 3D texture sampling with an en2end test.
It turns out that the implementation has already been done. The
test can pass with minor changes.

Bug: dawn:547

Change-Id: I5dfe1a446de3287392e39cb4dd58143e115b02cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2021-06-29 04:56:01 +00:00
Sarah 98ab91b474 Update compute shaders tests to include workgroup_size
Change-Id: I97ef98c1cfc1a06c5072d1a52233100ad3d37c09
Bug: tint:884
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56142
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2021-06-29 00:10:01 +00:00
Austin Eng 27b0162b96 Remove explicit test instantiation with use_tint_generator
We're migrating to run all tests with both Tint and SPIRV-Cross.
Remove explicitly instantiating only with Tint, and add
skips for tests that will not work if use_tint_generator is not
enabled.

Bug: dawn:571
Change-Id: I8322dec688e75b6efa8c4f18c6b9439a2e325631
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56261
Auto-Submit: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-06-28 21:18:40 +00:00
Sergey Karchevsky 0db69f0052 Fix compilation error when building with CMake and Clang
RefBase::Detatch() method in RefBase.h calls std::move,
but no appropriate header was included. Error example was:
RefBase.h:137:22: error: no member named 'move' in namespace 'std'

Change-Id: I60f84bffba06ba5fd3fea7fb9c4908cfe3989472
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-28 20:20:50 +00:00
Brandon Jones 55a389762d Deprecated StoreOp::Clear in favor of Discard
Change-Id: Ifac3b980f23c3476d91bb89759b2a60ed5efbc17
Bug: dawn:937
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56045
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
2021-06-28 18:38:24 +00:00
shrekshao 81372da137 Add placeholder virtual functions to dawn_wire Read/WriteHandle
Updated interface design is at
https://bugs.chromium.org/p/dawn/issues/detail?id=773#c21

Prelanding CL to avoid breaking change.
The proposed usage is at
https://dawn-review.googlesource.com/c/dawn/+/51164

Bug: dawn:773
Change-Id: If27396e60574b4a52fcda60e111bad33c9d63563
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2021-06-28 18:22:31 +00:00
Corentin Wallez a68489fb83 CopyTextureForBrowser(): Fix macro declaration
This is fixup for the
https://dawn-review.googlesource.com/c/dawn/+/54800
where the macre was not properly declared.
Clang doesn't claims about it, but GCC does.
The errors example for GCC 9.3.0:
/dawn/src/dawn_native/CopyTextureForBrowserHelper.cpp:40:5:
error: unterminated raw string
   40 |     R"(
      |     ^
/dawn/src/dawn_native/CopyTextureForBrowserHelper.cpp:46:6:
warning: missing terminating " character
   46 |     )"
      |      ^

Bug: chromium:1217153, chromium:819294
Change-Id: I47aa2dac37d9dfa7c02532caeb3341edd22fcd07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56066
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-28 16:57:13 +00:00
Ben Clayton db7def5816 common: RefBase fixes and improvements
Fix missing Release() on RefBase::operator=(const T&).

Always acquire the new reference before dropping the existing reference.
Consider:
* Object A holds the only reference to object B.
* Ref of A is assigned B.
If A were released before referencing B, then B would be a dead pointer.

Remove RefBase::kNullValue, just use Traits::kNullValue. Avoids an unnecessary constexpr copy.

Add even more tests.

Change-Id: I111079d56cbf8c09162aa6e493078bead9ae97fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55882
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-28 10:26:08 +00:00
Corentin Wallez 220ff07ffd dawn_native: Add a force_wgsl_step toggle.
This makes SPIRV ingestion always go through a SPIRV->WGSL step first.
This will be used to make sure that path works correctly on existing
WebGPU SPIRV sites so we're confident the SPIRV->WGSL translation will
work when compiled to WASM.

Bug: dawn:960
Change-Id: I17efd8c64d9d60ff033ba89b8fff9295e66524ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56080
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-06-28 10:23:08 +00:00
James Price 0cb3d480ff Enable testing of Metal with Tint MSL generator
We are now passing all of Dawn's E2E tests with the Tint generator.

Bug: dawn:571
Change-Id: Ie74a07bde805b8652ac23af2bda2fa11597d04ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55980
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-28 09:39:08 +00:00
James Price a0b31e04e8 Add missing structure padding to test
WGSL specifies that the size of a host-shareable structure is a
multiple of the largest alignment of any member in that
structure. While SPIR-V cross doesn't generate this trailing padding,
Tint does, and so we need to pad the host structure to match to avoid
validation errors.

Bug: dawn:571
Change-Id: Id5de89125a74c0469ae69d6e86b4c570bbdb31ab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-28 08:38:28 +00:00
陈俊嘉 610de1d725 CMake: couple fixes for UWP
Fix a capitalization error in CMakeLists.txt
Link dxgi.lib only in UWP compilation in CMakeLists.txt

Bug: dawn:766
Change-Id: I011f44c8147998a9f4b3a55b25888ca1ad05a3e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-28 08:19:28 +00:00
Jiawei Shao 3d5402c0a4 OpenGL: Return error when calling writeTexture() on stencil aspect
This patch adds a missing check in QueueGL::WriteTexture() to return
a validation error when we try to call writeTexture() on the stencil
aspect on OpenGL backends as copying from a buffer into a stencil
texture is not supported on OpenGL.

BUG=dawn:439

Change-Id: I203d40aefe346aea663a492c5a065248b74f8ea3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56002
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-06-27 05:38:05 +00:00
Jiawei Shao f7cde7e5a4 Fix wrong declaration in BufferZeroInitTest.BoundAsReadonlyStorageBuffer
This patch fixes a wrong buffer type declaration in the shader used
in BufferZeroInitTest.BoundAsReadonlyStorageBuffer. In this test the
buffer should be bound as a read-only storage buffer, so it should be
declared as var<storage, read> instead of var<storage, read_write>.

BUG: none
Change-Id: Ib85bf199f64e205b944b7233aae31323cbec1819
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56042
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2021-06-27 05:28:35 +00:00
Ben Clayton 448e1e91a7 D3D12: Reenable EncodeManyUBOAndSamplers test
Tint has rolled, so this test can be re-enabled.

SPIRV-Cross produces bad results - likely the UBO layout for mat2x2 is
incorrectly padded - so this test is suppressed for !UseTintGenerator.

Fixed: dawn:946
Change-Id: If1d030314f51759e6a2a00dd8edc2597efb1eb4a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55440
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-25 15:44:02 +00:00
Ben Clayton 17686f78cb Test that UBO and SB layout rules are correct and consistent for all backends
Fixed: tint:898
Change-Id: I81633715efd213cf0c566aa44d00bee82aa2c17a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54642
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-25 08:51:52 +00:00
Li Hao df4c60546e Add stress test for memory allocation and free on D3D12
It may not be the root cause of CTS memory leak, but we found some
issues in D3D12 memory allocation for large buffers (> 4M).

The memory allocation is not freed correctly when we call buffer
destroy. When we create a large buffer, it always allocate committed
resources from the system memory and append it to LRU cache, and will
try to free the expired memory in LRU cache when the left memory size
is not enough for the current allocation. When we call buffer destroy,
we remove its heap from LRU cache, release its allocation, but will
add the allocation reference to a delete queue and wait to be freed
together in the next device.tick. At this time, the destroyed memory is
not really released to the system memory. If no tick is triggered during
the buffer allocation and deallocation, these memories will never be
reused again and there will be a memory leak. We need to free these
memories when we detect there is not enough memory, do not wait for
device.tick to do that.

Add a stress case to track the issue, and need to discuss how to fix it.

Bug: dawn:957
Change-Id: Id4bcc97496d372ad7c27c31675327ca12e133217
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55740
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-25 08:10:42 +00:00
Corentin Wallez 396b7dff45 Vulkan: Check for required features when initializing adapters
Core WebGPU requires some Vulkan features to be implemented. Check for
them so that we don't return an adapter for a Vulkan device with
insufficient features.

Bug: dawn:796
Change-Id: I445760f184807b8f2d4ee248289b512c18038f33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55920
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-06-25 06:10:01 +00:00
Austin Eng a9faf7f74a Fix misplaced ASSERT in bind group validation
Fixed: dawn:614
Change-Id: I06e4c89f34a1705346620dea074e3d469cbd1409
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-06-24 23:05:51 +00:00
Austin Eng 700a5fb869 Add scoped autoreleasepool to tests and examples
This ensures ObjC objects do not leak. On non-Apple
platforms, the scope does nothing.

Fixed: dawn:546
Change-Id: Id43702e6536bf9cb37825a5449511e10cf0734f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55841
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-24 19:21:31 +00:00
陈俊嘉 b2bc57ad22 Add UWP compilation support in CMake
Set BUILD_EXAMPLE to OFF in UWP.
Disable Vulkan in UWP.
Compile GLFW related sources only on supported platform.
Remove linking to user32.lib in UWP.
Add linking to dxgi.lib only in debug configuration.
Use EmptyDebugLogger in UWP.

Bug: dawn:766

Change-Id: I3e6149058048d1b597267dfb9d63342b6a54e0af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-06-24 07:00:16 +00:00
Zhaoming Jiang 1af81e3128 Validate the buffer offset in T2B and B2T for depth/stencil texture
This patch modifies the ValidateLinearTextureCopyOffset for T2B and B2T
commands to make sure that buffer offset is a multiple of 4 when the
texture is of a depth/stencil format. The unittests are also updated
to cover these cases.

Bug: dawn:721
Change-Id: I5cb9487e61e7f6ac7075157a092a1f3577844042
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55720
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-06-24 05:38:00 +00:00
Austin Eng 75c5067ed1 Implement initialization of multisampled textures
Metal needs RenderTarget usage to be added to the texture
allocation so the clear can be done using a render pass.

Already working for GL which does not have usage flags on
creation.
Also working on Vulkan which does not need a render pass.
We use vkCmdClearColorImage.
D3D12 also needs a render pass to clear multisampled textures,
but it already requires multisampled
textures to be created with RenderTarget flags.

To test the behavior, NonzeroTextureCreation tests are
expanded, and the ExpectSampledDepthData helper is factored
into a more general ExpectSampledFloatData helper.

Fixes: dawn:794
Change-Id: If0f9f26f3c58b4292c85265aa7ff330e9931ddae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55604
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-24 02:01:46 +00:00
Sarah 2a57db73cb update compute shaders to include workgroup_size in their attribute
Change-Id: Ia9027f8ec9c4a293ae1bef735c8b5eeea84e81e2
Bug: tint:884
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55685
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2021-06-23 19:19:06 +00:00
Yunchao He 1317636fc8 Add a few tests for copies and fix bugs found by new tests
This change adds a few tests to cover more copy scenarios like
copy between different mip levels of the same texture, copies
between 3D texture and 2D Array textures for partial copies,
non-zero offset (copy origin), non-zero mip level, etc.

The new tests expose a bug, which is fixed by this change.

It also re-arranges the tests, in order to put all tests into
corresponding categories like T2B, B2T and T2T tests. Within each
category, tests are in the sequence of 2D texture tests, 2D array
texture tests, and 3D texture tests.

Bug: dawn:547

Change-Id: I624a8814d91950e69126705611f02e258eaf216b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55540
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-23 17:12:53 +00:00