From 1102b4d633841e54cc780caccd49698af8357eba Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 4 Dec 2014 16:40:55 -0800 Subject: [PATCH 1/4] Moving GPU into it's own library --- interface/CMakeLists.txt | 2 +- libraries/gpu/CMakeLists.txt | 52 +++++++++++++++++++ .../gpu}/src/gpu/Batch.cpp | 0 {interface => libraries/gpu}/src/gpu/Batch.h | 4 +- .../gpu}/src/gpu/Context.cpp | 0 .../gpu}/src/gpu/Context.h | 4 +- {interface => libraries/gpu}/src/gpu/Format.h | 2 +- .../gpu}/src/gpu/GLBackend.cpp | 2 +- .../gpu}/src/gpu/GLBackend.h | 6 +-- libraries/gpu/src/gpu/GPUConfig.h | 30 +++++++++++ .../gpu}/src/gpu/Resource.cpp | 0 .../gpu}/src/gpu/Resource.h | 4 +- .../gpu}/src/gpu/Stream.cpp | 0 {interface => libraries/gpu}/src/gpu/Stream.h | 6 +-- 14 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 libraries/gpu/CMakeLists.txt rename {interface => libraries/gpu}/src/gpu/Batch.cpp (100%) rename {interface => libraries/gpu}/src/gpu/Batch.h (98%) rename {interface => libraries/gpu}/src/gpu/Context.cpp (100%) rename {interface => libraries/gpu}/src/gpu/Context.h (94%) rename {interface => libraries/gpu}/src/gpu/Format.h (98%) rename {interface => libraries/gpu}/src/gpu/GLBackend.cpp (99%) rename {interface => libraries/gpu}/src/gpu/GLBackend.h (98%) create mode 100644 libraries/gpu/src/gpu/GPUConfig.h rename {interface => libraries/gpu}/src/gpu/Resource.cpp (100%) rename {interface => libraries/gpu}/src/gpu/Resource.h (98%) rename {interface => libraries/gpu}/src/gpu/Stream.cpp (100%) rename {interface => libraries/gpu}/src/gpu/Stream.h (97%) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index eb788ac49a..38dd02c655 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -107,7 +107,7 @@ endif() add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # link required hifi libraries -link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine physics) +link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics) # find any optional and required libraries find_package(ZLIB REQUIRED) diff --git a/libraries/gpu/CMakeLists.txt b/libraries/gpu/CMakeLists.txt new file mode 100644 index 0000000000..712e4320b5 --- /dev/null +++ b/libraries/gpu/CMakeLists.txt @@ -0,0 +1,52 @@ +set(TARGET_NAME gpu) + +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library() + +include_glm() + +link_hifi_libraries(shared) +if (APPLE) + # link in required OS X frameworks and include the right GL headers + find_library(CoreFoundation CoreFoundation) + find_library(OpenGL OpenGL) + + target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${OpenGL}) + + # install command for OS X bundle + INSTALL(TARGETS ${TARGET_NAME} + BUNDLE DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/install" COMPONENT Runtime + RUNTIME DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/install" COMPONENT Runtime + ) +else (APPLE) + find_package(OpenGL REQUIRED) + + if (${OPENGL_INCLUDE_DIR}) + include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") + endif () + + target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}") + + # link target to external libraries + if (WIN32) + find_package(GLEW REQUIRED) + include_directories(${GLEW_INCLUDE_DIRS}) + + # we're using static GLEW, so define GLEW_STATIC + add_definitions(-DGLEW_STATIC) + + target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" opengl32.lib) + + # try to find the Nsight package and add it to the build if we find it + find_package(NSIGHT) + if (NSIGHT_FOUND) + include_directories(${NSIGHT_INCLUDE_DIRS}) + add_definitions(-DNSIGHT_FOUND) + target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") + endif () + + endif() +endif (APPLE) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies() diff --git a/interface/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp similarity index 100% rename from interface/src/gpu/Batch.cpp rename to libraries/gpu/src/gpu/Batch.cpp diff --git a/interface/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h similarity index 98% rename from interface/src/gpu/Batch.h rename to libraries/gpu/src/gpu/Batch.h index 5304740dd3..601ae63a77 100644 --- a/interface/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -12,13 +12,13 @@ #define hifi_gpu_Batch_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" #include "Transform.h" #include -#include "gpu/Stream.h" +#include "Stream.h" #if defined(NSIGHT_FOUND) #include "nvToolsExt.h" diff --git a/interface/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp similarity index 100% rename from interface/src/gpu/Context.cpp rename to libraries/gpu/src/gpu/Context.cpp diff --git a/interface/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h similarity index 94% rename from interface/src/gpu/Context.h rename to libraries/gpu/src/gpu/Context.h index 8398288cb9..3a0fffb4ef 100644 --- a/interface/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -12,9 +12,9 @@ #define hifi_gpu_Context_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" -#include "gpu/Resource.h" +#include "Resource.h" namespace gpu { diff --git a/interface/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h similarity index 98% rename from interface/src/gpu/Format.h rename to libraries/gpu/src/gpu/Format.h index 8faa995924..d216495b4c 100644 --- a/interface/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -12,7 +12,7 @@ #define hifi_gpu_Format_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" namespace gpu { diff --git a/interface/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp similarity index 99% rename from interface/src/gpu/GLBackend.cpp rename to libraries/gpu/src/gpu/GLBackend.cpp index 1f8e7bf99f..85f0dde858 100644 --- a/interface/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -12,7 +12,7 @@ #include -#include "gpu/Batch.h" +#include "Batch.h" using namespace gpu; diff --git a/interface/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h similarity index 98% rename from interface/src/gpu/GLBackend.h rename to libraries/gpu/src/gpu/GLBackend.h index 0e4b38d89e..5a40e9ca36 100644 --- a/interface/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -12,10 +12,10 @@ #define hifi_gpu_GLBackend_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" -#include "gpu/Context.h" -#include "gpu/Batch.h" +#include "Context.h" +#include "Batch.h" #include diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h new file mode 100644 index 0000000000..024cf73112 --- /dev/null +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -0,0 +1,30 @@ +// +// GPUConfig.h +// libraries/gpu/src/gpu +// +// Created by Sam Gateau on 12/4/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef gpu__GPUConfig__ +#define gpu__GPUConfig__ + +#define GL_GLEXT_PROTOTYPES 1 + +#if defined(APPLE) +#include + +#elif defined(UNIX) +#include +#include + +#elif defined(WIN32) +#include +#include + +#endif + +#endif diff --git a/interface/src/gpu/Resource.cpp b/libraries/gpu/src/gpu/Resource.cpp similarity index 100% rename from interface/src/gpu/Resource.cpp rename to libraries/gpu/src/gpu/Resource.cpp diff --git a/interface/src/gpu/Resource.h b/libraries/gpu/src/gpu/Resource.h similarity index 98% rename from interface/src/gpu/Resource.h rename to libraries/gpu/src/gpu/Resource.h index 52108c215a..6247efe675 100644 --- a/interface/src/gpu/Resource.h +++ b/libraries/gpu/src/gpu/Resource.h @@ -12,9 +12,9 @@ #define hifi_gpu_Resource_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" -#include "gpu/Format.h" +#include "Format.h" #include diff --git a/interface/src/gpu/Stream.cpp b/libraries/gpu/src/gpu/Stream.cpp similarity index 100% rename from interface/src/gpu/Stream.cpp rename to libraries/gpu/src/gpu/Stream.cpp diff --git a/interface/src/gpu/Stream.h b/libraries/gpu/src/gpu/Stream.h similarity index 97% rename from interface/src/gpu/Stream.h rename to libraries/gpu/src/gpu/Stream.h index d024182531..93abfeeca3 100644 --- a/interface/src/gpu/Stream.h +++ b/libraries/gpu/src/gpu/Stream.h @@ -12,10 +12,10 @@ #define hifi_gpu_Stream_h #include -#include "InterfaceConfig.h" +#include "GPUConfig.h" -#include "gpu/Resource.h" -#include "gpu/Format.h" +#include "Resource.h" +#include "Format.h" #include #include From da1bb83eb0b34c8ea9c7b50c105c0dad4436f43f Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 4 Dec 2014 17:14:41 -0800 Subject: [PATCH 2/4] compiling the gpu library on mac --- libraries/gpu/CMakeLists.txt | 8 +------- libraries/gpu/src/gpu/GPUConfig.h | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libraries/gpu/CMakeLists.txt b/libraries/gpu/CMakeLists.txt index 712e4320b5..577f9f7a58 100644 --- a/libraries/gpu/CMakeLists.txt +++ b/libraries/gpu/CMakeLists.txt @@ -8,16 +8,10 @@ include_glm() link_hifi_libraries(shared) if (APPLE) # link in required OS X frameworks and include the right GL headers - find_library(CoreFoundation CoreFoundation) find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${OpenGL}) + target_link_libraries(${TARGET_NAME} ${OpenGL}) - # install command for OS X bundle - INSTALL(TARGETS ${TARGET_NAME} - BUNDLE DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/install" COMPONENT Runtime - RUNTIME DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/install" COMPONENT Runtime - ) else (APPLE) find_package(OpenGL REQUIRED) diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index 024cf73112..0d0a140e62 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -14,7 +14,8 @@ #define GL_GLEXT_PROTOTYPES 1 -#if defined(APPLE) +#ifdef __APPLE__ +#include #include #elif defined(UNIX) From 16da10bf19f401ed86f3c172275a27f53eb9e3a8 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 4 Dec 2014 17:15:59 -0800 Subject: [PATCH 3/4] compiling the gpu library on mac --- libraries/gpu/src/gpu/GPUConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index 0d0a140e62..faecfd4889 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -14,7 +14,7 @@ #define GL_GLEXT_PROTOTYPES 1 -#ifdef __APPLE__ +#if defined(__APPLE__) #include #include From 69792178b95f5eb4a1223456fb3052aeff0fed8d Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 5 Dec 2014 13:43:04 -0800 Subject: [PATCH 4/4] trying to fix the linux compilation --- libraries/gpu/src/gpu/GPUConfig.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index faecfd4889..393a476182 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -18,14 +18,15 @@ #include #include -#elif defined(UNIX) -#include -#include - #elif defined(WIN32) #include #include +#else +#include +#include + + #endif #endif