perf(graphics): frustum culling, once-per-frame lighting, drop GPU particle round-trip

- Mesh gains a model-space bounding sphere; RenderSystem3D now walks the ECS
  once per frame and culls draw units against the camera frustum (forward /
  G-buffer) and per-cascade light frustums (CSM) instead of re-walking the
  whole scene five times with no culling.
- Camera matrices, lighting packs and the clustered light table are resolved
  once per camera per frame; per-draw lighting becomes a cheap state toggle
  via the new Graphics::setMesh3DClusteredActive (Vulkan + WebGPU).
- The pseudo-GPU particle path (per-emitter upload -> dispatch -> synchronous
  readback every frame) is disabled; particles integrate on the CPU until a
  GPU-resident render path exists.
This commit is contained in:
西风逍遥游 committed 2026-08-19 23:46:16 +08:00
1 parent 7a56c804bd
commit da57cce5bb
10 files changed
+420 -220

No files matched your search

+5
View File
@@ -1597,6 +1597,7 @@ Mesh *Graphics::newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, cons
auto *mesh = new Mesh();
mesh->indexCount = indexCount;
mesh->gpuHandle = gpu.get();
mesh->computeBounds(posXYZ, vertexCount);
ownedGpuMeshes.push_back(std::move(gpu));
ownedMeshes.push_back(std::unique_ptr<Mesh>(mesh));
return mesh;
@@ -1671,6 +1672,7 @@ bool Graphics::bakeMeshMorph(Mesh *mesh) {
std::vector<float> pos, nrm;
mesh->computeMorphedPositions(pos, nrm);
if (pos.empty()) return false;
mesh->computeBounds(pos.data(), mesh->getVertexCount());
std::vector<float> verts;
verts.reserve(mesh->getVertexCount() * 8);
const auto &uvs = mesh->baseUv();
@@ -2292,6 +2294,9 @@ void Graphics::setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)
mesh3dClustered = upload;
mesh3dClusteredActive = upload.active;
}
void Graphics::setMesh3DClusteredActive(bool active) {
mesh3dClusteredActive = active;
}
void Graphics::setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) {
mesh3dLighting.lights[0].posRadius = glm::vec4(dir, 0.f);
mesh3dLighting.lights[0].color = glm::vec4(color, 1.f);