Uploading large texture data


This topic contains 4 replies, has 2 voices, and was last updated by  kruseborn 2 days, 5 hours ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1217

    kruseborn
    Participant

    I am trying to upload 3D texture data larger than 1 gig. It looks like the maximum buffer length on OSX is 1024 MB and 256 MB on Ipad. How would this be done in MoltenVk? Upload the data in smaller chunks with vkMapMemory? If this works, can I still have a descriptorSet to one contiguous memory?

    Something like this:

    VkDeviceSize first = maxSize; // 1024 MB
    VkDeviceSize second = size - maxSize;
    checkResult(vkMapMemory(vkContext.device, memory, 0, first, 0, &pData));
    memcpy(pData, data, first);
    vkUnmapMemory(vkContext.device, memory);
            
    checkResult(vkMapMemory(vkContext.device, memory, first, second, 0, &pData));
    memcpy(pData, data, second);
    vkUnmapMemory(vkContext.device, memory);

    However, when I am trying to do this I am still getting an error:

    -[MTLDebugDevice validateNewBufferArgs:options:]:306: failed assertion newBufferWith*:length 0x4cd90400 must not exceed 1024 MB.

    #1218

    Bill Hollings
    Keymaster

    @kruseborn

    Under Vulkan, device memory is allocated and populated separately from the creation of a buffer or image on that memory.

    In order to support this behaviour in the general sense, currently, all device memory allocations under MoltenVK are backed by a MTLBuffer. Consequently, device memory allocations are limited by the size of a MTLBuffer on the runtime platform.

    …Bill

    #1219

    kruseborn
    Participant

    It looks like you can allocate larger textures than buffer memory in Metal. I have been able to create a 512MB 3D texture on an iPad in Metal.
    Is this something that can been done in MoltenVK? And if its not, is there something I can write to create a texture with
    let texture = device.makeTexture(descriptor: textureDescriptor) And still somehow get a Vulkan-descriptorset from MoltenVK to point to that texture memory?

    #1220

    Bill Hollings
    Keymaster

    @kruseborn

    Good feedback. I appreciate you letting us know your results with that texture size.

    Unfortunately…it’s not currently possible to do either of what you are asking.

    The VkDeviceMemory objects that back Vulkan image objects, are in turn backed by MTLBuffers. Based on your feedback, we can look at re-factoring how memory management works with textures within MoltenVK, but that will require some development effort, and wouldn’t be available for several weeks.

    And unfortunately, the other option…of applying an existing MTLTexture to a VkImage…does not exist within the MoltenVK API.

    What is your timing on needing this kind of capability?

    …Bill

    #1229

    kruseborn
    Participant

    We are going to release the product in the end of the year, so like 2,3 month would not be a problem for us. But the in the final product we are dependent on really large textures and would really appreciate if you would look in to it. The max buffer size on iPad was only 256 MB, its strange that Apple has different limitations for textures and buffers.

    best regards
    kruseborn

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.