[2.1] PsoCacheHelper Usage Questions (porting imgui)

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

[2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Herb » Tue Jan 16, 2018 6:49 pm

Ok, I'm working on a new app with 2.1 and trying to use imgui for the GUI.

I found a nice person who ported the code to an earlier version of 2.1
https://bitbucket.org/ChaosCreator/imgu ... .1-binding

However, the 2.1 API has changed. I found dark_sylinc has made a helper class for this called PsoCacheHelper with some comments in there for usage, this was geared for Gorilla but imgui should be able to use it being an immediate gui.

So, referencing code in the above repo with the old 2.1 API, there's a class called ImguiManager where the tweaks are needed. I added a PsoCacheHelper to the class.

In Imgui::render, is where the fixes are needed.

Link to raw ImguiManager.cpp file HERE

This

Code: Select all

	const Ogre::HlmsBlendblock *blendblock = mPass->getBlendblock();
	const Ogre::HlmsMacroblock *macroblock = mPass->getMacroblock();
	mSceneMgr->getDestinationRenderSystem()->_setHlmsBlendblock(blendblock);
	mSceneMgr->getDestinationRenderSystem()->_setHlmsMacroblock(macroblock);
Changed to:

Code: Select all

    const Ogre::HlmsBlendblock *blendblock = mPass->getBlendblock();
    const Ogre::HlmsMacroblock *macroblock = mPass->getMacroblock();
    //mSceneMgr->getDestinationRenderSystem()->_setHlmsBlendblock(blendblock);
    //mSceneMgr->getDestinationRenderSystem()->_setHlmsMacroblock(macroblock);

    mPSOCache->clearState();
    /// @todo What do I put here????
    mPSOCache->setRenderTarget(?);

    mPSOCache->setMacroblock(macroblock);
    mPSOCache->setBlendblock(blendblock);
This makes sense, but I'm not sure what to put into the render target.... Anybody know?

This:

Code: Select all

			//render the object
			mSceneMgr->_injectRenderWithPass(mPass, mRenderables[i], 0, false, false);
Changed to:

Code: Select all

			//render the object
            //mSceneMgr->_injectRenderWithPass(mPass, mRenderables[i], 0, false, false);

            // xtitus - changes for 2.1 rendering with PSO
            Ogre::v1::RenderOperation renderOp;
            mRenderables[i]->getRenderOperation(renderOp, false);

            bool enablePrimitiveRestart = true;  // is this right???


            Ogre::VertexElement2VecVec vertexElements = renderOp.vertexData->
                    vertexDeclaration->convertToV2();
            mPSOCache->setVertexFormat( vertexElements,
                                      renderOp.operationType,
                                      enablePrimitiveRestart );

            Ogre::HlmsPso *pso = mPSOCache->getPso();
            mSceneMgr->getDestinationRenderSystem()->_setPipelineStateObject( pso );
I think this part looks like I'm on the right track, but wasn't sure on the "enablePrimitiveRestart"... Thoughts?

Thanks in advance for any help on this as I'm newer to using Ogre 2.1, been using Ogre 1.9 and lower for years... :)
0 x

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

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by dark_sylinc » Tue Jan 16, 2018 11:46 pm

Hi!

Regarding setRenderTarget, that goes the RenderTarget you're currently rendering to (could be the RenderWindow, a RenderTexture from the compositor, etc).
Since rendering is done inside a compositor, this information is in CompositorPass::mTarget. I don't know how IMGUI is interfaced with Ogre. If a custom compositor pass is used, then accessing that info should already be easy. If not, then sceneManager->getCurrentViewport()->getTarget() may have that info.

Code: Select all

I think this part looks like I'm on the right track, but wasn't sure on the "enablePrimitiveRestart"... Thoughts?
Primitive restart is used for rendering triangle strips. If IMGUI doesn't use tri strips, then this setting is not relevant. If IMGUI does use tri strip; if it doesn't need prim restart; then setting this value to true will very rarely produce rendering errors. If you set it to false and IMGUI does rely on it, then it will be easy to spot it (lots of glitches will be visible). To sumarize:
  • IMGUI needs it. enablePrimitiveRestart = true -> Correct render
  • IMGUI doesn't need it. enablePrimitiveRestart = true -> Most likely always correct, but could be ocassional glitch
  • IMGUI needs it. enablePrimitiveRestart = false -> Extreme glitches. Impossible not to notice.
  • IMGUI doesn't need it. enablePrimitiveRestart = false -> Correct render
My suggestion is leave it as false. If you see extreme corruption then you likely need it to be true.

Cheers
0 x

User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Herb » Wed Jan 17, 2018 7:26 pm

Ah, ok. That really helps explain on the rendertarget. Should be easy enough. I'll make the changes and see how it's working. Thanks dark_sylinc! :D
0 x

User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Herb » Thu Jan 25, 2018 6:50 pm

Finally got a chunk of time to work on dark_sylinc's advice, but having no luck....not sure on how really to debug this further... Anyone have any luck with the PsoCacheHelper class? I know dark_sylinc said it was not tested. :wink:

So, I init the ImGUIManager class doing:

Code: Select all

mPSOCache = new Ogre::PsoCacheHelper(Ogre::Root::getSingletonPtr()->getRenderSystem());
Then in the render I had to make a couple of changes... First see below with the commented out code what was in there before.

Code: Select all

    const Ogre::HlmsBlendblock *blendblock = mPass->getBlendblock();
    const Ogre::HlmsMacroblock *macroblock = mPass->getMacroblock();
    //mSceneMgr->getDestinationRenderSystem()->_setHlmsBlendblock(blendblock);
    //mSceneMgr->getDestinationRenderSystem()->_setHlmsMacroblock(macroblock);

    mPSOCache->clearState();
    mPSOCache->setRenderTarget(vp->getTarget());   // dark_sylinc's advice on setting rendertarget, which looks like the renderwindow obj)

    mPSOCache->setMacroblock(macroblock);
    mPSOCache->setBlendblock(blendblock);
Then I need to loop through all the Ogre::Renderables to draw. So for each object to render here's the main snippet.

Code: Select all

	    //render the object
            
            // this is no longer available in newer 2.1 API
            //mSceneMgr->_injectRenderWithPass(mPass, mRenderables[i], 0, false, false);

            // xtitus - changes for 2.1 rendering with PSO
            Ogre::v1::RenderOperation renderOp;
            mRenderables[i]->getRenderOperation(renderOp, false);

            bool enablePrimitiveRestart = true;  // tried both true and false...no change

            Ogre::VertexElement2VecVec vertexElements = renderOp.vertexData->
                    vertexDeclaration->convertToV2();
            mPSOCache->setVertexFormat( vertexElements,
                                      renderOp.operationType,
                                      enablePrimitiveRestart );

            Ogre::HlmsPso *pso = mPSOCache->getPso();
            mSceneMgr->getDestinationRenderSystem()->_setPipelineStateObject( pso );
Does anything look wrong in this? Thoughts @dark_sylinc? Just don't get anything on the screen, so not sure where to poke at next. Also coming up on 2.1 as most of years of ogre have been in the 1.7-1.9 version. Thanks!
0 x

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

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by dark_sylinc » Thu Jan 25, 2018 7:32 pm

At no point I see you're actually issuing a rendering command.
You're never calling RenderSystem::_render(const v1::RenderOperation& op), thus nothing will be drawn. You're basically loading a truck with all the things you need to send to destination, ensure the gas tank is full, but never actually dispatching the truck driver to perform the trip.
0 x

User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Herb » Thu Jan 25, 2018 8:24 pm

Yeah, I was wondering how the render happened... I didn't see any render call in your code comments in OgrePsoCacheHelper header so had the impression it was being called differently. Ok, so I added that to the very end.

So, every IMGUI renderable gets rendered with:

Code: Select all

mSceneMgr->getDestinationRenderSystem()->_render(renderOp);
I still don't have anything rendering to the screen... :cry: I'll keep digging. It's sounding like something really small.
0 x

Jay721
Halfling
Posts: 41
Joined: Mon Jan 29, 2018 8:19 am

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Jay721 » Sun Feb 11, 2018 12:24 pm

Did you get this working? I’m looking into getting ImGui on ogre too.
0 x

User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Herb » Sun Feb 11, 2018 2:11 pm

No, I didn’t.... I made the suggested changes and i’ve looked through the debugger at all the objects and everything looks good, but nothing is displayed on the screen... i’ve paused on it for the moment until I can think of something else to try.
0 x

Scalu
Gnoblar
Posts: 2
Joined: Wed Mar 14, 2018 10:11 pm

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Scalu » Thu Mar 15, 2018 5:56 am

Hi,

I was hoping to use imgui with 2.1 as well, but it seems that this latest attempt to get it working with the latest code stalled. I might give it a try, but being a Ogre newb, I don't imagine I will make any headway. If someone has managed to get it rendering since the last post, please let me know. I might check some other gui libs if they are reported to be working with 2.1. Thanks!
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 535
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 11

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Slicky » Thu Sep 06, 2018 9:27 pm

I took a stab at this using 2.1 and did not have success. I do get some random rendering that flickers in different parts of the screen and once in a while I see some text rendered what looks like at 90 degrees but it flickers on and off. I also just get random lines.

Hardly a success and all I can go on is reading other forum posts.

I am using the psocachelper class.

Has anyone got any GUI type implementation to work using this class? I think it might be a common solution but I see zero people with a working version.
0 x

User avatar
Aiden
Halfling
Posts: 52
Joined: Fri Jul 14, 2017 3:16 pm
x 2

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Aiden » Sat Sep 22, 2018 3:15 pm

I've managed to fix ogre-ffmpeg player to work, I also created ogre-assimp adaptor which somebody ported to 2.1. Had to downgrade abit to 1.11 so I could use IMGUI.
What is the current progress on getting IMGUI to work n ogre 2.1 ?
I might give it a try, maybe I might get as lucky as I was on the other ogre plugin projects. After all, I only need some good time messing around with it and learning more about the ogre rendering api.
If anyone has some code that almost works, It might be useful right now.
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 535
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 11

Re: [2.1] PsoCacheHelper Usage Questions (porting imgui)

Post by Slicky » Sun Sep 23, 2018 7:02 am

Some people have ImGui working with 2.1.

I haven't seen a complete solution posted. I was able to get some flickering using psocachelper but nothing recognisable.
0 x

Post Reply