Commit Graph

1292 Commits

Author SHA1 Message Date
Yunchao He 02dd733454 Add memory synchronization tests - data deps chain among passes
This CL adds end2end tests for memory synchronization tests for buffer.
It adds a few tests that iterate data read-add-write operations a few
times in buffer for compute and render respectively, and verifies
that data dependency among interations is well synchronized.

BUG=dawn:275

Change-Id: Idfe627e90de795d664ee64787d5c5d2bfcee676b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13700
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-20 00:05:20 +00:00
Yunchao He 452225d6be Add tests for map buffer twice
This patch add end2end tests for map buffer twice for map read, map
write, and SetSubData.

BUG=dawn:278

Change-Id: Ibe57d7923310d2513e314fa9bf185677a706d6da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13801
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-19 18:47:30 +00:00
Yunchao He 0c02f54edf code refactoring: prefix const color values with RGBA8
BUG=
Change-Id: I820180adc19b1d1c226ca92084c64e441173c27b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13760
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-11-19 17:57:30 +00:00
Corentin Wallez 083a1ce2bf Inline a 1 bit payload in RefCounted
This changes RefCounted to increment and decrement the refcount by steps
of 2, so that a 1 bit payload can be inlined in the refcount. This
avoids using a whole boolean + padding (4 or 8 bytes in general) to know
if objects are errors.

Fixes a longstanding optimization TODO.

BUG=dawn:105

Change-Id: I5e8f66465d23772fb6082ea3e0d5d4aba2132648
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13680
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-11-19 14:35:10 +00:00
Bryan Bernhart 9c81f8738a Allow SetBindGroup command to be skipped with dynamic offsets.
Fixes a bug where SetBindGroup command would fail to be skipped.

BUG=dawn:256

Change-Id: I9815c9d31aa88f6881274a1873cabe17379cc2e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13800
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-11-18 23:09:38 +00:00
Jiajie Hu d0c07f112e Vulkan: Fix release of semaphores in the recording context
This seems to be a regression introduced by CL:12022, where the
previously recorded semaphores are leaked while resetting the recording
context. The Vulkan validation layers will complain about this when
running the Linux-only image wrapping tests. Also, the semaphores are
queued for deletion with the right serial now.

Bug: dawn:19, dawn:150
Change-Id: I50fd46ca9de9199b29be2f85d5e9bd7394a10f1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiajie Hu <jiajie.hu@intel.com>
2019-11-18 08:15:18 +00:00
Yunchao He 612a63abe1 Add memory synchronization tests - storage to uniform sync
This CL adds end2end tests for memory synchronization tests for buffer.
It adds a few tests that write into storage buffer in compute pass,
then read via uniform binding from the same buffer in render pass.

BUG=dawn:275

Change-Id: Ic98a10aab4cdcddecd60662438d4b8bdd34fafbc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13580
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-18 04:28:24 +00:00
Yunchao He e0eeef4b34 code refactoring: const color values
BUG=
Change-Id: I6f394fd8ae45d30e1e3846b9a7a03f51efb8a475
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-11-18 03:27:44 +00:00
Austin Eng a930e599e1 Add cpu_time metric to dawn_perf_tests
The cpu_time metric measures the amount of CPU time spent on a step.
It excludes time spent waiting for the GPU or time between frames.

Bug: dawn:208
Change-Id: I5624d45557716c02bb7da632d2347eca0b81ad41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13640
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-15 15:43:26 +00:00
Yan b639e68495 Add large buffer to handle super large data block commands
TerribleCommandBuffer has space for 10,000,000 bytes worth of commands. If
commands contain super large data block (e.g. setsubdata), it will
return nullptr and crash dawn wire layer.

This patch adds a large buffer to handle super large data block.

BUG=dawn:251

Change-Id: Ib007e92b5282afbb93aef63cfffe5a3965f6d5c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-11-15 09:32:56 +00:00
Ryan Harrison 58dbfcae38 Refactor ShaderModule creation to use a Builder pattern
BUG=dawn:270

Change-Id: Iedae1a5500b1eb65abb84ff59f68d829c5c22c2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13500
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-14 16:10:45 +00:00
Corentin Wallez 321c12255e Remove the "Base" from pure-frontend dawn_native types
This was unnecessary verbosity. Fix this by having the ProcTable
generator using type aliases so all types appear like they have
"Base".

BUG=

Change-Id: I8c472fb924f6ce739e4e41038452381b4f727a2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13442
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-11-13 17:00:37 +00:00
Ryan Harrison 9e7107eb96 Migrate Dawn fuzzers to using new SPVC split API
Roll third_party/shaderc/ c9d5be6b0..0865050e5 (3 commits)

c9d5be6b01..0865050e54

