Compositors and resized textures

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


User avatar
bishopnator
Gnome
Posts: 388
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Compositors and resized textures

Post by bishopnator »

I got already several bugs in my implementation that after resizing a GPU texture and had to manually recreate the nodes in the workspace compositors which use the updated texture. The reason is that internally CompositorPass needs to recreate the RenderPassDescriptor which holds/refers to the RS texture data (e.g. ComPtr<ID3D11Resource> in D3D11). On the client side is it really hard to track such references and I believe that such behavior such be part of Ogre. I am creating the compositors which share some external textures which I resize by myself together with the window, but they cannot be part of the workspace itself, because then the sharing between windows is not possible.

Now when I resize a texture, I need to track in my code which workspaces use this particular texture and call recreateAllNodes() by myself before the whole update. Is it possible to somehow track such changes in the Ogre? I looked just briefly in the source code and I didn't find any "stamp" or whatever which I can use and store inside the workspace to check that the texture was recreated - the size doesn't matter - just if TextureGpu::transitionToResident() (or more specifically createInternalResourcesImpl) is called, the workspaces must recreate their nodes.

If it sounds like a good idea, I can try to prepare a PR with the changes, but some guidance would be very helpful.

User avatar
bishopnator
Gnome
Posts: 388
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Re: Compositors and resized textures

Post by bishopnator »

The simplest way seems to be to add a TextureGpuListener to all compositor channels (external RT) which calls CompositorWorkspace::destroyAllNodes. The nodes are then automatically recreated during update of the compositor workspace. The destroyAllNodes is protected so it is not possible implement such listener in the clients code (in Ogre the implementation would be as nested class inside CompositorWorkspace).

In my code I call the public method recreateAllNodes() but in some border cases it is possible, that the nodes are recreated multiple times for a single compositor workspace.