Skip to content

Commit

Permalink
[aot] Revert "C-API opengl runtime interop (#7014)" (#7032)
Browse files Browse the repository at this point in the history
This reverts commit a1485cd.

Issue: #

### Brief Summary
  • Loading branch information
feisuzhu authored Jan 3, 2023
1 parent 218e854 commit c012eb3
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 74 deletions.
15 changes: 0 additions & 15 deletions c_api/include/taichi/taichi_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
extern "C" {
#endif // __cplusplus

// Structure `TiOpenglRuntimeInteropInfo`
typedef struct TiOpenglRuntimeInteropInfo {
void *get_proc_addr;
} TiOpenglRuntimeInteropInfo;

// Function `ti_import_opengl_runtime`
TI_DLL_EXPORT void TI_API_CALL
ti_import_opengl_runtime(TiRuntime runtime,
TiOpenglRuntimeInteropInfo *interop_info);

// Function `ti_export_opengl_runtime`
TI_DLL_EXPORT void TI_API_CALL
ti_export_opengl_runtime(TiRuntime runtime,
TiOpenglRuntimeInteropInfo *interop_info);

// Structure `TiOpenglMemoryInteropInfo`
typedef struct TiOpenglMemoryInteropInfo {
GLuint buffer;
Expand Down
9 changes: 0 additions & 9 deletions c_api/src/taichi_opengl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

OpenglRuntime::OpenglRuntime()
: GfxRuntime(taichi::Arch::opengl),
device_(),
gfx_runtime_(taichi::lang::gfx::GfxRuntime::Params{
host_result_buffer_.data(), &device_}) {
taichi::lang::DeviceCapabilityConfig caps{};
Expand All @@ -19,14 +18,6 @@ taichi::lang::gfx::GfxRuntime &OpenglRuntime::get_gfx_runtime() {
return gfx_runtime_;
}

void ti_export_opengl_runtime(TiRuntime runtime,
TiOpenglRuntimeInteropInfo *interop_info) {
TI_CAPI_TRY_CATCH_BEGIN();
// FIXME: (penguinliogn)
interop_info->get_proc_addr = taichi::lang::opengl::kGetOpenglProcAddr;
TI_CAPI_TRY_CATCH_END();
}

void ti_export_opengl_memory(TiRuntime runtime,
TiMemory memory,
TiOpenglMemoryInteropInfo *interop_info) {
Expand Down
2 changes: 0 additions & 2 deletions c_api/src/taichi_vulkan_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ VulkanRuntimeImported::Workaround::Workaround(
taichi::lang::vulkan::VulkanLoader::instance().load_instance(params.instance);
taichi::lang::vulkan::VulkanLoader::instance().load_device(params.device);
vk_device.vk_caps().vk_api_version = api_version;
// FIXME: (penguinliong) Workaround missing vulkan caps from import.
vk_device.vk_caps().external_memory = true;

taichi::lang::DeviceCapabilityConfig caps{};

Expand Down
38 changes: 0 additions & 38 deletions c_api/taichi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1248,44 +1248,6 @@
"taichi/taichi_core.h"
],
"declarations": [
{
"name": "opengl_runtime_interop_info",
"type": "structure",
"fields": [
{
"name": "get_proc_addr",
"type": "void*"
}
]
},
{
"name": "import_opengl_runtime",
"type": "function",
"parameters": [
{
"type": "handle.runtime"
},
{
"name": "interop_info",
"type": "structure.opengl_runtime_interop_info",
"by_mut": true
}
]
},
{
"name": "export_opengl_runtime",
"type": "function",
"parameters": [
{
"type": "handle.runtime"
},
{
"name": "interop_info",
"type": "structure.opengl_runtime_interop_info",
"by_mut": true
}
]
},
{
"name": "opengl_memory_interop_info",
"type": "structure",
Expand Down
6 changes: 1 addition & 5 deletions taichi/rhi/opengl/opengl_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ int opengl_max_grid_dim = 1024;
// without this global static boolean.
static bool kUseGles = false;
static std::optional<bool> supported; // std::nullopt
void *kGetOpenglProcAddr;

static void glfw_error_callback(int code, const char *description) {
TI_WARN("GLFW Error {}: {}", code, description);
Expand All @@ -45,7 +44,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) {

// Code below is guaranteed to be called at most once.
int opengl_version = 0;
void *get_proc_addr = nullptr;

if (glfwInit()) {
glfwSetErrorCallback(glfw_error_callback);
Expand All @@ -55,6 +53,7 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
} else {
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
Expand All @@ -74,7 +73,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) {
TI_DEBUG("[glsl] cannot create GLFW window: error {}: {}", status, desc);
} else {
glfwMakeContextCurrent(window);
get_proc_addr = (void *)&glfwGetProcAddress;
if (use_gles) {
opengl_version = gladLoadGLES2(glfwGetProcAddress);
} else {
Expand Down Expand Up @@ -150,7 +148,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) {

eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context);

get_proc_addr = (void *)&glad_eglGetProcAddress;
if (use_gles) {
opengl_version = gladLoadGLES2(glad_eglGetProcAddress);
} else {
Expand Down Expand Up @@ -197,7 +194,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) {

supported = std::make_optional<bool>(true);
kUseGles = use_gles;
kGetOpenglProcAddr = get_proc_addr;
return true;
}

Expand Down
5 changes: 1 addition & 4 deletions taichi/rhi/opengl/opengl_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ void GLStream::command_sync() {
}

GLDevice::GLDevice() : stream_(this) {
initialize_opengl(false, true);
DeviceCapabilityConfig caps{};
if (!is_gles()) {
// 64bit isn't supported in ES profile
Expand Down Expand Up @@ -556,9 +555,9 @@ GLint GLDevice::get_devalloc_size(DeviceAllocation handle) {
GLint size = 0;
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
check_opengl_error("glGetBufferParameteriv");
return size;
glBindBuffer(GL_ARRAY_BUFFER, 0);
check_opengl_error("glBindBuffer");
return size;
}

std::unique_ptr<Pipeline> GLDevice::create_pipeline(
Expand Down Expand Up @@ -872,9 +871,7 @@ void GLCommandList::CmdImageToBuffer::execute() {
(void *)offset);
check_opengl_error("glGetTexImage");
glBindTexture(image_dims, /*target=*/0);
check_opengl_error("glBindTexture");
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, /*target=*/0);
check_opengl_error("glBindBuffer");
}

} // namespace opengl
Expand Down
1 change: 0 additions & 1 deletion taichi/rhi/opengl/opengl_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace opengl {
class GLDevice;

void check_opengl_error(const std::string &msg = "OpenGL");
extern void *kGetOpenglProcAddr;

class GLResourceSet : public ShaderResourceSet {
public:
Expand Down

0 comments on commit c012eb3

Please sign in to comment.