Commit Graph
138 Commits
Author SHA1 Message Date
baldurk fb826ee724 Fix the set of queues made available to initial state CONCURRENT buffers
* We don't want to enable all queues on the physical device because not all of
  them are necessarily enabled in the device itself.
2019-04-04 13:11:18 +01:00
Benson JoerisandBaldur Karlsson cc8aa679e9 Optimize Apply_InitialState for VkDeviceMemory resources
This change reduces the amount of data copied into VkDeviceMemory resources in
`Apply_InitialState`; this uses the new (interval-based) reference tracking.

On a large capture from a recent game, this change reduces the amount of copied
data from 2.2GB to 720MB (plus 100MB cleared to 0). This reduces the time spent
in `ApplyInitialContents` from 1800ms to 1500ms.

Ranges of memory are initialized/reset by either clearing to 0, or copying in
the initial state data, according to the `FrameRefType`, as follows:
- Read-only (`eFrameRef_Read`) regions of memory are initialized by copying
  once, before the first replay.
- Read-before-write (`eFrameRef_ReadBeforeWrite`) regions of memory are reset by
  copying before each replay.
- Write-only (`eFrameRef_PartialWrite` and `eFrameRef_CompleteWrite`) regions of
  memory are cleared to 0 before each replay. This is intended to avoid possible
  user confusion when inspecting these regions of memory, as they might
  otherwise show data written later in the frame.
- Unused (`eFrameRef_None`) regions of memory are cleared to 0 once, before the
  first replay.
2019-03-02 08:24:12 +00:00
baldurk 8ae9ccdd7f Check descriptor writes for validity before updating in PostVS fetch
* This can happen for push descriptors that are declared but never used.
2019-02-25 15:31:43 +00:00
baldurk 86ff87863e Update copyright years to 2019 2019-02-01 18:32:13 +00:00
baldurk db2ef74d13 Fix initial state crashes for images in external queues. Closes #1226 2019-01-08 17:24:15 +00:00
baldurk e3b50d2377 If an image is in an external or foreign queue we can't fetch contents
* There's nothing we can do - we can't safely transition from/to the external
  queue so we have to treat the initial contents as missing/undefined.
2019-01-03 17:56:53 +00:00
baldurk 64fc592341 Fix index used to look up writes when applying initial state descriptors 2018-12-21 12:38:28 +00:00
baldurk 68c5ffe5ee Don't apply quick check-and-skip for array descriptor slots
* Just because the first element in the array isn't valid doesn't mean there
  aren't elements later that are valid which we should update.
2018-12-21 12:38:28 +00:00
baldurk 4c7ed0cb3c Copy each plane aspect of multi-planar images separately on vulkan 2018-12-14 15:40:09 +00:00
baldurk 0253dbcc70 During capture report worst-case mem requirements for external images
* On some implementations, external images have lower memory requirements than
  an identical non-external image. To account for the replay being non-external
  we create both and pick the worst when reporting memory requirements to the
  app, so that it allocates enough for us on replay.
2018-11-16 15:13:36 +00:00
baldurk c0007374d2 Don't declare CONCURRENT buffer for 1 queue family. Closes #1135 2018-10-24 11:08:26 +01:00
baldurk 878c0c9ff1 Use immutable samplers when checking for validity
* Fortunately the sampler element in the write is ignored when doing the actual
  update so it's safe to write these in before the validity check.
2018-09-03 14:12:20 +01:00
Gary SweetandBaldur Karlsson 4ab781ec8c Add more missing Vulkan cache flushes
Missed these the first time around
2018-08-29 11:59:15 +02:00
baldurk add4b44283 Fix some cases missing multiqueue handling 2018-06-13 16:15:52 +01:00
baldurk ea3e2c8610 Add multiqueue support for Vulkan. Closes #373 2018-06-13 09:17:03 +01:00
baldurk 0cc5ed6145 Handle dstArrayElement when updating current bindings from initial state 2018-05-13 10:13:49 +01:00
baldurk 42aefbaf0e Fix off-by-one error with gathering array descriptor writes 2018-05-13 10:13:49 +01:00
baldurk dc8d4f63d5 Don't discard array descriptor update because some elements are invalid
* When checking for validity, some array elements might be valid while
  others might not be. This is still OK if the application knew that
  only certain elements would be accessed by the given shaders - so we
  should still update the others.
