| 1454 | } |
| 1455 | |
| 1456 | std::unique_ptr<sg::Image> GLTFLoader::parse_image(tinygltf::Image &gltf_image) const |
| 1457 | { |
| 1458 | std::unique_ptr<sg::Image> image{nullptr}; |
| 1459 | |
| 1460 | if (gltf_image.name.empty()) |
| 1461 | { |
| 1462 | gltf_image.name = gltf_image.uri; |
| 1463 | } |
| 1464 | |
| 1465 | if (!gltf_image.image.empty()) |
| 1466 | { |
| 1467 | // Image embedded in gltf file |
| 1468 | auto mipmap = sg::Mipmap{ |
| 1469 | /* .level = */ 0, |
| 1470 | /* .offset = */ 0, |
| 1471 | /* .extent = */ {/* .width = */ static_cast<uint32_t>(gltf_image.width), |
| 1472 | /* .height = */ static_cast<uint32_t>(gltf_image.height), |
| 1473 | /* .depth = */ 1u}}; |
| 1474 | std::vector<sg::Mipmap> mipmaps{mipmap}; |
| 1475 | image = std::make_unique<sg::Image>(gltf_image.name, std::move(gltf_image.image), std::move(mipmaps)); |
| 1476 | } |
| 1477 | else |
| 1478 | { |
| 1479 | // Load image from uri |
| 1480 | auto image_uri = model_path + "/" + gltf_image.uri; |
| 1481 | image = sg::Image::load(gltf_image.name, image_uri, vkb::sg::Image::Unknown); |
| 1482 | } |
| 1483 | |
| 1484 | // Check whether the format is supported by the GPU |
| 1485 | if (sg::is_astc(image->get_format())) |
| 1486 | { |
| 1487 | if (!device.is_image_format_supported(image->get_format())) |
| 1488 | { |
| 1489 | image = std::make_unique<sg::Astc>(*image); |
| 1490 | image->generate_mipmaps(); |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | image->create_vk_image(device); |
| 1495 | |
| 1496 | return image; |
| 1497 | } |
| 1498 | |
| 1499 | std::unique_ptr<vkb::scene_graph::components::SamplerC> GLTFLoader::parse_sampler(const tinygltf::Sampler &gltf_sampler) const |
| 1500 | { |
nothing calls this directly
no test coverage detected