GPU: More consistently clear ptrs on DeviceLost().

Rather get a null pointer crash than confusing buggy use-after-free
excitement.
This commit is contained in:
Unknown W. Brackets committed 2022-08-23 20:15:30 -07:00
1 parent 47b7305bf5
commit 7ec62a32b4
11 files changed
+17 -2

No files matched your search

+1 -1
View File
@@ -2437,7 +2437,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) {
+1
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) {
+1
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) {
+2
View File
@@ -91,6 +91,8 @@ DrawEngineGLES::~DrawEngineGLES() {
void DrawEngineGLES::DeviceLost() {
DestroyDeviceObjects();
draw_ = nullptr;
render_ = nullptr;
}
void DrawEngineGLES::DeviceRestore(Draw::DrawContext *draw) {
+1
View File
@@ -69,6 +69,7 @@ public:
void DeviceLost() {
Clear(false);
render_ = nullptr;
}
void DeviceRestore(Draw::DrawContext *draw);
void Clear(bool deleteThem = true);
+2
View File
@@ -620,6 +620,8 @@ void ShaderManagerGLES::ClearCache(bool deleteThem) {
void ShaderManagerGLES::DeviceLost() {
Clear();
render_ = nullptr;
draw_ = nullptr;
}
void ShaderManagerGLES::DeviceRestore(Draw::DrawContext *draw) {
+1 -1
View File
@@ -534,7 +534,7 @@ void GPU_Vulkan::DeviceLost() {
drawEngine_.DeviceLost();
pipelineManager_->DeviceLost();
textureCacheVulkan_->DeviceLost();
shaderManagerVulkan_->ClearShaders();
shaderManagerVulkan_->DeviceLost();
GPUCommon::DeviceLost();
}
+2
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) {
+4
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;
+1
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);
+1
View File
@@ -168,6 +168,7 @@ void SamplerCache::DeviceLost() {
vulkan_->Delete().QueueDeleteSampler(sampler);
});
cache_.Clear();
vulkan_ = nullptr;
}
void SamplerCache::DeviceRestore(VulkanContext *vulkan) {