Commit Graph

514 Commits

Author SHA1 Message Date
Corentin Wallez 226110f958 Rename nxt:: to dawn:: in the backends 2018-07-18 22:54:06 +02:00
Corentin Wallez 141c0be317 Add a temporary define to help rename nxt:: to dawn:: 2018-07-18 22:54:06 +02:00
Corentin Wallez a22335c2b7 Rename next.json to dawn.json 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 cfa524b86b
Fix glTFViewer by using push constants (#224)
* Works on Metal
* Not working on OpenGL (black screen; not sure why)
* Not working on Vulkan or D3D12 (push constants not implemented)
2018-07-17 11:12: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
Kai Ninomiya e320182f40
Fix glTFViewer (bind group + y-flip) (#222)
Doesn't completely fix the viewer - there is still a TODO about uniform buffers being updated incorrectly.
2018-07-16 10:30:16 -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
Corentin Wallez d5c1ecaf64 WireClient: MapReadCallback, unconditionnally consume the data
When a MapReadRequestCallback arrived late and hit one of the early out
of the handler (for example if the buffer was already unmapped), the
handler wouldn't consume the data payload of the command. This would
cause the command buffer pointer to not be advanced enough and point to
random data instead of the next command.
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
Kai Ninomiya 7883e7e59c
Fix ComputeBoids (#214)
I know there was some churn on which version of this shader was correct - but right now, this goes from broken on all 4 backends to working on all 4 backends. So this seems better.

The old code (accidentally?) uses descriptor arrays (I think), which are not trivial to support on all backends, so we won't use them for now.
2018-07-10 11:01:28 -07:00
Kai Ninomiya 6c639c991e
Roll glslang to 1ea8f595 (#215)
Rolling this now to fix some memory leaks.
2018-07-10 10:55:46 -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 a884cb2479 Fix CubeReflection transitioning inside a pass 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
Corentin Wallez 804fc749a0 Fix CubeReflection's orientation 2018-07-03 22:23:52 +02:00
Corentin Wallez 30f85cb484 Remove samples that were only used as temporary tests
However keep the following samples:
 - CHelloTriangle that demonstrates the C API
 - CppHelloTriangle that demonstrates the C++ API
 - Animometer that matches the WebGL benchmark
 - HelloDepthStencil that does more than just a triangle, renamed
   to CubeReflection
 - ComputeBoids as a cool graphics and compute interop demo
 - glTFViewer that shows slightly more advanced usage of NXT
2018-07-03 22:23:52 +02: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 40e72d79ca WireCmd: factor code to [de]serialize structs and methods
Methods, when their arguments are stored in a structure, are very
similar to structures (duh?) Take advantage of this to factor the
[de]serialization code between them and not just memcpy structures
around. This will allow structures to contain objects, and pointers to
other structures / array of objects etc.
2018-06-12 14:26:32 -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