I've got a simple function to get the rendertarget data of an RT( w/default pool ). This particular RT has a resolution of 1x1( it's the 10'th and final mip of a texture ). Here is my code to get data for IDirect3DSurface9 *pTargetSurface:
IDirect3DSurface9 *pSOS = NULL;
pd3dDevice->CreateOffScreenPlainSurface( 1, 1, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSOS, NULL );
// get residual energy
if( FAILED( hr = pd3dDevice->GetRenderTargetData( pTargetSurface, pSOS ) ) )
{
DebugStringDX( ClassName, "Failed to IDirect3DDevice9::GetRenderTargetData() at DownsampleArea()", __LINE__, hr );
goto Exit;
}
// lock surface
if( FAILED( hr = pSOS->LockRect( &rct, NULL, D3DLOCK_READONLY ) ) )
{
DebugStringDX( ClassName, "Failed to IDirect3DSurface9::LockRect() at DownsampleArea()", __LINE__, hr );
goto Exit;
}
// get residual energy from downsampled texture
pByte = ( BYTE* )rct.pBits;
D3DXVECTOR4 vEnergy;
vEnergy.z = ( float )pByte[ 0 ] / 255.0f;
vEnergy.y = ( float )pByte[ 1 ] / 255.0f;
vEnergy.x = ( float )pByte[ 2 ] / 255.0f;
vEnergy.w = ( float )pByte[ 3 ] / 255.0f;
V( pSOS->UnlockRect() );
All formatting and settings are correct, directx in debug mode shows no errors...
The problem is that the 4 bytes above are 0...I know this to be incorrect by using PIX to debug...PIX shows that RGB bytes are 0.078 and Alpah is 1. These values are not less than that which can be represented by a single byte( 1 / 255 ).
Any ideas? Am I copying rendertarget data correctly?