Skip to content

Commit

Permalink
Remove obsolete buffer allocation (maplibre#2361)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSylvester authored May 6, 2024
1 parent be1ba59 commit db1f47a
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/mbgl/mtl/upload_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,12 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
constexpr std::size_t align = 16;
constexpr std::uint8_t padding = 0;

std::vector<std::uint8_t> allData;
allData.reserve((defaults.getTotalSize() + align) * vertexCount);

uint32_t vertexStride = 0;

// For each attribute in the program, with the corresponding default and optional override...
const auto resolveAttr = [&](const size_t id, auto& default_, auto& override_) -> void {
auto& effectiveAttr = override_ ? *override_ : default_;
const auto& defaultAttr = static_cast<const VertexAttribute&>(default_);
const auto stride = defaultAttr.getStride();
const auto offset = static_cast<uint32_t>(allData.size());
const auto index = static_cast<std::size_t>(defaultAttr.getIndex());

bindings.resize(std::max(bindings.size(), index + 1));
Expand Down Expand Up @@ -222,24 +217,6 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
};
defaults.resolve(overrides, resolveAttr);

assert(vertexStride * vertexCount <= allData.size());

if (!allData.empty()) {
if (auto vertBuf = createVertexBufferResource(allData.data(), allData.size(), usage, /*persistent=*/false)) {
// Fill in the buffer in each binding that was generated without its own buffer
std::for_each(bindings.begin(), bindings.end(), [&](auto& b) {
if (b && !b->vertexBufferResource) {
b->vertexBufferResource = vertBuf.get();
}
});

outBuffers.emplace_back(std::move(vertBuf));
} else {
assert(false);
return {};
}
}

return bindings;
}

Expand Down

0 comments on commit db1f47a

Please sign in to comment.