Commit Graph

122 Commits (4ff7ac0bfa3fec8d65a169b8b0acc46597d71f06)

Author SHA1 Message Date
Ryan Foster be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
jp9000 8cc5f8de55 libobs-d3d11: Don't crash if unable to rebuild shared texture
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.
2016-12-21 16:09:12 -08:00
jp9000 d2bb7157c2 libobs-d3d11: Add optional macro to log shader disassembly 2016-11-25 12:01:31 -08:00
jp9000 f6fae9b7e9 libobs-d3d11: Remove possible null pointer dereference 2016-11-06 16:49:02 -08:00
jp9000 bd5de5d938 libobs-d3d11: Include GDI surface in rebuild
The GDI surface was not included in the rebuild process, therefore when
window capture is used, it would cause a crash after a rebuild.
2016-11-06 16:46:38 -08:00
jp9000 8e8834f109 libobs-d3d11: Rebuild device and assets if device removed/reset
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.
2016-11-03 09:23:24 -07:00
jp9000 5eb0c4ec83 libobs-d3d11: Add Release funtions to all GS objects
Releases references for each graphics object.
2016-11-03 09:23:23 -07:00
jp9000 54737c9c68 libobs-d3d11: Remove unused function 2016-11-03 09:23:22 -07:00
jp9000 951c6892b0 libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00
jp9000 5c71f79d5f libobs-d3d11: Make shared texture error message less vague 2016-11-03 09:23:20 -07:00
jp9000 ecd5b4ee81 libobs-d3d11: Save all D3D11 object descriptors (for rebuilding) 2016-11-03 09:23:19 -07:00
jp9000 bab77c2afd libobs-d3d11: Store static vertex buffer data (for rebuilding)
Instead of letting vertex buffer data be freed immediately, store it so
it can be used for rebuilding later.  Also, separate the buffer building
to a function.
2016-11-03 09:23:18 -07:00
jp9000 61042e2bc4 libobs-d3d11: Store static textures in RAM (for rebuilding) 2016-11-03 09:23:17 -07:00
jp9000 e4900751c3 libobs-d3d11: Store device adapter index (for rebuilding) 2016-11-03 09:23:16 -07:00
jp9000 6d18ae39c5 libobs-d3d11: Store swap initialization data (for rebuilding) 2016-11-03 09:23:15 -07:00
jp9000 bc0faf9a3c libobs-d3d11: Clear device state before unloading
Unloads all device data and clears all device references.  Probably not
necessary, but it's unknown how D3D11 handles this internally so
probably best to be safe.
2016-11-03 09:23:14 -07:00
jp9000 a5ed61e02e libobs-d3d11: Store index and add "Start" function
This allows restarting the duplicator at a later point in time.
2016-11-03 09:23:13 -07:00
jp9000 75cd6b4ab4 libobs-d3d11: Correct error message creating blend states 2016-11-03 09:23:12 -07:00
jp9000 66bdf43e44 libobs-d3d11: Correct error message for staging surfaces 2016-11-03 09:23:11 -07:00
jp9000 7321cc38e8 libobs-d3d11: Store shader samplers as pointers
This allows having them be a part of a linked list later.
2016-11-03 09:23:10 -07:00
jp9000 d4d0cd479d libobs-d3d11: Correct error message for pixel shaders 2016-11-03 09:23:09 -07:00
jp9000 1ecb1550af libobs-d3d11: Store compiled shader data (for rebuilding) 2016-11-03 09:23:08 -07:00
jp9000 29eea269fc libobs-d3d11: Store dxgi adapter used for device
Keeping a reference is useful, and additionally allows pruning a bit of
duplicated code in the dupicator object.
2016-11-03 09:23:07 -07:00
Ryan Foster 487ef58ee7 libobs-d3d11: Log GetDeviceRemovedReason
When DirectX throws error 0x887A0005 (DXGI_ERROR_DEVICE_REMOVED),
Microsoft recommends calling ID3D11Device::GetDeviceRemovedReason to
retrieve a more precise error code.

Closes jp9000/obs-studio#652
2016-10-07 01:07:00 -07:00
jp9000 4dc0024198 libobs/graphics: Add ability to set shader texture sampler
(Note: This also modifies libobs-d3d11 and libobs-opengl)

Allows overriding the sampler for a specific shader parameter.
2016-06-29 04:15:38 -07:00
jp9000 876cc94d51 libobs: Fix bug where bool constant size would be 1
(This commit also modifies libobs-d3d11)

