From 9b8d41557bd7717492a30633e1afef863200a4d1 Mon Sep 17 00:00:00 2001 From: 0xzhang Date: Sun, 17 Oct 2021 17:55:55 +0800 Subject: [PATCH] [vulkan] Clear unnecessary GLSL shader files on Vulkan backend. --- cmake/TaichiCore.cmake | 2 +- taichi/backends/vulkan/shaders/atomics.glsl.h | 44 ------------------- taichi/backends/vulkan/shaders/epilogue.h | 1 - taichi/backends/vulkan/shaders/prologue.h | 28 ------------ 4 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 taichi/backends/vulkan/shaders/atomics.glsl.h delete mode 100644 taichi/backends/vulkan/shaders/epilogue.h delete mode 100644 taichi/backends/vulkan/shaders/prologue.h diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index 3d6e6d2a0ca6f..525fcee7f0c09 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -58,7 +58,7 @@ file(GLOB TAICHI_CUDA_SOURCE "taichi/backends/cuda/*.cpp" "taichi/backends/cuda/ file(GLOB TAICHI_METAL_SOURCE "taichi/backends/metal/*.h" "taichi/backends/metal/*.cpp" "taichi/backends/metal/shaders/*") file(GLOB TAICHI_OPENGL_SOURCE "taichi/backends/opengl/*.h" "taichi/backends/opengl/*.cpp" "taichi/backends/opengl/shaders/*") file(GLOB TAICHI_CC_SOURCE "taichi/backends/cc/*.h" "taichi/backends/cc/*.cpp") -file(GLOB TAICHI_VULKAN_SOURCE "taichi/backends/vulkan/*.h" "taichi/backends/vulkan/*.cpp" "taichi/backends/vulkan/shaders/*" "external/SPIRV-Reflect/spirv_reflect.c") +file(GLOB TAICHI_VULKAN_SOURCE "taichi/backends/vulkan/*.h" "taichi/backends/vulkan/*.cpp" "external/SPIRV-Reflect/spirv_reflect.c") file(GLOB TAICHI_INTEROP_SOURCE "taichi/backends/interop/*.cpp" "taichi/backends/interop/*.h") diff --git a/taichi/backends/vulkan/shaders/atomics.glsl.h b/taichi/backends/vulkan/shaders/atomics.glsl.h deleted file mode 100644 index 1c183b6f4b30e..0000000000000 --- a/taichi/backends/vulkan/shaders/atomics.glsl.h +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format on -#include "taichi/backends/vulkan/shaders/prologue.h" - -#ifndef TI_INSIDE_VULKAN_CODEGEN -static_assert(false, "do not include"); -#endif // TI_INSIDE_VULKAN_CODEGEN - -#define VULKAN_BEGIN_CODE_DEF constexpr auto kVulkanAtomicsSourceCode = -#define VULKAN_END_CODE_DEF ; - -// clang-format off -VULKAN_BEGIN_CODE_DEF -STR( -// TODO: don't duplicate, pass in pointer -float fatomicAdd_root_buffer(int addr, float data) { - int old_val = 0; - int new_val = 0; - int cas_val = 0; - int ok = 0; - while (ok == 0) { - old_val = root_buffer[addr]; - new_val = floatBitsToInt(intBitsToFloat(old_val) + data); - cas_val = atomicCompSwap(root_buffer[addr], old_val, new_val); - ok = int(cas_val == old_val); - } - return intBitsToFloat(old_val); -} - -float fatomicAdd_global_tmps_buffer(int addr, float data) { - int old_val = 0; - int new_val = 0; - int cas_val = 0; - int ok = 0; - while (ok == 0) { - old_val = global_tmps_buffer[addr]; - new_val = floatBitsToInt(intBitsToFloat(old_val) + data); - cas_val = atomicCompSwap(global_tmps_buffer[addr], old_val, new_val); - ok = int(cas_val == old_val); - } - return intBitsToFloat(old_val); -} -) -VULKAN_END_CODE_DEF -// clang-format on diff --git a/taichi/backends/vulkan/shaders/epilogue.h b/taichi/backends/vulkan/shaders/epilogue.h deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/taichi/backends/vulkan/shaders/epilogue.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/taichi/backends/vulkan/shaders/prologue.h b/taichi/backends/vulkan/shaders/prologue.h deleted file mode 100644 index bbacdf2efc286..0000000000000 --- a/taichi/backends/vulkan/shaders/prologue.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef TI_INSIDE_VULKAN_CODEGEN - -#include "taichi/util/macros.h" - -#else - -#define STR(...) __VA_ARGS__ - -#define inout - -// GLSL builtin stubs -int floatBitsToInt(float f) { - return *reinterpret_cast(&f); -} - -int intBitsToFloat(float f) { - return *reinterpret_cast(&f); -} - -int atomicCompSwap(int &mem, int compare, int data) { - const int old = mem; - if (mem == compare) { - mem = data; - } - return old; -} - -#endif // TI_INSIDE_VULKAN_CODEGEN