diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2017-12-16 05:23:06 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2017-12-16 05:23:06 +0000 |
| commit | 035dd284b70429c7a59237c1e6debc1663bd7e15 (patch) | |
| tree | b2d50e6c0141bfb8c403010831036799ac657411 /Graphics | |
| parent | Updated CMakeLists (diff) | |
| download | DiligentCore-035dd284b70429c7a59237c1e6debc1663bd7e15.tar.gz DiligentCore-035dd284b70429c7a59237c1e6debc1663bd7e15.zip | |
CMake: enabling Android build
Diffstat (limited to 'Graphics')
| -rw-r--r-- | Graphics/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/include/VAOCache.h | 3 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/include/TextureUploaderBase.h | 1 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 4 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/src/TextureUploader.cpp | 3 | ||||
| -rw-r--r-- | Graphics/HLSL2GLSLConverterLib/CMakeLists.txt | 48 |
10 files changed, 66 insertions, 40 deletions
diff --git a/Graphics/CMakeLists.txt b/Graphics/CMakeLists.txt index 9eea09a3..3ae9b9f3 100644 --- a/Graphics/CMakeLists.txt +++ b/Graphics/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.8) +cmake_minimum_required (VERSION 3.6) set(DLL_REL_SUFFIX _${ARCH}r) set(DLL_DBG_SUFFIX _${ARCH}d) diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt index 377a625d..e0949b26 100644 --- a/Graphics/GraphicsEngine/CMakeLists.txt +++ b/Graphics/GraphicsEngine/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.6) project(GraphicsEngine CXX) diff --git a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt index 1ffe9558..decd024a 100644 --- a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt @@ -37,9 +37,8 @@ SOURCES ) if(PLATFORM_UNIVERSAL_WINDOWS) - # On Universal Windows Platform, we cannot run File2String utility and will use prebuilt Win32 version - get_target_property(FILE2STRING_SOURCE_DIR File2String SOURCE_DIR) - set(FILE2STRING_PATH "${FILE2STRING_SOURCE_DIR}/bin/Win32/File2String.exe") + # On Universal Windows Platform, we cannot build File2String utility and will use prebuilt Win32 version + set(FILE2STRING_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Utilities/File2Include/bin/Win32/File2String.exe") else() add_dependencies(ProcessHLSLDefinitions File2String) set(FILE2STRING_PATH $<TARGET_FILE:File2String>) diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index bf046937..bb257613 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -84,7 +84,7 @@ if(PLATFORM_WIN32) list(APPEND SOURCE src/RenderDeviceGLImpl.cpp) set(APPEND INCLUDE include/GLContextWindows.h) -elseif(PLATFORM_ANRDOID) +elseif(PLATFORM_ANDROID) list(APPEND SOURCE src/GLContextAndroid.cpp) list(APPEND SOURCE src/RenderDeviceGLESImpl.cpp) list(APPEND SOURCE src/GLStubs.cpp) @@ -132,13 +132,10 @@ PRIVATE ../HLSL2GLSLConverterLib/include ) - set(PRIVATE_DEPENDENCIES BuildSettings - glew-static Common GraphicsTools - opengl32.lib TargetPlatform ) @@ -147,6 +144,17 @@ set(PUBLIC_DEPENDENCIES HLSL2GLSLConverterLib ) +if(PLATFORM_WIN32) + set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} glew-static opengl32.lib) +elseif(PLATFORM_ANDROID) + set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLESv3 EGL android) + target_compile_definitions(GraphicsEngineOpenGL-static PRIVATE BUILDING_DLL USE_GL3_STUB=0) + target_compile_definitions(GraphicsEngineOpenGL-shared PRIVATE BUILDING_DLL USE_GL3_STUB=0) + # LOCAL_CFLAGS := -fvisibility=hidden +else() + message(FATAL_ERROR "Unknown platform") +endif() + target_link_libraries(GraphicsEngineOpenGL-static PRIVATE ${PRIVATE_DEPENDENCIES} PUBLIC ${PUBLIC_DEPENDENCIES}) target_link_libraries(GraphicsEngineOpenGL-shared PRIVATE ${PRIVATE_DEPENDENCIES} PUBLIC ${PUBLIC_DEPENDENCIES}) target_compile_definitions(GraphicsEngineOpenGL-shared PUBLIC ENGINE_DLL) diff --git a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h index ac469f16..cd2995c8 100644 --- a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h +++ b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h @@ -23,6 +23,7 @@ #pragma once +#include <cstring> #include "GraphicsTypes.h" #include "Buffer.h" #include "InputLayout.h" @@ -91,7 +92,7 @@ private: return pPSO == Key.pPSO && pIndexBuffer == Key.pIndexBuffer && NumUsedSlots == Key.NumUsedSlots && - memcmp(Streams, Key.Streams, sizeof(StreamAttribs) * NumUsedSlots) == 0; + std::memcmp(Streams, Key.Streams, sizeof(StreamAttribs) * NumUsedSlots) == 0; } }; diff --git a/Graphics/GraphicsTools/CMakeLists.txt b/Graphics/GraphicsTools/CMakeLists.txt index 17919956..32b1e919 100644 --- a/Graphics/GraphicsTools/CMakeLists.txt +++ b/Graphics/GraphicsTools/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.6) project(GraphicsTools CXX) @@ -11,9 +11,6 @@ set(INCLUDE include/RingBuffer.h include/TextureUploader.h include/TextureUploaderBase.h - include/TextureUploaderD3D11.h - include/TextureUploaderD3D12.h - include/TextureUploaderGL.h include/VariableSizeAllocationsManager.h include/VariableSizeGPUAllocationsManager.h ) @@ -23,11 +20,22 @@ set(SOURCE src/GraphicsUtilities.cpp src/pch.cpp src/TextureUploader.cpp - src/TextureUploaderD3D11.cpp - src/TextureUploaderD3D12.cpp - src/TextureUploaderGL.cpp ) +if(D3D11_SUPPORTED) + list(APPEND SOURCE src/TextureUploaderD3D11.cpp) + list(APPEND INCLUDE include/TextureUploaderD3D11.h) +endif() + +if(D3D12_SUPPORTED) + list(APPEND SOURCE src/TextureUploaderD3D12.cpp) + list(APPEND INCLUDE include/TextureUploaderD3D12.h) +endif() + +if(GL_SUPPORTED OR GLES_SUPPORTED) + list(APPEND SOURCE src/TextureUploaderGL.cpp) + list(APPEND INCLUDE include/TextureUploaderGL.h) +endif() add_library(GraphicsTools STATIC ${SOURCE} ${INCLUDE}) diff --git a/Graphics/GraphicsTools/include/TextureUploaderBase.h b/Graphics/GraphicsTools/include/TextureUploaderBase.h index 0bd43bcd..4cb6f2ef 100644 --- a/Graphics/GraphicsTools/include/TextureUploaderBase.h +++ b/Graphics/GraphicsTools/include/TextureUploaderBase.h @@ -51,7 +51,6 @@ namespace Diligent { } - virtual void WaitForCopyScheduled() = 0; virtual void* GetDataPtr() override final { return m_pData; } virtual size_t GetRowStride() const override final{ return m_RowStride; } virtual size_t GetDepthStride()const override final{ return m_DepthStride; } diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index 23089571..0cae06ac 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -814,10 +814,10 @@ void GenerateCheckerBoardPatternInternal(Uint32 Width, Uint32 Height, TEXTURE_FO static float LinearToSRGB(float x) { // This is exactly the sRGB curve - //return x < 0.0031308 ? 12.92 * x : 1.055 * pow(abs(x), 1.0 / 2.4) - 0.055; + //return x < 0.0031308 ? 12.92 * x : 1.055 * pow(std::abs(x), 1.0 / 2.4) - 0.055; // This is cheaper but nearly equivalent - return x < 0.0031308f ? 12.92f * x : 1.13005f * sqrtf(abs(x - 0.00228f)) - 0.13448f * x + 0.005719f; + return x < 0.0031308f ? 12.92f * x : 1.13005f * sqrtf(std::abs(x - 0.00228f)) - 0.13448f * x + 0.005719f; } diff --git a/Graphics/GraphicsTools/src/TextureUploader.cpp b/Graphics/GraphicsTools/src/TextureUploader.cpp index f056f162..ddc930ef 100644 --- a/Graphics/GraphicsTools/src/TextureUploader.cpp +++ b/Graphics/GraphicsTools/src/TextureUploader.cpp @@ -45,6 +45,9 @@ namespace Diligent case DeviceType::OpenGL: *ppUploader = MakeNewRCObj<TextureUploaderGL>()( pDevice, Desc ); break; + + default: + UNEXPECTED("Unexpected device type") } if (*ppUploader != nullptr) (*ppUploader)->AddRef(); diff --git a/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt b/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt index a2146be9..b3194592 100644 --- a/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt +++ b/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.3) +cmake_minimum_required (VERSION 3.6) project(HLSL2GLSLConverterLib CXX) @@ -42,25 +42,36 @@ PRIVATE GraphicsTools ) -# Create custom target to convert GLSLDefinitions.h to GLSLDefinitions_inc.h -add_custom_target(ProcessGLSLDefinitions -SOURCES - include/GLSLDefinitions.h -) -add_dependencies(ProcessGLSLDefinitions File2String) +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Create custom target to convert GLSLDefinitions.h to GLSLDefinitions_inc.h + add_custom_target(ProcessGLSLDefinitions + SOURCES + include/GLSLDefinitions.h + ) -add_custom_command(TARGET ProcessGLSLDefinitions - # Unfortunately it is not possible to set TARGET directly to GraphicsEngineD3DBase - # because PRE_BUILD is only supported on Visual Studio 8 or later. For all other generators - # PRE_BUILD is treated as PRE_LINK. - COMMAND COMMAND $<TARGET_FILE:File2String> include/GLSLDefinitions.h include/GLSLDefinitions_inc.h - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Processing GLSLDefinitions.h" - VERBATIM -) + if(PLATFORM_WIN32) + set(FILE2STRING_PATH $<TARGET_FILE:File2String>) + add_dependencies(ProcessGLSLDefinitions File2String) + else() + # We cannot run File2String utility and will use prebuilt Win32 version + set(FILE2STRING_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Utilities/File2Include/bin/Win32/File2String.exe") + endif() -add_dependencies(HLSL2GLSLConverterLib ProcessGLSLDefinitions) + add_custom_command(TARGET ProcessGLSLDefinitions + # Unfortunately it is not possible to set TARGET directly to GraphicsEngineD3DBase + # because PRE_BUILD is only supported on Visual Studio 8 or later. For all other generators + # PRE_BUILD is treated as PRE_LINK. + COMMAND COMMAND ${FILE2STRING_PATH} include/GLSLDefinitions.h include/GLSLDefinitions_inc.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Processing GLSLDefinitions.h" + VERBATIM + ) + add_dependencies(HLSL2GLSLConverterLib ProcessGLSLDefinitions) + set_target_properties(ProcessGLSLDefinitions PROPERTIES + FOLDER Core/Graphics/Helper + ) +endif() source_group("src" FILES ${SOURCE}) source_group("include" FILES ${INCLUDE}) @@ -70,6 +81,3 @@ source_group("generated" FILES include/GLSLDefinitions_inc.h) set_target_properties(HLSL2GLSLConverterLib PROPERTIES FOLDER Core/Graphics ) -set_target_properties(ProcessGLSLDefinitions PROPERTIES - FOLDER Core/Graphics/Helper -)
\ No newline at end of file |
