DrawEngine: Fix resource lifecycle

This commit is contained in:
Henrik Rydgård
2025-08-01 17:52:38 +02:00
parent b445f59e36
commit e4abbd3cae
2 changed files with 27 additions and 15 deletions
+25 -13
View File
@@ -90,19 +90,6 @@ void DrawEngineD3D11::InitDeviceObjects() {
draw_->SetInvalidationCallback(std::bind(&DrawEngineD3D11::Invalidate, this, std::placeholders::_1));
}
void DrawEngineD3D11::ClearInputLayoutMap() {
inputLayoutMap_.Iterate([&](const InputLayoutKey &key, ComPtr<ID3D11InputLayout> il) {
if (il)
il.Reset();
});
inputLayoutMap_.Clear();
}
void DrawEngineD3D11::NotifyConfigChanged() {
DrawEngineCommon::NotifyConfigChanged();
ClearInputLayoutMap();
}
void DrawEngineD3D11::DestroyDeviceObjects() {
if (draw_) {
draw_->SetInvalidationCallback(InvalidationCallback());
@@ -114,6 +101,31 @@ void DrawEngineD3D11::DestroyDeviceObjects() {
tessDataTransfer = nullptr;
delete pushVerts_;
delete pushInds_;
pushVerts_ = nullptr;
pushInds_ = nullptr;
}
void DrawEngineD3D11::DeviceLost() {
DestroyDeviceObjects();
draw_ = nullptr;
}
void DrawEngineD3D11::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
InitDeviceObjects();
}
void DrawEngineD3D11::ClearInputLayoutMap() {
inputLayoutMap_.Iterate([&](const InputLayoutKey &key, ComPtr<ID3D11InputLayout> il) {
if (il)
il.Reset();
});
inputLayoutMap_.Clear();
}
void DrawEngineD3D11::NotifyConfigChanged() {
DrawEngineCommon::NotifyConfigChanged();
ClearInputLayoutMap();
}
struct DeclTypeInfo {
+2 -2
View File
@@ -57,8 +57,8 @@ public:
DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context);
~DrawEngineD3D11();
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
void SetShaderManager(ShaderManagerD3D11 *shaderManager) {
shaderManager_ = shaderManager;