diff --git a/openVulkanoCpp/Scene/VertexInputDescription.hpp b/openVulkanoCpp/Scene/VertexInputDescription.hpp new file mode 100644 index 0000000..f04a58c --- /dev/null +++ b/openVulkanoCpp/Scene/VertexInputDescription.hpp @@ -0,0 +1,54 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "DataFormat.hpp" + +namespace openVulkanoCpp +{ + struct VertexInputParameter + { + uint32_t location; + uint32_t binding; + DataFormat format; + uint32_t offset; + + VertexInputParameter(uint32_t location, uint32_t binding, DataFormat format, uint32_t offset) + : location(location), binding(binding), format(format), offset(offset) + {} + + VertexInputParameter(size_t location, uint32_t binding, DataFormat format, uint32_t offset) + : location(location), binding(binding), format(format), offset(offset) + {} + }; + + struct VertexInputDescription + { + uint32_t bindingId; + uint32_t vertexSize; + std::vector inputParameters; + + VertexInputDescription(uint32_t bindingId, uint32_t vertexSize) : bindingId(bindingId), vertexSize(vertexSize) + {} + + VertexInputDescription(uint32_t bindingId, const VertexInputDescription& vertexDescription) + : bindingId(bindingId), vertexSize(vertexDescription.vertexSize), inputParameters(vertexDescription.inputParameters) + { + for (auto& param : inputParameters) + { + param.binding = bindingId; + } + } + + VertexInputDescription& AddInputParameter(DataFormat format, uint32_t offset) + { + if (offset >= vertexSize) throw std::runtime_error("VertexInputParameter offset cannot be greater than vertex size"); + inputParameters.emplace_back(inputParameters.size(), bindingId, format, offset); + return *this; + } + }; +}