Skip to content

Commit

Permalink
Profiling: Various markers around SDK functions
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 24, 2023
1 parent 3d3c390 commit 9ae53b0
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 308 deletions.
289 changes: 1 addition & 288 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,131 +431,7 @@ target_link_libraries(sdk PUBLIC
target_link_libraries(sdk PUBLIC
kananlib
Version
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target sdk-nolog
set(CMKR_TARGET sdk-nolog)
set(sdk-nolog_SOURCES "")

list(APPEND sdk-nolog_SOURCES
"shared/sdk/AActor.cpp"
"shared/sdk/APawn.cpp"
"shared/sdk/APlayerController.cpp"
"shared/sdk/CVar.cpp"
"shared/sdk/ConsoleManager.cpp"
"shared/sdk/DynamicRHI.cpp"
"shared/sdk/EngineModule.cpp"
"shared/sdk/FField.cpp"
"shared/sdk/FMalloc.cpp"
"shared/sdk/FName.cpp"
"shared/sdk/FProperty.cpp"
"shared/sdk/FRenderTargetPool.cpp"
"shared/sdk/FSceneView.cpp"
"shared/sdk/FStructProperty.cpp"
"shared/sdk/FViewportInfo.cpp"
"shared/sdk/Globals.cpp"
"shared/sdk/ScriptMatrix.cpp"
"shared/sdk/ScriptRotator.cpp"
"shared/sdk/ScriptVector.cpp"
"shared/sdk/Slate.cpp"
"shared/sdk/StereoStuff.cpp"
"shared/sdk/UCameraComponent.cpp"
"shared/sdk/UClass.cpp"
"shared/sdk/UEngine.cpp"
"shared/sdk/UEnum.cpp"
"shared/sdk/UFunction.cpp"
"shared/sdk/UGameEngine.cpp"
"shared/sdk/UGameViewportClient.cpp"
"shared/sdk/UGameplayStatics.cpp"
"shared/sdk/UObject.cpp"
"shared/sdk/UObjectArray.cpp"
"shared/sdk/UObjectBase.cpp"
"shared/sdk/UProperty.cpp"
"shared/sdk/USceneComponent.cpp"
"shared/sdk/Utility.cpp"
"shared/sdk/AActor.hpp"
"shared/sdk/APawn.hpp"
"shared/sdk/APlayerController.hpp"
"shared/sdk/CVar.hpp"
"shared/sdk/ConsoleManager.hpp"
"shared/sdk/DynamicRHI.hpp"
"shared/sdk/EngineModule.hpp"
"shared/sdk/FField.hpp"
"shared/sdk/FFieldClass.hpp"
"shared/sdk/FMalloc.hpp"
"shared/sdk/FName.hpp"
"shared/sdk/FProperty.hpp"
"shared/sdk/FRenderTargetPool.hpp"
"shared/sdk/FSceneView.hpp"
"shared/sdk/FStructProperty.hpp"
"shared/sdk/FViewportInfo.hpp"
"shared/sdk/Globals.hpp"
"shared/sdk/Math.hpp"
"shared/sdk/RHICommandList.hpp"
"shared/sdk/ScriptMatrix.hpp"
"shared/sdk/ScriptRotator.hpp"
"shared/sdk/ScriptVector.hpp"
"shared/sdk/Slate.hpp"
"shared/sdk/StereoStuff.hpp"
"shared/sdk/TArray.hpp"
"shared/sdk/UCameraComponent.hpp"
"shared/sdk/UClass.hpp"
"shared/sdk/UEngine.hpp"
"shared/sdk/UEnum.hpp"
"shared/sdk/UFunction.hpp"
"shared/sdk/UGameEngine.hpp"
"shared/sdk/UGameViewportClient.hpp"
"shared/sdk/UGameplayStatics.hpp"
"shared/sdk/UObject.hpp"
"shared/sdk/UObjectArray.hpp"
"shared/sdk/UObjectBase.hpp"
"shared/sdk/UProperty.hpp"
"shared/sdk/USceneComponent.hpp"
"shared/sdk/UWorld.hpp"
"shared/sdk/Utility.hpp"
"shared/sdk/threading/GameThreadWorker.hpp"
"shared/sdk/threading/RHIThreadWorker.hpp"
"shared/sdk/threading/RenderThreadWorker.hpp"
"shared/sdk/threading/ThreadWorker.hpp"
)

list(APPEND sdk-nolog_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${sdk-nolog_SOURCES})
add_library(sdk-nolog STATIC)

if(sdk-nolog_SOURCES)
target_sources(sdk-nolog PRIVATE ${sdk-nolog_SOURCES})
endif()

target_compile_features(sdk-nolog PUBLIC
cxx_std_23
)

target_compile_options(sdk-nolog PUBLIC
"/EHa"
"/MP"
)

target_include_directories(sdk-nolog PUBLIC
"shared/"
)

target_link_libraries(sdk-nolog PUBLIC
spdlog
bddisasm
bdshemu
glm_static
asmjit
)

target_link_libraries(sdk-nolog PUBLIC
kananlib-nolog
TracyClient
)

unset(CMKR_TARGET)
Expand Down Expand Up @@ -652,9 +528,6 @@ target_link_libraries(example_plugin PUBLIC
unset(CMKR_TARGET)
unset(CMKR_SOURCES)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target sdk-test
set(CMKR_TARGET sdk-test)
set(sdk-test_SOURCES "")
Expand Down Expand Up @@ -1035,163 +908,3 @@ add_custom_command(
unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target ue4poc-nolog
set(CMKR_TARGET ue4poc-nolog)
set(ue4poc-nolog_SOURCES "")

list(APPEND ue4poc-nolog_SOURCES
"src/ExceptionHandler.cpp"
"src/Framework.cpp"
"src/Main.cpp"
"src/Mod.cpp"
"src/Mods.cpp"
"src/WindowFilter.cpp"
"src/hooks/D3D11Hook.cpp"
"src/hooks/D3D12Hook.cpp"
"src/hooks/WindowsMessageHook.cpp"
"src/hooks/XInputHook.cpp"
"src/mods/FrameworkConfig.cpp"
"src/mods/PluginLoader.cpp"
"src/mods/UObjectHook.cpp"
"src/mods/VR.cpp"
"src/mods/vr/Bindings.cpp"
"src/mods/vr/CVarManager.cpp"
"src/mods/vr/D3D11Component.cpp"
"src/mods/vr/D3D12Component.cpp"
"src/mods/vr/FFakeStereoRenderingHook.cpp"
"src/mods/vr/IXRTrackingSystemHook.cpp"
"src/mods/vr/OverlayComponent.cpp"
"src/mods/vr/RenderTargetPoolHook.cpp"
"src/mods/vr/d3d12/CommandContext.cpp"
"src/mods/vr/d3d12/DirectXTK.cpp"
"src/mods/vr/d3d12/TextureContext.cpp"
"src/mods/vr/runtimes/OpenVR.cpp"
"src/mods/vr/runtimes/OpenXR.cpp"
"src/ue4poc-imgui/imgui_impl_dx11.cpp"
"src/ue4poc-imgui/imgui_impl_dx12.cpp"
"src/ue4poc-imgui/imgui_impl_win32.cpp"
"src/ExceptionHandler.hpp"
"src/Framework.hpp"
"src/LicenseStrings.hpp"
"src/Mod.hpp"
"src/Mods.hpp"
"src/WindowFilter.hpp"
"src/hooks/D3D11Hook.hpp"
"src/hooks/D3D12Hook.hpp"
"src/hooks/WindowsMessageHook.hpp"
"src/hooks/XInputHook.hpp"
"src/mods/FrameworkConfig.hpp"
"src/mods/PluginLoader.hpp"
"src/mods/UObjectHook.hpp"
"src/mods/VR.hpp"
"src/mods/vr/CVarManager.hpp"
"src/mods/vr/D3D11Component.hpp"
"src/mods/vr/D3D12Component.hpp"
"src/mods/vr/FFakeStereoRenderingHook.hpp"
"src/mods/vr/IXRTrackingSystemHook.hpp"
"src/mods/vr/OverlayComponent.hpp"
"src/mods/vr/RenderTargetPoolHook.hpp"
"src/mods/vr/d3d12/ComPtr.hpp"
"src/mods/vr/d3d12/CommandContext.hpp"
"src/mods/vr/d3d12/DirectXTK.hpp"
"src/mods/vr/d3d12/TextureContext.hpp"
"src/mods/vr/runtimes/OpenVR.hpp"
"src/mods/vr/runtimes/OpenXR.hpp"
"src/mods/vr/runtimes/VRRuntime.hpp"
"src/mods/vr/shaders/ps.hpp"
"src/mods/vr/shaders/vs.hpp"
"src/mods/vr/structures/Enums.hpp"
"src/mods/vr/structures/FGuid.hpp"
"src/mods/vr/structures/FName.hpp"
"src/mods/vr/structures/FXRHMDData.hpp"
"src/mods/vr/structures/FXRMotionControllerData.hpp"
"src/mods/vr/vtables/IXRTrackingSystemVTables.hpp"
"src/ue4poc-imgui/font_robotomedium.hpp"
"src/ue4poc-imgui/ue4poc_imconfig.hpp"
"src/utility/Logging.hpp"
"src/ue4poc-imgui/imgui_impl_dx11.h"
"src/ue4poc-imgui/imgui_impl_dx12.h"
"src/ue4poc-imgui/imgui_impl_win32.h"
)

list(APPEND ue4poc-nolog_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${ue4poc-nolog_SOURCES})
add_library(ue4poc-nolog SHARED)

if(ue4poc-nolog_SOURCES)
target_sources(ue4poc-nolog PRIVATE ${ue4poc-nolog_SOURCES})
endif()


target_compile_features(ue4poc-nolog PUBLIC
cxx_std_23
)

target_compile_options(ue4poc-nolog PUBLIC
"/GS-"
"/bigobj"
"/EHa"
"/MP"
)

target_include_directories(ue4poc-nolog PUBLIC
"shared/"
"src/"
"include/"
"${OPENXR_SOURCE_DIR}/src"
)

target_link_libraries(ue4poc-nolog PUBLIC
shlwapi
d3d11
d3d12
safetyhook
glm_static
imgui
openvr_api
openxr_loader
nlohmann_json
Version
TracyClient
DirectXTK
DirectXTK12
)

target_compile_definitions(ue4poc-nolog PUBLIC
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_OFF
)

target_link_libraries(ue4poc-nolog PUBLIC
kananlib-nolog
sdk-nolog
)

set_target_properties(ue4poc-nolog PROPERTIES
OUTPUT_NAME
UnrealVRBackend
LINK_FLAGS
"/DELAYLOAD:openvr_api.dll /DELAYLOAD:openxr_loader.dll"
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bin/${CMKR_TARGET}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/bin/${CMKR_TARGET}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
ARCHIVE_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ue4poc-nolog POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:openvr> $<TARGET_FILE_DIR:ue4poc-nolog>)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

22 changes: 2 additions & 20 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,8 @@ link-libraries = [
type = "sdk-template"
link-libraries = [
"kananlib",
"Version"
]

[target.sdk-nolog]
type = "sdk-template"
link-libraries = [
"kananlib-nolog",
"Version",
"TracyClient"
]

[target.plugin_renderlib]
Expand Down Expand Up @@ -277,16 +272,3 @@ add_custom_command(
TARGET ue4poc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:openvr> $<TARGET_FILE_DIR:ue4poc>)
"""

[target.ue4poc-nolog]
type="ue4template"
compile-definitions = ["SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_OFF"]
link-libraries = [
"kananlib-nolog",
"sdk-nolog"
]
cmake-after="""
add_custom_command(
TARGET ue4poc-nolog POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:openvr> $<TARGET_FILE_DIR:ue4poc-nolog>)
"""
5 changes: 5 additions & 0 deletions shared/sdk/ConsoleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
#include <utility/Module.hpp>
#include <utility/String.hpp>

#include <tracy/Tracy.hpp>

#include "EngineModule.hpp"

#include "ConsoleManager.hpp"

namespace detail {
sdk::FConsoleManager** try_find_console_manager(const std::wstring& string_candidate) {
ZoneScopedN("sdk::FConsoleManager::try_find_console_manager");
SPDLOG_INFO("Finding IConsoleManager...");

const auto now = std::chrono::steady_clock::now();
Expand Down Expand Up @@ -85,6 +88,8 @@ sdk::FConsoleManager** try_find_console_manager(const std::wstring& string_candi
namespace sdk {
FConsoleManager* FConsoleManager::get() {
static auto result = []() -> FConsoleManager** {
ZoneScopedN("sdk::FConsoleManager::get static init");

std::vector<std::wstring> candidates {
L"r.DumpingMovie",
L"vr.pixeldensity",
Expand Down
3 changes: 3 additions & 0 deletions shared/sdk/FMalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <utility/Module.hpp>
#include <spdlog/spdlog.h>

#include <tracy/Tracy.hpp>

#include "EngineModule.hpp"

#include "FMalloc.hpp"
Expand All @@ -12,6 +14,7 @@ namespace sdk {
// There are many different ways to find this because the pointer is used all over.
FMalloc* FMalloc::get() {
static FMalloc** result = []() -> FMalloc** {
ZoneScopedN("sdk::FMalloc::get static init");
SPDLOG_INFO("[FMalloc::get] Finding GMalloc...");

const auto core_uobject = sdk::get_ue_module(L"CoreUObject");
Expand Down
Loading

0 comments on commit 9ae53b0

Please sign in to comment.