fix: object shader error when used with rect primitive

This commit is contained in:
Samuliak 2024-09-01 18:58:48 +02:00
parent 5d07d115a6
commit 491ac694ab
2 changed files with 8 additions and 5 deletions

View File

@ -155,7 +155,7 @@ namespace LatteDecompiler
} }
} }
static void _emitAttributes(LatteDecompilerShaderContext* decompilerContext) static void _emitAttributes(LatteDecompilerShaderContext* decompilerContext, bool isRectVertexShader)
{ {
auto src = decompilerContext->shaderSource; auto src = decompilerContext->shaderSource;
std::string attributeNames; std::string attributeNames;
@ -171,7 +171,7 @@ namespace LatteDecompiler
cemu_assert_debug(decompilerContext->output->resourceMappingMTL.attributeMapping[i] >= 0); cemu_assert_debug(decompilerContext->output->resourceMappingMTL.attributeMapping[i] >= 0);
src->addFmt("uint4 attrDataSem{}", i); 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"; attributeNames += "#define ATTRIBUTE_NAME" + std::to_string((sint32)decompilerContext->output->resourceMappingMTL.attributeMapping[i]) + " attrDataSem" + std::to_string(i) + "\n";
else else
src->addFmt(" [[attribute({})]]", (sint32)decompilerContext->output->resourceMappingMTL.attributeMapping[i]); src->addFmt(" [[attribute({})]]", (sint32)decompilerContext->output->resourceMappingMTL.attributeMapping[i]);
@ -268,7 +268,7 @@ namespace LatteDecompiler
if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex) if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex)
{ {
_emitAttributes(decompilerContext); _emitAttributes(decompilerContext, isRectVertexShader);
} }
else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel) else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel)
{ {

View File

@ -20,8 +20,6 @@
#include "HW/Latte/Renderer/Metal/MetalCommon.h" #include "HW/Latte/Renderer/Metal/MetalCommon.h"
#include "HW/Latte/Renderer/Metal/MetalLayerHandle.h" #include "HW/Latte/Renderer/Metal/MetalLayerHandle.h"
#include "HW/Latte/Renderer/Renderer.h" #include "HW/Latte/Renderer/Renderer.h"
#include "Metal/MTLRenderCommandEncoder.hpp"
#include "imgui.h"
#define IMGUI_IMPL_METAL_CPP #define IMGUI_IMPL_METAL_CPP
#include "imgui/imgui_extension.h" #include "imgui/imgui_extension.h"
@ -1065,6 +1063,11 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
} }
// Cull mode // Cull mode
// Handled in draw_beginSequence
if (cullFront && cullBack)
cemu_assert_suspicious();
MTL::CullMode cullMode; MTL::CullMode cullMode;
if (cullFront) if (cullFront)
cullMode = MTL::CullModeFront; cullMode = MTL::CullModeFront;