diff --git a/lvk/LVK.cpp b/lvk/LVK.cpp index caa75160e0..8b8d70c942 100644 --- a/lvk/LVK.cpp +++ b/lvk/LVK.cpp @@ -319,6 +319,15 @@ void lvk::logShaderSource(const char* text) { LLOGL("\n"); } +uint32_t lvk::VertexInput::getVertexSize() const { + uint32_t vertexSize = 0; + for (uint32_t i = 0; i < LVK_VERTEX_ATTRIBUTES_MAX && attributes[i].format != VertexFormat::Invalid; i++) { + LVK_ASSERT_MSG(attributes[i].offset == vertexSize, "Unsupported vertex attributes foramt"); + vertexSize += lvk::getVertexFormatSize(attributes[i].format); + } + return vertexSize; +} + #if LVK_WITH_GLFW GLFWwindow* lvk::initWindow(const char* windowTitle, int& outWidth, int& outHeight, bool resizable) { if (!glfwInit()) { diff --git a/lvk/LVK.h b/lvk/LVK.h index 5c785cb2ab..c82527a760 100644 --- a/lvk/LVK.h +++ b/lvk/LVK.h @@ -543,6 +543,7 @@ struct VertexInput final { } return n; } + uint32_t getVertexSize() const; bool operator==(const VertexInput& other) const { return memcmp(this, &other, sizeof(VertexInput)) == 0;