Commit Graph

2081 Commits

Author SHA1 Message Date
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
Corentin Wallez cf77d75573 Roll third_party/swiftshader/ d25ce8725..f6f11215c (155 commits)
https://swiftshader.googlesource.com/SwiftShader/+log/d25ce8725224..f6f11215cd93

$ git log d25ce8725..f6f11215c --date=short --no-merges --format='%ad %ae %s'
2020-07-01 capn Implement shaderStorageImageExtendedFormats support
2020-07-05 capn Implement scatter/gather for 1- and 2-byte texels
2020-07-01 capn Fix float-to-half conversion
2020-07-03 capn Eliminate large image specialization
2020-06-24 capn Refactor texel buffer reads
2020-06-24 capn Implement SNORM uniform texel buffer support
2020-06-24 capn Implement B10G11R11_UFLOAT_PACK32 uniform texel buffer support
2020-07-02 sugoi ASTC Decoder: Trim unused struct members
2020-07-02 capn Fix /DEBUG:FASTLINK usage
2020-06-30 pcc Start reserving x18 by default on Android targets.
2020-06-25 srisser Fix debug assert from happening in release build
2020-06-10 capn Optimize clearing of depth and stencil images
2020-06-25 thakis mac: Add ARM64 support to swiftshader.
2020-06-22 amaiorano Kokoro: add builds with REACTOR_EMIT_DEBUG_INFO and REACTOR_EMIT_PRINT_LOCATION
2020-06-22 amaiorano Fix build when ENABLE_RR_DEBUG_INFO enabled
2020-06-22 amaiorano Make Windows Kokoro script less verbose
2020-06-22 cwallez Revert "Optimize clearing of depth and stencil images"
2020-06-11 capn Assert attachment format supports blending when blending is enabled
2020-06-10 capn Optimize copying image data for presentation
2020-06-10 capn Optimize clearing of depth and stencil images
2020-06-01 capn Assert reserved binding entries aren't accessed
2020-05-12 capn Optimize out-of-bounds checks with unsigned compare
2020-05-07 capn Replace instead of add pointer offsets when out of bounds
2020-06-15 capn Add a benchmark with multisampling enabled
2020-06-15 capn Refactor multisample benchmark support
2020-06-11 capn Implement multisample support for the triangle benchmark
2020-06-17 capn Don't assert thread_local initialization
2020-06-11 capn Ignore rasterization state pointers when rasterization is disabled
2020-06-11 capn Zero-initialize the context state and data
2020-06-15 sugoi Cleanup: using the proper Image subregion structure
2020-06-16 bclayton Squashed 'third_party/marl/' changes from 5c6c1532220..d29553a3730
2020-06-16 bclayton Squashed 'third_party/marl/' changes from c5127112545..5c6c1532220
2020-06-09 bclayton SpirvShaderDebugger: Show vector elements as xyzw
2020-06-09 bclayton SpirvShaderDebugger: Add a virtual destructor
2020-06-15 bclayton Squashed 'third_party/marl/' changes from 38c0c7a0f..c51271125
2020-06-15 bclayton Repoint marl branch from master to main
2020-06-15 bclayton SubzeroReactor: Use new marl::Scheduler::Config API.
2020-06-10 amaiorano Make rr::Print output to debugger and be stubbed
2020-06-10 sugoi Regres: Roll deqp forward to latest 1.2.1
2020-06-04 capn Validate the SPIR-V code in debug builds
2020-06-05 capn Add a triangle rendering benchmark
2020-06-10 capn Add glslang dependency to VulkanBenchmarks
2020-06-10 capn Add glslang as a submodule
2020-06-05 capn Move CMake build targets for PowerVR samples before unit tests
2020-06-01 capn Add microbenchmarks for vkCmdClear*Image
2020-06-04 capn Add back vulkan.hpp
2020-06-01 caio.oliveira Convert Vulkan headers from CRLF to LF endings
2020-06-02 ari.suonpaa Add Z mirroring support for image blit.
2020-05-26 vantablack Added reference counting for PipelineLayout objects
2020-06-02 bclayton libVulkan: Use new marl::Scheduler::Config API.
(...)
2020-05-01 amaiorano Regres: use Subzero backend by default
2020-04-30 bclayton Squashed 'third_party/marl/' changes from 748d3c161..3c643dd4c
2020-04-30 bclayton Vulkan/Debug: Don't step for column updates
2020-04-30 bclayton Vulkan/Debug: Fix build with clang-10.
2020-04-12 bclayton Device: Use std::unique_ptr instead of raw pointers
2020-04-09 amaiorano CMake: add graphviz generation scripts
2020-04-29 jrprice Fix null dereference in OFFSET macro
2020-04-29 capn Fix JIT on separate thread
2020-04-28 capn Avoid implicitly destructing thread-locals
2020-04-27 amaiorano Eliminate use of Vulkan header BEGIN_RANGE/END_RANGE/RANGE_SIZE enums
2020-04-27 amaiorano Run clang-format on renamed headers
2020-04-27 amaiorano Rename Vulkan-source .h to .hpp
2020-04-27 bclayton ReactorUnitTests: Speed up multithreaded tests
2020-04-22 capn Eliminate the ABORT() macro
2020-04-24 capn Record vkCmdBindDescriptorSets() as a single command
2020-04-23 capn Store binding information in the pipeline layout
2020-04-22 capn Don't expose individual descriptor set layouts to SPIR-V compilation
2020-04-23 capn Fix ordering of descriptor set bindings
2020-04-24 bclayton SpirvShader: Document activeLaneMask() and storesAndAtomicsMask()
2020-04-24 capn Omit ASSERT() expression evaluation in Release builds
2020-04-23 bclayton SpirvShaderDebugger: Ensure frames are fully popped
2020-04-23 bclayton SpirvShaderDebugger: Implement globals, stub array types
2020-04-22 bclayton SpirvShader: Add WriteCFGGraphVizDotFile debug function
2020-04-21 pcc Don't unlock Android buffers immediately after locking them.
2020-04-20 digit LLVM: Do not map read-only data sections as executable.
2020-04-17 digit Vulkan: Add vk_icdInitializeConnectToServiceCallback()
2020-04-23 amaiorano Kokoro: fix SWIFTSHADER_LESS_DEBUG_INFO not being set
2020-04-22 digit Update tests/presubmit.sh to accept Fuchsia bugs as fxb/#
2020-04-22 capn Fix specializing graphics routines for the pipeline layout
2019-05-15 bclayton SpirvShader: Add a flag for printing SPIRV execution
2020-04-17 bclayton Regres: Write logs to /dev/null
2020-04-20 amaiorano CMake: use target_compile_options/definitions for llvm
2020-04-20 amaiorano CMake: use target_link_options
2020-04-20 amaiorano CMake: require version 3.13
2020-04-20 amaiorano Kokoro: update CMake to latest version
2020-04-17 bclayton Regres: Limit the default number of threads to 100
2020-04-15 capn Pass only descriptor data to shader execution
2020-04-16 capn Reduce descriptor binding info exposure
2020-04-22 bclayton Kokoro: Fix ubuntu bots.
2020-04-17 digit Vulkan: Fix Fuchsia external semaphore fix tryWait().
2020-04-21 amaiorano CMake: fix astc code not being enabled correctly
2020-04-20 capn Don't use deprecated llvm::Type::getVectorNumElements()
2020-04-17 capn Fix JIT on separate thread
2020-04-03 bclayton Use Thread Safety Analysis annotations throughout SwiftShader.
2020-04-17 digit CMakeLists: Fix Fuchsia build.
2019-07-01 bclayton LLVMReactor: Drop codegenMutex, now thread safe.
2020-04-17 bclayton LLVMJIT: Remove the TargetMachine cache.
2020-04-17 bclayton LLVM 7: Set LLVM_ENABLE_THREADS to 1
2020-04-17 bclayton SpirvShader: Fix ASSERT firing in debugger
2020-04-17 bclayton Squashed 'third_party/marl/' changes from 539094011..748d3c161

