mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-10 11:33:24 +09:00
[Perf] (MG_Pipe): the residual fill keeps unchanged object pins and a memoised vertex-buffer set keeps its hash (rd12 Espryt monolith +1%).
This commit is contained in:
@@ -133,8 +133,11 @@ namespace MobileGL::MG_Pipe {
|
|||||||
case F::GetBoundTransformFeedbackName:
|
case F::GetBoundTransformFeedbackName:
|
||||||
dst.m_boundTransformFeedbackName = ctx.GetBoundTransformFeedbackName();
|
dst.m_boundTransformFeedbackName = ctx.GetBoundTransformFeedbackName();
|
||||||
break;
|
break;
|
||||||
|
// The four object pins: assigned only when the object moved, so the residual fill of
|
||||||
|
// every draw does not pay a reference-count increment and decrement for a pointer it
|
||||||
|
// already holds (P14: one of these moves per Minecraft draw, the other three rarely).
|
||||||
case F::GetBoundVertexArray:
|
case F::GetBoundVertexArray:
|
||||||
dst.m_boundVertexArray = ctx.GetBoundVertexArray();
|
if (dst.m_boundVertexArray != ctx.GetBoundVertexArray()) dst.m_boundVertexArray = ctx.GetBoundVertexArray();
|
||||||
break;
|
break;
|
||||||
case F::GetBufferBindingSlot:
|
case F::GetBufferBindingSlot:
|
||||||
// Every global target has a slot; Index stays null - GLContext resolves it
|
// Every global target has a slot; Index stays null - GLContext resolves it
|
||||||
@@ -247,10 +250,11 @@ namespace MobileGL::MG_Pipe {
|
|||||||
dst.m_primitiveRestartIndex = ctx.GetPrimitiveRestartIndex();
|
dst.m_primitiveRestartIndex = ctx.GetPrimitiveRestartIndex();
|
||||||
break;
|
break;
|
||||||
case F::GetProgramForDispatch:
|
case F::GetProgramForDispatch:
|
||||||
dst.m_programForDispatch = ctx.GetProgramForDispatch();
|
if (dst.m_programForDispatch != ctx.GetProgramForDispatch())
|
||||||
|
dst.m_programForDispatch = ctx.GetProgramForDispatch();
|
||||||
break;
|
break;
|
||||||
case F::GetProgramForDraw:
|
case F::GetProgramForDraw:
|
||||||
dst.m_programForDraw = ctx.GetProgramForDraw();
|
if (dst.m_programForDraw != ctx.GetProgramForDraw()) dst.m_programForDraw = ctx.GetProgramForDraw();
|
||||||
break;
|
break;
|
||||||
case F::GetProvokingVertexMode:
|
case F::GetProvokingVertexMode:
|
||||||
dst.m_provokingVertexMode = ctx.GetProvokingVertexMode();
|
dst.m_provokingVertexMode = ctx.GetProvokingVertexMode();
|
||||||
@@ -291,7 +295,8 @@ namespace MobileGL::MG_Pipe {
|
|||||||
dst.m_transformFeedbackPausedPrimitiveCounter = ctx.GetTransformFeedbackPausedPrimitiveCounter();
|
dst.m_transformFeedbackPausedPrimitiveCounter = ctx.GetTransformFeedbackPausedPrimitiveCounter();
|
||||||
break;
|
break;
|
||||||
case F::GetTransformFeedbackProgram:
|
case F::GetTransformFeedbackProgram:
|
||||||
dst.m_transformFeedbackProgram = ctx.GetTransformFeedbackProgram();
|
if (dst.m_transformFeedbackProgram != ctx.GetTransformFeedbackProgram())
|
||||||
|
dst.m_transformFeedbackProgram = ctx.GetTransformFeedbackProgram();
|
||||||
break;
|
break;
|
||||||
case F::GetViewport:
|
case F::GetViewport:
|
||||||
dst.m_viewport = ctx.GetViewport();
|
dst.m_viewport = ctx.GetViewport();
|
||||||
|
|||||||
@@ -211,7 +211,9 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// a Minecraft frame binds hundreds of chunk VAOs. Not for client-memory arrays, whose
|
// a Minecraft frame binds hundreds of chunk VAOs. Not for client-memory arrays, whose
|
||||||
// entries the draw itself supplies.
|
// entries the draw itself supplies.
|
||||||
VaoMemo* memo = vao && ownedClientBuffers == nullptr ? &MemoFor(*vao) : nullptr;
|
VaoMemo* memo = vao && ownedClientBuffers == nullptr ? &MemoFor(*vao) : nullptr;
|
||||||
|
Bool memoHit = false;
|
||||||
if (memo != nullptr && memo->BuffersValid && memo->ConfigVersion == vao->GetConfigVersion()) {
|
if (memo != nullptr && memo->BuffersValid && memo->ConfigVersion == vao->GetConfigVersion()) {
|
||||||
|
memoHit = true;
|
||||||
count = memo->BufferCount;
|
count = memo->BufferCount;
|
||||||
for (SizeT i = 0; i < count; ++i) {
|
for (SizeT i = 0; i < count; ++i) {
|
||||||
m_entries[i] = memo->Buffers[i];
|
m_entries[i] = memo->Buffers[i];
|
||||||
@@ -251,6 +253,7 @@ namespace MobileGL::MG_Pipe {
|
|||||||
if (attrib.Enabled && !attrib.Buffer) memoizable = false;
|
if (attrib.Enabled && !attrib.Buffer) memoizable = false;
|
||||||
}
|
}
|
||||||
if (memo != nullptr) {
|
if (memo != nullptr) {
|
||||||
|
memo->HashValid = false;
|
||||||
memo->BuffersValid = memoizable && count <= kVaoMemoBuffers;
|
memo->BuffersValid = memoizable && count <= kVaoMemoBuffers;
|
||||||
memo->ConfigVersion = vao->GetConfigVersion();
|
memo->ConfigVersion = vao->GetConfigVersion();
|
||||||
memo->BufferCount = count;
|
memo->BufferCount = count;
|
||||||
@@ -258,7 +261,19 @@ namespace MobileGL::MG_Pipe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint64 hash = MGPipeVertexBufferSetContentHash(m_entries.data(), 0, count, baseInstance);
|
// The set's hash is a function of the entries and the base instance, so a memoised set
|
||||||
|
// keeps the one it was hashed with for as long as the base instance is the same.
|
||||||
|
Uint64 hash = 0;
|
||||||
|
if (memoHit && memo->HashValid && memo->HashBaseInstance == baseInstance) {
|
||||||
|
hash = memo->Hash;
|
||||||
|
} else {
|
||||||
|
hash = MGPipeVertexBufferSetContentHash(m_entries.data(), 0, count, baseInstance);
|
||||||
|
if (memo != nullptr && memo->BuffersValid) {
|
||||||
|
memo->Hash = hash;
|
||||||
|
memo->HashBaseInstance = baseInstance;
|
||||||
|
memo->HashValid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlot::SetVertexBuffers, hash)) {
|
if (!MGPipeSetHashSuppressorInstance().ShouldEmit(MGPipeSuppressorSlot::SetVertexBuffers, hash)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -399,6 +414,9 @@ namespace MobileGL::MG_Pipe {
|
|||||||
Bool BuffersValid = false;
|
Bool BuffersValid = false;
|
||||||
Uint32 ConfigVersion = 0;
|
Uint32 ConfigVersion = 0;
|
||||||
Uint32 BufferCount = 0;
|
Uint32 BufferCount = 0;
|
||||||
|
Bool HashValid = false;
|
||||||
|
Uint32 HashBaseInstance = 0;
|
||||||
|
Uint64 Hash = 0;
|
||||||
Array<MGPVertexBuffer, kVaoMemoBuffers> Buffers{};
|
Array<MGPVertexBuffer, kVaoMemoBuffers> Buffers{};
|
||||||
};
|
};
|
||||||
VaoMemo& MemoFor(const VertexArrayObject& vao) {
|
VaoMemo& MemoFor(const VertexArrayObject& vao) {
|
||||||
|
|||||||
Reference in New Issue
Block a user