[2.2] How to compile MyGUI for Ogre 2.2

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

[2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Fri May 17, 2019 4:23 pm

Hi together,

I wanted to ask, if someone already ported the MyGUI Engine to Ogre2.2?
I get a lot of erros in Ogre2Platform project, because textures and compositors api has of course changed.

Best Regards
Lax
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1064
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 83

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by xrgo » Fri May 17, 2019 4:58 pm

rujialiu I summon you!
he helped me with that task, and prefer if he shares it.
rujia, maybe you could make a branch/fork on the official myGui repo?
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1205
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 77

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by al2950 » Fri May 17, 2019 8:21 pm

Arggg. I was also helped by rujialiu, but I did say I would create a PR with my changes but have failed to do that. I am not sure my approach to the changes is the most universal, but maybe I should at least make them public. I ve put it off because it requires git, which just irritates me! Ill try and find time this weekend
0 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Sat May 18, 2019 2:36 pm

Hi al2950,

that would be great!

Best Regards
Lax
0 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Sat May 18, 2019 5:11 pm

xrgo wrote:
Fri May 17, 2019 4:58 pm
rujialiu I summon you!
he helped me with that task, and prefer if he shares it.
rujia, maybe you could make a branch/fork on the official myGui repo?
haha, I was too lazy and hoped that al2950 would find sometime to publish the changes earlier than I do...
Arggg. I was also helped by rujialiu, but I did say I would create a PR with my changes but have failed to do that. I am not sure my approach to the changes is the most universal, but maybe I should at least make them public. I ve put it off because it requires git, which just irritates me! Ill try and find time this weekend
That would be very nice. Even if your changes are not most universal, it must be better than what I originally sent you 8-)
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1205
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 77

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by al2950 » Wed May 22, 2019 9:56 am

Sorry, failed to do this last weekend. I will try Friday. Please just keep pestering me!
1 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Sun May 26, 2019 9:58 am

Hi al2950,

you asked to pestering you :D
Is there any progress?

Best regards
Lax
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1205
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 77

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by al2950 » Sun May 26, 2019 11:52 am

ok, so it turns out I was even lazier than I thought. I think i took rujialiu changes and made them less sensible! I would really like to sort this properly so there is 1 ogre branch in mygui, with as much shared code as possible. This will obviously take a little while, and might be too messy to actually do. in the meantime I have uploaded what I currently use for 2.2:

https://github.com/al2950/mygui/tree/Ogre2.2
3 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Sun May 26, 2019 5:20 pm

Thanks a lot!
At least it compiled :)

Best Regards
Lax
0 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Wed May 29, 2019 4:12 pm

al2950 wrote:
Sun May 26, 2019 11:52 am
ok, so it turns out I was even lazier than I thought. I think i took rujialiu changes and made them less sensible! I would really like to sort this properly so there is 1 ogre branch in mygui, with as much shared code as possible. This will obviously take a little while, and might be too messy to actually do. in the meantime I have uploaded what I currently use for 2.2:

https://github.com/al2950/mygui/tree/Ogre2.2
yeah!!!
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1064
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 83

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by xrgo » Tue Aug 13, 2019 9:07 pm

Hello! I have MyGui working with Ogre 2.2 and OpenGL... the main usage for my is to render gui in to a texture that I use on some object inside the 3D scene.
Now I am porting my engine to Direct3D11 and all the MyGui stuffs don't show on the objects on the scene but it shows on the main render window :S

I am giving the correct texture when I call addWorkspace, and checked that the workspace has indeed the correct texture when update is being called. Also checked on renderdoc that the correct texture is not being filled with the gui image.

anyone else is using MyGui to render in to an Ogre 2.2 texture?

thanks!
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1064
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 83

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by xrgo » Fri Aug 23, 2019 10:54 pm

xrgo wrote:
Tue Aug 13, 2019 9:07 pm
Now I am porting my engine to Direct3D11 and all the MyGui stuffs don't show on the objects on the scene but it shows on the main render window :S
solved this problem thanks to dark_sylinc, by changing MyGUIPass::execute to this:

Code: Select all

	void MyGUIPass::execute(const Ogre::Camera *lodCameraconst)
	{
        profilingBegin();
        executeResourceTransitions();
        setRenderPassDescToCurrent();
		static_cast<MyGUI::Ogre2RenderManager*>(MyGUI::RenderManager::getInstancePtr())->render();
        profilingEnd();
	}
plus some profiling stuffs

thanks!
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4132
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 261
Contact:

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by dark_sylinc » Fri Aug 23, 2019 10:59 pm

The order of executeResourceTransitions and setRenderPassDescToCurrent was inverted!

