Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-104552 improve diagnostics #2799

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <mayaUsd/nodes/proxyShapeStageExtraData.h>
#include <mayaUsd/nodes/stageData.h>
#include <mayaUsd/utils/customLayerData.h>
#include <mayaUsd/utils/diagnosticDelegate.h>
#include <mayaUsd/utils/layerMuting.h>
#include <mayaUsd/utils/loadRules.h>
#include <mayaUsd/utils/query.h>
Expand Down
30 changes: 23 additions & 7 deletions lib/mayaUsd/python/wrapDiagnosticDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,27 @@ PXR_NAMESPACE_USING_DIRECTIVE;

namespace {

// This exposes UsdMayaDiagnosticBatchContext as a Python "context manager"
// object that can be used with the "with"-statement.
// This exposes a DiagnosticBatchContext as a Python "context manager"
// object that can be used with the "with"-statement to flush diagostic
// messages
class _PyDiagnosticBatchContext
{
public:
void __enter__() { _context.reset(new UsdMayaDiagnosticBatchContext()); }
void __exit__(object, object, object) { _context.reset(); }
_PyDiagnosticBatchContext() { }
_PyDiagnosticBatchContext(int c)
: _count(c)
{
}
void __enter__() { UsdMayaDiagnosticDelegate::SetMaximumUnbatchedDiagnostics(_count); }
void __exit__(object, object, object)
{
UsdMayaDiagnosticDelegate::Flush();
UsdMayaDiagnosticDelegate::SetMaximumUnbatchedDiagnostics(_previousCount);
}

private:
std::unique_ptr<UsdMayaDiagnosticBatchContext> _context;
int _count = 0;
int _previousCount = UsdMayaDiagnosticDelegate::GetMaximumUnbatchedDiagnostics();
};

} // anonymous namespace
Expand All @@ -46,11 +57,16 @@ void wrapDiagnosticDelegate()
{
typedef UsdMayaDiagnosticDelegate This;
class_<This, boost::noncopyable>("DiagnosticDelegate", no_init)
.def("GetBatchCount", &This::GetBatchCount)
.staticmethod("GetBatchCount");
.def("Flush", &This::Flush)
.staticmethod("Flush")
.def("SetMaximumUnbatchedDiagnostics", &This::SetMaximumUnbatchedDiagnostics)
.staticmethod("SetMaximumUnbatchedDiagnostics")
.def("GetMaximumUnbatchedDiagnostics", &This::GetMaximumUnbatchedDiagnostics)
.staticmethod("GetMaximumUnbatchedDiagnostics");

typedef _PyDiagnosticBatchContext Context;
class_<Context, boost::noncopyable>("DiagnosticBatchContext")
.def(init<int>())
.def("__enter__", &Context::__enter__, return_self<>())
.def("__exit__", &Context::__exit__);
}
10 changes: 0 additions & 10 deletions lib/mayaUsd/render/pxrUsdMayaGL/batchRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,21 +1374,11 @@ bool UsdMayaGLBatchRenderer::_UpdateIsSelectionPending(const bool isPending)
return true;
}

void UsdMayaGLBatchRenderer::StartBatchingFrameDiagnostics()
{
if (!_sharedDiagBatchCtx) {
_sharedDiagBatchCtx.reset(new UsdMayaDiagnosticBatchContext());
}
}

void UsdMayaGLBatchRenderer::_MayaRenderDidEnd(const MHWRender::MDrawContext* /* context */)
{
// Completing a viewport render invalidates any previous selection
// computation we may have done, so mark a new one as pending.
_UpdateIsSelectionPending(true);

// End any diagnostics batching.
_sharedDiagBatchCtx.reset();
}

PXR_NAMESPACE_CLOSE_SCOPE
12 changes: 0 additions & 12 deletions lib/mayaUsd/render/pxrUsdMayaGL/batchRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,6 @@ class UsdMayaGLBatchRenderer
MAYAUSD_CORE_PUBLIC
inline bool GetObjectSoftSelectEnabled() { return _objectSoftSelectEnabled; }

/// Starts batching all diagnostics until the end of the current frame draw.
/// The batch renderer will automatically release the diagnostics when Maya
/// is done rendering the frame.
MAYAUSD_CORE_PUBLIC
void StartBatchingFrameDiagnostics();

private:
friend class TfSingleton<UsdMayaGLBatchRenderer>;

Expand Down Expand Up @@ -479,12 +473,6 @@ class UsdMayaGLBatchRenderer
HdxSelectionTrackerSharedPtr _selectionTracker;

UsdMayaGLSoftSelectHelper _softSelectHelper;

/// Shared diagnostic batch context. Used for cases where we want to batch
/// diagnostics across multiple function calls, e.g., batching all of the
/// Sync() diagnostics across all prepareForDraw() callbacks in a single
/// frame.
std::unique_ptr<UsdMayaDiagnosticBatchContext> _sharedDiagBatchCtx;
};

MAYAUSD_TEMPLATE_CLASS(TfSingleton<UsdMayaGLBatchRenderer>);
Expand Down
4 changes: 0 additions & 4 deletions lib/mayaUsd/render/pxrUsdMayaGL/shapeAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ bool PxrMayaHdShapeAdapter::Sync(
{
// Legacy viewport implementation.

UsdMayaGLBatchRenderer::GetInstance().StartBatchingFrameDiagnostics();

const unsigned int displayStyle
= px_LegacyViewportUtils::GetMFrameContextDisplayStyle(legacyDisplayStyle);
const MHWRender::DisplayStatus displayStatus = _ToMHWRenderDisplayStatus(legacyDisplayStatus);
Expand Down Expand Up @@ -135,8 +133,6 @@ bool PxrMayaHdShapeAdapter::Sync(
{
// Viewport 2.0 implementation.

UsdMayaGLBatchRenderer::GetInstance().StartBatchingFrameDiagnostics();

TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE)
.Msg("Synchronizing PxrMayaHdShapeAdapter for Viewport 2.0: %p\n", this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <mayaUsd/base/tokens.h>
#include <mayaUsd/nodes/proxyShapeBase.h>
#include <mayaUsd/nodes/stageData.h>
#include <mayaUsd/utils/diagnosticDelegate.h>
#include <mayaUsd/utils/selectability.h>

#include <pxr/base/tf/diagnostic.h>
Expand Down
Loading