Skip to content

Commit

Permalink
Add stats file/stats mode and profile file to render settings (#2074)
Browse files Browse the repository at this point in the history
* Added stats_file to HdArnoldConfig
log_file, profile_file and stats_file are now set in the universe if they are overriden via their respective HDARNOLD env var

* stats:file, stats:mode and profile:file are now respected

* Updated changelog
  • Loading branch information
TomMinor authored Aug 28, 2024
1 parent d193004 commit ab33049
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [usd#2058](https://github.com/Autodesk/arnold-usd/issues/2058) - Support UsdPlane primitives
- [usd#2061](https://github.com/Autodesk/arnold-usd/issues/2061) - Support arnold light groups in Hydra
- [usd#2067](https://github.com/Autodesk/arnold-usd/issues/2067) - Do not author useless "normals" user data in meshes/curves through the procedural
- [usd#1118](https://github.com/Autodesk/arnold-usd/issues/1118) - Add profile/stats settings to the Render Settings

### Bug fixes
- [usd#1961](https://github.com/Autodesk/arnold-usd/issues/1961) - Random curves width in Hydra when radius primvars are authored
Expand Down
4 changes: 3 additions & 1 deletion libs/common/constant_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ ASTR2(primvars_arnold, "primvars:arnold");
ASTR2(primvars_arnold_light, "primvars:arnold:light");
ASTR2(log_file, "log:file");
ASTR2(log_verbosity, "log:verbosity");
ASTR2(profile_file, "profile:file");
ASTR2(stats_file, "stats:file");
ASTR2(stats_mode, "stats:mode");
ASTR2(outputs_color, "outputs:color");
ASTR2(outputs_out, "outputs:out");
ASTR2(primvars_arnold_light_shaders, "primvars:arnold:light:shaders");
Expand Down Expand Up @@ -406,7 +409,6 @@ ASTR(points);
ASTR(polymesh);
ASTR(procedural_custom);
ASTR(procedural_searchpath);
ASTR(profile_file);
ASTR(progressive);
ASTR(progressive_min_AA_samples);
ASTR(progressive_show_all_outputs);
Expand Down
32 changes: 31 additions & 1 deletion libs/common/rendersettings_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ TF_DEFINE_PRIVATE_TOKENS(_tokens,
((colorManagerEntry, "arnold:color_manager:node_entry"))
((logFile, "arnold:global:log:file"))
((logVerbosity, "arnold:global:log:verbosity"))
((statsFile, "arnold:global:stats:file"))
((statsMode, "arnold:global:stats:mode"))
((profileFile, "arnold:global:profile:file"))
((arnoldName, "arnold:name"))
((inputsName, "inputs:name"))
((_float, "float"))
Expand Down Expand Up @@ -846,7 +849,7 @@ AtNode* ReadRenderSettings(const UsdPrim &renderSettingsPrim, ArnoldAPIAdapter &
if (UsdAttribute logFileAttr = renderSettingsPrim.GetAttribute(_tokens->logFile)) {
VtValue logFileValue;
if (logFileAttr.Get(&logFileValue, time.frame)) {
std::string logFile = VtValueGetString(logFileValue);
const std::string logFile = VtValueGetString(logFileValue);
AiMsgSetLogFileName(logFile.c_str());
}
}
Expand All @@ -865,6 +868,33 @@ AtNode* ReadRenderSettings(const UsdPrim &renderSettingsPrim, ArnoldAPIAdapter &
#endif
}
}

// stats file
if (UsdAttribute statsFileAttr = renderSettingsPrim.GetAttribute(_tokens->statsFile)) {
VtValue statsFileValue;
if (statsFileAttr.Get(&statsFileValue, time.frame)) {
const std::string statsFile = VtValueGetString(statsFileValue);
AiStatsSetFileName(statsFile.c_str());
}
}

// stats mode (overwrite or append)
if (UsdAttribute statsModeAttr = renderSettingsPrim.GetAttribute(_tokens->statsMode)) {
VtValue statsModeValue;
if (statsModeAttr.Get(&statsModeValue, time.frame)) {
const AtStatsMode statsMode = static_cast<AtStatsMode>(VtValueGetInt(statsModeValue));
AiStatsSetMode(statsMode);
}
}

// profile file
if (UsdAttribute profileFileAttr = renderSettingsPrim.GetAttribute(_tokens->profileFile)) {
VtValue profileFileValue;
if (profileFileAttr.Get(&profileFileValue, time.frame)) {
const std::string profileFile = VtValueGetString(profileFileValue);
AiProfileSetFileName(profileFile.c_str());
}
}

return options;
}
Expand Down
3 changes: 3 additions & 0 deletions libs/render_delegate/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ TF_DEFINE_ENV_SETTING(HDARNOLD_interactive_fps_min, "5.0", "Minimum fps for prog

TF_DEFINE_ENV_SETTING(HDARNOLD_profile_file, "", "Output file for profiling information.");

TF_DEFINE_ENV_SETTING(HDARNOLD_stats_file, "", "Output file for stats information.");

TF_DEFINE_ENV_SETTING(HDARNOLD_texture_searchpath, "", "Texture search path.");

TF_DEFINE_ENV_SETTING(HDARNOLD_plugin_searchpath, "", "Plugin search path.");
Expand All @@ -116,6 +118,7 @@ HdArnoldConfig::HdArnoldConfig()
log_file = TfGetEnvSetting(HDARNOLD_log_file);
log_flags_console = TfGetEnvSetting(HDARNOLD_log_flags_console);
log_flags_file = TfGetEnvSetting(HDARNOLD_log_flags_file);
stats_file = TfGetEnvSetting(HDARNOLD_stats_file);
threads = TfGetEnvSetting(HDARNOLD_threads);
AA_samples = TfGetEnvSetting(HDARNOLD_AA_samples);
GI_diffuse_samples = std::max(0, TfGetEnvSetting(HDARNOLD_GI_diffuse_samples));
Expand Down
4 changes: 4 additions & 0 deletions libs/render_delegate/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ struct HdArnoldConfig {
///
std::string profile_file; ///< Output file for profiling data.

/// Use HDARNOLD_stats_file to set the value.
///
std::string stats_file; ///< Output file for stats data.

/// Use HDARNOLD_texture_searchpath to set the value.
///
std::string texture_searchpath; ///< Texture search path.
Expand Down
42 changes: 38 additions & 4 deletions libs/render_delegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ const SupportedRenderSettings& _GetSupportedRenderSettings()
{str::t_log_file, {"Log File Path", config.log_file}},
// Profiling Settings
{str::t_profile_file, {"File Output for Profiling", config.profile_file}},
// Stats Settings
{str::t_stats_file, {"File Output for Stats", config.stats_file}},
{str::t_stats_mode, {"Overwrite or append"}},
// Search paths
{str::t_texture_searchpath, {"Texture search path.", config.texture_searchpath}},
{str::t_plugin_searchpath, {"Plugin search path.", config.plugin_searchpath}},
Expand Down Expand Up @@ -535,6 +538,19 @@ HdArnoldRenderDelegate::HdArnoldRenderDelegate(bool isBatch, const TfToken &cont
AiMsgSetLogFileFlags(_universe, config.log_flags_file);
#endif
}
if (!config.log_file.empty())
{
AiMsgSetLogFileName(config.log_file.c_str());
}
if (!config.stats_file.empty())
{
AiStatsSetFileName(config.stats_file.c_str());
}
if (!config.profile_file.empty())
{
AiProfileSetFileName(config.profile_file.c_str());
}

hdArnoldInstallNodes();
// Check the USD environment variable for custom Materialx node definitions.
// We need to use this to pass it on to Arnold's MaterialX
Expand Down Expand Up @@ -658,6 +674,22 @@ void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& _key, const VtValu
_logFile = value.UncheckedGet<std::string>();
AiMsgSetLogFileName(_logFile.c_str());
}
} else if (key == str::t_stats_file) {
if (value.IsHolding<std::string>()) {
_statsFile = value.UncheckedGet<std::string>();
AiStatsSetFileName(_statsFile.c_str());
}
} else if (key == str::t_stats_mode) {
if (value.IsHolding<int>()) {
_statsMode = static_cast<AtStatsMode>(VtValueGetInt(value));
AiStatsSetMode(_statsMode);
AiStatsSetMode(AtStatsMode(0));
}
} else if (key == str::t_profile_file) {
if (value.IsHolding<std::string>()) {
_profileFile = value.UncheckedGet<std::string>();
AiProfileSetFileName(_profileFile.c_str());
}
} else if (key == str::t_enable_progressive_render) {
if (!_isBatch) {
_CheckForBoolValue(value, [&](const bool b) {
Expand Down Expand Up @@ -689,10 +721,6 @@ void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& _key, const VtValu
AiRenderSetHintFlt(GetRenderSession(), str::interactive_fps_min, value.UncheckedGet<float>());
}
}
} else if (key == str::t_profile_file) {
if (value.IsHolding<std::string>()) {
AiProfileSetFileName(value.UncheckedGet<std::string>().c_str());
}
} else if (key == _tokens->instantaneousShutter) {
_CheckForBoolValue(value, [&](const bool b) { AiNodeSetBool(_options, str::ignore_motion_blur, b); });
} else if (key == str::t_houdiniFps) {
Expand Down Expand Up @@ -937,6 +965,12 @@ VtValue HdArnoldRenderDelegate::GetRenderSetting(const TfToken& _key) const
return VtValue(ArnoldUsdGetLogVerbosityFromFlags(_verbosityLogFlags));
} else if (key == str::t_log_file) {
return VtValue(_logFile);
} else if (key == str::t_stats_file) {
return VtValue(_statsFile);
} else if (key == str::t_stats_mode) {
return VtValue(static_cast<int>(_statsMode));
} else if (key == str::t_profile_file) {
return VtValue(_profileFile);
} else if (key == str::t_interactive_target_fps) {
float v = 1.0f;
AiRenderGetHintFlt(GetRenderSession(), str::interactive_target_fps, v);
Expand Down
3 changes: 3 additions & 0 deletions libs/render_delegate/render_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
AtNode* _fallbackVolumeShader = nullptr; ///< Pointer to the fallback Arnold Volume Shader.
AtNode* _procParent = nullptr;
std::string _logFile;
std::string _statsFile;
AtStatsMode _statsMode;
std::string _profileFile;
AtString _pxrMtlxPath;

std::mutex _meshLightsMutex;
Expand Down

0 comments on commit ab33049

Please sign in to comment.