Skip to content

Commit

Permalink
Merge branch 'nfreybler/deprecate_usd_plugins2' into 'main'
Browse files Browse the repository at this point in the history
Deprecate loading of arbitrary USD plugins

See merge request lightspeedrtx/dxvk-remix-nv!775
  • Loading branch information
sultim-t-nv committed Apr 5, 2024
2 parents 3ce2a35 + a25ed7d commit a90cc32
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 109 deletions.
12 changes: 0 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Release/')
if get_option('buildtype') == 'debug'
nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Debug/')
endif
lss_usd_plugins_path = join_paths(global_src_root_norm, 'usd_plugins/')

rtxdi_include_path = include_directories('submodules/rtxdi/rtxdi-sdk/include')
# Need to use the include path as an argument to the shader build string,
Expand Down Expand Up @@ -499,11 +498,6 @@ if not dxvk_is_ninja
depends : [],
command : [copy_script_path, aftermath_lib_path, output_dir, 'GFSDK_Aftermath_Lib.x64.dll'] )

recursive_copy_lss_usd_plugins_target = custom_target('recursive_copy_lss_usd_plugins',
output : ['recursive_copy_lss_usd_plugins'],
build_by_default : true,
command : [recursive_copy_path, lss_usd_plugins_path, join_paths(output_dir, 'lss/usd_plugins/')] )

if enable_rtxio == true
copy_rtxio_target = custom_target('copy_rtxio',
output : ['copy_rtxio'],
Expand Down Expand Up @@ -714,12 +708,6 @@ if dxvk_is_ninja
depends : [],
command : [copy_script_path, aftermath_lib_path, output_path, 'GFSDK_Aftermath_Lib.x64.dll'] )

recursive_copy_lss_usd_plugins = custom_target('recursive_copy_lss_usd_plugins_' + target_suffix,
output : ['recursive_copy_lss_usd_plugins_' + target_suffix],
command : [recursive_copy_path,
lss_usd_plugins_path,
join_paths(output_path, 'lss/usd_plugins/')] )

