Complex external systems using the D3D11 device may need to perform
their own device loss handling, the upcoming Windows Graphics Capture
support for example.
Feature Level 9.3 appears to never have actually worked because shaders
are compiled as straight 4_0 instead of 4_0_level_9_3. That being the
case, baseline against 10_0 instead.
This change only wraps the functionality. I have rough code to exercise
the the query functionality, but that part is not really clean enough to
submit.
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed. Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
If a texture has to be rebuilt due to a driver reset and is a keyed
mutex shared texture, make sure to reacquire the shared handle and
acquire the lock.
When NV12 textures were added, driver crashes and their rebuild process
was not taken in to consideration. This fixes that by adding explicit
NV12 rebuild functions.
Prevents an issue where the output duplicator would cause the program to
crash if the graphics driver crashes and the graphics subsystem needs to
be rebuilt.
Sometimes when rebuilding a texture, it often has to fall back and
create a temporary texture, but it'll fail when trying to create a
shader resource for it. The suspicion is because it's due to not having
the proper shader binding flag when creating that temporary texture, so
this fixes that possible loophole.
When rebuilding the graphics subsystem, it's possible a shared texture
may no longer be available. In this case, just soft fail and allow the
texture to be rebuilt rather than crash the entire program over it.
Due to an NVIDIA driver bug with the Windows 10 Anniversary Update,
there are an increasingly large number of reports of "Device Removed"
errors and TDRs. When this happens, OBS stops outputting all data
because all graphics functions are failing, and it appears to just
"freeze up" for users.
To temporarily alleviate this issue while waiting for it to be fixed,
the D3D subsystem can be rebuilt when that happens, all assets can be
reloaded to ensure that it can continue functioning (with a minor hiccup
in playback).
To allow rebuilding the entire D3D subsystem, all objects that contain
D3D references must be part of a linked list (with a few exceptions) so
we can quickly traverse them all whenever needed, and all data for those
resources (static resources primarily, such as shaders, textures, index
buffers, vertex buffers) must be stored in RAM so they can be recreated
whenever needed.
Then if D3D reports a "device removed" or "device reset" error, all D3D
references must first be fully released with no stray references; the
linked list must be fully traversed until all references are released.
Then, the linked list must once again be traversed again, and all those
D3D objects must be recreated with the same data and descriptors (which
are now saved in each object). Finally, all states need to be reset.
After that's complete, the device is able to continue functioning almost
as it was before, although the output to recording/stream may get a few
green frames due to texture data being reset.
This will temporarily alleviate the "Device Removed" issue while waiting
for a fix from NVIDIA.