Skip to content

Commit

Permalink
Merge pull request #68 from Silverlan/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan authored Jun 11, 2024
2 parents 92f796a + 592fb71 commit 5fa08b2
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pragma-linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
uses: ./pragma/github_actions/build
id: build-pragma
with:
build-args: "--with-pfm --with-all-pfm-modules --with-vr --with-networking --with-lua-debugger=0"
build-args: "--with-pfm --with-all-pfm-modules --with-vr --with-networking --with-lua-debugger=0 --with-swiftshader"

- name: Create Release Archive
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pragma-windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
uses: ./pragma/github_actions/build
id: build-pragma
with:
build-args: "--with-pfm --with-all-pfm-modules --with-vr --with-networking --with-lua-debugger=0 --cmake-arg=\"-DCMAKE_SYSTEM_VERSION=10.0.22621.0\" --vcvars \"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat\""
build-args: "--with-pfm --with-all-pfm-modules --with-vr --with-networking --with-lua-debugger=0 --with-swiftshader --cmake-arg=\"-DCMAKE_SYSTEM_VERSION=10.0.22621.0\" --vcvars \"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat\""

- name: Create Release Archive
shell: bash
Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ add_dependencies(pragma_updater sharedutils-static)

add_dependencies(pragma_server server)
add_dependencies(pragma client server)
add_dependencies(pragma pragma_server)
add_dependencies(pragma pragma_updater)

