Since Ogre 2.2 is getting more and more mature and feature-rich, we're considering using Ogre 2.2 in production (currently only a few devs of our project is using Ogre 2.2 during development). Most things are already working, but fake area lights and screen space decals have not been integrated. I did write integration codes, but they're not working.
Our lights/decals are highly dynamic, so we're re-using textures (light mask and decal texture) I don't want to create a new one everytime, so we want to reuse texture names and upload new data everytime. However, if I use scheduleTransitionTo() which can upload the image data and delete it automatically (I copied these code from Ogre sample), I have to make the texture OnStorage again, otherwise it'll think the texture is already Resident so no need to do transition.
Even for the first time, it still failed (in our case) because there is not enough StagingTextures. When loading the scene, it allocates new StagingTextures when needed, but when I'm uploading light mask/decal texture after the whole scene is loaded, it doesn't allocate new StagingTexture, then try to find a compatible StagingTexture then silently failed. The same code works in the official FakeAreaLight sample because there aren't many resources in the sample, so there are still StagingTextures available.
When writing this post, I realized that I can manually get a StagingTexture and upload the image (it should work, because I've already done it in my MyGUI wrapper), but a more convenient way is preferred.
Also, it'll be nice to have a dedicated streaming sample to help testing various streaming scenarios, combining loading external resources AND uploading/re-uploading to textures programatically.
Edit: codes to manually get StagingTexture and upload data:
Code: Select all
uint8 *imageData = reinterpret_cast<uint8*>(mTmpData.data);
const size_t bytesPerRow = mTexture->_getSysRamCopyBytesPerRow(0);
mTexture->_transitionTo(Ogre::GpuResidency::Resident, imageData);
mTexture->_setNextResidencyStatus(Ogre::GpuResidency::Resident);
Ogre::StagingTexture *stagingTexture = textureManager->getStagingTexture(mTexture->getWidth(), mTexture->getHeight(),
1u, 1u,
mTexture->getPixelFormat());
stagingTexture->startMapRegion();
Ogre::TextureBox texBox = stagingTexture->mapRegion(mTexture->getWidth(), mTexture->getHeight(), 1u, 1u,
mTexture->getPixelFormat());
texBox.copyFrom(imageData, mTexture->getWidth(), mTexture->getHeight(), bytesPerRow);
stagingTexture->stopMapRegion();
stagingTexture->upload(texBox, mTexture, 0, 0, true);
textureManager->removeStagingTexture(stagingTexture);
stagingTexture = 0;
OGRE_FREE_SIMD(imageData, Ogre::MEMCATEGORY_RESOURCE);
mTmpData.data = nullptr;
mTexture->notifyDataIsReady();