[2.2]Porting my engine to 2.2

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1044
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 73

[2.2]Porting my engine to 2.2

Post by xrgo » Tue Jan 08, 2019 7:11 pm

Hello! I started porting my engine to Ogre 2.2 (from 2.1), so I am going to be posting some questions in this thread..
the first problem I have is this:

Code: Select all

    //Init Ogre::Root, with no cfg Files
    mRoot = new Ogre::Root("","");
    
    //Install RenderSystem Plugin
    Ogre::GL3PlusPlugin* glPlugin = OGRE_NEW Ogre::GL3PlusPlugin();
    Ogre::Root::getSingleton().installPlugin(glPlugin);

    //Use the first available Renderer
    Ogre::RenderSystem* renderSys = mRoot->getAvailableRenderers()[0];
    mRoot->setRenderSystem(renderSys);

    //Initialize Root
    mRoot->initialise(false);

    std::cout<<"renderSys  "<<renderSys<<std::endl;
    std::cout<<"getTextureGpuManager  "<<renderSys->getTextureGpuManager()<<std::endl;
I get this output:
renderSys 0000020502B37ED0
getTextureGpuManager 0000000000000000
in other words TextureGpuManager is null, do I have to create it somehow?

Thank you so much in advance!
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Tue Jan 08, 2019 10:44 pm

The TextureGpuManager ptr will be created when you create your first window (first window creates a lot of API resources), which hasn't happened yet in the code you posted

Cheers
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Wed Jan 09, 2019 7:14 pm

Thank you, yes that was it, I have a window manager and I was creating the window later, I rearranged some things and now its working, thanks!

Now I have the next problem:

I have my objects using datablocks that derive from HlmsPbs, I commented everything so now they basically look like this:
OgreHlmsPbs.h:

Code: Select all

#ifndef YHLMSPBSEXTENDED_H
#define YHLMSPBSEXTENDED_H

#include "yHlmsPbsExtended.h"

class yHlmsPbsDatablockExtended;

class yHlmsPbsExtended : public Ogre::HlmsPbs
{
public:
    yHlmsPbsExtended( Ogre::Archive *dataFolder, Ogre::ArchiveVec *libraryFolders );

    Ogre::HlmsDatablock* createDatablockImpl( Ogre::IdString datablockName,
                                                        const Ogre::HlmsMacroblock *macroblock,
                                                        const Ogre::HlmsBlendblock *blendblock,
                                                        const Ogre::HlmsParamVec &paramVec ) override;
};

#endif // YHLMSPBSEXTENDED_H
yHlmsPbsExtended.cpp

Code: Select all

#include "yHlmsPbsExtended.h"
#include "yHlmsPbsDatablockExtended.h"
#include "OgreRoot.h"
#include "OgreHlmsManager.h"
#include "CommandBuffer/OgreCommandBuffer.h"
#include "CommandBuffer/OgreCbTexture.h"
#include "CommandBuffer/OgreCbShaderBuffer.h"
#include "OgreTextureGpuManager.h"

#include <iostream>


yHlmsPbsExtended::yHlmsPbsExtended( Ogre::Archive *dataFolder, Ogre::ArchiveVec *libraryFolders ) :
    HlmsPbs( dataFolder, libraryFolders )
{
}

Ogre::HlmsDatablock* yHlmsPbsExtended::createDatablockImpl( Ogre::IdString datablockName,
                                                   const Ogre::HlmsMacroblock *macroblock,
                                                   const Ogre::HlmsBlendblock *blendblock,
                                                   const Ogre::HlmsParamVec &paramVec )
{
    return OGRE_NEW yHlmsPbsDatablockExtended( datablockName, this, macroblock, blendblock, paramVec );
}
yHlmsPbsDatablockExtended.h:

Code: Select all

#ifndef YHLMSPBSDATABLOCKEXTENDED_H
#define YHLMSPBSDATABLOCKEXTENDED_H

#include "OgreHlmsPbsDatablock.h"
#include "OgreHlmsTextureManager.h"
#include "OgreConstBufferPool.h"
#include "OgreVector4.h"

#include "OgreHeaderPrefix.h"

class yHlmsPbsDatablockExtended : public Ogre::HlmsPbsDatablock
{
    friend class yHlmsPbsExtended;
public:
    yHlmsPbsDatablockExtended( Ogre::IdString name, yHlmsPbsExtended *creator,
                               const Ogre::HlmsMacroblock *macroblock,
                               const Ogre::HlmsBlendblock *blendblock,
                               const Ogre::HlmsParamVec &params );
};

