Skip to content

Commit

Permalink
[REMIX-3552] DXVK log -> rtx-remix/logs/remix_dxvk.log
Browse files Browse the repository at this point in the history
- Add util_filesys, to be shared with bridge for common resolution of paths
- Change dxvk log from \_d3d9.log -> remix_dxvk.log
- Change default log location from CWD -> `rtx-remix/logs/`
- Edit Logger to be able to reset static Logger instance after initialization
  • Loading branch information
nv-nfreybler committed Oct 8, 2024
2 parents fd48377 + aedd1bf commit af6c832
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 103 deletions.
20 changes: 19 additions & 1 deletion src/d3d9/d3d9_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
#include "d3d9_shader_validator.h"
#include "d3d9_device.h"

// NV-DXVK start: RTX FileSystem management
#include "../util/util_filesys.h"
// NV-DXVK end

#include <windows.h>

class D3DFE_PROCESSVERTICES;
using PSGPERRORID = UINT;

namespace dxvk {
Logger Logger::s_instance("d3d9.log");
// NV-DXVK start: pass log level as param
Logger Logger::s_instance("d3d9.log", LogLevel::None);
// NV-DXVK end

HRESULT CreateD3D9(
bool Extended,
Expand All @@ -22,6 +28,18 @@ namespace dxvk {
// NV-DXVK end
if (!ppDirect3D9Ex)
return D3DERR_INVALIDCALL;

// NV-DXVK start: Set up rtx filesystem
// If Direct3DCreate9 is invoked more than once, we want our static
// state to remain.
ONCE(
const auto exePath = env::getExePath();
const auto exeDir = std::filesystem::path(exePath).parent_path();
util::RtxFileSys::init(exeDir.string());
Logger::initRtxLog();
util::RtxFileSys::print();
);
// NV-DXVK end

// NV-DXVK start: external API / provide error code on exception
try {
Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/dxvk_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ namespace dxvk {
// NV-DXVK start: Check against extension requirements for DXVK and Remix to run
Logger::err("Unable to find all required Vulkan GPU extensions for device creation.");

messageBox("Your GPU doesn't support the required features to run RTX Remix. See the *_d3d9.log for what features your GPU doesn't support. The game will exit now.", "RTX Remix - GPU Feature Error!", MB_OK);
messageBox("Your GPU doesn't support the required features to run RTX Remix. See the 'rtx-remix/logs/remix-dxvk.log' for what features your GPU doesn't support. The game will exit now.", "RTX Remix - GPU Feature Error!", MB_OK);
// NV-DXVK end

// NV-DXVK start: Provide error code on exception
Expand Down
1 change: 0 additions & 1 deletion src/dxvk/dxvk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
// NV-DXVK start: Provide error code on exception
#include <remix/remix_c.h>
// NV-DXVK end

namespace dxvk {
bool filterErrorMessages(const char* message) {
// validation errors that we are currently ignoring --- to fix!
Expand Down
9 changes: 5 additions & 4 deletions src/dxvk/imgui/dxvk_imgui_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "../rtx_render/rtx_imgui.h"
#include "../../lssusd/game_exporter_paths.h"

#include "../../util/util_filesys.h"
#include "../../util/util_string.h"

#include <filesystem>
Expand Down Expand Up @@ -261,8 +262,8 @@ namespace dxvk {
m_percent = 1.f;
const bool captureInstances = (RtxOptions::Get()->m_captureInstances.getValue());
m_output.push_back((captureInstances) ? "Scene captured to:" : "Assets captured to:");
const std::string destination = (captureInstances) ? m_captureStageName :
std::filesystem::absolute(std::filesystem::path(GameCapturer::s_baseDir)).string();
const std::string destination =
(captureInstances) ? m_captureStageName : util::RtxFileSys::path(util::RtxFileSys::Captures).string();
m_output.push_back(destination);
return;
}
Expand Down Expand Up @@ -307,8 +308,8 @@ namespace dxvk {
if (m_prevState.has<GameCapturer::State::Complete>() &&
ImGui::SmallButton("Copy Full Path")) {
const bool captureInstances = (RtxOptions::Get()->m_captureInstances.getValue());
const std::string toCopy = (captureInstances) ? m_capturePath :
std::filesystem::absolute(std::filesystem::path(GameCapturer::s_baseDir)).string();
const std::string toCopy =
(captureInstances) ? m_capturePath : util::RtxFileSys::path(util::RtxFileSys::Captures).string();
ImGui::SetClipboardText(toCopy.c_str());
}
ImGui::PopTextWrapPos();
Expand Down
1 change: 0 additions & 1 deletion src/dxvk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ dxvk_src = files([
'rtx_render/rtx_env.h',
'rtx_render/rtx_game_capturer.cpp',
'rtx_render/rtx_game_capturer.h',
'rtx_render/rtx_game_capturer_paths.h',
'rtx_render/rtx_game_capturer_utils.h',
'rtx_render/rtx_geometry_utils.cpp',
'rtx_render/rtx_geometry_utils.h',
Expand Down
1 change: 0 additions & 1 deletion src/dxvk/rtx_render/rtx_asset_data_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "rtx_utils.h"
#include "rtx_options.h"
#include "rtx_asset_package.h"
#include "rtx_game_capturer_paths.h"
#include "rtx_io.h"
#include "dxvk_scoped_annotation.h"
#include <gli/gli.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/dxvk/rtx_render/rtx_asset_replacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "dxvk_context.h"
#include "rtx_context.h"
#include "rtx_options.h"
#include "rtx_game_capturer_paths.h"
#include "rtx_utils.h"
#include "rtx_asset_data_manager.h"

Expand Down
30 changes: 5 additions & 25 deletions src/dxvk/rtx_render/rtx_game_capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

#include "rtx_game_capturer.h"
#include "rtx_game_capturer_paths.h"

#include "rtx_context.h"
#include "rtx_types.h"
Expand All @@ -36,6 +35,7 @@

#include "../../util/log/log.h"
#include "../../util/config/config.h"
#include "../../util/util_filesys.h"
#include "../../util/util_vector.h"
#include "../../util/util_window.h"

Expand All @@ -52,31 +52,9 @@

#include <filesystem>

#define BASE_DIR (std::string(GameCapturer::s_baseDir))
#define BASE_DIR (util::RtxFileSys::path(util::RtxFileSys::Captures).string())

namespace dxvk {
const std::string GameCapturer::s_baseDir = []() {
std::string pathStr = env::getEnvVar("DXVK_CAPTURE_PATH");
if (!pathStr.empty()) {
if(*pathStr.rbegin() != '/') {
pathStr += '/';
}
} else {
pathStr = relPath::remixCaptureDir;
}
{
using namespace std::filesystem;
const path wholePath = path(pathStr);
path ctorPath(".");
for (const auto& part : wholePath) {
ctorPath /= part;
ctorPath = absolute(ctorPath);
env::createDirectory(ctorPath.string());
}
}
return pathStr;
}();

namespace {
static inline pxr::GfMatrix4d matrix4ToGfMatrix4d(const Matrix4& mat4) {
const auto& float4x4 = reinterpret_cast<const float(&)[4][4]>(mat4);
Expand Down Expand Up @@ -118,7 +96,8 @@ namespace dxvk {
}

static std::string getBakedSkyProbeName(const std::string& captureName) {
return captureName + commonFileName::bakedSkyProbeSuffix;
const std::string bakedSkyProbeSuffix("_T_SkyProbe" + lss::ext::dds);
return captureName + bakedSkyProbeSuffix;
}
}

Expand All @@ -134,6 +113,7 @@ namespace dxvk {
, m_sceneManager(sceneManager)
, m_exporter(exporter)
, m_options{ getOptions() } {

if(!env::getEnvVar("DXVK_RTX_CAPTURE_ENABLE_ON_FRAME").empty()) {
Logger::info(str::format("[GameCapturer] DXVK_RTX_CAPTURE_ENABLE_ON_FRAME: ", env::getEnvVar("DXVK_RTX_CAPTURE_ENABLE_ON_FRAME")));
}
Expand Down
2 changes: 0 additions & 2 deletions src/dxvk/rtx_render/rtx_game_capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ class GameCapturer : public RcObject
return m_completeCapture;
}

static const std::string s_baseDir;

private:
GameCapturer() = delete;
GameCapturer(const GameCapturer& other) = delete;
Expand Down
43 changes: 0 additions & 43 deletions src/dxvk/rtx_render/rtx_game_capturer_paths.h

This file was deleted.

11 changes: 6 additions & 5 deletions src/dxvk/rtx_render/rtx_mod_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/
#include "rtx_mod_manager.h"

#include "rtx_game_capturer_paths.h"
#include "rtx_asset_replacer.h"
#include "rtx_mod_usd.h"

#include "rtx_options.h"

#include "../../util/log/log.h"
#include "../../util/util_filesys.h"
#include "../../util/util_string.h"

#include <unordered_set>
Expand All @@ -38,7 +38,6 @@ namespace fs = std::filesystem;

namespace dxvk {

static const std::string kDefaultModsDir = relPath::rtxRemixDir + relPath::modsDir;
static const std::string kDefaultModFileName = "mod";

static const ModTypeInfo* kModTypeInfos[] = {
Expand Down Expand Up @@ -84,16 +83,18 @@ ModManager::Mods ModManager::enumerateAllMods() {
Mods mods;

std::string modsPath = env::getEnvVar("DEFAULT_MODS_DIR");
if (modsPath == "")
modsPath = kDefaultModsDir;
if (modsPath == "") {
modsPath = util::RtxFileSys::path(util::RtxFileSys::Mods).string();
}


const Path defaultModsDir = Path(modsPath).lexically_normal();

std::string baseGameModPath = getBaseGameModPath(RtxOptions::Get()->baseGameModRegex(), RtxOptions::Get()->baseGameModPathRegex());

std::vector<Path> vecModsDirs; // [TODO] = GetAddtlModsSearchDirs();
if (baseGameModPath != "") {
vecModsDirs.push_back(baseGameModPath + "/" + relPath::rtxRemixDir + relPath::modsDir);
vecModsDirs.push_back(baseGameModPath + "/rtx-remix/mods/");
}
vecModsDirs.push_back(defaultModsDir);
for (const auto& modsDirPath : vecModsDirs) {
Expand Down
1 change: 0 additions & 1 deletion src/dxvk/rtx_render/rtx_mod_usd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "dxvk_context.h"
#include "rtx_context.h"
#include "rtx_options.h"
#include "rtx_game_capturer_paths.h"
#include "rtx_utils.h"
#include "rtx_asset_data_manager.h"
#include "rtx_texture_manager.h"
Expand Down
39 changes: 25 additions & 14 deletions src/util/log/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "log.h"

#include "../util_env.h"
#include "../util_filesys.h"


// NV-DXVK start: Don't double print every line
Expand Down Expand Up @@ -57,20 +58,25 @@ namespace{

namespace dxvk {

Logger::Logger(const std::string& file_name)
: m_minLevel(getMinLogLevel())
Logger::Logger(const std::string& file_name, const LogLevel logLevel)
: m_minLevel(logLevel)
// NV-DXVK start: Don't double print every line
, m_doublePrintToStdErr(getDoublePrintToStdErr())
// NV-DXVK end
{
if (m_minLevel != LogLevel::None) {
auto path = getFileName(file_name);

if (!path.empty())
if (!path.empty()) {
m_fileStream = std::ofstream(str::tows(path.c_str()).c_str());
assert(m_fileStream.is_open());
}
}
}

void Logger::initRtxLog() {
s_instance = std::move(Logger("remix-dxvk.log"));
}

Logger::~Logger() { }

Expand Down Expand Up @@ -156,19 +162,24 @@ namespace dxvk {
return LogLevel::Info;
}


std::string Logger::getFileName(const std::string& base) {
std::string path = env::getEnvVar("DXVK_LOG_PATH");

if (path == "none")
// NV-DXVK start: Use std::filesystem::path helpers + RtxFileSys
using fspath = std::filesystem::path;
fspath path = util::RtxFileSys::path(util::RtxFileSys::Logs);
if(path.empty()) {
return "";

if (!path.empty() && *path.rbegin() != '/')
path += '/';

std::string exeName = env::getExeBaseName();
path += exeName + "_" + base;
return path;
}
path /= "remix-dxvk.log";
std::cout << path << std::endl;
return path.string();
// NV-DXVK end
}

Logger& Logger::operator=(Logger&& other) {
m_minLevel = other.m_minLevel;
m_doublePrintToStdErr = other.m_doublePrintToStdErr;
std::swap(m_fileStream, other.m_fileStream);
return *this;
}

}
14 changes: 11 additions & 3 deletions src/util/log/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ namespace dxvk {

public:

Logger(const std::string& file_name);
// NV-DXVK start: pass log level as param
Logger(const std::string& file_name, const LogLevel logLevel = getMinLogLevel());
// NV-DXVK end
~Logger();

// NV-DXVK start: special init pathway for remix logs
static void initRtxLog();
// NV-DXVK end

static void trace(const std::string& message);
static void debug(const std::string& message);
static void info (const std::string& message);
Expand All @@ -68,9 +74,9 @@ namespace dxvk {

static Logger s_instance;

const LogLevel m_minLevel;
LogLevel m_minLevel;
// NV-DXVK start: Don't double print every line
const bool m_doublePrintToStdErr;
bool m_doublePrintToStdErr;
// NV-DXVK end

dxvk::mutex m_mutex;
Expand All @@ -83,6 +89,8 @@ namespace dxvk {
static std::string getFileName(
const std::string& base);

Logger& operator=(Logger&& other);

};

}
Loading

0 comments on commit af6c832

Please sign in to comment.