clean up accurate barriers

This commit is contained in:
Samuliak 2025-01-08 16:58:06 +01:00
parent 68d328b094
commit 27a31fedab
No known key found for this signature in database
2 changed files with 16 additions and 10 deletions

View file

@ -1031,7 +1031,11 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
endRenderPass = CheckIfRenderPassNeedsFlush(geometryShader); endRenderPass = CheckIfRenderPassNeedsFlush(geometryShader);
if (endRenderPass) if (endRenderPass)
{
EndEncoding(); EndEncoding();
// TODO: only log in debug?
cemuLog_logOnce(LogType::Force, "Ending render pass due to render target self-dependency\n");
}
} }
// Primitive type // Primitive type
@ -1871,6 +1875,11 @@ bool MetalRenderer::CheckIfRenderPassNeedsFlush(LatteDecompilerShader* shader)
const auto relative_textureUnit = shader->resourceMapping.getTextureUnitFromBindingPoint(i); const auto relative_textureUnit = shader->resourceMapping.getTextureUnitFromBindingPoint(i);
auto hostTextureUnit = relative_textureUnit; auto hostTextureUnit = relative_textureUnit;
auto textureDim = shader->textureUnitDim[relative_textureUnit]; auto textureDim = shader->textureUnitDim[relative_textureUnit];
// Texture is accessed as a framebuffer fetch, therefore there is no need to flush it
if (shader->textureRenderTargetIndex[relative_textureUnit] != 255)
continue;
auto texUnitRegIndex = hostTextureUnit * 7; auto texUnitRegIndex = hostTextureUnit * 7;
switch (shader->shaderType) switch (shader->shaderType)
{ {
@ -1895,8 +1904,7 @@ bool MetalRenderer::CheckIfRenderPassNeedsFlush(LatteDecompilerShader* shader)
continue; continue;
LatteTexture* baseTexture = textureView->baseTexture; LatteTexture* baseTexture = textureView->baseTexture;
if (!m_state.m_isFirstDrawInRenderPass)
{
// If the texture is also used in the current render pass, we need to end the render pass to "flush" the texture // If the texture is also used in the current render pass, we need to end the render pass to "flush" the texture
for (uint8 i = 0; i < LATTE_NUM_COLOR_TARGET; i++) for (uint8 i = 0; i < LATTE_NUM_COLOR_TARGET; i++)
{ {
@ -1905,7 +1913,6 @@ bool MetalRenderer::CheckIfRenderPassNeedsFlush(LatteDecompilerShader* shader)
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -125,8 +125,7 @@ struct MetalState
MetalActiveFBOState m_lastUsedFBO; MetalActiveFBOState m_lastUsedFBO;
size_t m_vertexBufferOffsets[MAX_MTL_VERTEX_BUFFERS]; size_t m_vertexBufferOffsets[MAX_MTL_VERTEX_BUFFERS];
// TODO: find out what is the max number of bound textures on the Wii U class LatteTextureViewMtl* m_textures[LATTE_NUM_MAX_TEX_UNITS] = {nullptr};
class LatteTextureViewMtl* m_textures[64] = {nullptr};
size_t m_uniformBufferOffsets[METAL_GENERAL_SHADER_TYPE_TOTAL][MAX_MTL_BUFFERS]; size_t m_uniformBufferOffsets[METAL_GENERAL_SHADER_TYPE_TOTAL][MAX_MTL_BUFFERS];
MTL::Viewport m_viewport; MTL::Viewport m_viewport;