Boolean constant size should be 4
2016-02-21 12:05:04 -08:00
jp9000 2a99e6ff18 libobs-d3d11: Log monitors/VRAM 2015-12-21 14:19:20 -08:00
jp9000 fd591fbd45 libobs-d3d11: Use debug log if duplicator fails to create
The duplicator is supposed to be able to safely fail to create, so using
a debug log message is more appropriate.
2015-11-16 11:11:16 -08:00
jp9000 ccfd57d100 libobs/graphics: Rename inconsistent function names
Renames functions:
gs_shader_setmatrix3 -> gs_shader_set_matrix3
gs_voltexture_getdepth -> gs_voltexture_get_depth
2015-10-21 07:46:43 -07:00
jp9000 eb459e2adc libobs-d3d11: Remove windowless context #error 2015-08-05 01:07:16 -07:00
jp9000 2b62c33c16 libobs-d3d11: Use windowless context
(Non-compiling commit: windowless-context branch)
2015-08-05 01:07:15 -07:00
jp9000 844123164f libobs-d3d11: Add windowless context #error 2015-08-05 01:07:06 -07:00
jp9000 278fd03a66 libobs-d3d11: Use get_win_ver (not GetVersionEx) 2015-08-01 14:51:23 -07:00
jp9000 cedd894fe7 libobs-d3d11: Make sure current swap is valid 2015-07-30 17:16:24 -07:00
jp9000 be52fa26f9 Add gs_blend_function_separate
This allows the ability to separate the blend states of color and alpha.

The default blend state has also changed so that alpha is always added
together to ensure that the destination image always gets an alpha value
that is actually usable after the operation (for render targets).

Old default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_SRCALPHA, alpha dest: GS_BLEND_INVSRCALPHA

New default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_ONE,      alpha dest: GS_BLEND_ONE
2015-03-27 11:18:02 -07:00
jp9000 3812393472 libobs-d3d11: Fix uint -> HWND casting
HWND is considered a pointer, so when casting you must cast to a
pointer-sized integer before attempting to cast to a pointer.
2015-02-09 03:56:12 -08:00
jp9000 86563ea1cd libobs-d3d11: Fix vertical alignment
Someone's going to yell at me about this, but fix vertical alignment for
certain member variables in the main header.

For future reference, if you must use vertical alignment, always give it
plenty of space for the type names to grow in case you need to
add/change variables in the future; don't just align to the 'longest'
value, give it an extra 8-16 spaces for potential future variables.
This is done to prevent having to make commits like this in the future
that sort of pollute the history.
2015-02-09 03:56:12 -08:00
jp9000 3af33b26ac libobs-d3d11: Use integer type with switch
DXGI_FORMAT has too many values we don't need/use, so the value for this
switch should be an integer instead of an enum to prevent warnings.
2015-02-09 03:56:11 -08:00
jp9000 e7cca4edd1 libobs-d3d11: Fix incorrect format specifier 2015-02-09 03:56:10 -08:00
jp9000 73c6dca1b5 libobs-d3d11: Fix potentially uninitialized vars 2015-02-09 03:56:10 -08:00
jp9000 7650df5525 libobs-d3d11: Fill out switch enum values
When using an enumeration value with a switch, it needs to be filled out
with all possible values to prevent compiler warnings.  This warning is
used to prevent the developer from unintentionally forgetting to add new
enum values to any switches the enum is used on later on.  Sadly, only
good compilers actually have this warning (mingw).
2015-02-09 03:56:09 -08:00
jp9000 1b2c3a6176 libobs-d3d11: Fix initializer list ordering
Microsoft's compiler doesn't seem to care about warning about things
like initializer list ordering.  Mingw actually reports on this to
prevent potential confusion about ordering.
2015-02-09 03:56:09 -08:00
jp9000 f4406e71f4 libobs-d3d11: Use member initialization
Instead of using initializer lists, use member initialization to clean
up the default values for member variables
2015-02-09 03:56:08 -08:00
martell 5d184dc8e5 obs-d3d11: use sprintf for mingw-w64
We have a sprintf_s function in mingw-w64, but it's the it won't compile
with visual studio because it's the C11 specification (aka the correct
specification that's not made by morons).  Microsoft's version differs
to the specification (and is made by morons), so fall back to sprintf

(note if you can't tell, this commit message was edited by Jim)
2015-02-09 03:46:11 -08:00
martell d1a1a84722 obs-d3d11: Use cinttypes header (mingw)
There appears to be a bug with mingw where including the regular C
inttypes.h won't work; instead you have to use the 'cinttypes' C++
version.
2015-02-09 03:43:56 -08:00
martell e96bd8c6bb obs-d3d11: include float.h for FLT_MAX
gcc expects this header to be included
2015-02-09 03:41:59 -08:00
martell 27c4336eed libobs-d3d11: Remove Microsoft's dxgi.h
I have added LGPL idl's for d3d11 and dxgi to mingw-w64, so we can
remove the existing mingw helper files from libobs-d3d11
2015-02-09 03:41:50 -08:00
jp9000 111b516043 libobs-d3d11: Log available adapters 2015-01-14 21:28:08 -08:00
jp9000 389c0b95d6 libobs-d3d11: Log adapter ID 2015-01-14 21:28:08 -08:00
jp9000 1cb02d5879 libobs: Add function to enumerate video adapters
The gs_enum_adapters function is an optional implementation to allow
enumeration of available graphics adapters that can be used with the
program.  The ID associated with the adapter can be an index or a hash
depending on the implementation.
2015-01-14 21:28:01 -08:00