if enable_rtxio == true
copy_rtxio = custom_target('copy_rtxio_' + target_suffix,
output : ['copy_rtxio_' + target_suffix],
Expand Down
24 changes: 6 additions & 18 deletions src/dxvk/rtx_render/rtx_game_capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,12 @@ namespace dxvk {
: m_pDevice(pDevice)
, m_sceneManager(sceneManager)
, m_exporter(exporter)
, m_options{ getOptions() }
, m_bUseLssUsdPlugins(lss::GameExporter::loadUsdPlugins("./lss/usd_plugins/")) {
, m_options{ getOptions() } {
Logger::info(str::format("[GameCapturer] DXVK_RTX_CAPTURE_ENABLE_ON_FRAME: ", env::getEnvVar("DXVK_RTX_CAPTURE_ENABLE_ON_FRAME")));
env::createDirectory(BASE_DIR);
env::createDirectory(BASE_DIR + lss::commonDirName::texDir);
env::createDirectory(BASE_DIR + lss::commonDirName::matDir);
lss::GameExporter::setMultiThreadSafety(true);
if (m_bUseLssUsdPlugins) {
Logger::debug("[GameCapturer] LSS USD Plugins successfully found and loaded.");
} else {
Logger::warn("[GameCapturer] LSS USD Plugins failed to load.");
}
}

GameCapturer::~GameCapturer() {
Expand Down Expand Up @@ -960,16 +954,14 @@ namespace dxvk {
std::unique_ptr<Capture> pCap,
State* pState,
CompletedCapture* complete,
const float framesPerSecond,
const bool bUseLssUsdPlugins) {
const float framesPerSecond) {
Capture& cap = *pCap;
const auto numTexExportsInProgress = m_exporter.getNumExportsInFlights();
constexpr float kTimePerTexExport = 0.0050f; // Liberally decided by inspection, derived from timed out tests
const float texExportTimeout = numTexExportsInProgress * kTimePerTexExport;
m_exporter.waitForAllExportsToComplete(texExportTimeout);
assert(pState->has<State::PreppingExport>());
auto exportPrep = prepExport(cap, framesPerSecond, bUseLssUsdPlugins);

const auto exportPrep = prepExport(cap, framesPerSecond);
pState->set<State::PreppingExport, false>();
pState->set<State::Exporting, true>();

Expand All @@ -996,15 +988,13 @@ namespace dxvk {
std::move(m_pCap),
&m_state,
&m_completeCapture,
static_cast<float>(m_options.fps),
m_bUseLssUsdPlugins).detach();
static_cast<float>(m_options.fps)).detach();
}

lss::Export GameCapturer::prepExport(const Capture& cap,
const float framesPerSecond,
const bool bUseLssUsdPlugins) {
const float framesPerSecond) {
lss::Export exportPrep;
prepExportMetaData(cap, framesPerSecond, bUseLssUsdPlugins, exportPrep);
prepExportMetaData(cap, framesPerSecond, exportPrep);
prepExportMaterials(cap, exportPrep);
prepExportMeshes(cap, exportPrep);
if (exportPrep.bExportInstanceStage) {
Expand All @@ -1017,7 +1007,6 @@ namespace dxvk {

void GameCapturer::prepExportMetaData(const Capture& cap,
const float framesPerSecond,
const bool bUseLssUsdPlugins,
lss::Export& exportPrep) {
// Prep meta data
exportPrep.meta.windowTitle = window::getWindowTitle(cap.hwnd);
Expand All @@ -1030,7 +1019,6 @@ namespace dxvk {
exportPrep.meta.endTimeCode = floor(static_cast<double>(cap.currentFrameNum));
exportPrep.meta.numFramesCaptured = cap.numFramesCaptured;
window::saveWindowIconToFile(exportPrep.meta.iconPath, cap.hwnd);
exportPrep.meta.bUseLssUsdPlugins = bUseLssUsdPlugins;
exportPrep.meta.bReduceMeshBuffers = true;
exportPrep.meta.isZUp = RtxOptions::Get()->isZUp();
if (s_captureRemixConfigs) {
Expand Down
7 changes: 1 addition & 6 deletions src/dxvk/rtx_render/rtx_game_capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,9 @@ class GameCapturer : public RcObject
void exportUsd(const Rc<DxvkContext> ctx);
struct Capture;
static lss::Export prepExport(const Capture& cap,
const float framesPerSecond,
const bool bUseLssUsdPlugins);
const float framesPerSecond);
static void prepExportMetaData(const Capture& cap,
const float framesPerSecond,
const bool bUseLssUsdPlugins,
lss::Export& exportPrep);
static void prepExportMaterials(const Capture& cap,
lss::Export& exportPrep);
Expand Down Expand Up @@ -312,9 +310,6 @@ class GameCapturer : public RcObject
// State
bool m_bTriggerCapture = false;
State m_state;

// Constants
const bool m_bUseLssUsdPlugins;

// Handles
DxvkDevice* const m_pDevice;
Expand Down
25 changes: 0 additions & 25 deletions src/lssusd/game_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,6 @@ std::string computeLocalPath(const std::string& assetPath) {
return resolvedPath.GetPathString();
}

bool GameExporter::loadUsdPlugins(const std::string& path) {
static auto& pluginRegistry = pxr::PlugRegistry::GetInstance();
std::string fullPath = computeLocalPath(path);
static auto plugins = pluginRegistry.RegisterPlugins(fullPath);
for (auto plugin : plugins) {
if (plugin == nullptr)
continue;

if (!plugin->IsLoaded() && !plugin->Load()) {
return false;
}
dxvk::Logger::info("[GameExporter] Load plugin: " + plugin->GetName());
}
return plugins.size() > 0;
}

void GameExporter::exportUsd(const Export& exportData) {
if(s_bMultiThreadSafety) {
std::scoped_lock lock(s_mutex);
Expand Down Expand Up @@ -714,15 +698,6 @@ void GameExporter::exportMeshes(const Export& exportData, ExportContext& ctx) {
pxr::UsdShadeMaterialBindingAPI(meshXformSchema.GetPrim()).Bind(shaderMatSchema);
}

// Kit metadata
if(exportData.meta.bUseLssUsdPlugins) {
meshXformSchema.GetPrim().SetMetadata(PXR_NS::SdfFieldKeys->Kind, PXR_NS::KindTokens->assembly);
static const pxr::TfToken kTokHideInStageWindow("hide_in_stage_window");
meshSchema.GetPrim().SetMetadata(kTokHideInStageWindow, true);
static const pxr::TfToken kTokNoDelete("no_delete");
meshSchema.GetPrim().SetMetadata(kTokNoDelete, true);
}

meshStage->Save();

// Cache material reference
Expand Down
1 change: 0 additions & 1 deletion src/lssusd/game_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class GameExporter
static void setMultiThreadSafety(const bool enable) {
s_bMultiThreadSafety = enable;
}
static bool loadUsdPlugins(const std::string& path);
static void exportUsd(const Export& exportData);
private:
struct Reference {
Expand Down
1 change: 0 additions & 1 deletion src/lssusd/game_exporter_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ struct Export {
double startTimeCode;
double endTimeCode;
size_t numFramesCaptured;
bool bUseLssUsdPlugins;
bool bReduceMeshBuffers;
bool isZUp;
std::unordered_map<std::string, std::string> renderingSettingsDict;
Expand Down
41 changes: 0 additions & 41 deletions usd_plugins/ov_kit_editor_ext/plugInfo.json

This file was deleted.

5 changes: 0 additions & 5 deletions usd_plugins/plugInfo.json

This file was deleted.

0 comments on commit a90cc32

Please sign in to comment.