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

[hd, hdx] Move tracing macros in InsertTask<T> #3000

Merged
merged 2 commits into from
May 17, 2024
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
9 changes: 7 additions & 2 deletions pxr/imaging/hd/renderIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,17 @@ HdRenderIndex::_Clear()

void
HdRenderIndex::_TrackDelegateTask(HdSceneDelegate* delegate,
SdfPath const& taskId,
HdTaskSharedPtr const& task)
SdfPath const& taskId,
HdTaskCreateFnc taskCreateFnc)
{
HD_TRACE_FUNCTION();
HF_MALLOC_TAG_FUNCTION();

if (taskId == SdfPath()) {
return;
}

HdTaskSharedPtr task = taskCreateFnc(delegate, taskId);
_tracker.TaskInserted(taskId, task->GetInitialDirtyBitsMask());
_taskMap.emplace(taskId, _TaskInfo{delegate, task});
}
Expand Down
14 changes: 9 additions & 5 deletions pxr/imaging/hd/renderIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,16 @@ class HdRenderIndex final
// Allocate the next available instance id to the prim
void _AllocatePrimId(HdRprim* prim);

using HdTaskCreateFnc =
std::function<HdTaskSharedPtr(HdSceneDelegate*, SdfPath const&)>;

// Inserts the task into the index and updates tracking state.
// _TrackDelegateTask is called by the inlined InsertTask<T>, so it needs
// to be marked HD_API.
HD_API
void _TrackDelegateTask(HdSceneDelegate* delegate,
SdfPath const& taskId,
HdTaskSharedPtr const& task);
HdTaskCreateFnc taskCreateFnc);

template <typename T>
static inline const TfToken & _GetTypeId();
Expand Down Expand Up @@ -593,11 +596,12 @@ template <typename T>
void
HdRenderIndex::InsertTask(HdSceneDelegate* delegate, SdfPath const& id)
{
HD_TRACE_FUNCTION();
HF_MALLOC_TAG_FUNCTION();
auto createTask = [](HdSceneDelegate* _delegate, SdfPath const& _id) -> HdTaskSharedPtr
{
return std::make_shared<T>(_delegate, _id);
};

HdTaskSharedPtr task = std::make_shared<T>(delegate, id);
_TrackDelegateTask(delegate, id, task);
_TrackDelegateTask(delegate, id, createTask);
}

PXR_NAMESPACE_CLOSE_SCOPE
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/hdx/unitTestDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ TF_DEFINE_PRIVATE_TOKENS(
_tokens,

(renderBufferDescriptor)
);
);


static void
_CreateGrid(int nx, int ny, VtVec3fArray *points,
Expand Down