Commit Graph

541 Commits

Author SHA1 Message Date
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
Corentin Wallez 923574eed5 Rename IsNXTBitMask and NxtReference/Release to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez a5ee52d33e Rename NXT -> DAWN in header guards 2018-07-18 22:54:06 +02:00
Corentin Wallez 0927ea549c Rename // NXT API to // Dawn API 2018-07-18 22:54:06 +02:00
Corentin Wallez a4da03249c Rename NXTTest to DawnTest
Also formats the whole file for the first time.
2018-07-18 22:54:06 +02:00
Corentin Wallez ae187efc80 Rename NXT_INSTANTIATE_TEST to DAWN_INSTANTIATE_TEST 2018-07-18 22:54:06 +02:00
Corentin Wallez be5ca38351 Rename nxtProcTable and nxtSetProcs to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez b1669e3fa4 Change the API prefix in generators from nxt to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez ae79c03d45 Rename the nxt namespace to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 05c90ee4cb Rename nxt -> dawn for dawn_wsi.h declarations
Also does the initial complete formatting of files in src/include
2018-07-18 22:54:06 +02:00
Corentin Wallez 3e371b146d Rename files in src/include nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 046cb46bee Rename generated files nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez fde3f2b5e0 Rename NXT -> Dawn in the rest of CMakeLists 2018-07-18 22:54:06 +02:00
Corentin Wallez f684040e0a Rename NXTHelpers to DawnHelpers 2018-07-18 22:54:06 +02:00
Corentin Wallez d148aebf3f Rename CMakeLists targets nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez f1ded9bea2 Rename CMakeLists variables NXT_* to DAWN_* 2018-07-18 22:54:06 +02:00
Corentin Wallez 54e58c20b2 Rename nxt:: to dawn:: in tests 2018-07-18 22:54:06 +02:00
Corentin Wallez 83a9c9d6d9 Rename src/common macros NXT_* to DAWN_* 2018-07-18 22:54:06 +02:00
Corentin Wallez 33ca49614d Rename Error.h macros from NXT to DAWN 2018-07-18 22:54:06 +02:00
Corentin Wallez 226110f958 Rename nxt:: to dawn:: in the backends 2018-07-18 22:54:06 +02:00
Corentin Wallez 4a9ef4ee21 Rename the copyright authors from NXT to Dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 021c9504d0 Make CommandBufferValidation use Error.h 2018-07-17 22:34:10 +02:00
Corentin Wallez 52f2383bb8 DeviceBase: Add helper to consume errors
This adds DeviceBase::ConsumedError which is a helper method intended to
be the main place where Error.h errors are consumed.

To test this mechanism, object creation using descriptors is changed to
use ConsumedError, which finally gets their validation errors go
somewhere. This mechanism isn't final though because we have yet to
implement WebGPU error handling.
2018-07-17 22:34:10 +02:00
Corentin Wallez 629c11baad Add windows_with_undefs.h to fix conflicts with windows.h
windows.h adds macros such as `#define GetMessage GetMessageA` which
cause conflicts in naming when for example a class definition is before
windows.h and a use is after windows.h

