Add WebGPU Backend w/ Dawn Support (#3838)
This commit is contained in:
43
src/mbgl/webgpu/vertex_attribute.cpp
Normal file
43
src/mbgl/webgpu/vertex_attribute.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <mbgl/webgpu/vertex_attribute.hpp>
|
||||
#include <mbgl/gfx/vertex_vector.hpp>
|
||||
#include <mbgl/webgpu/buffer_resource.hpp>
|
||||
#include <mbgl/webgpu/upload_pass.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
namespace mbgl {
|
||||
namespace webgpu {
|
||||
|
||||
const gfx::UniqueVertexBufferResource& VertexAttribute::getBuffer(gfx::VertexAttribute& attrib_,
|
||||
UploadPass& uploadPass,
|
||||
const gfx::BufferUsageType usage,
|
||||
bool forceUpdate) {
|
||||
if (!attrib_.getBuffer()) {
|
||||
auto& attrib = static_cast<VertexAttribute&>(attrib_);
|
||||
if (attrib.sharedRawData) {
|
||||
return uploadPass.getBuffer(attrib.sharedRawData, usage, forceUpdate);
|
||||
} else {
|
||||
if (!attrib.rawData.empty()) {
|
||||
auto buffer = uploadPass.createVertexBufferResource(
|
||||
attrib.rawData.data(), attrib.rawData.size(), usage, false);
|
||||
attrib.setBuffer(std::move(buffer));
|
||||
attrib.setRawData({});
|
||||
attrib_.setDirty(false);
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return attrib_.getBuffer();
|
||||
}
|
||||
|
||||
bool VertexAttributeArray::isModifiedAfter(std::chrono::duration<double> time) const {
|
||||
// Use the base class implementation
|
||||
return gfx::VertexAttributeArray::isModifiedAfter(time);
|
||||
}
|
||||
|
||||
} // namespace webgpu
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user