Skip to content

Commit

Permalink
Add northstar support (#297)
Browse files Browse the repository at this point in the history
* Add northstar support

* Disable opacity AOV when using Northstar
  • Loading branch information
hshakula authored Jun 22, 2020
1 parent ff27fff commit a810809
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 19 deletions.
9 changes: 7 additions & 2 deletions cmake/modules/FindRpr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ if(WIN32)
set(RPR_HYBRID_BINARY ${RPR_BIN_LOCATION}/Hybrid.dll)
endif()

if (EXISTS "${RPR_BIN_LOCATION}/Northstar64.dll")
set(RPR_NORTHSTAR_BINARY ${RPR_BIN_LOCATION}/Northstar64.dll)
endif()

set(RPR_BINARIES
${RPR_BIN_LOCATION}/RadeonProRender64.dll
${RPR_BIN_LOCATION}/RprLoadStore64.dll
${RPR_TAHOE_BINARY}
${RPR_HYBRID_BINARY})
${RPR_HYBRID_BINARY}
${RPR_NORTHSTAR_BINARY})
else()
find_library(RPR_HYBRID_BINARY
NAMES Hybrid${CMAKE_SHARED_LIBRARY_SUFFIX}
Expand Down Expand Up @@ -90,7 +95,7 @@ else()
endif()
endif(WIN32)

if(NOT RPR_TAHOE_BINARY AND NOT RPR_HYBRID_BINARY)
if(NOT RPR_TAHOE_BINARY AND NOT RPR_HYBRID_BINARY AND NOT RPR_NORTHSTAR_BINARY)
message(FATAL_ERROR "At least one RPR plugin required")
endif()

Expand Down
4 changes: 4 additions & 0 deletions pxr/imaging/plugin/hdRpr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ if(HoudiniUSD_FOUND)
RENAME plugInfo.json)
endif()

if(RPR_NORTHSTAR_BINARY)
set(GEN_SCRIPT_ARGS --northstar ${GEN_SCRIPT_ARGS})
endif()