2018-05-12 12:57:40 +01:00
baldurk 94548886eb Implement VK_KHR_push_descriptor extension. Closes #905 2018-04-24 14:41:57 +01:00
baldurk ada2222d8f Don't allocate wholeMemBuf buffer for memory that doesn't allow buffers
* Some memory types may not be compatible with buffers, so allocations
  in those memory type indices we just don't create a spanning buffer,
  as it won't be needed anyway to restore memory contents.
2018-04-03 17:10:21 +01:00
baldurk 919c0f11dd Override type for structured data when directly serialising a ResourceId 2018-02-15 10:57:31 +00:00
baldurk 1ee01e1f82 Apply a normalisation pass over the serialised data
* This is a backwards-incompatible change, so it's done here before v1.0
  so that we can freely break compatibility and not need to define a lot
  of ugly compatibility code.
* The primary motivation is to make the serialised data more uniform
  and have fewer special cases where the serialised form is naturally
  defined from the functions/structs in question.
* There are still some special cases or variances but they should be
  more isolated and only where really necessary.
* Remove some cases in the D3D12 struct serialising where we were
  directly serialising child struct members in the parent struct.
* We now try to match argument/struct member order as closely as
  possible.
* Serialising an array with a count no longer reads the count back out
  into that variable, counts must be serialised separately. This means
  all members/arguments are explicitly present in the structured data
  and also eliminates the awkward case where a count needed to be
  serialised separately after an array if we want to have the count be
  a valid number even if the array could be NULL. It also means we don't
  need the FIXED_COUNT() macro since array lengths can be plain values
  and don't have to be a reference type.
2018-02-14 15:57:53 +00:00
baldurk b17790e5c2 Batch vulkan initial state related allocations together
* We allocate chunks of 32MB - 256MB then suballocate as needed.
2018-01-25 18:18:47 +00:00
baldurk d452230782 Refactor resource manager initial content data to be driver-specific
* This allows more flexible construction of what params/resources need
  to be saved with initial contents data, as well as allowing better
  type safety where possible by using driver-specific types for the
  stored data.
* Especially it tidies up the ugly 'all data that tags along must be
  a written into a single allocated byte pointer'.
* The initial content struct is responsible for destroying itself and
  freeing any data.
2018-01-25 15:30:20 +00:00
baldurk e305029ddd Update copyright years to 2018 2018-01-01 17:55:29 +00:00
baldurk 58ac0ccfb2 Compile fix for checking vulkan handle directly as bool 2017-11-24 18:25:43 +00:00
baldurk 1b0fafc872 Fail out of chunk serialisation if API calls fail
* For a few primary cases, we check to see if the API call failed (or is
  looking like it will fail, in the case of vulkan) and bail out. This
  will cause the capture to fail to load.
2017-11-24 18:14:22 +00:00
baldurk 1a879a261b Check for serialisation success in chunk serialise functions
* In each function, we check that serialisation succeeded before going
  on to actually call into the API. If something went wrong, then we
  bail out and fail to load the capture.
2017-11-24 18:14:22 +00:00
baldurk 3ac3e6c3f1 Fill out resource descriptions in each driver
* For Vulkan and D3D12, we now create a dummy command buffer to ensure
  that there's actually a chunk available to correspond to the command
  buffer that gets submitted or recorded to.