#endif // YHLMSPBSDATABLOCKEXTENDED_H
yHlmsPbsDatablockExtended.cpp:

Code: Select all

#include "yHlmsPbsDatablockExtended.h"
#include "yHlmsPbsExtended.h"
#include "OgreCubemapProbe.h"
#include "OgreHlmsManager.h"
#include "OgreTextureGpu.h"
#include "OgreTextureGpuManager.h"
#include "OgreRenderSystem.h"
#include "OgreTextureFilters.h"
#include "OgreLogManager.h"

#include <iostream>

yHlmsPbsDatablockExtended::yHlmsPbsDatablockExtended( Ogre::IdString name, yHlmsPbsExtended *creator,
                                                      const Ogre::HlmsMacroblock *macroblock,
                                                      const Ogre::HlmsBlendblock *blendblock,
                                                      const Ogre::HlmsParamVec &params ) :
    Ogre::HlmsPbsDatablock( name, creator, macroblock, blendblock, params )
{
    
}
so it should behave just like default hlmsPbs (If I am not missing something)
I also commented out my custom pieces and my pbs Listener

but I get this crash:
Image

basically mTexturesDescSet and mSamplersDescSet are null

I also removed the loading of texture and it also crashes

any ideas?
Thank youuuuuuu
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Wed Jan 09, 2019 7:28 pm

Ooops. That's a bug.

The code should check if datablock->mTexturesDescSet is a nullptr. This can happen if the material doesn't have textures.

This is a really easy fix, but I guess I should try myself that because if that's crashing, that means alpha testing was never tested :O
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Wed Jan 09, 2019 8:07 pm

Fixed. Thanks for the report!
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Wed Jan 09, 2019 11:09 pm

thank you so much!!

got this error:
error C1115: unable to find compatible overloaded function "mix(float, vec3, float)"
solved by changing this:

Code: Select all

pixelData.F0 = lerp( 0.03f, pixelData.diffuse.xyz * 3.14159f, metalness );
to this:

Code: Select all

pixelData.F0 = lerp( vec3(0.03f), pixelData.diffuse.xyz * 3.14159f, vec3(metalness) );
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Wed Jan 09, 2019 11:46 pm

Thanks! Pushed another fix.

Your fix was correct. It's just that our change is API-agnostic (make_float_fresnel is a macro) and I also spotted another bug when sampling the metalness map (it is always monochrome).
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Thu Jan 10, 2019 2:21 pm

Thanks x 10^64

next problem:

I got this funny effect when enabling MSAA:

Image

what could that be?
this is my compositor:

Code: Select all

