diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 2241a18dd3..a9769383b9 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -108,10 +108,11 @@ void DrawEngineGLES::DeviceRestore() { } void DrawEngineGLES::InitDeviceObjects() { + _assert_msg_(G3D, render_ != nullptr, "Render manager must be set"); + for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) { frameData_[i].pushVertex = render_->CreatePushBuffer(i, GL_ARRAY_BUFFER, 1024 * 1024); frameData_[i].pushIndex = render_->CreatePushBuffer(i, GL_ELEMENT_ARRAY_BUFFER, 256 * 1024); - } int vertexSize = sizeof(TransformedVertex); @@ -129,8 +130,10 @@ void DrawEngineGLES::DestroyDeviceObjects() { if (!frameData_[i].pushVertex && !frameData_[i].pushIndex) continue; - render_->DeletePushBuffer(frameData_[i].pushVertex); - render_->DeletePushBuffer(frameData_[i].pushIndex); + if (frameData_[i].pushVertex) + render_->DeletePushBuffer(frameData_[i].pushVertex); + if (frameData_[i].pushIndex) + render_->DeletePushBuffer(frameData_[i].pushIndex); frameData_[i].pushVertex = nullptr; frameData_[i].pushIndex = nullptr; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index ffef7dd59f..3e1b322e0d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -856,13 +856,16 @@ public: // PIC1 is the loading image, so let's only draw if it's available. if (ginfo && ginfo->pic1.texture) { - dc.GetDrawContext()->BindTexture(0, ginfo->pic1.texture->GetTexture()); + Draw::Texture *texture = ginfo->pic1.texture->GetTexture(); + if (texture) { + dc.GetDrawContext()->BindTexture(0, texture); - double loadTime = ginfo->pic1.timeLoaded; - uint32_t color = alphaMul(color_, ease((time_now_d() - loadTime) * 3)); - dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); - dc.Flush(); - dc.RebindTexture(); + double loadTime = ginfo->pic1.timeLoaded; + uint32_t color = alphaMul(color_, ease((time_now_d() - loadTime) * 3)); + dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); + dc.Flush(); + dc.RebindTexture(); + } } } @@ -1154,6 +1157,8 @@ void EmuScreen::render() { using namespace Draw; DrawContext *thin3d = screenManager()->getDrawContext(); + if (!thin3d) + return; // shouldn't really happen but I've seen a suspicious stack trace.. if (invalid_) { // Loading, or after shutdown? diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 3043425f61..8ca63aab67 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -650,7 +650,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, if (useCPUThread) { // This is the "GPU thread". - graphicsContext->ThreadFrame(); + if (graphicsContext) + graphicsContext->ThreadFrame(); } else { UpdateRunLoopAndroid(env); } diff --git a/ext/native/thin3d/VulkanQueueRunner.cpp b/ext/native/thin3d/VulkanQueueRunner.cpp index 6623112428..f22fa7d340 100644 --- a/ext/native/thin3d/VulkanQueueRunner.cpp +++ b/ext/native/thin3d/VulkanQueueRunner.cpp @@ -353,8 +353,6 @@ void VulkanQueueRunner::RunSteps(VkCommandBuffer cmd, std::vector &st // * Create copies of render target that are rendered to multiple times and textured from in sequence, and push those render passes // as early as possible in the frame (Wipeout billboards). - // Push down empty "Clear/Store" renderpasses, and merge them with the first "Load/Store" to the same framebuffer. - // Actually let's just bother with the first one for now. This affects Wipeout Pure. for (int j = 0; j < (int)steps.size() - 1; j++) { if (steps[j]->stepType == VKRStepType::RENDER && steps[j]->render.finalColorLayout == VK_IMAGE_LAYOUT_UNDEFINED) { @@ -362,6 +360,8 @@ void VulkanQueueRunner::RunSteps(VkCommandBuffer cmd, std::vector &st steps[j]->render.finalColorLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; } + // Push down empty "Clear/Store" renderpasses, and merge them with the first "Load/Store" to the same framebuffer. + // Actually let's just bother with the first one for now. This affects Wipeout Pure. if (steps.size() > 1 && steps[j]->stepType == VKRStepType::RENDER && steps[j]->render.numDraws == 0 && steps[j]->render.color == VKRRenderPassAction::CLEAR && diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 6f6a7dc735..ab9b828def 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -312,8 +312,13 @@ public: } VkImageView GetImageView() { - vkTex_->Touch(); - return vkTex_->GetImageView(); + if (vkTex_) { + vkTex_->Touch(); + return vkTex_->GetImageView(); + } else { + // This would be bad. + return VK_NULL_HANDLE; + } } private: