fixed D3D11 shutdown warnings

This commit is contained in:
Noel Berry 2022-01-09 18:31:20 -08:00 committed by GitHub
parent c8afa3f699
commit 5f4a332d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,12 +184,12 @@ namespace Blah
{ {
if (texture) if (texture)
texture->Release(); texture->Release();
texture = nullptr;
if (staging) if (staging)
staging->Release(); staging->Release();
staging = nullptr;
if (view) if (view)
view->Release(); view->Release();
staging = nullptr;
texture = nullptr;
view = nullptr; view = nullptr;
} }
@ -332,6 +332,10 @@ namespace Blah
for (auto& it : color_views) for (auto& it : color_views)
it->Release(); it->Release();
color_views.clear(); color_views.clear();
if (depth_view)
depth_view->Release();
depth_view = nullptr;
} }
Attachments& textures() override Attachments& textures() override
@ -505,22 +509,26 @@ namespace Blah
{ {
if (vertex) if (vertex)
vertex->Release(); vertex->Release();
vertex = nullptr;
if (vertex_blob) if (vertex_blob)
vertex_blob->Release(); vertex_blob->Release();
vertex_blob = nullptr;
if (fragment) if (fragment)
fragment->Release(); fragment->Release();
fragment = nullptr;
if (fragment_blob) if (fragment_blob)
fragment_blob->Release(); fragment_blob->Release();
fragment_blob = nullptr;
for (auto& it : vertex_uniform_buffers) for (auto& it : vertex_uniform_buffers)
it->Release(); it->Release();
vertex_uniform_buffers.clear();
for (auto& it : fragment_uniform_buffers) for (auto& it : fragment_uniform_buffers)
it->Release(); it->Release();
fragment_uniform_buffers.clear();
vertex = nullptr;
vertex_blob = nullptr;
fragment = nullptr;
fragment_blob = nullptr;
} }
Vector<UniformInfo>& uniforms() override Vector<UniformInfo>& uniforms() override
@ -558,8 +566,10 @@ namespace Blah
{ {
if (vertex_buffer) if (vertex_buffer)
vertex_buffer->Release(); vertex_buffer->Release();
vertex_buffer = nullptr;
if (index_buffer) if (index_buffer)
index_buffer->Release(); index_buffer->Release();
index_buffer = nullptr;
} }
void index_data(IndexFormat format, const void* indices, i64 count) override void index_data(IndexFormat format, const void* indices, i64 count) override
@ -759,10 +769,15 @@ namespace Blah
dxgi_adapter->GetDesc(&adapter_desc); dxgi_adapter->GetDesc(&adapter_desc);
Log::info("D3D11 %ls", adapter_desc.Description); Log::info("D3D11 %ls", adapter_desc.Description);
dxgi_device->Release();
dxgi_adapter->Release();
} }
else else
{
Log::info("D3D11"); Log::info("D3D11");
} }
}
return true; return true;
} }
@ -786,12 +801,14 @@ namespace Blah
for (auto& it : state.sampler_cache) for (auto& it : state.sampler_cache)
it.state->Release(); it.state->Release();
// TODO:
// Do we need to release live resources? ex. Texture's that
// haven't been released by shutdown will still exist...
// release main devices // release main devices
if (state.backbuffer_view)
state.backbuffer_view->Release();
if (state.backbuffer_depth_view)
state.backbuffer_depth_view->Release();
state.swap_chain->Release(); state.swap_chain->Release();
state.context->ClearState();
state.context->Flush();
state.context->Release(); state.context->Release();
state.device->Release(); state.device->Release();
@ -806,6 +823,7 @@ namespace Blah
void Graphics::update() void Graphics::update()
{ {
} }
void Graphics::before_render() void Graphics::before_render()
@ -937,9 +955,6 @@ namespace Blah
&mesh->vertex_buffer, &mesh->vertex_buffer,
&stride, &stride,
&offset); &offset);
D3D11_BUFFER_DESC desc;
mesh->vertex_buffer->GetDesc(&desc);
} }
// Assign Index Buffer // Assign Index Buffer