add_custom_command(
COMMAND ${GEN_SCRIPT_PYTHON} ${GEN_SCRIPT} ${GEN_SCRIPT_ARGS}
DEPENDS ${GENERATION_DEPENDENT_FILES}
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/plugin/hdRpr/python/generateFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
p.add_argument('scripts_dir', help="Directory with scripts")
p.add_argument("install", help="The install root for generated files.")
p.add_argument("--houdini_root", help="The install root for generated files.")
p.add_argument('--northstar', default=False, action='store_true', help='Whether enable northstar render setting or not')
args = p.parse_args()

generate_ds_files = []
Expand All @@ -29,5 +30,5 @@
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + os.pathsep + os.path.join(os.path.join(args.houdini_root, 'houdini'), 'python2.7libs')

subprocess.check_call([sys.executable, os.path.join(args.scripts_dir, 'generateLightSettingFiles.py'), args.install] + generate_ds_files)
subprocess.check_call([sys.executable, os.path.join(args.scripts_dir, 'generateRenderSettingFiles.py'), args.install] + generate_ds_files)
subprocess.check_call([sys.executable, os.path.join(args.scripts_dir, 'generateRenderSettingFiles.py'), args.install] + generate_ds_files + (['--northstar'] if args.northstar else []))
subprocess.check_call([sys.executable, os.path.join(args.scripts_dir, 'generateGeometrySettingFiles.py'), args.install] + generate_ds_files)
16 changes: 13 additions & 3 deletions pxr/imaging/plugin/hdRpr/python/generateRenderSettingFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def hidewhen_not_ambient_occlusion_mode(render_setting_categories):
{
'name': 'Device',
'houdini': {
'hidewhen': 'renderQuality != 3'
'hidewhen': 'renderQuality < 3'
},
'settings': [
{
Expand Down Expand Up @@ -138,7 +138,7 @@ def hidewhen_not_ambient_occlusion_mode(render_setting_categories):
{
'name': 'AdaptiveSampling',
'houdini': {
'hidewhen': 'renderQuality != 3'
'hidewhen': 'renderQuality < 3'
},
'settings': [
{
Expand All @@ -162,7 +162,7 @@ def hidewhen_not_ambient_occlusion_mode(render_setting_categories):
{
'name': 'Quality',
'houdini': {
'hidewhen': 'renderQuality != 3'
'hidewhen': 'renderQuality < 3'
},
'settings': [
{
Expand Down Expand Up @@ -661,6 +661,16 @@ class HdRprConfig {{
p = argparse.ArgumentParser()
p.add_argument("install", help="The install root for generated files.")
p.add_argument("--generate_ds_files", default=False, action='store_true')
p.add_argument('--northstar', default=False, action='store_true', help='Whether enable northstar render setting or not')
args = p.parse_args()

if args.northstar:
for category in render_setting_categories:
if category['name'] == 'RenderQuality':
for setting in category['settings']:
if setting['name'] == 'renderQuality':
setting['values'].append('Northstar')
break
break

generate_render_setting_files(args.install, args.generate_ds_files)
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdRpr/rifcpp/rifContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ std::unique_ptr<Context> Context::Create(rpr::Context* rprContext, rpr::ContextM
try {
std::unique_ptr<Context> rifContext;
if (HasGpuContext(contextFlags) &&
rprContextMetadata.pluginType != rpr::kPluginHybrid &&
rprContextMetadata.pluginType == rpr::kPluginTahoe &&
!(contextFlags & RPR_CREATION_FLAGS_ENABLE_METAL)) {
rifContext.reset(new ContextOpenCL(rprContext, modelPath));
} else {
Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/plugin/hdRpr/rpr/contextHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ rpr::CreationFlags getAllCompatibleGpuFlags(rpr_int pluginID, const char* cacheP
}
if (infoStatus != RPR_SUCCESS) {
PRINT_CONTEXT_CREATION_DEBUG_INFO("Failed to query device name: %d\n", infoStatus);
return false;
}

rprObjectDelete(temporaryContext);
Expand Down
39 changes: 27 additions & 12 deletions pxr/imaging/plugin/hdRpr/rprApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,13 @@ class HdRprApiImpl {
InitRif();
InitScene();
InitCamera();
InitAovs();

m_state = kStateRender;
} catch (rpr::Error& e) {
TF_RUNTIME_ERROR("%s", e.what());
m_state = kStateInvalid;
} catch (rif::Error& e) {
TF_RUNTIME_ERROR("%s", e.what());
m_state = kStateInvalid;
}
}

UpdateRestartRequiredMessageStatus();
}
Expand Down Expand Up @@ -1104,10 +1102,9 @@ class HdRprApiImpl {

if (config->IsDirty(HdRprConfig::DirtyRenderQuality)) {
auto quality = config->GetRenderQuality();

auto newPlugin = GetPluginType(quality);
auto activePlugin = m_rprContextMetadata.pluginType;
if ((activePlugin == rpr::kPluginTahoe && quality < kRenderQualityFull) ||
(activePlugin == rpr::kPluginHybrid && quality == kRenderQualityFull)) {
if (newPlugin != activePlugin) {
restartRequired = true;
}
}
Expand All @@ -1119,6 +1116,8 @@ class HdRprApiImpl {
RenderQualityType currentRenderQuality;
if (m_rprContextMetadata.pluginType == rpr::kPluginTahoe) {
currentRenderQuality = kRenderQualityFull;
} else if (m_rprContextMetadata.pluginType == rpr::kPluginNorthStar) {
currentRenderQuality = static_cast<RenderQualityType>(int(kRenderQualityFull) + 1);
} else {
rpr_uint currentHybridQuality = RPR_RENDER_QUALITY_HIGH;
size_t dummy;
Expand Down Expand Up @@ -1235,12 +1234,18 @@ class HdRprApiImpl {

if (preferences.IsDirty(HdRprConfig::DirtyAlpha) || force) {
m_isAlphaEnabled = preferences.GetEnableAlpha();
if (m_rprContextMetadata.pluginType == rpr::kPluginNorthStar) {
// Disable opacity AOV in Northstar because it's always zeroed
m_isAlphaEnabled = false;
}

UpdateColorAlpha();
}

m_currentRenderQuality = preferences.GetRenderQuality();

if (m_rprContextMetadata.pluginType == rpr::kPluginTahoe) {
if (m_rprContextMetadata.pluginType == rpr::kPluginTahoe ||
m_rprContextMetadata.pluginType == rpr::kPluginNorthStar) {
UpdateTahoeSettings(preferences, force);
} else if (m_rprContextMetadata.pluginType == rpr::kPluginHybrid) {
UpdateHybridSettings(preferences, force);
Expand Down Expand Up @@ -1732,6 +1737,16 @@ Don't show this message again?
}

private:
static rpr::PluginType GetPluginType(RenderQualityType renderQuality) {
if (renderQuality == kRenderQualityFull) {
return rpr::kPluginTahoe;
} else if (renderQuality == int(kRenderQualityFull) + 1) {
return rpr::kPluginNorthStar;
} else {
return rpr::kPluginHybrid;
}
}

void InitRpr() {
RenderQualityType renderQuality;
{
Expand All @@ -1744,7 +1759,8 @@ Don't show this message again?
m_rprContextMetadata.renderDeviceType = static_cast<rpr::RenderDeviceType>(config->GetRenderDevice());
}

m_rprContextMetadata.pluginType = renderQuality == kRenderQualityFull ? rpr::kPluginTahoe : rpr::kPluginHybrid;
m_rprContextMetadata.pluginType = GetPluginType(renderQuality);

auto cachePath = HdRprApi::GetCachePath();
m_rprContext.reset(rpr::CreateContext(cachePath.c_str(), &m_rprContextMetadata));
if (!m_rprContext) {
Expand Down Expand Up @@ -1787,10 +1803,9 @@ Don't show this message again?
}

m_rifContext = rif::Context::Create(m_rprContext.get(), m_rprContextMetadata, modelsPath);
if (!m_rifContext) {
return;
}
}

void InitAovs() {
auto initInternalAov = [this](TfToken const& name) {
auto& aovDesc = HdRprAovRegistry::GetInstance().GetAovDesc(name);
if (auto aov = CreateAov(name, 0, 0, aovDesc.format)) {
Expand Down

0 comments on commit a810809

Please sign in to comment.