diff --git a/taichi/backends/vulkan/codegen_vulkan.cpp b/taichi/backends/vulkan/codegen_vulkan.cpp index d0306d1a427e9c..fd6f3562da1d98 100644 --- a/taichi/backends/vulkan/codegen_vulkan.cpp +++ b/taichi/backends/vulkan/codegen_vulkan.cpp @@ -1408,8 +1408,8 @@ class KernelCodegen { std::ofstream fout((params_.ti_kernel_name).c_str(), std::ios::binary | std::ios::out); - fout.write(reinterpret_cast(task_res.spirv_code.data()), - task_res.spirv_code.size() * sizeof(uint32_t)); + fout.write(reinterpret_cast(optimized_spv.data()), + optimized_spv.size() * sizeof(uint32_t)); fout.close(); #endif diff --git a/taichi/backends/vulkan/vulkan_device.cpp b/taichi/backends/vulkan/vulkan_device.cpp index 25105a752fbe0d..53a049cd5ca457 100644 --- a/taichi/backends/vulkan/vulkan_device.cpp +++ b/taichi/backends/vulkan/vulkan_device.cpp @@ -1144,8 +1144,11 @@ DeviceAllocation VulkanDevice::allocate_memory(const AllocParams ¶ms) { VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; #endif + bool export_sharing = params.export_sharing && + this->get_cap(DeviceCapability::vk_has_external_memory); + VmaAllocationCreateInfo alloc_info{}; - if (params.export_sharing) { + if (export_sharing) { buffer_info.pNext = &external_mem_buffer_create_info; } #ifdef __APPLE__ @@ -1173,8 +1176,8 @@ DeviceAllocation VulkanDevice::allocate_memory(const AllocParams ¶ms) { } alloc.buffer = vkapi::create_buffer( - device_, params.export_sharing ? allocator_export_ : allocator_, - &buffer_info, &alloc_info); + device_, export_sharing ? allocator_export_ : allocator_, &buffer_info, + &alloc_info); vmaGetAllocationInfo(alloc.buffer->allocator, alloc.buffer->allocation, &alloc.alloc_info); @@ -1482,8 +1485,11 @@ DeviceAllocation VulkanDevice::create_image(const ImageParams ¶ms) { alloc.format = image_info.format; + bool export_sharing = params.export_sharing && + this->get_cap(DeviceCapability::vk_has_external_memory); + VkExternalMemoryImageCreateInfo external_mem_image_create_info = {}; - if (params.export_sharing) { + if (export_sharing) { external_mem_image_create_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; external_mem_image_create_info.pNext = NULL; @@ -1504,8 +1510,8 @@ DeviceAllocation VulkanDevice::create_image(const ImageParams ¶ms) { alloc_info.usage = VMA_MEMORY_USAGE_GPU_ONLY; alloc.image = vkapi::create_image( - device_, params.export_sharing ? allocator_export_ : allocator_, - &image_info, &alloc_info); + device_, export_sharing ? allocator_export_ : allocator_, &image_info, + &alloc_info); vmaGetAllocationInfo(alloc.image->allocator, alloc.image->allocation, &alloc.alloc_info); diff --git a/taichi/program/opaque_handles.h b/taichi/program/opaque_handles.h new file mode 100644 index 00000000000000..6fd6185f5445cc --- /dev/null +++ b/taichi/program/opaque_handles.h @@ -0,0 +1,14 @@ +#pragma once +#include "taichi/lang_util.h" +#include "taichi/backends/device.h" + +namespace taichi { +namespace lang { + +class OpaqueObjects { + public: + +}; + +} +} // namespace taichi \ No newline at end of file