Some DeviceLost/DeviceRestore cleanup

This commit is contained in:
Henrik Rydgård committed 2023-02-26 11:05:52 +01:00
1 parent 231f4efbbb
commit 72bed6f2b5
16 files changed
+42 -25

No files matched your search

+2
View File
@@ -74,6 +74,8 @@ public:
virtual ~DrawEngineCommon();
void Init();
virtual void DeviceLost() = 0;
virtual void DeviceRestore(Draw::DrawContext *draw) = 0;
bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices);
+3
View File
@@ -119,6 +119,9 @@ public:
DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context);
~DrawEngineD3D11();
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
void SetShaderManager(ShaderManagerD3D11 *shaderManager) {
shaderManager_ = shaderManager;
}
+1 -1
View File
@@ -89,7 +89,7 @@ public:
void ClearShaders() override;
void DirtyLastShader() override;
void DeviceLost() override {}
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
int GetNumVertexShaders() const { return (int)vsCache_.size(); }
int GetNumFragmentShaders() const { return (int)fsCache_.size(); }
+1 -1
View File
@@ -52,7 +52,7 @@ public:
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
void DeviceLost() override {}
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
protected:
+3
View File
@@ -107,6 +107,9 @@ public:
DrawEngineDX9(Draw::DrawContext *draw);
~DrawEngineDX9();
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
void SetShaderManager(ShaderManagerDX9 *shaderManager) {
shaderManager_ = shaderManager;
}
+8
View File
@@ -105,6 +105,14 @@ u32 GPU_DX9::CheckGPUFeatures() const {
return CheckGPUFeaturesLate(features);
}
void GPU_DX9::DeviceLost() {
GPUCommonHW::DeviceLost();
}
void GPU_DX9::DeviceRestore(Draw::DrawContext *draw) {
GPUCommonHW::DeviceRestore(draw);
}
void GPU_DX9::ReapplyGfxState() {
dxstate.Restore();
GPUCommonHW::ReapplyGfxState();
+3
View File
@@ -36,6 +36,9 @@ public:
u32 CheckGPUFeatures() const override;
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
void ReapplyGfxState() override;
void GetStats(char *buffer, size_t bufsize) override;
+1 -1
View File
@@ -85,7 +85,7 @@ public:
int GetNumVertexShaders() const { return (int)vsCache_.size(); }
int GetNumFragmentShaders() const { return (int)fsCache_.size(); }
void DeviceLost() override {}
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
std::vector<std::string> DebugGetShaderIDs(DebugShaderType type);
+1 -1
View File
@@ -42,7 +42,7 @@ public:
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
void DeviceLost() override {}
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
protected:
+2 -2
View File
@@ -76,8 +76,8 @@ public:
fragmentTestCache_ = testCache;
}
void DeviceLost();
void DeviceRestore(Draw::DrawContext *draw);
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
void ClearTrackedVertexArrays() override {}
+1 -7
View File
@@ -239,7 +239,6 @@ void GPU_GLES::DeviceLost() {
// TransformDraw has registered as a GfxResourceHolder.
CancelReady();
fragmentTestCache_.DeviceLost();
drawEngine_.DeviceLost();
GPUCommonHW::DeviceLost();
}
@@ -247,13 +246,8 @@ void GPU_GLES::DeviceLost() {
void GPU_GLES::DeviceRestore(Draw::DrawContext *draw) {
GPUCommonHW::DeviceRestore(draw);
UpdateCmdInfo();
UpdateVsyncInterval(true);
shaderManager_->DeviceRestore(draw_);
textureCache_->DeviceRestore(draw_);
drawEngine_.DeviceRestore(draw_);
fragmentTestCache_.DeviceRestore(draw_);
UpdateVsyncInterval(true);
}
void GPU_GLES::BeginHostFrame() {
+9
View File
@@ -417,13 +417,22 @@ void GPUCommonHW::DeviceLost() {
textureCache_->Clear(false);
textureCache_->DeviceLost();
shaderManager_->DeviceLost();
drawEngineCommon_->DeviceLost();
}
// Call at the start of the GPU implementation's DeviceRestore
void GPUCommonHW::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
framebufferManager_->DeviceRestore(draw_);
textureCache_->DeviceRestore(draw_);
shaderManager_->DeviceRestore(draw_);
drawEngineCommon_->DeviceRestore(draw_);
PPGeSetDrawContext(draw_);
gstate_c.SetUseFlags(CheckGPUFeatures());
BuildReportingInfo();
UpdateCmdInfo();
}
void GPUCommonHW::UpdateCmdInfo() {
+3
View File
@@ -173,6 +173,9 @@ public:
SoftwareDrawEngine();
~SoftwareDrawEngine();
void DeviceLost() override {}
void DeviceRestore(Draw::DrawContext *draw) override {}
void NotifyConfigChanged() override;
void DispatchFlush() override;
void DispatchSubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int cullMode, int *bytesRead) override;
-1
View File
@@ -287,7 +287,6 @@ void DrawEngineVulkan::DeviceLost() {
void DrawEngineVulkan::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
InitDeviceObjects();
}
+2 -2
View File
@@ -158,8 +158,8 @@ public:
framebufferManager_ = fbManager;
}
void DeviceLost();
void DeviceRestore(Draw::DrawContext *draw);
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
// So that this can be inlined
void Flush() {
+2 -9
View File
@@ -454,7 +454,6 @@ void GPU_Vulkan::DeviceLost() {
SaveCache(shaderCachePath_);
}
DestroyDeviceObjects();
drawEngine_.DeviceLost();
pipelineManager_->DeviceLost();
GPUCommonHW::DeviceLost();
@@ -462,17 +461,11 @@ void GPU_Vulkan::DeviceLost() {
void GPU_Vulkan::DeviceRestore(Draw::DrawContext *draw) {
GPUCommonHW::DeviceRestore(draw);
InitDeviceObjects();
gstate_c.SetUseFlags(CheckGPUFeatures());
BuildReportingInfo();
UpdateCmdInfo();
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
drawEngine_.DeviceRestore(draw_);
pipelineManager_->DeviceRestore(vulkan);
textureCacheVulkan_->DeviceRestore(draw_);
shaderManagerVulkan_->DeviceRestore(draw_);
InitDeviceObjects();
}
void GPU_Vulkan::GetStats(char *buffer, size_t bufsize) {