MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / CNativeTexture

Method CNativeTexture

Source/SysPSP/Graphics/NativeTexturePSP.cpp:269–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267//
268//*****************************************************************************
269CNativeTexture::CNativeTexture( u32 w, u32 h, ETextureFormat texture_format )
270: mTextureFormat( texture_format )
271, mWidth( w )
272, mHeight( h )
273, mCorrectedWidth( CorrectDimension( w ) )
274, mCorrectedHeight( CorrectDimension( h ) )
275, mTextureBlockWidth( GetTextureBlockWidth( mCorrectedWidth, texture_format ) )
276, mpPalette( nullptr )
277, mIsPaletteVidMem( false )
278, mIsSwizzled( true )
279#ifdef DAEDALUS_ENABLE_ASSERTS
280, mPaletteSet( false )
281#endif
282{
283 mScale.x = 1.0f / mCorrectedWidth;
284 mScale.y = 1.0f / mCorrectedHeight;
285
286 u32 bytes_required( GetBytesRequired() );
287
288 if( !CVideoMemoryManager::Get()->Alloc( bytes_required, &mpData, &mIsDataVidMem ) )
289 {
290 #ifdef DAEDALUS_DEBUG_CONSOLE
291 DAEDALUS_ERROR( "Out of memory for texels ( %d bytes)", bytes_required );
292 #endif
293 }
294 switch( texture_format )
295 {
296 case TexFmt_CI4_8888:
297 if( !CVideoMemoryManager::Get()->Alloc( kPalette4BytesRequired, &mpPalette, &mIsPaletteVidMem ) )
298 {
299 #ifdef DAEDALUS_DEBUG_CONSOLE
300 DAEDALUS_ERROR( "Out of memory for 4-bit palette, %d bytes", kPalette4BytesRequired );
301 #endif
302 }
303 break;
304
305 case TexFmt_CI8_8888:
306 if( !CVideoMemoryManager::Get()->Alloc( kPalette8BytesRequired, &mpPalette, &mIsPaletteVidMem ) )
307 {
308 #ifdef DAEDALUS_DEBUG_CONSOLE
309 DAEDALUS_ERROR( "Out of memory for 8-bit palette, %d bytes", kPalette8BytesRequired );
310 #endif
311 }
312 break;
313#ifdef DAEDALUS_ENABLE_ASSERTS
314 default:
315 DAEDALUS_ASSERT( !IsTextureFormatPalettised( texture_format ), "Unhandled palette texture" );
316 break;
317 #endif
318 }
319}
320
321//*****************************************************************************
322//

Callers

nothing calls this directly

Calls 4

CorrectDimensionFunction · 0.70
GetTextureBlockWidthFunction · 0.70
AllocMethod · 0.45

Tested by

no test coverage detected