ppy / osu-framework

A game framework written with osu! in mind.
MIT License
1.67k stars 420 forks source link

Use value equality to determine uniform buffer equivalence #6414

Open LumpBloom7 opened 2 weeks ago

LumpBloom7 commented 2 weeks ago

The previous reference-equality guaranteed that DrawNodes that bind uniform blocks will break batches, even if the uniform block data is identical to an adjacent DrawNode for the same shader.

Value equality allows adjacent DrawNodes with the same uniform data to share the same uniform block, and therefore the same batch.

A possible problem with this solution is that it depends on the uniform data being set before binding, where the check occurs. Failure to do so will result in incorrect uniform data being used during drawing. However, all code in osu/framework binds after setting uniform data, so I don't feel like it is a problem in general.

Uniform uploads still happen even with this change.

smoogipoo commented 2 days ago

depends on the uniform data being set before binding, where the check occurs. Failure to do so will result in incorrect uniform data being used during drawing

I'm not sure I can get past the hidden breakage aspect of this, even if there are no usages...

LumpBloom7 commented 23 hours ago

I agree, which is the reason I brought it up. If this quick fix is used, we likely should enforce the order of uniform uploads. (Cannot set data while bound?)