GPU/D3D11: Fix crash/hang when toggling bilinear setting

This commit is contained in:
Connor McLaughlin 2020-08-12 02:27:10 +10:00
parent d1ee6c0da7
commit bb344a4e1e
2 changed files with 21 additions and 5 deletions

View File

@ -13,10 +13,12 @@ GPU_HW_D3D11::GPU_HW_D3D11() = default;
GPU_HW_D3D11::~GPU_HW_D3D11()
{
if (m_host_display)
{
m_host_display->ClearDisplayTexture();
ResetGraphicsAPIState();
}
m_context->ClearState();
DestroyShaders();
DestroyStateObjects();
}
bool GPU_HW_D3D11::Initialize(HostDisplay* host_display)
@ -121,8 +123,6 @@ void GPU_HW_D3D11::UpdateSettings()
bool framebuffer_changed, shaders_changed;
UpdateHWSettings(&framebuffer_changed, &shaders_changed);
m_context->ClearState();
if (framebuffer_changed)
{
m_host_display->ClearDisplayTexture();
@ -132,6 +132,8 @@ void GPU_HW_D3D11::UpdateSettings()
if (shaders_changed)
{
DestroyShaders();
DestroyStateObjects();
CreateStateObjects();
CompileShaders();
}
@ -352,6 +354,19 @@ bool GPU_HW_D3D11::CreateStateObjects()
return true;
}
void GPU_HW_D3D11::DestroyStateObjects()
{
m_batch_blend_states = {};
m_linear_sampler_state.Reset();
m_point_sampler_state.Reset();
m_blend_no_color_writes_state.Reset();
m_blend_disabled_state.Reset();
m_depth_test_less_state.Reset();
m_depth_test_always_state.Reset();
m_depth_disabled_state.Reset();
m_cull_none_rasterizer_state.Reset();
}
bool GPU_HW_D3D11::CompileShaders()
{
GPU_HW_ShaderGen shadergen(m_host_display->GetRenderAPI(), m_resolution_scale, m_true_color, m_scaled_dithering,

View File

@ -57,6 +57,7 @@ private:
bool CreateUniformBuffer();
bool CreateTextureBuffer();
bool CreateStateObjects();
void DestroyStateObjects();
bool CompileShaders();
void DestroyShaders();