| 362 | } |
| 363 | |
| 364 | bool CookAssetsStep::Process(CookingData& data, CacheData& cache, Asset* asset) |
| 365 | { |
| 366 | PROFILE_CPU_ASSET(asset); |
| 367 | if (asset->IsVirtual()) |
| 368 | { |
| 369 | // Virtual assets are not included into the build |
| 370 | return false; |
| 371 | } |
| 372 | const bool wasLoaded = asset->IsLoaded(); |
| 373 | if (asset->WaitForLoaded()) |
| 374 | { |
| 375 | LOG(Error, "Failed to load asset \'{0}\'", asset->ToString()); |
| 376 | return true; |
| 377 | } |
| 378 | if (!wasLoaded) |
| 379 | { |
| 380 | // HACK: give some time to resave any old assets in Asset::onLoad after it's loaded |
| 381 | // This assumes that if Load Thread enters Asset::Save then it will get asset lock and hold it until asset is saved |
| 382 | // So we can take the same lock to wait for save end but first we need to wait for it to get that lock |
| 383 | // (in future try to handle it in a better way) |
| 384 | Platform::Sleep(5); |
| 385 | } |
| 386 | ScopeLock lock(asset->Locker); |
| 387 | |
| 388 | // Switch based on an asset type |
| 389 | const auto asBinaryAsset = dynamic_cast<BinaryAsset*>(asset); |
| 390 | if (asBinaryAsset) |
| 391 | return Process(data, cache, asBinaryAsset); |
| 392 | const auto asJsonAsset = dynamic_cast<JsonAssetBase*>(asset); |
| 393 | if (asJsonAsset) |
| 394 | return Process(data, cache, asJsonAsset); |
| 395 | |
| 396 | LOG(Error, "Unknown asset type \'{0}\'", asset->GetTypeName()); |
| 397 | return false; |
| 398 | } |
| 399 | |
| 400 | bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* assetBase) |
| 401 | { |
no test coverage detected