SHARE
TWEET

Untitled

a guest Mar 14th, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     external_image_info = ffi.automem(vulkan.vk.ExternalMemoryImageCreateInfoKHX)
  2.     external_image_info[0] = {
  3.         handleTypes = "OPAQUE_FD_BIT_KHX"
  4.     }
  5.     external_image = vulkan.Image(gpu, {
  6.         pNext = external_image_info
  7.         imageType = "2D"
  8.         format = "R8G8B8A8_UNORM"
  9.         extent = {width = 512, height = 512, depth = 1}
  10.         mipLevels = 1
  11.         arrayLayers = 1
  12.         samples = "1_BIT"
  13.         tiling = "OPTIMAL"
  14.         usage = ["SAMPLED_BIT", "COLOR_ATTACHMENT_BIT"]
  15.         initialLayout = "COLOR_ATTACHMENT_OPTIMAL"
  16.     })
  17.  
  18.     req = external_image.getMemoryRequirements()
  19.     memoryIndex = null
  20.     for memtype in warpgpu.memory_report(gpu.physicalDevice).types
  21.         if 1 & (req.memoryTypeBits >> memtype.index) != 0
  22.             memoryIndex = memtype.index
  23.     assert memoryIndex, "No memory available for this resource"
  24.  
  25.     mem_info = ffi.automem(vulkan.vk.MemoryAllocateInfo)
  26.     export_info = ffi.automem(vulkan.vk.ExportMemoryAllocateInfoKHX)
  27.     export_info[0] = {
  28.         handleTypes = "OPAQUE_FD_BIT_KHX"
  29.     }
  30.     mem_info[0] = {
  31.         #pNext = export_info # if I comment this away, no crash.
  32.         allocationSize = 1024 * 32
  33.         memoryTypeIndex = memoryIndex
  34.     }
  35.     mem = gpu.allocateMemory(mem_info) #CRASH
  36.  
  37.     external_image.bindMemory(mem, 0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top