| 10 | } |
| 11 | |
| 12 | void RendererWGPU::drawMemoryOrderImpl(const View::RenderAtomsView& atoms) { |
| 13 | if (atoms.count < 2 || !atoms.hasPositions()) { |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | std::vector<MemoryOrderVertex> verts; |
| 18 | verts.reserve((atoms.count - 1) * 2); |
| 19 | |
| 20 | const float invLastIndex = atoms.count > 1 ? 1.0f / static_cast<float>(atoms.count - 1) : 0.0f; |
| 21 | for (size_t i = 0; i + 1 < atoms.count; ++i) { |
| 22 | verts.push_back(MemoryOrderVertex{ |
| 23 | .pos = glm::vec3(atoms.x[i], atoms.y[i], atoms.z[i]), |
| 24 | .t = static_cast<float>(i) * invLastIndex, |
| 25 | }); |
| 26 | verts.push_back(MemoryOrderVertex{ |
| 27 | .pos = glm::vec3(atoms.x[i + 1], atoms.y[i + 1], atoms.z[i + 1]), |
| 28 | .t = static_cast<float>(i + 1) * invLastIndex, |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | const uint64_t bytes = verts.size() * sizeof(MemoryOrderVertex); |
| 33 | if (bytes > lineLayer_.memoryOrderVbCapacity) { |
| 34 | lineLayer_.memoryOrderVb = |
| 35 | WGPUContext::instance().createBuffer(bytes * 2, wgpu::BufferUsage::Vertex | wgpu::BufferUsage::CopyDst, "Memory_Order_Geometry"); |
| 36 | lineLayer_.memoryOrderVbCapacity = bytes * 2; |
| 37 | } |
| 38 | |
| 39 | WGPUContext::instance().queue()->writeBuffer(*lineLayer_.memoryOrderVb, 0, verts.data(), bytes); |
| 40 | |
| 41 | currentPass->setPipeline(*pipelines_.memoryOrder); |
| 42 | currentPass->setBindGroup(0, *lineLayer_.bindGroups[lineUniformSlotIndex_ - 1], 0, nullptr); |
| 43 | currentPass->setVertexBuffer(0, *lineLayer_.memoryOrderVb, 0, bytes); |
| 44 | currentPass->draw(verts.size(), 1, 0, 0); |
| 45 | } |
nothing calls this directly
no test coverage detected