setRenderPassDescToCurrent must be called first!
executeResourceTransitions is only relevant for Metal.
0 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Tue Sep 10, 2019 2:05 pm

A gentle reminder: the latest commit breaks a few API. In order to compile MyGUI, you need a simple change:

Code: Select all

Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
index 72a57b5..a32177d 100644
--- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
+++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
@@ -100,7 +100,7 @@ namespace MyGUI
         //mSaveRenderPassDesc = system->getCurrentPassDescriptor();
         Ogre::Vector4 viewportSize(0, 0, 1, 1);
         Ogre::Vector4 scissors(0, 0, 1, 1);
-        system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, viewportSize, scissors, false, false);
+        system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, &viewportSize, &scissors, 1, false, false);
 #endif
     }
The line might not match because I'm using my own MyGUI branch.
0 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Tue Oct 08, 2019 8:43 pm

Hi all,

was someone able to adapt MyGUI to newest Ogre2.2 version from github?
Now some includes cannot be found anymore:

Code: Select all

#include <OgreTextureManager.h>
#include <OgreTexture.h>
#include <OgrePixelBox.h>
...
They have been moved to "deprecated" folder. When this folder is prefixed, other errors do occur.

Another question, what happened to RenderWindow? It is no more available...

Best Regards
Lax
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4132
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 261
Contact:

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by dark_sylinc » Tue Oct 08, 2019 9:13 pm

Hi!

This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.

If for some reason that's not the case, then the header files are still included on the Deprecated folder and add that folder to the list of include_headers so that they can be found by the compiler
0 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Tue Oct 08, 2019 9:20 pm

Hi,
This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.
Unfortunately not.

I could replace "OgreTextureManager" with "OgreTextureGpuManager" etc.

Trying to compile MyGUI I found other issues:

- Ogre::TextureUsage is also no more available:

Code: Select all

Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage)
	{
		if (_usage == TextureUsage::Default)
		{
			return Ogre::TU_STATIC_WRITE_ONLY;
		}
		else if (_usage == TextureUsage::RenderTarget)
		{
			return Ogre::TU_RENDERTARGET;
		}
		else if (_usage.isValue(TextureUsage::Static))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_STATIC_WRITE_ONLY;
			}
			else
			{
				return Ogre::TU_STATIC;
			}
		}
		else if (_usage.isValue(TextureUsage::Dynamic))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_DYNAMIC_WRITE_ONLY;
			}
			else
			{
				return Ogre::TU_DYNAMIC;
			}
		}
		else if (_usage.isValue(TextureUsage::Stream))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE;
			}
			else
			{
				return Ogre::TU_DYNAMIC;
			}
		}
		return Ogre::TU_DEFAULT;
	}
How could that be replaced?
0 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Wed Oct 09, 2019 2:34 am

Lax wrote:
Tue Oct 08, 2019 9:20 pm
Hi,
This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.
Unfortunately not.

I could replace "OgreTextureManager" with "OgreTextureGpuManager" etc.

Trying to compile MyGUI I found other issues:

- Ogre::TextureUsage is also no more available:

Code: Select all

Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage)
	{
		if (_usage == TextureUsage::Default)
		{
			return Ogre::TU_STATIC_WRITE_ONLY;
		}
		else if (_usage == TextureUsage::RenderTarget)
		{
			return Ogre::TU_RENDERTARGET;
		}
		else if (_usage.isValue(TextureUsage::Static))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_STATIC_WRITE_ONLY;
			}
			else
			{
				return Ogre::TU_STATIC;
			}
		}
		else if (_usage.isValue(TextureUsage::Dynamic))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_DYNAMIC_WRITE_ONLY;
			}
			else
			{
				return Ogre::TU_DYNAMIC;
			}
		}
		else if (_usage.isValue(TextureUsage::Stream))
		{
			if (_usage.isValue(TextureUsage::Write))
			{
				return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE;
			}
			else
			{
				return Ogre::TU_DYNAMIC;
			}
		}
		return Ogre::TU_DEFAULT;
	}
How could that be replaced?
That can be COMPLETELY removed. That function, and the mUsage member variable, because they're not used anyway. Only MyGUI's own usage (_usage) is used. When creating a manual texture, we can directly query _usage instead of mUsage.

In case your MyGUI code used it (I'm using my own branch so it's possible that your MyGUI branch is still using it), here is my createManual function:

Code: Select all

