[Feat] (MG_Backend/DirectVulkan/VertexInputStateManager): impelement VertexInputStateManager

This commit is contained in:
2026-02-09 21:31:27 +08:00
parent cd3ff1f881
commit 358efe4d1b
3 changed files with 273 additions and 1 deletions
@@ -0,0 +1,44 @@
// MobileGL - MobileGL/MG_Backend/DirectVulkan/Managers/VertexInputStateManager.h
// Copyright (c) 2025-2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
#pragma once
#include "Includes.h"
#include "MG_State/GLState/VertexArrayState/VertexArrayObject.h"
#include "Config.h"
#include "xxhash.h"
namespace MobileGL::MG_Backend::DirectVulkan {
class VertexInputStateManager {
public:
using VertexArrayObject = MobileGL::MG_State::GLState::VertexArrayObject;
using HashType = XXH64_hash_t;
struct VertexInputStateInfo {
VkPipelineVertexInputStateCreateInfo CreateInfo{VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO};
Vector<VkVertexInputBindingDescription> BindingDescriptions;
Vector<VkVertexInputAttributeDescription> AttributeDescriptions;
};
VertexInputStateManager();
~VertexInputStateManager();
VertexInputStateInfo& CreatePipelineVertexInputState(VertexArrayObject* vaoObject);
VertexInputStateInfo* GetPipelineVertexInputState(HashType hash);
VertexInputStateInfo* GetPipelineVertexInputState(VertexArrayObject* vaoObject);
private:
void Cleanup();
void PatchCreateInfoPointers(VertexInputStateInfo& stateInfo);
HashType GetHash(VertexArrayObject* vaoObject);
VkFormat ResolveVertexFormat(const MG_State::GLState::VertexAttribute& attrib) const;
Uint GetDataTypeByteSize(DataType type) const;
UnorderedMap<HashType, VertexInputStateInfo> m_vertexInputStateInfo;
XXH64_state_t* const m_hashState = XXH64_createState();
};
} // namespace MobileGL::MG_Backend::DirectVulkan