Find Resource Name From Alias question

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Find Resource Name From Alias question

Post by hedphelym »

I'm trying to debug some texture hiccups, there seems to be some object that is loaded later then the initial scene, then
when I move around the scene it starts loading them and it freezes during this.
I have hundreds of objects, but I'm not exactly sure which one is causing issues, so I'm trying to trace it down.
If I remove all materials - everything works fine, so it's not mesh related.

In the log output I get this warning when the hiccup occurs:

Code: Select all

WARNING: Texture instance 'HlmsTextureManager/15' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
So I then wanted to find out what resource \ texture map that is, the name printed is not any name I have given any texture,
so if I understand it correctly - that name is a 'alias', I then try and get the texture like below, but it always returns 'NULL'.
So I'm a bit unsure if I'm using it the correct way.

Code: Select all

Ogre::IdString tmpId;
tmpId = 15;

Ogre::HlmsManager *const hlmsManager = GetOgreRoot()->getHlmsManager();
Ogre::HlmsTextureManager *const hlmsTextureManager = hlmsManager->getTextureManager();
const Ogre::String* texname = hlmsTextureManager->findResourceNameFromAlias(tmpId);

if (texname != NULL)
{
	PrintOgreLog("" + Utilities::ToString(texname), Ogre::LML_CRITICAL);
}else
{
	PrintOgreLog("Could not find texture by alias", Ogre::LML_CRITICAL);
}
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Find Resource Name From Alias question

Post by paroj »

no, this is not an alias, it is the name of the underlying "v1" Texture, which is created here:
https://github.com/OGRECave/ogre/blob/v ... #L870-L876

it seems that Ogre decides to allocate a new texture atlas at that point, which would also explain why it takes some time.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

Ah okay, thank you for the pointer on that, I'll check some more around it when I get back to the office tomorrow.
At least now It makes more sense to me, so thanks again.
I'll post again if I have more questions - or if I find out the cause, it might help someone else with the same problem later.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

I've been debugging some more now.
I have removed all objects, and all materials until I ended up with one object using one pbs material.
This object has a unique material, and the object is outside the camera view at startup.
when this object is coming into view (by rotating the camera towards it) it triggers this, causing it to lag substantially while updating as mentioned above. When it has done this once it works fine afterwards.

I also tested it by making a simple cube mesh, assign the material there the same way (just to rule out any mesh related errors), and the same
happens.

So, the issues seems to be two things:
1) The atlas update giving the texture warning as you mentioned, but that does not happen for all materials it seems.
2) Objects with PBS material loaded outside the camera view, causes hiccup when they are not culled.

So now I'm thinking about what to do next.
Maybe force some kind of update on all materials when scene has been loaded? So that this atlas\material is updated on first frame?
Do you have any other suggestions?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Find Resource Name From Alias question

Post by dark_sylinc »

This doesn't seem like a material loading problem (since all textures are loaded upfront in 2.1) but rather a shader compilation problem.

See Ogre 2.1 FAQ entry regarding this issue.

Cheers
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

I'll check more tomorrow.
The texture error I suspect comes from a material we make with v1 (old material type).
I have to dig more into that one when the other issue is resolved.

But the other issue - hiccup when object comes into view the first time - is still not resolved, I'll see if I can make reproduce it with the sample scene that comes with ogre, that one uses just a simple pbs material with color, nothing extra or fancy on that one.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

I was able to reproduce the hiccup with the ogre 2.1 tutorialsky_postprocess sample, the only thing you need to do is to
go into the file : cameracontroller.cpp , set the 'mCameraYaw( 0 )' to: 'mCameraYaw( 180 ),' on line 16.

Then when you run the tutorialsky sample the box will be behind the camera when the sample is started,
you rotate the camera so that the object comes into view, then you see the lag, exactly as we experience in our software as well.

Also maybe worth a mention, we have '-DOGRE_PROFILING_PROVIDER="remotery"' enabled as well.
I will now compile without remotery enabled in cmake and see if I get the same issue.

Edit:
Also happens without remotery.
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

Re: Find Resource Name From Alias question

Post by TaaTT4 »

As @dark_sylinc already told you before, the stall is caused by shader compilation (see the link he provided in his post or this one for more info). Switch to OpenGL render system (if this is an option to you) to greatly reduce the issue or, even better, use shaders cache.

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

I have 'fast shader hack' enabled, this is done during startup.
(I was expecting that to be the same as caching - correct me if I'm wrong).

The problem I'm experiencing is happening after everything has started and loaded, the sample can run for many frames with good framerate when
the camera looks away from the cube (like I explained with the sample project above), but as soon as I turn the camera around
it stutters badly as the cube comes into the view for the first time.

I'm not trying to be ignorant or not accept answers being posted here, I'm just trying to make sure we are talking about the exact same issue.

With the sample mentioned above I get the same stutter in both OpenGL and DirectX.
It would be nice if someone else here also could give it a test to see.

Tested the exact scenario with the tutorial_sky_postprocess (by modifing the camera to start up looking away from the cube) on another machine at the office - get the same stutter there.
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

Re: Find Resource Name From Alias question

Post by TaaTT4 »

hedphelym wrote: Wed May 30, 2018 9:14 am I have 'fast shader hack' enabled, this is done during startup.
(I was expecting that to be the same as caching - correct me if I'm wrong).
Fast shader hack is totally unrelated to cache. The hack just reduce the shader compilation time (so the stall should be shorter) while the cache save the compilation result. On subsequent runs, thanks to this cache, the shaders will not be compiled at all.
hedphelym wrote: Wed May 30, 2018 9:14 am The problem I'm experiencing is happening after everything has started and loaded, the sample can run for many frames with good framerate when
the camera looks away from the cube (like I explained with the sample project above), but as soon as I turn the camera around
it stutters badly as the cube comes into the view for the first time.
That's because shaders compilation happens when the object gets rendered for the first time.
hedphelym wrote: Wed May 30, 2018 9:14 am With the sample mentioned above I get the same stutter in both OpenGL and DirectX.
OpenGL doesn't get rid of this issue, it just reduces the stall compared to DirectX (at least on my machine).

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

Thank you for explaining it, it makes sense now, I'll get that caching implemented asap.

And it is as you say - smaller stall on OpenGL then with DirectX.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: Find Resource Name From Alias question

Post by hedphelym »

This seems to help a lot indeed.

Just one more question about the cache -
when it loads, is all the microcode loaded in at once and are ready - or does it load the microcode for the specific shader when the shader becomes visible?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Find Resource Name From Alias question

Post by dark_sylinc »

When you load the microcode cache, we load all of them into memory; so later when the shader is created we compare md5 hashes and select the microcode from the cache instead of creating it.

However internally when we pass the microcode to D3D11, the driver will internally convert that binary blob into another binary blob (ISA-specific binary for your GPU) but that consumes negligible time in comparison.
Eventually we'll implement something to get rid of that "negligible time" (because it increases framerate variance, which can cause dizziness in VR) but it's not a priority right now.
Post Reply