Page 1 of 1

ResourceDictionary Texture Optimization

Posted: 25 Aug 2021, 16:30
by stonstad
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!

Re: ResourceDictionary Texture Optimization

Posted: 26 Aug 2021, 17:45
by jsantos
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.

Re: ResourceDictionary Texture Optimization

Posted: 27 Aug 2021, 16:15
by stonstad
Understood, thank you!

Re: ResourceDictionary Texture Optimization

Posted: 09 Mar 2022, 21:21
by stonstad
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!

Re: ResourceDictionary Texture Optimization

Posted: 10 Mar 2022, 13:42
by jsantos
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