fix: GPUDriven batch lookup 索引语义混淆——多实体共享 mesh 越界崩溃
ViewScratch.lookup 误存 worlds 索引却被当 batches 索引用。单实体时 每个 mesh 恰好只出现一次、两序号恒等,潜伏不炸;多实体共享同一 Model(2x2 实例网格实测)后 worlds 与 batches 分叉,first-insert 用 worlds.size() 索引 batches → vector 断言越界。 修:lookup 存 batches 索引,batch.first(GPU firstInstance 基址) 保持 worlds 索引,两语义各归其位。
This commit is contained in:
@@ -303,8 +303,12 @@ namespace Engine
|
|||||||
instanceTruncated = true;
|
instanceTruncated = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// lookup 值 = batches 索引(此前误存 worlds 索引:
|
||||||
|
// 单实体时两序号恰好恒等,多实体共享 mesh 后分叉
|
||||||
|
// → batches[worldsIdx] 越界)。batch.first(GPU
|
||||||
|
// firstInstance 基址)才是 worlds 索引,语义别混
|
||||||
const auto [it, inserted] = s.lookup.emplace(
|
const auto [it, inserted] = s.lookup.emplace(
|
||||||
mesh.get(), static_cast<u32>(s.worlds.size()));
|
mesh.get(), static_cast<u32>(s.result.batches.size()));
|
||||||
if (inserted) {
|
if (inserted) {
|
||||||
s.result.batches.push_back({mesh.get(),
|
s.result.batches.push_back({mesh.get(),
|
||||||
static_cast<u32>(s.worlds.size()), 0});
|
static_cast<u32>(s.worlds.size()), 0});
|
||||||
|
|||||||
Reference in New Issue
Block a user