$ git log c9d5be6b0..0865050e5 --date=short --no-merges --format='%ad %ae %s'
2019-11-12 rharrison Split spvc shader generation into initialize and compile phases (#882)
2019-11-12 9856269+sarahM0 opName - opStruct (#880)
2019-11-12 rharrison Rolling 5 dependencies and updating expectations (#879)

Created with:
  roll-dep third_party/shaderc

Change-Id: Iea431b36973ac1fbfe68f1353e538ca4ca5ca910
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13423
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2019-11-13 15:37:47 +00:00
Jiawei Shao cfdbaaa376 Implement querying WGPUDeviceProperties from dawn_native::Adapter
This patch adds an interface GetAdapterProperties() on Adapter which can
directly return a WGPUDeviceProperties object that includes the
information of the adapter.

BUG=chromium:996713

Change-Id: I9a7b1512d259761e198dfac3eafa718171d47241
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-11-13 01:53:25 +00:00
Corentin Wallez 604072bc2e Make the SwapChain interface match webgpu.h
This changes the methods of Dawn's SwapChain to match webgpu.h, namely
Present() now doesn't take arguments, and GetNextTexture() is replaced
with GetCurrentTextureView().

BUG=dawn:269

Change-Id: Ia0debefb170caf799c3310b1dad5535c4c5f59ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13441
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-12 18:30:11 +00:00
Brandon Jones 700cfe7664 Implement D3D12 Native Render Passes
Uses D3D12 native render pass API when possible. On pre-RS5 builds of
Windows, Dawn will fall back to a software emulated render pass. A
toggle was added to provide test coverage to the emulated render pass
implementation and used in tests that test render pass functionality in
particular.

Bug: dawn:36
Change-Id: I297a3ec7655b68d28204db2d3ab78cb82bb4e7a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13082
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2019-11-12 18:14:21 +00:00
Austin Eng cfc9c6e322 Make perf test tracing thread-safe
The Metal driver calls command buffer completion callbacks on a
separate thread so enqueueing these trace events needs to be made
thread-safe. In the future, Dawn will probably have other threads
that also require thread-safe tracing.

In this CL, each thread records trace events into its own buffer,
and all buffers concatenated when trace events are acquired.

Bug: dawn:254, dawn:208
Change-Id: I0f1abd404568d838091066a8f27a3bf98fa764b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-11 23:15:56 +00:00
Yunchao He c51616d790 Implement readonly storage buffer - validation at shader side
This patch adds validation code for shader side for readonly storage
buffer. It also adds unit tests for validation.

BUG=dawn:180

Change-Id: Ib5789381d41d77867dd6e6aa1f1ccbc8fa43a382
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12941
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-11-11 20:05:28 +00:00
Yunchao He 5aa7458db6 Tiny fixes for BindGroup/BindGroupLayout tests
This patch sets proper value in a few end2end tests for BindGroup/BindGroupLayout.
It also removes unused variables in unittest test for BindGroup/BindGroupLayout.

Bug=dawn:180
Change-Id: Ie5c8b2fd8265fe90b7b54c48af48106c356564b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13300
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-11-11 19:11:08 +00:00
Ryan Harrison 59b2987b20 Another spvc API migration
Subtle change to how results are handled requiring another change.

Rolling DEPS ahead to pick up change.

Roll third_party/shaderc/ 76ee91e12..f4cf10c66 (4 commits)

76ee91e126..f4cf10c66f

$ git log 76ee91e12..f4cf10c66 --date=short --no-merges --format='%ad %ae %s'
2019-11-11 rharrison Correct Unicode issue with add_copyright.py (#876)
2019-11-08 rharrison Another major API rework (#871)
2019-11-07 rharrison Remove deprecated API elements (#870)
2019-11-07 9856269+sarahM0 Add support and unit test for OpTypeInt, OpTypePointer and OpConstant (#872)

Created with:
  roll-dep third_party/shaderc

Change-Id: Ic461c3ec135d2c73ebadede62fb34c90e7961eda
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13380
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-11 18:39:08 +00:00
Jiajie Hu 3c086a0c2e Remove VulkanImageWrappingTests suppression on Intel
The Intel bot upgrade (crbug.com/966500) is finished.

Bug: chromium:976495
Change-Id: I2d48f07d2e6951f77f76c870e3d23b5a62db1dd1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13360
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-11 08:59:07 +00:00
Rafael Cintron 600a26d50a Fix ResourceHeapAllocation Memory Leak
ResourceAllocatorManager::DeallocateMemory was correctly invalidating the
passed in allocation object. However, since the subclass
ResourceHeapAllocation class was not overriding the Invalidate method and
clearing out the D3D12Resource pointer, the resource ended up being tied
to the lifetime of the Texture object instead of being released on Destroy.

In Chromium, this bug was particularly egregious as it meant swap chain
texture cleanup was at the whims of the Javascript garbage collector.

Bug: dawn:242
Change-Id: Ia5856c61c8d3b92a2247a9aaa5f91c5de0a99dcb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13200
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-08 21:47:00 +00:00
Kai Ninomiya ae1f25fee8 Update naming for vertex state
- VertexInputDescriptor -> VertexStateDescriptor
- VertexBufferDescriptor -> VertexBufferLayoutDescriptor
- VertexBufferDescriptor.stride -> .arrayStride
- VertexAttributeDescriptor.offset no longer optional

gpuweb PR: https://github.com/gpuweb/gpuweb/pull/469

Bug: dawn:22
Change-Id: I5431df4ba22cfbdb1bc81e6709e562cd736892a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13100
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-07 22:23:29 +00:00
Ryan Harrison c3284fa40e Migrate away from using recently deprecated APIs
Due to a renaming/refactoring of the spvc API Dawn is currently using
a deprecated class name. Fixing this, so the deprecated APIs can be
removed.

Also including the roll to pick up the API changes.

Roll third_party/shaderc/ 0a260d789..76ee91e12 (7 commits)

0a260d789f..76ee91e126

$ git log 0a260d789..76ee91e12 --date=short --no-merges --format='%ad %ae %s'
2019-11-06 9856269+sarahM0 Fix spvc test machanism and adds unit tests for OpSource (#868)
2019-11-06 rharrison Move spirv_cross state out of result and rename opaque state handle (#865)
2019-11-05 9856269+sarahM0 Add unit test for spvcir parser (#866)
2019-11-04 rharrison Rolling 5 dependencies (#862)
2019-11-04 9856269+sarahM0  Add --emit-line-drective option (#861)
2019-11-01 9856269+sarahM0 Add spvcir unit test - OpCapability (#857)
2019-11-01 rharrison Add flag for updating invalid expecations and rewrite end logic (#856)

Created with:
  roll-dep third_party/shaderc

Change-Id: I81649618da6753657ef5a7533785559c2a13c416
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13180
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-07 17:02:57 +00:00
Yunchao He 252d1eb47f Suppress viewport test
BUG=dawn:205, dawn:257

Change-Id: I319211832818e3aa865cbfc4b342328cad832230
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-07 12:15:17 +00:00
Li, Hao 0e1bef3251 Add Vulkan validation layers on Windows
Deploy self-built Vulkan validation layers instead of system installed
one. And it will reuse third_party/angle's Vulkan validation layers if
building with chromium.

Bug: dawn:150
Change-Id: I94e26f7a152fb2a1c39bcb102d60024f4d65eee6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-07 12:13:27 +00:00
Yunchao He 64cfaeac4c Reland "Implement readonly storage buffer - validation at API side"
This is a reland of 34ac535f02

Original change's description:
> Implement readonly storage buffer - validation at API side
> 
> This patch adds validation code for API side for readonly storage
> buffer. It also adds unit tests for API validation.
> 
> BUG=dawn:180
> 
> Change-Id: I9a97c5f3aa23e720619d138ca55d7b17f08d64c9
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12620
> Reviewed-by: Austin Eng <enga@chromium.org>
> Commit-Queue: Yunchao He <yunchao.he@intel.com>

Bug: dawn:180
Change-Id: I1e107ff6168279940496317b973f2d8c7c3c6114
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13083
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-07 07:09:07 +00:00
Bryan Bernhart 2cdf132c0f Support for small resource placement.
Enables use of 4KB resource alignments where permitted.
This saves heap memory (4KB vs 64KB per allocation) and improves re-use.

BUG=dawn:27

Change-Id: I7a0a30252f480db2d0fa7f5d949207a56e3aa2e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12900
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-11-05 19:34:45 +00:00
Corentin Wallez c277c38d90 Suppress failing VertexFormat tests on Mac Intel
BUG=dawn:259

Change-Id: I6865c4acb2a717f11d74eaf26ec4df88100f1573
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13060
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-11-05 16:07:05 +00:00
Kai Ninomiya e3b510e462 Enable EmulateStoreAndMSAAResolve correctly by platform
Fixes the accidental disabling of the workaround on 10.11, where it is
required, and implements detection for iOS.

Bug: dawn:253, dawn:56
Change-Id: I0278f29892d3a49144b5e9620e4377e42a4a5155
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12960
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-11-05 15:56:05 +00:00
Corentin Wallez 0558f99119 Vulkan: Reuse descriptor pools
This changes puts descriptor pools in the BindGroupLayout so that they
can be reused between descriptors with the same layout.

This makes the DrawCallPerf.Run/Vulkan_NoReuseBindGroups benchmark go
from 1400ns to 800ns per run.

BUG=dawn::256

Change-Id: Ia9baf7f998d9ff4d552e255c80069b67c6a9ac40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12920
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-05 15:44:05 +00:00
Bryan Bernhart 6df81ebf1d Support for resource heap tier 2.
Enables mixing of texture and buffers in the same heap.
This allows better heap re-use and reduces internal fragmentation.
A toggle has been added and enabled by default.

BUG=dawn:27

Change-Id: I466dc96240fe1e8de6e3dc56ed5547d7b61ee045
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12821
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-11-01 18:19:01 +00:00
Austin Eng 314fd3513d Update SetBindGroup dynamic offsets to uint32_t
In WebGPU these are uint32_t because Vulkan accepts at most a 32-bit
unsigned integer.

Bug: dawn:22
Change-Id: Ia61cd710f80c19135ac215a9a93ef9a8f683bac2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12942
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-01 15:51:01 +00:00
Austin Eng c5e06a5d9f Fix result units in perf tests
Timing results extracted from trace events are reported in seconds,
not milliseconds.

Bug: dawn:208
Change-Id: I004d1ee5bbd0aaba8cf5b201f95903e76af0c530
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13000
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-01 15:07:01 +00:00
Austin Eng fb03935bed Add a GetInstanceProcAddr helper for the native Vulkan backend.
This is a helper to allow a Dawn embedder to look up the Vulkan device
functions.  Possibly remove when we design a cleaner way to share function
pointers.

Change-Id: I3ed92568e543c1aad9e0e64d72ad0990824640cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12980
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-01 01:10:09 +00:00
Austin Eng ec9010eabc Revert "Implement readonly storage buffer - validation at API side"
This reverts commit 34ac535f02.

Reason for revert: Failing Dawn into Chromium roll due to failed ASSERT
https://ci.chromium.org/p/chromium/builders/try/dawn-linux-x64-deps-rel/3514

Original change's description:
> Implement readonly storage buffer - validation at API side
> 
> This patch adds validation code for API side for readonly storage
> buffer. It also adds unit tests for API validation.
> 
> BUG=dawn:180
> 
> Change-Id: I9a97c5f3aa23e720619d138ca55d7b17f08d64c9
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12620
> Reviewed-by: Austin Eng <enga@chromium.org>
> Commit-Queue: Yunchao He <yunchao.he@intel.com>

TBR=cwallez@chromium.org,kainino@chromium.org,yunchao.he@intel.com,enga@chromium.org

Change-Id: I64e5dfd40e7aab982d97fb48544180bc9b8ea558
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:180
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12981
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-11-01 01:09:51 +00:00
Yunchao He 34ac535f02 Implement readonly storage buffer - validation at API side
This patch adds validation code for API side for readonly storage
buffer. It also adds unit tests for API validation.

BUG=dawn:180

Change-Id: I9a97c5f3aa23e720619d138ca55d7b17f08d64c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12620
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-10-31 17:56:42 +00:00
Jiajie Hu 9ec47a0bca Validate texture component type in BGL against its shader module declaration
We have already been validating the component type of a texture matches
the bind group layout. Here is another constraint introduced by
https://github.com/gpuweb/gpuweb/pull/384. For better code reuse,
conversion from wgpu::TextureComponentType to dawn_native::Format::Type
is factored out as a helper function.

Bug: dawn:202
Change-Id: I394497722b4043dc109eca60116224b7a617e02e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12860
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-31 09:51:11 +00:00
Austin Eng 64a3bb93dc Add DrawCallPerf tests
These tests draw a simple triangle with many ways of encoding commands,
binding, and uploading data to the GPU. This tests the performance of Dawn's
validation, command recording, and submission by switching buffer
bindings, bind groups, and pipelines. Some test instantiations upload
per-draw data to test efficiency of resource transitions or pre-record
commands in a render bundle.

Change-Id: I9994cd96ef5988cca410462418792f28161c0526
Bug: dawn:208
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12460
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-31 03:20:31 +00:00
Austin Eng 672707f76e perf_tests: Compute metrics for command validation and recording
This CL reads trace events from the tests and computes the total
time of validation and command recording.

Bug: dawn:208
Change-Id: I551d1e30e60b7d1a839b4fb834ad3608c6cedf63
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12782
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-30 01:02:03 +00:00
Austin Eng 84bcf44fae Only mark objects as cached right before inserting into the cache
This fixes bugs where we try to uncache objects that fail creation.

Bug: dawn:249
Change-Id: Ic60b3ce702dfdda18baa6d263911885a43d3cda7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12820
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-30 00:20:03 +00:00
Stephen White fe221ac089 Add another missing #include.
Change-Id: I5a34f78e0387d249185a9f3e24c7fd77a40c5a9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12841
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-30 00:19:43 +00:00
Bryan Bernhart 3debb26a9e Limit heap growth when uploading with SetSubData.
Removes unbounded heap growth by capping the heap
size to 4MB and falling back to direct allocation for larger
requests.

BUG=dawn:239

Change-Id: I9ae660809e3c0c539fbcfbee4afcf6fb1f466355
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12720
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-29 22:49:43 +00:00
Stephen White 6eb7d0ec3e Add some missing #includes.
Change-Id: I6d029dcddcfb77bbf30daa331ab066b6c254ee89
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12840
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2019-10-29 18:40:12 +00:00
Austin Eng 73d5bb57e6 Use enums for trace event categories
Explicit enums are simpler to use in Dawn and allow only specific
categories which the perf tests understand.

Also adds trace events around command recording and validation on
all backends.

Bug: dawn:208
Change-Id: I7859ffd6668b20893780c6081bf2c9019a7115e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12781
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-28 23:15:40 +00:00
Austin Eng 7a7d547381 perf_tests: Always capture trace events and flush incrementally
Previously, the trace event buffer was cleared after *all* tests
completed. In order to avoid allocating a ton of space to hold
traces, this patch factors the trace event recording so that the
buffer is processed and reset at the end of each test trial.

This patch also prepares for the future where trace events will be
processed at the end of each trial to compute additional metrics.

Bug: dawn:208
Change-Id: If2ed193ee47794c666df9f0b369ec1ce660b177f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12780
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-28 23:08:17 +00:00
Corentin Wallez 45b51f5df7 Make unittests and fuzzers use webgpu.h
BUG=dawn:22

Change-Id: Iff5465ad7a9456f9c6b2ee380af748b3afc129b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12741
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-28 22:15:47 +00:00
Corentin Wallez cab352c2f6 Make end2end and perf tests use webgpu.h
BUG=dawn:22

Change-Id: Ief855d294779b97283a79532e9d503aab6fda751
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12740
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-28 13:27:36 +00:00
Bryan Bernhart 9cf62efda9 D3D12: Use CheckHRESULT for allocator errors.
BUG=dawn:27

Change-Id: If28d1cbafcbdac29bafac0fb0e846208634ece33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12521
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-28 12:59:36 +00:00
Austin Eng f6281a5530 perf_tests: Add missing trace event "id"
This missing identifier is used to match async trace events. Its
absence broke async trace events since their Begin/End could not
be matched correctly.

Bug: dawn:208
Change-Id: I0671af8c3cbb8ff6220adcb8ed5621b831e383c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-28 11:35:20 +00:00
Corentin Wallez 04863c42be Make examples and utils use webgpu.h
BUG=dawn:22

Change-Id: I602d6a3422b493d199f3fded61ff1666bc2d9d7d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12702
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-25 11:36:47 +00:00
Corentin Wallez 9f90c8d3ca Make dawn_native public headers and dawn_wsi use webgpu.h
BUG=dawn:22

Change-Id: I112d71323c9305fa0997d251556fe0a41dafed29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12701
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-24 23:55:37 +00:00
Corentin Wallez 1fdcb16b69 Make dawn_wire use the webgpu.h header
BUG=dawn:22

Change-Id: I4963aa27322086e74947a1a6265c921e2c7d3d85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12700
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-24 22:27:27 +00:00
Corentin Wallez 15e751e418 Vulkan: Implement initial version of the suballocation
This makes the Vulkan backend use the BuddyMemoryAllocator to
sub-allocate small resources inside a larger VkDeviceMemory object.
Right now the heuristic to decide to do suballocation is naive and
should be improved.

BUG=dawn:27

Change-Id: Idcc7b6686c086633c85328a7afb91ee84abf7b8c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12662
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-24 21:32:27 +00:00
Corentin Wallez ca35435716 Preliminary changes to Vulkan memory suballocation
This mostly makes the MemoryAllocator not owned by the
BuddyResourceAllocator so that we don't need an extra class for the
dependency injection in the Vulkan backend. (the container for the
BuddyMemoryAllocator can be it's MemoryAllocator at the same time).

Also renames methods of MemoryAllocator to be more explicit.

Also renames the constructor parameter of BuddyMemoryAllocator to be
(subjectively) closer to what the represent.

BUG=dawn:27

Change-Id: I37355ad5b3cded143956f0adc4742fa1b717e9bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12661
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-24 21:28:16 +00:00
Corentin Wallez 60a04dd18c Vulkan: Use the ResourceMemoryAllocator for all resources
This removes the duplication of the memory allocators in preparation for
using sub-allocation in the Vulkan backend too.

Also renames ResourceMemory to ResourceHeap and MemoryResourceAllocator
to ResourceMemoryAllocator, and fixes a number of unused includes.

BUG=dawn:27

Change-Id: I1a9e7d41e5efafa5192bda1d89dc06455fa2af40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12660
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-24 21:24:27 +00:00
Yunchao He 6da1770507 Fix ambiguous errors for bind group
BUG=

Change-Id: I384e8125674dd5a83ef742fde9f3546f938909df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12680
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-24 17:27:06 +00:00
Yan 402fbcca93 Enable UpdateDynamicOffsetsMultipleTimesComputePipeline case
Austin added barriers for storage buffer in compute pipeline in
this patch (https://dawn-review.googlesource.com/c/dawn/+/12301).

This case now can work fine.

Bug: dawn:236
Change-Id: Id449ae5053f1f018ea95c271bff7e4ab2180a937
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12640
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-23 16:34:42 +00:00
Corentin Wallez 1f6c8c4d54 Make dawn_native use the webgpu.h header
BUG=dawn:22

Change-Id: I66e2d998f5e09030e40ec88813cd65c492018fd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-23 11:57:41 +00:00
Bryan Bernhart c833c0c592 D3D12: Enable sub-allocation for MSAA and non-MSAA textures.
Updates TextureD3D to use the allocation handle and
defaults to using MSAA heaps.

BUG=dawn:27

Change-Id: I2318bb8d068df86364cb2ebc433f4737e9e121aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12580
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-22 21:01:11 +00:00
Austin Eng 7b3cc35cb6 D3D12/Vulkan: Insert storage buffer barriers between compute pass dipatches
This patch extends the BindGroupTracker in the D3D12 and Vulkan backends to
track bound storage buffers. We insert barriers between dispatches to properly
synchronize writes to storage buffers.

Bug: dawn:236
Change-Id: Iab3f964c345b64755557ab206e05a2ff7b0a3a1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12301
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-22 17:28:20 +00:00
Corentin Wallez 2c8b5c6370 Introduce the webgpu[_cpp].h headers.
webgpu.h is the "official" header for WebGPU in native and is being
developed in https://github.com/webgpu-native/webgpu-headers

dawn.h and dawncpp.h are changed to become webgpu.h and webgpu_cpp.h
respectively and use the new naming convention. New dawn.h and dawncpp.h
headers are created that just proxy the types, constants and functions
to their WebGPU counterpart.

Almost no naming change is done in Dawn in this commit, which help check
that the proxying headers work correctly. A couple changes were
necessary, in particular for tests of the internal of dawncpp.h, and a
workaround for a standard library bug for std::underlying_type was
removed because it is no longer needed and got in the way.

Finally since some templates were renamed to match the name of the file
they create instead of using the generic "api" name.

BUG=dawn:22

Change-Id: I12ee22d0b02ccb5b8a52ceccabb3e63ce74da007
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-21 20:04:10 +00:00
Rafael Cintron f0c036a3d2 Plug D3D 11on12 memory leak
11on12 has a bug where D3D12 resources used only for keyed
shared mutexes are not released until work is submitted to
the device context and flushed.

The most minimal work we can get away with is issuing a
TiledResourceBarrier.

ID3D11DeviceContext2 is available in Win8.1 and above.
This suffices for a D3D12 backend since both D3D12 and 11on12
first appeared in Windows 10.

Bug:dawn:217
Change-Id: I422eedf0de9c41777ab704f63520e2f2584f2afb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12520
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
2019-10-21 15:13:29 +00:00
Bryan Bernhart 8d00f5db8f Prevent kMaxHeapSize overflow on 32-bit debug builds.
Uses uint64_t instead of size_t in isPowerOfTwo checks.

BUG=dawn:27

Change-Id: If8bcdcd855d10fd2dc1f42fa18e3defab13a76b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12500
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-21 09:23:09 +00:00
Jiawei Shao 5c2f5f3961 Implement serialization/deserialization of DawnDeviceProperties
This patch implements the serialization and deserialization of
DawnDeviceProperties in dawn_wire for the use of serializing this type
of object in Chromium.

BUG=chromium:996713
TEST=dawn_unittests

Change-Id: I1678627a017079540689d8529a1a7e1c975aae61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12240
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-20 03:01:56 +00:00
Bryan Bernhart f603903da7 Replace size_t with uint64_t in ringbuffer.
Adds overflow check in RingBufferAllocator + unit-test.
Also, update clients to use uint64_t to avoid casts or narrowing.

BUG=dawn:233

Change-Id: I652e3142407006d082491add600371f95d44741a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12380
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-18 16:19:00 +00:00
Yizhou Jiang 4794168ef8 Use toggle to turn off vsync on D3D12
Parameter syncInterval of function Preset specifies how to synchronize
presentation of a frame. To turn off vsync in D3D12 backend,
set syncInterval to 0 which represents the presentation occurs
immediately.

BUG=dawn:237

Change-Id: Ic17f00bae5af9fd6bca4130d6e2282f3c34de4e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12303
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
2019-10-18 01:45:28 +00:00
Rafael Cintron b2b2ef57a5 Add D3D12 keyed shared mutexes to Dawn
Dawn creates a keyed shared mutex for all wrapped resources and acquires
the mutex before the texture is used in an ExecuteCommandList call.

To coordinate with external clients, backend API has been extended
to allow clients to get and set the acquire key.

Pending and queue command lists have now been merged into one.

A future change will adjust GetPendingCommandContext to return a raw
command context without the need for error handling.

Bug:dawn:217
Change-Id: Ia96c449c305586407153f05ce75a40794b96027e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12220
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
2019-10-18 00:37:42 +00:00
Austin Eng 92a011a253 Record and dump trace events in the perf tests
Trace data can be used to build additional metrics which measure
validation costs, GPU time, etc. It will also be helpful to store in
the test output for later analysis.

This CL also adds jsoncpp as a DEP so we can dump trace file json
output.

Bug: dawn:208
Change-Id: Ia6c05ca90aecae308ee6a4fd11e5f43bb03b1dc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12080
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-17 19:00:32 +00:00
Bryan Bernhart 154badfe2f Resource Management 8: placed resource sub-allocation.
- Adds d3d allocators (placed resource + heap).
- Support for heap tier 1 but only buffers.
- Suballocation optimization is enabled for allocations under 4MB.

BUG=dawn:27

Change-Id: I79177830670d1f322bbadf45f797415a3e9208d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5680
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-17 17:25:28 +00:00
Austin Eng 31bde95857 perf_tests: Replace WaitForGPU with maxStepsInFlight argument
The current BufferUpload perf test calls WaitForGPU at the end of
every step to time how long the batch of uploads took. Future tests
will want to have multiple Steps or Frames in flight to mimic real
applications that use double or triple buffering. This patch removes
WaitForGPU and adds a |maxStepsInFlight| argument which a test can
set to configure how many steps can be running on the GPU.
For the BufferUpload tests, this is still 1.

Bug: dawn:208
Change-Id: I95ae12b2358e0283088205bd2ffd20532ea62871
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12302
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-17 00:15:07 +00:00
Austin Eng 7f426898ef Skip BufferUploadPerf 16MB SetSubData on all backends.
This test is flaky on all backends.

Bug: dawn:239, chromium:1014946
TBR=cwallez@chromium.org

Change-Id: I77dd261420c78d4b7f21a9e54b835ee3466df97d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12360
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-16 18:59:04 +00:00
Corentin Wallez e180b591d1 Fix compilation with shared_library components on Windows
An exported function of libdawn_native wasn't in libdawn_native_sources
instead of libdawn_native which made it not exported on Windows.

BUG=dawn:22

Change-Id: I824f1d4af18f8308b88e1650837cbe62374ace72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12320
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 15:31:31 +00:00
Corentin Wallez fb7508435f Add missing header for MSVC
BUG=dawn:22

Change-Id: I627768f450a42d6f3522156eb1702114040c8a39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12321
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 11:44:11 +00:00
Austin Eng cc071e45bb Split generation of dawncpp headers from libdawncpp
libdawn_native also requires the dawncpp headers. When we separated
libdawn_cpp from the dawn_headers, libdawn_native lost the cpp headers
and caused a compile failure. This patch separates the dawncpp headers
as a separate target so both libdawncpp and libdawn_native can depend
on them.

Bug: dawn:22
Change-Id: I4172f1654377afac8c4314123ee8b5b81dc7c928
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12300
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 10:26:01 +00:00
Natasha Lee f3d50baf85 D3D12 replace ASSERT_SUCCESS with better error handling
Added D3D12Error to check HRESULTS and return error messages
with the correct error names.

Remove ASSERT_SUCCESS from D3D12 backend and use
MaybeError and ResultError instead to handle errors.


Bug: dawn:19
Change-Id: Idf2f1987725e7e658bd29a9b13653125ab43c564
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12000
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 09:26:54 +00:00
Li, Hao c7d535bd72 Prioritize discrete GPU in end2end tests
- Prefer discrete GPU on multi-GPU systems, otherwise get
integrated GPU.
- Add a test to check adapter filter.

BUG=dawn:184

Change-Id: Ib1c3e81e20a15aeaf18746892324ce5144b7fda1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9320
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-16 09:24:55 +00:00
Stephen White fd90d767ba clang-win compile files for skia-dawn.
Do explicit uint8_t -> float conversions (as was previously done for TextureVk).
Add a missing #include.

Change-Id: If7616ec00e2ea2cf55b9b0cc966b0436a5a21d9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12280
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2019-10-15 19:29:58 +00:00
Corentin Wallez c57b180208 Add dawnGetProcAddress.
This will become wgpuGetProcAddress that is part of the webgpu.h and the
last gap in functionality for dawn.h to match webgpu.h.

BUG=dawn:22

Change-Id: I0dcb3b5e6bd99cb10db273fc101d3ec0161b7da0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-15 12:08:48 +00:00
Corentin Wallez 96496828a0 Split the libdawn target in components with a single purpose.
The functionality of the dawn_headers and libdawn targets are split into
the following targets:

 - dawn_headers: the new version only exposes the "dawn.h" C API and no
   longer includes the C++ API.
 - dawncpp: the header and implementation of the C++ API that wraps the
   C API. This is unbundled from the rest so the C++ API can be used
   with libdawn_proc or other libraries implementing the C API.
 - libdawn_proc: A DawnProcTable-backend implementation of the C API.

This is needed because in follow-up commit there will be three libraries
implementing the C API: libdawn_proc that trampolines where we want, and
libdawn_native/wire that don't have trampolines for better perf.

BUG=dawn:22

Change-Id: I5d941f0d98e5a4b633e14d67eb5269f7924f0647
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12160
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-15 11:44:38 +00:00
Yizhou Jiang 1093c4de2c Add a toggle to turn off vsync in Dawn
This commit add a toggle to turn off vsync in Dawn.
When turn off vsync, choose vulkan present mode VK_PRESENT_MODE_IMMEDIATE_KHR
if the mode is available on the system, but if the mode isn't supported,
choose default mode VK_PRESENT_MODE_FIFO_KHR.

BUG=dawn:237

Change-Id: If400262b67cc8051422745e3bed737431183c0b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
2019-10-15 07:43:05 +00:00
Corentin Wallez 2e666bd5de Vulkan: Remove two ASSERT(false) with more detailed reading of Vk spec.
QueueWaitIdle can fail but if it fails, the error codes show that we
can't do anything about it so we just ignore the result.

BufferGetMemoryRequirements should always return memory types bits that
allow Dawn to select a good memory type of a resource.

BUG=dawn:19

Change-Id: I52beebf9f2be2bfb997ca9c1bf306618a73c9c4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12183
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-15 07:29:55 +00:00
Li, Hao d59fec5d70 Skip LargeBufferFails test with NVIDIA for enabling Vulkan validation layers on Windows
Fails on NVIDIA cards when Vulkan validation layers are enabled becuase the maximum size of a single allocation cannot be larger than or equal to 4G on some platforms.

BUG=dawn:241

Change-Id: I863a2219287d3d363b3013027ba8fc9df846b42d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12141
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-10-15 01:42:45 +00:00
Jiawei Shao 91fbfc34e8 ASSERT object is not nullptr in DeviceBase::ValidateObject
This patch adds an ASSERT expression on the object parameter of
DeviceBase::ValidateObject() so that Dawn won't crash in the debug
build when a nullptr object is being used unexpectedly.

BUG=dawn:209

Change-Id: I52ad57b58eb59edf04afc9963e260436d93e673e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-10-15 00:17:35 +00:00
Corentin Wallez ba9e1ff86f Fix compilation in MSVC that was missing a <utility> include
BUG=

Change-Id: I3090fec89bb9dd39d28997cb58943643e8c7ed6f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12182
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-14 14:24:50 +00:00
Corentin Wallez b6acae6d35 Suppress BufferUploadPerf for setSubData of 16MB on Vulkan
TBR=enga@chromium.org
BUG=dawn:239

Change-Id: Ie6dda6df45326d57d7ea8f04670904afee25b51d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12161
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-14 12:38:10 +00:00
Corentin Wallez c44b2d4881 Vulkan: Properly handle errors for fences and commands
This commit makes the following changes:
 - Unused fences are reset when they will next be used so there is a
   single place where error handling is needed, either for resetting
   an existing fence, or for creating a new fence.
 - All accesses to VkCommandBuffer are moved to using the
   CommandRecordingContext and GetPendingCommandBuffer is removed.
 - Instead of tracking both a current (VkCommandBuffer + Pool) and
   a command recording context that contains the same VkCommandBuffer,
   the RecordingContext now holds the pool too, as well as a tag to
   know if it was ever queried (meaning it contains commands).
 - mRecordingContext is now always valid, such that
   GetRecordingContext() doesn't need to return an error.

BUG=dawn:19

Change-Id: I853d4ecdc6905b66e842688f39d863e362f59b66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12022
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-11 12:12:07 +00:00
Corentin Wallez 76e1e41cc7 Vulkan: Proper error handling for submission.
BUG=dawn:19

Change-Id: I457a7d3f95a9f486b6d7dbf5fe1885758362d504
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12021
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-11 11:29:46 +00:00
Corentin Wallez 18a5d42898 Vulkan: Handle errors when creating VkRenderPass
BUG=dawn:19

Change-Id: I6007fb594a7c073b835554ca6914453a67608947
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11863
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-11 11:17:22 +00:00
Bryan Bernhart 3b05a6e031 BufferUploadPerf: Measure various buffer sizes.
Upload perf depends on buffer size. Try small and large buffers
to ensure allocation tuning is more accurate.

BUG=dawn:208

Change-Id: I1ee23454e86a31cf0a316946bc87550dad51e5c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11961
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-10 18:14:28 +00:00
Rafael Cintron 8bde031abe Add CommandRecordingContext to D3D12
This change refactors D3D12 backend to have CommandRecordingContext
CommandRecordingContext allows us to, in a future, add additional
data to the context such as textures that need to be acquired and
released before command lists are executed.

The Device's pending command list and the command list which resides
in the Queue object were converted to use CommandRecordingContext.

Bug=dawn:234

Change-Id: Ic13a229fc1f15895ef71117ce638c942de224743
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11940
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-10 18:06:58 +00:00
Corentin Wallez d285525d4a Make the offset of SetIndexBuffer default to 0
BUG=dawn:22

Change-Id: Icc4f03c3f49b610ef5f620b4c26a6ae24ed6c774
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12040
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-10 17:21:48 +00:00
François Beaufort bed0fdf7ad Allow Bind Group Layout Binding visibility to be None
According to https://github.com/gpuweb/gpuweb/issues/405, None is a
valid value for GPUBindGroupLayoutBinding visibility to be passed in.

Bug: dawn:22
Change-Id: I7b30b7ab8ed6824718573fa25fad5d509846db55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
2019-10-10 09:08:29 +00:00
François Beaufort 91b2142ee4 Change setVertexBuffers to setVertexBuffer
Following WebGPU spec change at
https://github.com/gpuweb/gpuweb/pull/468, this CL changes all
occurrences of setVertexBuffers to setVertexBuffer.

Bug: dawn:22
Change-Id: I48b551a89dc0934dfa61e661e9546a2b7eafd2fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12020
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-10 07:29:58 +00:00
Bryan Bernhart e16a901fb8 D3D12: Move resource into allocation handle.
Allows buffer/texture direct access to underlying resource rather than indirectly with a opaque memory type.

BUG=dawn:27

Change-Id: I2eb69f4e30c96c431dbc96094d671be1e0a29869
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-09 16:50:42 +00:00
Austin Eng e79b06100f Skip tests if no adapter is available
Bug: dawn:208
Change-Id: I076fd497101dd017e8d83ae034edb7b1fa1f8581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11941
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-09 16:23:22 +00:00
Corentin Wallez 70c8c10571 Make the dynamicOffsets optional in SetBindGroup.
BUG=dawn:22

Change-Id: I9d032d9be16a483046edc6055b86e61ae08118e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12023
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-09 16:08:42 +00:00
Corentin Wallez e09869ed52 Vulkan: Handle errors when wrapping external images
This also introduces another combinator to ConsumeError for
ResultOrError.

BUG=dawn:19

Change-Id: Ic204313436f5e919473d604efd049fe3d3c27a66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11862
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-09 10:11:00 +00:00
François Beaufort c932f33093 Attribute offset needs to be multiple of 4 bytes
Metal requires offset to be 4 bytes aligned. This CL makes sure a
validation error is fired when offset is not a multiple of 4.

See https://developer.apple.com/documentation/metal/mtlvertexattributedescriptor/1515785-offset

Bug: dawn:22
Change-Id: I8be26fc1851e3aea7cfdbd5c92dfb4169fdaed5e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11902
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-09 06:12:10 +00:00
Corentin Wallez e986cb9254 Vulkan: Add proper error handling for all regular object creation.
This makes all the regular WebGPU object creation handle errors properly
in the Vulkan backend instead of ASSERTing no Vulkan error is raised.

Static Create functions are added to all these types so that the details
of how the initialization is done is private, and it isn't possible to
construct an object but forget to initialize it.

BUG=dawn:19

Change-Id: I362b2d66b74dd7799ffbf69d732bc58caa97950b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-08 08:16:11 +00:00
Bryan Bernhart bc8e7ea286 Fix MSVC build error due to implicit descriptor heap offset cast.
BUG=dawn:233

Change-Id: Ia42d7e99df910f245b7c78be16b7916c0730e8a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11960
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-08 07:46:51 +00:00
Corentin Wallez b629c50a20 Guard macOS or iOS specific code in #if guards
This is necessary because @available(macOS 10.N, *) is taken on all iOS
versions but there is no way to say the branch is just not taken on any
iOS version. The proper way to deal with this is to add additional #if
guards to just not compile the code on iOS / macOS.

BUG=dawn:225

Change-Id: I76ec01f933364e9b47b5dda1198359f2ab4d1188
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11900
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-08 07:44:21 +00:00
Corentin Wallez a83e0cdbcc Remove stray push constant code.
There was still some logic associated with push constants in Dawn. This
removes it to remove some code and reclaim one buffer in Metal. Related
code was found via `git grep "push constant"`.

BUG=

Change-Id: I17de9d47872483875b6fa292f8259ef1fc4ecaf3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11904
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-08 07:37:02 +00:00
Corentin Wallez bd481fc199 Allow ResultOrError to downcast from backend to frontend types
More concretely this makes Result<T*, E*> able to be move-constructed
from Result<ChildClassOfT*, E*> for free.

BUG=dawn:19

Change-Id: Iea2b8997079ac3bfcf270d6b73a79cf5cac2c06f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11860
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-08 07:36:03 +00:00
Mathieu-Andre Chiasson 720988d878 Fixed compilation issue on clang 6.x
Bug:dawn:235
Change-Id: If96dbb9f70ee95a93fc1f14a9741903c3fd32b66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11942
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-10-08 01:55:57 +00:00
Austin Eng 8eb8385e2e dawn_wire: Tag deserialize commands with volatile pointer
This prevents bugs where the compiler assumes a piece of memory
will be the same if read from twice.

Bug: dawn:230
Change-Id: Ib3358e56b6cf8f1fbf449c5d564ef85c969d695b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11840
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-07 20:38:47 +00:00
Rafael Cintron 86d921e048 Add MaybeError to d3d12::Device::ExecuteCommandList
Closing a command list can fail. We need to handle the error
gracefully instead of ignoring it.

As a fallout from adding MaybeError to ExecuteCommandList, need to
also add MaybeError to TickImpl, and OnBeforePresent.

Bug:dawn:19
Change-Id: I13685f3dd731f4ab49cbff4ce4edfa960d630464
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11841
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
2019-10-07 15:32:10 +00:00
Jinho Bang 0b82671047 Rename PipelineStageDescriptor to ProgrammableStageDescriptor
This is to match the WebGPU's WebIDL[1].

[1] https://github.com/gpuweb/gpuweb/pull/359

Bug: dawn:22
Change-Id: Id0cf0a7a6605ea7ec474d0f0885685ed21875dce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11883
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-07 12:23:09 +00:00
Corentin Wallez 90a5595bbe dawn_wsi: Pass the Metal queue to the SwapChainImpl
If the swapchain creates its own queue, there can be races to determine
whether the submit of the present happens first. The didn't show up
in our samples but was an issue in real apps. Passing the queue to the
swapchain makes it simple to keep operations well ordered.

BUG=dawn:225

Change-Id: I9cc8e6e8140ad4a816373cffc9bda74ee826a41b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11640
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-07 08:18:09 +00:00
Bryan Bernhart 21dfc91954 Resource Management 7: Device memory sub-allocation using buddy allocator.
Uses a large buddy system to allocate binary sized heaps on-demand.

BUG=dawn:27

Change-Id: I72e425c23e601da6ee53827423bef7ff13be049c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10880
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-03 18:17:31 +00:00
François Beaufort 277d2e15d5 Add missing optional label member to descriptors
This CL adds missing optional label members to all descriptors. It is
not used yet but needed from the WebGPU side.

Bug: dawn:22
Change-Id: I103870f9207eed8168bc2245294888af4e1edd9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11720
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-03 14:56:49 +00:00
Austin Eng 3fd022ef60 Validate injected errors are not NoError
HandleError assumes that the error is not NoError. InjectError is
an untrusted wire command and needs to validate that NoError is not
passed.

Bug: chromium:1010703, chromium:1004368
Change-Id: Id48a877ded327a6e3a54fedb2be2c54eeca5cd3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-03 14:40:09 +00:00
Bryan Bernhart 0da52f2d92 D3D12: Move resource allocators from device into manager.
Encapsulates resource allocation using a manager class.

BUG=dawn:27

Change-Id: I7a496261dcede647d32e44d96ed27237bf418fb2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11742
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-02 21:45:09 +00:00
Austin Eng 867f72058a Add missing "strlen" parameter for Device InjectError command.
This CL adds a StringMessageMatcher to the wire unittests harness
to validate that messages are not degenerate.

Bug: chromium:1004368
Change-Id: I121a259e67938b06ccc5e9829abfa3e25fffc003
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11740
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-02 06:35:38 +00:00
Austin Eng dc9f1e6806 Add validation tests for WebGPU bind group "persistence"
A draw should be valid if the currently set bind groups match the
current pipeline layout, irrespective of changes in pipeline layout.
This is different from the descriptor set inheritance in Vulkan which
Dawn used to follow.

Bug: dawn:201
Change-Id: I1181ba80614ae40d665094f4ea742804565f6ed3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11641
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-02 06:27:58 +00:00
Jiawei Shao deb28ea45d D3D12: Implement ASSERT_SUCCESS as macro instead of function
This patch implements ASSERT_SUCCESS(hr) as a macro instead of a
function so that when hr fails Dawn can print out the line number of the
expression that causes the failure.

For example, previously we will always get the following error message
because ASSERT_SUCCESS is a function:
Assertion failure at ../../src/dawn_native/d3d12/DeviceD3D12.cpp:43
(ASSERT_SUCCESS): (((HRESULT)(hr)) >= 0)

Now we can get more details about where the failure occurs because now
ASSERT_SUCCESS is a macro:
Assertion failure at ../../src/dawn_native/d3d12/DeviceD3D12.cpp:59
(Initialize): (((HRESULT)(mD3d12Device->CreateCommandQueue(&queueDesc,
__uuidof(**(&mFence)), IID_PPV_ARGS_Helper(&mFence)))) >= 0)

BUG=dawn:178

Change-Id: I435ee2f418658bca276f439fcabfabbfecbff998
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11700
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-01 02:30:32 +00:00
Bryan Bernhart e6b93e8706 D3D12: Use ringbuffer allocator for descriptor heaps.
Enable descriptor heap re-use by using ringbuffer.

BUG=dawn:155

Change-Id: I72e3fb98a64dc1af671e185e2114868a577a0554
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9460
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-10-01 02:19:02 +00:00
Austin Eng e06f01be71 dawn_wire: Forward client-generated errors to the server
This fixes a problem where client-generated errors weren't properly
captured in error scopes.

Bug: chromium:1004368
Change-Id: Ic0f6e5bc5e281c676ea7154dd217cfc8dd51be5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11642
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-09-30 22:50:59 +00:00
Jiawei Shao 55a00c7a1f Set writemask to 0 when no fs output matches color state on Metal and Vulkan
This patch fixes an undefined behaviour on Metal and Vulkan when there
is a color state whose corresponding fragment output is not declared in
the fragment shader.

According to Vulkan SPEC (Chapter 14.3), the input values to blending or
color attachment writes are undefined for components which do not
correspond to a fragment shader output. Vulkan validation layer follows
the SPEC that it only allows the shader to not produce a matching output
if the writemask is 0, or it will report a warning when the application
is against this rule.

When no fragment output matches the color state in a render pipeline,
the output differs on different Metal devices. On some Metal devices the
fragment output will be (0, 0, 0, 0) even if it is not declared in the
shader, while on others there will be no fragment outputs and the content
in the color attachments is not changed.

This patch fixes this issue by setting the color write mask to 0 to
prevent the undefined values being written into the color attachments.

With this patch, the following end2end tests will not report warnings
any more when we enable the Vulkan validation layer:
ObjectCachingTest.RenderPipelineDeduplicationOnLayout/Vulkan
ObjectCachingTest.RenderPipelineDeduplicationOnVertexModule/Vulkan
ObjectCachingTest.RenderPipelineDeduplicationOnFragmentModule/Vulkan

BUG=dawn:209
TEST=dawn_end2end_tests

Change-Id: I5613daa1b9a45349ea1459fbdfe4a12d6149f0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11581
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-09-30 07:27:57 +00:00
Bryan Bernhart 52bd6b7da6 Move kInvalidOffset to RingBufferAllocator namespace.
BUG=dawn:27

Change-Id: I1c580d8e41c4f9bb10b638297b4c3a3fa61a0d93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11680
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-27 21:26:13 +00:00
Bryan Bernhart 86ac0b93c9 Rename INVALID_OFFSET to kInvalidOffset.
BUG=dawn:27

Change-Id: Ida590a2b3cf3da17bbedf6ef61d72eaaa443bc4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11561
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-27 15:11:52 +00:00
Jiawei Shao 64f4dd7127 Add check between color state format and fragment shader output
This patch adds the validation on the compatibility between the format
of the color states and the fragment shader output when we create a
render pipeline state object as is required in Vulkan (Vulkan SPEC
Chapter 14.3 "Fragment Output Interface"):
"if the type of the values written by the fragment shader do not match
the format of the corresponding color attachment, the resulting values
are undefined for those components".

BUG=dawn:202
TEST=dawn_unittests

Change-Id: I3a72baa11999bd07c69050c42b094720ef4708b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11461
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-09-26 00:12:41 +00:00
Mathieu-Andre Chiasson 09cc2b92c7 Fixed compilation issues when using libstdc++
Bug:dawn:229
Change-Id: I18ce6330bc4597db4f2c4548698b38ab2c826203
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-25 19:32:01 +00:00
Natasha Lee cf0e9d93f1 Add StoreOp::Clear
When storeOp is clear, texture subresource is set as not initialized

Bug: dawn:145
Change-Id: I364d7239a7ebdb9d5a28a4af559f3212be7ef15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11560
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-25 13:08:28 +00:00
Jiawei Shao 05be0ff348 Validate fragment output location doesn't exceed kMaxColorAttachments
This patch adds the validation on the fragment shader output location to
ensure it will never exceed kMaxColorAttachments.

BUG=dawn:202
TEST=dawn_unittests

Change-Id: I4ac4463fd3dfb3c2e9ffecb370f9d9d59393c26d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11580
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-25 01:21:28 +00:00
François Beaufort c3b613296d Rename GPUBindGroupLayoutBinding dynamic to hasDynamicOffset
Following WebGPU change at  https://github.com/gpuweb/gpuweb/pull/427,
this CL renames GPUBindGroupLayoutBinding dynamic to hasDynamicOffset.

Bug: dawn:22
Change-Id: Ie1c2bf4b1f6764c83be7cfe04f4f1a1d2205f685
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11500
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-24 11:08:17 +00:00
Bryan Bernhart 41f8aa550b Return Dawn result upon submit.
Missing OOM error should submit fail to create a descriptor heap.

BUG=dawn:177

Change-Id: I6ccc10f3e0b8de0bd21caa9aca35f4f269ce51e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11540
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-23 21:21:10 +00:00
Corentin Wallez c81a717379 Remove indirection for colorStates
This is to match the work in progress webgpu.h header.

BUG=dawn:22

Change-Id: Ia1077fef95e6bda541cddbd2f6ce40b79138e960
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9383
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-20 23:22:27 +00:00
Corentin Wallez b8dbada76d Make ComboRenderPipelineDescriptor non copyable.
This causes subtle bugs in tests when pointers in combo render pipeline
descriptors point at other combo render pipeline descriptors.

BUG=dawn:22

Change-Id: I5234df26895986fd1d7a9b4e835598177581803a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11340
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-20 23:15:47 +00:00
Yunchao He 394553b02e Set y-axis up in normalized coordinate system.
BUG=dawn:224

Change-Id: I6bb4946e87b593f1d62a13b3b8ab38f21d3e9ffb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10201
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-09-20 23:04:47 +00:00
Corentin Wallez a838c7d497 Remove indirection for colorAttachments
This is to match the work in progress webgpu.h header.

BUG=dawn:22

Change-Id: I1371cda1b7666de8eb8283fa7e5da935d17e1d52
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9381
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-20 22:59:47 +00:00
Brian Sheedy 0c4d75931a Disable BufferSetSubData.ManySetSubData on Metal
Disables ManySetSubData on Intel/Metal configurations, as it has started
failing on Mac 10.14.6.

Bug: dawn:228
Change-Id: Ia7d27a698deb9abc08cc04660903e5c6c93bbf50
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11460
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-20 22:16:03 +00:00
Corentin Wallez 38b295de38 Fix availability check for MTLCopyAllDevices
This caused failure on macOS 10.11 because Dawn decided Metal is
supported but would go ahead and reach an UNREACHABLE() block.

BUG=chromium:1006181

Change-Id: I20739a058adaa60a71ec489e07b36ebf48ef871a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11420
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-20 17:40:53 +00:00
Corentin Wallez a9a84dfe1e BUILD.gn: Delete stale generated files in Dawn's gen dir.
This normalizes even more the directory structure of generated files in
Dawn and removes stale autogenerated files that could be included
wrongly using a GN action.

See comment on top of dawn_generator.gni in this commit for more
context.

BUG=dawn:22

Change-Id: I8ec038f949c048431b2b643af4462f98c4ae610b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11361
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-19 23:30:42 +00:00
Bryan Bernhart bdd88a7dc1 Check if allocation is valid before deallocating.
Ensure deallocate does not assert should allocation fail but still be used.

BUG=dawn:227

Change-Id: I5edd4c160bced7934970c5d59e541a3a8f7a8afb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11380
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-19 20:40:12 +00:00
Ryan Harrison ae4dbeb178 Roll ahead shaderc API and update API usage as needed
Roll third_party/shaderc/ 4baa46a5d..68b6857ac (2 commits)

4baa46a5d1..68b6857ac0

$ git log 4baa46a5d..68b6857ac --date=short --no-merges --format='%ad %ae %s'
2019-09-18 rharrison Code hygiene work for spvc (#808)
2019-09-10 stevenperron Have update_build_version.py new parameter (#805)

Change-Id: I06e0f62a1443741e8ac09a84ff63ddd100f6a656
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11341
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2019-09-19 14:20:46 +00:00
Bryan Bernhart 450e212cf5 Remove device dependencies from ringbuffer.
Allows ringbuffer sub-allocator to be used for non-staging memory.

BUG=dawn:155

Change-Id: Id0021907f520909aaebaf79e992124a47797d38d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9760
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-09-18 22:06:41 +00:00
Austin Eng b11bd2dfe5 Fix leak of ErrorData after Device::ConsumedError
The code to delete this ErrorData* was lost in the error scope
refactor.

Bug: chromium:1002783, chromium:1002888, dawn:153
Change-Id: Iebe13c778079501193b942ebd97a559041516c3d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11320
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-09-18 21:03:41 +00:00
Corentin Wallez 897ebc7a71 Normalize generated file paths to match main tree.
Previously dawn_native files were in src/dawn_native/ while generated
files were in dawn_native/. This makes some things complicated when
integrating in other source trees so normalize all generated files to be
in paths that match the main tree.

BUG=dawn:225

Change-Id: I5b3e04d37a16251143578dfb7a31445b229fe4ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11300
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-18 04:33:12 +00:00
Corentin Wallez b495e48405 Support compilation of Dawn on iOS.
BUG=dawn:225

Change-Id: I618552c55c8472adc25625733b59d972d7297f57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11040
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-18 04:32:52 +00:00
Corentin Wallez 5e9082daa4 Add some missing headers in BUILD.gn files.
BUG=dawn:225

Change-Id: Ie1ebe62caea48353b6b3579c9405b5cc700fba66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11302
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-17 21:36:15 +00:00
Corentin Wallez f7c263624b Add missing include in the Vulkan backend.
BUG=dawn:225

Change-Id: I8dc0c5c884d8130b98a849e0d675e29d80aa4de8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11303
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-17 21:28:45 +00:00
Austin Eng 519b16c4b0 Add README.md for the Dawn perf test harness
Bug: dawn:208
Change-Id: Ic9b4c83ab3c27851d149adb5986f3a5556d0548a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11283
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-17 21:02:38 +00:00
Austin Eng 7f3f331ce6 Support setting bind groups before pipeline for all backends
This is to match WebGPU semantics.

Bug: dawn:201
Change-Id: I2aab671fc389edf1d2765395814a9c831afc653e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11080
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-17 19:25:27 +00:00
Natasha Lee 617e356580 OpenGL: clear nonrenderable texture formats
Clears nonrenderable color formats and merges zero vs nonzero clears
to use the same code path.

Bug: dawn:145
Change-Id: I8f2f36134b56787e07231d82e37c36897ba1d4ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10820
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-17 18:54:47 +00:00
Austin Eng be990077f4 Support ErrorScopes for asynchronous GPU execution
This changes updates ErrorScopes so that scopes enclosing a
Queue::Submit or Queue::Signal resolve their callbacks asynchronously
after GPU execution is complete.

Bug: dawn:153
Change-Id: I0e0b8a9f19f3f29d1b6a3683938154b87f190a07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10701
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-09-17 18:24:07 +00:00
Yunchao He bb3c895619 Fix a typo in viewport validation test
BUG=dawn:53

Change-Id: I793373fa6e1fb167d5a8fe0a064c57ddf2ceedba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11281
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-17 18:01:09 +00:00
Hao Li 2383fd4fbf Revert "Skip some end2end tests for Vulkan validation layers enable on Windows"
This reverts commit 4cc1891039.

Reason for revert: dawn:210 has been fixed, we can add these tests back.

Original change's description:
> Skip some end2end tests for Vulkan validation layers enable on Windows
> 
> Temporarily skip some tests to make Vulkan validation layers could be
> enabled on Windows, these tests are failing on Vulkan with validation
> layers enabled.
> 
> BUG=dawn:210
> 
> Change-Id: I03a6ab6aca94f7c7044cc27cc1ff5d79ad1f88d2
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11141
> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

TBR=cwallez@chromium.org,yunchao.he@intel.com,jiawei.shao@intel.com,shaobo.yan@intel.com,hao.x.li@intel.com,enga@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: dawn:210
Change-Id: I4f86369aa0dbfe366b0597cc844af4e74d687eea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11280
Reviewed-by: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-09-17 02:36:22 +00:00
Natasha Lee 01600dfb3d Use clear loadop to lazy clear depth stencil attachments
Bug: dawn:210, dawn:145
Change-Id: I1eb990266ccd7b51b4a336b0d4d37e0195c6fe69
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11020
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-11 22:04:42 +00:00
Li, Hao 2a2392073b Set point size value for vertex shader in OptionalVertexInputTest
When pipeline topology is set to Point_List, PointSize must be written
in vertex shader for Vulkan backend.

BUG=dawn:146

Change-Id: I0ea6aa937866d1985287d353f82d344100b41acd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-09-11 15:59:16 +00:00