Commit Graph

505 Commits

Author SHA1 Message Date
Corentin Wallez 6fee61ca9c Make Dawn error macro more explicit and have an "error type"
The error type will help distinguish between validation errors, context
losts and others which should be handled differently.

Take advantage of advantage of this to change DAWN_RETURN_ERROR to
"return DAWN_FOO_ERROR" to have the return be more explicit. Also
removes usage of DAWN_TRY_ASSERT for more explicit checks.

Change-Id: Icbce16b0c8d8eb084b0af2fc132acee776909a36
2018-09-11 07:55:27 -04:00
Corentin Wallez cca9c698a0 Use unique_ptr where applicable.
Change-Id: Icb29f6f9760f0ea36528e8ea6890713c2fb3b965
2018-09-07 07:22:04 -04:00
Corentin Wallez 21d8438ad6 Validate SPIR-V code when creating ShaderModules
This integrates spirv-val in dawn_native so that regular and
WebGPU-specific validation of shaders is done.

Also adds tests to check OpUndef is correctly rejected so we know
WebGPU-specific validation is working.

Change-Id: If49d276c98bca8cd3c6c1a420903fe34923a2942
2018-09-07 05:41:25 -04:00
Corentin Wallez 8e335a5585 Descriptorize ComputePipeline
Change-Id: Ic9d7014ba44d927d7f9ddf81a8870432c68941e8
2018-09-05 08:32:53 -04:00
Corentin Wallez eb7d64a17f D3D12: Destroy all COM objects before the DLLs are unloaded
Change-Id: I00109460fa83110bd9af6d6b8ff2b5022ed580f3
2018-09-05 08:32:53 -04:00
Corentin Wallez 98ca29b582 Fix VkNonDispatchableHandle alignment on Linux x86
There alignof(uint64_t) is 8 but it is aligned to 4 inside structures.

Change-Id: Ia94e9e5c962e9f5898a8f39977b83a9e10cbf454
2018-09-05 08:01:24 -04:00
Li Hao 3cc58af801 Update reason for hiding vktrace layer 2018-09-03 05:45:37 -04:00
Li Hao 92bddc47c9 Vulkan: add macro for vktrace
Hide vktrace layout behide a marco 'DAWN_USE_VKTRACE' and enable it in
build if need.
2018-09-03 05:45:37 -04:00
Jiawei Shao 9daa4ad1c8 Fix the barrier in vulkan::Texture::TransitionUsageNow to make the
barrier cover all the slices in a 2D array texture.
2018-09-03 05:43:49 -04:00
Jiawei Shao 4ccf4e3fdd Support 2D array texture copying on D3D12, Metal and OpenGL
This patch implements the creation of 2D array textures and copying
between a buffer and a layer of a 2D array texture on D3D12, Metal
and OpenGL back-ends.

TEST=dawn_end2end_tests
2018-09-03 05:43:49 -04:00
Corentin Wallez d8597b2e1f D3D12: Dynamically load D3D12, DXGI and D3DCompiler
Linking against their .lib makes loading Dawn fail on systems that don't
have the DLLs. This happens for example on Windows7 that doesn't have
d3d12.dll. Instead we dynamically load functions pointers from these
DLLs at d3d12::Device startup.