void yWorkspaceManager::createMainWorkspaceDefinition(){

    yAssert( yUtils::isGraphicsThread(), "Main workspace must be created in Graphics thread" );


    //MAIN RENDER NODE DEFINITION
    Ogre::CompositorNodeDef *renderNodeDef = mCompositorManager->addNodeDefinition( "MainEngineRenderingNode" );

    renderNodeDef->addTextureSourceName( "renderwindow", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT );
    renderNodeDef->addTextureSourceName( "TerraShadowTexture", 1, Ogre::TextureDefinitionBase::TEXTURE_INPUT );

    renderNodeDef->setNumLocalTextureDefinitions(1);

    Ogre::TextureDefinitionBase::TextureDefinition *renderTex = renderNodeDef->addTextureDefinition( "renderAux" );
    renderTex->format = Ogre::PFG_RGBA16_FLOAT;
    renderTex->msaa = 0; //use target's MSAA value (render window)


    float supersampleFactor = 1.0f;

    Ogre::String buffer;
    if( yUtils::getConfigFileSetting( "SuperSampling", buffer ) ) {
        supersampleFactor = Ogre::StringConverter::parseReal( buffer );
    }

    renderTex->widthFactor = supersampleFactor;
    renderTex->heightFactor = supersampleFactor;

    Ogre::RenderTargetViewDef *rtv = renderNodeDef->addRenderTextureView( "renderAux" );
    Ogre::RenderTargetViewEntry attachment;
    attachment.textureName = "renderAux";
    rtv->colourAttachments.push_back( attachment );
    rtv->depthBufferId = Ogre::DepthBuffer::POOL_NO_DEPTH;



    renderNodeDef->setNumTargetPass( 2 );
    {
        {
            Ogre::CompositorTargetDef *targetDef = renderNodeDef->addTargetPass( "renderAux" );
            targetDef->setNumPasses( 2 );

            //CLEAR
            Ogre::CompositorPassClearDef *passClearDef = static_cast<Ogre::CompositorPassClearDef*>( targetDef->addPass( Ogre::PASS_CLEAR ) );
            passClearDef->setAllClearColours( Ogre::ColourValue::Black );
            //passClearDef->mClearBufferFlags = Ogre::FBT_COLOUR;
            passClearDef->mProfilingId = "MAIN_CLEAR_PASS";

            //SCENE
            mPassSceneDef = static_cast<Ogre::CompositorPassSceneDef*>( targetDef->addPass( Ogre::PASS_SCENE ) );
            mPassSceneDef->mExposedTextures.push_back( "TerraShadowTexture" );
            if( !mDisableShadows ){
                mPassSceneDef->mShadowNode = "MainEngineShadowNode";
            }
            mPassSceneDef->mProfilingId = "MAIN_SCENE_PASS";
            mPassSceneDef->mIdentifier = 25001;
        }
        {
            Ogre::CompositorTargetDef *targetDef = renderNodeDef->addTargetPass( "renderwindow" );
            targetDef->setNumPasses( 1 );

            //QUAD
            Ogre::CompositorPassQuadDef *passQuadDef = static_cast<Ogre::CompositorPassQuadDef*>( targetDef->addPass( Ogre::PASS_QUAD ) );
            passQuadDef->mMaterialName = "FinalProcessingMat";
            passQuadDef->addQuadTextureSource( 0, "renderAux" );
            passQuadDef->mProfilingId = "MAIN_FINAL_PROCESSING_QUAD_PASS";
        }

    }

    //MAIN WORKSPACE DEFINITION
    Ogre::CompositorWorkspaceDef *workspaceDef = mCompositorManager->addWorkspaceDefinition( "MainEngineWorkspace" );
    workspaceDef->connectExternal( 0, "MainEngineRenderingNode", 0 );
    workspaceDef->connectExternal( 1, "MainEngineRenderingNode", 1 ); //for terra shadows

}

also, in a few words or example, whats the purpose of RenderTargetViewDef? edit: found the Ogre2.2.Changes.md file, *reading*

thanks!!
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Thu Jan 10, 2019 4:48 pm

You're missing renderTex->textureFlags = TextureFlags::RenderToTexture. It's weird that Ogre did not complain.
I suggest you compare your snippet against CompositorTextureBaseTranslator::translateTextureProperty, which is the code responsible for setting up a texture from scripts.

I don't see what else could be wrong in that code but I have a few suggestions (btw looks like your FinalProcessingMat shader expects a 2D texture but it's receiving an MSAA texture, or vice versa. Triple check with RenderDoc what's bound in each slot and what the shader expects):

1. Your clear and scene pass can be merged into one. Scene passes can issue clears of their own.
On the Scene pass def:

Code: Select all

mPassSceneDef->setAllLoadActions( LoadAction::Clear );
mPassSceneDef->setAllStoreActions( StoreAction::MultisampleResolve ); //Asuming you won't be using your MSAA buffer directly, else use Store or StoreAndMultisampleResolve
2. It seems you're only rendering a large quad to the RenderWindow. If that's so, then it's pointless to set the RenderWindow to use MSAA. The reasons are explained in Ogre2.2.Changes.md, also explained in the Progress Report from last year.

I suggest you create an explicit MSAA texture, and either directly resolve to the render window, or have your shader read the msaa content directly:

Code: Select all

