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).
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
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
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
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
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
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.
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.
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.
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.
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.
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().
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
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.
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.
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.
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.
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.
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.
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.
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.
* Use a descriptor for BindGroupLayout
* Fix MatchesLambda
* Add WireTests.StructureOfStructureArrayArgument
* Add BindGroupValidationTests.BindGroupLayoutCache
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.
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.
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
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.
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
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.
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*
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.