载入中...
搜索中...
未找到
IndirectBuilder.cpp
浏览该文件的文档.
2
3namespace eve::graphics {
4
6 entries_.clear();
7 order_.clear();
8 commands_.clear();
9}
10
11void IndirectBuilder::add(uint32_t seq, uint32_t meshId, uint32_t materialId,
12 uint32_t pipelineId) {
13 entries_.push_back(Entry{makeKey(seq, meshId, materialId, pipelineId), seq, meshId,
14 materialId, pipelineId});
15}
16
17uint32_t IndirectBuilder::build(const std::vector<GpuMeshRecord> &meshTable) {
18 order_.clear();
19 commands_.clear();
20 order_.reserve(entries_.size());
21
22 std::vector<uint32_t> idx(entries_.size());
23 for (uint32_t i = 0; i < entries_.size(); ++i) idx[i] = i;
24 std::stable_sort(idx.begin(), idx.end(), [this](uint32_t a, uint32_t b) {
25 const Entry &ea = entries_[a];
26 const Entry &eb = entries_[b];
27 if (ea.key != eb.key) return ea.key < eb.key;
28 return ea.seq < eb.seq;
29 });
30 for (uint32_t i : idx) order_.push_back(i);
31
32 size_t i = 0;
33 while (i < idx.size()) {
34 const Entry &first = entries_[idx[i]];
35 size_t j = i + 1;
36 while (j < idx.size()) {
37 const Entry &e = entries_[idx[j]];
38 if (e.pipelineId != first.pipelineId || e.materialId != first.materialId ||
39 e.meshId != first.meshId)
40 break;
41 ++j;
42 }
43 if (first.meshId < meshTable.size()) {
44 const GpuMeshRecord &m = meshTable[first.meshId];
45 if (m.indexCount > 0) {
47 cmd.indexCount = m.indexCount;
48 cmd.instanceCount = uint32_t(j - i);
49 cmd.firstIndex = m.firstIndex;
50 cmd.vertexOffset = m.vertexBase;
51 cmd.firstInstance = uint32_t(i); // position in the sorted instance buffer
52 commands_.push_back(cmd);
53 }
54 }
55 i = j;
56 }
57 return uint32_t(commands_.size());
58}
59
60} // namespace eve::graphics
uint32_t a
uint32_t b
int idx
float m[16]
uint32_t build(const std::vector< GpuMeshRecord > &meshTable)
Sort + merge. meshTable supplies indexCount/firstIndex/vertexBase.
void add(uint32_t seq, uint32_t meshId, uint32_t materialId, uint32_t pipelineId)
seq = monotonic instance sequence (stable order tiebreak).
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
Indirect draw command; layout identical to VkDrawIndexedIndirectCommand.
GPU mesh table record (std430). Mirrors GLSL GpuMeshRecord.