102 Commits

Author SHA1 Message Date
Corentin Wallez
9d4b9ab313 OpenGL: move buffer to its own file 2017-07-17 13:48:17 -04:00
Kai Ninomiya
fec8c58a97 Add depth-stencil textures and attachments (#77)
Related: #29
2017-07-17 12:03:16 -04:00
Corentin Wallez
11ce310de3 D3D12: make texture transition barrier on all subresources
This doesn't fix anything in particular and is just a drive-by
change.
2017-07-13 15:41:43 -04:00
Corentin Wallez
de4a3c4c3b Fix framebuffer dimensions in InputStateTest
Also add validation that the framebuffer size matches its attachement
size and make a test for it.
2017-07-13 15:41:43 -04:00
Corentin Wallez
0b186b1fda Use feature detection macros everywhere 2017-07-13 14:55:23 -04:00
Corentin Wallez
275817a93a Add proper defines for backend enablement 2017-07-13 14:55:23 -04:00
Corentin Wallez
a7bfc9d2ac Metal: Fix Device::pendingCommands being freed under us 2017-07-13 14:55:23 -04:00
Austin Eng
77a29986b0 D3D12 Render Targets (#72)
Implements BeginRenderSubpass on the D3D12 backend. Descriptors for render target and depth stencil views are recorded in a descriptor heap for each framebuffer. For now, we still have the hack where no attachment renders to the backbuffer, so the CommandBuffer records those when necessary when it is submitted.

This PR also enables input states for D3D12 which are mostly working. One failure seems to be happening because our texture copies are not yet correct.
2017-07-12 17:36:36 -07:00
Kai Ninomiya
e66fcd8b0e OpenGL backend: implement render passes (#73)
Probably not the most efficient implementation, but works.

Issues:

* Doesn't seem to render until the second frame. No clue why, yet.
* Hardcoded 640x480 in more places.
* Creates new FBOs for every subpass every frame. Should be done at Framebuffer build or CommandBuffer build time.
2017-07-11 17:49:20 -07:00
Corentin Wallez
0f833f30ed Enable warnings on Windows 2017-07-11 13:59:15 -04:00
Corentin Wallez
83e779d8f2 Fix all Windows warnings 2017-07-11 13:59:15 -04:00
Corentin Wallez
8fca4a21b7 Use UNREACHABLE in more places 2017-07-11 13:59:15 -04:00
Corentin Wallez
96acaef95e Fix MSVC warnings on enum class switches 2017-07-11 13:59:15 -04:00
Corentin Wallez
fd589f3919 Add an internal ASSERT macro
This macro has some advantages over the standard library one:
 - It prints the place where the macro was triggered
 - It "references" the condition even in Release to avoid warnings
 - In release, if possible, it gives compiler hints

It is basically is stripped down version of the ASSERT macros I wrote
for the Daemon engine in src/common/Assert.h

This commit also removes the stray "backend" namespaces for common/
code.
2017-07-10 19:35:21 -04:00
Corentin Wallez
bd0594bab8 Enable warnings on non-MSVC 2017-07-10 19:35:21 -04:00
Corentin Wallez
228ba88fe6 Remove unused Device::CopyBindGroup 2017-07-10 19:35:21 -04:00
Corentin Wallez
98c90d4faa Fix clang/GCC warnings 2017-07-10 19:35:21 -04:00
Corentin Wallez
a52c23c553 Make one missed #include start from src/ 2017-07-10 19:35:21 -04:00
Corentin Wallez
98614a02d3 Fix EnsureTextureUsage not using usage 2017-07-10 19:35:21 -04:00
Kai Ninomiya
296951df60 Introduce Begin/EndComputePass (#70) 2017-07-10 14:07:24 -07:00
Austin Eng
afdcf7d828 D3D12: Wait for GPU on device destruction 2017-07-10 16:45:28 -04:00
Austin Eng
f9c39d021e Add device reference counting 2017-07-10 16:45:28 -04:00
Kai Ninomiya
563e9e253e Remove prints added in #67 and fix test broken in #64 (#69) 2017-07-10 10:23:27 -07:00
Kai Ninomiya
cb2d6d8553 Freeze texture transitions while attached; consolidate OutputAttachment usage (#67)
* lock usages for attachments during subpasses
* refactor IsTextureTransitionPossible
* change attachment usages to OutputAttachment
* make SetBindGroup validation lazier
2017-07-07 16:06:14 -07:00
Kai Ninomiya
794d4faece null backend: fix resource usage after cmdbuf transition (#63)
and test it.
2017-07-07 11:47:40 -07:00
Kai Ninomiya
fa37f2239c replace AdvanceSubpass with Begin/EndRenderSubpass
and replace subpassActive with VALIDATION_ASPECT_RENDER_SUBPASS
2017-07-07 11:19:42 -04:00
Corentin Wallez
fffe6dfa16 Split backend/common in backend/ and common/
This directory used to contain both the state tracking code for the
backends, and the common utilities that could be used both by the
backends and the rest of the code. Things are now:

 - src/common is utility code for the whole repo
 - src/backend contains libNXT's code
 - src/utils is utility code that we don't want in libNXT

This commit also changes all includes to use global paths from src/
bacause it had to touch a bunch of #include statements anyway.
2017-07-06 17:54:52 -04:00
Austin Eng
47261d4ecb Implement MapReadAsync on D3D12 backend
Buffers with MapRead allowed are created on the READBACK heap and always
add the D3D12_RESOURCE_STATE_COPY_DEST state (required by D3D12).
Likewise MapWrite adds the D3D12_RESOURCE_STATE_GENERIC_READ state and
places resources on the UPLOAD heap. Because these states are
required, transitions for mapped buffers do nothing.
2017-07-06 16:57:54 -04:00
Austin Eng
8fa550c015 Add D3D12 buffer/buffer buffer/texture and texture/buffer copies
Right now, this only works if textures are 256-byte aligned
2017-07-06 16:57:54 -04:00
Austin Eng
6774bce06e Remove unused Device member in D3D12 TextureView and BufferView 2017-07-06 16:57:54 -04:00
Austin Eng
beb76d06db Rename d3d12 Device tick functions to Tick 2017-07-06 16:57:54 -04:00
Austin Eng
6103c62489 Rename backend::d3d12::ResourceUploader::UploadToBuffer to BufferSubData 2017-07-06 16:57:54 -04:00
Corentin Wallez
5e03aec75a Remove some unused variables 2017-07-06 16:30:20 -04:00
Corentin Wallez
2dd73fbc1d Remove unnecessary Device forwarding. 2017-07-06 16:30:20 -04:00
Corentin Wallez
8308b1c1b3 Metal: Don't hardcode the texture usage or dimension 2017-07-06 11:34:31 -04:00
Corentin Wallez
c6f9006b02 Metal: Use RGBA instead of BGRA and clear render targets by default
This makes rendering of the samples have the wrong colors on the Metal
backend, but using BGRA made end2end tests fail. The rendering color
will be fixed when the WSI is introduced.
2017-07-06 11:34:31 -04:00
Corentin Wallez
8859178703 Add nxt::VertexFormat::FloatR32 2017-07-06 11:34:31 -04:00
Austin Eng
cd13691783 Update SPRIV-Cross for HLSL SM5.1 register name support 2017-07-04 14:30:34 -04:00
Austin Eng
036f76f51f D3D12: Refactor bind group descriptor tracking and descriptor heap allocation
Extract descriptor offset computation and CPU descriptor recording to
BindGroupLayout and BindGroup. Refactor descriptor heap allocation to
copy from a large CPU heap to a GPU heap.
2017-07-04 14:30:34 -04:00
Austin Eng
aecf0b130e Add D3D12 buffer, texture, and sampler binding 2017-07-04 14:30:34 -04:00
Austin Eng
29477375a6 fix bind group state tracking on pipeline switch 2017-07-04 14:30:34 -04:00
Corentin Wallez
e9d347e89e Add T->B copies.
This implements T->B copies on the Metal backend only and while it adds
validation tests, end2end tests will be done in a follow-up commit.
2017-06-27 13:25:42 -04:00
Corentin Wallez
b6d52b4ad1 Refactor copy validation to add helper functions useful for T->B too.
Also fixes validation not taking the mip-level into account when
checking if the copy would fit in the texture.
2017-06-27 13:25:42 -04:00
Corentin Wallez
4b4922cdce Allow empty B->T copies
This adds a test that empty copies are valid for B->B copies too. Tests
for B->T will come in a follow up commit.
2017-06-27 13:25:42 -04:00
Corentin Wallez
ef199c0310 Metal: Implement BufferMapRead 2017-06-22 09:56:30 -07:00
Corentin Wallez
6cb33ef24e Metal: Introduce a proper BufferUploader and PendingCommands
Previously the Metal backend used a manual mutex system to make sure the
BufferSetSubData didn't have data races with reads from the GPU. Replace
this with a non-hacky version
 - Make the Buffer objects allocated on the GPU
 - Make SetSubData use a ResourceUploader that allocates a CPU buffer
   and schedules a CPU->GPU copy.
 - Have a list of pending commands and a finished command serial to
   order operations and track when resource become unused.
2017-06-22 09:56:30 -07:00
Corentin Wallez
0ba5550874 Metal: split non-trivial objects in their own file.
No functional changes intended, but there are a couple additional
cleanups:
 - Use anonymous namespaces instead of static functions
 - Don't store an extra Device pointer in objects
2017-06-22 09:56:30 -07:00
Corentin Wallez
702186e169 Add restrictions on usages allowed with MapRead/Write 2017-06-22 09:56:30 -07:00
Corentin Wallez
76707f9ac9 SerialQueue: add const version of the iterators.
Unfortunately you can't template on const-ness in C++ so we have to
duplicate all the iterator code for SerialQueue (that, or introduce very
heavy templating).
2017-06-22 09:56:30 -07:00
Corentin Wallez
e64dec7a3d Move Serial declaration to Forward.h
This is a bit ugly but avoids having to include all of SerialQueue.h
just to get this typedef.
2017-06-22 09:56:30 -07:00