| 227 | } |
| 228 | |
| 229 | bool CachedTexture::Initialise() |
| 230 | { |
| 231 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 232 | DAEDALUS_ASSERT_Q(mpTexture == nullptr); |
| 233 | #endif |
| 234 | u32 width {mTextureInfo.GetWidth()}; |
| 235 | u32 height {mTextureInfo.GetHeight()}; |
| 236 | |
| 237 | if (mTextureInfo.GetEmulateMirrorS()) width *= 2; |
| 238 | if (mTextureInfo.GetEmulateMirrorT()) height *= 2; |
| 239 | |
| 240 | mpTexture = CNativeTexture::Create( width, height, SelectNativeFormat(mTextureInfo) ); |
| 241 | if( mpTexture != nullptr ) |
| 242 | { |
| 243 | // If this we're performing Texture updated checks, randomly offset the |
| 244 | // 'FrameLastUpToDate' time. This ensures when lots of textures are |
| 245 | // created on the same frame we update them over a nice distribution of frames. |
| 246 | |
| 247 | if(gCheckTextureHashFrequency > 0) |
| 248 | { |
| 249 | mFrameLastUpToDate = gRDPFrame + (FastRand() & (gCheckTextureHashFrequency - 1)); |
| 250 | } |
| 251 | UpdateTextureHash(); |
| 252 | UpdateTexture( mTextureInfo, mpTexture ); |
| 253 | } |
| 254 | |
| 255 | return mpTexture != nullptr; |
| 256 | } |
| 257 | |
| 258 | // Update the hash of the texture. Returns true if the texture should be updated. |
| 259 | bool CachedTexture::UpdateTextureHash() |
no test coverage detected