Created with:
  roll-dep third_party/swiftshader

TBR=enga@chromium.org
Bug: None

Change-Id: I9c71f3e1810f0515ba5958cf18c9d31f0b3b40cd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24441
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-07 10:24:41 +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
Ryan Harrison 92554d75f3 Update path of third_party/spirv-tools to SPIRV-Tools
Change-Id: Id0ee4940c7cec255558bcca3bfa578ee4bdb87ab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24421
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-07-06 21:31:00 +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
Hao Li 16ca52cc16 Roll third_party/shaderc/ caa519ca5..f4025c1cd (2 commits)
caa519ca53..f4025c1cd5

$ git log caa519ca5..f4025c1cd --date=short --no-merges --format='%ad %ae %s'
2020-07-01 xinghua.cao Add interface for enabling 16-bit types (#1091)
2020-06-23 rharrison Roll 5 dependencies and update tests/expectations (#1087)

Created with:
   roll-dep third_party/shaderc --roll-to 'origin/main'

Bug: dawn:426
Change-Id: I99198704f7cb3ce6e5ceab74f2941372fd4af025
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24220
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-07-02 08:50:28 +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
Jiajie Hu 2ffc55ab38 Never try to populate the LASTCHANGE file in non-standalone checkout
Since the build/ directory is checked out behind 'dawn_standalone', the
'lastchange' hook depending on that should be guarded by the same
condition.

Bug: dawn:437
Change-Id: If6d1f5ee505eab5bc5519ec6d29b2efe5d69d9aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24123
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiajie Hu <jiajie.hu@intel.com>
2020-07-01 05:08:36 +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
Brandon Jones 10e4a44ce6 Roll third_party/spirv-cross/ f9ae06512..2e7a56258 (1 commit)
f9ae06512e..2e7a562583

$ git log f9ae06512..2e7a56258 --date=short --no-merges --format='%ad
%ae %s'
2020-06-23 post HLSL: Workaround FXC bugs with degenerate switch blocks.

Created with:
    roll-dep third_party/spirv-cross

Bug: dawn:425
Change-Id: Ibc80512eeb55b46704daccfd7f4cc2d6c1ddedc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23760
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-23 20:14:15 +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
Ryan Harrison 4cf65bcab5 Rolling 4 dependencies
Roll third_party/glslang/ 00965b9fa..839704450 (14 commits)

00965b9fa9..8397044502

$ git log 00965b9fa..839704450 --date=short --no-merges --format='%ad %ae %s'
2020-06-22 gleese Update test expected files with new magic number
2020-06-22 gleese Update SPIR-V generator version
2020-06-05 gleese Update test results to expect OpFUnordNotEqual
2020-06-05 gleese Use OpFUnordNotEqual for floating-point !=
2020-06-22 johnkslang Update README.md
2020-06-19 bclayton Add kokoro configs for android-ndk and cmake
2020-06-19 bclayton Switch ndk_test from gnustl_static to c++_static
2020-06-17 ShabbyX Add -g0 command line argument
2020-06-16 cepheus Build: use better MSVC subfolder names for the previous build changes.
2020-06-16 cepheus Bump version numbers.
2020-06-16 bclayton Move hlsl/ source to glslang/HLSL/
2020-06-16 cepheus Bump version.
2020-06-15 bclayton CMake: Fold HLSL source into glslang
2020-06-10 bclayton C Interface: Split SPIR-V C interface to own file

Roll third_party/shaderc/ c2ac70797..caa519ca5 (2 commits)

c2ac70797a..caa519ca53

$ git log c2ac70797..caa519ca5 --date=short --no-merges --format='%ad %ae %s'
2020-06-17 rharrison Add support for different default/trunks in roll-deps (#1086)
2020-06-15 rharrison Rolling 5 dependencies (#1085)

Roll third_party/spirv-cross/ 9e3df69d4..f9ae06512 (12 commits)

9e3df69d4e..f9ae06512e

$ git log 9e3df69d4..f9ae06512 --date=short --no-merges --format='%ad %ae %s'
2020-06-22 dsinclair Roll deps and update tests.
2020-06-22 post MSL: Remove the old VertexAttr API.
2020-06-19 cwallez Fix placement of SPIRV_CROSS_DEPRECATED.
2020-06-19 post Fix duplicated initialization for loop variables with initializers.
2020-06-18 post MSL: Add test case for constructing struct with non-value-type array.
2020-06-18 post MSL: Deal with loading non-value-type arrays.
2020-06-18 post MSL: Add tests for array copies in and out of buffers.
2020-06-18 post MSL: Improve handling of array types in buffer objects.
2020-06-18 post Clean up some deprecation warnings when building with Makefile.
2020-06-18 post Remove unused member in MSLShaderInput.
2020-06-13 cdavis MSL: Fix up input variables' vector lengths in all stages.
2020-06-16 post HLSL: Fix texProj in legacy HLSL.

Roll third_party/tint/ b8f493005..0c647a889 (15 commits)

https://dawn.googlesource.com/tint/+log/b8f4930055df..0c647a8896d1

$ git log b8f493005..0c647a889 --date=short --no-merges --format='%ad %ae %s'
2020-06-22 dneto sample: handle SPIR-V assembly input
2020-06-19 dj2 [spirv-writer] Emit logical and and logical or
2020-06-18 dneto [spirv-reader] Remove orphaned TODOs
2020-06-18 dsinclair Add support for sclamp and uclamp GLSL methods.
2020-06-18 dsinclair [spirv-writer] Add as casts.
2020-06-18 dneto [spirv-reader] Add ConvertFToU, ConvertFToS
2020-06-18 dsinclair [wgsl-reader] Fixup off by 1 bug.
2020-06-17 dneto [spirv-reader] Add mixed scalar/vector/matrix multiply
2020-06-17 dneto [spirv-reader] Add ConvertSToF, ConvertUToF
2020-06-17 dj2 Add GLSL MatrixInverse type determination.
2020-06-17 dneto [spirv-reader] Add vector shuffle
2020-06-17 dj2 Add type determination for GLSL determinant.
2020-06-17 dneto [spirv-reader] Add OpCopyObject
2020-06-17 dj2 [spirv-writer] Only extract composites for non-const constructors.
2020-06-16 dneto [spirv-reader] Add ArrayStride

Change-Id: I74d332c0972b2e6e0f4b6cc349d54ea5887b051c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23661
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-06-22 20:54:53 +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