Generating Mip-Maps for Cubemaps

Hello guys,
i have a small problem and just want to ask if there is an easy solution.
I generating mip-maps for my cubemaps using the pvrtex-tool (ktx + dds files), but when i load them in they are wrong.
It seems like the mip-map data is stored for each face sequentally but vulkan (or at least my engine) needs all faces from mip-level 0 in sequential order, then from mip-level 1 etc.

So before i write a ugly routine which places all those data in the right order i want to know if there is something i can do to avoid this.

Thanks in advance

This is how it looks:

DDS files store cubemaps with each face’s mipmap levels being contiguous. So it’s “for each face, for each mipmap level”. KTX files store cubemaps in a different order: “for each mipmap level, for each face”.

But really it doesn’t matter, because unless you’re loading up to a linear image, you can’t guarantee that your image data matches the exact layout of the hardware. So copying it will have to involve a number of DMA operations. That is, you can’t guarantee that you can do just one memcpy from the file data into a GPU VkImage’s memory.

Your problem seems to be that your code is expecting the file format to provide information in an order other than the order the file format says it provides it.

I didn’t understand your last sentence, but i realised GLI just stores the data the way i assumed independent from the file-format (mip-map data for each face sequentally).
Then i saw you can access the mip-map data separately with the same “data()-function” and i just fixed it by using a loop:

// Instead of  just copying the data with "memcpy(tex->rawData->ptr,, tex->rawData->size);"
// I do this now:

char* dataPtr = (char*)tex->rawData->ptr;
for (unsigned level = 0; level < texCube.levels(); level++)
    // MipSize in bytes
    uint32_t mipSize = texCube.size(level);

    // Save some information for VkBufferImageCopy's later
    tex->mipmaps.push_back({ static_cast<uint32_t>(texCube.extent(level).x),  static_cast<uint32_t>(texCube.extent(level).y), mipSize });

    for (unsigned face = 0; face < texCube.faces(); face++)
          memcpy(dataPtr,, face, level), mipSize);
          dataPtr += mipSize;

Then i take those raw-image data and transfer them to the GPU via Staging (VkBufferImageCopy’s).