From bc018c9513535eaef407c30da55e8a3aa857a5bb Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 18 Mar 2026 13:25:10 +0800 Subject: [PATCH] [Chore] (MG_Backend/DirectVulkan): add `indexBufferView` field for draw cmds --- MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp | 8 ++++---- .../MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp | 2 +- .../MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp b/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp index 0d7fedfc..c4cadc97 100644 --- a/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp @@ -67,8 +67,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { DrawIndexedCmd payload{}; payload.mode = mode; - payload.indexType = type; - payload.indexByteOffset = reinterpret_cast(indices); + payload.indexBufferView.indexType = type; + payload.indexBufferView.indexByteOffset = reinterpret_cast(indices); payload.indexCount = count; payload.instanceCount = 1; @@ -107,8 +107,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { MOBILEGL_ASSERT(MG_State::pGLContext, "DirectVulkan::DrawElementsBaseVertex called with null GL context"); DrawIndexedCmd payload{}; payload.mode = mode; - payload.indexType = type; - payload.indexByteOffset = reinterpret_cast(indices); + payload.indexBufferView.indexType = type; + payload.indexBufferView.indexByteOffset = reinterpret_cast(indices); payload.indexCount = count; payload.instanceCount = 1; payload.firstIndex = 0; diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp index f487b7fd..2650cde1 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp @@ -1269,7 +1269,7 @@ void main() { auto& frame = m_frameContext.GetCurrent(); SetupDraw(frame, payload.mode, DrawSetupAspect::IndexBuffer, - payload.indexType, payload.indexByteOffset, payload.indexCount); + payload.indexBufferView.indexType, payload.indexBufferView.indexByteOffset, payload.indexCount); MOBILEGL_ASSERT(frame.isCommandRecording, "%s: frame recording was not started", __func__); diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h index ae5a4bb5..f205a544 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h @@ -54,9 +54,13 @@ namespace MobileGL::MG_Backend::DirectVulkan { Uint32 firstInstance = 0; }; - struct DrawIndexedCmd: public DrawBaseCmd { + struct IndexBufferView { GLenum indexType = GL_UNSIGNED_SHORT; SizeT indexByteOffset = 0; + }; + + struct DrawIndexedCmd: public DrawBaseCmd { + IndexBufferView indexBufferView; Uint32 indexCount = 0; Uint32 instanceCount = 1;