Commit Graph

1917 Commits

Author SHA1 Message Date
Tomek Ponitka eac38cfbc1 Fixing a deprecated arrayLayer value inside Queue::WriteTexture
Chromium always sends arrayLayer instead of origin.depth since
the migration hasn't been finished yet. This wasn't caught
in Dawn's testing since we are using origin.depth everywhere.

Bug: dawn:483
Change-Id: I13b1ccfb016eea01a3291ca439457db09966e9a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26160
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-08-03 09:11:52 +00:00
Corentin Wallez 8c201dfadc Allow arrayLayerCount=0 during the deprecation period.
The value 0 is the default value for default-constructed C descriptors
and should be allowed.

Bug: dawn:22
Change-Id: I876ec4d9c6d70a798b0d6cea5c2ccecaad850eff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-08-03 09:00:12 +00:00
Jiawei Shao 8c9858e9b8 Fix clearing sint/uint color attachments on Vulkan and OpenGL
This patch fixes a bug on the clear of color attachments with signed or
unsigned integer formats on Vulkan and OpenGL by using the correct APIs
to set the clear color for signed/unsigned integer formats.

BUG=dawn:497
Change-Id: If1bc9858875e6384e71c15bb6770fbbb10045037
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26041
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-08-01 04:18:17 +00:00
Jiawei Shao fada501190 Metal: Add shader compilation error message to DAWN_VALIDATION_ERROR
BUG=dawn:498

Change-Id: I850956a6c57ffe9d77e0729e89da6d9a62076509
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26060
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-07-31 00:03:43 +00:00
Bryan Bernhart f03590a754 D3D12: Dynamic shader-visible heap allocation.
Allocates shader-visible descriptor heaps at a much
smaller size then pool-allocates them upon reaching
the max size. This strategy avoids always wasting memory
for lighter users while still maximizing performance for
heavy users.

BUG=dawn:155

Change-Id: I0519235c901d0283b98ee824eeb0cda6de70b210
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25620
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-30 21:50:32 +00:00
Austin Eng 0d9fce100d Add texture aspect to texture copy view and validation tests
Bug: dawn:439
Change-Id: I0ca283f58fe2b63ac3a8c468f8ea1bb2d300856f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24683
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-30 15:29:57 +00:00
Austin Eng b8a56af176 Rephrase Format::aspect enum as an enum class mask
Format::aspect should be a mask so that it is easier to iterate over
and test if an aspect is present.

This CL also re-exports wgpu's EnumClassBitMask helpers in dawn_native.
It also adds an EnumMaskIterator which wraps BitSetIterator to allow
iterating over the enums in an enum mask.

