| 45 | {} |
| 46 | |
| 47 | void Build(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program) override |
| 48 | { |
| 49 | m_geometryBuffers.resize(m_mesh->m_buffers.size()); |
| 50 | m_bindingInfoCount = static_cast<uint8_t>(m_mesh->m_buffers.size()); |
| 51 | CHECK_LESS_OR_EQUAL(m_bindingInfoCount, kMaxBindingInfo, ()); |
| 52 | for (size_t i = 0; i < m_mesh->m_buffers.size(); i++) |
| 53 | { |
| 54 | auto const sizeInBytes = m_mesh->m_buffers[i]->GetSizeInBytes(); |
| 55 | if (sizeInBytes == 0) |
| 56 | continue; |
| 57 | |
| 58 | m_geometryBuffers[i] = |
| 59 | m_objectManager->CreateBuffer(VulkanMemoryManager::ResourceType::Geometry, sizeInBytes, 0 /* batcherHash */); |
| 60 | SET_DEBUG_NAME_VK(VK_OBJECT_TYPE_BUFFER, m_geometryBuffers[i].m_buffer, |
| 61 | ("VB: Mesh (" + m_mesh->m_debugName + ") " + std::to_string(i)).c_str()); |
| 62 | |
| 63 | m_objectManager->Fill(m_geometryBuffers[i], m_mesh->m_buffers[i]->GetData(), sizeInBytes); |
| 64 | |
| 65 | m_bindingInfo[i] = |
| 66 | dp::BindingInfo(static_cast<uint8_t>(m_mesh->m_buffers[i]->m_attributes.size()), static_cast<uint8_t>(i)); |
| 67 | for (size_t j = 0; j < m_mesh->m_buffers[i]->m_attributes.size(); ++j) |
| 68 | { |
| 69 | auto const & attr = m_mesh->m_buffers[i]->m_attributes[j]; |
| 70 | auto & binding = m_bindingInfo[i].GetBindingDecl(static_cast<uint16_t>(j)); |
| 71 | binding.m_attributeName = attr.m_attributeName; |
| 72 | binding.m_componentCount = static_cast<uint8_t>(attr.m_componentsCount); |
| 73 | binding.m_componentType = gl_const::GLFloatType; |
| 74 | binding.m_offset = static_cast<uint8_t>(attr.m_offset); |
| 75 | CHECK_LESS_OR_EQUAL(m_mesh->m_buffers[i]->GetStrideInBytes(), |
| 76 | static_cast<uint32_t>(std::numeric_limits<uint8_t>::max()), ()); |
| 77 | binding.m_stride = static_cast<uint8_t>(m_mesh->m_buffers[i]->GetStrideInBytes()); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if (!m_mesh->m_indices.empty()) |
| 82 | { |
| 83 | auto const sizeInBytes = static_cast<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t)); |
| 84 | m_indexBuffer = |
| 85 | m_objectManager->CreateBuffer(VulkanMemoryManager::ResourceType::Geometry, sizeInBytes, 0 /* batcherHash */); |
| 86 | SET_DEBUG_NAME_VK(VK_OBJECT_TYPE_BUFFER, m_indexBuffer.m_buffer, |
| 87 | ("IB: Mesh (" + m_mesh->m_debugName + ")").c_str()); |
| 88 | |
| 89 | m_objectManager->Fill(m_indexBuffer, m_mesh->m_indices.data(), sizeInBytes); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | void Reset() override |
| 94 | { |
nothing calls this directly
no test coverage detected