mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Reorganize the DeviceLost code a little. FramebufferManagerCommon now sees it.
This commit is contained in:
parent
e37468700d
commit
d9ee06a60d
17 changed files with 56 additions and 40 deletions
|
@ -465,6 +465,8 @@ public:
|
|||
|
||||
uint64_t GetNativeObject(NativeObject obj) override {
|
||||
switch (obj) {
|
||||
case NativeObject::CONTEXT:
|
||||
return (uint64_t)vulkan_;
|
||||
case NativeObject::FRAMEBUFFER_RENDERPASS:
|
||||
// Return a representative renderpass.
|
||||
return (uint64_t)renderManager_.GetFramebufferRenderPass();
|
||||
|
|
|
@ -2102,3 +2102,14 @@ std::vector<FramebufferInfo> FramebufferManagerCommon::GetFramebufferList() {
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
presentation_->DeviceLost();
|
||||
draw_ = nullptr;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DeviceRestore(Draw::DrawContext *draw) {
|
||||
draw_ = draw;
|
||||
presentation_->DeviceRestore(draw);
|
||||
}
|
||||
|
|
|
@ -305,6 +305,9 @@ public:
|
|||
virtual void Resized();
|
||||
virtual void DestroyAllFBOs();
|
||||
|
||||
virtual void DeviceLost();
|
||||
virtual void DeviceRestore(Draw::DrawContext *draw);
|
||||
|
||||
Draw::Framebuffer *GetTempFBO(TempFBO reason, u16 w, u16 h);
|
||||
|
||||
// Debug features
|
||||
|
|
|
@ -468,7 +468,3 @@ void FramebufferManagerD3D11::PackDepthbuffer(VirtualFramebuffer *vfb, int x, in
|
|||
|
||||
void FramebufferManagerD3D11::EndFrame() {
|
||||
}
|
||||
|
||||
void FramebufferManagerD3D11::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ public:
|
|||
void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) override;
|
||||
|
||||
void EndFrame();
|
||||
void DeviceLost();
|
||||
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
|
||||
|
||||
void BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags);
|
||||
|
|
|
@ -198,10 +198,12 @@ void GPU_D3D11::DeviceLost() {
|
|||
shaderManagerD3D11_->ClearShaders();
|
||||
drawEngine_.ClearInputLayoutMap();
|
||||
textureCacheD3D11_->Clear(false);
|
||||
framebufferManagerD3D11_->DeviceLost();
|
||||
|
||||
GPUCommon::DeviceLost();
|
||||
}
|
||||
|
||||
void GPU_D3D11::DeviceRestore() {
|
||||
GPUCommon::DeviceRestore();
|
||||
// Nothing needed.
|
||||
}
|
||||
|
||||
|
|
|
@ -559,10 +559,6 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
|
|||
void FramebufferManagerDX9::EndFrame() {
|
||||
}
|
||||
|
||||
void FramebufferManagerDX9::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
}
|
||||
|
||||
void FramebufferManagerDX9::DecimateFBOs() {
|
||||
FramebufferManagerCommon::DecimateFBOs();
|
||||
for (auto it = offscreenSurfaces_.begin(); it != offscreenSurfaces_.end(); ) {
|
||||
|
|
|
@ -47,7 +47,6 @@ public:
|
|||
void DestroyAllFBOs();
|
||||
|
||||
void EndFrame();
|
||||
void DeviceLost();
|
||||
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
|
||||
|
||||
void BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags);
|
||||
|
|
|
@ -242,13 +242,13 @@ void GPU_DX9::BuildReportingInfo() {
|
|||
|
||||
void GPU_DX9::DeviceLost() {
|
||||
// Simply drop all caches and textures.
|
||||
// FBOs appear to survive? Or no?
|
||||
shaderManagerDX9_->ClearCache(false);
|
||||
textureCacheDX9_->Clear(false);
|
||||
framebufferManagerDX9_->DeviceLost();
|
||||
GPUCommon::DeviceLost();
|
||||
}
|
||||
|
||||
void GPU_DX9::DeviceRestore() {
|
||||
GPUCommon::DeviceRestore();
|
||||
// Nothing needed.
|
||||
}
|
||||
|
||||
|
|
|
@ -389,16 +389,14 @@ void FramebufferManagerGLES::EndFrame() {
|
|||
}
|
||||
|
||||
void FramebufferManagerGLES::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
FramebufferManagerCommon::DeviceLost();
|
||||
DestroyDeviceObjects();
|
||||
presentation_->DeviceLost();
|
||||
}
|
||||
|
||||
void FramebufferManagerGLES::DeviceRestore(Draw::DrawContext *draw) {
|
||||
draw_ = draw;
|
||||
presentation_->DeviceRestore(draw);
|
||||
render_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
FramebufferManagerCommon::DeviceRestore(draw);
|
||||
CreateDeviceObjects();
|
||||
render_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
}
|
||||
|
||||
void FramebufferManagerGLES::Resized() {
|
||||
|
|
|
@ -46,7 +46,10 @@ public:
|
|||
virtual void Init() override;
|
||||
void EndFrame();
|
||||
void Resized() override;
|
||||
void DeviceLost();
|
||||
|
||||
void DeviceLost() override;
|
||||
void DeviceRestore(Draw::DrawContext *draw) override;
|
||||
|
||||
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
|
||||
|
||||
// For use when texturing from a framebuffer. May create a duplicate if target.
|
||||
|
@ -56,8 +59,6 @@ public:
|
|||
|
||||
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
|
||||
|
||||
void DeviceRestore(Draw::DrawContext *draw);
|
||||
|
||||
protected:
|
||||
// Used by ReadFramebufferToMemory and later framebuffer block copies
|
||||
void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override;
|
||||
|
|
|
@ -300,21 +300,18 @@ void GPU_GLES::DeviceLost() {
|
|||
fragmentTestCache_.DeviceLost();
|
||||
depalShaderCache_.DeviceLost();
|
||||
drawEngine_.DeviceLost();
|
||||
framebufferManagerGL_->DeviceLost();
|
||||
// Don't even try to access the lost device.
|
||||
draw_ = nullptr;
|
||||
|
||||
GPUCommon::DeviceLost();
|
||||
}
|
||||
|
||||
void GPU_GLES::DeviceRestore() {
|
||||
draw_ = (Draw::DrawContext *)PSP_CoreParameter().graphicsContext->GetDrawContext();
|
||||
INFO_LOG(G3D, "GPU_GLES: DeviceRestore");
|
||||
GPUCommon::DeviceRestore();
|
||||
|
||||
UpdateCmdInfo();
|
||||
UpdateVsyncInterval(true);
|
||||
|
||||
shaderManagerGL_->DeviceRestore(draw_);
|
||||
textureCacheGL_->DeviceRestore(draw_);
|
||||
framebufferManagerGL_->DeviceRestore(draw_);
|
||||
drawEngine_.DeviceRestore(draw_);
|
||||
fragmentTestCache_.DeviceRestore(draw_);
|
||||
depalShaderCache_.DeviceRestore(draw_);
|
||||
|
|
|
@ -468,6 +468,18 @@ void GPUCommon::Reinitialize() {
|
|||
framebufferManager_->DestroyAllFBOs();
|
||||
}
|
||||
|
||||
// Call at the END of the GPU implementation's DeviceLost
|
||||
void GPUCommon::DeviceLost() {
|
||||
framebufferManager_->DeviceLost();
|
||||
draw_ = nullptr;
|
||||
}
|
||||
|
||||
// Call at the start of the GPU implementation's DeviceRestore
|
||||
void GPUCommon::DeviceRestore() {
|
||||
draw_ = (Draw::DrawContext *)PSP_CoreParameter().graphicsContext->GetDrawContext();
|
||||
framebufferManager_->DeviceRestore(draw_);
|
||||
}
|
||||
|
||||
void GPUCommon::UpdateVsyncInterval(bool force) {
|
||||
#if !(PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS))
|
||||
int desiredVSyncInterval = g_Config.bVSync ? 1 : 0;
|
||||
|
|
|
@ -260,6 +260,9 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void DeviceLost() override;
|
||||
void DeviceRestore() override;
|
||||
|
||||
void SetDrawType(DrawType type, GEPrimitiveType prim) {
|
||||
if (type != lastDraw_) {
|
||||
// We always flush when drawing splines/beziers so no need to do so here
|
||||
|
|
|
@ -388,15 +388,12 @@ void FramebufferManagerVulkan::EndFrame() {
|
|||
}
|
||||
|
||||
void FramebufferManagerVulkan::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
FramebufferManagerCommon::DeviceLost();
|
||||
DestroyDeviceObjects();
|
||||
presentation_->DeviceLost();
|
||||
}
|
||||
|
||||
void FramebufferManagerVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw) {
|
||||
vulkan_ = vulkan;
|
||||
draw_ = draw;
|
||||
presentation_->DeviceRestore(draw);
|
||||
|
||||
void FramebufferManagerVulkan::DeviceRestore(Draw::DrawContext *draw) {
|
||||
FramebufferManagerCommon::DeviceRestore(draw);
|
||||
vulkan_ = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT);
|
||||
InitDeviceObjects();
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ public:
|
|||
void BeginFrameVulkan(); // there's a BeginFrame in the base class, which this calls
|
||||
void EndFrame();
|
||||
|
||||
void DeviceLost();
|
||||
void DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw);
|
||||
void DeviceLost() override;
|
||||
void DeviceRestore(Draw::DrawContext *draw) override;
|
||||
|
||||
int GetLineWidth();
|
||||
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
|
||||
|
||||
|
|
|
@ -526,26 +526,25 @@ void GPU_Vulkan::DeviceLost() {
|
|||
SaveCache(shaderCachePath_);
|
||||
}
|
||||
DestroyDeviceObjects();
|
||||
framebufferManagerVulkan_->DeviceLost();
|
||||
vulkan2D_.DeviceLost();
|
||||
drawEngine_.DeviceLost();
|
||||
pipelineManager_->DeviceLost();
|
||||
textureCacheVulkan_->DeviceLost();
|
||||
depalShaderCache_.DeviceLost();
|
||||
shaderManagerVulkan_->ClearShaders();
|
||||
draw_ = nullptr;
|
||||
|
||||
GPUCommon::DeviceLost();
|
||||
}
|
||||
|
||||
void GPU_Vulkan::DeviceRestore() {
|
||||
GPUCommon::DeviceRestore();
|
||||
vulkan_ = (VulkanContext *)PSP_CoreParameter().graphicsContext->GetAPIContext();
|
||||
draw_ = (Draw::DrawContext *)PSP_CoreParameter().graphicsContext->GetDrawContext();
|
||||
InitDeviceObjects();
|
||||
|
||||
CheckGPUFeatures();
|
||||
BuildReportingInfo();
|
||||
UpdateCmdInfo();
|
||||
|
||||
framebufferManagerVulkan_->DeviceRestore(vulkan_, draw_);
|
||||
vulkan2D_.DeviceRestore(vulkan_);
|
||||
drawEngine_.DeviceRestore(vulkan_, draw_);
|
||||
pipelineManager_->DeviceRestore(vulkan_);
|
||||
|
|
Loading…
Add table
Reference in a new issue