diff --git a/taichi/backends/vulkan/embedded_device.cpp b/taichi/backends/vulkan/embedded_device.cpp index 7ad4bf296f463..7bcaa13e41460 100644 --- a/taichi/backends/vulkan/embedded_device.cpp +++ b/taichi/backends/vulkan/embedded_device.cpp @@ -426,7 +426,8 @@ void EmbeddedVulkanDevice::create_logical_device() { } else if (name == VK_KHR_SPIRV_1_4_EXTENSION_NAME) { ti_device_->set_cap(DeviceCapability::spirv_version, 0x10400); enabled_extensions.push_back(ext.extensionName); - } else if (name == VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) { + } else if (name == VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME || + name == VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) { ti_device_->set_cap(DeviceCapability::vk_has_external_memory, true); enabled_extensions.push_back(ext.extensionName); } else if (name == VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME) { diff --git a/taichi/ui/backends/vulkan/app_context.cpp b/taichi/ui/backends/vulkan/app_context.cpp index cadd844171745..2de0388060e32 100644 --- a/taichi/ui/backends/vulkan/app_context.cpp +++ b/taichi/ui/backends/vulkan/app_context.cpp @@ -97,6 +97,14 @@ void AppContext::cleanup() { } } +bool AppContext::requires_export_sharing() const { + // only the cuda backends needs export_sharing to interop with vk + // with other backends (e.g. vulkan backend on mac), turning export_sharing to + // true leads to crashes + // TODO: investigate this, and think of a more universal solution. + return config.ti_arch == Arch::cuda; +} + GLFWwindow *AppContext::glfw_window() const { return glfw_window_; } diff --git a/taichi/ui/backends/vulkan/app_context.h b/taichi/ui/backends/vulkan/app_context.h index 2736f91c8f19b..aa5f3eed59bc9 100644 --- a/taichi/ui/backends/vulkan/app_context.h +++ b/taichi/ui/backends/vulkan/app_context.h @@ -19,6 +19,7 @@ class AppContext { taichi::lang::vulkan::VulkanDevice &device(); const taichi::lang::vulkan::VulkanDevice &device() const; + bool requires_export_sharing() const; AppConfig config; diff --git a/taichi/ui/backends/vulkan/renderable.cpp b/taichi/ui/backends/vulkan/renderable.cpp index 68e8758b370ee..2876dd26c841c 100644 --- a/taichi/ui/backends/vulkan/renderable.cpp +++ b/taichi/ui/backends/vulkan/renderable.cpp @@ -144,7 +144,8 @@ void Renderable::create_graphics_pipeline() { void Renderable::create_vertex_buffer() { size_t buffer_size = sizeof(Vertex) * config_.max_vertices_count; - Device::AllocParams vb_params{buffer_size, false, false, true, + Device::AllocParams vb_params{buffer_size, false, false, + app_context_->requires_export_sharing(), AllocUsage::Vertex}; vertex_buffer_ = app_context_->device().allocate_memory(vb_params); @@ -157,7 +158,8 @@ void Renderable::create_vertex_buffer() { void Renderable::create_index_buffer() { size_t buffer_size = sizeof(int) * config_.max_indices_count; - Device::AllocParams ib_params{buffer_size, false, false, true, + Device::AllocParams ib_params{buffer_size, false, false, + app_context_->requires_export_sharing(), AllocUsage::Index}; index_buffer_ = app_context_->device().allocate_memory(ib_params); diff --git a/taichi/ui/backends/vulkan/renderables/set_image.cpp b/taichi/ui/backends/vulkan/renderables/set_image.cpp index e97fccfcd9df5..501a94a46275e 100644 --- a/taichi/ui/backends/vulkan/renderables/set_image.cpp +++ b/taichi/ui/backends/vulkan/renderables/set_image.cpp @@ -128,8 +128,9 @@ void SetImage::create_texture() { cpu_staging_buffer_ = app_context_->device().allocate_memory(cpu_staging_buffer_params); - Device::AllocParams gpu_staging_buffer_params{image_size, false, false, true, - AllocUsage::Uniform}; + Device::AllocParams gpu_staging_buffer_params{ + image_size, false, false, app_context_->requires_export_sharing(), + AllocUsage::Uniform}; gpu_staging_buffer_ = app_context_->device().allocate_memory(gpu_staging_buffer_params); }