set_property(TARGET pragma PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
Expand Down Expand Up @@ -1167,6 +1166,9 @@ endfunction(pragma_install)

pragma_install(pragma ".")
pragma_install(pragma_server ".")
if(WIN32)
pragma_install(pragma_console ".")
endif()
pragma_install(alsoundsystem "${BINARY_OUTPUT_DIR}")

pragma_install(client "${BINARY_OUTPUT_DIR}")
Expand Down Expand Up @@ -1194,8 +1196,12 @@ pragma_install(wgui "${BINARY_OUTPUT_DIR}")
pragma_install(util_unicode "${BINARY_OUTPUT_DIR}")

message("Custom install targets: ${PRAGMA_INSTALL_CUSTOM_TARGETS}")
set(PRAGMA_INSTALL_DEPENDENCIES pragma pragma_server iclient iserver udm_convert ${PRAGMA_INSTALL_CUSTOM_TARGETS})
if(WIN32)
list(APPEND PRAGMA_INSTALL_DEPENDENCIES pragma_console)
endif()
add_custom_target(pragma-install
DEPENDS pragma iclient iserver udm_convert ${PRAGMA_INSTALL_CUSTOM_TARGETS}
DEPENDS ${PRAGMA_DEPENDENCIES}
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${PRAGMA_INSTALL_COMPONENT}
-DBUILD_TYPE=${CONFIG_BUILD_TYPE}
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Windows](https://github.com/Silverlan/pragma/actions/workflows/pragma-windows-ci.yml/badge.svg?branch=main)](https://github.com/Silverlan/pragma/actions/workflows/pragma-windows-ci.yml) [![Build Linux](https://github.com/Silverlan/pragma/actions/workflows/pragma-linux-ci.yml/badge.svg?branch=main)](https://github.com/Silverlan/pragma/actions/workflows/pragma-linux-ci.yml)
[![Build Windows](https://github.com/Silverlan/pragma/actions/workflows/pragma-windows-ci.yml/badge.svg?branch=main)](https://github.com/Silverlan/pragma/actions/workflows/pragma-windows-ci.yml) [![Build Linux](https://github.com/Silverlan/pragma/actions/workflows/pragma-linux-ci.yml/badge.svg?branch=main)](https://github.com/Silverlan/pragma/actions/workflows/pragma-linux-ci.yml) [![License](https://img.shields.io/github/license/Silverlan/pragma)](#license) [![CodeFactor](https://img.shields.io/codefactor/grade/github/Silverlan/pragma)](https://www.codefactor.io/repository/github/Silverlan/pragma)

<img align="right" width="150" height="150" alt="Pragma Logo" title="Pragma Logo" src="https://wiki.pragma-engine.com/uploads/images/gallery/2022-09/scaled-1680-/pragma-logo-256.png">

Expand Down Expand Up @@ -98,7 +98,7 @@ Running the build-script with the arguments above will build and install Pragma
| Parameter | Description | Default |
| --------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------- |
| `--help` | Display this help | |
| `--generator <generator>` | The generator to use. | Windows: `Visual Studio 17 2022`<br/>Linux: `Unix Makefiles` |
| `--generator <generator>` | The generator to use. | Windows: `Visual Studio 17 2022`<br/>Linux: `Ninja Multi-Config` |
| `--c-compiler` | [Linux only] The C-compiler to use. | `clang-18` |
| `--cxx-compiler` | [Linux only] The C++-compiler to use. | `clang++-18` |
| `--no-sudo` | [Linux only] Will not run sudo commands. System packages will have to be installed manually. | `0` |
Expand All @@ -111,6 +111,8 @@ Running the build-script with the arguments above will build and install Pragma
| `--with-vr <1/0>` | Include Virtual Reality support. | `0` |
| `--with-networking <1/0>` | Include networking module(s) for multiplayer support. | `0` |
| `--with-lua-debugger <1/0>` | Include Lua-debugger support. | `0` |
| `--with-swiftshader <1/0>` | Include SwiftShader support for CPU-only rendering. | `0` |
| `--build-swiftshader <1/0>` | Builds SwiftShader from source instead of downloading prebuilt binaries. | `0` |
| `--build-cycles <1/0>` | Build the Cycles library (otherwise uses pre-built binaries). Requires --with-all-pfm-modules| `0` |
| `--build <1/0>` | Build Pragma after configurating and generating build files. | `1` |
| `--build-all <1/0>` | Build all dependencies instead of downloading prebuilt binaries where available. | `0` |
Expand Down
48 changes: 40 additions & 8 deletions build_scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
else:
defaultGenerator = "Visual Studio 17 2022"
parser.add_argument('--generator', help='The generator to use.', default=defaultGenerator)
if platform == "win32":
parser.add_argument('--vcvars', help='Path to vcvars64.bat.', default="\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\"")
parser.add_argument("--with-essential-client-modules", type=str2bool, nargs='?', const=True, default=True, help="Include essential modules required to run Pragma.")
parser.add_argument("--with-common-modules", type=str2bool, nargs='?', const=True, default=True, help="Include non-essential but commonly used modules (e.g. audio and physics modules).")
parser.add_argument("--with-pfm", type=str2bool, nargs='?', const=True, default=False, help="Include the Pragma Filmmaker.")
Expand All @@ -30,9 +28,11 @@
parser.add_argument("--with-networking", type=str2bool, nargs='?', const=True, default=False, help="Include networking module(s) for multiplayer support.")
parser.add_argument("--with-common-entities", type=str2bool, nargs='?', const=True, default=True, help="Include addons with support for common entity types.")
parser.add_argument("--with-lua-debugger", type=str2bool, nargs='?', const=True, default=False, help="Include Lua-debugger support.")
parser.add_argument("--with-swiftshader", type=str2bool, nargs='?', const=True, default=False, help="Include SwiftShader support for CPU-only rendering.")
parser.add_argument('--vtune-include-path', help='The include path to the VTune profiler (required for CPU profiling).', default='')
parser.add_argument('--vtune-library-path', help='The path to the "libittnotify" library of the VTune profiler (required for CPU profiling).', default='')
parser.add_argument("--build", type=str2bool, nargs='?', const=True, default=True, help="Build Pragma after configurating and generating build files.")
parser.add_argument("--build-swiftshader", type=str2bool, nargs='?', const=True, default=False, help="Builds SwiftShader from source instead of downloading prebuilt binaries.")
parser.add_argument("--build-all", type=str2bool, nargs='?', const=True, default=False, help="Build all dependencies instead of downloading prebuilt binaries where available. Enabling this may significantly increase the disk space requirement and build time.")
parser.add_argument('--build-config', help='The build configuration to use.', default='RelWithDebInfo')
parser.add_argument('--build-directory', help='Directory to write the build files to. Can be relative or absolute.', default='build')
Expand Down Expand Up @@ -87,8 +87,6 @@
no_sudo = args["no_sudo"]
no_confirm = args["no_confirm"]
generator = args["generator"]
#if platform == "win32":
# vcvars = args["vcvars
with_essential_client_modules = args["with_essential_client_modules"]
with_common_modules = args["with_common_modules"]
with_pfm = args["with_pfm"]
Expand All @@ -98,6 +96,8 @@
with_networking = args["with_networking"]
with_common_entities = args["with_common_entities"]
with_lua_debugger = args["with_lua_debugger"]
with_swiftshader = args["with_swiftshader"]
build_swiftshader = args["build_swiftshader"]
vtune_include_path = args["vtune_include_path"]
vtune_library_path = args["vtune_library_path"]
build = args["build"]
Expand All @@ -122,15 +122,15 @@
print("c_compiler: " +c_compiler)

print("generator: " +generator)
#if platform == "win32":
# print("vcvars: " +vcvars)
print("with_essential_client_modules: " +str(with_essential_client_modules))
print("with_common_modules: " +str(with_common_modules))
print("with_pfm: " +str(with_pfm))
print("with_core_pfm_modules: " +str(with_core_pfm_modules))
print("with_all_pfm_modules: " +str(with_all_pfm_modules))
print("with_vr: " +str(with_vr))
print("with_lua_debugger: " +str(with_lua_debugger))
print("with_swiftshader: " +str(with_swiftshader))
print("build_swiftshader: " +str(build_swiftshader))
print("rerun: " +str(rerun))
print("update: " +str(update))
print("build: " +str(build))
Expand Down Expand Up @@ -493,6 +493,40 @@ def execscript(filepath):
os.chdir("../../")
os.chdir("../../")

########## SwiftShader ##########
if with_swiftshader:
os.chdir(deps_dir)
swiftshader_root = normalize_path(os.getcwd() +"/swiftshader")
swiftshader_modules_dir = install_dir +"/modules/swiftshader/"

swiftshader_bin_dir = swiftshader_root +"/build/bin/"
if build_swiftshader:
if not Path(swiftshader_root).is_dir():
print_msg("SwiftShader not found. Downloading...")
git_clone("https://github.com/Silverlan/swiftshader.git")
os.chdir("swiftshader")
reset_to_commit("8f431ea")

print_msg("Building SwiftShader...")
os.chdir("build")
cmake_configure("..",generator)
cmake_build("Release")
else:
if not Path(swiftshader_root).is_dir():
mkpath(swiftshader_bin_dir)
os.chdir(swiftshader_bin_dir)
print_msg("Downloading prebuilt SwiftShader...")
if platform == "win32":
http_extract("https://github.com/Silverlan/swiftshader/releases/download/latest/swiftshader.zip")
else:
http_extract("https://github.com/Silverlan/swiftshader/releases/download/latest/swiftshader.tar.gz",format="tar.gz")
print_msg("Installing SwiftShader...")
mkpath(swiftshader_modules_dir)
if platform == "win32":
cp(swiftshader_bin_dir +"/vulkan-1.dll",swiftshader_modules_dir)
else:
cp(swiftshader_bin_dir +"/libvulkan.so.1",swiftshader_modules_dir)

########## vcpkg ##########
os.chdir(deps_dir)
if platform == "win32":
Expand Down Expand Up @@ -703,8 +737,6 @@ def execbuildscript(filepath):
l["install_system_packages"] = install_system_packages
# l["harfbuzz_include_dir"] = harfbuzz_include_dir
# l["harfbuzz_lib"] = harfbuzz_lib
#else:
# l["vcvars"] = "vcvars"

if platform == "win32":
l["determine_vs_installation_path"] = determine_vs_installation_path
Expand Down
3 changes: 3 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ set_target_properties(client PROPERTIES FOLDER core)
set_target_properties(pragma PROPERTIES FOLDER core)
set_target_properties(pragma_server PROPERTIES FOLDER core)
set_target_properties(wms_shared PROPERTIES FOLDER core)
if(WIN32)
set_target_properties(pragma_console PROPERTIES FOLDER core)
endif()

set(CMAKE_CXX_STANDARD 20)
11 changes: 10 additions & 1 deletion core/client/src/c_launchparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ std::optional<uint32_t> g_launchParamHeight {};
std::optional<Color> g_titleBarColor {};
std::optional<Color> g_borderColor {};
bool g_launchParamExperimentalMemoryOptimizationEnabled = false;
bool g_cpuRendering = false;
bool g_windowless = false;
static void LPARAM_windowed(const std::vector<std::string> &argv) { g_launchParamWindowedMode = true; }

Expand Down Expand Up @@ -111,7 +112,14 @@ static void LPARAM_border_bar_color(const std::vector<std::string> &argv)
g_borderColor = Color::CreateFromHexColor(strHex);
}

static void LPARAM_EXPERIMENTAL_MEMORY_OPTIMIZATION(const std::vector<std::string> &argv) {g_launchParamExperimentalMemoryOptimizationEnabled = (argv.empty() || util::to_boolean(argv.front())); }
static void LPARAM_EXPERIMENTAL_MEMORY_OPTIMIZATION(const std::vector<std::string> &argv) { g_launchParamExperimentalMemoryOptimizationEnabled = (argv.empty() || util::to_boolean(argv.front())); }

static void LPARAM_cpu_rendering(const std::vector<std::string> &argv)
{
g_cpuRendering = (argv.empty() || util::to_boolean(argv.front()));
// Without optimizations enabled, loading with CPU rendering will take a very long time
g_launchParamExperimentalMemoryOptimizationEnabled = true;
}

REGISTER_LAUNCH_PARAMETER_HELP(-windowed, LPARAM_windowed, "-window -startwindowed -sw", "start in windowed mode");
REGISTER_LAUNCH_PARAMETER(-window, LPARAM_windowed);
Expand All @@ -138,3 +146,4 @@ REGISTER_LAUNCH_PARAMETER_HELP(-windowless, LPARAM_windowless, "<1/0>", "If enab
REGISTER_LAUNCH_PARAMETER_HELP(-title_bar_color, LPARAM_title_bar_color, "<hexColor>", "Hex color for the window title bar.");
REGISTER_LAUNCH_PARAMETER_HELP(-border_color, LPARAM_border_bar_color, "<hexColor>", "Hex color for the window border.");
REGISTER_LAUNCH_PARAMETER_HELP(-experimental_memory_optimization, LPARAM_EXPERIMENTAL_MEMORY_OPTIMIZATION, "<1/0>", "Enables experimental code for RAM usage reduction.");
REGISTER_LAUNCH_PARAMETER_HELP(-cpu_rendering, LPARAM_cpu_rendering, "<1/0>", "If enabled, the CPU will be used for rendering instead of GPU.");
20 changes: 19 additions & 1 deletion core/client/src/rendering/c_render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static spdlog::logger &LOGGER_VALIDATION = pragma::register_logger("prosper_vali
RenderContext::RenderContext() : m_monitor(nullptr), m_renderAPI {"vulkan"} {}
RenderContext::~RenderContext() { m_graphicsAPILib = nullptr; }
DLLNETWORK std::optional<std::string> g_customTitle;
extern bool g_cpuRendering;
void RenderContext::InitializeRenderAPI()
{
auto &renderAPI = GetRenderAPI();
Expand All @@ -38,7 +39,24 @@ void RenderContext::InitializeRenderAPI()
std::string location;
std::string modulePath;
getRenderApiPath(renderAPI, location, modulePath);
m_graphicsAPILib = util::load_library_module(modulePath, util::get_default_additional_library_search_directories(modulePath), {}, &outErr);

auto additionalSearchDirectories = util::get_default_additional_library_search_directories(modulePath);
if(g_cpuRendering) {
if(renderAPI == "vulkan") {
if(filemanager::exists("modules/swiftshader/")) {
auto p = util::Path::CreatePath(util::get_program_path());
p += "modules/swiftshader/";
additionalSearchDirectories.push_back(p.GetString());

spdlog::info("-cpu_rendering option has been specified. SwiftShader will be used for rendering instead of Vulkan driver.");
}
else
spdlog::error("-cpu_rendering option requires SwiftShader module, which is not installed! Ignoring option...");
}
else
spdlog::error("-cpu_rendering option is only supported for Vulkan render API! Ignoring option...");
}
m_graphicsAPILib = util::load_library_module(modulePath, additionalSearchDirectories, {}, &outErr);
return (m_graphicsAPILib != nullptr);
};
std::string err;
Expand Down
10 changes: 10 additions & 0 deletions core/pragma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ else()
set_target_properties(pragma PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "-console -luaext")
endif()

if(WIN32)
def_project(pragma_console exe ${APP_ICON_RESOURCE_WINDOWS})

set_target_properties(pragma_console PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "-console -luaext")

# This is required so that the executable can be launched from within a Windows terminal
set_target_properties(pragma_console PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")

set_target_properties(pragma_console PROPERTIES OUTPUT_NAME "pragma" SUFFIX ".com")
target_sources(pragma_console PRIVATE ${APP_ICON_RESOURCE_WINDOWS})
endif()
17 changes: 0 additions & 17 deletions core/pragma/include/pragma/pragma_executable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@ namespace pragma {
const char *runEngineSymbol = server ? "RunEngine" : "RunCEngine";

#ifdef _WIN32
if(!server) {
// Check if Vulkan drivers are installed
auto bt = IDTRYAGAIN;
while(bt == IDTRYAGAIN) {
auto hVulkan = LoadLibrary("vulkan-1.dll");
if(hVulkan != NULL)
break;
std::stringstream msg;
msg << "Vulkan drivers not found! Please make sure your GPU drivers are up to date, and that your graphics vendor supports Vulkan for your GPU model.";
msg << " You may have to explicitly enable the Vulkan RT during driver installation.";
bt = MessageBox(nullptr, msg.str().c_str(), "Critical Error", MB_CANCELTRYCONTINUE | MB_ICONERROR);
if(bt == IDCANCEL)
return MODULE_NULL;
else if(bt == IDCONTINUE)
break;
}
}
#if ENABLE_GDEBUGGER_SUPPORT == 1
HINSTANCE hEngine = LoadLibrary(library);
#else
Expand Down
1 change: 1 addition & 0 deletions core/pragma/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ try {
"materials/logo/pragma_window_icon.png",
"-title_bar_color",
"#262626",
"-console",
};
auto cargs = pragma::merge_arguments(argc, argv, extraArgs);
auto hModule = pragma::launch_pragma(cargs.size(), cargs.data());
Expand Down
3 changes: 3 additions & 0 deletions core/pragma_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ if(UNIX)
target_link_libraries(pragma_server "pthread")
else()
set_target_properties(pragma_server PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "-console -luaext")

# This is required so that the executable can be launched from within a Windows terminal
set_target_properties(pragma_server PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
endif()
8 changes: 7 additions & 1 deletion core/shared/include/pragma/util/rig_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace pragma::ik {
SwivelHingeJoint,
TwistJoint,
AngularJoint,
DistanceJoint,

Count,
};
Expand All @@ -89,7 +90,11 @@ namespace pragma::ik {
std::optional<Vector3> axisB {};
std::optional<umath::Degree> maxAngle {};
float rigidity = 1.f;
std::optional<Vector3> anchorPosition {};
union {
std::optional<Vector3> anchorPosition {};
std::optional<Vector3> anchorPositionA;
};
std::optional<Vector3> anchorPositionB {};
std::optional<Vector3> measurementAxisA {};
};

Expand Down Expand Up @@ -130,6 +135,7 @@ namespace pragma::ik {
PRigConfigJoint AddTwistLimit(const pragma::GString &bone0, const pragma::GString &bone1, const Vector3 &axisA, const Vector3 &axisB, umath::Degree maxAngle, float rigidity = 1.f, const std::optional<Vector3> &measurementAxisA = {});
PRigConfigJoint AddSwivelHingeJoint(const pragma::GString &bone0, const pragma::GString &bone1, const Vector3 &axisA, const Vector3 &axisB, float rigidity = 1.f);
PRigConfigJoint AddTwistJoint(const pragma::GString &bone0, const pragma::GString &bone1, const Vector3 &axisA, const Vector3 &axisB, float rigidity);
PRigConfigJoint AddDistanceJoint(const pragma::GString &bone0, const pragma::GString &bone1, float rigidity = 1.f);
PRigConfigJoint AddAngularJoint(const pragma::GString &bone0, const pragma::GString &bone1, float rigidity = 1.f);

void RemoveConstraints(const pragma::GString &bone);
Expand Down
Loading

0 comments on commit 5fa08b2

Please sign in to comment.