From 491ac694ab85607b291abb3a3efa017379c90cb6 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Sun, 1 Sep 2024 18:58:48 +0200 Subject: [PATCH] fix: object shader error when used with rect primitive --- .../LatteDecompilerEmitMSLHeader.hpp | 6 +++--- src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp index 615e86f9..38392bdb 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp @@ -155,7 +155,7 @@ namespace LatteDecompiler } } - static void _emitAttributes(LatteDecompilerShaderContext* decompilerContext) + static void _emitAttributes(LatteDecompilerShaderContext* decompilerContext, bool isRectVertexShader) { auto src = decompilerContext->shaderSource; std::string attributeNames; @@ -171,7 +171,7 @@ namespace LatteDecompiler cemu_assert_debug(decompilerContext->output->resourceMappingMTL.attributeMapping[i] >= 0); src->addFmt("uint4 attrDataSem{}", i); - if (decompilerContext->options->usesGeometryShader) + if (decompilerContext->options->usesGeometryShader || isRectVertexShader) attributeNames += "#define ATTRIBUTE_NAME" + std::to_string((sint32)decompilerContext->output->resourceMappingMTL.attributeMapping[i]) + " attrDataSem" + std::to_string(i) + "\n"; else src->addFmt(" [[attribute({})]]", (sint32)decompilerContext->output->resourceMappingMTL.attributeMapping[i]); @@ -268,7 +268,7 @@ namespace LatteDecompiler if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex) { - _emitAttributes(decompilerContext); + _emitAttributes(decompilerContext, isRectVertexShader); } else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel) { diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index a60b1363..6b667ec0 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -20,8 +20,6 @@ #include "HW/Latte/Renderer/Metal/MetalCommon.h" #include "HW/Latte/Renderer/Metal/MetalLayerHandle.h" #include "HW/Latte/Renderer/Renderer.h" -#include "Metal/MTLRenderCommandEncoder.hpp" -#include "imgui.h" #define IMGUI_IMPL_METAL_CPP #include "imgui/imgui_extension.h" @@ -1065,6 +1063,11 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 } // Cull mode + + // Handled in draw_beginSequence + if (cullFront && cullBack) + cemu_assert_suspicious(); + MTL::CullMode cullMode; if (cullFront) cullMode = MTL::CullModeFront;