[2.2] Integration issues and complex texture streaming/transition sample wanted

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
rujialiu
Greenskin
Posts: 140
Joined: Mon May 09, 2016 8:21 am
x 11

[2.2] Integration issues and complex texture streaming/transition sample wanted

Post by rujialiu » Thu Nov 08, 2018 6:49 am

Hi!

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();
0 x

rujialiu
Greenskin
Posts: 140
Joined: Mon May 09, 2016 8:21 am
x 11

Re: [2.2] Integration issues and complex texture streaming/transition sample wanted

Post by rujialiu » Thu Nov 08, 2018 11:04 am

hmmm... uploading a whole Image2 manually with StagingTexture is not trivial because we have mipmaps, and I can't get the raw data buffer directly for uploading :(

It'll be nice to have a "switch lighting mask texture" functionality to Ogre 2.2 sample. By "switching" you can just do simple things like altering the thickness of the hollow area etc, just to illustrate how to modify the texture of fake area lights from an Image2 object on-the-fly.
0 x

User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 140
Joined: Wed Apr 23, 2014 3:49 pm
x 4

Re: [2.2] Integration issues and complex texture streaming/transition sample wanted

Post by TaaTT4 » Tue Nov 20, 2018 4:44 pm

rujialiu wrote:
Thu Nov 08, 2018 6:49 am
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).
I'm having the same thought in these days. Did you already made the switching? In case, can you please briefly describe how did it gone and how long did it take the whole process?
0 x
Senior game programmer at Vae Victis
Working on Racecraft

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

Re: [2.2] Integration issues and complex texture streaming/transition sample wanted

Post by dark_sylinc » Wed Nov 21, 2018 12:33 am

Several of these issues will be addressed soon by adding a streaming sample, but something caught my eye.
rujialiu wrote:
Thu Nov 08, 2018 6:49 am
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.
What's "silently failed" here?
Show me some quick pseudo code of what you're doing (is the code you posted?) and when it silently fails (what fails? what's the result?).
0 x

rujialiu
Greenskin
Posts: 140
Joined: Mon May 09, 2016 8:21 am
x 11

Re: [2.2] Integration issues and complex texture streaming/transition sample wanted

Post by rujialiu » Wed Nov 21, 2018 6:44 am

dark_sylinc wrote:
Wed Nov 21, 2018 12:33 am
What's "silently failed" here?
Show me some quick pseudo code of what you're doing (is the code you posted?) and when it silently fails (what fails? what's the result?).
Oops, sorry I didn't update this thread after further investigation. I THOUGHT the texture requested failed to find a matching StagingTexture and was silently ignored but later I realized it might be fulfilled in the NEXT iteration. However, I did not try to debug it since then. I Will hopefully look into this within a few days.
0 x

rujialiu
Greenskin
Posts: 140
Joined: Mon May 09, 2016 8:21 am
x 11

Re: [2.2] Integration issues and complex texture streaming/transition sample wanted

Post by rujialiu » Wed Nov 21, 2018 6:53 am

TaaTT4 wrote:
Tue Nov 20, 2018 4:44 pm
I'm having the same thought in these days. Did you already made the switching? In case, can you please briefly describe how did it gone and how long did it take the whole process?
We had an intermediate layer that supports Ogre 2.0, 2.1 and 2.2. Very few users have issues running Ogre 2.1 so we still provide Ogre 2.0 based software (VERY different lighting/materials of course), and while most of our users are using Ogre 2.2 based software, the intermediate layer for Ogre 2.2 already supports most features but still needs testing. We will probably be able to release an Ogre 2.2 based version by the end of this year.

I don't think I spent much time integrating Ogre 2.2 but because I was too eager to try new things, I did spent some time when 2.2 was still in early ages 8-)

Anyway, code changes are a loooooooot less than Ogre 2.0 -> Ogre 2.1 unless you have too many low-level texture handling. I have some notes on what I did during Ogre 2.1->2.2 transition but it may need serious editing before posting here. If you're interested you can PM me.
0 x

Post Reply