MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / copyContentsToMemory

Method copyContentsToMemory

OgreMain/src/OgreImage2.cpp:404–470  ·  view source on GitHub ↗

-----------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

402 }
403 //-----------------------------------------------------------------------------------
404 void Image2::copyContentsToMemory( TextureGpu *texture, TextureBox srcBox, TextureBox dstBox,
405 PixelFormatGpu dstFormat, bool automaticResolve )
406 {
407 if( texture->getResidencyStatus() != GpuResidency::Resident &&
408 texture->getNextResidencyStatus() != GpuResidency::Resident )
409 {
410 OGRE_EXCEPT(
411 Exception::ERR_INVALIDPARAMS,
412 "Texture '" + texture->getNameStr() + "' must be resident or becoming resident!!!",
413 "Image2::copyContentsToMemory" );
414 }
415
416 if( !texture->getEmptyBox( 0 ).fullyContains( srcBox ) || !dstBox.equalSize( srcBox ) )
417 {
418 OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Invalid box.", "Image2::copyContentsToMemory" );
419 }
420
421 texture->waitForData();
422
423 TextureGpuManager *textureManager = texture->getTextureManager();
424
425 TextureGpu *resolvedTexture = texture;
426
427 if( texture->isMultisample() && texture->hasMsaaExplicitResolves() && automaticResolve &&
428 !texture->isOpenGLRenderWindow() )
429 {
430 resolvedTexture = textureManager->createTexture(
431 texture->getNameStr() + "/Tmp/__ResolveTex", GpuPageOutStrategy::Discard,
432 TextureFlags::RenderToTexture, texture->getTextureType() );
433 resolvedTexture->copyParametersFrom( texture );
434 resolvedTexture->setPixelFormat( texture->getPixelFormat() );
435 resolvedTexture->setSampleDescription( 1u );
436 resolvedTexture->_transitionTo( GpuResidency::Resident, (uint8 *)0 );
437 texture->_resolveTo( resolvedTexture );
438 }
439
440 AsyncTextureTicket *asyncTicket = textureManager->createAsyncTextureTicket(
441 srcBox.width, srcBox.height, srcBox.getDepthOrSlices(), texture->getTextureType(),
442 texture->getPixelFormat() );
443 asyncTicket->download( resolvedTexture, 0, true, &srcBox );
444
445 if( asyncTicket->canMapMoreThanOneSlice() )
446 {
447 srcBox = asyncTicket->map( 0 );
448 PixelFormatGpuUtils::bulkPixelConversion( srcBox, texture->getPixelFormat(), dstBox,
449 dstFormat );
450 asyncTicket->unmap();
451 }
452 else
453 {
454 dstBox.numSlices = 1;
455 for( size_t i = 0; i < asyncTicket->getNumSlices(); ++i )
456 {
457 srcBox = asyncTicket->map( static_cast<uint32>( i ) );
458 PixelFormatGpuUtils::bulkPixelConversion( srcBox, texture->getPixelFormat(), dstBox,
459 dstFormat );
460 dstBox.data = dstBox.at( 0, 0, 1u );
461 asyncTicket->unmap();

Callers

nothing calls this directly

Calls 15

getResidencyStatusMethod · 0.80
getEmptyBoxMethod · 0.80
waitForDataMethod · 0.80
getTextureManagerMethod · 0.80
copyParametersFromMethod · 0.80
setPixelFormatMethod · 0.80
setSampleDescriptionMethod · 0.80
_transitionToMethod · 0.80
_resolveToMethod · 0.80

Tested by

no test coverage detected