D3D11RenderTexture::getCustomAttribute missing? Topic is solved

Problems building or running the engine, queries about how to use features etc.
User avatar
Arthurfernandes
Kobold
Posts: 33
Joined: Mon Oct 28, 2024 10:50 pm
x 2

Re: D3D11RenderTexture::getCustomAttribute missing?

Post by Arthurfernandes »

@paroj, bad news. After thousands of tests, the new function is not working perfectly. I'm encountering random errors when experimenting in the scene. Sometimes, when I try to create an entity for the first time, I get an Access Memory Violation error. If it’s not the entity, the error occurs in another part of the code, but it’s always the same Access Violation error.

After adding logs throughout the Ogre source code, I tracked it down to this specific line:

Code: Select all

hr = pUnk->QueryInterface(__uuidof(IDXGIResource), (void**)&pDXGIResource);

As I mentioned, sometimes the crash happens at the very beginning, and I don't even get the chance to see the ogrehead on the screen. Another issue occurs when I try to activate the bounding box for an entity—again, an Access Violation error.

I’ve implemented some methods to move the entity and the camera using WPF, and those work just fine without crashes. However, if I attempt to activate the bounding box, it immediately crashes with an Access Violation error.

If it helps, here is my code for creating the Texture and the Scene:

Code: Select all

public void CreateTexture11(IntPtr surface)
{
    texturePtr = TextureManager.getSingleton().create("Ogre Render", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
    texturePtr.setUsage(0x20);
    texturePtr._setSurface(surface);
    texturePtr.load();
}

Code: Select all

private void OgreHeadScene()
{
    #region Ambient Light

scnMgr.setAmbientLight(new ColourValue(0.1f, 0.1f, 0.1f));

#endregion

#region Camera

camNode = scnMgr.getRootSceneNode().createChildSceneNode();
cam = scnMgr.createCamera("myCam");
cam.setNearClipDistance(5);
cam.setAutoAspectRatio(true);
camNode.setPosition(0, 47, 222);
camNode.attachObject(cam);

#endregion

#region Light

Light mainLight = scnMgr.createLight("MainLight");
SceneNode lightNode = scnMgr.getRootSceneNode().createChildSceneNode();
lightNode.setPosition(20, 80, 50);
lightNode.attachObject(mainLight);

#endregion

#region Entity

Entity entity = scnMgr.createEntity("OgreHead", "ogrehead.mesh");
SceneNode entityNode = scnMgr.getRootSceneNode().createChildSceneNode();
entityNode.attachObject(entity);

Entity entity2 = scnMgr.createEntity("OgreHead2", "ogrehead.mesh");
SceneNode entityNode2 = scnMgr.getRootSceneNode().createChildSceneNode(new Vector3(84, 48, 0));
entityNode2.attachObject(entity2);

Entity entity3 = scnMgr.createEntity("OgreHead3", "ogrehead.mesh");
SceneNode entityNode3 = scnMgr.getRootSceneNode().createChildSceneNode(new Vector3(0, 104, 0));
entityNode3.setScale(2, 1.2f, 2);
entityNode3.attachObject(entity3);

Entity entity4 = scnMgr.createEntity("OgreHead4", "ogrehead.mesh");
SceneNode entityNode4 = scnMgr.getRootSceneNode().createChildSceneNode(new Vector3(-84, 48, 0));
entityNode4.roll(new Radian(new Degree(-90).valueRadians()));
entityNode4.attachObject(entity4);

#endregion
}
paroj
OGRE Team Member
OGRE Team Member
Posts: 2135
Joined: Sun Mar 30, 2014 2:51 pm
x 1145

Re: D3D11RenderTexture::getCustomAttribute missing?

Post by paroj »

if you are using #3275, then likely the issue is that mSurface is uninitialized.

User avatar
Arthurfernandes
Kobold
Posts: 33
Joined: Mon Oct 28, 2024 10:50 pm
x 2

Re: D3D11RenderTexture::getCustomAttribute missing?

Post by Arthurfernandes »

paroj wrote: Thu Jan 23, 2025 6:35 pm

if you are using #3275, then likely the issue is that mSurface is uninitialized.

Just a quick question: if I use mSurface once, do I always need to use it afterward? What I mean is, after initializing the texture with the mSurface pointer

Code: Select all

auto tex = TextureManager::create(...)
tex->setUsage(TU_RENDERTARGET);
tex->_setSurface(handle);
tex->load();

When I create an Entity, will this Entity use the same _createShared2DTex method, or will it use the regular _create2DTex method?

Because this is happening now, when I create a texture, it uses _createShared2DTex, but everything I do afterward uses _create2DTex. Maybe this is causing the Access Memory Violation.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2135
Joined: Sun Mar 30, 2014 2:51 pm
x 1145

Re: D3D11RenderTexture::getCustomAttribute missing?

Post by paroj »

take another look at #3275 - I fixed the mSurface initialization there.

regarding your question: the texture will keep mSurface until it is unloaded. All entities using the texture will use the given mSurface. Other textures and other entities are not affected.

User avatar
Arthurfernandes
Kobold
Posts: 33
Joined: Mon Oct 28, 2024 10:50 pm
x 2

Re: D3D11RenderTexture::getCustomAttribute missing?

Post by Arthurfernandes »

paroj wrote: Wed Jan 29, 2025 5:11 pm

take another look at #3275 - I fixed the mSurface initialization there.

regarding your question: the texture will keep mSurface until it is unloaded. All entities using the texture will use the given mSurface. Other textures and other entities are not affected.

The strange thing is that I keep getting Access Violation errors. In 99% of the cases where I modify the D3D11Image component (resizing it, for example), if I try to do anything in the Ogre scene, an Access Violation occurs in renderOneFrame. Could this be due to the component's queue?

Another thing that sometimes happens is that when creating a new entity, an Access Violation error appears. Most of the time, this occurs after resizing, but occasionally, it happens when generating the first entity. Any clues on what I should investigate? Ogre or the component?