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
+2 -2
View File
@@ -281,7 +281,7 @@ bool HardwareScene::Render(SDL_Renderer* renderer,int width,int height,const std
if(mesh && !batch.blend && !batch.additive && batch.depthWrite && batch.transform.skin[0]==0 && batch.transform.modes[0]>0.5f)
while(i+count<batches.size()) {
const auto& next=batches[i+count];
if(meshes[i+count]!=mesh || next.texture!=batch.texture || next.cull!=batch.cull || next.depth!=batch.depth || next.depthWrite!=batch.depthWrite || next.blend || next.additive || next.alphaRef!=batch.alphaRef || next.transform.skin[0]!=0 || next.transform.modes[0]<.5f)break;
if(meshes[i+count]!=mesh || next.firstIndex!=batch.firstIndex || next.indexCount!=batch.indexCount || next.texture!=batch.texture || next.cull!=batch.cull || next.depth!=batch.depth || next.depthWrite!=batch.depthWrite || next.blend || next.additive || next.alphaRef!=batch.alphaRef || next.transform.skin[0]!=0 || next.transform.modes[0]<.5f)break;
++count;
}
SDL_GPUBufferBinding binding{mesh ? mesh->vertices : vertices_,0};SDL_BindGPUVertexBuffers(pass,0,&binding,1);
@@ -292,7 +292,7 @@ bool HardwareScene::Render(SDL_Renderer* renderer,int width,int height,const std
auto transform=batch.transform;if(count>1)transform.modes[0]=2;
SDL_PushGPUVertexUniformData(cmd,0,&transform,sizeof(transform));
if(transform.skin[0]>0 && batch.palette && batch.palette.get()!=pushedPalette){pushedPalette=batch.palette.get();std::fill(std::begin(palette),std::end(palette),0);std::copy_n(batch.palette->data(),std::min(batch.palette->size(),size_t(128*16)),palette);SDL_PushGPUVertexUniformData(cmd,1,palette,sizeof(palette));}
SDL_DrawGPUIndexedPrimitives(pass,batch.indexCount,count,mesh ? 0 : batch.firstIndex,0,count>1 ? i : 0);++lastDrawCalls_;i+=count;
SDL_DrawGPUIndexedPrimitives(pass,batch.indexCount,count,batch.firstIndex,0,count>1 ? i : 0);++lastDrawCalls_;i+=count;
}
SDL_EndGPURenderPass(pass);const auto beforeSubmit=SDL_GetPerformanceCounter();
if(!SDL_SubmitGPUCommandBuffer(cmd))return false;