Commit Graph

9165 Commits

Author SHA1 Message Date
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 862f884a65 SampleUtils: Look at argv starting from 1 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
Corentin Wallez b1341db700 Add a NXT_NO_DISCARD that is C++17 [[nodiscard]] where available 2018-05-31 15:00:28 -04:00
Corentin Wallez b711b9b2c9 Add a GetDefaultSamplerDescriptor helper. 2018-05-23 14:03:51 -04:00
Corentin Wallez 5101d57972 WireTests: Add a test for sending structs of non-object values 2018-05-23 14:03:51 -04:00
Corentin Wallez 99c6fa2f55 WireTests: introduce a MatchesLambda GMock helper 2018-05-23 14:03:51 -04:00
Corentin Wallez 1ae19e8276 Change Sampler creation to use a descriptor instead of a builder 2018-05-23 14:03:51 -04:00
Corentin Wallez a6416543a4 generator: Add support for structure of non-object values 2018-05-23 14:03:51 -04:00
Corentin Wallez 2ee315ca64 Make WireTests not rely on SamplerBuilder
The sampler builder will be removed as the first builder being converted
to a descriptor. Use CommandBufferBuilder instead as it is not expected
to change soon.
2018-05-23 14:03:51 -04:00
Corentin Wallez e8c8f020fb Factor autogen validation utilities out of ProcTable 2018-05-23 14:03:51 -04:00
Corentin Wallez 7d95c40163 Factor CMakeLists backend ProcTable generation 2018-05-23 14:03:51 -04:00
Corentin Wallez 8d6b5d2337 Rename RenderPassInfo to RenderPassDescriptor 2018-05-16 11:18:14 -04:00
Corentin Wallez 6f7749cce9 Change render passes from multi to single pass.
This as an API change to get closer to the direction in which WebGPU is
headed. The API change in next.json caused a ton of files to be changed
in the same commit to keep things compiling.

API: the Framebuffer and RenderPass objects are now merged in a single
RenderPassInfo that contains the attachments, loadOps and clear values
for a BeginRenderPass command. The concept of subpass is removed.
The RenderPass creation argument to RenderPipelines is replaced by
explicitly setting the format of attachments for RenderPipeline.

Validation: SetPipeline checks are changed to check that the attachments
info set on a RenderPipeline matches the attachments of the render pass.

Backends: Most changes are simplifications of the backends that no
longer require and indirection to query the current subpass out of the
render pass in BeginSubpass, and don't need to get the attachment info
from a RenderPass when creating RenderPipelines. In the Vulkan backend,
a VkRenderPass cache is added to reuse VkRenderPasses between
RenderPassInfos and RenderPipelines.

Tests and examples: they are updated with the simplified API. Tests
specific to the Framebuffer and RenderPass objects were removed and
validation tests for RenderPassInfo were added.

