fix: Shadow pass 接入 GPUDriven batch,实例上限提至 16384
100 背包掉帧 + 警告刷屏的根因: 1. backpack.obj 有 44 个 mesh 部件,100 实体 × 44 = 4400 实例 打爆 4096 上限 → 每帧截断 + 告警刷屏。上限提至 16384 (1MB/slot),告警改一次性 2. Shadow pass 仍逐实体逐部件画(4400 draw,CPU 提交瓶颈)。 改为与 Forward 共用同一批 batch:Set0 绑 ObjectBuffer, lightVP 一次 push,44 draw 完成。shadow.vert 经 gl_InstanceIndex 从 SSBO 取模型矩阵 实测(100 背包):GPU 总耗时 ~5.7ms(Shadow 2.9 + Forward 2.6 + 后处理 0.1),0 警告,帧率受 mailbox 垂直同步 pacing 限制
This commit is contained in:
+8
-6
@@ -1,17 +1,19 @@
|
||||
#version 450
|
||||
|
||||
// Shadow pass vertex:光源视角写深度。
|
||||
// push constant = { lightVP, model },与 Forward pass 用同一份
|
||||
// lightVP(UBO.lightSpace)和同一份 model(TransformComponent.world),
|
||||
// 保证阴影贴图与主视角几何严格一致。
|
||||
// GPUDriven:模型矩阵经 gl_InstanceIndex 从实例缓冲取(与 Forward
|
||||
// 共用同一份数据),push 只带 lightVP(全 pass 一次)。
|
||||
|
||||
layout(location = 0) in vec3 inPosition;
|
||||
|
||||
layout(push_constant) uniform ShadowPush {
|
||||
layout(std430, set = 0, binding = 1) readonly buffer ObjectBuffer {
|
||||
mat4 models[];
|
||||
} objects;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
mat4 lightVP;
|
||||
mat4 model;
|
||||
} pc;
|
||||
|
||||
void main() {
|
||||
gl_Position = pc.lightVP * pc.model * vec4(inPosition, 1.0);
|
||||
gl_Position = pc.lightVP * objects.models[gl_InstanceIndex] * vec4(inPosition, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user