| 297 | } |
| 298 | |
| 299 | bool Texture2D::updateWithMipmaps(MipmapInfo* mipmaps, |
| 300 | int mipmapsNum, |
| 301 | backend::PixelFormat pixelFormat, |
| 302 | backend::PixelFormat renderFormat, |
| 303 | int pixelsWide, |
| 304 | int pixelsHigh, |
| 305 | bool preMultipliedAlpha, |
| 306 | int index) |
| 307 | { |
| 308 | // the pixelFormat must be a certain value |
| 309 | AXASSERT(pixelFormat != PixelFormat::NONE, "the \"pixelFormat\" param must be a certain value!"); |
| 310 | AXASSERT(pixelsWide > 0 && pixelsHigh > 0, "Invalid size"); |
| 311 | |
| 312 | if (mipmapsNum <= 0) |
| 313 | { |
| 314 | AXLOGW("WARNING: mipmap number is less than 1"); |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | auto& pfd = backend::PixelFormatUtils::getFormatDescriptor(pixelFormat); |
| 319 | if (!pfd.bpp) |
| 320 | { |
| 321 | AXLOGW("WARNING: unsupported pixelformat: {:x}", (uint32_t)pixelFormat); |
| 322 | #ifdef AX_USE_METAL |
| 323 | AXASSERT(false, "pixeformat not found in _pixelFormatInfoTables, register required!"); |
| 324 | #endif |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | bool compressed = backend::PixelFormatUtils::isCompressed(pixelFormat); |
| 329 | |
| 330 | if (compressed && !Configuration::getInstance()->supportsPVRTC() && !Configuration::getInstance()->supportsETC1() && |
| 331 | !Configuration::getInstance()->supportsETC2() && !Configuration::getInstance()->supportsS3TC() && |
| 332 | !Configuration::getInstance()->supportsASTC() && !Configuration::getInstance()->supportsATITC()) |
| 333 | { |
| 334 | AXLOGW("WARNING: PVRTC/ETC images are not supported"); |
| 335 | return false; |
| 336 | } |
| 337 | |
| 338 | #if AX_ENABLE_CACHE_TEXTURE_DATA |
| 339 | VolatileTextureMgr::getOrAddVolatileTexture(this); |
| 340 | #endif |
| 341 | |
| 342 | backend::TextureDescriptor textureDescriptor; |
| 343 | textureDescriptor.width = pixelsWide; |
| 344 | textureDescriptor.height = pixelsHigh; |
| 345 | |
| 346 | textureDescriptor.samplerDescriptor.magFilter = |
| 347 | (_flags & TextureFlag::ANTIALIAS_ENABLED) ? backend::SamplerFilter::LINEAR : backend::SamplerFilter::NEAREST; |
| 348 | if (mipmapsNum == 1) |
| 349 | { |
| 350 | textureDescriptor.samplerDescriptor.minFilter = (_flags & TextureFlag::ANTIALIAS_ENABLED) |
| 351 | ? backend::SamplerFilter::LINEAR |
| 352 | : backend::SamplerFilter::NEAREST; |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | textureDescriptor.samplerDescriptor.minFilter = (_flags & TextureFlag::ANTIALIAS_ENABLED) |
nothing calls this directly
no test coverage detected