mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Feat] (DirectGLES): implement transform feedback capture
Transform feedback was frontend-only on DirectGLES: glBeginTransformFeedback just flipped MobileGL's own capture state and the real ES driver was never told to capture anything, so every capture buffer read back as whatever it held before the draw (zeros for a fresh glBufferData(NULL)). DirectVulkan drives its capture from its own draw recording, so the shared GLFunctionsTable had no entries for the span at all. Capture now runs on the real driver: - The backend program declares the capture set with glTransformFeedbackVaryings before it links. SPIRV-Cross keeps user output names verbatim in the transpiled ESSL, so the frontend's requested names carry over unchanged. - New GLFunctionsTable Begin/EndTransformFeedback entries hand the span boundaries to the backend (null for DirectVulkan, which is unaffected). - The driver-side begin is deferred to the first draw of the span: ES needs the capturing program current and the capture buffers bound, and both only become true once PrepareForDraw has run. A span that never draws never touches the driver, which is what the GL semantics amount to anyway. - The end mirrors the captured ranges back into the frontend buffer shadows - the GPU wrote them behind the frontend's back, so MapBuffer/GetBufferSubData would otherwise still return the pre-draw bytes. Takes KHR-GL32.transform_feedback from 13/21 to 19/21; the two remaining failures are the geometry-amplified primitive queries, which still go through the frontend's CPU accounting.
This commit is contained in:
@@ -578,6 +578,9 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
MG_State::pGLContext->BeginTransformFeedback(primitiveMode, program);
|
||||
if (const auto beginXfb = MG_Backend::gBackendFunctionsTable.GL.BeginTransformFeedback) {
|
||||
beginXfb(primitiveMode);
|
||||
}
|
||||
}
|
||||
|
||||
// Vulkan transform feedback captures triangle strips in plain (i, i+1, i+2)
|
||||
@@ -649,6 +652,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
const auto capturedProgram = MG_State::pGLContext->GetTransformFeedbackProgram();
|
||||
const Uint64 inputPrimitives = MG_State::pGLContext->GetTransformFeedbackInputPrimitives();
|
||||
// Closed while the capture state is still active: a backend that captures
|
||||
// through its own driver reads the capture program and buffer bindings here.
|
||||
if (const auto endXfb = MG_Backend::gBackendFunctionsTable.GL.EndTransformFeedback) {
|
||||
endXfb();
|
||||
}
|
||||
MG_State::pGLContext->EndTransformFeedback();
|
||||
// Captured results must be visible to MapBuffer/GetBufferSubData after
|
||||
// End; the capture targets are host-coherent GPU memory, so completing
|
||||
|
||||
Reference in New Issue
Block a user