Bug: dawn:439
Change-Id: I08180a45b27c6031e2f80b0fa1801716677fd813
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24682
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-30 15:25:37 +00:00
Kai Ninomiya 38ba51ce7a Make shim headers at <webgpu/*> that point to <dawn/*>
Emscripten's headers live at <webgpu/*>; this makes it so projects don't
have to ifdef which #include path to use.

Bug: dawn:160
Change-Id: I39efee44447470551a78db0abd062f4a2fe9083a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26020
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-30 09:15:27 +00:00
Jiawei Shao a36a91a445 Support lazy initialization on the buffers bound into a bind group
BUG=dawn:414

Change-Id: Ice592d6427747941406431709999d08778f0f221
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25861
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-07-30 08:20:17 +00:00
Bryan Bernhart 03cf7c3eae Enable GBV by default for correctness tests.
Dawn apps using debug builds may hang due to
GBV being always on by default. This change turns
on GBV for correctness tests only.

BUG=dawn:490

Change-Id: I2728d834ed53f9acc7556f8d1178d718c0b49457
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25421
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2020-07-29 19:44:41 +00:00
Tomek Ponitka 2c8e1f2f11 Optimizing memcpy inside Queue::WriteTexture
Fixing an earlier TODO.

Bug: dawn:483
Change-Id: I19d961512caea1f9d502d7e58b56cd3846c9f7f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25983
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-07-29 18:37:51 +00:00
Corentin Wallez f93fa6acd9 dawn_wire: Implement CreateBufferMapped on top of mappedAtCreation
Reland with a fix for narrowing of uint64_t to size_t of the buffer size
in 32 bit mode.

This inverts the shimming to have the old mapping at creation method
be implemented on top of the new method..

Also updates Wire tests to use mappedAtCreation instead of
CreateBufferMapped.

TBR=senorblanco@chromium.org
Bug: dawn:445
Change-Id: I89fe84b6e0b5d0d4a5c6a2db7b38cb7d6cd063f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25981
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-29 17:01:11 +00:00
Tomek Ponitka ab04da48f4 Enabling alphaToCoverage
Added the alphaToCoverage functionality with some
end2end tests. There is no validation for disabling alphaToCoverage
mode if SV_Coverage is statically used by the shader yet.

Bug: dawn:494
Change-Id: I9df15b35697ea05a064b092edae9d5d20f73c4d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25761
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-29 11:44:41 +00:00
Tomek Ponitka 9ecb99344f Roll third_party/spirv-cross/ to enable shader-output mask in HLSL
0376576d2d..f5e9f4a172

$ git log 0376576d2..f5e9f4a17 --date=short --no-merges --format='%ad %ae %s'
2020-07-23 tommek Adding BuiltInSampleMask in HLSL

Created with:
  roll-dep third_party/spirv-cross

Change-Id: I1a9702ce1da046e7c987deaa1994de019d570fb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-07-29 10:10:21 +00:00
Corentin Wallez 9d0b9d7212 D3D12Info: programmatically compute the shader profiles.
Bug: dawn:426
Change-Id: Ic360b95e908404137e01a00439b93e5b9b1828ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24380
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-29 09:34:11 +00:00
Corentin Wallez b88b1a15c7 Revert "dawn_wire: Implement CreateBufferMapped on top of mappedAtCreation"
This reverts commit 0811ecc775.

Reason for revert: Makes the Dawn roll fail.

Original change's description:
> dawn_wire: Implement CreateBufferMapped on top of mappedAtCreation
> 
> This inverts the shimming to have the old mapping at creation method
> be implemented on top of the new method..
> 
> Also updates Wire tests to use mappedAtCreation instead of
> CreateBufferMapped.
> 
> Bug: dawn:445
> 
> Change-Id: I77dcfe72040e5bf187c41fe99c8dd785d5156a07
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25701
> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>

TBR=cwallez@chromium.org,senorblanco@chromium.org,enga@chromium.org

Change-Id: Ied940d505fdf576860697dee8df2548c73581eba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:445
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-29 09:10:13 +00:00
Tomek Ponitka 225a2b46b0 Enabling sampleMask usage in RenderPipelineMTL
Added the sampleMask functionality in Metal.

Bug: dawn:491
Change-Id: Id4a14d0cc715dc701c6f29e4588ce327c5b26cba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25481
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-07-29 08:19:59 +00:00
Kai Ninomiya bce1cbd0e2 CMake: add -framework Metal to dawn_native
Bug: None
Change-Id: Ic71747e48e3d1a737f73bac37cced760af4f195d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25940
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-29 07:21:09 +00:00
Kai Ninomiya a390d7f84f Disable "all" warnings when compiling MSL code
Hopefully works around an issue where some Metal drivers treat warnings
as errors.

Bug: dawn:493
Change-Id: Ia535502a14fd4215ff74eee2662dfbde7e01bc4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25841
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-28 18:51:28 +00:00
Corentin Wallez 0811ecc775 dawn_wire: Implement CreateBufferMapped on top of mappedAtCreation
This inverts the shimming to have the old mapping at creation method
be implemented on top of the new method..

Also updates Wire tests to use mappedAtCreation instead of
CreateBufferMapped.

Bug: dawn:445

Change-Id: I77dcfe72040e5bf187c41fe99c8dd785d5156a07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25701
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-28 15:30:07 +00:00
Corentin Wallez 5b007a519a dawn_wire: Implement MapRead/WriteAsync on top of MapAsync
This inverts the shimming to have the old mapping entrypoints be
implemented on top of the new mapping entrypoint.

Bug: dawn:445

Change-Id: I98c81b2873d506790b1b19048c5289c62d1b83ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25700
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-28 09:00:11 +00:00
Jiawei Shao c11a19145f Support buffer lazy initialization before CopyTextureToBuffer
BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: I5bdd6333029170d47ea240388e7b7d80750ae5d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25643
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-07-28 01:58:50 +00:00
Austin Eng 361a0d8334 Update max storage buffer bindings per stage to 6
This is a temporary change to unblock Tensorflow.js until we
expose querying and setting GPULimits.

Bug: none
Change-Id: Iad851b2be260e9fade7c326bc7fcde39b46cf7fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25840
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-27 21:24:17 +00:00
Bryan Bernhart 1f16229c9b Disable MultisampledRenderingTests on NV/D3D12.
E2E tests fail to pass with backend validation. Disable these tests
until there is resolution from the investigation.

BUG=dawn:462

Change-Id: I0325bafb31cc706be122a601ecfe154bf8880b5b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25680
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-27 19:50:21 +00:00
Hao Li d5a4775cfc Query API: QuerySet on D3D12
- Implement QuerySet object creation on D3D12 backend.
- Add end2end tests for the creation on D3D12 backend.

Bug: dawn:434
Change-Id: I9657792ca5cba8f156471783a7c13f6d36b7a19e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25225
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2020-07-25 14:48:12 +00:00
Kai Ninomiya 0d158ac681 Fix some bugs in buffer mapping in the wire client
Bug: dawn:445
Change-Id: Ibfc55e26c2bc1757811669d84e54e9f775bee8f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25440
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-23 18:27:56 +00:00
Corentin Wallez c7ae7a0012 Implement sampleMask in D3D12 and OpenGL.
Some tests are not enabled in D3D12 yet because SPIRV-Cross lacks
support for gl_SampleMask.

Bug: dawn:491

Change-Id: I6cce56b5d0ab883f39b8d58987246c08a23b6410
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25580
Reviewed-by: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-23 16:26:16 +00:00
Tomek Ponitka 4d9cadd58a Enabling sampleMask usage in RenderPipelineVk
Added the sampleMask functionality in Vulkan with some
end2end tests including tests for the shader-output
mask.

Bug: dawn:491
Change-Id: Ib39682d8857729adb4776bc2f2d8e759bf75677b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25340
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-23 11:30:56 +00:00
Xinghua Cao 92ebe87b74 Vulkan: Set apiVersion dawn targets
Set apiVersion to Vulkan 1.0 if the instance only supports
Vulkan 1.0. Otherwise set apiVersion to Vulkan 1.2, treat
1.2 as the highest API version dawn targets.

Bug: dawn:426
Change-Id: I322eaa0a93a518df36b86717c2ed5a98c5d056ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25065
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Xinghua Cao <xinghua.cao@intel.com>
2020-07-20 08:44:29 +00:00
Jiawei Shao d0dd661f18 Implement buffer lazy initialization before CopyBufferToTexture()
This patch adds the check and implementations of buffer lazy
initialization before CopyBufferToTexture().

The support of buffer lazy initialization before CopyTextureToBuffer()
is much more complicated than what we do for CopyBufferToTexture(), so
we decide to put it in another CL instead of writing them together with
CopyBufferToTexture().

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: I45fdcdde2c9a0dafff23623815fc35c877990ef1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25140
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-20 02:08:59 +00:00
Austin Eng 1233b66c90 Guard [MTLDevice recommendedMaxWorkingSetSize] only on MacOS
Bug: none
Change-Id: Id5d23151953dfc5401776180b42d921adc22833b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25161
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-18 00:43:17 +00:00
Austin Eng 4a4c76b8b5 Add offset argument in BufferZeroInit mapping test
The CL that added offset/size args landed about the same time
as the CL that adding zero init mapping tests (without the args).

Tbr=cwallez@chromium.org
Bug: dawn:445, dawn:414

Change-Id: I388399d425c3a3c12be79b160686caaf3d81a89c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25162
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-18 00:22:27 +00:00
Corentin Wallez f6e7044697 Add offset and size to Get[Const]MappedRange.
Bug: dawn:445
Change-Id: I73758d95e61d1fbe69f328907a6170a1b27d785b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24983
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-17 18:50:37 +00:00
Austin Eng 4b7ca6bf96 Call vkFreeCommandBuffers before destroying the vkCommandPool
This should not be necessary as the command pool should own the
memory if it was created without the creation flag
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT. However, some drivers
leak memory if vkFreeCommandBuffers is not called.

Bug: chromium:1082181
Change-Id: Ia437fc17b2a304a248b9227b43cfff1868f9f10e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25062
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-17 15:26:56 +00:00
Austin Eng 64dd82e94f Remove depth sampling tests of non-normalized depth values
Depth texture values outside the 0-1 range are not supported without
an extension.

Bug: dawn:413, dawn:367
Change-Id: I75e7f0de054d6f9a4bac7c6b955c65db810fe36e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24681
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-17 15:18:57 +00:00
Austin Eng e01dd678d3 Make common/ compile with Emscripten
Projects using Dawn that are compiled with Emscripten may use some
of our common headers and utilities. ex.) creating a ShaderModule
from SPIR-V. Add handling for __EMSCRIPTEN__ to Platform.h so
compiling to WASM works.

Also, implement GetExecutablePath on Emscripten as unreachable.
This is only ever used to search native paths in the Vulkan backend.

Bug: none
Change-Id: I5d9d6e27e287cb34e7af3214add1c4bc8c6a0f70
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25064
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-17 14:52:47 +00:00
Tomek Ponitka 7f4980e7d2 Optimizing WriteTexture offset on Vulkan
Added an additional alignment on the staging buffer offset in
WriteTexture on Vulkan to match
VkPhysicalDeviceLimits::optimalBufferCopyOffsetAlignment.
We now allocate some additional memory in the staging buffer for that
purpose.

Bug: dawn:483
Change-Id: Ic5b95aa57f6c241e0ab9f9853b4c3152e52e5630
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24982
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-17 09:45:26 +00:00
Tomek Ponitka 73652263df Changing validation order for linear texture data
Changed the order of validation blocks in ValidateLinearTextureData.
It doesn't match the order in spec now, but for the algorithm to
compute required bytes in copy we need the conditions which come
after the ones relating to it. Also switched the order of
ValidateLinearTextureData and ValidateTextureCopyRange for similar
reasons.

Bug: dawn:483
Change-Id: If00ae769d170ea12494258721916ec55d79e2880
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25041
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-17 09:44:46 +00:00
Hao Li 5c89c8dc70 Query API: ResolveQuerySet
Add ResovleQuerySet on CommandEncoder and its validation tests.

Bug: dawn:434
Change-Id: Ibba166dd11e15430cd5f6647676a47ce67481844
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24303
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2020-07-17 09:02:46 +00:00
Jiawei Shao 77eb64eb8c Implement buffer lazy initialization before mapping
This patch implements buffer lazy initialization beffor MapAsync() and
buffer creation with BufferDescriptor.mappedAtCreation == true.

Note that this patch doesn't initialize buffers in MapReadAsyc() and
MapWriteAsync() because they are deprecated and will be removed soon.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: Ifea99833897081f599c45797e0829c57de1ac926
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24687
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-07-17 09:01:26 +00:00
Tomek Ponitka 2733af5c75 Optimizing WriteTexture row pitch on Vulkan
Fixing an earlier TODO about aligning bytesPerRow in WriteTextureImpl
to VkPhysicalDeviceLimits::optimalBufferCopyRowPitch.

Bug: dawn:483
Change-Id: Ided2d367177f2f886a84f232c77f1f9f0d50d05d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24981
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-17 08:33:16 +00:00
Corentin Wallez 450b6f4f84 Use MapAsync callback for server->client map callbacks.
This changes the format of the server->client callback for async mapping
to match MapAsync. Previously there were two callbacks, one for
MapReadAsync and one for MapWriteAsync.

Bug: dawn:445

Change-Id: I3330c07ac8bb6d1fa9019563e9c946875e852639
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24821
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-17 07:38:36 +00:00
Austin Eng b92a363a1a Vulkan: Fix MemoryServiceZirconHandle CreateImage
vkCreateImage when bound to imported memory, must also have
a VkExternalImageCreateInfo struct in its pNext chain that
has VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA
as a handleType.

This was discovered when tests started failing after a roll
of the Vulkan validation layers.

Bug: none
Change-Id: Ic7fc95f963062c8740e714a490adf6a020fed220
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-17 07:30:36 +00:00
Austin Eng cb2938a1af D3D12: Bucket descriptor allocation by powers of two
WebGPU currently allows as many as 108 view descriptors per bind
group. This is too many to have one descriptor allocator per size,
so we need to bucket them by size.

Bug: dawn:443, dawn:488
Change-Id: I4fc8cf7cd0dc8292bb6a8488fd2ceb7575e1e5f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24787
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-17 01:11:16 +00:00
Austin Eng e8e089ad28 Add missing headers to BUILD.gn and CMakeLists.txt
Bug: none
Change-Id: I101935b8f75b3cbcf0f79a429f7a850ce62e90e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25063
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-16 21:45:06 +00:00
Austin Eng 34f5133104 Validate 1D texture bindings cannot be multisampled
Bug: chromium:1104737
Change-Id: I61d631f7fce2c7d68823f265f06f75069af765a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25101
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-16 20:43:26 +00:00
Corentin Wallez c15c6eb9d8 dawn_wire/server: Use MapAsync to do Map[Read/Write]Async
This changes the format of the client->server command for async mapping
to match MapAsync and updates the doer on the server to implement it via
MapAsync. Previously the command had an isWrite boolean that routed to
either MapReadAsync or MapWriteAsync.

Also updates the Wire tests using mock_webgpu.h for the new server-side
traces.

Bug: dawn:445

Change-Id: I673cbe5e08b7c71539e8678dbb07b4043a9fadb2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24820
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-16 17:07:05 +00:00
Corentin Wallez 2a232ba399 DawnTest: Use MapAsync for expectations.
Bug: dawn:445
Change-Id: I1ef0e0f2eef03565254fb07a1ffca51cddeb0a97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25040
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-16 16:35:40 +00:00
Corentin Wallez af09f74913 Roll third_party/swiftshader/ ad65826a2..e8dd233c7 (10 commits)
Also removes suppressions for tests that pass after
https://swiftshader-review.googlesource.com/c/SwiftShader/+/46509

https://swiftshader.googlesource.com/SwiftShader/+log/ad65826a2ab1..e8dd233c7a85

$ git log ad65826a2..e8dd233c7 --date=short --no-merges --format='%ad %ae %s'
2020-07-16 cwallez Fix B<->T copies of multiple array layers and unpacked rowpitch
2020-07-15 bclayton Regres: Collate and add new documentation for Regres
2020-04-08 natsu Support Gralloc3 in SwiftShader
2020-07-14 swiftshader.regress Regres: Update test lists @ cd0af645
2020-07-13 capn Undefine Bool after the headers that define them
2020-07-11 capn Remove dead ASTC code for GLES
2020-07-09 capn Rename command classes to match API calls
2020-06-04 srisser Add decoder for BC6h
2020-06-15 sugoi Image dirtiness
2020-07-09 amaiorano Android: build against llvm-10 instead of llvm-7

Created with:
  roll-dep third_party/swiftshader

Bug: None

Change-Id: Ife6dcf9f832e4aaab40de3bdb62d4b1eb258d2f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25042
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-16 15:09:55 +00:00
Tomek Ponitka e28cc55cac Implementing Queue::WriteTexture in Vulkan
Added implementation of writeTexture in Vulkan.

Bug: dawn:483
Change-Id: Id74b6518c46caf59e07a9d16dd51d8c28340fd50
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24660
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-16 09:08:41 +00:00
Tomek Ponitka ce665b4624 Adding TextureZeroInitTests for WriteTexture
Added TextureZeroInitTests: WriteWholeTexture, WriteTextureHalf,
WriteWholeTextureArray, WriteTextureArrayHalf,
WriteWholeTextureAtMipLevel, WriteTextureHalfAtMipLevel.

Bug: dawn:483
Change-Id: I54a1c9c918f8289df5285135cd27e01f2bef07b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24740
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-15 20:17:17 +00:00
Natasha Lee 5a1d39ad0b [D3D12] Add DXGIAdapter to AdapterDiscoveryOptions
This gives Chromium the option to give Dawn the correct dxgi adapter to use

Bug: chromium:1036711
Change-Id: Ica544d2e76d1c300038fa07b5b639a35c43f60b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2020-07-15 18:26:17 +00:00
Tomek Ponitka 9d66c5353f Implementing Queue::WriteTexture in Metal
Added implementation of writeTexture in Metal. It's using a
staging buffer instead of writing directly from the CPU to
the texture, because Dawn uses the private storage mode for
most of the Metal textures.

Bug: dawn:483
Change-Id: I6b85ee8bbe343881337bdb203a122dc1f1523177
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24581
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-15 18:06:07 +00:00
Sylvain Defresne 212c5bd9b2 Convert GN libs lists to frameworks
GN recently added support for Apple frameworks to link, rather than
overloading the libs lists. This pulls .frameworks out of the libs
lists, so that GN can stop supporting .frameworks in libs in the
future.

Bug: chromium:1052560
Change-Id: I0b57a3c4c995887a57937317db30b67cf7a7f0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-15 09:59:46 +00:00
Jiawei Shao 3b17f0bde8 Optimize B2T and T2B copies with multiple texture layers on D3D12
This patch optimizes the implementation of buffer-to-texture and
texture-to-buffer computations on D3D12 backends by computing
TextureCopySplits once for all the 2D texture array layers in the
copy instead of computing it once per layer. You can see the
comments in the function D3D12::ComputeTextureCopySplits() for more
details.

BUG=dawn:453
TEST=dawn_end2end_tests

Change-Id: I1b66d24d2418147957fbe03e2c25144bd043a62e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24643
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-07-15 08:33:39 +00:00
Austin Eng b31f5e717e Remove kMaxBindingsPerGroup limit
kMaxBindingsPerGroup is not a real WebGPU limit. Code in Dawn that
uses it now uses dynamically sized vectors, optimistic stack_vecs or
a different limit like kMaxDynamicBuffersPerPipelineLayout.

The CL introduces kMaxOptimalBindingsPerGroup=32 which is used to size
the static portion of stack_vecs, but the value is tentative.

Bug: dawn:443
Change-Id: I08e06bed6531bed8b4365f36cf2fc0579ac5f180
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23502
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-14 22:20:35 +00:00
Corentin Wallez 0d52f800a1 Implement Buffer::MapAsync
MapAsync in dawn_native is fully implemented and only missing
a couple cleanups that can be done once MapRead/WriteAsync are
removed.

MapAsync in dawn_wire is left as a pure shim on top of
MapRead/WriteAsync and will be transitioned to its own commands
in follow-ups.

All MapRead/WriteAsync end2end and validation tests are duplicated
for MapAsync.

Bug: dawn:445

Change-Id: Ib1430b9257149917be19a84f13e0ddd2a8eccc32
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-14 12:30:14 +00:00
Corentin Wallez 92f501dbfd Roll third_party/swiftshader/ f6f11215c..ad65826a2 (15 commits)
This fixes a couple of end2end copy tests that were failing with
swiftshader.

https://swiftshader.googlesource.com/SwiftShader/+log/f6f11215cd93..ad65826a2ab1

$ git log f6f11215c..ad65826a2 --date=short --no-merges --format='%ad %ae %s'
2020-07-03 capn Fix copying of multiple image layers
2020-07-02 capn Fix copying of multisample images
2020-07-02 capn Fix image slice / plane name usage
2020-07-09 amaiorano Android: add llvm-10 build file and fix build
2020-07-08 amaiorano Add llvm-10 configs for Android
2020-07-09 amaiorano Add arm64 support for Darwin to llvm-10 configs
2020-07-08 amaiorano Add validation and platform restrictions to LLVM-10 update script
2020-07-07 capn Remove unsupported formats
2020-07-02 sdefresne Convert GN libs lists to frameworks
2020-07-08 amaiorano Update llvm 10 Darwin config
2020-07-08 amaiorano Update llvm 10 Linux config
2020-07-06 amaiorano Enable Kokoro LLVM 10 builds on Windows
2020-07-06 amaiorano Add llvm-10 configs for Windows
2020-07-06 amaiorano Copy and modify update.py for LLVM 10
2020-07-07 swiftshader.regress Regres: Update test lists @ f6f11215

Created with:
  roll-dep third_party/swiftshader

Bug: swiftshader:152

Change-Id: Ie7cc23ef38e1befb952f2b92a8fb33d465687604
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24661
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-14 06:58:54 +00:00
Austin Eng e700a6a764 Add ityp::vector class and unittests
In order to remove the kMaxBindingsPerGroup limit in Dawn, some static
ityp::arrays need to be made dynamically sized. This CL adds ityp::vector
wrapping std::vector.

This CL also fixes the assumption that ityp::stack_vec iterators are pointers

Bug: dawn:442, dawn:443
Change-Id: I8698cbba3ea80ac063ab918a77f223c527720d08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24480
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-14 01:32:43 +00:00
Austin Eng 8e316f1177 Add per-stage and per-pipeline-layout limits and validation
This CL adds per-stage and per-pipeline-layout limits according
to the WebGPU spec. It also slightly increases kMaxBindingsPerGroup
from 16 to 24 so that these limits can be effectively tested
without hitting kMaxBindingsPerGroup. kMaxBindingsPerGroup is not a
real WebGPU limit and will be removed in future patches.

Bug: dawn:443
Change-Id: I72be062cd31dea4ebd851f2d9f8274a77f286846
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24481
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-14 00:53:23 +00:00
Kai Ninomiya 261b05d3dd PipelineStatisticsName -> PipelineStatisticName
To match upstream WebGPU (and be grammatically more correct).

Upstream webgpu.h change:
https://github.com/webgpu-native/webgpu-headers/pull/60

Bug: dawn:22
Change-Id: Id665e883259b9297a90c13b43187461c64fdc3da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24702
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-13 18:21:03 +00:00
Kai Ninomiya 3e6db22fa8 Add BufferCopyView.layout and deprecate old fields
Bug: dawn:22
Change-Id: Idc37faf5edaa01a6fb1a38d1a81022ad652cf428
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24622
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-13 17:23:33 +00:00
Enrico Galli b9285f69ba Rename Buffer::IsMapWritable to Buffer::IsMappableAtCreation
Renaming method to better reflect the actual usage.

Bug: none
Change-Id: I3fcdeffaa06fceae9d5818f79c3b7985fb1885ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24701
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-12 16:16:01 +00:00
Kai Ninomiya 53405b54d5 Add occlusionQuerySet for compatibility with upstream webgpu.h
Adds RenderPassDescriptor.occlusionQuerySet for struct compatibility
with upstream webgpu.h, and validation errors that it's not used (since
it's not implemented).

Bug: dawn:22
Change-Id: I05ac75105038a0d7569cc720170e55f35b0f80d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24620
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-11 03:15:16 +00:00
Yunchao He 0b43a803bf Remove a unnecessary validation test in bind group
binding index >= kMaxBindingsPerGroup is actually valid.

Bug: none

Change-Id: Idfba743d50013b7115f125b6441fd49732dffc96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24700
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-10 23:30:56 +00:00
Brandon Jones 7695afc902 Implement Validation For DepthStencilAttachment ReadOnly
Implements validation for RenderPassDepthStencilAttachmentDescriptor depthReadOnly and
stencilReadOnly flags to match WebGPU specification. Includes corresponding unit tests.

bug: dawn:485
Change-Id: I21e624850d5a393469569417f102fb979dbfdf27
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24602
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-10 23:13:58 +00:00
Bryan Bernhart 8c255acbe4 Add GPU detection for WARP
Adds WARP to known vendor/device Ids so
tests can detect when MBR is being used.

BUG=dawn:463
TEST=dawn_end2end_tests

Change-Id: I19f16dfeb4839c5a7c0a993bab94d2b6ca4ca36d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24680
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2020-07-10 22:58:48 +00:00
Kai Ninomiya 2afea0c671 Autoformat all tests and examples
Bug: none
Change-Id: I69904944db1d4c2fbcca74bb8b66b5a7524e76bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24642
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-10 20:33:08 +00:00
Kai Ninomiya 6328356129 Autoformat everything except tests/examples
Done by:
- Appending an extra newline at the end of src/**/*.{cpp,h,mm,gn}
  except src/tests/*
- Running git cl format --full to format the full contents of every
  changed file

Bug: none
Change-Id: Id88fc5ed0c5efbbc93b2c6a305c2f98465fe646d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-10 18:19:38 +00:00
Kai Ninomiya 479689912e Reorder minBufferBindingSize to match upstream webgpu.h
Bug: dawn:22
Change-Id: I409a2de9f1704613d1cdbda976c3ab50eff48d46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24603
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-09 20:49:43 +00:00
Enrico Galli c9fc175bba D3D12: Empty CPU written range in Unmap calls on READBACK heaps
In order to remove a warning in the D3D debug layer, this patch passes
an empty range CPU written range to calls of Unmap on READBACK
buffers.

Bug: dawn:419
Change-Id: Ic4dcbf31beb3a257c3d88896f4bb97e19caf0cc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24301
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-09 20:40:53 +00:00
Tomek Ponitka c98988de11 Added validation tests for copying to 2d-array textures
Added validation tests for CommandEncoder::CopyB2T, CommandEncoder::CopyT2B and
Queue::WriteTexture which involve copying or writing to multiple layers
of a 2d-array texture.

Bug: dawn:483
Change-Id: I23f580dff86cd2512a94b41c9c0ce795122a045e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24443
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-07-09 17:33:13 +00:00
Jiawei Shao dab10eae8a Implement buffer lazy initialization before CopyBufferToBuffer
This patch implements buffer lazy initialization before
CopyBufferToBuffer() behind the toggle LazyClearBufferOnFirstUse.
- If the source buffer is not initialized, it will be cleared to 0
  before CopyBufferToBuffer().
- If the destination buffer is not initialized and the copy doesn't
  overwrite the whole buffer, it will be cleared to 0 before
  CopyBufferToBuffer(), otherwise the buffer shouldn't be cleared.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: I3d0512c6376a1ed8928e86f8e56fefebc16910fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24360
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-09 09:15:22 +00:00
Corentin Wallez d3bf2188aa Remove usage of the UNIT_TEST macro.
It is breaking the roll of Dawn in Chromium because on ChromeOS the
macro is defined on the command-line, causing the compilation to fail
because of a macro redefinition.

Bug: None
TBR=enga@chromium.org
Change-Id: I13eebb9b40f2a5f7c1eed4e3572de3eda2db8bb6

Change-Id: I4797211f4d9ff122d992d78aeac83fd4f0585ff6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24580
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-09 07:00:32 +00:00
Corentin Wallez 1318c603d9 Don't rely on null::Queue::Submit resolving mapping operations.
In the validation tests, we relied on Queue.Submit(0, nullptr) to
resolve mapping operations. This is fragile so we replace it with a
FlushMappingOperations() function that uses device.Tick() instead.

This allows removing the mapSerial argument from
Buffer::MapRead/WriteAsyncImpl (which was the actual goal of this CL).

Bug: dawn:445
Change-Id: Id98822287370c371bebb83afb8e290e17f3c1b55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24381
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-09 06:12:04 +00:00
Austin Eng d761d5a575 Add Chromium's StackVector base class and ityp::stack_vec
In order to lift Dawn's restriction on the number of bindings
per bind group, static sized arays need to be converted to
dynamically sized vectors. This CL adds Chromium's StackVector
class which behaves like std::vector but provides a stack allocator
to allocate small vectors on the stack. Dawn can use this to avoid
making separate heap allocations for a smaller, realistic binding
counts.

The CL also adds an ityp::stack_vec class to support using
a StackVector with TypedInteger indices.

Bug: dawn:442, dawn:443
Change-Id: I7604c02b3ea52cd63990a2e8b45ed238a5d52232
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23681
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-08 20:27:30 +00:00
Corentin Wallez 8a9919980f Don't leak buffers if MapAtCreation fails.
This required changing DeviceBase::CreateBufferImpl to return
ResultOrError<Ref<BufferBase>>

Bug: chromium:1103154
Change-Id: I1a5811d293333b6ef29c988a08f2f1f84ac65702
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24500
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-08 19:45:40 +00:00
Corentin Wallez 519edd5890 Fix MSVC compilation.
- Fix a struct vs. class in forward declaration of std::hash
 - Fix an unsigned vs. signed compare in BitSetIterator
 - Fix the assumption that std::array::[const_]iterator is a pointer.
 - Fix for reinterpret_cast from uint64_t to uint64_t not being allowed
   for vulkan_platform.h
 - Fix for a 32bit shift being expanded to 64bit.

Bug: None
Change-Id: I5f2bf8745aa1ef1eba9916fcf6ff7801b48f61cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24501
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-08 18:50:30 +00:00
Tomek Ponitka a9c7d64aad Adding Queue::WriteTexture
Added Queue::WriteTexture with validation but no actual
implementation. Tests were mostly taken from validation tests
for copying buffer to texture. Validation tests for CopyB2T
and WriteTexture do not cover 2d-array textures yet.

Bug: dawn:483
Change-Id: I9027eb615c02fe2265cde912f6ba17a235b94728
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-07-08 18:42:30 +00:00
Enrico Galli 83fe1bc34d D3D12: Added default optimized clear color to resource creation
Adding zero as the optimized clear value to silence a warning in
the D3D12 debug layer. Warning will still occur under non-zero
clears.

Bug: dawn:418
Change-Id: Idada948950f28130618834d966b237dcc39460c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24300
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-08 07:39:56 +00:00
Bryan Bernhart 7622be0544 D3D12: Avoid re-binding sampler tables.
Skip re-binding samplers since sampler heap
allocations are cached and the pipeline would
redundantly get set every draw. This is
particularly important for draw heavy scenarios.

After the change:
+3% in RendererPerfTest/1.* via SkiaDawn
+100% for Forest Demo FPS (55ms vs 28ms)

BUG=dawn:479

Change-Id: I93cbca4e365d6ff89ec86fc15eaccf70b49ea916
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24161
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2020-07-07 23:32:52 +00:00
Corentin Wallez b2ea1915d4 Implement GPUBufferDescriptor.mappedAtCreation.
This CL:

 - Adds mappedAtCreation to dawn.json
 - Changes dawn_native to implement CreateBufferMapped in terms of
   mappedAtCreation.
 - Duplicates all the CreateBufferMappedTests to mappedAtCreation tests
   (both validation and end2end).
 - Implements dawn_wire's mappedAtCreation in terms of
   CreateBufferMapped. The reversal in dawn_wire will be done in a
   follow-up CL.

Bug: dawn:445

Change-Id: I70b9fa729b1402524a6b993c3f288987eb65c6c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24083
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-07-07 11:21:51 +00:00
Tomek Ponitka 0f5d496f12 Rephrasing CopyBufferToTexture validation
Moved some of the validation helper functions from CommandEncoder.cpp
to CommandValidation.cpp. This will make them accessible for
Queue::WriteTexture. Also introduced ValidateLinearTextureData
and ValidateTextureCopyRange which combine already implemented
checks in a way that's defined in WebGPU spec.

Bug: dawn:483
Change-Id: I04304c5e4906f3745c6adf75758fae179c6ffcfe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24283
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-07-07 10:18:51 +00:00
Corentin Wallez 9585c468a2 Update dawn.json to more closely match webgpu.h
- Move wgpu::TextureUsage::Storage at the end of the enum.
 - Reorder some methods of device to be in alphabetical order.
 - Reorder members of wgpu::QuerySetDescriptor.
 - Change SurfaceDescriptorFromHTMLCanvasID to
   SurfaceDescriptorFromCanvasHTMLDescriptor.

Bug: dawn:22
Change-Id: Ib18fbaf153ad2969b0d0c4e49682e8736b00776c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24280
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-06 18:50:00 +00:00
Corentin Wallez dbf805fe8d Update GetMappedRange to not produce validation errors
GetMappedRange never produces errors and instead returns nullptr when it
is disallowed. When in a correct state, should return a valid pointer as
much as possible, even if the buffer is an error or if the device is
lost.

Adds tests for error buffers and device loss, and modify existing tests
to not expect a device error.

Also removes some dead code in the Vulkan backend and adds a fix for
missing deallocation of VkMemory on device shutdown.

Bug: dawn:445

Change-Id: Ia844ee3493cdaf75083424743dd194fa94faf591
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24160
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-06 18:08:10 +00:00
Xinghua Cao db34c78910 Check FP16 support on D3D backend
True FP16 is only supported in DXC through Shader Model 6.2, also
check the value of the Native16BitShaderOpsSupported member of
D3D12_FEATURE_DATA_D3D12_OPTIONS4 to view whether hardware actually
supports FP16 operations.

BUG=dawn:426
TEST=dawn_end2end_tests

Change-Id: If675f7ba650cb1bd8c792928b70619b9ccda048a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23243
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Xinghua Cao <xinghua.cao@intel.com>
2020-07-06 08:28:00 +00:00
Jiawei Shao 80f927d763 Implement buffer lazy initialization before writeBuffer
This patch implements buffer lazy initialization before writeBuffer():
if the buffer is not initialized and writeBuffer() doesn't cover the
whole buffer, the buffer will be cleared to 0, otherwise the buffer
shouldn't be cleared.

This patch also introduces a toggle LazyClearBufferOnFirstUse for the
development of buffer lazy initialization: before buffer lazy
initialization being completely supported, all the related code will
only be enabled behind this toggle to prevent the buffers with valid
content being unexpectedly cleared.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: I99a2aa98ca4b9b21d69c6b32080afb525e2c4ad3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24041
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-06 08:24:30 +00:00
Dirk Pranke 59ccb1f6de Add proper data_deps to dawn_perf_tests.
Currently the Chromium build defines a wrapper build target
for Dawn (//chrome/test:dawn_perf_tests) that seems to exist
only to specify some extra data dependencies. By moving this
data dependencies onto the Dawn dawn_perf_tests itself, this
removes a problematic target in Chromium that would otherwise
block my planned changes for crbug.com/816629.

Bug: chromium:816629
Change-Id: I428698fe164bd1aad09c8dba14e57a4b7acebb1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24302
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-03 05:47:07 +00:00
Corentin Wallez f695264d30 Broaden -Wno-tautological-type-limit-compare
In https://dawn-review.googlesource.com/c/dawn/+/24162 it was added
inside the is_win condition so it didn't take effect on Linux.

TBR=enga@chromium.org
TBR=senorblanco@chromium.org
Bug: None
Change-Id: Icc9ea20ed3a5ae4e5c514ce32bff88009ad82b1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24240
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-02 09:21:08 +00:00
Jiawei Shao 4d007f34f3 Fix bugs in the multi-layer copies with BC formats on D3D12 and OpenGL
This patch fixes two bugs in the copy commands with BC formats and
multiple array layers on D3D12 and OpenGL and adds two end2end tests as
the regression tests.

This patch also removes "viewArrayLayer" in the struct CopyConfig used
in CompressedTextureBCFormatTest and sets the base array layer into
CopyConfig.copyOrigin3D.z instead.

BUG=dawn:453
TEST=dawn_end2end_tests

Change-Id: I1c2e6b79fb7c44fc996655ab5a908e27ba8c4729
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24183
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-02 09:08:09 +00:00
Idan Raiter bcc65f2d48 Vulkan: Enable robust buffer access if validation is on
Bug: dawn:480
Change-Id: Id145fab2fe24b70a063c3cc1f75f0a565635abf8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24182
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-01 21:37:57 +00:00
Austin Eng 509b811a75 Vulkan: Fix MemoryServiceOpaqueFD CreateImage
vkCreateImage when bound to imported memory, must also have
a VkExternalImageCreateInfo struct in its pNext chain that
has VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT as a
handleType.

This was discovered when tests started failing after a roll
of the Vulkan validation layers.

Tbr=cwallez@chromium.org, senorblanco@chromium.com
Bug: none
Change-Id: I4692d650af27b9325342baeda34a0d982fc49041
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24200
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-07-01 20:44:47 +00:00
Corentin Wallez 96c78ec737 Disable -Wtautological-type-limit-compare
This unblocks a roll into Skia.

Allow comparison against type limits that might be tautological on
32bit or 64bit systems. Without this the following produces an error
on 64bit:

  if (myUint64 > std::numeric_limits<size_t>::max()) {...}

Bug: None
Change-Id: I31fc579738b6fb85b40cfeac8f30936161a15da1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24162
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-01 14:36:56 +00:00
Tomek Ponitka 5fb974cf47 Changing pointers to Ref<> in GetOrCreateBGL
DeviceBase::GetOrCreateBindGroupLayout and
DeviceBase::GetOrCreateEmptyBindGroupLayout are now returning
ResultOrError<Ref<BindGroupLayoutBase>> instead of
ResultOrError<BindGroupLayoutBase*>.

Bug: dawn:466
Change-Id: I223864325aba9011b0ba6dc67589ead48d930309
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24082
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-01 13:09:46 +00:00
Hao Li 5191adc58c Query API: WriteTimestamp
Add WriteTimestamp API on CommandEncoder, ComputePassEncoder and
RenderPassEncoder.

Bug: dawn:434
Change-Id: Ifeca4efed01d80459d6fefa22ba05bea699b541f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23244
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2020-07-01 10:48:16 +00:00
Tomek Ponitka 268fe254ec Added constraints for too large uniform buffer bindings
Added a constraint in ValidateBufferBinding function checking for too
large uniform buffer bindings. Added MaxUniformBufferBindingSize
test in BindGroupValidationTest.

Bug: dawn:436
Change-Id: I31c6e2236ce928d5e81c43455eb18cf4eacdc0f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24081
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:49:20 +00:00
Bryan Bernhart bd2ab92853 D3D12: Limit QueueWriteBufferTests.ManyWriteBuffer
The stress test is causing timeouts on slower GPUs
due to the TDR threshold being hit. This halves the
number of writes required to complete the test.

BUG=dawn:228

Change-Id: I18dfa68b39a2c079b89eeadc78a69675e5c3269f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2020-06-30 18:48:20 +00:00
Corentin Wallez f7fab5a259 dawn_native: Use correct integer width for SetSubData.
SetSubData's count is a uint64_t while Queue::WriteBuffer's is a size_t
so we add a small validation check that no narrowing will occur.

No test is added because SetSubData will be removed soon, and it will be
hard to test because of the Null backend's artificial OOM.

This was found while debugging an unrelated fuzzer issue.

Bug: chromium:1099621
Change-Id: I27a9da2b94f51e889c5573f88d4a0a73fea5985c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23961
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-30 18:46:32 +00:00
Corentin Wallez 00d6215be9 dawn_wire/client: Add ToAPI and FromAPI helpers.
In the client code, we often need to translate between WGPUObject (the
API type) to Object* (the internal client type). This added a bunch of
reinterpret_casts that make the code less readable and more fragile.

This CL adds FromAPI and ToAPI helpers in the autogenerated
ApiObjects_autogen.h header, that convert between API and internal types
in a type-safe way.

Bug: dawn:445

Change-Id: Ia1bf624f0315ced496b95cb660adf88abd916d71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24063
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:39:50 +00:00
Corentin Wallez 2f616dd108 dawn_wire: Remove client/ApiProcs_autogen.h
This header was only used to call DeviceCreateErrorBuffer and
DeviceInjectError that are used in some handwritten client commands.
We remove the need for the header by making these two commands
handwritten.

This also improves readability, previously injecting errors read:

  ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(device),
                           WGPUErrorType_Validation,
                           "Some validation message");

And now reads:

  device->InjectError(WGPUErrorType_Validation, "Some validation message");

Bug: dawn:445

Change-Id: Ie11570aacf3036e13abd174d91670ecb84661226
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:26:30 +00:00
Corentin Wallez d411726003 dawn_wire: Make ApiProcs call into objects directly.
This CL modifies code generation so that the generated client procs call
the handwritten methods on client objects directly.

Previously the flow was:
  - wgpuBarDoStuff
  - ClientBarDoStuff
  - ClientHandwrittenBarDoStuff
  - client::Bar::DoStuff

With this CL the flow is:
  - wgpuBarDoStuff
  - ClientBarDoStuff
  - client::Bar::DoStuff

This required adding Buffer creation methods on client::Device instead
of calling client::Buffer static methods directly.

Bug: dawn:445

Change-Id: I1b332b71ac7a03685afcf8fd0617d3d27da468cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24062
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:01:50 +00:00
Corentin Wallez 9fa68833b2 dawn_wire/client: Encapsulate all queue/fence-related logic
This CL only moves code, renames client::Fence members, and introduces
client::Queue. Additional fence methods are added for the interaction
with the queue. There are no functional changes.

With this ApiProcs.cpp is almost passthrough and will be removed in a
follow-up CL.

Bug: dawn:445
Change-Id: I65544ef76b54614452cf7c74a948a96cb35a4cfe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24061
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-30 17:53:08 +00:00
Corentin Wallez 91904cdfde D3D12: Simplify the mapping logic.
This also removes the reliance on BufferBase::IsMapped to know whether
to unmap on destroy. This call was confusing because it was used by the
D3D12 backend to know if its own storage was mapped, but semantically
seemed to check for Buffer::State::Mapped (and not MappedAtCreation).

Bug: dawn:445
Change-Id: I3d6fde1d2996798d53264d5643545f0efb90551a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24060
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <brandon1.jones@intel.com>
2020-06-30 12:21:54 +00:00
Corentin Wallez 1325ab1251 Add Buffer::Get[|Const]MappedRange
This CL adds GetMappedRange reusing the existing GetMappedPointerImpl
call in dawn_native. In dawn_wire tracking is added to keep a
Buffer::mMappedData around.

Tests are added to test the result of Get[|Const]MappedRange in all
buffer states.

Bug: dawn:445
Change-Id: I3737dc4d36f31d392839952da0b5c0d10c7c8a88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-06-30 11:51:14 +00:00
Corentin Wallez 2008d15326 Buffer: Always use MappedAtCreation state when applicable.
In a follow-up CL we need to know if the buffer is in the
MappedAtCreation state for validation of GetMappedRange. Having the
state not 100% reflect the state in the spec meant that validation if
GetMappedRange would fail for buffers mapped at creation for which
IsMapWritable is true.

Bug: dawn:445
Change-Id: I4a64335a708b838526da8d65f907b21c782816e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23981
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-06-30 11:05:44 +00:00
Corentin Wallez bae16b4df9 dawn_wire/client: Encapsulate all buffer-related logic in Buffer.cpp
This CL only moves code, renames client::Buffer members and does
additional casts where needed. No functional changes.

Bug: dawn:445

Change-Id: I2bf83ecc1c9b36d5965d0365360dd981fcd41aac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23860
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-30 09:48:14 +00:00
Corentin Wallez b231c7fb71 Null: Make Increment/DecrementMemoryUsage use uint64_t.
Otherwise on 32-bit platforms, creation of a buffer bigger than the max
size_t would overflow the check and no OOM would be produced.

Bug: chromium:1099621

Change-Id: I987a338b150d10c0eabc3eb5fb3b815a5c2a5ca2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23960
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-06-29 20:03:16 +00:00
Yunchao He 1c9e045024 Fix a bug in PassResourceUsageTracker.cpp
In a render/compute pass, if a texture is used as the same usages
across its subresources, and it is also used as different usages
across its subresources. We should mark that it is not used as the
same usages across its subresources for this pass, and we need to
visit every single subresource to track its usages transition.

Bug: dawn:462

Change-Id: Ide0770db62a3b7b85664757b21eb3280a0bb646c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23300
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-29 19:00:05 +00:00
Tomek Ponitka bf27bd7a5e Caching empty bind group layouts
Added Device::GetOrCreateEmptyBindGroupLayout which caches the result
after being run and modified PipelineBase::getBindGroupLayout to use
that instead of creating a new empty bind group layout each time.

Bug: dawn:466
Change-Id: I70a5719265784eb8f60c2eedf6db7596462b21bd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
2020-06-29 11:13:43 +00:00
Bryan Bernhart b7ece23ffc D3D12: Remove ComPtr from d3d12::Buffer::GetD3D12Resource
Creating lots of SRVs needlessly refcounts and floods PIX traces.

BUG=dawn:155

Change-Id: I26fd1019c8c1326f0e6db3e94240a29e4d466be1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24002
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-29 08:50:03 +00:00
Jiawei Shao 330c272fc4 Enable two cases in TextureZeroInitTests with swiftshader
This patch enables two tests with swiftshader after the fix in
https://dawn-review.googlesource.com/c/dawn/+/23200.

BUG=dawn:22
TEST=dawn_end2end_tests

Change-Id: I27ff5afe6735aff3c416cbe65d039006b1ceae55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-29 08:30:03 +00:00
Corentin Wallez ff90599cdf Replace TextureCopyView::arrayLayer -> origin.z in backends
Also fix a misuse of VkBufferImageCopy that caused some Swiftshader
failures.

Bug: dawn:22
Change-Id: Ie812a590d70c7561dfcf2f78ce6c530187610e65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23200
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2020-06-26 11:07:00 +00:00
Jiawei Shao 2a6cc4f8fb Optimize B2T and T2B copies with multiple array layers on Metal
This patch moves the computation of TextureBufferCopySplit outside of
the loop over each copy texture array layer so that we only need to do
the computation once for each B2T and T2B copy command.

BUG=dawn:453
TEST=dawn_end2end_tests

Change-Id: I1fcfc972504f845467af92a77bc37870ed7b52a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23720
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-25 00:00:18 +00:00
Austin Eng 8ab3719fc4 Fix validation of multisampled BGL bindings
Bug: chromium:1097501, chromium:1097514
Change-Id: I18f03398488cc3b5adf6755989e787e117d8a004
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23640
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-06-23 00:22:24 +00:00
Jiawei Shao 92379bff49 Support copying multiple array layers in one B2T and T2B copy command
This patch adds the support of copying with multiple texture array
layers in one buffer-to-texture and texture-to-buffer copy command.

BUG=dawn:453
TEST=dawn_end2end_tests

Change-Id: If009dbb29f2b0ef0667715eed0d66053b1491fd4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23248
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-06-21 09:33:44 +00:00
Austin Eng 250f26229b Use TypedInteger for BindGroupIndex
Bug: dawn:442
Change-Id: I889a943cbaf2d349c31a15fdf126d66964bdd0a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23247
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-06-20 01:30:32 +00:00
Jiawei Shao e5d94c31a0 Fix a bug in ComputeTextureCopyBufferSize with empty copySize
This patch fixes a bug in buffer-to-texture and texture-to-buffer copies
when copySize.height == 0 or copySize.depth == 0. Previously we miss the
checks if either copySize.height or copySize.depth is 0 before doing
(copySize.height / blockHeight - 1) and (copySize.depth - 1) thus we
will get incorrect results because of arithmetic overflows.

This patch fixes this bug by adding the missed check and adds the
related regression tests in dawn_unittests

BUG=dawn:453
TEST=dawn_unittests

Change-Id: I970e420c0fa7f0b61c656365bef079c123a59e6a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23520
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-06-19 22:39:53 +00:00
Idan Raiter f434fdc6ed Add minimum buffer size validation
Bug: dawn:459
Change-Id: I755cc0ada7be7b1cb71724cb410ab0c3a88cea24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22421
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-19 21:39:23 +00:00
Austin Eng b75075ac7b Protect against huge buffer allocations on macOS 10.12, 10.13
|MTLDevice maxBufferLength| is not available until 10.14, so on
lower versions of macOS, try using |recommendedMaxWorkingSetSize|

Bug: dawn:450
Change-Id: I52dc4211cf3d7014771d580a9af9c72abe92a375
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23263
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-06-19 18:47:33 +00:00
Austin Eng 0e9e5ee8aa Skip Buffer OOM tests when using ASAN
ASAN throws when hitting OOM conditions which these tests intentionally
try to create.

Bug: dawn:450
Change-Id: I635480ae329cd5ace55287d77e2b79e663174f49
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23246
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-19 17:35:33 +00:00
Corentin Wallez 90abd47a28 dawn_wire: Factor the common command serialization pattern.
Bug: dawn:445

Change-Id: I15a99a126c0494fd06dd727ff5c9008cde675d76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23560
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-19 16:49:43 +00:00
Austin Eng 8f9523eb38 Add support for multisampled sampling
This CL adds support for multisampled sampling on the D3D12 backend.
This was already working on other backends. It also adds tests that all
of the sample locations are correct.

Bug: dawn:431
Change-Id: I6849e5e2d708ad4824e6db2665d668d43a4ef5ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23245
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-19 16:21:33 +00:00
Corentin Wallez 4e4ebe87ad Vulkan: Simplify PNextChainBuilder
Change mTailPtr to mCurrent that's a VkBaseOutStructure*.

Bug: dawn:464
Change-Id: Ic10a0abc95e279e1537786601d006cf18305687a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23540
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-19 16:08:43 +00:00
Corentin Wallez be637db589 Vulkan: Correctly request 16bit shader features.
All the querying of extensions was correctly handled for the WebGPU
ShaderFloat16 extensions, except that we forgot to request it when
creating the VkDevice.

In practice this doesn't crash as most drivers won't check if the
extension is enabled, and just compile the shader code correctly.
However the Vulkan Validation Layers complain. This CL fixes it by
requesting the features on device creation.

Bug: dawn:426
Change-Id: Id7307bb4f1d08a10bec9fc7bf0500c5761f96ff7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23203
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-06-19 14:41:23 +00:00
Austin Eng 693e88ae85 Vulkan: consider VK_ERROR_OUT_OF_HOST_MEMORY an OOM error
Bug: dawn:450
Change-Id: I89095a23a5bf7e17553b6945f79347ba31d732c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-19 07:30:13 +00:00
Corentin Wallez 581c407cd2 Fix TypedInteger hash compilation failure with stdlibc++
TypedInteger.h didn't include <functional> which made the reference to
std::hash cause a compilation failure. Fix this by moving TypedInteger
hashing to HashUtils.h so that TypedInteger doesn't include <functional>
in all of its users.

Bug: dawn:442
Change-Id: I5a0271bb187682616eb5ef3a13bb7f6271203453
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-18 09:00:48 +00:00
Austin Eng 7a4685f448 Add TypedInteger
This CL adds a TypedInteger helper which provides additional type
safety in Dawn. It is a compile-time restriction that prevents integers
of different types from being used interchangably in Debug builds.

It also adds ityp::{array,bitset,span} as helper classes to wrap std::
versions (not span). These accept a template paramter as the Index type
so that typed integers, or enum classes, may be used as a type-safe
index.

For now, bind group layout binding indices use TypedInteger. Future
CLs will convert other indices to be type-safe as well.

Bug: dawn:442
Change-Id: I5b63b1e4f6154322db0227a7788a4e9b8303410e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19902
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-06-17 22:35:19 +00:00
Natasha Lee 3f4f356611 Fix D3D12 Device Initialize calls NextSerial
Device shouldn't be used until after DeviceBase::Initialize so we need
to move the NextSerial call to after Device Initialization is completed.

Bug: chromium:1094477
Change-Id: I2ab317c1d75f853c022faac3fc0bbd66fbd7c14e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23261
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2020-06-16 23:55:08 +00:00
Bryan Bernhart 67cd013b62 D3D12: Workaround incorrect debug layer error handling
Retrieval filter was receiving errors that shouldn't be
stored or not storing new errors. Since these errors are
never reaching the storage filter or being stored without
being filtered, this workaround removes the storage
filter entirely and filters them upon being retrieved.

After the change, two new E2E tests fail
backend validation and require further investigation.

Bug: dawn:460
Change-Id: I92d8c55c71832064b94e8ff0307e7af57ea81fda
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23144
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2020-06-16 23:46:59 +00:00
Ryan Harrison 1b3ed54ffb Use Tint public header
Roll third_party/tint/ be45ff508..b8f493005 (12 commits)

https://dawn.googlesource.com/tint/+log/be45ff508124..b8f4930055df

$ git log be45ff508..b8f493005 --date=short --no-merges --format='%ad %ae %s'
2020-06-16 rharrison Make #define values public in BUILD.gn
2020-06-16 dj2 Cleanup formatting and linter.
2020-06-16 dneto [spirv-reader] Support ifbreak with other forward edge
2020-06-16 dneto [spirv-reader] Add Namer::MakeDerivedName
2020-06-16 dneto [spirv-reader] Update TODOs in test matrix
2020-06-16 dneto [spirv-reader] Add OpCompositeExtract
2020-06-15 dsinclair [spirv-writer] Allow emitting an array stride.
2020-06-15 dsinclair Determine types for module scoped variable constructors.
2020-06-12 dneto [spirv-reader] Add OpCompositeConstruct
2020-06-12 dneto [spirv-reader] First GLSL.std.450 instructions
2020-06-11 dneto [spirv-reader] Add fallthrough
2020-06-11 dneto [spirv-reader] Add switch-selection

Created with:
  roll-dep third_party/tint

Change-Id: Ia529ee3c49e426715b09d5e0c2546061d7979c17
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23280
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-06-16 19:24:18 +00:00
Natasha Lee 3fe84b5b33 Fix AssertAndIgnoreDeviceLossError to handle errors injected by fuzzer
Fuzzer recently started sometimes injecting errors with
CheckHRESULT returning E_FAKE_ERROR_FOR_TESTING, which needs to also be ignored
in AssertAndIgnoreDeviceLossError so that we can continue with destruction.

Rename AssertAndIgnoreDeviceLossError to IgnoreErrors

This CL also adds Austin's pretty printing of HRESULT results as hex values
and adds printing of "E_FAKE_ERROR_FOR_TESTING" error.

Bug: chromium:1094448
Change-Id: I6715a5eec02919a3e3b4c86d493b3f7e84c5e206
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23241
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-06-16 17:53:38 +00:00
Brandon Jones ac6bd4c98f Fix fuzzer hang when waiting for fence signal after device loss
When the fuzzer passes the command DeviceLoseForTesting, the
DawnWireServerFuzzer will hang forever when waiting for a fence signal
because the device was lost. This commit sets a callback on device loss
which gives an extra condition to break the hang.

Bug: dawn:444

Change-Id: I0157358ed6da39cc6fcab7e1be8a3d5fde74266f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23141
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Natasha Lee <natlee@microsoft.com>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2020-06-16 16:55:38 +00:00
Jiawei Shao 59cfe3ea03 Clean up CopyTests
This patch does several clean-ups in CopyTests as a preparation of
supporting buffer-to-texture and texture-to-buffer copies with multiple
texture array layers.
1. Remove the zero-initialization of textures in CopyTests_B2T
2. Use a big buffer that contains the pixel data in all the texture
   array layers instead of several small ones that only contains one
   texture array layer.
3. Make CopyTests_T2T::DoTest() also use CopyTests::TextureSpec as its
   input parameter.
4. Add tests for the copies with multiple texture array layers. In this
   patch we just copy the data once per texture array layer, while in
   the next patch we will be able to copy the data for all the related
   texture array layers in one copy command.
5. Move some helper functions for copy tests to WGPUHelpers.cpp

BUG=dawn:453
TEST=dawn_end2end_tests

Change-Id: Ia0150a6c55fffce3e24dda2cd45fd920b0873dc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-16 12:26:38 +00:00
Corentin Wallez fefb452f29 Reland: Vulkan: Enforce fixed subgroup size for compute shaders.
Reland after a refactor of how the extension handling work in the Vulkan
backend.

The original author is David Turner <david.turner.dev@gmail.com>.

This CL ensures that, on architectures with a varying subgroup size,
compute shaders are always compiled with a fixed subgroup size to
avoid consistency issues when one shader writes data in a subgroup-size
dependent layout to GPU memory, to be read by another shader in a
future dispatch.

At the moment, only Intel ICDs are known to implement this [1],
and the code uses a heuristics to chose the size of 16, which seems to
be the sweet spot according to Intel engineers.

+ Update the PNextChainBuilder class to deal with the fact that
  VkComputePipelineCreateInfo::pNext is defined as a const void*,
  which created compiler errors in the previous implementation.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=108875

Bug: dawn:464
Change-Id: I035ee06084fcc964742f0bff4c54cff257c742ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23202
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-06-16 09:17:48 +00:00
Corentin Wallez 5cef1162b9 Reland: Vulkan: Report and enable subgroup size control device extension.
Reland after a refactor of how the extension handling work in the Vulkan
backend.

The original author is David Turner <david.turner.dev@gmail.com>.

Certain Vulkan ICDs (Intel ones notably) will compile SPIR-V
shaders with an liberal, compiler-selected, subgroup size (i.e.
either 8, 16 or 32). For more context, see [1].

This can be a problem for compute, when one shader stores data
in device memory using a subgroup-size dependent layout, to be
consumed by a another shader. Problems arise when the compiler
decides to compile both shaders with different subgroup sizes.

To work-around this, the VK_EXT_subgroup_size_control device
extension was introduced recently: it allows the device to
report the min/max subgroup sizes it provides, and allows
the Vulkan program to control the subgroup size precisely
if it wants to.

This patch adds support to the Vulkan backend to report and
enable the extension if it is available. Note that:

- This changes the definition of VulkanDeviceKnobs to
  make room for the required pNext-linked chains of
  extensions.

- A helper class, PNextChainBuilder is also provided in
  UtilsVulkan.h to make it easy to build pNext-linked
  extension struct chains at runtime, as required when
  probing device propertires/features, or when
  creating a new VkDevice handle.

- This modifies VulkanDeviceInfo::GatherDeviceInfo() to
  use PNextChainBuilder to query extension features and properties
  in a single call to vkGetPhysicalDevice{Properties,Features}2.

Apart from that, there is no change in behaviour in this CL.
I.e. a later CL might force a specific subgroup size for
consistency, or introduce a new API to let Dawn clients
select a fixed subgroup size.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=108875

Bug: dawn:464
Change-Id: I01e5c28e7dac66f0a57bf35532eb192912b254fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23201
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-16 07:54:28 +00:00
Corentin Wallez 984493d0ac Deprecate TextureCopyView::arrayLayer -> origin.z
All existing tests and samples are updated and deprecation tests added.

CommandEncoder still encodes using arrayLayers so the backends are
unchanged. They will be handled in a follow-up CL.

Bug: dawn:22

Change-Id: Ib5346b46eb04d97349cab8f32ef8da5034726ca8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23104
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-06-16 03:05:17 +00:00
Austin Eng cf1fdf413c Handle OOM buffer allocations better
This CL checks buffer sizes before creating map read/write handles.
It is an error to map a buffer that can't be addressed on the CPU.

It also changes client-side synchronous errors on mapAsync to be
normal map failures, and not device lost errors. These should be
recoverable.

The CL adds additional testing for really large, but not UINT64_MAX
buffers, and fixes a VVL warning when buffer allocations exceed the
size of their memory heap.

Bug: dawn:450, dawn:398, chromium:1014740
Change-Id: Ieb34c04c3d01c429b7e3b7810729d5e91ecb6270
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22626
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-15 23:42:13 +00:00
Yunchao He e5be22e949 D3D12: use one barrier to transit states for all subresources
If a texture's old states of all subresources are the same, and its
new states are the same too, then we can use one barrier to transit
states for all subresources. We don't need to use one barrier per
each subresource.

This change can reduce barriers we dispatched, in order to improve
performance for particular situations.

Bug: dawn:441

Change-Id: I9fe9dabda725e05d4ce5a8e69ee7b40e6724a22a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23145
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-15 18:32:02 +00:00
Yunchao He 1c2a039e04 Optimize subresource tracking - use texture view
Bug: dawn:441

Change-Id: I5cdfc1d84b27eb0b127d34ee829ceedf15f1150c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22321
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-15 18:26:12 +00:00
Yunchao He ee7debf44d Refactor subresource related variables to a struct - backend
This patch put subresource related variables like baseMipLevel,
levelCount, baseArrayLayer, layerCount into a single struct at
backends.

Bug: dawn:157

Change-Id: I50c6bb0ed8ae7a184506c23cab4b64a472bbd75e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23163
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2020-06-15 17:24:42 +00:00
Corentin Wallez 8a5325ca9a Texture: Change to mArrayLayerCount to mSize.depth
This makes the tracking in TextureBase match the shape of
wgpu::TextureDescriptor.

GetSize() becomes a bit more surprising because the depth can sometimes
be the array size, so new getters GetWidth(), GetHeight() and GetDepth()
are added.

Some simplifications to the backend texture creation code are included
that will make it less error prone to add support for 1D / 3D textures.

Bug: dawn:22

Change-Id: I33b6ca99af9d58fc88f5f626cfd5e2e62a8b45cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23103
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-15 09:57:51 +00:00
Corentin Wallez 4234d78201 Deprecate TextureDescriptor::arrayLayerCount -> size.depth
This updates CL:

 - Adds a deprecation warning to use size.depth instead of
arrayLayerCount.
 - Changes all tests and samples to use size.depth.
 - Adds deprecation tests for the change.

In particular the state tracking in TextureBase isn't changed yet
because it requires non-trivial changes in the backends. It will be done
in a follow-up CL.

Bug:dawn:22

Change-Id: Ic02dfb5baaba8d5b06cd339ce988e9b1d16cb5e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23101
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-15 09:46:01 +00:00
Jiawei Shao 6b3a974b42 OpenGL: Enable nonzero_clear_resources_on_creation_for_testing on buffer
This patch enables nonzero_clear_resources_on_creation_for_testing
toggle on buffer on OpenGL backends as a preparation of supporting
buffer lazy-initialization in Dawn.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: Ib49ad17a5d89e14dbdb08d2eb8d6441fadb68f10
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23143
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-06-13 01:04:53 +00:00
Jiawei Shao 2ef2be746d D3D12: Enable nonzero_clear_resources_on_creation_for_testing on buffer
This patch enables nonzero_clear_resources_on_creation_for_testing
toggle on buffer on D3D12 backends as a preparation of supporting
buffer lazy-initialization in Dawn.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: Id4f45ff5ccf906692c3855451b120aa56f68c7a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23142
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2020-06-13 00:59:13 +00:00
Brandon Jones 1663b1d04d Make D3D12 Fuzzer Only Build On Windows
Prevents the d3d12 fuzzer from building on non-windows platforms.

bug: dawn:444
bug: chromium:1094230
Change-Id: I3ce20c645b3fe99b51e06b493ced34308d7cc21e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23162
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2020-06-12 17:56:31 +00:00
Yunchao He 4fd4aa1f19 Vulkan: use one barrier if we can for non-pass operations
When we do transition barriers for a texture view outside of a pass
(say copy, clear, initialization), if the texture view can cover all
subresources, and its old usages across all subresources are the
same, then we can use one transition barrier. We don't need to use
separate barrier per each subresource.

This patch can reduce barrier we delivered, and improve performance
for particular situations.

Bug: dawn:441

Change-Id: I2ae9b39793915553cbaaceacaf58bf87c9ba3bc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23129
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2020-06-12 17:01:41 +00:00
Corentin Wallez f87b62a904 Don't store unnessary SubresourceRange members in TextureBase
This is preparatory change for a subsequent CL that will deprecate
TextureDescriptor::arrayLayerCount in favor of size.depth.

Bug: dawn:157
Bug: dawn:22
Change-Id: Id64556dc81056fbe7751073ffe9872026c145e77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23102
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-12 16:51:51 +00:00
Corentin Wallez 5c9f7af77d Vulkan: Properly handle Device extension dependencies
The checks for dependencies of Device extensions were incomplete, makes
sure the transitive dependencies of the extensions we care about are all
known so they can participate in the dependency check.

Also removes a workaround for surprising Vulkan behavior with instance
extensions getting promoted as device functions. This should be handled
correctly now as DeviceExt contains the physical device extensions as
well.

Bug: dawn:457

Change-Id: I4b79729d809c9edfedcb075a0e6aa5b4dd473ab3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22942
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-12 08:19:31 +00:00
Brandon Jones 9435068a36 Track ShaderVisibleDescriptorHeap Upon Allocation
Fixes bug where a newly allocated ShaderVisibleDescriptorHeap would be
untracked in the residency LRU upon allocation, causing Dawn's residency
manager to become out of sync with D3D12's internal residency refcount
by calling MakeResident once more than needed.

Bug: dawn:193
Change-Id: I47804471b41df476db989634e50bded6006e05aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23125
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-06-12 08:17:41 +00:00
Natasha Lee 82027bd8ac Fix ResourceMemoryAllocation null dereference
Moves last TickImpl call during ShutDown to only be called if the
device was fully created.

Bug: dawn:400, chromium:1093639
Change-Id: I25437e3b33d0fc57f21e82c63bfb0fd4d9384175
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23123
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-12 08:13:41 +00:00