From 6922ee7e528e171dade2fad42155035f370a8cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 18 Dec 2022 21:58:20 +0100 Subject: [PATCH] Add some asserts in the hope of gathering some more info (and consolidating some crashes). --- Common/GPU/OpenGL/GLRenderManager.h | 4 +++- Common/GPU/OpenGL/thin3d_gl.cpp | 9 +++++---- Common/GPU/Vulkan/VulkanRenderManager.cpp | 1 + UI/NativeApp.cpp | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index 52ac971cec..e2d132726f 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -796,7 +796,9 @@ public: } void SetBlendAndMask(int colorMask, bool blendEnabled, GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha, GLenum funcColor, GLenum funcAlpha) { - _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER); + // Make this one only a non-debug _assert_, since it often comes first. + // Lets us collect info about this potential crash through assert extra data. + _assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER); GLRRenderData data{ GLRRenderCommand::BLEND }; data.blend.mask = colorMask; data.blend.enabled = blendEnabled; diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index b7737bd919..839a1e3a23 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -281,8 +281,7 @@ private: class OpenGLPipeline : public Pipeline { public: - OpenGLPipeline(GLRenderManager *render) : render_(render) { - } + OpenGLPipeline(GLRenderManager *render) : render_(render) {} ~OpenGLPipeline() { for (auto &iter : shaders) { iter->Release(); @@ -1142,17 +1141,19 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc, const iter->AddRef(); pipeline->shaders.push_back(static_cast(iter)); } else { - ERROR_LOG(G3D, "ERROR: Tried to create graphics pipeline %s with a null shader module", tag); + ERROR_LOG(G3D, "ERROR: Tried to create graphics pipeline %s with a null shader module", tag ? tag : "no tag"); delete pipeline; return nullptr; } } + if (desc.uniformDesc) { pipeline->dynamicUniforms = *desc.uniformDesc; } pipeline->samplers_ = desc.samplers; if (pipeline->LinkShaders(desc)) { + _assert_((u32)desc.prim < ARRAY_SIZE(primToGL)); // Build the rest of the virtual pipeline object. pipeline->prim = primToGL[(int)desc.prim]; pipeline->depthStencil = (OpenGLDepthStencilState *)desc.depthStencil; @@ -1161,7 +1162,7 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc, const pipeline->inputLayout = (OpenGLInputLayout *)desc.inputLayout; return pipeline; } else { - ERROR_LOG(G3D, "Failed to create pipeline %s - shaders failed to link", tag); + ERROR_LOG(G3D, "Failed to create pipeline %s - shaders failed to link", tag ? tag : "no tag"); delete pipeline; return nullptr; } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 6eb24de9ef..9affdc590e 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -635,6 +635,7 @@ void VulkanRenderManager::EndCurRenderStep() { for (VKRGraphicsPipeline *pipeline : pipelinesToCheck_) { if (!pipeline->pipeline[(size_t)rpType]) { pipeline->pipeline[(size_t)rpType] = Promise::CreateEmpty(); + _assert_(renderPass); compileQueue_.push_back(CompileQueueEntry(pipeline, renderPass->Get(vulkan_, rpType, sampleCount), rpType, sampleCount)); needsCompile = true; } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9d127c155a..d043883544 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -876,6 +876,8 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { Core_SetGraphicsContext(graphicsContext); g_draw = graphicsContext->GetDrawContext(); + _assert_(g_draw); + if (!CreateGlobalPipelines()) { ERROR_LOG(G3D, "Failed to create global pipelines"); return false;