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 07:41:23 -07:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2016 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "d3d11-subsystem.hpp"
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_vertex_buffer::Rebuild()
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
uvBuffers.clear();
|
|
|
|
uvSizes.clear();
|
|
|
|
BuildBuffers();
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_index_buffer::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateBuffer(&bd, &srd, &indexBuffer);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create buffer", hr);
|
|
|
|
}
|
|
|
|
|
2016-12-21 15:53:14 -08:00
|
|
|
void gs_texture_2d::RebuildSharedTextureFallback()
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
td = {};
|
|
|
|
td.Width = 2;
|
|
|
|
td.Height = 2;
|
|
|
|
td.MipLevels = 1;
|
|
|
|
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
|
|
|
td.ArraySize = 1;
|
2016-12-21 15:53:14 -08:00
|
|
|
td.SampleDesc.Count = 1;
|
2019-06-22 22:13:45 -07:00
|
|
|
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
2016-12-21 15:53:14 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
width = td.Width;
|
|
|
|
height = td.Height;
|
2016-12-21 15:53:14 -08:00
|
|
|
dxgiFormat = td.Format;
|
2019-06-22 22:13:45 -07:00
|
|
|
levels = 1;
|
2016-12-21 15:53:14 -08:00
|
|
|
|
|
|
|
resourceDesc = {};
|
2019-06-22 22:13:45 -07:00
|
|
|
resourceDesc.Format = td.Format;
|
|
|
|
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
2016-12-21 15:53:14 -08:00
|
|
|
resourceDesc.Texture2D.MipLevels = 1;
|
|
|
|
|
|
|
|
isShared = false;
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_texture_2d::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
if (isShared) {
|
|
|
|
hr = dev->OpenSharedResource((HANDLE)(uintptr_t)sharedHandle,
|
2019-06-22 22:13:45 -07:00
|
|
|
__uuidof(ID3D11Texture2D),
|
|
|
|
(void **)&texture);
|
2016-12-21 15:53:14 -08:00
|
|
|
if (FAILED(hr)) {
|
2019-06-22 22:13:45 -07:00
|
|
|
blog(LOG_WARNING,
|
|
|
|
"Failed to rebuild shared texture: ", "0x%08lX",
|
|
|
|
hr);
|
2016-12-21 15:53:14 -08:00
|
|
|
RebuildSharedTextureFallback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isShared) {
|
2019-06-22 22:13:45 -07:00
|
|
|
hr = dev->CreateTexture2D(
|
|
|
|
&td, data.size() ? srd.data() : nullptr, &texture);
|
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 07:41:23 -07:00
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create 2D texture", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = dev->CreateShaderResourceView(texture, &resourceDesc, &shaderRes);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create resource view", hr);
|
|
|
|
|
|
|
|
if (isRenderTarget)
|
|
|
|
InitRenderTargets();
|
2016-11-06 16:46:38 -08:00
|
|
|
|
|
|
|
if (isGDICompatible) {
|
|
|
|
hr = texture->QueryInterface(__uuidof(IDXGISurface1),
|
2019-06-22 22:13:45 -07:00
|
|
|
(void **)&gdiSurface);
|
2016-11-06 16:46:38 -08:00
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create GDI surface", hr);
|
|
|
|
}
|
2019-03-03 08:43:06 -08:00
|
|
|
|
|
|
|
acquired = false;
|
|
|
|
|
|
|
|
if ((td.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0) {
|
|
|
|
ComQIPtr<IDXGIResource> dxgi_res(texture);
|
|
|
|
if (dxgi_res)
|
|
|
|
GetSharedHandle(dxgi_res);
|
|
|
|
device_texture_acquire_sync(this, 0, INFINITE);
|
|
|
|
}
|
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 07:41:23 -07:00
|
|
|
}
|
|
|
|
|
2019-02-17 17:41:42 -08:00
|
|
|
void gs_texture_2d::RebuildNV12_Y(ID3D11Device *dev)
|
|
|
|
{
|
|
|
|
gs_texture_2d *tex_uv = pairedNV12texture;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = dev->CreateTexture2D(&td, nullptr, &texture);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create 2D texture", hr);
|
|
|
|
|
|
|
|
hr = dev->CreateShaderResourceView(texture, &resourceDesc, &shaderRes);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create resource view", hr);
|
|
|
|
|
|
|
|
if (isRenderTarget)
|
|
|
|
InitRenderTargets();
|
|
|
|
|
|
|
|
tex_uv->RebuildNV12_UV(dev);
|
2019-03-03 08:43:06 -08:00
|
|
|
|
|
|
|
acquired = false;
|
|
|
|
|
|
|
|
if ((td.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0) {
|
|
|
|
ComQIPtr<IDXGIResource> dxgi_res(texture);
|
|
|
|
if (dxgi_res)
|
|
|
|
GetSharedHandle(dxgi_res);
|
|
|
|
device_texture_acquire_sync(this, 0, INFINITE);
|
|
|
|
}
|
2019-02-17 17:41:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void gs_texture_2d::RebuildNV12_UV(ID3D11Device *dev)
|
|
|
|
{
|
|
|
|
gs_texture_2d *tex_y = pairedNV12texture;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
texture = tex_y->texture;
|
|
|
|
|
|
|
|
hr = dev->CreateShaderResourceView(texture, &resourceDesc, &shaderRes);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create resource view", hr);
|
|
|
|
|
|
|
|
if (isRenderTarget)
|
|
|
|
InitRenderTargets();
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_zstencil_buffer::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
hr = dev->CreateTexture2D(&td, nullptr, &texture);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create depth stencil texture", hr);
|
|
|
|
|
|
|
|
hr = dev->CreateDepthStencilView(texture, &dsvd, &view);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create depth stencil view", hr);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_stage_surface::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateTexture2D(&td, nullptr, &texture);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create staging surface", hr);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_sampler_state::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateSamplerState(&sd, state.Assign());
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create sampler state", hr);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_vertex_shader::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2019-06-22 22:13:45 -07:00
|
|
|
hr = dev->CreateVertexShader(data.data(), data.size(), nullptr,
|
|
|
|
&shader);
|
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 07:41:23 -07:00
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create vertex shader", hr);
|
|
|
|
|
2019-10-17 09:24:13 -07:00
|
|
|
const UINT layoutSize = (UINT)layoutData.size();
|
|
|
|
if (layoutSize > 0) {
|
|
|
|
hr = dev->CreateInputLayout(layoutData.data(), layoutSize,
|
|
|
|
data.data(), data.size(), &layout);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create input layout", hr);
|
|
|
|
}
|
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 07:41:23 -07:00
|
|
|
|
|
|
|
if (constantSize) {
|
|
|
|
hr = dev->CreateBuffer(&bd, NULL, &constants);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create constant buffer", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (gs_shader_param ¶m : params) {
|
|
|
|
param.nextSampler = nullptr;
|
|
|
|
param.curValue.clear();
|
|
|
|
gs_shader_set_default(¶m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_pixel_shader::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2019-06-22 22:13:45 -07:00
|
|
|
|
|
|
|
hr = dev->CreatePixelShader(data.data(), data.size(), nullptr, &shader);
|
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 07:41:23 -07:00
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create pixel shader", hr);
|
|
|
|
|
|
|
|
if (constantSize) {
|
|
|
|
hr = dev->CreateBuffer(&bd, NULL, &constants);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create constant buffer", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (gs_shader_param ¶m : params) {
|
|
|
|
param.nextSampler = nullptr;
|
|
|
|
param.curValue.clear();
|
|
|
|
gs_shader_set_default(¶m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void gs_swap_chain::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = device->factory->CreateSwapChain(dev, &swapDesc, &swap);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create swap chain", hr);
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2019-07-27 13:31:07 -07:00
|
|
|
void gs_timer::Rebuild(ID3D11Device *dev)
|
|
|
|
{
|
|
|
|
D3D11_QUERY_DESC desc;
|
|
|
|
desc.Query = D3D11_QUERY_TIMESTAMP;
|
|
|
|
desc.MiscFlags = 0;
|
|
|
|
HRESULT hr = dev->CreateQuery(&desc, &query_begin);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create timer", hr);
|
|
|
|
hr = dev->CreateQuery(&desc, &query_end);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create timer", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gs_timer_range::Rebuild(ID3D11Device *dev)
|
|
|
|
{
|
|
|
|
D3D11_QUERY_DESC desc;
|
|
|
|
desc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
|
|
|
|
desc.MiscFlags = 0;
|
|
|
|
HRESULT hr = dev->CreateQuery(&desc, &query_disjoint);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create timer", hr);
|
|
|
|
}
|
|
|
|
|
2019-12-15 11:36:24 -08:00
|
|
|
void gs_texture_3d::RebuildSharedTextureFallback()
|
|
|
|
{
|
|
|
|
td = {};
|
|
|
|
td.Width = 2;
|
|
|
|
td.Height = 2;
|
|
|
|
td.Depth = 2;
|
|
|
|
td.MipLevels = 1;
|
|
|
|
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
|
|
|
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
|
|
|
|
|
|
|
width = td.Width;
|
|
|
|
height = td.Height;
|
|
|
|
depth = td.Depth;
|
|
|
|
dxgiFormat = td.Format;
|
|
|
|
levels = 1;
|
|
|
|
|
|
|
|
resourceDesc = {};
|
|
|
|
resourceDesc.Format = td.Format;
|
|
|
|
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
|
|
|
|
resourceDesc.Texture3D.MostDetailedMip = 0;
|
|
|
|
resourceDesc.Texture3D.MipLevels = 1;
|
|
|
|
|
|
|
|
isShared = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gs_texture_3d::Rebuild(ID3D11Device *dev)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
if (isShared) {
|
|
|
|
hr = dev->OpenSharedResource((HANDLE)(uintptr_t)sharedHandle,
|
|
|
|
__uuidof(ID3D11Texture3D),
|
|
|
|
(void **)&texture);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
"Failed to rebuild shared texture: ", "0x%08lX",
|
|
|
|
hr);
|
|
|
|
RebuildSharedTextureFallback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isShared) {
|
|
|
|
hr = dev->CreateTexture3D(
|
|
|
|
&td, data.size() ? srd.data() : nullptr, &texture);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create 3D texture", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = dev->CreateShaderResourceView(texture, &resourceDesc, &shaderRes);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create resource view", hr);
|
|
|
|
|
|
|
|
acquired = false;
|
|
|
|
|
|
|
|
if ((td.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0) {
|
|
|
|
ComQIPtr<IDXGIResource> dxgi_res(texture);
|
|
|
|
if (dxgi_res)
|
|
|
|
GetSharedHandle(dxgi_res);
|
|
|
|
device_texture_acquire_sync(this, 0, INFINITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void SavedBlendState::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateBlendState(&bd, &state);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create blend state", hr);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void SavedZStencilState::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateDepthStencilState(&dsd, &state);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create depth stencil state", hr);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:22:04 -08:00
|
|
|
void SavedRasterState::Rebuild(ID3D11Device *dev)
|
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 07:41:23 -07:00
|
|
|
{
|
|
|
|
HRESULT hr = dev->CreateRasterizerState(&rd, &state);
|
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create rasterizer state", hr);
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
const static D3D_FEATURE_LEVEL featureLevels[] = {
|
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 07:41:23 -07:00
|
|
|
D3D_FEATURE_LEVEL_11_0,
|
|
|
|
D3D_FEATURE_LEVEL_10_1,
|
|
|
|
D3D_FEATURE_LEVEL_10_0,
|
|
|
|
};
|
|
|
|
|
|
|
|
void gs_device::RebuildDevice()
|
|
|
|
try {
|
|
|
|
ID3D11Device *dev = nullptr;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
blog(LOG_WARNING, "Device Remove/Reset! Rebuilding all assets...");
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
2019-11-27 16:35:27 -08:00
|
|
|
for (gs_device_loss &callback : loss_callbacks)
|
|
|
|
callback.device_loss_release(callback.data);
|
|
|
|
|
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 07:41:23 -07:00
|
|
|
gs_obj *obj = first_obj;
|
|
|
|
|
|
|
|
while (obj) {
|
|
|
|
switch (obj->obj_type) {
|
|
|
|
case gs_type::gs_vertex_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_vertex_buffer *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_index_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_index_buffer *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_texture_2d:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_texture_2d *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_zstencil_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_zstencil_buffer *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_stage_surface:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_stage_surface *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_sampler_state:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_sampler_state *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_vertex_shader:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_vertex_shader *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_pixel_shader:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_pixel_shader *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_duplicator:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_duplicator *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_swap_chain:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_swap_chain *)obj)->Release();
|
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 07:41:23 -07:00
|
|
|
break;
|
2019-07-27 13:31:07 -07:00
|
|
|
case gs_type::gs_timer:
|
|
|
|
((gs_timer *)obj)->Release();
|
|
|
|
break;
|
|
|
|
case gs_type::gs_timer_range:
|
|
|
|
((gs_timer_range *)obj)->Release();
|
|
|
|
break;
|
2019-12-15 11:36:24 -08:00
|
|
|
case gs_type::gs_texture_3d:
|
|
|
|
((gs_texture_3d *)obj)->Release();
|
|
|
|
break;
|
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 07:41:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
obj = obj->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &state : zstencilStates)
|
|
|
|
state.Release();
|
|
|
|
for (auto &state : rasterStates)
|
|
|
|
state.Release();
|
|
|
|
for (auto &state : blendStates)
|
|
|
|
state.Release();
|
|
|
|
|
|
|
|
context->ClearState();
|
2019-11-27 16:35:27 -08:00
|
|
|
context->Flush();
|
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 07:41:23 -07:00
|
|
|
|
|
|
|
context.Release();
|
|
|
|
device.Release();
|
|
|
|
adapter.Release();
|
|
|
|
factory.Release();
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
InitFactory(adpIdx);
|
|
|
|
|
|
|
|
uint32_t createFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
2019-06-22 22:13:45 -07:00
|
|
|
hr = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
|
|
|
|
createFlags, featureLevels,
|
|
|
|
sizeof(featureLevels) /
|
|
|
|
sizeof(D3D_FEATURE_LEVEL),
|
|
|
|
D3D11_SDK_VERSION, &device, nullptr, &context);
|
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 07:41:23 -07:00
|
|
|
if (FAILED(hr))
|
|
|
|
throw HRError("Failed to create device", hr);
|
|
|
|
|
|
|
|
dev = device;
|
|
|
|
|
|
|
|
obj = first_obj;
|
|
|
|
while (obj) {
|
|
|
|
switch (obj->obj_type) {
|
|
|
|
case gs_type::gs_vertex_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_vertex_buffer *)obj)->Rebuild();
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_index_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_index_buffer *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
2019-06-22 22:13:45 -07:00
|
|
|
case gs_type::gs_texture_2d: {
|
|
|
|
gs_texture_2d *tex = (gs_texture_2d *)obj;
|
|
|
|
if (!tex->nv12) {
|
|
|
|
tex->Rebuild(dev);
|
|
|
|
} else if (!tex->chroma) {
|
|
|
|
tex->RebuildNV12_Y(dev);
|
2019-02-17 17:41:42 -08:00
|
|
|
}
|
2019-06-22 22:13:45 -07:00
|
|
|
} break;
|
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 07:41:23 -07:00
|
|
|
case gs_type::gs_zstencil_buffer:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_zstencil_buffer *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_stage_surface:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_stage_surface *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_sampler_state:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_sampler_state *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_vertex_shader:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_vertex_shader *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_pixel_shader:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_pixel_shader *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_duplicator:
|
2017-11-16 20:33:03 -08:00
|
|
|
try {
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_duplicator *)obj)->Start();
|
2017-11-16 20:33:03 -08:00
|
|
|
} catch (...) {
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_duplicator *)obj)->Release();
|
2017-11-16 20:33:03 -08:00
|
|
|
}
|
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 07:41:23 -07:00
|
|
|
break;
|
|
|
|
case gs_type::gs_swap_chain:
|
2019-06-22 22:13:45 -07:00
|
|
|
((gs_swap_chain *)obj)->Rebuild(dev);
|
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 07:41:23 -07:00
|
|
|
break;
|
2019-07-27 13:31:07 -07:00
|
|
|
case gs_type::gs_timer:
|
|
|
|
((gs_timer *)obj)->Rebuild(dev);
|
|
|
|
break;
|
|
|
|
case gs_type::gs_timer_range:
|
|
|
|
((gs_timer_range *)obj)->Rebuild(dev);
|
|
|
|
break;
|
2019-12-15 11:36:24 -08:00
|
|
|
case gs_type::gs_texture_3d:
|
|
|
|
((gs_texture_3d *)obj)->Rebuild(dev);
|
|
|
|
break;
|
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 07:41:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
obj = obj->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
curRenderTarget = nullptr;
|
|
|
|
curZStencilBuffer = nullptr;
|
|
|
|
curRenderSide = 0;
|
|
|
|
memset(&curTextures, 0, sizeof(curTextures));
|
|
|
|
memset(&curSamplers, 0, sizeof(curSamplers));
|
|
|
|
curVertexBuffer = nullptr;
|
|
|
|
curIndexBuffer = nullptr;
|
|
|
|
curVertexShader = nullptr;
|
|
|
|
curPixelShader = nullptr;
|
|
|
|
curSwapChain = nullptr;
|
|
|
|
zstencilStateChanged = true;
|
|
|
|
rasterStateChanged = true;
|
|
|
|
blendStateChanged = true;
|
|
|
|
curDepthStencilState = nullptr;
|
|
|
|
curRasterState = nullptr;
|
|
|
|
curBlendState = nullptr;
|
|
|
|
curToplogy = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
|
|
|
|
|
|
|
for (auto &state : zstencilStates)
|
|
|
|
state.Rebuild(dev);
|
|
|
|
for (auto &state : rasterStates)
|
|
|
|
state.Rebuild(dev);
|
|
|
|
for (auto &state : blendStates)
|
|
|
|
state.Rebuild(dev);
|
|
|
|
|
2019-11-27 16:35:27 -08:00
|
|
|
for (gs_device_loss &callback : loss_callbacks)
|
|
|
|
callback.device_loss_rebuild(device.Get(), callback.data);
|
|
|
|
|
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 07:41:23 -07:00
|
|
|
} catch (const char *error) {
|
|
|
|
bcrash("Failed to recreate D3D11: %s", error);
|
|
|
|
|
2019-08-28 21:10:51 -07:00
|
|
|
} catch (const HRError &error) {
|
2019-06-22 22:13:45 -07:00
|
|
|
bcrash("Failed to recreate D3D11: %s (%08lX)", error.str, error.hr);
|
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 07:41:23 -07:00
|
|
|
}
|