25 const size_t primitiveSetsNb = builder._primitiveSets.size();
29 for (
auto& builderPrimitiveSet : builder._primitiveSets) {
33 targetPrimitiveSet.mode = builderPrimitiveSet.getMode();
34 targetPrimitiveSet.
material = builderPrimitiveSet.getMaterial();
36 auto& builderAttributes = builderPrimitiveSet.getAttributes();
38 const uint32_t attributesNb =
static_cast<uint32_t
>(builderAttributes.size());
39 targetPrimitiveSet.
attributes.resize(attributesNb);
40 primitiveSetData->
buffers.resize(attributesNb);
42 for (uint32_t j = 0; j < attributesNb; ++j) {
43 targetPrimitiveSet.
attributes[j] = builderAttributes[j];
47 targetPrimitiveSet.
texCoords.size() == 3) {
48 LUG_LOG.warn(
"Vulkan::Mesh::build: More than 3 texture coordinates, others will be ignored");
52 switch (targetPrimitiveSet.
attributes[j].type) {
79 LUG_LOG.error(
"Vulkan::Mesh::build: Can't find graphics queue");
83 bufferBuilder.setQueueFamilyIndices({graphicsQueue->getQueueFamily()->getIdx()});
84 bufferBuilder.setSize(targetPrimitiveSet.
attributes[j].buffer.size);
87 bufferBuilder.setUsage(VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
89 bufferBuilder.setUsage(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
92 VkResult result{VK_SUCCESS};
93 if (!bufferBuilder.build(primitiveSetData->
buffers[j], &result)) {
94 LUG_LOG.error(
"Vulkan::Mesh::build: Can't create buffer: {}", result);
98 targetPrimitiveSet.
attributes[j]._data =
static_cast<void*
>(&primitiveSetData->
buffers[j]);
109 targetPrimitiveSet.
_data =
static_cast<void*
>(primitiveSetData);
119 deviceMemoryBuilder.
setMemoryFlags(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
125 for (
auto& buffer : primitiveSetData->
buffers) {
126 if (!deviceMemoryBuilder.addBuffer(buffer)) {
127 LUG_LOG.error(
"Vulkan::Mesh::build: Can't add buffer to device memory");
133 VkResult result{VK_SUCCESS};
134 if (!deviceMemoryBuilder.build(mesh->
_deviceMemory, &result)) {
135 LUG_LOG.error(
"Vulkan::Mesh::build: Can't create device memory: {}", result);
143 uint32_t attributesNb =
static_cast<uint32_t
>(primitiveSet.attributes.size());
145 for (i = 0; i < attributesNb; ++i) {
146 primitiveSetData->
buffers[i].updateData(
147 primitiveSet.attributes[i].buffer.data,
148 primitiveSet.attributes[i].buffer.size
uint32_t countColor
The number of colors (maximum 3).
std::vector< Attribute * > texCoords
uint32_t positionVertexData
0 if no attribute position.
Tangent (VEC4<FLOAT> w component is a sign value (-1 or +1) indicating handedness of the tangent basi...
Describes part of a Mesh.
A Mesh, which itsef is a Resource. A mesh is composed of a vector of PrimitiveSet.
const API::Queue * getQueue(const std::string &queueName) const
Resource::SharedPtr< Material > material
Dummy class for a shared pointer.
std::vector< PrimitiveSet > _primitiveSets
uint32_t primitiveMode
The primitive mode.
Pipeline::Id::PrimitivePart pipelineIdPrimitivePart
Resource::SharedPtr< lug::Graphics::Render::Mesh > build(const ::lug::Graphics::Builder::Mesh &builder)
uint32_t normalVertexData
0 if no attribute normal.
std::vector< Attribute * > colors
std::vector< Attribute > attributes
void setMemoryFlags(VkMemoryPropertyFlags flags)
API::Device & getDevice()
std::vector< API::Buffer > buffers
API::DeviceMemory _deviceMemory
uint32_t tangentVertexData
0 if no attribute tangeant.
uint32_t countTexCoord
The number of texcoord (maximum 3).