TextureCacheD3D11: Fix resource lifecycle

This commit is contained in:
Henrik Rydgård
2025-08-01 17:57:52 +02:00
parent e4abbd3cae
commit e0d9edc077
3 changed files with 19 additions and 5 deletions
-3
View File
@@ -76,7 +76,6 @@ GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
}
void GPU_D3D11::FinishInitOnMainThread() {
textureCacheD3D11_->InitDeviceObjects();
stockD3D11.Create(device_);
}
@@ -111,14 +110,12 @@ void GPU_D3D11::DeviceLost() {
// FBOs appear to survive? Or no?
shaderManager_->ClearShaders();
drawEngine_.ClearInputLayoutMap();
textureCache_->Clear(false);
GPUCommonHW::DeviceLost();
}
void GPU_D3D11::DeviceRestore(Draw::DrawContext *draw) {
GPUCommonHW::DeviceRestore(draw);
// Nothing needed.
}
void GPU_D3D11::BeginHostFrame() {
+16
View File
@@ -140,6 +140,7 @@ TextureCacheD3D11::TextureCacheD3D11(Draw::DrawContext *draw, Draw2D *draw2D)
TextureCacheD3D11::~TextureCacheD3D11() {
Clear(true);
DestroyDeviceObjects();
}
void TextureCacheD3D11::InitDeviceObjects() {
@@ -148,6 +149,21 @@ void TextureCacheD3D11::InitDeviceObjects() {
_dbg_assert_(SUCCEEDED(hr));
}
void TextureCacheD3D11::DestroyDeviceObjects() {
depalConstants_.Reset();
}
void TextureCacheD3D11::DeviceLost() {
Clear(false);
DestroyDeviceObjects();
draw_ = nullptr;
}
void TextureCacheD3D11::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
InitDeviceObjects();
}
void TextureCacheD3D11::SetFramebufferManager(FramebufferManagerD3D11 *fbManager) {
framebufferManager_ = fbManager;
}
+3 -2
View File
@@ -55,10 +55,11 @@ public:
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
void InitDeviceObjects();
void DestroyDeviceObjects();
protected:
void BindTexture(TexCacheEntry *entry) override;