Closed rickbrew closed 1 month ago
Here's the code in my ID2D1Properties
wrapper where I perform my own optimization to skip the ID2D1Properties::SetValue()
call, which then does not result in D2D thinking it needs to re-run PrepareForRender()
, nor re-do layout (MapInputRectsToOutputRect
), nor invalidate the output cache (if the Cached property is set, which I do occasionally use), etc
As per discussion on Discord, https://discord.com/channels/143867839282020352/960223751599976479/1248401471813189795
The risk here is that two bitwise-equal shader structs could produce two constants buffers that are bitwise non-identical due to not setting the padding areas to zero.
This then defeats any sort of optimizations for checking to see if a property's new value is actually different than the old one, which then permits skipping
ValueChanged
events and also re-runningPrepareForRender()
and the like.This is something I've seen significant performance wins from -- in my
D2D1Properties
wrapper, I check to see if setting anIUnknown*
property will result in the sameIUnknown*
identity pointer, and then I don't forward theSetValue()
call to Direct2D. This resulted in significant, measurable, even noticeable (framerate) performance improvements.