From 0393a41b89fb80df094e3a00a3a3d5b7bd509524 Mon Sep 17 00:00:00 2001 From: tx00100xt Date: Tue, 3 Oct 2023 13:22:31 +0300 Subject: [PATCH] Added support building only OpenGL version of game --- CMakeLists.txt | 3 + README.md | 14 ++ SamTFE/Sources/CMakeLists.txt | 205 +++++++++++++++++- SamTFE/Sources/Engine/Graphics/DrawPort.cpp | 7 +- .../Engine/Graphics/DrawPort_RenderScene.cpp | 5 + SamTFE/Sources/Engine/Rendering/Render.cpp | 4 + SamTSE/Sources/CMakeLists.txt | 205 +++++++++++++++++- SamTSE/Sources/Engine/Graphics/DrawPort.cpp | 7 +- .../Engine/Graphics/DrawPort_RenderScene.cpp | 5 + SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp | 2 +- SamTSE/Sources/Engine/Rendering/Render.cpp | 4 + 11 files changed, 438 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f3ed04c..600e0f68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,9 +63,12 @@ if(USE_SYSTEM_VULKAN) find_package(Vulkan REQUIRED) if(Vulkan_FOUND) include_directories(${Vulkan_INCLUDE_DIRS}) + message(STATUS "Building Vulkan/OpenGL version") else() message(FATAL_ERROR "Error! USE_SYSTEM_VULKAN is set but neccessary developer files are missing") endif() +else() + message(STATUS "Building OpenGL version only without Vulkan support") endif() diff --git a/README.md b/README.md index ed03aeee..73589934 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,20 @@ make -j4 make install ``` +#### Building OpenGL version only + +If your video card does not support Vulkan and you do not have the Vulkan libraries and header files installed, then you can build a version only with an OpenGL render. +You just need to add one key(**-DUSE_SYSTEM_VULKAN=FALSE**) for the cmake command. Example: + +``` +cd SeriousSamClassic-VK +mkdir build +cd build +cmake -DUSE_SYSTEM_VULKAN=FALSE .. +make -j4 +make install +``` + Running ------- diff --git a/SamTFE/Sources/CMakeLists.txt b/SamTFE/Sources/CMakeLists.txt index aa803f15..a6f00e6b 100644 --- a/SamTFE/Sources/CMakeLists.txt +++ b/SamTFE/Sources/CMakeLists.txt @@ -109,11 +109,15 @@ option(TFE "Compile a The First Encounter version" FALSE) if(INTERNAL_NAME STREQUAL "serioussam") add_definitions(-DFIRST_ENCOUNTER=1) - add_definitions(-DSE1_VULKAN=1) + if(USE_SYSTEM_VULKAN) + add_definitions(-DSE1_VULKAN=1) + endif() set(MP "") message(STATUS "Building Serious Sam Classic The First Encounter") else() - add_definitions(-DSE1_VULKAN=1) + if(USE_SYSTEM_VULKAN) + add_definitions(-DSE1_VULKAN=1) + endif() set(MP "MP") message(STATUS "Building Serious Sam Classic The Second Encounter") endif() @@ -1024,6 +1028,7 @@ if(PANDORA) endif() add_dependencies(engine_safemath${MP} ParseEntities${MP}) +if(USE_SYSTEM_VULKAN) set(ENGINE_SRCS ${ENGINE_ENTITIES_CPP} Engine/Engine.cpp @@ -1206,6 +1211,177 @@ set(ENGINE_SRCS ${ADDITIONAL_ENGINE_SRCS} ${ZLIB_SRCS} ) +else() +set(ENGINE_SRCS + ${ENGINE_ENTITIES_CPP} + Engine/Engine.cpp + Engine/Base/Anim.cpp + Engine/Base/CRC.cpp + Engine/Base/CRCTable.cpp + Engine/Base/Changeable.cpp + Engine/Base/Console.cpp + Engine/Base/Directory.cpp + Engine/Base/ErrorReporting.cpp + Engine/Base/FileName.cpp + Engine/Base/Input.cpp + Engine/Base/Lists.cpp + Engine/Base/Memory.cpp + Engine/Base/Profiling.cpp + Engine/Base/ProgressHook.cpp + Engine/Base/Protection.cpp + Engine/Base/Relations.cpp + Engine/Base/ReplaceFile.cpp + Engine/Base/Serial.cpp + Engine/Base/Shell.cpp + Engine/Base/ShellTypes.cpp + Engine/Base/Statistics.cpp + Engine/Base/Stream.cpp + Engine/Base/Timer.cpp + Engine/Base/Translation.cpp + Engine/Base/Unzip.cpp + Engine/Base/Updateable.cpp + Engine/Base/CTString.cpp + Engine/Base/Scanner.cpp + Engine/Base/Parser.cpp + Engine/Base/Parser.h + Engine/Base/IFeel.cpp + Engine/Base/iconvlite.cpp + Engine/Base/Unix/UnixFileSystem.cpp + Engine/Base/Unix/UnixDynamicLoader.cpp + Engine/Base/SDL/SDLTimer.cpp + Engine/Base/SDL/SDLInput.cpp + Engine/Base/SDL/SDLEvents.cpp + ${SYNCHRO_SRCS} + Engine/Brushes/BrushIO.cpp + Engine/Brushes/BrushShadows.cpp + Engine/Brushes/BrushTriangularize.cpp + Engine/Brushes/BrushArchive.cpp + Engine/Brushes/BrushImport.cpp + Engine/Brushes/BrushMip.cpp + Engine/Brushes/BrushExport.cpp + Engine/Entities/NearestPolygon.cpp + Engine/Entities/EntityProperties.cpp + Engine/Entities/FieldBSPTesting.cpp + Engine/Entities/EntityCopying.cpp + Engine/Entities/LastPositions.cpp + Engine/Math/Projection_Isometric.cpp + Engine/Math/Object3D.cpp + Engine/Math/Projection_Parallel.cpp + Engine/Math/Projection_Perspective.cpp + Engine/Math/Float.cpp + Engine/Math/Object3D_CSG.cpp + Engine/Math/Projection_Simple.cpp + Engine/Math/Functions.cpp + Engine/Math/ObjectSector.cpp + Engine/Math/Placement.cpp + Engine/Math/TextureMapping.cpp + Engine/Math/Geometry.cpp + Engine/Math/Projection.cpp + #Engine/Math/Object3D_IO.cpp # Exploration 3D support. + #Engine/Models/EditModel.cpp + Engine/Models/Model.cpp + Engine/Models/RenderModel_View.cpp + Engine/Models/Normals.cpp + Engine/Models/VertexGetting.cpp + Engine/Models/RenderModel.cpp + Engine/Models/MipMaker.cpp + Engine/Models/ModelProfile.cpp + Engine/Models/RenderModel_Mask.cpp + Engine/Light/LayerMaker.cpp + Engine/Light/LayerMixer.cpp + Engine/Light/LightSource.cpp + Engine/Graphics/Adapter.cpp + Engine/Graphics/Raster.cpp + Engine/Graphics/GfxLibrary.cpp + Engine/Graphics/Benchmark.cpp + Engine/Graphics/GfxProfile.cpp + Engine/Graphics/Color.cpp + Engine/Graphics/ShadowMap.cpp + Engine/Graphics/DepthCheck.cpp + Engine/Graphics/Texture.cpp + Engine/Graphics/DisplayMode.cpp + Engine/Graphics/Gfx_OpenGL.cpp + Engine/Graphics/Gfx_OpenGL_Textures.cpp + Engine/Graphics/TextureEffects.cpp + Engine/Graphics/DrawPort.cpp + Engine/Graphics/Gfx_wrapper.cpp + Engine/Graphics/DrawPort_Particles.cpp + Engine/Graphics/Graphics.cpp + Engine/Graphics/ViewPort.cpp + Engine/Graphics/DrawPort_RenderScene.cpp + Engine/Graphics/ImageInfo.cpp + Engine/Graphics/Fog.cpp + Engine/Graphics/MultiMonitor.cpp + Engine/Graphics/Font.cpp + Engine/Graphics/Shader.cpp + Engine/Graphics/Stereo.cpp + Engine/Graphics/SDL/SDLOpenGL.cpp + Engine/Graphics/SDL/SDLAdapter.cpp + Engine/Network/ActionBuffer.cpp + Engine/Network/NetworkMessage.cpp + Engine/Network/Server.cpp + Engine/Network/Buffer.cpp + Engine/Network/NetworkProfile.cpp + Engine/Network/SessionState.cpp + Engine/Network/PlayerBuffer.cpp + Engine/Network/MessageDispatcher.cpp + Engine/Network/PlayerSource.cpp + Engine/Network/Compression.cpp + Engine/Network/Network.cpp + Engine/Network/PlayerTarget.cpp + Engine/Network/CPacket.cpp + Engine/Network/ClientInterface.cpp + Engine/Network/CommunicationInterface.cpp + Engine/Network/Diff.cpp + Engine/GameAgent/GameAgent.cpp + Engine/Terrain/ArrayHolder.cpp + Engine/Terrain/Terrain.cpp + Engine/Terrain/TerrainArchive.cpp + Engine/Terrain/TerrainEditing.cpp + Engine/Terrain/TerrainLayer.cpp + Engine/Terrain/TerrainRender.cpp + Engine/Terrain/TerrainTile.cpp + Engine/Rendering/Render.cpp + Engine/Rendering/RenderProfile.cpp + Engine/Rendering/SelectOnRender.cpp + Engine/Ska/AnimSet.cpp + Engine/Ska/RMRender.cpp + Engine/Ska/Skeleton.cpp + Engine/Ska/ModelInstance.cpp + Engine/Ska/StringTable.cpp + Engine/Ska/Mesh.cpp + Engine/Ska/RMRenderMask.cpp + Engine/Ska/smcPars.cpp + Engine/Ska/smcPars.h + Engine/Ska/smcScan.cpp + Engine/Sound/SoundDecoder.cpp + Engine/Sound/SoundObject.cpp + Engine/Sound/SoundLibrary.cpp + Engine/Sound/SoundProfile.cpp + Engine/Sound/SoundData.cpp + Engine/Sound/Wave.cpp + Engine/Sound/SoundMixer.cpp + Engine/Templates/Stock_CAnimData.cpp + Engine/Templates/Stock_CAnimSet.cpp + Engine/Templates/Stock_CEntityClass.cpp + Engine/Templates/Stock_CMesh.cpp + Engine/Templates/Stock_CModelData.cpp + Engine/Templates/Stock_CSkeleton.cpp + Engine/Templates/Stock_CSoundData.cpp + Engine/Templates/Stock_CTextureData.cpp + Engine/Templates/Stock_CShader.cpp + Engine/Templates/NameTable_CTFileName.cpp + Engine/Templates/NameTable_CTranslationPair.cpp + Engine/Templates/BSP.cpp + Engine/World/PhysicsProfile.cpp + Engine/World/World.cpp + Engine/World/WorldEditingProfile.cpp + Engine/World/WorldIO.cpp + ${ADDITIONAL_ENGINE_SRCS} + ${ZLIB_SRCS} +) +endif() + set(ENGINELIB "Engine${MP}${DEBUGSUFFIX}") add_library(${ENGINELIB} SHARED ${ENGINE_SRCS} @@ -1216,20 +1392,25 @@ endif() add_dependencies(${ENGINELIB} ParseEntities${MP}) target_link_libraries(${ENGINELIB} engine_safemath${MP}) if(FREEBSD) -target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) -target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) -target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) + target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) + target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) + endif() endif() + if(MACOSX) if(USE_SYSTEM_SDL2) # use sdl2 framework on system target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) else() # use local libsdl2 - find_library(COCOA_FRAMEWORK Cocoa) + find_library(COCOA_FRAMEWORK Cocoa) target_link_libraries(${ENGINELIB} "${COCOA_FRAMEWORK}") target_link_libraries(${ENGINELIB} "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") endif() target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) - target_link_libraries(${ENGINELIB} Vulkan::Vulkan) + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} Vulkan::Vulkan) + endif() endif() if(PANDORA) target_link_libraries(${ENGINELIB} "rt") @@ -1239,10 +1420,14 @@ if(RPI4) endif() if(FREEBSD OR MACOSX) -set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") else() -target_link_libraries(${ENGINELIB} vulkan) -set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} vulkan) + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") + else() + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") + endif() endif() add_executable(SeriousSam${MP} diff --git a/SamTFE/Sources/Engine/Graphics/DrawPort.cpp b/SamTFE/Sources/Engine/Graphics/DrawPort.cpp index cc60615c..6acd2ead 100644 --- a/SamTFE/Sources/Engine/Graphics/DrawPort.cpp +++ b/SamTFE/Sources/Engine/Graphics/DrawPort.cpp @@ -565,6 +565,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; +#ifdef SE1_VULKAN // only lines that are aligned with axes if (eAPI == GAT_VK) { @@ -586,6 +587,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, return; } +#endif // SE1_VULKAN ASSERT( GfxValidApi(eAPI) ); @@ -711,7 +713,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; - +#ifdef SE1_VULKAN if ( eAPI == GAT_VK ) { // top @@ -736,6 +738,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL return; } +#endif // SE1_VULKAN ASSERT( GfxValidApi(eAPI) ); @@ -809,12 +812,14 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COLOR col { const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; +#ifdef SE1_VULKAN // draw only using polygons if ( eAPI == GAT_VK ) { Fill(pixI, pixJ, pixWidth, pixHeight, col, col, col, col); return; } +#endif // SE1_VULKAN // if color is tranlucent if( ((col&CT_AMASK)>>CT_ASHIFT) != CT_OPAQUE) diff --git a/SamTFE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/SamTFE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 3eaaa3bd..a17c46c8 100644 --- a/SamTFE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/SamTFE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -1554,9 +1554,14 @@ void RSRenderGroup( ScenePolygon *pspoGroup, ULONG ulGroupFlags, ULONG ulTestedF extern INDEX d3d_iMaxBurstSize; ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, (INDEX)0, (INDEX)9999); d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, (INDEX)0, (INDEX)9999); + +#ifdef SE1_VULKAN const INDEX iMaxBurstSize = (eAPI==GAT_OGL) ? ogl_iMaxBurstSize : (eAPI==GAT_VK) ? 0 : d3d_iMaxBurstSize; +#else + const INDEX iMaxBurstSize = (eAPI == GAT_OGL) ? ogl_iMaxBurstSize : d3d_iMaxBurstSize; +#endif // SE1_VULKAN // if unlimited lock count if( iMaxBurstSize==0) diff --git a/SamTFE/Sources/Engine/Rendering/Render.cpp b/SamTFE/Sources/Engine/Rendering/Render.cpp index 29a80b81..ef518771 100644 --- a/SamTFE/Sources/Engine/Rendering/Render.cpp +++ b/SamTFE/Sources/Engine/Rendering/Render.cpp @@ -732,7 +732,11 @@ void CRenderer::Render(void) if( !re_bRenderingShadows && re_iIndex==0) { // OpenGL allows us to check z-buffer from previous frame - cool deal! // Direct3D is, of course, totally different story. :( +#ifdef SE1_VULKAN if( _pGfx->gl_eCurrentAPI==GAT_OGL || _pGfx->gl_eCurrentAPI == GAT_VK || d3d_bAlternateDepthReads) { +#else + if( _pGfx->gl_eCurrentAPI==GAT_OGL || d3d_bAlternateDepthReads) { +#endif // SE1_VULKAN ChangeStatsMode(CStatForm::STI_FLARESRENDERING); extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel=0); CheckDelayedDepthPoints(re_pdpDrawPort); diff --git a/SamTSE/Sources/CMakeLists.txt b/SamTSE/Sources/CMakeLists.txt index d65b7425..ed040ba5 100644 --- a/SamTSE/Sources/CMakeLists.txt +++ b/SamTSE/Sources/CMakeLists.txt @@ -109,11 +109,15 @@ option(TFE "Compile a The First Encounter version" FALSE) if(INTERNAL_NAME STREQUAL "serioussam") add_definitions(-DFIRST_ENCOUNTER=1) - add_definitions(-DSE1_VULKAN=1) + if(USE_SYSTEM_VULKAN) + add_definitions(-DSE1_VULKAN=1) + endif() set(MP "") message(STATUS "Building Serious Sam Classic The First Encounter") else() - add_definitions(-DSE1_VULKAN=1) + if(USE_SYSTEM_VULKAN) + add_definitions(-DSE1_VULKAN=1) + endif() set(MP "MP") message(STATUS "Building Serious Sam Classic The Second Encounter") endif() @@ -1024,6 +1028,7 @@ if(PANDORA) endif() add_dependencies(engine_safemath${MP} ParseEntities${MP}) +if(USE_SYSTEM_VULKAN) set(ENGINE_SRCS ${ENGINE_ENTITIES_CPP} Engine/Engine.cpp @@ -1206,6 +1211,177 @@ set(ENGINE_SRCS ${ADDITIONAL_ENGINE_SRCS} ${ZLIB_SRCS} ) +else() +set(ENGINE_SRCS + ${ENGINE_ENTITIES_CPP} + Engine/Engine.cpp + Engine/Base/Anim.cpp + Engine/Base/CRC.cpp + Engine/Base/CRCTable.cpp + Engine/Base/Changeable.cpp + Engine/Base/Console.cpp + Engine/Base/Directory.cpp + Engine/Base/ErrorReporting.cpp + Engine/Base/FileName.cpp + Engine/Base/Input.cpp + Engine/Base/Lists.cpp + Engine/Base/Memory.cpp + Engine/Base/Profiling.cpp + Engine/Base/ProgressHook.cpp + Engine/Base/Protection.cpp + Engine/Base/Relations.cpp + Engine/Base/ReplaceFile.cpp + Engine/Base/Serial.cpp + Engine/Base/Shell.cpp + Engine/Base/ShellTypes.cpp + Engine/Base/Statistics.cpp + Engine/Base/Stream.cpp + Engine/Base/Timer.cpp + Engine/Base/Translation.cpp + Engine/Base/Unzip.cpp + Engine/Base/Updateable.cpp + Engine/Base/CTString.cpp + Engine/Base/Scanner.cpp + Engine/Base/Parser.cpp + Engine/Base/Parser.h + Engine/Base/IFeel.cpp + Engine/Base/iconvlite.cpp + Engine/Base/Unix/UnixFileSystem.cpp + Engine/Base/Unix/UnixDynamicLoader.cpp + Engine/Base/SDL/SDLTimer.cpp + Engine/Base/SDL/SDLInput.cpp + Engine/Base/SDL/SDLEvents.cpp + ${SYNCHRO_SRCS} + Engine/Brushes/BrushIO.cpp + Engine/Brushes/BrushShadows.cpp + Engine/Brushes/BrushTriangularize.cpp + Engine/Brushes/BrushArchive.cpp + Engine/Brushes/BrushImport.cpp + Engine/Brushes/BrushMip.cpp + Engine/Brushes/BrushExport.cpp + Engine/Entities/NearestPolygon.cpp + Engine/Entities/EntityProperties.cpp + Engine/Entities/FieldBSPTesting.cpp + Engine/Entities/EntityCopying.cpp + Engine/Entities/LastPositions.cpp + Engine/Math/Projection_Isometric.cpp + Engine/Math/Object3D.cpp + Engine/Math/Projection_Parallel.cpp + Engine/Math/Projection_Perspective.cpp + Engine/Math/Float.cpp + Engine/Math/Object3D_CSG.cpp + Engine/Math/Projection_Simple.cpp + Engine/Math/Functions.cpp + Engine/Math/ObjectSector.cpp + Engine/Math/Placement.cpp + Engine/Math/TextureMapping.cpp + Engine/Math/Geometry.cpp + Engine/Math/Projection.cpp + #Engine/Math/Object3D_IO.cpp # Exploration 3D support. + #Engine/Models/EditModel.cpp + Engine/Models/Model.cpp + Engine/Models/RenderModel_View.cpp + Engine/Models/Normals.cpp + Engine/Models/VertexGetting.cpp + Engine/Models/RenderModel.cpp + Engine/Models/MipMaker.cpp + Engine/Models/ModelProfile.cpp + Engine/Models/RenderModel_Mask.cpp + Engine/Light/LayerMaker.cpp + Engine/Light/LayerMixer.cpp + Engine/Light/LightSource.cpp + Engine/Graphics/Adapter.cpp + Engine/Graphics/Raster.cpp + Engine/Graphics/GfxLibrary.cpp + Engine/Graphics/Benchmark.cpp + Engine/Graphics/GfxProfile.cpp + Engine/Graphics/Color.cpp + Engine/Graphics/ShadowMap.cpp + Engine/Graphics/DepthCheck.cpp + Engine/Graphics/Texture.cpp + Engine/Graphics/DisplayMode.cpp + Engine/Graphics/Gfx_OpenGL.cpp + Engine/Graphics/Gfx_OpenGL_Textures.cpp + Engine/Graphics/TextureEffects.cpp + Engine/Graphics/DrawPort.cpp + Engine/Graphics/Gfx_wrapper.cpp + Engine/Graphics/DrawPort_Particles.cpp + Engine/Graphics/Graphics.cpp + Engine/Graphics/ViewPort.cpp + Engine/Graphics/DrawPort_RenderScene.cpp + Engine/Graphics/ImageInfo.cpp + Engine/Graphics/Fog.cpp + Engine/Graphics/MultiMonitor.cpp + Engine/Graphics/Font.cpp + Engine/Graphics/Shader.cpp + Engine/Graphics/Stereo.cpp + Engine/Graphics/SDL/SDLOpenGL.cpp + Engine/Graphics/SDL/SDLAdapter.cpp + Engine/Network/ActionBuffer.cpp + Engine/Network/NetworkMessage.cpp + Engine/Network/Server.cpp + Engine/Network/Buffer.cpp + Engine/Network/NetworkProfile.cpp + Engine/Network/SessionState.cpp + Engine/Network/PlayerBuffer.cpp + Engine/Network/MessageDispatcher.cpp + Engine/Network/PlayerSource.cpp + Engine/Network/Compression.cpp + Engine/Network/Network.cpp + Engine/Network/PlayerTarget.cpp + Engine/Network/CPacket.cpp + Engine/Network/ClientInterface.cpp + Engine/Network/CommunicationInterface.cpp + Engine/Network/Diff.cpp + Engine/GameAgent/GameAgent.cpp + Engine/Terrain/ArrayHolder.cpp + Engine/Terrain/Terrain.cpp + Engine/Terrain/TerrainArchive.cpp + Engine/Terrain/TerrainEditing.cpp + Engine/Terrain/TerrainLayer.cpp + Engine/Terrain/TerrainRender.cpp + Engine/Terrain/TerrainTile.cpp + Engine/Rendering/Render.cpp + Engine/Rendering/RenderProfile.cpp + Engine/Rendering/SelectOnRender.cpp + Engine/Ska/AnimSet.cpp + Engine/Ska/RMRender.cpp + Engine/Ska/Skeleton.cpp + Engine/Ska/ModelInstance.cpp + Engine/Ska/StringTable.cpp + Engine/Ska/Mesh.cpp + Engine/Ska/RMRenderMask.cpp + Engine/Ska/smcPars.cpp + Engine/Ska/smcPars.h + Engine/Ska/smcScan.cpp + Engine/Sound/SoundDecoder.cpp + Engine/Sound/SoundObject.cpp + Engine/Sound/SoundLibrary.cpp + Engine/Sound/SoundProfile.cpp + Engine/Sound/SoundData.cpp + Engine/Sound/Wave.cpp + Engine/Sound/SoundMixer.cpp + Engine/Templates/Stock_CAnimData.cpp + Engine/Templates/Stock_CAnimSet.cpp + Engine/Templates/Stock_CEntityClass.cpp + Engine/Templates/Stock_CMesh.cpp + Engine/Templates/Stock_CModelData.cpp + Engine/Templates/Stock_CSkeleton.cpp + Engine/Templates/Stock_CSoundData.cpp + Engine/Templates/Stock_CTextureData.cpp + Engine/Templates/Stock_CShader.cpp + Engine/Templates/NameTable_CTFileName.cpp + Engine/Templates/NameTable_CTranslationPair.cpp + Engine/Templates/BSP.cpp + Engine/World/PhysicsProfile.cpp + Engine/World/World.cpp + Engine/World/WorldEditingProfile.cpp + Engine/World/WorldIO.cpp + ${ADDITIONAL_ENGINE_SRCS} + ${ZLIB_SRCS} +) +endif() + set(ENGINELIB "Engine${MP}${DEBUGSUFFIX}") add_library(${ENGINELIB} SHARED ${ENGINE_SRCS} @@ -1216,20 +1392,25 @@ endif() add_dependencies(${ENGINELIB} ParseEntities${MP}) target_link_libraries(${ENGINELIB} engine_safemath${MP}) if(FREEBSD) -target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) -target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) -target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) + target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) + target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) + endif() endif() + if(MACOSX) if(USE_SYSTEM_SDL2) # use sdl2 framework on system target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) else() # use local libsdl2 - find_library(COCOA_FRAMEWORK Cocoa) + find_library(COCOA_FRAMEWORK Cocoa) target_link_libraries(${ENGINELIB} "${COCOA_FRAMEWORK}") target_link_libraries(${ENGINELIB} "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") endif() target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) - target_link_libraries(${ENGINELIB} Vulkan::Vulkan) + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} Vulkan::Vulkan) + endif() endif() if(PANDORA) target_link_libraries(${ENGINELIB} "rt") @@ -1239,10 +1420,14 @@ if(RPI4) endif() if(FREEBSD OR MACOSX) -set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") else() -target_link_libraries(${ENGINELIB} vulkan) -set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") + if(USE_SYSTEM_VULKAN) + target_link_libraries(${ENGINELIB} vulkan) + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") + else() + set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") + endif() endif() add_executable(SeriousSam${MP} diff --git a/SamTSE/Sources/Engine/Graphics/DrawPort.cpp b/SamTSE/Sources/Engine/Graphics/DrawPort.cpp index cc60615c..6acd2ead 100644 --- a/SamTSE/Sources/Engine/Graphics/DrawPort.cpp +++ b/SamTSE/Sources/Engine/Graphics/DrawPort.cpp @@ -565,6 +565,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; +#ifdef SE1_VULKAN // only lines that are aligned with axes if (eAPI == GAT_VK) { @@ -586,6 +587,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, return; } +#endif // SE1_VULKAN ASSERT( GfxValidApi(eAPI) ); @@ -711,7 +713,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; - +#ifdef SE1_VULKAN if ( eAPI == GAT_VK ) { // top @@ -736,6 +738,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL return; } +#endif // SE1_VULKAN ASSERT( GfxValidApi(eAPI) ); @@ -809,12 +812,14 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COLOR col { const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; +#ifdef SE1_VULKAN // draw only using polygons if ( eAPI == GAT_VK ) { Fill(pixI, pixJ, pixWidth, pixHeight, col, col, col, col); return; } +#endif // SE1_VULKAN // if color is tranlucent if( ((col&CT_AMASK)>>CT_ASHIFT) != CT_OPAQUE) diff --git a/SamTSE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/SamTSE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 3eaaa3bd..a17c46c8 100644 --- a/SamTSE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/SamTSE/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -1554,9 +1554,14 @@ void RSRenderGroup( ScenePolygon *pspoGroup, ULONG ulGroupFlags, ULONG ulTestedF extern INDEX d3d_iMaxBurstSize; ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, (INDEX)0, (INDEX)9999); d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, (INDEX)0, (INDEX)9999); + +#ifdef SE1_VULKAN const INDEX iMaxBurstSize = (eAPI==GAT_OGL) ? ogl_iMaxBurstSize : (eAPI==GAT_VK) ? 0 : d3d_iMaxBurstSize; +#else + const INDEX iMaxBurstSize = (eAPI == GAT_OGL) ? ogl_iMaxBurstSize : d3d_iMaxBurstSize; +#endif // SE1_VULKAN // if unlimited lock count if( iMaxBurstSize==0) diff --git a/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp b/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp index acdaa66a..c175a51d 100644 --- a/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp +++ b/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp @@ -998,7 +998,7 @@ void SvkMain::AcquireNextImage() VkResult r; uint32_t nextImageIndex; - if (gl_VkSwapchain == 0x00) { // NULL + if (gl_VkSwapchain == 0x00) { // NULL CPrintF("Vulkan warrning: VkSwapchain == NULL...\n"); } diff --git a/SamTSE/Sources/Engine/Rendering/Render.cpp b/SamTSE/Sources/Engine/Rendering/Render.cpp index 29a80b81..ef518771 100644 --- a/SamTSE/Sources/Engine/Rendering/Render.cpp +++ b/SamTSE/Sources/Engine/Rendering/Render.cpp @@ -732,7 +732,11 @@ void CRenderer::Render(void) if( !re_bRenderingShadows && re_iIndex==0) { // OpenGL allows us to check z-buffer from previous frame - cool deal! // Direct3D is, of course, totally different story. :( +#ifdef SE1_VULKAN if( _pGfx->gl_eCurrentAPI==GAT_OGL || _pGfx->gl_eCurrentAPI == GAT_VK || d3d_bAlternateDepthReads) { +#else + if( _pGfx->gl_eCurrentAPI==GAT_OGL || d3d_bAlternateDepthReads) { +#endif // SE1_VULKAN ChangeStatsMode(CStatForm::STI_FLARESRENDERING); extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel=0); CheckDelayedDepthPoints(re_pdpDrawPort);