2017-11-17 16:30:50 +00:00
baldurk 7ca6c80414 Add ability to convert a capture to structured data without replaying 2017-11-08 18:24:22 +00:00
baldurk fd680f4a8b Convert vulkan initial state handling to new serialisation system 2017-11-08 18:24:12 +00:00
baldurk 9ef0c5282c Make aligned buffer allocation a common function, out of serialiser 2017-11-03 16:15:19 +00:00
baldurk 501b1a846c Don't do full-image transitions per subresource, just do it once 2017-09-07 10:41:23 +01:00
baldurk 8994bc0fb8 Store resource type with initial contents data 2017-08-31 10:48:16 +01:00
baldurk dd856a1f1f Remove unused VkBufferCreateInfo structures. Refs #688
* These structs were no longer used since the memory wholeMemBuf was
  added, and they had some confusing enum usage that triggered static
  analysis warnings.
2017-07-11 20:03:03 +01:00
baldurk 6d89d451cd Switch orders of depth and stencil copies when restoring D/S 'MS' arrays
* This was previously needed to be stencil-before-depth to workaround an
  nvidia driver bug, but now depth-before-stencil works around a RADV
  hang and it no longer seems to be necessary for nvidia.
* The RADV issue is being fixed upstream but this is a 'free' workaround
  until that arrives.
2017-06-26 10:53:42 +01:00
baldurk baea067fd9 Check for created initial contents before handling MSAA. Refs #579
* In edge cases, MSAA textures can have no true initial contents and
  will need to be cleared.
2017-04-20 10:49:07 +01:00
baldurk 9278af463a Check for sparse buffer memory requirements when unbinding. Refs #580
* If a buffer is small, its memory requirements might be aligned up to
  a larger value for sparse binding.
2017-04-17 12:12:18 +01:00
baldurk 729706e7f1 memcpy into the right structure, avoids trashing data. 2017-04-08 16:12:48 +01:00
baldurk 030cbfde9a Batch update copyright years everywhere 2017-01-06 12:13:31 +00:00
baldurk a4ebf68e9d Fix format string - IDs are 64-bit 2017-01-04 16:54:54 +00:00
baldurk 7baf53c89b Do stencil copies before depth copies, to *actually* do workaround 2016-11-08 14:11:33 +01:00
baldurk 2b2eb1b96b Workaround failed depth copies on nvidia 2016-11-08 13:38:18 +01:00
baldurk 2ef5b469ea Fix VS2015 variable shadowing warnings 2016-11-07 20:14:37 +01:00
baldurk 8d0915401f Unify feature macro handling 2016-11-07 18:14:49 +01:00
baldurk 65e05a3196 Add support for serialising multisampled images in vulkan. Refs #193
* This also applies to stencil even in non-multisampled images.
* Serialisation applies to both network proxying data, initial frame
  contents at the beginning of a captured frame, and saving images to
  disk.
2016-11-07 18:14:45 +01:00
baldurk 7ab314d1a6 Add explicit casts int -> uint32_t for array/mip 2016-07-15 14:45:25 +02:00
baldurk f00a0a8a5e Keep image initial states as buffers in CPU memory, copy from there
* This is potentially slightly less optimal as it means the initial
  states aren't in GPU memory for a faster copy, but it means we're much
  less likely to hit OOM due to way more GPU allocs, and it's still
  pretty fast.
* Further optimisation is possible by reducing the number of images that
  actually either need initial states at all (detect when images are
  first used to clear via a renderpass), or by detecting images that are
  frame invariant and we only have initial states for immutable contents
  and avoid copying them more than once.
2016-07-15 13:26:42 +02:00
baldurk a7dc5f207f Size readback buffer for initial states based on what we need
* No need to base readback buffer on image memory requirements which
  could be packed tighter than our requirements for readback (e.g. depth
  and stencil combined formats)
2016-07-13 16:49:10 +02:00
baldurk ee63587813 Rename IsDepthStencilFormat to IsDepthOrStencilFormat 2016-07-13 15:53:01 +02:00