mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 12:48:32 +09:00
[Feat] (MG_Impl, MG_Backend, MG_State): implement glMultiDrawArrays and glGetBufferSubData
Two previously-stubbed GL 3.3 Core entry points. glMultiDrawArrays: mirrors the existing glMultiDrawElements(BaseVertex) architecture end to end -- a new MultiDrawArrays backend function-table slot dispatched from the frontend after program/primitive-mode validation (plus a drawcount < 0 -> GL_INVALID_VALUE guard). - DirectGLES: PrepareForDraw once, then loop native glDrawArrays with the same per-range client-side array upload the single DrawArrays does. - DirectVulkan: build a MultiDrawCmd payload and hand it to a new VulkanRenderer::MultiDrawArrays, which does one SetupDraw over the union of the sub-draw vertex ranges and then a vkCmdDraw per range (mirrors VulkanRenderer::MultiDrawElements). glGetBufferSubData: reads a range of the bound buffer's CPU shadow into client memory via a new BufferObject::DownloadSubData, with the same validation shape as BufferSubData (INVALID_VALUE for negative/overflowing range, INVALID_OPERATION for no bound buffer or a non-persistent mapped buffer). The shadow reflects CPU writes and backend write-backs but not arbitrary GPU-side writes, which is documented on the method. Tests: 2 BufferTest cases for glGetBufferSubData (round-trip read of a middle range and the whole buffer, plus out-of-range/negative/no-buffer errors). BufferTest 32/32, SanityTest 30/30, VertexArrayTest 42/42; library builds clean. (The glMultiDrawArrays draw paths are not runtime-testable on this host and are compile-verified against the tested MultiDrawElements pattern.)
This commit is contained in:
@@ -116,6 +116,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MG_Backend::gBackendFunctionsTable.GL.DrawArrays(mode, first, count);
|
||||
}
|
||||
|
||||
void MultiDrawArrays_Backend(GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
MG_Backend::gBackendFunctionsTable.GL.MultiDrawArrays(mode, first, count, drawcount);
|
||||
}
|
||||
|
||||
void DrawElementsBaseVertex_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||
GLint basevertex) {
|
||||
#ifdef TRACY_ENABLE
|
||||
@@ -426,6 +433,18 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
DrawArrays_Backend(mode, first, count);
|
||||
}
|
||||
|
||||
void MultiDrawArrays(GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount) {
|
||||
if (!ValidateCurrentProgramForExecution(__func__)) return;
|
||||
if (!ValidatePrimitiveModeForBackend(__func__, mode)) return;
|
||||
if (drawcount < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "drawcount must be non-negative."));
|
||||
return;
|
||||
}
|
||||
MultiDrawArrays_Backend(mode, first, count, drawcount);
|
||||
}
|
||||
|
||||
void MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
|
||||
GLsizei drawcount) {
|
||||
if (!ValidateCurrentProgramForExecution(__func__)) return;
|
||||
|
||||
Reference in New Issue
Block a user