Quantcast
Getting performance issues with SetTexture() - WoWInterface
 
Thread Tools Display Modes
06-24-16, 11:21 PM   #1
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
Getting performance issues with SetTexture()

Hey folks.
I'm getting fps drops from 90fps to 7fps when i do use SetTexture() with a .tga file equal or larger than 256x256.
Since it seems a odd issue, I'm wondering if this is happening only for me, may you guys test this too?

To try reproduce on your guys end, create a 1024x1024 .tga texture or use this https://www.dropbox.com/s/ulyeqa2z0ummlu7/1024.tga?dl=0, place it on world of warcraft/interface/

And run the macro:
/run for o=1,10 do local f=CreateFrame("frame");f:SetPoint("center");f:SetSize(300,300); local t=f:CreateTexture(nil,"overlay");t:SetAllPoints();f:SetScript("OnUpdate",function() t:SetTexture("Interface\\1024")end);end;

Thank you.
 
06-24-16, 11:28 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,236
Might not your problem be trying to SetTexture every tic of an OnUpdate script?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
 
06-25-16, 12:02 AM   #3
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 928
Originally Posted by Tercioo View Post
I'm getting fps drops from 90fps to 7fps when i do use SetTexture() with a .tga file equal or larger than 256x256.
Since it seems a odd issue, I'm wondering if this is happening only for me, may you guys test this too?
I tested your script and got fps drops




But it could indeed be those 10 OnUpdate scripts you're running, isn't that a bit too much?

Lua Code:
  1. for o = 1, 10 do
  2.     local f = CreateFrame("frame")
  3.     f:SetPoint("center")
  4.     f:SetSize(300, 300)
  5.     local t = f:CreateTexture(nil, "overlay")
  6.     t:SetAllPoints()
  7.    
  8.     f:SetScript("OnUpdate", function()
  9.         t:SetTexture("Interface\\1024")
  10.     end)
  11. end
 
06-25-16, 03:15 AM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Why would you want to change the texture 10 times in every frame update. Why would you want to update it even 1 time in every frame update?
 
06-25-16, 11:12 AM   #5
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
Guys I fully understand the concern about setting on tick, nobody should be doing that, but on live 6.2, it can handle 500 SetTexture() without drops, and, 7.0.3 10 textures already are dropping fps from 90 to 7.

A real world application example issue (which I'm facing now) is this: http://cdn-wow.mmoui.com/preview/pvw66831.png
There is a large amount of textures to set in one tick and it's causing a small freeze when I open the world map.
 
06-25-16, 11:43 AM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 427
Textures are handled differently in Legion to reduce demand on memory. It seems every time you explicitly hide a texture, it's freed from memory and will be reallocated once it's shown again. I'm not completely sure about this, but I think if you use GetTexture() on a hidden region, it'll return nil now, since it doesn't have a texture attached to it if it's hidden.

I had a similar problem (which was honestly just bad design) where I used a 1024x1024 gradient to backdrop a couple of tiny check buttons, which wasn't an issue on Live since they're only loaded once, but in Legion, it would take a second for the frame to draw all the objects when it was shown.

The threshold for frame drops seems to be relatively high on my mid-range system, but the only thing you can do is to be mindful of the amount of textures you're using and their original size. If you're able to, merge stuff as much as possible and remove any redundant regions that you're using out of convenience. Also, it's probably not a good idea to use texture coordinates for a crap ton of textures. Until we can store our own atlas textures through Blizzard's system, it's probably wise to just use small individual textures instead. Most importantly, don't refresh textures in an update script.

Edit: One thing I noticed from reading your code is that you're using separate textures for each button to draw different rarity borders around the reward icons. Why aren't you using a white border texture and setting vertex color to the item rarity instead? Hiding and re-showing all those textures is unnecessary, when you can just change the color of them instead. Each time you do this, you're forcing the game to reload your 512x512 atlas texture, crop it and resize it.

Lua Code:
  1. local color = ITEM_QUALITY_COLORS[rarity]
  2. self.border:SetVertexColor(color.r, color.g, color.b)

Edit 2: In comparison, look at this frame which doesn't cause any drop in frame rate:


It has quite a few individual textures drawn, and each spell icon is masked. However, the mask I'm using is tiny and meant for the circle buttons around the minimap. On top of that is a 32x32 pixel border. In fact, all custom textures that are repeatedly drawn in that screenshot are equal to or less than 64x64 pixels. I'm also using the atlas approach for some of the elements, but they are few in number.
__________________

Last edited by MunkDev : 06-25-16 at 12:39 PM.
 
06-25-16, 12:56 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
The beta client doesn't seem to be using the existing copy of the texture that's been loaded into memory and is creating a new copy of it every time the texture is set.

I'm not sure if it can't tell that the textures are the same because of what they did to texture paths, but I don't think this is intentional because loading new textures is extremely slow compared to reusing the copy in memory.
 
06-26-16, 02:35 PM   #8
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
Originally Posted by semlar View Post
The beta client doesn't seem to be using the existing copy of the texture that's been loaded into memory and is creating a new copy of it every time the texture is set.

I'm not sure if it can't tell that the textures are the same because of what they did to texture paths, but I don't think this is intentional because loading new textures is extremely slow compared to reusing the copy in memory.
Did a test on this and yeah, it's reading the texture from the hard drive each time SetTexture() is called.
I don't believe this will be up for the release.

Hey @MunkDev, thank you for the tips.
 
07-11-16, 07:32 AM   #9
MaXiMiUS
A Murloc Raider
Join Date: Apr 2008
Posts: 9
Originally Posted by Tercioo View Post
Did a test on this and yeah, it's reading the texture from the hard drive each time SetTexture() is called.
I don't believe this will be up for the release.

Hey @MunkDev, thank you for the tips.
I certainly hope it's not like this on release, as it's making my addon kill my framerate (60FPS to 12FPS) when it doesn't impact framerate at all on live. These are textures I need to update on every frame too, as it's extremely choppy if I throttle the OnUpdate calls.

Edit: Nevermind I guess, I found what the real killer was. Unnecessary Hide(texture) calls every OnUpdate, followed promptly by Show(texture).

Edit 2: Still getting unacceptable FPS drops when I first call SetTexture on something new, though -- even if the texture has previously been used as recently as 10 seconds ago. Who at Blizzard thought it was a good idea to unload this stuff from memory immediately when loading it from the drive causes such a big performance hit? Just loading 1-2 fresh textures for SetTexture *once* causes a 15 FPS dip for 1-2 seconds -_-

Last edited by MaXiMiUS : 07-13-16 at 06:01 AM.
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » Getting performance issues with SetTexture()

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off