render: draw tri-groups as index sub-ranges of one resident mesh

Render3DDraw/HardwareBatch carry first_index/index_count; resident
meshes are uploaded once per model and groups draw with firstIndex.
Bumps sdk to 9ec7fa1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 16:27:05 +09:00
co-authored by Claude Opus 5.5
parent d5333745c5
commit f03f63e700
6 changed files with 53 additions and 19 deletions
+15
View File
@@ -138,6 +138,21 @@ int main() {
pixels=frame({offscreen,left,right});
assert(resident.GetLastDrawCallCount()==2 && redAt(16)>245 && redAt(48)>120 && redAt(48)<135);
SDL_DestroySurface(pixels);
// Tri-group sub-ranges share one resident buffer; firstIndex selects the right-hand triangle only.
{
auto groups=std::make_shared<ava2::Render3DDraw>(*mesh);
groups->positions={-.65f,-.2f,.5f,-.35f,-.2f,.5f,-.5f,.2f,.5f, .35f,-.2f,.5f,.65f,-.2f,.5f,.5f,.2f,.5f};
groups->indices={0,1,2,3,4,5};groups->diffuse=std::vector<uint32_t>(6,0xffff0000);
auto second=left;second.geometry=groups;second.transform.mvp[12]=0;second.firstIndex=3;second.indexCount=3;
const auto uploads=resident.GetResidentUploadCount();
pixels=frame({second});
assert(resident.GetResidentUploadCount()==uploads+1 && resident.GetLastDynamicUploadBytes()==0);
assert(redAt(48)>245 && redAt(16)<5);SDL_DestroySurface(pixels);
auto first=second;first.firstIndex=0;
pixels=frame({first,second});
assert(resident.GetResidentUploadCount()==uploads+1 && resident.GetLastDrawCallCount()==2);
assert(redAt(16)>245 && redAt(48)>245);SDL_DestroySurface(pixels);
}
// Bone translation moves the raw triangle to the center; no CPU-deformed stream is uploaded.
left.transform.skin[0]=1;left.palette=std::make_shared<std::vector<float>>(std::vector<float>{1,0,0,0,0,1,0,0,0,0,1,0,.5f,0,0,1});
auto skinned=std::make_shared<ava2::Render3DDraw>(*mesh);skinned->bone_indices=std::vector<uint8_t>(12,0);skinned->bone_weights={1,0,0,0,1,0,0,0,1,0,0,0};left.geometry=skinned;