mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
simplify texture readback
This commit is contained in:
parent
28aef858f2
commit
6bb191212b
@ -25,8 +25,6 @@ void LatteTextureReadbackInfoMtl::StartTransfer()
|
||||
blitCommandEncoder->copyFromTexture(baseTexture->GetTexture(), 0, 0, MTL::Origin{0, 0, 0}, MTL::Size{(uint32)baseTexture->width, (uint32)baseTexture->height, 1}, m_mtlr->GetTextureReadbackBuffer(), m_bufferOffset, bytesPerRow, bytesPerImage);
|
||||
|
||||
m_commandBuffer = m_mtlr->GetCurrentCommandBuffer();
|
||||
m_mtlr->RequestSoonCommit();
|
||||
m_mtlr->RequestCommitOnIdle();
|
||||
}
|
||||
|
||||
bool LatteTextureReadbackInfoMtl::IsFinished()
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "HW/Latte/Renderer/Metal/MetalCommon.h"
|
||||
#include "gui/guiWrapper.h"
|
||||
|
||||
#define DEFAULT_COMMIT_TRESHOLD 256
|
||||
#define COMMIT_TRESHOLD 256
|
||||
|
||||
extern bool hasValidFramebufferAttached;
|
||||
|
||||
@ -297,7 +297,7 @@ bool MetalRenderer::BeginFrame(bool mainWindow)
|
||||
|
||||
void MetalRenderer::Flush(bool waitIdle)
|
||||
{
|
||||
if (m_commitOnIdle || m_recordedDrawcalls > 0)
|
||||
if (m_recordedDrawcalls > 0)
|
||||
CommitCommandBuffer();
|
||||
if (waitIdle)
|
||||
{
|
||||
@ -308,8 +308,8 @@ void MetalRenderer::Flush(bool waitIdle)
|
||||
|
||||
void MetalRenderer::NotifyLatteCommandProcessorIdle()
|
||||
{
|
||||
if (m_commitOnIdle)
|
||||
CommitCommandBuffer();
|
||||
//if (m_commitOnIdle)
|
||||
// CommitCommandBuffer();
|
||||
}
|
||||
|
||||
void MetalRenderer::AppendOverlayDebugInfo()
|
||||
@ -1055,7 +1055,7 @@ void MetalRenderer::draw_endSequence()
|
||||
bool hasReadback = LatteTextureReadback_Update();
|
||||
m_recordedDrawcalls++;
|
||||
// The number of draw calls needs to twice as big, since we are interrupting the render pass
|
||||
if (m_recordedDrawcalls >= m_commitTreshold * 2 || hasReadback)
|
||||
if (m_recordedDrawcalls >= COMMIT_TRESHOLD * 2 || hasReadback)
|
||||
{
|
||||
CommitCommandBuffer();
|
||||
|
||||
@ -1320,16 +1320,14 @@ void MetalRenderer::EndEncoding()
|
||||
m_encoderType = MetalEncoderType::None;
|
||||
|
||||
// Commit the command buffer if enough draw calls have been recorded
|
||||
if (m_recordedDrawcalls >= m_commitTreshold)
|
||||
if (m_recordedDrawcalls >= COMMIT_TRESHOLD)
|
||||
CommitCommandBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
void MetalRenderer::CommitCommandBuffer()
|
||||
{
|
||||
m_commitTreshold = DEFAULT_COMMIT_TRESHOLD;
|
||||
m_recordedDrawcalls = 0;
|
||||
m_commitOnIdle = false;
|
||||
|
||||
if (m_commandBuffers.size() != 0)
|
||||
{
|
||||
|
@ -375,16 +375,6 @@ public:
|
||||
return m_state.m_encoderState;
|
||||
}
|
||||
|
||||
void RequestSoonCommit()
|
||||
{
|
||||
m_commitTreshold = m_recordedDrawcalls + 8;
|
||||
}
|
||||
|
||||
void RequestCommitOnIdle()
|
||||
{
|
||||
m_commitOnIdle = true;
|
||||
}
|
||||
|
||||
void SetBuffer(MTL::RenderCommandEncoder* renderCommandEncoder, MetalShaderType shaderType, MTL::Buffer* buffer, size_t offset, uint32 index);
|
||||
void SetTexture(MTL::RenderCommandEncoder* renderCommandEncoder, MetalShaderType shaderType, MTL::Texture* texture, uint32 index);
|
||||
void SetSamplerState(MTL::RenderCommandEncoder* renderCommandEncoder, MetalShaderType shaderType, MTL::SamplerState* samplerState, uint32 index);
|
||||
@ -485,9 +475,7 @@ private:
|
||||
MTL::CommandEncoder* m_commandEncoder = nullptr;
|
||||
CA::MetalDrawable* m_drawable = nullptr;
|
||||
|
||||
uint32 m_commitTreshold = 0;
|
||||
uint32 m_recordedDrawcalls = 0;
|
||||
bool m_commitOnIdle = false;
|
||||
|
||||
// State
|
||||
MetalState m_state;
|
||||
|
Loading…
Reference in New Issue
Block a user