13 const std::shared_ptr<VertexFormat>& vertexFormat1)
15 std::string key = getKey(vertexFormat0, vertexFormat1);
17 auto it = _cache.find(key);
18 if (it != _cache.end()) {
22 auto layout = create(vertexFormat0, vertexFormat1);
28 std::string MetalVertexBufferLayout::getKey(
const std::shared_ptr<VertexFormat>& vertexFormat0,
29 const std::shared_ptr<VertexFormat>& vertexFormat1)
const
31 std::ostringstream oss;
33 oss << vertexFormat0->renderingHashString();
40 oss << vertexFormat1->renderingHashString();
48 std::vector<void*> MetalVertexBufferLayout::create(
const std::shared_ptr<VertexFormat>& vertexFormat0,
49 const std::shared_ptr<VertexFormat>& vertexFormat1)
52 std::vector<void*> layout;
55 auto addFormat = [&](std::shared_ptr<VertexFormat> format) {
61 bool interleaved = format->isInterleaved();
62 const char* stepMode = format->isInstancing() ?
"instance" :
"vertex";
103 layout.push_back(
nullptr);
107 addFormat(vertexFormat0);
108 addFormat(vertexFormat1);