Page MenuHome

GPUIndexBuf: Find the minimum and maximum index through the builder
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Jun 1 2021, 10:44 PM.

Details

Summary

This is a discrete optimization that only affects around 1 to 3 ms when
editing highpoly meshes.

However, moving the bounds code to the builder can be useful for future
optimizations like building multithreaded.


Some Results:

MASTER:PATCH:
large_mesh_editing:Average: 6.889993 FPSAverage: 6.973309 FPS
rdata 9ms iter 35ms (frame 145ms)rdata 9ms iter 33ms (frame 144ms)
large_mesh_editing_ledge:Average: 6.856628 FPSAverage: 6.943300 FPS
rdata 9ms iter 38ms (frame 146ms)rdata 9ms iter 36ms (frame 144ms)
looptris_test:Average: 3.462660 FPSAverage: 3.508681 FPS
rdata 11ms iter 94ms (frame 270ms)rdata 12ms iter 92ms (frame 268ms)
subdiv_mesh_cage_and_final:Average: 1.731085 FPSAverage: 1.829342 FPS
rdata 7ms iter 44ms (frame 293ms)rdata 7ms iter 43ms (frame 277ms)
rdata 7ms iter 46ms (frame 284ms)rdata 7ms iter 45ms (frame 268ms)
subdiv_mesh_final_only:Average: 5.719009 FPSAverage: 6.189731 FPS
rdata 3ms iter 23ms (frame 173ms)rdata 3ms iter 21ms (frame 157ms)
subdiv_mesh_final_only_ledge:Average: 5.685724 FPSAverage: 6.151417 FPS
rdata 3ms iter 22ms (frame 169ms)rdata 3ms iter 21ms (frame 158ms)

Diff Detail

Repository
rB Blender
Branch
indexbuf_builder_clamp (branched from master)
Build Status
Buildable 14891
Build 14891: arc lint + arc unit

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Jun 1 2021, 10:44 PM
Germano Cavalcante (mano-wii) created this revision.
Jeroen Bakker (jbakker) requested changes to this revision.Jun 2 2021, 7:40 AM
Jeroen Bakker (jbakker) added inline comments.
source/blender/gpu/intern/gpu_index_buffer.cc
151

Think you meant CLAMP_MAX, also for the rest CLAMP_MIN(builder->index_len, elem);

This revision now requires changes to proceed.Jun 2 2021, 7:40 AM
Clément Foucault (fclem) requested changes to this revision.Jun 2 2021, 12:47 PM
Clément Foucault (fclem) added inline comments.
source/blender/gpu/intern/gpu_index_buffer.cc
164

Use min_ii or max_ii instead of the macro.

source/blender/gpu/intern/gpu_index_buffer.cc
151

Think you meant CLAMP_MAX, also for the rest CLAMP_MIN(builder->index_len, elem);

I checked here again...
CLAMP_MIN(builder->index_len, elem); expands to:
{ if ((builder->index_len) < (elem)) { (builder->index_len) = (elem); } }(void)0
This matches the existing code.

Germano Cavalcante (mano-wii) marked 2 inline comments as done.
  • Use 'MIN2' 'MAX2' macro

I haven't found a min_ii or max_ii that can be used for uints. min_ii breaks considering UINT32_MAX or RESTART_INDEX as -1.

But the MIN2 and MAX2 macros seem to be just as readable.

Using these macros doesn't seem to affect the previous benchmark results.

BLI_math_base now has max_uu and min_uu that can be used for this. But that can be cleaned up after it lands in master.

This revision is now accepted and ready to land.Jun 7 2021, 12:22 PM
This revision was landed with ongoing or failed builds.Jun 7 2021, 1:47 PM
This revision was automatically updated to reflect the committed changes.