RevalSoft
Topic Author
Posts: 15
Joined: 24 Jun 2018, 15:23

Caching of textures

29 Dec 2022, 22:25

Hi there!

I'm implement game UI via Noesis and have get freezes on first open windows where used texture atlas for icons, sure somewhere i'm make mistake with resource organization and missing caching in TextureProvider.

Please, explain to me how to correct preload big texture in TextureProvider and share it between multiply xaml (game windows) in most correct way.

For now i make in each .xaml (like MyGameWindow1.xaml) merged resource with global resource file:
<UserControl.Resources>
	<ResourceDictionary>
		<ResourceDictionary.MergedDictionaries>
			<ResourceDictionary Source="Resources.xaml" />
		</ResourceDictionary.MergedDictionaries>
	</ResourceDictionary>
</UserControl.Resources>
and in Resource.xaml (which in global resource file):
<ResourceDictionary.MergedDictionaries>
	<ResourceDictionary Source="SkillAtlas_Common.xaml" />
	<ResourceDictionary Source="SkillAtlas_Master.xaml" />
</ResourceDictionary.MergedDictionaries>
// ... other Styles, Templates and etc.
In XamlProvider i realised caching and each .xaml loadings only once in memory, but as follows from my observations it not preventing from loading texture atlases in each .xaml.
As example: MyWindow1.xaml uses Atlas1 and MyWindow2.xaml uses Atlas1, but after open MyWindow1.xaml and get loaded Atlas1 it not loads Atlas1 for MyWindow2.xaml, after open second one window it will be again freeze for first opening.

With best regards.
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Caching of textures

02 Jan 2023, 13:04

Probably this is happening because after MyWindow1.xaml is closed, Atlas1 is unused and we release it. When MyWindow2.xaml is opened, Atlas is requested again and needs to be loaded. By default, we only implement a reference counter mechanism for textures, if you need something more sophisticated you need to implement it yourself in a custom Texture provider. For example, keeping a reference to Atlas1 to avoid unloading it.

There are also good hints about custom texture providers in this post:

viewtopic.php?t=2819

Who is online

Users browsing this forum: No registered users and 5 guests