void yWorkspaceManager::createMainWorkspaceDefinition(){

    yAssert( yUtils::isGraphicsThread(), "Main workspace must be created in Graphics thread" );


    //MAIN RENDER NODE DEFINITION
    Ogre::CompositorNodeDef *renderNodeDef = mCompositorManager->addNodeDefinition( "MainEngineRenderingNode" );

    renderNodeDef->addTextureSourceName( "renderwindow", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT );
    renderNodeDef->addTextureSourceName( "TerraShadowTexture", 1, Ogre::TextureDefinitionBase::TEXTURE_INPUT );

    renderNodeDef->setNumLocalTextureDefinitions(1);

    Ogre::TextureDefinitionBase::TextureDefinition *renderTex = renderNodeDef->addTextureDefinition( "renderAux" );
    renderTex->format = Ogre::PFG_RGBA16_FLOAT;
    renderTex->msaa = SET_MSAA_HERE;
    renderTex->textureFlags = TextureFlags::RenderToTexture | TextureFlags::MsaaExplicitResolve;

    float supersampleFactor = 1.0f;

    Ogre::String buffer;
    if( yUtils::getConfigFileSetting( "SuperSampling", buffer ) ) {
        supersampleFactor = Ogre::StringConverter::parseReal( buffer );
    }

    renderTex->widthFactor = supersampleFactor;
    renderTex->heightFactor = supersampleFactor;

    Ogre::RenderTargetViewDef *rtv = renderNodeDef->addRenderTextureView( "renderAux" );
    Ogre::RenderTargetViewEntry attachment;
    attachment.textureName = "renderAux";
    //attachment.resolveTextureName = "renderwindow"; //UNCOMMENT THIS TO resolve directly to RenderWindow
    rtv->colourAttachments.push_back( attachment );
    rtv->depthBufferId = Ogre::DepthBuffer::POOL_NO_DEPTH;



    renderNodeDef->setNumTargetPass( 2 );
    {
        {
            Ogre::CompositorTargetDef *targetDef = renderNodeDef->addTargetPass( "renderAux" );
            targetDef->setNumPasses( 1 );

            //CLEAR
            Ogre::CompositorPassClearDef *passClearDef = static_cast<Ogre::CompositorPassClearDef*>( targetDef->addPass( Ogre::PASS_CLEAR ) );
            passClearDef->setAllClearColours( Ogre::ColourValue::Black );
            //passClearDef->mClearBufferFlags = Ogre::FBT_COLOUR;
            passClearDef->mProfilingId = "MAIN_CLEAR_PASS";

            //SCENE
            mPassSceneDef = static_cast<Ogre::CompositorPassSceneDef*>( targetDef->addPass( Ogre::PASS_SCENE ) );
            mPassSceneDef->setAllClearColours( Ogre::ColourValue::Black );
            mPassSceneDef->setAllLoadActions( LoadAction::Clear );
            mPassSceneDef->setAllStoreActions( StoreAction::Store );
            mPassSceneDef->mExposedTextures.push_back( "TerraShadowTexture" );
            if( !mDisableShadows ){
                mPassSceneDef->mShadowNode = "MainEngineShadowNode";
            }
            mPassSceneDef->mProfilingId = "MAIN_SCENE_PASS";
            mPassSceneDef->mIdentifier = 25001;
        }
        {
            Ogre::CompositorTargetDef *targetDef = renderNodeDef->addTargetPass( "renderwindow" );
            targetDef->setNumPasses( 1 );

            //QUAD
            Ogre::CompositorPassQuadDef *passQuadDef = static_cast<Ogre::CompositorPassQuadDef*>( targetDef->addPass( Ogre::PASS_QUAD ) );
            passQuadDef->setAllLoadActions( LoadAction::DontCare );
            passQuadDef->mMaterialName = "FinalProcessingMat";
            passQuadDef->addQuadTextureSource( 0, "renderAux" ); //Your shader better accept an msaa texture
            passQuadDef->mProfilingId = "MAIN_FINAL_PROCESSING_QUAD_PASS";
        }

    }

    //MAIN WORKSPACE DEFINITION
    Ogre::CompositorWorkspaceDef *workspaceDef = mCompositorManager->addWorkspaceDefinition( "MainEngineWorkspace" );
    workspaceDef->connectExternal( 0, "MainEngineRenderingNode", 0 );
    workspaceDef->connectExternal( 1, "MainEngineRenderingNode", 1 ); //for terra shadows

}
By doing this, you're avoiding a copy and a 2nd resolve, which will improve your performance, something Ogre 2.1 could not do.

To be clear this is what your code was doing:
Clear -> Render Scene -> Resolve renderAux -> Copy to RenderWindow -> Resolve Render Window (done by the OS) -> Present

Now your code will do:
Clear -> Render Scene -> Copy and resolve to RenderWindow (must be handled by your shader code) -> Present

If you didn't have supersampling feature, you could also set up your compositor to resolve directly to RenderWindow, without a copy:
Clear -> Render Scene -> Resolve to RenderWindow (you never run FinalProcessingMat) -> Present

Cheers
Matias
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Fri Jan 11, 2019 9:24 pm

thanks! damn MSAA is a whole world
the glitchy render Its fixed now by doing this:

