26 std::vector<World3DGPUIndexedBatch> result;
28 for (
const auto node :
slot.visibleOrder())
30 const auto*
object =
slot.find(node);
31 if (
object ==
nullptr || !object->screenBounds || !object->asset ||
32 !object->asset->renderData)
35 const auto renderData =
object->renderData ?
36 object->renderData :
object->asset->renderData;
37 if (!renderData)
continue;
38 auto gpu =
cache.resolveForScene(object->asset);
39 if (!gpu)
return std::unexpected(gpu.error());
41 if (renderData != object->asset->renderData)
43 auto dynamic =
cache.resolveDynamicVertices(object->node,
44 object->asset, renderData);
46 vertexBuffer = (*dynamic)->vertexBuffer;
49 result.reserve(result.size() + renderData->batches.size());
51 for (
const auto&
batch : renderData->batches)
53 if (
batch.firstIndex > std::numeric_limits<std::uint32_t>::max() ||
54 batch.indexCount > std::numeric_limits<std::uint32_t>::max())
57 "GPU draw batch exceeds 32-bit indexed draw range"});
62 gpuTexture = (*gpu)->texture(
batch.texture->key);
63 if (gpuTexture ==
nullptr)
66 "textured HMD batch has no uploaded SDL_GPU texture"});
69 std::array<SDL_GPUTextureSamplerBinding, 5> modernTextures{};
70 const std::array<const std::optional<data::ModernTextureBinding>*, 5>
maps{
71 &
batch.material.baseColorTexture, &
batch.material.metallicRoughnessTexture,
72 &
batch.material.normalTexture, &
batch.material.emissiveTexture,
73 &
batch.material.occlusionTexture};
81 "modern map has no uploaded immutable GPU texture"});
86 object->contentsDataId,
89 object->worldTransform,
90 *
object->screenBounds,
94 static_cast<std::uint32_t
>(
batch.firstIndex),
95 static_cast<std::uint32_t
>(
batch.indexCount),
98 batch.texture, modernTextures});