From e0e2145210a151d8e27c6b56f901a66d517d58a3 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Sat, 18 Jun 2022 00:27:49 +0800 Subject: [PATCH] Fixed C-API provision --- c_api/include/taichi/taichi_core.h | 8 ++++---- c_api/include/taichi/taichi_vulkan.h | 2 +- c_api/src/taichi_vulkan_impl.cpp | 2 +- c_api/taichi.json | 2 +- misc/generate_c_api.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/c_api/include/taichi/taichi_core.h b/c_api/include/taichi/taichi_core.h index a98670eb479ae..8eb072a0efb0b 100644 --- a/c_api/include/taichi/taichi_core.h +++ b/c_api/include/taichi/taichi_core.h @@ -62,10 +62,10 @@ typedef enum TiArgumentType { // bit_field.memory_usage typedef enum TiMemoryUsageFlagBits { - TI_MEMORY_USAGE_STORAGE_BIT = 0, - TI_MEMORY_USAGE_UNIFORM_BIT = 1, - TI_MEMORY_USAGE_VERTEX_BIT = 2, - TI_MEMORY_USAGE_INDEX_BIT = 3, + TI_MEMORY_USAGE_STORAGE_BIT = 1 << 0, + TI_MEMORY_USAGE_UNIFORM_BIT = 1 << 1, + TI_MEMORY_USAGE_VERTEX_BIT = 1 << 2, + TI_MEMORY_USAGE_INDEX_BIT = 1 << 3, } TiMemoryUsageFlagBits; typedef TiFlags TiMemoryUsageFlags; diff --git a/c_api/include/taichi/taichi_vulkan.h b/c_api/include/taichi/taichi_vulkan.h index ead229b65f8ae..e019406e8f8f5 100644 --- a/c_api/include/taichi/taichi_vulkan.h +++ b/c_api/include/taichi/taichi_vulkan.h @@ -21,7 +21,7 @@ typedef struct TiVulkanRuntimeInteropInfo { // structure.vulkan_memory_interop_info typedef struct TiVulkanMemoryInteropInfo { VkBuffer buffer; - size_t size; + uint64_t size; VkBufferUsageFlags usage; } TiVulkanMemoryInteropInfo; diff --git a/c_api/src/taichi_vulkan_impl.cpp b/c_api/src/taichi_vulkan_impl.cpp index eb3ddb83d2174..fd71a9d81786a 100644 --- a/c_api/src/taichi_vulkan_impl.cpp +++ b/c_api/src/taichi_vulkan_impl.cpp @@ -160,7 +160,7 @@ void ti_export_vulkan_runtime(TiRuntime runtime, vk_device.graphics_queue_family_index(); } -TiMemory ti_import_vulkan_runtime_allocation( +TiMemory ti_import_vulkan_memory( TiRuntime runtime, const TiVulkanMemoryInteropInfo *interop_info) { Runtime *runtime2 = (Runtime *)runtime; diff --git a/c_api/taichi.json b/c_api/taichi.json index 540dd8c566e77..1ccc42383d416 100644 --- a/c_api/taichi.json +++ b/c_api/taichi.json @@ -450,7 +450,7 @@ }, { "name": "size", - "type": "size_t" + "type": "uint64_t" }, { "name": "usage", diff --git a/misc/generate_c_api.py b/misc/generate_c_api.py index 72e5c359536dd..263fedad8162a 100644 --- a/misc/generate_c_api.py +++ b/misc/generate_c_api.py @@ -162,7 +162,7 @@ def get_flag_name(self, flag_name: Name): def declr(self): out = ["typedef enum " + self.type_name + " {"] for name, value in self.bits.items(): - out += [f" {name} = {value},"] + out += [f" {name} = 1 << {value},"] out += ["} " + self.type_name + ";"] out += [f"typedef TiFlags {self.field_type_name};"] return '\n'.join(out)