MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / parse_image

Method parse_image

framework/gltf_loader.cpp:1456–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1454}
1455
1456std::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
1499std::unique_ptr<vkb::scene_graph::components::SamplerC> GLTFLoader::parse_sampler(const tinygltf::Sampler &gltf_sampler) const
1500{

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.80
is_astcFunction · 0.50
get_formatMethod · 0.45
generate_mipmapsMethod · 0.45
create_vk_imageMethod · 0.45

Tested by

no test coverage detected