Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vulkan] Fix GGUI #3330

Merged
merged 3 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion taichi/backends/vulkan/embedded_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions taichi/ui/backends/vulkan/app_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand Down
1 change: 1 addition & 0 deletions taichi/ui/backends/vulkan/app_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions taichi/ui/backends/vulkan/renderable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions taichi/ui/backends/vulkan/renderables/set_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down