Change-Id: I4d01a12d0f91bec45bf125450d2c08aaa9ff9fac
2018-08-31 09:13:35 -04:00
Jiawei Shao 748a5d5b28 Implement DAWN_SKIP_TEST_IF for dawn_end2end_tests
This patch implements a micro DAWN_SKIP_TEST_IF in DawnTest.h which
can be used to skip running a test in dawn_end2end_tests when the
given condition is satisfied.
2018-08-31 03:29:11 -04:00
Jiawei Shao 4b74dbef7b Implement copying between a buffer and a texture 2D array on Vulkan (#257)
Implement copying between a buffer and a texture 2D array on Vulkan

This patch implements the creation of a 2D array texture and data
copying between a buffer and a layer of a 2D array texture on
Vulkan back-ends.

TEST=dawn_end2end_tests
2018-08-30 04:27:38 -04:00
Jiawei Shao 425428f97b Descriptorize Texture
This patch introduces texture descriptor for texture creation instead
of texture builders.

This patch also adds "arrayLayer" to texture descriptor and removes
mDevice in TextureD3D12.
2018-08-28 03:00:48 -04:00
Stephen White 75559bf1be
Change WIN32 to _WIN32. (#260)
WIN32 is defined by the SDK, but _WIN32 is defined by the compiler.
Since Dawn doesn't necessarily include <windows.h> everywhere dawn.h is
included, we should use _WIN32 (which will always be defined).
2018-08-27 10:13:34 -04:00
Corentin Wallez 0fa2feb96a Roll SPIRV-Cross and use upstream repo.
In the DEPS file we are going to use Chromium's mirror of
github.com/KhronosGroup/SPIRV-Cross so we need to adjust .gitmodules to
point to it instead of Kangz/SPIRV-Cross. Also take that opportunity to
roll SPIRV-Cross.

Change-Id: I4f53a4fc54f5b1b9a754ac55e976c81e5eeabeb2
2018-08-24 12:28:28 -04:00
Corentin Wallez d90748b256 Fix VkNonDispatchableHandle's alignment on 32bit platforms
On 32bit platforms, even if it contains a uint64_t the handle wrapper
will align to 4 bytes because the assembly load operations can't take
advantage of 64bit aligned loads.

Fix this by forcing the alignment to the alignment of what would be the
native Vulkan handle type.

Also use macros with defined()

Change-Id: I0de9b4a77e648c416b04311b854c956762248868
2018-08-24 05:47:57 -04:00
Corentin Wallez 82b6573d54 Descriptorize Buffer
We still keep a dummy BufferBuilder object around so that it can be used
for the builder error callback tests of the wire.

Change-Id: If0c502bb8b62ee3ed61815e34e9b6ee6c03a65ef
2018-08-23 08:23:06 -04:00
Corentin Wallez 0202250464 Check ShaderModuleDescriptor->nextInChain
Change-Id: Iffa7485b3a2dc43911c86ac614e7d99d737aaf6f
2018-08-23 08:23:06 -04:00
Corentin Wallez 62c774391b Rename GetAllowedUsage to GetUsage.
Resources used to have both a current and an allowed usage but the
concept of current usage has been removed so we can rename "allowed
usage" to "usage" to make the name match WebGPU's
WebGPUBufferDescriptor::usage and WebGPUTextureDescriptor::usage

Change-Id: I5190950bf7f7f5b86c92247ef0240fead9886268
2018-08-23 08:23:06 -04:00
Corentin Wallez 5800712897 Workaround a _GLIBCXX_DEBUG bug for std::hash<std::bitset>
This fixes the GN debug build on Linux.

Change-Id: I847a8c67eda1f9069477de0af910f0cd520ccc2c
2018-08-21 02:28:16 -04:00
Corentin Wallez f35eff3fde Remove BindGroupBuilder::SetUsage
BindGroup usage isn't something that's part of WebGPU's sketch.idl and
it might never exist. Remove it to simplify the migration of bindgroup
to descriptor.

Change-Id: I21e0a98eb60434d4009e748cd9afcbf89edd7e6a
2018-08-21 02:27:12 -04:00
Corentin Wallez df6710358b Descriptorize ShaderModule
Change-Id: Ic79d00380f583485de0fb05bd47b1f869919ebe6
2018-08-21 02:26:24 -04:00
Jiawei Shao 94c92fa5e7 Enable RenderPassLoadOpTests on Vulkan back-ends
RenderPassLoadOpTests can pass on Vulkan back-ends now.
2018-08-17 09:53:15 +02:00
Corentin Wallez 5b61abce09 Fix Windows compilation using GN and clang-cl.
This includes a bunch of fixes for clang warnings in Windows specific
code that was only compiled by MSVC previously. This also tidies up some
BUILD.gn issues on Windows.
2018-08-14 21:42:32 +02:00
Corentin Wallez d2969a7d3d Make Dawn "gn check" by default (except SPIRV-Tools)
This required adding some missing dependencies, splitting public headers
of libdawn_[native|wire] so they aren't hidden in the
libdawn_[native|wire]_sources targets, and making unittests depend on
sources directly instead of static libraries (which is almost equivalent).

As a byproduct, Empty.cpp is no longer needed and is removed.
2018-08-14 14:33:19 +02:00
Corentin Wallez c978fe8d15 Fix D3D12Binding crach after the GetProc refactor 2018-08-09 20:54:43 +02:00
Corentin Wallez de4dbc3cf7 Fix VulkanBindings crash 2018-08-06 21:39:17 +02:00
Corentin Wallez e046e6b2ab Fix -Wsign-compare warnings in unittests 2018-08-06 21:39:17 +02:00
Corentin Wallez 21a23857dc Add initial BUILD.gn files for libdawn[|_native|_wire] 2018-08-06 16:38:33 +02:00
Corentin Wallez dcb71a131c dawn_native: Factor getting procs into a single function.
Now the backends only expose the creation of devices. Getting the procs
is moved to DawnNative that will over time more backend-agnostic APIs.
2018-08-06 16:38:33 +02:00
Corentin Wallez fe253f135b Generate a single ProcTable instead of one per backend.
This required putting Queue::Submit on QueueBase which is something we
would want to do anyway, and removes the need for Queue::ValidateSubmit
being called in the ProcTable.

This removes the need for all the "GeneratedCodeIncludes" files and
leads to a bunch of simplifications in BindGroup as well as the
dawn_native CMakeLists.txt.

Finally this was done in order to simplify the writing of BUILD.gn
files.
2018-08-02 13:39:07 +02:00
Corentin Wallez 1ac25e850a Fix the utils copy of glad not being initialized 2018-08-02 13:39:07 +02:00
Corentin Wallez 1a796039d9 Make shared library dependencies private.
By default CMake makes dependencies public, which is not what we want
for libdawn, libdawn_native and libdawn_wire
2018-07-30 17:22:45 +02:00
Corentin Wallez bdc867713a Make dawn_wire a shared library
Also moves the TerribleCommandBuffer to utils:: because it isn't part of
the implementation of the wire, renames dawn::wire to dawn_wire, moves
src/wire to src/dawn_wire and puts the interface of dawn_wire in
src/include/dawn_wire.
2018-07-30 17:22:45 +02:00
Corentin Wallez 012c149fd9 Build with nortti/exceptions and fvisibility=hidden
This both makes the CMake build closer to the Chromium build, and
reduces the binary size heavily.
2018-07-30 17:22:45 +02:00
Corentin Wallez 196ade667f Make libdawn_native a shared library.
The interface exposed by libdawn_native is declared in the new headers
living in src/include/dawn_native so that they both the users and the
libraries use the DAWN_NATIVE_EXPORT macros.
2018-07-27 12:56:26 +02:00
Corentin Wallez 36afbb6a0d Make dawn_native use its own header for Dawn datatypes
The dawn.h and dawncpp.h structure definitions references dawnFoo or
dawn::Foo respectively when it should reference dawn_native::FooBase* in
dawn_native. Autogenerate files to declare the dawn_native version of
the structs and change the ProcTable generation to use it instead.

This is important to make libdawn_native a shared library because
currently it was depending on dawncpp's definition of .Get().
2018-07-27 12:56:26 +02:00
Corentin Wallez 5d313225ff Make the Vulkan backend interface use native Vulkan types
This extends our Vulkan handle wrapper to have conversions from uint64_t
as well as the native Vulkan types:
 - The dawn_wsi interface uses the uint64_t version.
 - The backend interface uses the native Vulkan version
2018-07-27 12:56:26 +02:00
Corentin Wallez 5dcaadb0f9 Make libdawn a shared library, add a DAWN_EXPORT macro 2018-07-25 21:03:49 +02:00
Corentin Wallez e37234cd22 Standardize header guards for libdawn headers 2018-07-25 21:03:49 +02:00
Corentin Wallez 6c27fd9c94 CMakeLists: Generate Dawn headers separately from libdawn
libdawn will be one of the libraries produced but other libraries like
libdawn_native don't need to link against it. However they do need the
Dawn headers so we generate them separately.

This also makes all internal targets depend on the header generation and
have the include directories necessary for those headers.

Also has a small fix for setting compile flags only for C++ files.
2018-07-25 21:03:49 +02:00
Corentin Wallez 49a65d0c0c dawn_native: Fixup namespace from backend:: to dawn_native:: 2018-07-25 11:27:55 +02:00
Corentin Wallez 30965a7729 dawn_native: Fixup header guards from BACKEND_ to DAWNNATIVE_ 2018-07-25 11:27:55 +02:00
Corentin Wallez d37523fbde Move src/backend to src/dawn_native 2018-07-25 11:27:55 +02:00
Corentin Wallez 7914958034 BufferBase: Split validation in helper methods 2018-07-20 21:37:44 +02:00
Corentin Wallez 1ea205fb12 CommandBuffer: have a state tracker per-pass
Also perform small code simplifications of the CommandBufferStateTracker
now that it only tracks aspects.
2018-07-20 21:37:34 +02:00
Stephen White 1184e46f87
Fix bind group binding ID validation. (#227)
* Fix bind group binding ID validation.

Use the binding, not the iterator index.
2018-07-19 09:52:31 -04:00
Corentin Wallez 6ed9cbf894 Rename last references of NXT to Dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 9fc65344f4 Rename NXT -> Dawn in the comments 2018-07-18 22:54:06 +02:00