Code: Select all

    renderTex->textureFlags = Ogre::TextureFlags::RenderToTexture;
    .........
            mPassSceneDef->setAllLoadActions( Ogre::LoadAction::Clear );
            mPassSceneDef->setAllStoreActions( Ogre::StoreAction::StoreAndMultisampleResolve );
also removed the clear pass

I have to test the other things you mentioned, but for now I prefer to advance on the next stuff...

I think MSAA its working, but I have a weird scaling issue that wont let me appreciate it:

I am rendering in to a Qt window, and I have this code:

Code: Select all

//Rezise Window Event
void yGraphicsRenderWindow::resizeEvent( QResizeEvent* rEvent ) {
    Q_UNUSED( rEvent );

    if( mOgreRenderWindow ){
        unsigned int width = uint( mRenderContainer->size().width() );
        unsigned int height = uint( mRenderContainer->size().height() );
        
        //mOgreRenderWindow->requestResolution( width, height );
        mOgreRenderWindow->requestResolution( 320, 240 );
        mOgreRenderWindow->windowMovedOrResized();

        std::cout<<"valueeeezzz"<<std::endl;
        std::cout<<mOgreRenderWindow->getRequestedWidth()<<std::endl;
        std::cout<<mOgreRenderWindow->getRequestedHeight()<<std::endl;
        std::cout<<"---"<<std::endl;
        std::cout<<mOgreRenderWindow->getWidth()<<std::endl;
        std::cout<<mOgreRenderWindow->getHeight()<<std::endl;
    }
}
my window is 1280*720 when that event is called, but I am forcing to 320x240 for testing and I get this values:
valueeeezzz
1296
759
---
1296
759
I call requestResolution( 320, 240 ) but the getRequested is 1296 x 759, I have no idea where that values comes from
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Fri Jan 11, 2019 10:24 pm

btw, theres a duplicated @insertpiece( custom_ps_posMaterialLoad ) in 800.PixelShader_piece_ps.any
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Sat Jan 12, 2019 12:04 am

My guess is that when you call windowMovedOrResized, we retrieve the window's properties and find out the window is larger, thus the requested resolution cannot be satisfied. That works the same as 2.1

1296x759 sounds like 1280x720 after border information (i.e. title bar and the window borders)
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 1:15 am

dark_sylinc wrote:
Sat Jan 12, 2019 12:04 am
That works the same as 2.1
strange, in 2.1 I do get the resolution asked:
Image

I tried moving the windowMovedOrResized after the getRequested to see if the windowMovedOrResized call reseted the values:

Code: Select all

        mOgreRenderWindow->requestResolution( 320, 240 );

        std::cout<<"valueeeezzz"<<std::endl;
        std::cout<<mOgreRenderWindow->getRequestedWidth()<<std::endl;
        std::cout<<mOgreRenderWindow->getRequestedHeight()<<std::endl;
        std::cout<<"---"<<std::endl;
        std::cout<<mOgreRenderWindow->getWidth()<<std::endl;
        std::cout<<mOgreRenderWindow->getHeight()<<std::endl;

        mOgreRenderWindow->windowMovedOrResized();
