Skip to content

Commit

Permalink
Clean up C-API headers
Browse files Browse the repository at this point in the history
  • Loading branch information
PENGUINLIONG committed Oct 11, 2022
1 parent 3b43816 commit b5f42b7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 12 deletions.
15 changes: 11 additions & 4 deletions c_api/include/taichi/taichi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
#include "taichi/taichi_core.h"

#if TI_WITH_VULKAN
#define VK_NO_PROTOTYPES 1
#include "taichi/taichi_vulkan.h"
#if !TI_NO_VULKAN_INCLUDES
#include <vulkan/vulkan.h>
#endif // !TI_NO_EXTERNAL_INCLUDES

#include "taichi/taichi_vulkan.h"
#endif // TI_WITH_VULKAN

#if TI_WITH_OPENGL
#include "taichi/taichi_opengl.h"
#endif
#if !TI_NO_OPENGL_INCLUDES
#include <GL/gl.h>
#endif // !TI_NO_OPENGL_INCLUDES

#include "taichi/taichi_opengl.h"
#endif // TI_WITH_OPENGL
1 change: 1 addition & 0 deletions c_api/include/taichi/taichi_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ typedef struct TiImageAllocateInfo {
TiImageExtent extent;
uint32_t mip_level_count;
TiFormat format;
TiBool export_sharing;
TiImageUsageFlags usage;
} TiImageAllocateInfo;

Expand Down
7 changes: 6 additions & 1 deletion c_api/include/taichi/taichi_opengl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <taichi/taichi_core.h>
#include <glad/gl.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -12,6 +11,12 @@ typedef struct TiOpenglMemoryInteropInfo {
uint64_t size;
} TiOpenglMemoryInteropInfo;

// function.import_opengl_memory
TI_DLL_EXPORT void TI_API_CALL
ti_import_opengl_memory(TiRuntime runtime,
TiMemory memory,
TiOpenglMemoryInteropInfo *interop_info);

// function.export_opengl_memory
TI_DLL_EXPORT void TI_API_CALL
ti_export_opengl_memory(TiRuntime runtime,
Expand Down
1 change: 0 additions & 1 deletion c_api/include/taichi/taichi_vulkan.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <taichi/taichi_core.h>
#include <vulkan/vulkan.h>

#ifdef __cplusplus
extern "C" {
Expand Down
63 changes: 57 additions & 6 deletions c_api/taichi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"name": "taichi/taichi_platform.h",
"is_built_in": true
},
{
"name": "vulkan/vulkan.h",
"is_built_in": true
},
{
"name": "taichi/taichi_core.h",
"required_modules": [
Expand Down Expand Up @@ -874,8 +870,7 @@
{
"name": "taichi/taichi_vulkan.h",
"required_modules": [
"taichi/taichi_core.h",
"vulkan/vulkan.h"
"taichi/taichi_core.h"
],
"declarations": [
{
Expand Down Expand Up @@ -1165,6 +1160,62 @@
}
]
},
{
"name": "taichi/taichi_opengl.h",
"required_modules": [
"taichi/taichi_core.h"
],
"declarations": [
{
"name": "opengl_memory_interop_info",
"type": "structure",
"fields": [
{
"name": "buffer",
"type": "GLuint"
},
{
"name": "size",
"type": "uint64_t"
}
]
},
{
"name": "import_opengl_memory",
"type": "function",
"parameters": [
{
"type": "handle.runtime"
},
{
"type": "handle.memory"
},
{
"name": "interop_info",
"type": "structure.opengl_memory_interop_info",
"by_mut": true
}
]
},
{
"name": "export_opengl_memory",
"type": "function",
"parameters": [
{
"type": "handle.runtime"
},
{
"type": "handle.memory"
},
{
"name": "interop_info",
"type": "structure.opengl_memory_interop_info",
"by_mut": true
}
]
}
]
},
{
"name": "taichi/taichi_unity.h",
"required_modules": [
Expand Down
1 change: 1 addition & 0 deletions misc/generate_c_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def generate_module_header(module):
BuiltInType("VkImageViewType", "VkImageViewType"),
BuiltInType("PFN_vkGetInstanceProcAddr", "PFN_vkGetInstanceProcAddr"),
BuiltInType("char", "char"),
BuiltInType("GLuint", "GLuint"),
}

for module in Module.load_all(builtin_tys):
Expand Down

0 comments on commit b5f42b7

Please sign in to comment.