Skip to content

Commit

Permalink
hdGatling: steer progressive rendering using render settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pablode committed Nov 2, 2024
1 parent 27c2ac6 commit d3492e9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/gatling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <pxr/imaging/hd/renderPassState.h>
#include <pxr/imaging/hd/renderBuffer.h>
#include <pxr/imaging/hd/renderIndex.h>
#include <pxr/imaging/hd/tokens.h>
#include <pxr/imaging/hf/pluginDesc.h>
#include <pxr/imaging/hgi/hgi.h>
#include <pxr/imaging/hgi/tokens.h>
Expand Down Expand Up @@ -111,6 +112,8 @@ int main(int argc, const char* argv[])
HdRenderDelegate* renderDelegate = plugin->CreateRenderDelegate();
TF_AXIOM(renderDelegate);

renderDelegate->SetRenderSetting(HdRenderSettingsTokens->enableInteractive, VtValue(false));

// Handle cmdline args.
AppSettings settings;
if (!ParseArgs(argc, argv, *renderDelegate, settings))
Expand Down
2 changes: 1 addition & 1 deletion src/hdGatling/renderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ HdRenderSettingDescriptorList HdGatlingRenderDelegate::GetRenderSettingDescripto
return _settingDescriptors;
}

void HdGatlingRenderDelegate::SetRenderSetting(TfToken const& key, VtValue const& value)
void HdGatlingRenderDelegate::SetRenderSetting(const TfToken& key, const VtValue& value)
{
#ifdef NDEBUG
// Disallow changing debug render settings in release config.
Expand Down
2 changes: 1 addition & 1 deletion src/hdGatling/renderDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HdGatlingRenderDelegate final : public HdRenderDelegate
public:
HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override;

void SetRenderSetting(TfToken const& key, VtValue const& value) override;
void SetRenderSetting(const TfToken& key, const VtValue& value) override;

HdCommandDescriptors GetCommandDescriptors() const override;

Expand Down
41 changes: 40 additions & 1 deletion src/hdGatling/renderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <pxr/base/gf/matrix3d.h>
#include <pxr/base/gf/camera.h>

#include <gtl/gb/Log.h>
#include <gtl/gi/Gi.h>

PXR_NAMESPACE_OPEN_SCOPE
Expand Down Expand Up @@ -88,6 +89,44 @@ namespace

return id;
}

bool _IsInteractive(const HdRenderSettingsMap& settings)
{
auto settingIt = settings.find(HdRenderSettingsTokens->enableInteractive);
if (settingIt != settings.end())
{
return settingIt->second.Get<bool>();
}

// https://www.sidefx.com/docs/hdk/_h_d_k__u_s_d_hydra.html#HDK_USDHydraCustomSettingsInteractive
const static TfToken houdiniInteractive("houdini:interactive", TfToken::Immortal);
settingIt = settings.find(houdiniInteractive);

if (settingIt != settings.end())
{
const VtValue& val = settingIt->second;

const char* str = nullptr;
if (val.IsHolding<std::string>())
{
str = val.UncheckedGet<std::string>().c_str();
}
else if (val.IsHolding<TfToken>())
{
str = val.UncheckedGet<TfToken>().GetText();
}
else
{
// FIXME: might need to build against Houdini SDK and extract UT_StringHolder in this case
GB_ERROR("failed to get string from houdini:interactive setting");
return false;
}

return strcmp(str, "normal") != 0;
}

return false;
}
}

HdGatlingRenderPass::HdGatlingRenderPass(HdRenderIndex* index,
Expand Down Expand Up @@ -231,7 +270,7 @@ void HdGatlingRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassS

renderBuffer->Unmap();

_isConverged = true;
_isConverged = !_IsInteractive(_settings);
}

PXR_NAMESPACE_CLOSE_SCOPE

0 comments on commit d3492e9

Please sign in to comment.