void Ogre2Texture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format)
    {
        setFormat(_format);
        setUsage(_usage);
        uint32 textureFlags = 0; // Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB
        if (_usage.isValue(TextureUsage::RenderTarget)) {
            textureFlags |= Ogre::TextureFlags::RenderToTexture;
        }
        // TODO: Ogre::TextureFlags::Manual

        Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
        mTexture = textureMgr->createOrRetrieveTexture(
            mName,
            Ogre::GpuPageOutStrategy::Discard,
            textureFlags,
            Ogre::TextureTypes::Type2D,
            Ogre::ResourceGroupManager::
            AUTODETECT_RESOURCE_GROUP_NAME);
        
        if (mTexture) {
            mTexture->setResolution(_width, _height);
            mTexture->setPixelFormat(mPixelFormat);
        }

        if (_usage.isValue(TextureUsage::RenderTarget)) {
            textureFlags |= Ogre::TextureFlags::RenderToTexture;
            if (mTexture->getNextResidencyStatus() != Ogre::GpuResidency::Resident) {
                mTexture->_transitionTo(Ogre::GpuResidency::Resident, nullptr);
                mTexture->_setNextResidencyStatus(Ogre::GpuResidency::Resident);
            }
        }
        setDataBlockTexture(mTexture);
    }
2 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Wed Oct 09, 2019 2:41 am

Lax wrote:
Tue Oct 08, 2019 9:20 pm
Trying to compile MyGUI I found other issues:
But... if you already updated to the latest commit or latest this one: https://github.com/OGRECave/ogre-next/c ... f3d539bc48

After your code compiles, it's likely that it'll crash. That's because the with fixing issue 33, RenderQueue::frameEnded() has an assertion inside that expect every render() is followed by renderPassPrepare() AND no VaoManager::_update() is called in-between(). However, that means in MyGUI's Ogre2RenderManager::render(), you have to call renderPassPrepare before calling render(), like this:

Code: Select all

mSceneManager->getRenderQueue()->renderPassPrepare(false, false);
mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false);
That is likely breaking other codes as well. Is it intended, @dark_sylinc?
1 x

Lax
Gnome
Posts: 383
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 9

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by Lax » Sat Oct 12, 2019 10:01 am

Hi all,

thanks, that worked!

Best Regards
Lax
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4132
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 261
Contact:

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by dark_sylinc » Sun Oct 20, 2019 11:50 pm

rujialiu wrote:
Wed Oct 09, 2019 2:41 am
After your code compiles, it's likely that it'll crash. That's because the with fixing issue 33, RenderQueue::frameEnded() has an assertion inside that expect every render() is followed by renderPassPrepare() AND no VaoManager::_update() is called in-between(). However, that means in MyGUI's Ogre2RenderManager::render(), you have to call renderPassPrepare before calling render(), like this:

Code: Select all

mSceneManager->getRenderQueue()->renderPassPrepare(false, false);
mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false);
That is likely breaking other codes as well. Is it intended, @dark_sylinc?
I took a detailed look: it looks like the assert accidentally caught a bad use. It's not a bug.

The function RenderQueue::renderPassPrepare must be called if you're calling RenderQueue::render.
In Ogre 2.1 the tasks performed by renderPassPrepare were being done inside RenderQueue::render.

IIRC we had to split them into two functions because of some Metal incompatibility with RenderPassDescriptors. Overlays were being naughty in their _updateRenderQueue calls (a v1 legacy stuff), and were forcing to breakup the close a RenderCommandEncoder too early in order to open a BlitCommandEncoder, so we had to move things around.

And thus we had to move things around. The current order of execution which must be honoured to work correctly in Metal:
  1. Call RenderSystem::beginRenderPassDescriptor
  2. Call Overlays' _updateRenderQueue (i.e. in fireRenderQueueStarted). You don't need to if you don't use Overlays. But if you need to copy GPU buffers around, then this still applies.
  3. Call RenderQueue::renderPassPrepare
  4. Call executeRenderPassDescriptorDelayedActions (which originally was inside beginRenderPassDescriptor)
  5. Call RenderQueue::render
If you don't follow this order, you could get exceptions from either Ogre or Metal, or a performance warning in Ogre.log. If you don't get any exceptions or warnings, then it is very likely you were lucky the code was not doing anything that forced to breakup a RenderCommandEncoder, hence everything ran without issues.

Cheers

Update: I've pushed a documentation update to clarify this
1 x

rujialiu
Goblin
Posts: 235
Joined: Mon May 09, 2016 8:21 am
x 24

Re: [2.2] How to compile MyGUI for Ogre 2.2

Post by rujialiu » Mon Oct 21, 2019 2:54 am

dark_sylinc wrote:
Sun Oct 20, 2019 11:50 pm
Update: I've pushed a documentation update to clarify this
Oh, thanks! So the MyGUI code should also call renderPassPrepare BEFORE you wrote the assertions. I guess everyone here, like me, don't use MyGUI in Metal RS 8-)
0 x

Post Reply