Merge pull request #15895 from unknownbrackets/gpu-minor

GPU: Correct Draw2D::DeviceRestore()
This commit is contained in:
Henrik Rydgård 2022-08-24 11:50:42 +02:00 committed by GitHub
commit 586da08820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 3 deletions

View file

@ -144,10 +144,11 @@ void Draw2D::DeviceLost() {
DoRelease(draw2DVs_);
DoRelease(draw2DSamplerLinear_);
DoRelease(draw2DSamplerNearest_);
draw_ = nullptr;
}
void Draw2D::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
}
void Draw2D::Ensure2DResources() {

View file

@ -2439,7 +2439,7 @@ void FramebufferManagerCommon::DeviceLost() {
void FramebufferManagerCommon::DeviceRestore(Draw::DrawContext *draw) {
draw_ = draw;
draw2D_.DeviceRestore(draw_);
presentation_->DeviceRestore(draw);
presentation_->DeviceRestore(draw_);
}
void FramebufferManagerCommon::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) {

View file

@ -393,6 +393,7 @@ void PresentationCommon::ShowPostShaderError(const std::string &errorString) {
void PresentationCommon::DeviceLost() {
DestroyDeviceObjects();
draw_ = nullptr;
}
void PresentationCommon::DeviceRestore(Draw::DrawContext *draw) {

View file

@ -50,6 +50,7 @@ void TextureShaderCache::DeviceRestore(Draw::DrawContext *draw) {
void TextureShaderCache::DeviceLost() {
Clear();
draw_ = nullptr;
}
ClutTexture TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) {

View file

@ -91,6 +91,8 @@ DrawEngineGLES::~DrawEngineGLES() {
void DrawEngineGLES::DeviceLost() {
DestroyDeviceObjects();
draw_ = nullptr;
render_ = nullptr;
}
void DrawEngineGLES::DeviceRestore(Draw::DrawContext *draw) {

View file

@ -69,6 +69,7 @@ public:
void DeviceLost() {
Clear(false);
render_ = nullptr;
}
void DeviceRestore(Draw::DrawContext *draw);
void Clear(bool deleteThem = true);

View file

@ -617,6 +617,8 @@ void ShaderManagerGLES::ClearCache(bool deleteThem) {
void ShaderManagerGLES::DeviceLost() {
Clear();
render_ = nullptr;
draw_ = nullptr;
}
void ShaderManagerGLES::DeviceRestore(Draw::DrawContext *draw) {

View file

@ -528,7 +528,7 @@ void GPU_Vulkan::DeviceLost() {
drawEngine_.DeviceLost();
pipelineManager_->DeviceLost();
textureCacheVulkan_->DeviceLost();
shaderManagerVulkan_->ClearShaders();
shaderManagerVulkan_->DeviceLost();
GPUCommon::DeviceLost();
}

View file

@ -26,6 +26,7 @@ PipelineManagerVulkan::~PipelineManagerVulkan() {
Clear();
if (pipelineCache_ != VK_NULL_HANDLE)
vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_);
vulkan_ = nullptr;
}
void PipelineManagerVulkan::Clear() {
@ -55,6 +56,7 @@ void PipelineManagerVulkan::DeviceLost() {
Clear();
if (pipelineCache_ != VK_NULL_HANDLE)
vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_);
vulkan_ = nullptr;
}
void PipelineManagerVulkan::DeviceRestore(VulkanContext *vulkan) {

View file

@ -160,6 +160,10 @@ ShaderManagerVulkan::~ShaderManagerVulkan() {
delete[] codeBuffer_;
}
void ShaderManagerVulkan::DeviceLost() {
draw_ = nullptr;
}
void ShaderManagerVulkan::DeviceRestore(Draw::DrawContext *draw) {
VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT);
draw_ = draw;

View file

@ -86,6 +86,7 @@ public:
ShaderManagerVulkan(Draw::DrawContext *draw);
~ShaderManagerVulkan();
void DeviceLost();
void DeviceRestore(Draw::DrawContext *draw);
void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat);

View file

@ -168,6 +168,7 @@ void SamplerCache::DeviceLost() {
vulkan_->Delete().QueueDeleteSampler(sampler);
});
cache_.Clear();
vulkan_ = nullptr;
}
void SamplerCache::DeviceRestore(VulkanContext *vulkan) {