| 343 | } |
| 344 | |
| 345 | static bool LoadMaterialFile(donut::engine::FilePathOrInlineData const& source, NtcMaterial& material, |
| 346 | ntc::IContext* ntcContext, ntc::FileStreamWrapper& ntcFile, ntc::MemoryStreamWrapper& ntcMemory, |
| 347 | ntc::TextureSetMetadataWrapper& textureSetMetadata) |
| 348 | { |
| 349 | if (material.name.empty()) |
| 350 | material.name = "Material"; |
| 351 | |
| 352 | ntc::Status ntcStatus; |
| 353 | ntc::IStream* stream = nullptr; |
| 354 | |
| 355 | if (source.data) |
| 356 | { |
| 357 | ntcStatus = ntcContext->OpenReadOnlyMemory(source.data->buffer->data(), source.data->buffer->size(), |
| 358 | ntcMemory.ptr()); |
| 359 | |
| 360 | if (ntcStatus != ntc::Status::Ok) |
| 361 | { |
| 362 | log::warning("Cannot open '%s', error code = %s: %s", source.ToString().c_str(), |
| 363 | ntc::StatusToString(ntcStatus), ntc::GetLastErrorMessage()); |
| 364 | return false; |
| 365 | } |
| 366 | |
| 367 | stream = ntcMemory.Get(); |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | ntcStatus = ntcContext->OpenFile(source.path.c_str(), false, ntcFile.ptr()); |
| 372 | if (ntcStatus == ntc::Status::FileUnavailable) |
| 373 | { |
| 374 | log::warning("Material file '%s' does not exist.", source.path.c_str()); |
| 375 | return false; |
| 376 | } |
| 377 | else if (ntcStatus != ntc::Status::Ok) |
| 378 | { |
| 379 | log::warning("Cannot open '%s', error code = %s: %s", source.path.c_str(), |
| 380 | ntc::StatusToString(ntcStatus), ntc::GetLastErrorMessage()); |
| 381 | return false; |
| 382 | } |
| 383 | |
| 384 | stream = ntcFile.Get(); |
| 385 | } |
| 386 | |
| 387 | ntcStatus = ntcContext->CreateTextureSetMetadataFromStream(stream, textureSetMetadata.ptr()); |
| 388 | if (ntcStatus != ntc::Status::Ok) |
| 389 | { |
| 390 | log::warning("Cannot load metadata for '%s', error code = %s: %s", source.ToString().c_str(), |
| 391 | ntc::StatusToString(ntcStatus), ntc::GetLastErrorMessage()); |
| 392 | return false; |
| 393 | } |
| 394 | |
| 395 | return true; |
| 396 | } |
| 397 | |
| 398 | bool NtcMaterialLoader::TranscodeTiles(const std::vector<TranscodeTileInfo>& tiles, nvrhi::ICommandList* commandList, |
| 399 | bool enableBlockCompression) |
no test coverage detected