From 60f890aa3fc055832caba35235a811a424f6eaed Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Wed, 25 May 2022 14:25:10 -0300 Subject: [PATCH] Add more diagnostics to Readback test --- .../2.0/Tests/Readback/ReadbackGameState.cpp | 34 +++++++++++++++++-- .../2.0/Tests/Readback/ReadbackGameState.h | 1 + 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Samples/2.0/Tests/Readback/ReadbackGameState.cpp b/Samples/2.0/Tests/Readback/ReadbackGameState.cpp index 5af7a9cd98a..be9f7ea233d 100644 --- a/Samples/2.0/Tests/Readback/ReadbackGameState.cpp +++ b/Samples/2.0/Tests/Readback/ReadbackGameState.cpp @@ -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" @@ -161,6 +162,14 @@ namespace Demo mUnlitDatablock->setColour( randColour ); + uint32_t rgba = randColour.getAsABGR(); + const uint8_t *rgba8 = reinterpret_cast( &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(); @@ -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!" ); } @@ -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; } } @@ -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 diff --git a/Samples/2.0/Tests/Readback/ReadbackGameState.h b/Samples/2.0/Tests/Readback/ReadbackGameState.h index d3c668fb33b..1703d5baebd 100644 --- a/Samples/2.0/Tests/Readback/ReadbackGameState.h +++ b/Samples/2.0/Tests/Readback/ReadbackGameState.h @@ -19,6 +19,7 @@ namespace Demo Ogre::HlmsUnlitDatablock *mUnlitDatablock; Ogre::uint32 mRgbaReference; + Ogre::uint8 mRgbaResult[4]; Ogre::TextureBox const *mTextureBox; bool mRaceConditionDetected;