[2.2] Async Texture Ticket MipMaps (DX11) [SOLVED]

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 50
Contact:

[2.2] Async Texture Ticket MipMaps (DX11) [SOLVED]

Post by SolarPortal »

Hi, just wondering if you can shed some light on the async texture tickets when it comes to mapping the mip levels as the texture box i always get back is the full size texture on the width and height of the Ogre::TextureBox

Stepped through with the debugger and the downloadFromGpu seems to return the correct width and height of the mip level, however when you call map, the mWidth and mHeight from the mapImpl( uint32 slice ) function says the full texture resolution.

So more in depth:
OgreD3D11AsyncTextureTicket.cpp
line 128: DownloadFromGpu.
The "srcTextureBox" variable for the staging texture shows for example 128x128 as the mip resolution for a 1024x1024 base resolution texture, however the:

OgreD3D11AsyncTextureTicket.cpp
Line 264: TextureBox D3D11AsyncTextureTicket::mapImpl( uint32 slice )

Code: Select all

TextureBox retVal( mWidth, mHeight, getDepth(), getNumSlices(),
mWidth and mHeight are 1024 x 1024 when they should read 128x128 from what i would expect, as it does not seem to take into account the mip level when returning the texture box.

Any reason why it shows 1024x1024 and do i have to do the rez changes to the texture box returned, or is this an error.


Example Pseudo Code:

Code: Select all

	// myTexture width / height = 1024
	// myTexture depth = 1
	// myTexture type = cubemap - slices = 6
	// myTexture format = PFG_RGBA16_FLOAT
	// mMip level = 3
	asyncTicket = textureGpuManager->createAsyncTextureTicket(myTexture->getWidth(), myTexture->getHeight(), myTexture->getDepth(), TypeCube, PFG_RGBA16_FLOAT);
	asyncTicket->download(myTexture, mMip, true); // Downloads 128x128 to staging texture
	
	TextureBox box;
	if (asyncTicket->canMapMoreThanOneSlice()) {
		box = asyncTicket->map(0));
	}else {
		for (SkyUInt32 i = 0; i < asyncTicket->getNumSlices(); i++) {
			... asyncTicket->map(i));
		}
	}
	
	//box.width will be 1024 whereas i need it to be 128 to match the downloaded mip level res
	//box.height will be 1024 whereas i need it to be 128 to match the downloaded mip level res
Hope this makes sense, i think i could be misunderstanding something but wanted to check first.
If you need more information, then please let me know :)

Edit: Of course this would also affect the bytesPerRow and bytesPerImage which is why im not sure if this is a bug or not and cant find an example in ogre source where the mipmaps are being downloaded and used with the texturebox, only the "void PccPerPixelGridPlacement::preCopyRenderTargetToCubemap( TextureGpu *renderTarget, uint32 cubemapArrayIdx )" seems to download mips and getEmptyBox is used in the _copyRenderTargetToCubemap() function....

Still thinking its a misunderstanding...

Edit 2: Duh!! just make the texture ticket with the height and width of what i want.

Code: Select all

asyncTicket = textureGpuManager->createAsyncTextureTicket(myTexture->getWidth() >> mMip, myTexture->getHeight() >> mMip, myTexture->getDepth(), TypeCube, PFG_RGBA16_FLOAT);
Nevermind! :P
Last edited by SolarPortal on Wed Jul 15, 2020 6:57 pm, edited 1 time in total.
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk

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

Re: [2.2] Async Texture Ticket MipMaps (DX11)

Post by dark_sylinc »

SolarPortal wrote:
Wed Jul 15, 2020 4:43 pm
Edit 2: Duh!! just make the texture ticket with the height and width of what i want.

Code: Select all

asyncTicket = textureGpuManager->createAsyncTextureTicket(myTexture->getWidth() >> mMip, myTexture->getHeight() >> mMip, myTexture->getDepth(), TypeCube, PFG_RGBA16_FLOAT);
Nevermind! :P
The proper call is (see Image2::convertFromTexture):

Code: Select all

const uint32 width  = std::max( 1u, texture->getWidth() >> mip );
const uint32 height = std::max( 1u, texture->getHeight() >> mip );
const uint32 depth  = std::max( 1u, texture->getDepth() >> mip );
const uint32 depthOrSlices = std::max( depth, texture->getNumSlices() );

AsyncTextureTicket *asyncTicket =
        textureManager->createAsyncTextureTicket( width, height, depthOrSlices,
                                                  texture->getTextureType(),
                                                  texture->getPixelFormat() );
Otherwise with your version you're skipping the mips on depth, you're skipping slices entirely, and width or height may end up being 0 if the texture isn't squared.

User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 50
Contact:

Re: [2.2] Async Texture Ticket MipMaps (DX11)

Post by SolarPortal »

Thanks for the info :) Completely missed that bit when i looked at convertFromTexture lol :P
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk

Post Reply