Stanzilla / WoWUIBugs

World of Warcraft UI Bug Tracker
153 stars 7 forks source link

SetColorTexture calls can stall execution for several milliseconds #580

Open Meorawr opened 4 weeks ago

Meorawr commented 4 weeks ago

Use of the SetColorTexture API can stall script execution by a number of milliseconds relative to client framerate - eg. a 14ms stall at 60fps, or a 30ms stall at 30fps.

Test case

Execute the following command. The number of milliseconds spent in the SetColorTexture call will be printed to the chat frame.

/run local T = UIParent:CreateTexture(); local r = fastrandom; local s = debugprofilestop(); T:SetColorTexture(r(), r(), r(), 1); print(debugprofilestop() - s);

A few observations;

  1. The issue only appears to be present in the DirectX 12 renderer. Swapping to D3D11 results in the call taking a reasonable amount of time (~0.1ms).
  2. The issue only appears to be present if the "Max Foreground FPS" option is disabled.
  3. The issue only appears to be present on the first use of SetColorTexture in any given frame. Subsequent calls in the same frame don't appear to stall.
  4. The milliseconds spent in the call appears to be related to framerate; if I cap my GPU at 60 FPS in driver settings then I can see calls taking 14ms, whereas if I uncap it then I can see calls taking ~0.1ms.
  5. Spuriously the SetColorTexture call will actually be fast for some executions of the test command. This may just be down to bad luck with the fastrandom call resulting in reuse of a color, but it feels a bit too frequent for that to be likely.