User avatar
stonstad
Topic Author
Posts: 183
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

ResourceDictionary Texture Optimization

25 Aug 2021, 16:30

Hello! Hoping you are all well. Noesis is terrific and it is a joy to work with. I have an optimization question.

If I have a resource dictionary with definitions as follows:
<ImageBrush x:Key="Window_0_TL" ImageSource="Images/window chrome/popup/background_x1.png" ViewboxUnits="Absolute" Viewbox="0,0,20,20"/>
<ImageBrush x:Key="Window_0_T" ImageSource="Images/window chrome/popup/background_x1.png" ViewboxUnits="Absolute" Viewbox="20,0,426,20"/>
<ImageBrush x:Key="Window_0_TR" ImageSource="Images/window chrome/popup/background_x1.png" ViewboxUnits="Absolute" Viewbox="446,0,20,20"/>
...

Is this internally stored as a single texture? More specifically, is it 1x or 3x memory usage?


If I have a resource dictionary with definitions as follows:
<ImageBrush x:Key="Fwd Light_Light" ImageSource="Images/context menu/actions/light/light.png" Stretch="None"/>
<ImageBrush x:Key="Lnd Light_Light" ImageSource="Images/context menu/actions/light/light.png" Stretch="None"/>
Is this internally stored as one texture or two? More specifically, is it 1x or 2x memory usage?

Thanks!
 
User avatar
jsantos
Site Admin
Posts: 3424
Joined: 20 Jan 2012, 17:18
Contact:

Re: ResourceDictionary Texture Optimization

26 Aug 2021, 17:45

We don't create extra textures. so if you have one texture in Unity, that the one we are using internally. So, in both examples you provided we are always using one texture and 1x memory usage.

Note that since 3.1, Sprites are supported in DataContexts and accessible to ImageSource properties in XAML using data-binding. See our Inventory sample.
Or if you prefer you can also use CroppedBitmap in XAML.
 
User avatar
stonstad
Topic Author
Posts: 183
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: ResourceDictionary Texture Optimization

27 Aug 2021, 16:15

Understood, thank you!
 
User avatar
stonstad
Topic Author
Posts: 183
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: ResourceDictionary Texture Optimization

09 Mar 2022, 21:21

Hello! I am revisiting this question with a new variation. Let's say that I have a single XAML shape that is stored as a resource. If I have 100 instances of the XAML shape displayed in my NoesisView, is that 1x memory consumption or 100x memory consumption? Similarly, is it 1x rendering bandwidth or 100x rendering bandwidth? Thank you!
 
User avatar
jsantos
Site Admin
Posts: 3424
Joined: 20 Jan 2012, 17:18
Contact:

Re: ResourceDictionary Texture Optimization

10 Mar 2022, 13:42

There is a memory cost "per instance", not 100x, but probably 10-15x. For each instance there is a "cached" representation of the path optimized for rendering on the GPU. These are separate caches because each instance can be rendered at a different scale.

For the rendering, each path is rendered again (we don't cache into textures), so in this case, 100x

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest