Skip to content

Commit

Permalink
[Build] [refactor] Define Cmake OpenGL runtime target (#4887)
Browse files Browse the repository at this point in the history
* Move LLVM Cmake to its own dir

* Suppress warning from submodules

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Use current source dir

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Separate Vulkan runtime files from codegen

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Use keywords instead of plain target_link_libraries

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Separate opengl runtime files from backend

* Remove some warnings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Minor

* Add glfw include

* Add link to taichi core

* Update taichi/program/extension.cpp

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: yekuang <k-ye@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 30, 2022
1 parent de08a27 commit b3446e9
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 13 deletions.
5 changes: 5 additions & 0 deletions cmake/TaichiCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ if (APPLE)
)
endif()

# TODO: replace these includes per target basis
include_directories(${CMAKE_SOURCE_DIR})
include_directories(external/include)
include_directories(external/spdlog/include)
include_directories(external/glad/include)
include_directories(external/SPIRV-Tools/include)
include_directories(external/PicoSHA2)
if (TI_WITH_OPENGL)
Expand Down Expand Up @@ -351,6 +353,9 @@ if (TI_WITH_OPENGL)
add_subdirectory(external/SPIRV-Cross)
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/SPIRV-Cross)
target_link_libraries(${CORE_LIBRARY_NAME} PRIVATE spirv-cross-glsl spirv-cross-core)

add_subdirectory(taichi/runtime/opengl)
target_link_libraries(${CORE_LIBRARY_NAME} PRIVATE opengl_runtime)
endif()

if (TI_WITH_DX11)
Expand Down
4 changes: 2 additions & 2 deletions taichi/backends/opengl/codegen_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>

#include "taichi/backends/opengl/opengl_api.h"
#include "taichi/runtime/opengl/opengl_api.h"
#include "taichi/backends/opengl/opengl_data_types.h"
#include "taichi/backends/opengl/opengl_kernel_util.h"
#include "taichi/ir/ir.h"
Expand Down Expand Up @@ -31,7 +31,7 @@ namespace shaders {

#define TI_INSIDE_OPENGL_CODEGEN
#include "taichi/backends/opengl/shaders/atomics_macro_f32.glsl.h"
#include "taichi/backends/opengl/shaders/runtime.h"
#include "taichi/runtime/opengl/shaders/runtime.h"
#include "taichi/backends/opengl/shaders/random.glsl.h"
#include "taichi/backends/opengl/shaders/fast_pow.glsl.h"
#include "taichi/backends/opengl/shaders/print.glsl.h"
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/codegen_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "taichi/inc/constants.h"
#include "taichi/lang_util.h"
#include "taichi/backends/opengl/struct_opengl.h"
#include "taichi/backends/opengl/opengl_api.h"
#include "taichi/runtime/opengl/opengl_api.h"

#include <string>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/opengl_device.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "opengl_device.h"
#include "opengl_api.h"
#include "taichi/runtime/opengl/opengl_api.h"

namespace taichi {
namespace lang {
Expand Down
4 changes: 2 additions & 2 deletions taichi/backends/opengl/opengl_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "taichi/backends/opengl/struct_opengl.h"

#include "taichi/backends/opengl/opengl_kernel_launcher.h"
#include "taichi/backends/opengl/opengl_api.h"
#include "taichi/runtime/opengl/opengl_kernel_launcher.h"
#include "taichi/runtime/opengl/opengl_api.h"
#include "taichi/backends/opengl/codegen_opengl.h"

#include "taichi/system/memory_pool.h"
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/shaders/indirect.glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"#version 430 core\nprecision highp float;\n"
#define TI_INSIDE_OPENGL_CODEGEN
#define TI_OPENGL_NESTED_INCLUDE
#include "taichi/backends/opengl/shaders/runtime.h"
#include "taichi/runtime/opengl/shaders/runtime.h"
#undef TI_OPENGL_NESTED_INCLUDE
#undef TI_INSIDE_OPENGL_CODEGEN
STR(
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/struct_opengl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Codegen for the hierarchical data structure
#pragma once

#include "taichi/backends/opengl/opengl_kernel_launcher.h"
#include "taichi/runtime/opengl/opengl_kernel_launcher.h"
#include "taichi/backends/opengl/opengl_data_types.h"
#include "taichi/ir/snode.h"

Expand Down
2 changes: 1 addition & 1 deletion taichi/codegen/spirv/spirv_ir_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ void IRBuilder::init_random_function(Value global_tmp_) {
store_var(rand_z_, _521288629u);
store_var(rand_w_, _88675123u);

enum spv::Op add_op = spv::OpIAdd;
// enum spv::Op add_op = spv::OpIAdd;
bool use_atomic_increment = false;

// use atomic increment for DX API to avoid error X3694
Expand Down
1 change: 0 additions & 1 deletion taichi/program/extension.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "extension.h"
//#include "taichi/backends/opengl/opengl_api.h"

#include <unordered_map>
#include <unordered_set>
Expand Down
2 changes: 1 addition & 1 deletion taichi/python/export_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*******************************************************************************/

#include "taichi/backends/metal/api.h"
#include "taichi/backends/opengl/opengl_api.h"
#include "taichi/runtime/opengl/opengl_api.h"
#include "taichi/runtime/vulkan/runtime.h"
#include "taichi/backends/dx/dx_api.h"
#include "taichi/common/core.h"
Expand Down
16 changes: 16 additions & 0 deletions taichi/runtime/opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ./taichi/runtime/opengl/CMakeLists.txt

add_library(opengl_runtime)
target_sources(opengl_runtime
PRIVATE
opengl_api.cpp
)
target_include_directories(opengl_runtime
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/shaders
${PROJECT_SOURCE_DIR}/external/SPIRV-Tools/include
${PROJECT_SOURCE_DIR}/external/glad/include
${PROJECT_SOURCE_DIR}/external/eigen
${PROJECT_SOURCE_DIR}/external/glfw/include
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "taichi/backends/opengl/opengl_kernel_util.h"
#include "taichi/backends/opengl/opengl_utils.h"
#include "taichi/backends/opengl/shaders/runtime.h"
#include "taichi/runtime/opengl/shaders/runtime.h"
#include "taichi/ir/transforms.h"
#include "taichi/program/kernel.h"
#include "taichi/program/program.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>

#include "taichi/backends/device.h"
#include "taichi/backends/opengl/opengl_kernel_launcher.h"
#include "taichi/runtime/opengl/opengl_kernel_launcher.h"
#include "taichi/backends/opengl/opengl_kernel_util.h"
#include "taichi/common/core.h"
#include "taichi/ir/offloaded_task_type.h"
Expand Down
File renamed without changes.

0 comments on commit b3446e9

Please sign in to comment.