Skip to content

Commit

Permalink
Add more diagnostics to Readback test
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed May 25, 2022
1 parent 1624634 commit 60f890a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
34 changes: 31 additions & 3 deletions Samples/2.0/Tests/Readback/ReadbackGameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "OgreCamera.h"
#include "OgreHlms.h"
#include "OgreItem.h"
#include "OgreLogManager.h"
#include "OgreLwString.h"
#include "OgreMesh.h"
#include "OgreMesh2.h"
Expand Down Expand Up @@ -161,6 +162,14 @@ namespace Demo

mUnlitDatablock->setColour( randColour );

uint32_t rgba = randColour.getAsABGR();
const uint8_t *rgba8 = reinterpret_cast<const uint8_t *>( &rgba );

Ogre::LogManager::getSingleton().logMessage(
"Testing colour: " + std::to_string( rgba8[0] ) + " " + std::to_string( rgba8[1] ) +
" " + std::to_string( rgba8[2] ) + " " + std::to_string( rgba8[3] ),
Ogre::LML_CRITICAL );

workspace->_validateFinalTarget();
workspace->_beginUpdate( false );
workspace->_update();
Expand All @@ -175,10 +184,21 @@ namespace Demo
mTextureBox = &box;

mGraphicsSystem->getSceneManager()->executeUserScalableTask( this, true );
//execute(0u,1u);
// execute(0u,1u);

if( mRaceConditionDetected )
{
Ogre::LogManager::getSingleton().logMessage(
"Race condition detected!. Expected value: " + std::to_string( rgba8[0] ) + " " +
std::to_string( rgba8[1] ) + " " + std::to_string( rgba8[2] ) + " " +
std::to_string( rgba8[3] ) +
" Got instead: " + std::to_string( mRgbaResult[0] ) + " " +
std::to_string( mRgbaResult[1] ) + " " + std::to_string( mRgbaResult[2] ) +
" " + std::to_string( mRgbaResult[3] ),
Ogre::LML_CRITICAL );

mRaceConditionDetected = false;

OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Race condition detected!",
"Test failed!" );
}
Expand Down Expand Up @@ -222,6 +242,13 @@ namespace Demo
if( dataPtr[0] != refValue[3] || dataPtr[1] != refValue[2] ||
dataPtr[2] != refValue[1] || dataPtr[3] != refValue[0] )
{
if( !mRaceConditionDetected )
{
mRgbaResult[0] = dataPtr[0];
mRgbaResult[1] = dataPtr[1];
mRgbaResult[2] = dataPtr[2];
mRgbaResult[3] = dataPtr[3];
}
mRaceConditionDetected = true;
}
}
Expand All @@ -231,7 +258,8 @@ namespace Demo
void ReadbackGameState::generateDebugText( float timeSinceLast, Ogre::String &outText )
{
TutorialGameState::generateDebugText( timeSinceLast, outText );
outText += "\nThis test draws a random colour to an offscreen RTT and downloads\n"
"its contents. If the colour doesn't match we throw an error.";
outText +=
"\nThis test draws a random colour to an offscreen RTT and downloads\n"
"its contents. If the colour doesn't match we throw an error.";
}
} // namespace Demo
1 change: 1 addition & 0 deletions Samples/2.0/Tests/Readback/ReadbackGameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Demo
Ogre::HlmsUnlitDatablock *mUnlitDatablock;

Ogre::uint32 mRgbaReference;
Ogre::uint8 mRgbaResult[4];
Ogre::TextureBox const *mTextureBox;
bool mRaceConditionDetected;

Expand Down

0 comments on commit 60f890a

Please sign in to comment.