Skip to content

Commit

Permalink
HdPrman:
Browse files Browse the repository at this point in the history
Moving stopping the renderer and increasing sceneVersion from HdPrman_RenederParam::AcquireContext to HdPrman_Context::AcquireRiley.
Clients trying to edit riley are forced to stop the renderer because HdPrman_Context::riley is now protected on the context.

Motivation: Change 2193331 demonstrated that there legimate cases where we need to access the context without stopping the renderer.

Since the HdPrman_InteractiveRenderPass now also has to call AcquireRiley, the flag needsStartRender local to _Execute or explicit calls to stop the rendeer are no longer needed since these edits to riley are treated like any other edit.

(Internal change: 2193522)
(Internal change: 2193551)
  • Loading branch information
unhyperbolic authored and pixar-oss committed Nov 5, 2021
1 parent ce6dc3b commit e7bd168
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 213 deletions.
1 change: 0 additions & 1 deletion third_party/renderman-24/plugin/hdPrman/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pxr_plugin(${PXR_PACKAGE}
renderParam.h

PRIVATE_HEADERS
interactiveRenderParam.h
virtualStructConditionalGrammar.tab.h

CPPFILES
Expand Down
7 changes: 3 additions & 4 deletions third_party/renderman-24/plugin/hdPrman/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ TF_MAKE_STATIC_DATA(std::vector<HdPrman_Context::IntegratorCameraCallback>,
}

HdPrman_Context::HdPrman_Context() :
riley(nullptr),
_rix(nullptr),
_ri(nullptr),
_mgr(nullptr),
_riley(nullptr),
_instantaneousShutter(false)
{
/* NOTHING */
}

HdPrman_Context::~HdPrman_Context() = default;
Expand Down Expand Up @@ -1470,8 +1469,8 @@ HdPrman_Context::_InitializePrman()

// Acquire Riley instance.
_mgr = (RixRileyManager*)_rix->GetRixInterface(k_RixRileyManager);
riley = _mgr->CreateRiley(RtUString(rileyvariant.c_str()), RtParamList());
if(!riley) {
_riley = _mgr->CreateRiley(RtUString(rileyvariant.c_str()), RtParamList());
if(!_riley) {
TF_RUNTIME_ERROR("Could not initialize riley API.");
return;
}
Expand Down
8 changes: 5 additions & 3 deletions third_party/renderman-24/plugin/hdPrman/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ struct HdPrman_Context
TfToken const& role,
RtParamList& params);

// Riley instance.
riley::Riley *riley;

// Request edit access to the Riley scene and return it.
virtual riley::Riley * AcquireRiley() = 0;
// A fallback material to use for any geometry that
// does not have a bound material.
riley::MaterialId fallbackMaterial;
Expand Down Expand Up @@ -197,6 +196,9 @@ struct HdPrman_Context
// Xcpt Handler
HdPrman_Xcpt _xcpt;

// Riley instance.
riley::Riley *_riley;

private:
// Refcounts for each category mentioned by a light link.
// This is used to convey information from lights back to the
Expand Down
12 changes: 5 additions & 7 deletions third_party/renderman-24/plugin/hdPrman/coordSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,20 @@ HdPrmanCoordSys::HdPrmanCoordSys(SdfPath const& id)
/* NOTHING */
}

HdPrmanCoordSys::~HdPrmanCoordSys()
{
}
HdPrmanCoordSys::~HdPrmanCoordSys() = default;

void
HdPrmanCoordSys::Finalize(HdRenderParam *renderParam)
{
HdPrman_Context *context =
static_cast<HdPrman_RenderParam*>(renderParam)->AcquireContext();
static_cast<HdPrman_RenderParam*>(renderParam)->GetContext();
_ResetCoordSys(context);
}

void
HdPrmanCoordSys::_ResetCoordSys(HdPrman_Context *context)
{
riley::Riley *riley = context->riley;
riley::Riley *riley = context->AcquireRiley();
if (_coordSysId != riley::CoordinateSystemId::InvalidId()) {
riley->DeleteCoordinateSystem(_coordSysId);
_coordSysId = riley::CoordinateSystemId::InvalidId();
Expand All @@ -70,11 +68,11 @@ HdPrmanCoordSys::Sync(HdSceneDelegate *sceneDelegate,
HdDirtyBits *dirtyBits)
{
HdPrman_Context *context =
static_cast<HdPrman_RenderParam*>(renderParam)->AcquireContext();
static_cast<HdPrman_RenderParam*>(renderParam)->GetContext();

SdfPath id = GetId();

riley::Riley *riley = context->riley;
riley::Riley *riley = context->AcquireRiley();

if (*dirtyBits) {
// Sample transform
Expand Down
21 changes: 10 additions & 11 deletions third_party/renderman-24/plugin/hdPrman/gprim.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
#include "pxr/pxr.h"
#include "pxr/imaging/hd/enums.h"
#include "pxr/usd/sdf/types.h"
#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/gf/matrix4d.h"

#include "hdPrman/context.h"
#include "hdPrman/instancer.h"
#include "hdPrman/material.h"
#include "hdPrman/renderParam.h"
#include "hdPrman/renderPass.h"
#include "hdPrman/rixStrings.h"

#include "Riley.h"
Expand All @@ -46,24 +44,25 @@ PXR_NAMESPACE_OPEN_SCOPE
/// A mix-in template that adds shared gprim behavior to support
/// various HdRprim types.
template <typename BASE>
class HdPrman_Gprim : public BASE {
class HdPrman_Gprim : public BASE
{
public:
typedef BASE BaseType;
using BaseType = BASE;

HdPrman_Gprim(SdfPath const& id)
: BaseType(id)
{
}

virtual ~HdPrman_Gprim() = default;
~HdPrman_Gprim() override = default;

void
Finalize(HdRenderParam *renderParam) override
{
HdPrman_Context *context =
static_cast<HdPrman_RenderParam*>(renderParam)->AcquireContext();
static_cast<HdPrman_RenderParam*>(renderParam)->GetContext();

riley::Riley *riley = context->riley;
riley::Riley *riley = context->AcquireRiley();

// Release retained conversions of coordSys bindings.
context->ReleaseCoordSysBindings(BASE::GetId());
Expand Down Expand Up @@ -149,7 +148,10 @@ HdPrman_Gprim<BASE>::Sync(HdSceneDelegate* sceneDelegate,
TF_UNUSED(reprToken);

HdPrman_Context *context =
static_cast<HdPrman_RenderParam*>(renderParam)->AcquireContext();
static_cast<HdPrman_RenderParam*>(renderParam)->GetContext();

// Riley API.
riley::Riley *riley = context->AcquireRiley();

// Update instance bindings.
BASE::_UpdateInstancer(sceneDelegate, dirtyBits);
Expand All @@ -168,9 +170,6 @@ HdPrman_Gprim<BASE>::Sync(HdSceneDelegate* sceneDelegate,
HdTimeSampleArray<GfMatrix4d, HDPRMAN_MAX_TIME_SAMPLES> xf;
sceneDelegate->SampleTransform(id, &xf);

// Riley API.
riley::Riley *riley = context->riley;

// Resolve material binding. Default to fallbackGprimMaterial.
if (*dirtyBits & HdChangeTracker::DirtyMaterialId) {
#if HD_API_VERSION < 37
Expand Down
Loading

0 comments on commit e7bd168

Please sign in to comment.