Add a header that can be used both to include windows.h and remove
defines, and to only remove defines (when windows.h is included by)
external dependencies.
2018-07-17 22:34:10 +02:00
Kai Ninomiya 6aaa10fa60
Skip ComputeCopyStorageBufferTests.SizedArrayOfStruct on D3D12 (#225) 2018-07-17 11:14:47 -07:00
Kai Ninomiya b7ecfaa347
Partially fix ComputeCopyStorageBufferTests.DISABLED_UnsizedArray (#220)
And update test names + comments on several ComputeCopyStorageBufferTests cases.
2018-07-16 13:44:59 -07:00
Corentin Wallez d8c068fb4f Remove explicit usage transition from the API and validation
This removes the following for both Buffer and Texture:
 - The builder's SetInitialUsage
 - The object's FreezeUsage and TransitionUsage methods
 - The CommandBuffer Transition<Object>Usage methods

All samples and tests are simplified as a result. This also obsoletes
the UsageValidationTest which is removed.

Some validation was dependent on "current usage" and hasn't been
reintroduced for implicit transitions yet:
 - Buffers can be used while mapped
 - Swapchain textures can be used after they have been presented.

Validation for these will involve collecting all the resources used by a
command buffer and will be done in a follow-up patch.
2018-07-16 14:44:20 +02:00
Corentin Wallez d2312e8138 Fix D3D12 compute bindgroups 2018-07-16 14:44:20 +02:00
Corentin Wallez 27388434d6 D3D12: Fix SetDescriptorHeap when we only have a sampler heap 2018-07-13 13:31:14 +02:00
Corentin Wallez a430a9a0aa Make the D3D12 backend support implicit barriers
With this the backend ignores explicit usage transition hints from the
frontent and generates all the barriers automatically based on resource
usage.

The current implementation is very naive and encodes a barrier
immediately just before a resource is used in a new state.
2018-07-13 13:31:14 +02:00
Corentin Wallez 2beeae3ad3 CommandBufferD3D12: Iterate per pass 2018-07-13 13:31:14 +02:00
Corentin Wallez aa13be96e8 Make the Vulkan backend support implicit barriers.
With this commit the Vulkan backend completely ignores the explicit
barrier commands passed from the frontend, and generates its own
pipeline barriers.

Right now it encodes each barrier just before the resources are used,
which is quite bad but will be optimized later.

This commit also makes the frontend command buffer validation perform
the checks necessary for implicit barriers (although they are redundant
with checks for explicit barriers) because the tracking can pre-compute
pass usage information that's useful for the Vulkan backend.

Tests for usage validation inside passes will be added once the concept
of transition is removed from the API.
2018-07-11 17:17:21 +02:00
Corentin Wallez 117f2f0ad6 Make EnumClassBitmask operations constexpr
This allows declaring combinations of bits as constants in header.
kReadOnlyBufferUsages is added using this feature.

Also reformat the file.
2018-07-11 17:17:21 +02:00
Kai Ninomiya 23bec15f4c
ComputeCopyStorageBufferTests (#216)
These should hopefully subsume the ComputeBoids demo for testing purposes. Not all of these tests pass currently:

* ComputeCopyStorageBufferTests.StructTest/D3D12 fails due to "Reading structs from ByteAddressBuffer not yet supported."
* The disabled tests fail for various reasons on various backends.
2018-07-10 17:26:35 -07:00
Kai Ninomiya 0582bfdfda
Fix D3D12 descriptor renumbering (#218)
Previously, the renumbering loop would sometimes iterate in the wrong order. To fix this, instead use the binding info already correctly extracted by `ExtractSpirvInfo`.

Fixes ComputeCopyStorageBufferTests.BasicTest/D3D12.
2018-07-10 17:25:48 -07:00
Kai Ninomiya 21006bbe6f Assert HandleCommands succeeds 2018-07-10 14:00:52 -07:00
Kai Ninomiya 234becf175
Use a descriptor for BindGroupLayout (#211)
* Use a descriptor for BindGroupLayout
* Fix MatchesLambda
* Add WireTests.StructureOfStructureArrayArgument
* Add BindGroupValidationTests.BindGroupLayoutCache
2018-07-10 12:23:50 -07:00
Corentin Wallez 976430c097 CommandBufferMTL: Iterate per-pass
This introduces a small amount of code duplication in the code that
handles push constants. On the plus side it removes the need for all the
asserts around which Metal encoder is active.
2018-07-10 10:59:44 +02:00
Corentin Wallez c9f0348bfe CommandBufferVk: Iterate per-pass 2018-07-10 10:59:44 +02:00
Corentin Wallez 47fe5c52b5 CommandBufferGL: Iterate per pass 2018-07-10 10:59:44 +02:00
Corentin Wallez b3bd35ed88 CommandBufferBuilder::Validate: Iterate per pass
This changes the validation to have one iteration loop for the main
buffer that calls to pass-specific iteration loops for compute passes
and render passes. This is done to simplify code a bit and will help
implement implicit transitions that are "precomputed" per pass in the
command buffer validation and re-used in the backends.

A number of code simplifications were made to CommandBufferStateTracker
since it doesn't need to know if we are in a pass anymore. Further
simplifications will happen when implicit barriers are implemented.
2018-07-10 10:59:44 +02:00
Corentin Wallez e909d4efe1 Move FreeCommands and SkipCommand to their own file 2018-07-10 10:59:44 +02:00
Stephen White bcd2e8559e
Remove extra copy of Queue in GL backend. (#213) 2018-07-06 15:39:11 -04:00
Kai Ninomiya 11fc210487 Move mDevice from PipelineLayoutVk to PipelineLayoutBase 2018-07-03 14:54:40 -07:00
Kai Ninomiya c5711ecd93 Rename GetBindGroupsLayoutMask -> GetBindGroupLayoutsMask 2018-07-03 14:54:40 -07:00
Kai Ninomiya 311e2a44b9 Allow bind group layouts to be sparse in pipeline layout
Instead of initializing all of the bind group layouts in the pipeline
layout to default values, let them be nullptr and allow this elsewhere.

Follow-up on some changes in #206
2018-07-03 14:54:40 -07:00
Kai Ninomiya 66c06f42f4
Manually retain/release mPendingCommands (#208)
Fixes a crash for me on macOS+Metal
2018-07-03 12:19:28 -07:00
Kai Ninomiya f53f98bf86
Use a descriptor for PipelineLayout (#206)
Adds support for structures inside descriptors.
2018-06-27 16:21:39 -07:00
Corentin Wallez a2f9277dac D3D12: Split D3D12Backend in Forward.h and DeviceD3D12 2018-06-19 13:51:26 -04:00
Corentin Wallez 1f51263672 Metal: Split off QueueMTL 2018-06-19 13:51:26 -04:00
Corentin Wallez 0f2e7b67c1 Metal: Split MetalBackend in Forward.h and DeviceMTL 2018-06-19 13:51:26 -04:00
Corentin Wallez a714f5b459 OpenGL: Split off QueueGL 2018-06-19 13:51:26 -04:00
Corentin Wallez 77d1f10493 OpenGL: Split OpenGLBackend in Forward.h and DeviceGL 2018-06-19 13:51:26 -04:00
Corentin Wallez 30f7ddbb6b Vulkan: Split VulkanBackend in Forward.h and DeviceVk 2018-06-19 13:51:26 -04:00
Corentin Wallez a4cb35cdbc Vulkan: Split off QueueVk 2018-06-19 13:51:26 -04:00
Corentin Wallez b703def640 Add Device::CreateQueue() instead of the builder
We are changing all object creation to use descriptors but there is no
creation argument to pass for queue, so instead Device::CreateQueue
takes no argument.
2018-06-18 13:33:40 -04:00
Corentin Wallez 82565b340f Add NXT_UNUSED to silence unused warnings 2018-06-12 14:26:32 -04:00
Corentin Wallez 5ab96e0d40 Wire: Implement MapWriteAsync
The flow of commands is a bit more involved than for MapReadAsync and
goes like this:
 - C->S MapAsync isWrite = true
 - S: Call MapWriteAsync
 - S: MapWriteAsync callback fired
 - S->C: MapWriteAsyncCallback (no data compared to the read case)
 - C: Call the MapWriteAsync callback with a zeroed out buffer
 - C: Application calls unmap.
 - C->S: UpdateMappedData with the content of the mapped pointer
 - S: Copy the data in the mapped pointer
 - C->S: Regular unmap command
 - S: Call unmap

Makes nxt_end2end_tests -w pass all tests.

Also duplicates the MapRead wire tests for the write cases
2018-06-09 13:52:45 +02:00
Corentin Wallez 88fb8fa353 Wire: Move the logic of [de]serialization in WireCmd.
This will help with follow-up changes that add support for a more
complete grammer of types, including structures containing pointers
to objects or other structures.

Instead of having the wire::Client and wire::Server directly act on
buffer memory, a couple interfaces are introduced so that WireCmd can do
things like get the object<->id mapping and temporary allocations.

While the serialization and deserialization of most commands was moved
into WireCmd, the commands that don't directly correspond to NXT methods
have their logic moved inside Client and Server and will be made to
expose the new interface in a follow-up commit.
2018-06-08 13:58:55 +02:00
Corentin Wallez 419e9841a8 NXTTest: add -w to run the end2end tests through the wire
This will be useful to provide additional coverage of the wire in
addition to the very focused WireTests unittests. All tests pass except
the MapWriteAsync ones that aren't implemented in the wire yet. They can
be skipped with --gtest_filter=-*MapWrite*
2018-06-08 13:58:55 +02:00
Corentin Wallez 79d9e16d3c Make Device::CreateSamplerImpl to return a ResultOrError
This will allow backends to do error-handling internally for things like
allocation failures though non of them take advantage of it yet.
2018-05-31 15:00:28 -04:00
Corentin Wallez 50e0986e0e Use Error in Sampler and autogenerated validation functions 2018-05-31 15:00:28 -04:00
Corentin Wallez 1fda980fa6 Add an Error and ResultOrError<T> type and tests
These types are meant to be used for computations that might but are not
expected to fail in backend/, such that the error case can be much
slower than the success case.

The NXT_TRY and NXT_TRY_RESULT macros are added to help write more
concise code that uses Error and ResultOrError.
2018-05-31 15:00:28 -04:00
Corentin Wallez 44b5ca4aa1 Add a functional-y Result<T, E> class and tests for it.
Implements two optimized versions of Result, one for Result<void, E*> as
a nullable pointer, and one for Result<T*, E*> as a tagged pointer.
2018-05-31 15:00:28 -04:00
Corentin Wallez 2141e960b7 Add NXT_(UN)?LIKELY macros to help with branch prediction 2018-05-31 15:00:28 -04:00