MyGUI / mygui

Fast, flexible and simple GUI.
http://mygui.info/
Other
713 stars 205 forks source link

Null program bound with D3D9RenderSystem::bindGpuProgram with Ogre 1.13 #229

Closed corentinjaffre closed 1 year ago

corentinjaffre commented 2 years ago

In my game editor when I load a new game/level I destroy and recreate MyGUI. It has been working perfectly for years until Ogre 1.13. Now, when I recreate a second-time MyGUI, the first call to RenderWindow->update() throw an exception: Null program bound with D3D9RenderSystem::bindGpuProgram. The exception occurs with MyGUI shader MyGUI_Ogre_VP.hlsl. The resource is marked as LOADSTATE_PREPARED the second time I restart MyGUI, could it be the issue?

My trace:

KernelBase.dll!7637c5af()   Unknown
    KernelBase.dll![Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll] Unknown
    [External Code] 
    RenderSystem_Direct3D9_d.dll!Ogre::ExceptionFactory::_throwException(Ogre::Exception::ExceptionCodes code=ERR_RENDERINGAPI_ERROR, int number=3, const std::string & desc={...}, const std::string & src={...}, const char * file=0x04741200, long line=3285) Line 266   C++
    RenderSystem_Direct3D9_d.dll!Ogre::ExceptionFactory::throwException(Ogre::Exception::ExceptionCodes code=ERR_RENDERINGAPI_ERROR, const std::string & desc={...}, const std::string & src={...}, const char * file=0x04741200, long line=3285) Line 282  C++
    RenderSystem_Direct3D9_d.dll!Ogre::D3D9RenderSystem::bindGpuProgram(Ogre::GpuProgram * prg=0x00000000) Line 3283    C++
    OgreMain_d.dll!Ogre::SceneManager::bindGpuProgram(Ogre::GpuProgram * prog=0x00000000) Line 3821 C++
    OgreMain_d.dll!Ogre::SceneManager::_setPass(const Ogre::Pass * pass=0x0543cf90, bool evenIfSuppressed=false, bool shadowDerivation=true) Line 868   C++
    ShmupCreator.exe!MyGUI::OgreRenderManager::begin() Line 317 C++
    ShmupCreator.exe!MyGUI::OgreRenderManager::renderQueueStarted(unsigned char queueGroupId='d', const std::string & invocation={...}, bool & skipThisInvocation=false) Line 205   C++
    OgreMain_d.dll!Ogre::SceneManager::fireRenderQueueStarted(unsigned char id='d', const std::string & invocation={...}) Line 2475 C++
    OgreMain_d.dll!Ogre::SceneManager::renderVisibleObjectsDefaultSequence() Line 1547  C++
    OgreMain_d.dll!Ogre::SceneManager::_renderVisibleObjects() Line 1522    C++
    OgreMain_d.dll!Ogre::SceneManager::_renderScene(Ogre::Camera * camera=0x08864138, Ogre::Viewport * vp=0x0cc3a370, bool includeOverlays=true) Line 1325  C++
    OgreMain_d.dll!Ogre::Camera::_renderScene(Ogre::Viewport * vp=0x0cc3a370) Line 496  C++
    OgreMain_d.dll!Ogre::Viewport::update() Line 219    C++
    OgreMain_d.dll!Ogre::RenderTarget::_updateViewport(Ogre::Viewport * viewport=0x0cc3a370, bool updateStatistics=true) Line 199   C++
    RenderSystem_Direct3D9_d.dll!Ogre::D3D9RenderWindow::_updateViewport(Ogre::Viewport * viewport=0x0cc3a370, bool updateStatistics=true) Line 841 C++
    OgreMain_d.dll!Ogre::RenderTarget::_updateAutoUpdatedViewports(bool updateStatistics=true) Line 176 C++
    OgreMain_d.dll!Ogre::RenderTarget::updateImpl() Line 153    C++
    OgreMain_d.dll!Ogre::RenderTarget::update(bool swap=false) Line 555 C++
>   ShmupCreator.exe!playState::startEditor() Line 4958 C++
    ShmupCreator.exe!playState::init(Ogre::RenderWindow * mrenderWindow=0x00731550, Ogre::OverlaySystem * OverlaySystem=0x0069d7a8, Game * mgam=0x01745818) Line 486    C++
    ShmupCreator.exe!GameManager::changeState(GameState * state=0x01746b98) Line 69 C++
    ShmupCreator.exe!GameState::changeState(GameState * state=0x01746b98) Line 40   C++
    ShmupCreator.exe!playState::Update(const double deltatime=0.033333000000000002) Line 1277   C++
    ShmupCreator.exe!GameManager::update(const double deltatime=0.033333000000000002) Line 103  C++
    ShmupCreator.exe!RealMain(HINSTANCE__ * hInstance=0x00ee0000, char * lpCmdLine=0x0064559f, int nCmdShow=10) Line 904    C++
    ShmupCreator.exe!WinMain(HINSTANCE__ * hInstance=0x00ee0000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x0064559f, int nCmdShow=10) Line 1046    C++
corentinjaffre commented 2 years ago

I fixed the issue by adding this to MyGUI:

mDefaultShader->vertexProgram->load();
mDefaultShader->fragmentProgram->load();
sercero commented 2 years ago

Where did you add that?

Can you make a pull request?

corentinjaffre commented 2 years ago

Actually I didn't make a PR, because I'm not sure of what is causing this issue. Anyway, I change in MyGUI_OgreRenderManager.cpp the void OgreRenderManager::registerShader method and added the 2 lines in

if (_shaderName == "Default")
{
    mDefaultShader = mRegisteredShaders[_shaderName];

    // Set the default shader
    mDefaultShader->vertexProgram->load();
    mDefaultShader->fragmentProgram->load();
    mPass->setVertexProgram(mDefaultShader->vertexProgram->getName());
    mPass->setFragmentProgram(mDefaultShader->fragmentProgram->getName());
}