From bbed00751f459241852d95b98cc544b7f79d9d63 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Wed, 28 Aug 2024 20:09:45 +0200 Subject: [PATCH] hack: don't attempt to compile shaders with errors --- src/Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.cpp | 6 ++++++ src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.cpp | 8 ++++++++ src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.cpp index ad63a041..ade541ba 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.cpp @@ -350,6 +350,12 @@ MTL::RenderPipelineState* MetalPipelineCache::GetRenderPipelineState(const Latte auto mtlVertexShader = static_cast(vertexShader->shader); auto mtlPixelShader = static_cast(pixelShader->shader); mtlVertexShader->CompileVertexFunction(); + // HACK + if (!mtlVertexShader->GetFunction()) + { + debug_printf("no vertex function, skipping draw\n"); + return nullptr; + } mtlPixelShader->CompileFragmentFunction(activeFBO); // Render pipeline state diff --git a/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.cpp b/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.cpp index 4c968d1c..6ad72d87 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.cpp @@ -218,12 +218,20 @@ void RendererShaderMtl::Compile(const std::string& mslCode) if (m_function) m_function->release(); + // HACK + if (m_hasError) + return; + NS::Error* error = nullptr; MTL::Library* library = m_mtlr->GetDevice()->newLibrary(ToNSString(mslCode), nullptr, &error); if (error) { printf("failed to create library (error: %s) -> source:\n%s\n", error->localizedDescription()->utf8String(), mslCode.c_str()); error->release(); + + // HACK + m_hasError = true; + return; } m_function = library->newFunction(ToNSString("main0")); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.h b/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.h index e21db55e..ca5a0ff9 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/RendererShaderMtl.h @@ -63,5 +63,8 @@ private: std::vector m_binary; std::string m_mslCode; + // HACK + bool m_hasError = false; + void Compile(const std::string& mslCode); };