handle special state 8 and 5

This commit is contained in:
Samuliak 2024-11-05 17:13:34 +01:00
parent 07c62d5f95
commit ea0a30b564
No known key found for this signature in database
2 changed files with 35 additions and 5 deletions

View File

@ -20,10 +20,6 @@
#include "Cemu/Logging/CemuLogging.h"
#include "Cafe/HW/Latte/Core/FetchShader.h"
#include "Cafe/HW/Latte/Core/LatteConst.h"
#include "Cafe/HW/Latte/Renderer/Metal/MetalCommon.h"
#include "Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.h"
#include "Cafe/HW/Latte/Renderer/Renderer.h"
#include "HW/Latte/Renderer/Metal/MetalPipelineCompiler.h"
#include "config/CemuConfig.h"
#define IMGUI_IMPL_METAL_CPP
@ -34,6 +30,9 @@ extern bool hasValidFramebufferAttached;
float supportBufferData[512 * 4];
// Defined in the OpenGL renderer
void LatteDraw_handleSpecialState8_clearAsDepth();
MetalRenderer::MetalRenderer()
{
m_device = MTL::CreateSystemDefaultDevice();
@ -827,7 +826,19 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
return;
}
// TODO: special state 8 and 5
// fast clear color as depth
if (LatteGPUState.contextNew.GetSpecialStateValues()[8] != 0)
{
LatteDraw_handleSpecialState8_clearAsDepth();
LatteGPUState.drawCallCounter++;
return;
}
else if (LatteGPUState.contextNew.GetSpecialStateValues()[5] != 0)
{
draw_handleSpecialState5();
LatteGPUState.drawCallCounter++;
return;
}
auto& encoderState = m_state.m_encoderState;
@ -1254,6 +1265,23 @@ void MetalRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader*
}
}
void MetalRenderer::draw_handleSpecialState5()
{
LatteMRT::UpdateCurrentFBO();
LatteRenderTarget_updateViewport();
LatteTextureView* colorBuffer = LatteMRT::GetColorAttachment(0);
LatteTextureView* depthBuffer = LatteMRT::GetDepthAttachment();
sint32 vpWidth, vpHeight;
LatteMRT::GetVirtualViewportDimensions(vpWidth, vpHeight);
surfaceCopy_copySurfaceWithFormatConversion(
depthBuffer->baseTexture, depthBuffer->firstMip, depthBuffer->firstSlice,
colorBuffer->baseTexture, colorBuffer->firstMip, colorBuffer->firstSlice,
vpWidth, vpHeight);
}
void* MetalRenderer::indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex)
{
auto& bufferAllocator = m_memoryManager->GetTemporaryBufferAllocator();

View File

@ -263,6 +263,8 @@ public:
void draw_updateVertexBuffersDirectAccess();
void draw_updateUniformBuffersDirectAccess(LatteDecompilerShader* shader, const uint32 uniformBufferRegOffset);
void draw_handleSpecialState5();
// index
void* indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) override;
void indexData_uploadIndexMemory(uint32 bufferIndex, uint32 offset, uint32 size) override;