[BUG] FSAA on Shadows raises exception when it shouldn't

Minor issues with the Ogre API that can be trivial to fix
Post Reply
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5586
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1413
Contact:

[BUG] FSAA on Shadows raises exception when it shouldn't

Post by dark_sylinc »

setShadowTextureConfig documentation says:
@param fsaa The level of multisampling to use. Ignored if the device does not support it.
However when setting FSAA in a device that doesn't support it (for the given texture format) will raise an exception instead. Call stack:

Code: Select all

>	RenderSystem_Direct3D9_d.dll!Ogre::D3D9Texture::_createNormTex(IDirect3DDevice9 * d3d9Device=0x058fc200)  Line 1139	C++
 	RenderSystem_Direct3D9_d.dll!Ogre::D3D9Texture::createInternalResourcesImpl(IDirect3DDevice9 * d3d9Device=0x058fc200)  Line 992	C++
 	RenderSystem_Direct3D9_d.dll!Ogre::D3D9Texture::createInternalResourcesImpl()  Line 964 + 0xc bytes	C++
 	RenderSystem_Direct3D9_d.dll!Ogre::D3D9Texture::createInternalResources()  Line 939 + 0x12 bytes	C++
 	OgreMain_d.dll!Ogre::TextureManager::createManual(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & name="Ogre/ShadowTexture2", const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & group="Internal", Ogre::TextureType texType=TEX_TYPE_2D, unsigned int width=1024, unsigned int height=1024, unsigned int depth=1, int numMipmaps=0, Ogre::PixelFormat format=PF_FLOAT32_R, int usage=512, Ogre::ManualResourceLoader * loader=0x00000000, bool hwGamma=false, unsigned int fsaa=2, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fsaaHint="")  Line 158 + 0x1d bytes	C++
 	OgreMain_d.dll!Ogre::TextureManager::createManual(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & name="Ogre/ShadowTexture2", const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & group="Internal", Ogre::TextureType texType=TEX_TYPE_2D, unsigned int width=1024, unsigned int height=1024, int num_mips=0, Ogre::PixelFormat format=PF_FLOAT32_R, int usage=512, Ogre::ManualResourceLoader * loader=0x00000000, bool hwGammaCorrection=false, unsigned int fsaa=2, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fsaaHint="")  Line 337 + 0x49 bytes	C++
 	OgreMain_d.dll!Ogre::ShadowTextureManager::getShadowTextures(const std::vector<Ogre::ShadowTextureConfig,Ogre::STLAllocator<Ogre::ShadowTextureConfig,Ogre::CategorisedAllocPolicy<0> > > & configList=[3]({width=2048 height=2048 format=PF_FLOAT32_R ...},{width=1024 height=1024 format=PF_FLOAT32_R ...},{width=1024 height=1024 format=PF_FLOAT32_R ...}), std::vector<Ogre::TexturePtr,Ogre::STLAllocator<Ogre::TexturePtr,Ogre::CategorisedAllocPolicy<0> > > & listToPopulate=[2]({...},{...}))  Line 115 + 0x4c bytes	C++
 	OgreMain_d.dll!Ogre::SceneManager::ensureShadowTexturesCreated()  Line 6076 + 0x33 bytes	C++
 	OgreMain_d.dll!Ogre::SceneManager::prepareShadowTextures(Ogre::Camera * cam=0x01dd8e90, Ogre::Viewport * vp=0x0d3fdab0, const Ogre::HashedVector<Ogre::Light *> * lightList=0x00000000)  Line 6206 + 0x12 bytes	C++
 	OgreMain_d.dll!Ogre::SceneManager::_renderScene(Ogre::Camera * camera=0x01dd8e90, Ogre::Viewport * vp=0x0d3fdab0, bool includeOverlays=false)  Line 1392 + 0x1c bytes	C++
 	OgreMain_d.dll!Ogre::Camera::_renderScene(Ogre::Viewport * vp=0x0d3fdab0, bool includeOverlays=false)  Line 426 + 0x2b bytes	C++
 	OgreMain_d.dll!Ogre::Viewport::update()  Line 219	C++
 	OgreMain_d.dll!Ogre::RenderTarget::_updateViewport(Ogre::Viewport * viewport=0x0d3fdab0, bool updateStatistics=true)  Line 200	C++
 	OgreMain_d.dll!Ogre::RenderTarget::_updateAutoUpdatedViewports(bool updateStatistics=true)  Line 177 + 0x1b bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::updateImpl()  Line 154 + 0x14 bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::update(bool swap=true)  Line 611 + 0x12 bytes	C++
 	RenderSystem_Direct3D9_d.dll!Ogre::D3D9MultiRenderTarget::update(bool swapBuffers=true)  Line 109 + 0x10 bytes	C++
 	OgreMain_d.dll!Ogre::CompositorChain::preRenderTargetUpdate(const Ogre::RenderTargetEvent & evt={...})  Line 302 + 0x1e bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::firePreUpdate()  Line 416 + 0x20 bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::_beginUpdate()  Line 161 + 0x12 bytes	C++
 	RenderSystem_Direct3D9_d.dll!Ogre::D3D9RenderWindow::_beginUpdate()  Line 849 + 0xb bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::updateImpl()  Line 153 + 0x12 bytes	C++
 	OgreMain_d.dll!Ogre::RenderTarget::update(bool swap=false)  Line 611 + 0x12 bytes	C++
 	OgreMain_d.dll!Ogre::RenderSystem::_updateAllRenderTargets(bool swapBuffers=false)  Line 122 + 0x22 bytes	C++
 	OgreMain_d.dll!Ogre::Root::_updateAllRenderTargets()  Line 1393 + 0x1c bytes	C++
 	OgreMain_d.dll!Ogre::Root::renderOneFrame()  Line 978 + 0x8 bytes	C++
The relevant functions are probably ShadowTextureManager::getShadowTextures() & D3D9Texture::_createNormTex()
I don't see anywhere in Ogre's code a check to see whether FSAA is supported, or an "ignore" flag.

Anywhere knows something about it?
It seems to me the Ogre Exception was added after setShadowTextureConfig docs were written. Most likely setShadowTextureConfig was realying that the failure from d3d9Device->CreateRenderTarget would be ignored, leaving textureResources->pFSAASurface as a null pointer.

The right way to do it is to first check FSAA is supported, if not, drop the setting.
Post Reply