From 5dbbfed654ab77747cb6875cd5b8925d2307b96b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 20 Oct 2021 15:34:52 +0200 Subject: [PATCH] PS5 support progress --- Source/Engine/Graphics/Enums.h | 3 +++ Source/Engine/Graphics/Graphics.Build.cs | 4 ++-- Source/Engine/Platform/ConditionVariable.h | 14 ++--------- Source/Engine/Platform/Window.h | 2 ++ .../PhysX/foundation/PxPreprocessor.h | 3 +++ Source/ThirdParty/enet/enet.h | 2 +- .../Bindings/BindingsGenerator.Cpp.cs | 2 +- .../Flax.Build/Deps/Dependencies/PhysX.cs | 18 ++++++++++++-- .../Flax.Build/Deps/Dependencies/freetype.cs | 16 +++++++++++++ .../Tools/Flax.Build/Deps/Dependencies/ogg.cs | 16 +++++++++++++ .../Flax.Build/Deps/Dependencies/vorbis.cs | 24 +++++++++++++++++++ .../Platforms/Unix/UnixToolchain.cs | 4 ++++ 12 files changed, 90 insertions(+), 18 deletions(-) diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 0bd22067c..44f644d42 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -431,6 +431,9 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(BlendingMode); /// API_ENUM() enum class ColorWrite { + // No color writing. + None = 0, + // Allow data to be stored in the red component. Red = 1, // Allow data to be stored in the green component. diff --git a/Source/Engine/Graphics/Graphics.Build.cs b/Source/Engine/Graphics/Graphics.Build.cs index bcc1d2c98..c64dd5478 100644 --- a/Source/Engine/Graphics/Graphics.Build.cs +++ b/Source/Engine/Graphics/Graphics.Build.cs @@ -58,8 +58,8 @@ public class Graphics : EngineModule case TargetPlatform.UWP: options.PrivateDependencies.Add("GraphicsDeviceDX11"); break; - case TargetPlatform.XboxOne: - case TargetPlatform.XboxScarlett: + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: options.PrivateDependencies.Add("GraphicsDeviceDX12"); break; case TargetPlatform.Linux: diff --git a/Source/Engine/Platform/ConditionVariable.h b/Source/Engine/Platform/ConditionVariable.h index 90cf375e6..3d9989b18 100644 --- a/Source/Engine/Platform/ConditionVariable.h +++ b/Source/Engine/Platform/ConditionVariable.h @@ -2,19 +2,9 @@ #pragma once -#if PLATFORM_WINDOWS +#if PLATFORM_WINDOWS || PLATFORM_UWP || PLATFORM_XBOX_ONE || PLATFORM_XBOX_SCARLETT #include "Win32/Win32ConditionVariable.h" -#elif PLATFORM_UWP -#include "Win32/Win32ConditionVariable.h" -#elif PLATFORM_LINUX -#include "Unix/UnixConditionVariable.h" -#elif PLATFORM_PS4 -#include "Unix/UnixConditionVariable.h" -#elif PLATFORM_XBOX_ONE -#include "Win32/Win32ConditionVariable.h" -#elif PLATFORM_XBOX_SCARLETT -#include "Win32/Win32ConditionVariable.h" -#elif PLATFORM_ANDROID +#elif PLATFORM_LINUX || PLATFORM_ANDROID || PLATFORM_PS4 || PLATFORM_PS5 #include "Unix/UnixConditionVariable.h" #elif PLATFORM_SWITCH #include "Platforms/Switch/Engine/Platform/SwitchConditionVariable.h" diff --git a/Source/Engine/Platform/Window.h b/Source/Engine/Platform/Window.h index 0a68ea9c7..ea2bb6e8e 100644 --- a/Source/Engine/Platform/Window.h +++ b/Source/Engine/Platform/Window.h @@ -18,6 +18,8 @@ #include "Android/AndroidWindow.h" #elif PLATFORM_SWITCH #include "Platforms/Switch/Engine/Platform/SwitchWindow.h" +#elif PLATFORM_PS5 +#include "Platforms/PS5/Engine/Platform/PS5Window.h" #else #error Missing Window implementation! #endif diff --git a/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h b/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h index bdd6cc7ba..3b7a8f37e 100644 --- a/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h +++ b/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h @@ -102,6 +102,9 @@ Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSyst #define PX_IOS 1 #elif defined(__APPLE__) #define PX_OSX 1 +#elif defined(__PROSPERO__) +#define PX_PS4 1 +#define PX_PS5 1 #elif defined(__ORBIS__) #define PX_PS4 1 #elif defined(__NX__) diff --git a/Source/ThirdParty/enet/enet.h b/Source/ThirdParty/enet/enet.h index 73aa72cf0..2357e8488 100644 --- a/Source/ThirdParty/enet/enet.h +++ b/Source/ThirdParty/enet/enet.h @@ -140,7 +140,7 @@ #else #include #include - #if PLATFORM_PS4 + #if PLATFORM_PS4 || PLATFORM_PS5 #define ENET_IPV6 0 #include in_addr in4addr_any = { 0 }; diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 29415bb45..0e1e2a818 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -1291,7 +1291,7 @@ namespace Flax.Build.Bindings var baseType = classInfo?.BaseType ?? structureInfo?.BaseType; if (classInfo != null && classInfo.IsBaseTypeHidden) baseType = null; - if (baseType != null && (baseType.Name == "PersistentScriptingObject" || baseType.Name == "ScriptingObject")) + if (baseType != null && (baseType.Name == "PersistentScriptingObject" || baseType.Name == "ScriptingObject" || baseType.Name == "ManagedScriptingObject")) baseType = null; CppAutoSerializeFields.Clear(); CppAutoSerializeProperties.Clear(); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index 4267141fd..f3aa8ac9e 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -31,6 +31,7 @@ namespace Flax.Deps.Dependencies TargetPlatform.UWP, TargetPlatform.XboxOne, TargetPlatform.PS4, + TargetPlatform.PS5, TargetPlatform.XboxScarlett, TargetPlatform.Android, TargetPlatform.Switch, @@ -152,6 +153,12 @@ namespace Flax.Deps.Dependencies suppressBitsPostfix = true; binariesPrefix = "lib"; break; + case TargetPlatform.PS5: + binariesSubDir = "ps5"; + buildPlatform = "PROSPERO"; + suppressBitsPostfix = true; + binariesPrefix = "lib"; + break; case TargetPlatform.XboxOne: case TargetPlatform.XboxScarlett: binariesSubDir = "win.x86_64.vc142.md"; @@ -209,8 +216,9 @@ namespace Flax.Deps.Dependencies switch (targetPlatform) { case TargetPlatform.PS4: + case TargetPlatform.PS5: // Hack: PS4 uses .o extension for compiler output files but CMake uses .obj even if CMAKE_CXX_OUTPUT_EXTENSION/CMAKE_C_OUTPUT_EXTENSION are specified - Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\ps4"), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o"); + Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\" + binariesSubDir), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o"); break; case TargetPlatform.XboxOne: case TargetPlatform.XboxScarlett: @@ -320,7 +328,7 @@ namespace Flax.Deps.Dependencies } // Get the source - CloneGitRepoSingleBranch(root, "https://github.com/NVIDIAGameWorks/PhysX.git", "4.1"); + CloneGitRepoSingleBranch(root, "https://github.com/FlaxEngine/PhysX.git", "flax-master"); foreach (var platform in options.Platforms) { @@ -347,6 +355,12 @@ namespace Flax.Deps.Dependencies Build(options, "ps4", platform, TargetArchitecture.x64); break; } + case TargetPlatform.PS5: + { + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); + Build(options, "ps5", platform, TargetArchitecture.x64); + break; + } case TargetPlatform.XboxScarlett: { Build(options, "vc16win64", platform, TargetArchitecture.x64); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs index 03ec4f711..b198dbf29 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs @@ -29,6 +29,7 @@ namespace Flax.Deps.Dependencies TargetPlatform.UWP, TargetPlatform.XboxOne, TargetPlatform.PS4, + TargetPlatform.PS5, TargetPlatform.XboxScarlett, TargetPlatform.Android, TargetPlatform.Switch, @@ -163,6 +164,21 @@ namespace Flax.Deps.Dependencies break; } + case TargetPlatform.PS5: + { + // Get the build data files + Utilities.DirectoryCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"), + Path.Combine(root, "builds", "PS5"), false, true); + + // Build for PS5 + var solutionPath = Path.Combine(root, "builds", "PS5", "freetype.sln"); + Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO"); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + Utilities.FileCopy(Path.Combine(root, "lib", "PS5", libraryFileName), Path.Combine(depsFolder, libraryFileName)); + + break; + } case TargetPlatform.XboxOne: { // Fix the MSVC project settings for Xbox One diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs b/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs index d0e81ae57..6056cad48 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs @@ -28,6 +28,7 @@ namespace Flax.Deps.Dependencies TargetPlatform.UWP, TargetPlatform.XboxOne, TargetPlatform.PS4, + TargetPlatform.PS5, TargetPlatform.XboxScarlett, TargetPlatform.Android, TargetPlatform.Switch, @@ -143,6 +144,21 @@ namespace Flax.Deps.Dependencies break; } + case TargetPlatform.PS5: + { + // Get the build data files + Utilities.DirectoryCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg"), + Path.Combine(root, "PS5"), true, true); + + // Build for PS5 + var solutionPath = Path.Combine(root, "PS5", "libogg_static.sln"); + Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO"); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + Utilities.FileCopy(Path.Combine(root, "PS5", "lib", libraryFileName), Path.Combine(depsFolder, libraryFileName)); + + break; + } case TargetPlatform.XboxOne: { // Fix the MSVC project settings for Xbox Scarlett diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index 7d49a8d8e..510feacb9 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -29,6 +29,7 @@ namespace Flax.Deps.Dependencies TargetPlatform.UWP, TargetPlatform.XboxOne, TargetPlatform.PS4, + TargetPlatform.PS5, TargetPlatform.XboxScarlett, TargetPlatform.Android, TargetPlatform.Switch, @@ -186,6 +187,24 @@ namespace Flax.Deps.Dependencies Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"), Path.Combine(root, "libogg", "include", "ogg", "config_types.h")); break; + case TargetPlatform.PS5: + buildDir = Path.Combine(rootMsvcLib, "PS5"); + binariesToCopy = new[] + { + new Binary("libvorbis.a", "libvorbis"), + }; + vcxprojPaths = new[] + { + Path.Combine(buildDir, "libvorbis", "libvorbis_static.vcxproj"), + }; + buildPlatform = "PROSPERO"; + Utilities.DirectoryCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "vorbis"), + buildDir, true, true); + Utilities.FileCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"), + Path.Combine(root, "libogg", "include", "ogg", "config_types.h")); + break; case TargetPlatform.XboxOne: buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010"); binariesToCopy = binariesToCopyWindows; @@ -279,6 +298,11 @@ namespace Flax.Deps.Dependencies BuildMsbuild(options, TargetPlatform.PS4, TargetArchitecture.x64); break; } + case TargetPlatform.PS5: + { + BuildMsbuild(options, TargetPlatform.PS5, TargetArchitecture.x64); + break; + } case TargetPlatform.XboxScarlett: { BuildMsbuild(options, TargetPlatform.XboxScarlett, TargetArchitecture.x64); diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs index 758e2dfb1..2ea075e1d 100644 --- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs @@ -96,8 +96,12 @@ namespace Flax.Build.Platforms var exeExtension = Platform.BuildPlatform.ExecutableFileExtension; ToolsetRoot = toolchainSubDir == null ? Path.Combine(toolchainRoots, ArchitectureName) : Path.Combine(toolchainRoots, toolchainSubDir); ClangPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "clang++"))) + exeExtension; + if (!File.Exists(ClangPath)) + ClangPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "clang"))) + exeExtension; if (!File.Exists(ClangPath)) ClangPath = Path.Combine(ToolsetRoot, "bin/clang++") + exeExtension; + if (!File.Exists(ClangPath)) + ClangPath = Path.Combine(ToolsetRoot, "bin/clang") + exeExtension; ArPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "ar"))) + exeExtension; LlvmArPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}", "llvm-ar"))) + exeExtension; RanlibPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "ranlib"))) + exeExtension;