From 3122576f0419b9531544f483a9b50d2d8ac02789 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 4 Dec 2024 15:04:51 +0100 Subject: [PATCH] enabling pre compiled header --- Makefile | 16 ++++++++++++++-- runtime/Includes/PreCompiled.h | 1 + runtime/Sources/Renderer/Descriptor.cpp | 1 - runtime/Sources/Renderer/RenderCore.cpp | 10 ++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0224cc8..cc39693 100644 --- a/Makefile +++ b/Makefile @@ -31,13 +31,19 @@ CXX = clang++ CXXFLAGS = -std=c++20 -fPIC -Wall -Wextra -DSDL_MAIN_HANDLED INCLUDES = -I./includes -I./runtime/Includes -I./runtime/Sources -I./third_party +CXXPCHFLAGS = + +PCH = runtime/Includes/PreCompiled.h +GCH = runtime/Includes/PreCompiled.h.gch + NZSLC = nzslc ifeq ($(TOOLCHAIN), gcc) CXX = g++ CXXFLAGS += -Wno-error=cpp else - CXXFLAGS += -Wno-error=#warning + CXXFLAGS += -Wno-error=#warning -include-pch $(GCH) + CXXPCHFLAGS = -xc++-header endif ifeq ($(OS), Darwin) @@ -108,7 +114,7 @@ ifeq ($(OBJS_TOTAL), 0) # To avoid division per 0 endif CURR_OBJ = 0 -$(OBJ_DIR)/%.o: %.cpp +$(OBJ_DIR)/%.o: %.cpp $(GCH) @mkdir -p $(dir $@) @$(eval CURR_OBJ=$(shell echo $$(( $(CURR_OBJ) + 1 )))) @$(eval PERCENT=$(shell echo $$(( $(CURR_OBJ) * 100 / $(OBJS_TOTAL) )))) @@ -132,6 +138,10 @@ CURR_SPV = 0 all: _printbuildinfos @$(MAKE) $(NAME) +$(GCH): + @printf "$(COLOR)($(_BOLD)%3s%%$(_RESET)$(COLOR)) $(_RESET)Compiling $(_BOLD)PreCompiled header$(_RESET)\n" "0" + @$(CXX) $(CXXPCHFLAGS) $(INCLUDES) $(PCH) -o $(GCH) + $(NAME): $(OBJS) @printf "Linking $(_BOLD)$(NAME)$(_RESET)\n" @$(CXX) -shared -o $(NAME) $(OBJS) $(LDFLAGS) @@ -151,6 +161,8 @@ shaders: clean-shaders $(SPVS) clean: @$(RM) $(OBJ_DIR) @printf "Cleaned $(_BOLD)$(OBJ_DIR)$(_RESET)\n" + @$(RM) $(GCH) + @printf "Cleaned $(_BOLD)$(GCH)$(_RESET)\n" fclean: clean @$(RM) $(NAME) diff --git a/runtime/Includes/PreCompiled.h b/runtime/Includes/PreCompiled.h index b4f64b6..4a958a9 100644 --- a/runtime/Includes/PreCompiled.h +++ b/runtime/Includes/PreCompiled.h @@ -83,6 +83,7 @@ #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-variable" + #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wparentheses" #include #pragma GCC diagnostic pop diff --git a/runtime/Sources/Renderer/Descriptor.cpp b/runtime/Sources/Renderer/Descriptor.cpp index db18106..0954bd0 100644 --- a/runtime/Sources/Renderer/Descriptor.cpp +++ b/runtime/Sources/Renderer/Descriptor.cpp @@ -142,7 +142,6 @@ namespace mlx void DescriptorPoolManager::Destroy() { MLX_PROFILE_FUNCTION(); - #pragma omp parallel for for(auto& pool : m_pools) pool.Destroy(); m_pools.clear(); diff --git a/runtime/Sources/Renderer/RenderCore.cpp b/runtime/Sources/Renderer/RenderCore.cpp index f2b005c..e4e6aa4 100644 --- a/runtime/Sources/Renderer/RenderCore.cpp +++ b/runtime/Sources/Renderer/RenderCore.cpp @@ -12,14 +12,16 @@ #define KVF_REALLOC(p, x) (mlx::MemManager::Get().Realloc(p, x)) #define KVF_FREE(x) (mlx::MemManager::Get().Free(x)) -#if defined(MLX_COMPILER_GCC) || defined(MLX_COMPILER_CLANG) - #pragma clang diagnostic push +#if defined(MLX_COMPILER_GCC) #pragma GCC diagnostic push - #pragma clang diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #include - #pragma clang diagnostic pop #pragma GCC diagnostic pop +#elif defined(MLX_COMPILER_CLANG) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-field-initializers" + #include + #pragma clang diagnostic pop #else #include #endif