same output =(

I'll keep looking, thanks!
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Sat Jan 12, 2019 1:21 am

I don't know what to say other than to step inside windowMovedOrResized and requestResolution(2.2)/resize(2.1) and compare why 2.1 and 2.2 are different....

What's the 2.1's equivalent code? I'm guessing you call resize instead of requestResolution?
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 1:37 am

dark_sylinc wrote:
Sat Jan 12, 2019 1:21 am
I don't know what to say other than to step inside windowMovedOrResized and requestResolution(2.2)/resize(2.1) and compare why 2.1 and 2.2 are different....
yes! I am on it
dark_sylinc wrote:
Sat Jan 12, 2019 1:21 am
What's the 2.1's equivalent code? I'm guessing you call resize instead of requestResolution?
exactly
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 2:00 am

solved:
found that is not entering the if( !mIsExternal ) (obviously) so is attached to the Qwidget (mRenderContainer) size all the time, and the widget is a windowCointainer that actually holds "this" which is a QWindow, so the problem is solved just by doing (this->)setFlags( Qt::FramelessWindowHint ); so, as you said, the borders and bar is eliminated (which are not visible anyways when creating the cointainer)
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 4:42 pm

in case this helps someone, I had another problem, some objects looked behind while being front when I have a quad pass active:

Image

Image

solved by using rtv->depthBufferId = Ogre::DepthBuffer::POOL_DEFAULT;

Now the next problem:
All the textures are black =(
On my HlmsSkyDome textures are working! but in the pbs objects don't, strange thing is that they do seems to load correctly in code:

Code: Select all

                ogreTexture = mTextureManager->createOrRetrieveTexture(
                                                    texture->mTextureData.mFileName,
                                                    Ogre::GpuPageOutStrategy::Discard,
                                                    Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB,
                                                    Ogre::TextureTypes::Type2DArray,
                                                    Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
                ogreTexture->scheduleTransitionTo( Ogre::GpuResidency::Resident );

                //for debugging:
                ogreTexture->waitForMetadata();
                ogreTexture->waitForData();
                std::cout<<"================"<<std::endl;
                std::cout<<texture->mTextureData.mFileName<<std::endl;
                std::cout<<ogreTexture->getWidth()<<std::endl;
                std::cout<<ogreTexture->getHeight()<<std::endl;
                std::cout<<ogreTexture->getRealResourceNameStr()<<std::endl;
The output is correct for every texture

And the shader is being created with the textureMaps0:

Code: Select all

pixelData.diffuse = SampleDiffuse( textureMaps0,
										   samplerState5,
										   UV_DIFFUSE( inPs.uv0.xy ),
										   texIndex_diffuseIdx );
I can confirm that is the texture since I do

Code: Select all

outColour.xyz = pixelData.diffuse.xyz;
return;
right after and is completely black

Btw what is samplerState5? is not defined anywhere in the output shader, why is not crashing? and I cant find it in the templates.

The hlmspbs I am using is the one I mentioned a few post before, its derived from hlmpbs but its doing nothing right now

I am going to try to run renderdoc, but last time I tried it crashed everytime
owyeah its running, and in textureMaps0 says No Resource, so it must be a binding stuff, i'll keep diggin'
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 5:58 pm

I put a breakpoint in line 2466 (OgreHlmsPBs.cpp):

Image

and it seems to be reaching the correct texture, at least width, height and name is correct

mHasSeparateSamplers seems to be always false so its entering the if( !mHasSeparateSamplers ) but no the if( datablock->mSamplersDescSet != mLastDescSampler && mHasSeparateSamplers )
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 6:09 pm

fixed!!!
createorretreive the texture as Ogre::TextureTypes::Type2D with Ogre::TextureFlags::AutomaticBatching ,
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Sat Jan 12, 2019 6:37 pm

xrgo wrote:
Sat Jan 12, 2019 6:09 pm
fixed!!!
createorretreive the texture as Ogre::TextureTypes::Type2D with Ogre::TextureFlags::AutomaticBatching ,
Yep, the vast majority of textures will use that setting combination. When AutomaticBatching is set, the TextureGpu will pretend it's Type2D, but it's internally a Type2DArray.
When e.g. you ask to copy the texture to another texture, we internally offset the slice (or slices if both are auto batched) to point to the right slice in the array.

Btw, because these flags were not user-friendly when all you wanted was to load a texture from file, I added another overload to createOrRetrieve that is much friendlier, and has similar parameters to the HlmsTextureManager. See the one that accepts CommonTextureTypes as argument.
If you see its code, it's nothing fancy: It just setups the filters and flags for you based on the CommonTextureTypes preset.
xrgo wrote:
Sat Jan 12, 2019 5:58 pm
mHasSeparateSamplers seems to be always false so its entering the if( !mHasSeparateSamplers ) but no the if( datablock->mSamplersDescSet != mLastDescSampler && mHasSeparateSamplers )
For OpenGL mHasSeparateSamplers will always be false, for the rest of the APIs it will always be true. This is an optimization for the APIs that support it.
Btw what is samplerState5? is not defined anywhere in the output shader, why is not crashing? and I cant find it in the templates.
It is the sampler associated with that texture. But OpenGL has no such thing (hence mHasSeparateSamplers = false). You'll see the macro completely ignores that parameter, so the final code will not contain it e.g.

Code: Select all

//GLSL version
#define OGRE_Sample( myTexture, mySampler, uv ) texture( myTexture, uv )
//D3D11/HLSL version
#define OGRE_Sample( myTexture, mySampler, uv ) myTexture.Sample( mySampler, uv )
That's why you can't find samplerState5 defined anywhere in the GLSL snippet and why it doesn't crash either.
2 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Sat Jan 12, 2019 6:39 pm

thank you for the explanation!
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Mon Jan 14, 2019 1:34 am

Hi!

Because you're porting to 2.2; I just added Reverse Depth to Ogre 2.2
It can be toggled on/off at init time.

While most of the time it's "turn on and it just works", it may require additional work for code with custom matrices (e.g. VR), and a few shaders (like the sky, because the back of the screen is now z = 0.0; also see ReconstructPosFromDepth needed a few tweaks).

I suggest that you disable it (via params.insert( std::make_pair("reverse_depth", "No" ) );) until you get your 2.2 build up and running. Only then you should play with it. I also need to write a few recommendations on how to fix the problems that may arise.
1 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Mon Jan 14, 2019 2:37 pm

yeah thanks!!!!!!!
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by xrgo » Tue Jan 15, 2019 1:56 pm

still many things to port, but looking good so far, for example in one simulator I had 3.4GB vram usage, now its at 2.5GB! nice!
fps (in noVR) seems to be the same... but I just tried VR and I get a crash here:

Code: Select all

    Ogre::TextureGpuManager* textureManager = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
    mEyesRenderTexture = textureManager->createTexture( "OpenVRRenderTexture",
                                                              Ogre::GpuPageOutStrategy::Discard,
                                                              Ogre::TextureFlags::RenderToTexture,
                                                              Ogre::TextureTypes::Type2D );

    mEyesRenderTexture->setResolution( mRenderWidth*2, mRenderHeight );
    mEyesRenderTexture->setNumMipmaps( 0 );
    mEyesRenderTexture->setPixelFormat( Ogre::PixelFormatGpu::PFG_RGBA8_UNORM_SRGB );
    mEyesRenderTexture->setMsaa( msaa );
    mEyesRenderTexture->_transitionTo( Ogre::GpuResidency::Resident, (uint8*)0 );
    mEyesRenderTexture->waitForData();

    bool bFSAA;
    mTextureBounds[0] = { 0.0f, 1.0f, 0.5f, 0.0f }; //flip vertically
    mTextureBounds[1] = { 0.5f, 1.0f, 1.0f, 0.0f }; //flip vertically

    GLuint srcidL = ((Ogre::GL3PlusTexture*)mEyesRenderTexture)->getGLID(bFSAA); <<CRASH HEREEEEEEEEE
    mEyeTexture = { (void*)srcidL, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
but just sometimes, when no crash I get a black image (but I might have some compositor problems yet)

I guess that casting is no longer valid? so how can I get de GLID?
0 x

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

Re: [2.2]Porting my engine to 2.2

Post by dark_sylinc » Tue Jan 15, 2019 3:46 pm

I see 3 problems in that code you posted:

1.

Code: Select all

mEyesRenderTexture->setNumMipmaps( 0 );
This is invalid. Ogre 2.1 doesn't count the base mipmap, Ogre 2.2 does. So you should use a 1.
This will trigger an assert, so please run in Debug mode to catch bad API usage more easily.

Also remember this applies to getNumMipmaps too. See 'Things to watch out when porting' from the manual.

2. Change this code:

Code: Select all

mEyesRenderTexture->_transitionTo( Ogre::GpuResidency::Resident, (uint8*)0 );
mEyesRenderTexture->waitForData();
For this:

Code: Select all

mEyesRenderTexture->_transitionTo( Ogre::GpuResidency::Resident, (uint8*)0 );
mEyesRenderTexture->notifyDataIsReady();
waitForData() is for regular textures (i.e. AutomaticBatching) waiting on the worker thread to finish loading the image from file/memory.
When you're loading the texture by hand or manipulating a RenderTexture, etc, call notifyDataIsReady to indicate Ogre the texture is ready to be displayed.

3. This is the actual crash. Obviously that cast is invalid now.

Code: Select all

GLuint srcidL = ((Ogre::GL3PlusTexture*)mEyesRenderTexture)->getGLID(bFSAA); <<CRASH HEREEEEEEEEE
    mEyeTexture = { (void*)srcidL, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
You can replace it with:

Code: Select all

GLuint srcidL = static_cast<Ogre::GL3PlusTextureGpu*>(mEyesRenderTexture)->getFinalTextureName();
    mEyeTexture = { (void*)srcidL, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
I'm not sure whether you want getMsaaFramebufferName here. You have 3 functions. I just added documentation to them to clarify what they do.
0 x

Post Reply