Commit Graph
128 Commits
Author SHA1 Message Date
baldurk 4612d71df5 Switch some maps to unordered in resource manager 2022-10-26 13:08:17 +01:00
baldurk a8f0fb1736 Stop forcing references for resourced invalidated by freed bound memory 2022-08-07 18:56:11 +01:00
baldurk fcdea67879 Update copyright years to 2022 2022-02-17 17:38:32 +00:00
baldurk 8245b99b56 Avoid some redundant checks in GetLiveResource
* Historically we always expected a live resource, but with descriptors that can
  be stale we can have a lot of queries where it's fine to just get NULL back if
  the resource doesn't exist.
2021-10-19 18:12:19 +01:00
baldurk 25b17c8093 Add R/W locking around access to crash handler. Closes #2376
* The crash handler gets destroyed and recreated when we need to change creation
  parameters, and this races against anything else trying to use it to register
  or unregister memory regions.
* In partcular when initialising the replay we recreated the crash handler right
  after kicking off the GPU enumeration.
* We add a read/write lock so there's no significant added contention on most
  paths (even though it's not really high traffic in any case) to prevent this
  kind of problem in future.
2021-09-29 10:54:29 +01:00
baldurk cf78735861 GetLiveID should respect replacements. Closes #2300
* This ensures we use the up to date edited pipeline for e.g. pipeline-based
  shader disassembly.
2021-06-28 13:10:11 +01:00
baldurk aeaf26930c Implement reserved (sparse) resources on D3D12. Closes #2203 2021-03-12 18:08:23 +00:00
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
baldurk f5f9e78dde Completely remove idle background tracking of descriptors on vulkan
* In principle descriptors should be updated less often than they are
  referenced, so we used to cache tracking of them at update time to improve the
  speed that references can be processed at submit time during capture.
* Some applications though update a *lot* of descriptors *very* often,
  effectively writing all their descriptors for a frame every frame. That means
  that this background tracking is wasteful and has a big performance impact, so
  instead it's a better balance to do more work at submit time during capture.
2021-01-05 18:26:27 +00:00
baldurk 632e9302b6 Cache whether chunks are from an allocator
* If chunks come from an allocator they can't be safely deleted because the
  allocator may have been reset and recorded over where these chunks were with
  other data. Fortunately we don't need to do anything to delete them, so
  storing the allocator status up front is sufficient.
2020-10-20 16:12:45 +01:00
baldurk 78f1f8f3d1 Remove volatile from Atomic parameter declarations
* This was leaky from windows' InterlockedIncrement etc declarations, and is not
  necessary.
2020-09-09 16:40:04 +01:00
baldurk afe3bee92d Only lock in resource manager while capturing
* On replay currently we only have single-threaded access so the lock is just
  overhead
2020-09-03 18:08:39 +01:00
baldurk 54286833bf Switch some maps to unordered_map where we only use them for lookups 2020-09-03 18:08:35 +01:00
baldurk 51b228b042 Disable resource record chunk locking for command buffers
* The API user is supposed to lock this for us, so don't waste time locking
  ourselves.
2020-08-26 19:27:42 +01:00
baldurk 1b844d1498 Add resettable chunk allocator for recording command buffers 2020-08-26 19:27:41 +01:00
baldurk 73cc1f5476 Add specialised rdcarray which implements key/value lookup 2020-08-19 15:21:00 +01:00
baldurk 78e2475dad Use a read/write lock for resource record access in resource manager 2020-08-19 14:24:51 +01:00
baldurk 88c6dc27e4 Use plain array instead of set for resource record parents array 2020-08-19 14:24:51 +01:00
baldurk b0d3fb12a9 Don't perform queue submit until after flushing maps/references
* While active capturing we might do significant work to flush coherent mapped
  memory regions and prepare initial contents for postponed resources that are
  about to be write-referenced. We need to do that before submitting the actual
  work to the queue or else the contents may be corrupted.
2020-08-12 15:15:33 +01:00
baldurk efd2c03430 Items in initial contents list don't need to be added as written records
* Resources which aren't referenced in the frame don't need initial states
  unless we have 'Ref All Resources' enabled. These initial states can be
  stripped on replay as they aren't needed.
* We also renamed the WrittenRecords to more explicitly list that this is the
  list of resources needing initial contents, whether because they were dirty
  (and so had initial contents) or because they were written mid-frame and so
  need to be reset.
2020-08-07 12:21:05 +01:00
baldurk 9f2de54521 Better reserve of written records size 2020-08-04 17:52:10 +01:00
baldurk 2d47466297 Combine last write time and last partial use maps into array
* We only care about tracking two things:
  1. Resources that have been written very recently. These should not be
     postponed as there's a high chance they'll be written mid-frame and so we'd
     need their initial contents.
  2. Resources that have their last non-complete-write reference was a while ago
  However in the second case we can acceptably ignore any resources that haven't
  been written recently either, since if the resource hasn't been written and
  also hasn't been complete-written then it hasn't been used at all.
* So when updating the non-complete-write time we only do this if the resource
  has had a write reference, and intermittently we remove any resources that
  haven't had a write at all.
* Postponed resources will be exactly the same set, because we treat a resource
  as postponable if we have no write time for it at all so it's fine to remove
  old resources from the list. Fewer resources will be skipped, as we now treat
  resources that have no known age as non-skippable. However in the majority of
  these cases we expect either for the resource to not be used at all (thus the
  postpone will never be forced to prepare and we won't serialise anything), or
  else if it is used the chances are high it will be used read-only so the
  postpone will still be enough.
2020-08-03 18:30:20 +01:00
baldurk 035073fac9 When updating descriptor bind refs, cache resource references
* This means we don't have to iterate the whole bindrefs array every time we
  want to propagate references in the background, but we can submit them in
  batch.
2020-08-03 18:30:20 +01:00
baldurk 0b061f4565 Stop tracking dirty state at fine-grained detail on vulkan
* Almost all dirty-able resources (memory and images) become dirty almost
  immediately, so spending time tracking dirty state is wasted. Instead we treat
  these resources as dirty at creation and rely on the postponing logic to avoid
  preparing initial states for newly created resources that are not used in the
  frame.
* This may cause more 'last-minute' postponed prepares for newly created
  resources, which would previously.
2020-08-03 18:30:20 +01:00
thisisjimmyfb 58a6d7eb76 skip initial states for cleared renderpass
also refactored the postpone logic
2020-06-15 15:43:52 +01:00
Rémi Palandri 1dd7aa9296 vulkan low-memory-mode 2020-05-27 22:37:51 +01:00
baldurk ecd8dd0ade Don't report replaced IDs in pipeline state
* If we return back (accurate) replaced IDs in current pipeline state, the UI
  won't recognise them since the list of resources is cached and fixed at load
  time.
* The replaced ID is still present in the shader reflection info as we return
  the replaced shader's reflection and not the original's.
* We also change how we replace a programshader (glCreateShaderProgramv) on GL.
  Instead of creating a program and a shader - resulting in two objects
  replacing one - we instead replace the shader that got built with a program.
  We can do this safely since we know the shader won't be used as an actual real
  shader (since it was a program in the original capture too).
2020-04-03 15:19:28 +01:00
baldurk 187bd57501 Use 64-bit integer for chunk ID
* Using a 32-bit integer, signed, gives only 2 billion chunks before it wraps.
  With Vulkan/D3D12 creating new chunks even while in the background for
  recording commands this is feasible to hit.
2020-03-19 17:16:20 +00:00
Benson Joeris 96bbeea4a5 Add ImageState
`ImageState` tracks the state of images and their subresources.
This functionality was previously split between the `ImageLayouts` and
`ImgRefs` classes.

Change-Id: I3242417dacf73fe07765f9bcfd449599e373e10d
2020-01-27 20:44:54 +00:00
Benson Joeris 35a15cf8d1 Add Unknown FrameRefType
This represents a (sub)resource for which no usage info is available.
It should be conservatively assumed that such a resource needs to be
re-initialized before each replay (and this behaviour is reflected in
`InitReq()`).

Change-Id: I12235a6cb1c4b2e3e21bed8834653ec6a3aea009
2020-01-27 20:44:54 +00:00
baldurk 2916c0f9f7 Update copyright years to 2020 2020-01-06 16:20:45 +00:00
baldurk bd9f4fc389 Remove use of vector/string from core project
* This also affects the drivers via interfaces e.g. IReplayDriver and some
  utility functions.
2019-12-16 18:10:31 +00:00
baldurk c4ca8cb1d1 Reduce reliance on big public headers where possible
* Mostly moving includes from common headers to cpp where possible, and removing
  includes of the whole thing where only enums or rdcstr etc are needed.
2019-12-16 17:06:16 +00:00
baldurk 6d1d302491 Fix a number of warnings identified by higher clang warning levels
* We enable a couple of high signal-to-noise warnings in all clang builds
2019-12-02 20:41:28 +00:00
baldurk ba8186559d Don't allow resource records to become their own parents 2019-11-19 23:20:55 +00:00
baldurk 5c01ab3ea9 For resources written in the frame, mark dirty at the end
* If the write was recorded only to the frame, our background tracking may no
  longer be up to date so if the resource isn't dirty already it should be
  marked dirty so that we fetch its state properly on any subsequent captures.
  This is most relevant for GL where many objects have mutable state which may
  only be recorded mid-frame.
2019-08-09 11:49:28 +01:00
Dmitry Soshnikov 3cc9557264 Introduce Low-Memory mode 2019-07-24 22:45:41 +01:00
Benson Joeris 5120622dac Added InitPolicy
This allows finer control of the initialization/reset behaviour of
resources based on their ref type.

Currently, these policies only apply to the initialization/reseting of
VkDeviceMemory and VkImage resources.

Change-Id: Ib647cbaf99b650e8da40d07944400ace7dde504d
2019-07-09 16:15:56 +01:00
Benson Joeris 40c56dafa3 Add WriteBeforeRead to FrameRefType.
`WriteBeforeRead` is used to signify that a resource is partially
written, and then later read. For the purpose of correct replay,
`WriteBeforeRead` can be treated as `Read`--the resource needs to be
initialized once (so that the non-overwritten data is correct), but does
not need to be reset for later replays (since performing the same write
again will not change the data).

However, it is useful to track this state separately from `Read`,
because the user may inspect the resource at a point in time before the
write, and it might be confusing to see the result of the future write
(which would be visible if `WriteBeforeRead` was treated as `Read`).

Change-Id: I7df58bacb4444f7e8d7e26a5532a55b0ff8f128d
2019-07-09 16:15:56 +01:00
Benson Joeris 30b02bc1dd Refactor ComposeFrameRefsUnordered
Change-Id: I4d80b626c3c37a4c576024b3f8c2145dcb3bf108
2019-07-09 16:15:56 +01:00
Benson Joeris 7edd6c0ab5 Add ComposeFrameRefsDisjoint
Previously, the ref type of the a VkDeviceMemory or VkImage resource
was calculated as the max of the ref types of the subresources. This
reliance on the ordering of the `FrameRefType` enum values is fragile--
in particular, this makes it more difficult to add new `FrameRefType`
alternatives.

Now, the ref type of composite resources are calculated using
`ComposeFrameRefsDisjoint` instead of `max`.

Change-Id: Id5db68b6756555cdc6b068d28f1b72cb827f3d1e
2019-07-09 16:15:56 +01:00
baldurk e48065c96b Replace use of std::pair with rdcpair wherever possible
* Only remaining uses in our code is when we're interacting with std::map where
  it uses std::pair internally
2019-05-17 16:32:56 +01:00
baldurk 462772af91 Remove 'using std::set' 2019-05-17 16:32:56 +01:00
baldurk fb333ebc9b Remove 'using std::map'
* This will make it easier to replace std::map in future
2019-05-15 14:12:17 +01:00
baldurk 95e63cb965 Remove pending-dirty operations, mark resources dirty immediately
* Now that the dirty list is only read once at the start of the frame we can
  mark resources dirty mid-frame freely and don't have to defer that. The
  internal resource manager locking prevents us from adding to the list while it
  is being modified.
2019-05-15 14:12:17 +01:00
baldurk 0ae245c4a8 Refactor initial state callbacks to always allow deleted resources
* Instead of passing the resource handle itself to GetSize_InitialState or
  Serialise_InitialState, we pass the Id, ResourceRecord, and prepared initial
  contents. All of these can survive past the destruction of the resource.
* Removes the need for AllowDeletedResource_InitialState() - it's always allowed
  now.
* Need_InitialStateChunk is also refactored but it's only used on D3D11
  currently and potentially will be removed in future.
2019-05-14 17:13:22 +01:00
baldurk 0fd6b0c546 Remove forced initial states for resources
* This was used for two things:
  - UAVs on D3D11, which we can just mark dirty at creation as we do
   with things on D3D12/Vulkan where we know we'll always want initial
   states.
  - Texture views/Texture buffers on GL, where we check if the texture
   was referenced and force initial states for the underlying data
   store. This requires a bit more work but can still be achieved by a
   GL-specific force-inclusion pass on the frame references.
2019-05-14 15:30:55 +01:00
baldurk ada97bf7bd Only reference dirty resource list at capture begin time. Closes #1309
* The problem with trying to keep the list of dirty resources identical at the
  start and the end of the capture is that resources being deleted or dirtied
  mid-frame causes problems. For the latter we have 'pending dirty' ugliness,
  for the former we weren't properly handling it in all cases. Instead just
  prepare initial contents from dirty resources, then use the list of resources
  that had initial contents prepared to determine which should be saved.
* This means resources freed mid frame are fine, as long as we hold onto their
  resource records and initial contents which we do. It also means the pending
  dirty handling can be removed and we can just dirty resources as soon as we
  want - it will be ignored mid-frame and apply to subsequent frames.
2019-05-14 15:30:55 +01:00
Alex Vakulenko ca2307e34c Make it possible to write chunks larger than 4 GB
Added a special chunk flag indicating that chunk size is a 64 bit value.
This allows to handle larger chunks (which heppens quite rarely) while
still maintaining backward compatibility with the majority of traces.

Bumped RDC file version of 0x101 (1.1) to make sure older version cannot
read the new file format.
2019-05-10 10:25:26 -07:00
Benson Joeris 5e49b076b5 Add serialization for FrameRefType 2019-02-18 17:33:59 +00:00