Tested by running CppHelloTriangle on all backends, end2end tests on all
platforms and all examples on the GL backend.
2018-05-16 11:18:14 -04:00
Corentin Wallez 87ec361cc2 Use the binding mask for BGL hashing and comparison 2018-05-16 11:18:14 -04:00
Stephen White f77e3cc648 Don't release things which will be autoreleased. 2018-05-09 11:37:09 -04:00
Corentin Wallez ae27c7a4bc Move HashCombine to HashUtils and make it work better on 64bits
HashCombine will be used in more than just BindGroupLayout caching so we
extract it to a separate header. Add a better mixing constant for 64bit
systems.
2018-05-08 16:51:06 -04:00
Corentin Wallez 60ffbfc071 Add word size detection to Platform.h 2018-05-08 16:51:06 -04:00
Stephen White 8f2050540d Fix a memory leak in metal ShaderModule.
Make the MetalFunctionData object returned by GetFunction() own a
reference to the MTLFunction and release it on destruction.
2018-04-28 00:06:20 -04:00
Stephen White 1ec5782bff Fix travis lint script (again).
Don't error out if there are no files to format.
2018-04-28 00:03:53 -04:00
Stephen White c71cbf7721 Fix leak in Metal's Device::GetPendingCommandBuffer().
GetPendingCommandBuffer() doesn't need to retain the metal
command buffer; it's created with a ref.
2018-04-28 00:03:53 -04:00
Stephen White cce393e0d4 Fix some more memory leaks in the Metal backend. 2018-04-27 11:37:45 -04:00
Stephen White 22b862e052 Fix some leaking builder objects in common backend.
Delete the TextureBuilder created in SwapChainBase::GetNextTexture().
Delete the InputStateBuilder and DepthStencilStateBuilder created in
RenderPipelineBuilder::GetResultImpl().
2018-04-26 13:50:14 -04:00
Corentin Wallez 18ae692a21 Remove in-pass transitions in HelloCompute
This isn't validated out yet.
2018-04-19 13:22:56 -04:00
Corentin Wallez 46d5441557 Vulkan: Implement compute CommandBuffer operations 2018-04-19 13:22:56 -04:00
Corentin Wallez 186a5cba87 CommandBufferVk: Lazily set bindgroups in preparation for compute
Also fix PipelineLayoutBase::InheritedGroupsMask
2018-04-19 13:22:56 -04:00
Corentin Wallez 20aa6b9759 Vulkan: Implement ComputePipeline 2018-04-19 13:22:56 -04:00
Corentin Wallez 857a1cdb0e Enable IndexFormatTests on D3D12 2018-04-18 15:31:24 -04:00
Corentin Wallez 5ec9683800 Vulkan: Implement textures in bindgroups
Also enable the sampler tests on the Vulkan backend
2018-04-18 15:31:24 -04:00
Corentin Wallez e44b900861 Vulkan: Implement samplers 2018-04-18 15:31:24 -04:00
Corentin Wallez 32cb6fbca0 RenderPassVk: Set the correct number of color attachments 2018-04-17 18:10:57 -04:00
Corentin Wallez 4977fa66a3 VulkanDevice: Request indenpendentBlend.
This is a core NXT feature but wasn't enabled, causing the Vulkan
validation layers to produce an error.
2018-04-17 18:10:57 -04:00
Corentin Wallez bfeb285dcf Fix BindGroupLayout leak in PipelineLayout default.
PipelineLayout was re-entering in NXT to create the default empty BGLs,
but forgot to remove the initial external refcount for them.

Fixing this showed an issue where it was impossible to externally
reference a RefCounted that had only internal references, fix this as
well and add a test.
2018-04-17 18:10:57 -04:00
Corentin Wallez df5a18d883 Fix BindGroupLayout caused by caching.
When a BGL was first created in the cache, it started with an external
refcount of 1 and we then referenced again in
BindGroupLayoutBuilder::GetResultImpl, causing a leak.

Fix this by referencing in the cache lookup only if the BGL already
exists.
2018-04-17 18:10:57 -04:00
Stephen White 51f9987298 Update CommandBufferGL.cpp 2018-04-16 15:31:02 -04:00
Corentin Wallez 9ce29d1104 Fixup comment 2018-04-16 15:31:02 -04:00
Stephen White ac49ed0779 Use a memcpy to avoid strict-aliasing warnings. 2018-04-16 15:31:02 -04:00
Stephen White 6d90e01858 Expand allowable formats for color attachments.
Don't assert on color formats which can be cleared with a
floating-point clear value.
So far, these are { unorm } x { r, rg, rgba, bgra }.
Fix linter error when no files to check.
2018-04-13 11:53:12 -04:00
Stephen White d0771f8dd5 Metal backend: do a Tick() on queue submit. 2018-04-12 13:14:19 -04:00
Stephen White 8c231b6990 Fix a DrawElements bug in the Metal backend.
The indexOffset of the draw was not being used. It must be
included in the indexBufferOffset.
Renamed indexBufferOffset -> indexBufferBaseOffset.
Add a DrawElements test which exercises zero and non-zero index offsets.
2018-04-12 10:32:33 -04:00
Stephen White a5aacc9cad Fix color write mask on GL backend.
Set the color mask even if blending is disabled.
2018-04-10 14:37:06 -04:00
Stephen White 10a659ad91 Implement support for all Int32 vertex formats. (#179) 2018-04-10 14:35:17 -04:00
Stephen White e5ae3274a3 Make SetSubData take size in uint8_t not uint32_t.
Also change data pointer to uint8_t*.
Add a test for a non-aligned SetSubData().
Implemented on all backends.
2018-04-10 14:34:24 -04:00
Stephen White ee66f25c4f Add support for R16G16B16A16 ushort.
Also implement both new formats in Vulkan.
2018-04-10 11:37:35 -04:00