* This is required for the new heap-indexing bindless because we don't even have
ranges to mark referenced, but for other cases ref-all resources tends to be
more efficient especially when we're going to get to the same place (including
all resources) via a less efficient mechanism.
* Most remote replay links are slow enough that the lag introduced by
synchronously fetching and displaying these thumbnails would be annoying for
simple mouse-over scenarios.
These operations now run on the main thread and not on the Replay thread
* Updating the NSOpenGLContext
* Setting the view property on the NSOpenGLContext
* Getting the window size from the NSView
The specific methods that are run on the main thread are:
* NSOpenGLContext setView
* NSOpenGLContext update
* NSView frame
* NSView convertSizeToBacking
* NSView setWantsBestResolutionOpenGLSurface
These methods are asynchronously dispatched to the main thread using the Apple NSApplication main thread dispatch queue i.e.
dispatch_async(dispatch_get_main_queue(), <method>);
The threading synchronization intent is:
* the Replay does not block waiting for a deferred main thread API to complete
* mutex locks are used to protect containers shared between the main and Replay threads
* the main thread uses a TryLock approach when wanting to acquire the context lock. If the context lock is held by the Replay thread then the main thread reschedules the requested context operation i.e.
if (TryToGetContectLock(context))
{
[context update];
}
else
{
scheduleContextUpdate(context);
}
* When scheduling requests to the main thread the NSOpenGLContext and NSView objects are referred to by an index into an array and not by pointer value.
There are two debugging modes which are disabled by default
* RD_THREAD_RANDOM_SLEEP
* RD_USE_CONTEXT_LOCK_COUNTS
Enabling RD_THREAD_RANDOM_SLEEP performs sleeps of random times on both the Replay and main thread when calling the different context and view methods.
RD_THREAD_RANDOM_SLEEP is useful to expose race conditions.
Enabling RD_USE_CONTEXT_LOCK_COUNTS tracks the lock count on the context objects in the "s_ContextLocksCount" container.
The low-level context locking is handled in NSGL_makeCurrentContext which is called from CGLPlatform::MakeContextCurrent which in turn is called from GLReplay::MakeCurrentReplayContext.
The currently locked context is tracked in TLS storage and the currently locked context is unlocked before locking the new context and then setting the current context TLS value.
* If there would be no tooltip otherwise, it just shows the thumbnail. Otherwise
any tooltip text (like view parameters or image layout) is displayed below the
thumbnail
* On capture we have a fast temporary thread-local memory allocator that only
supports one allocation at a time, which is sufficient for unwrapping the
parameters to a single function call.
* On replay though we might want to unwrap a function's parameters, and then
inside do things like e.g. call a drawcall callback which makes its own calls
that need to be unwrapped.
* To support these nested calls we instead allocate 4MB per thread on replay and
use it like a ring buffer.
- Get framebuffer attachments from pipeline state (should account for
imageless framebuffers)
- If there is no depth attachment, then depth bounds test and depth test
do not modify coverage information
* This is a bit coarse, as e.g. if you have one window that is unsupported on an
API and another that is this will treat both as supported even if the active
window doesn't support capturing. This is an unlikely case and needs a new UI
to properly represent that.
* This in particular means push constants and specialization constants on vulkan
but also applies to root-value cbuffers on D3D12.
* GL bare uniforms are not feasible to expose in this way.