Skip to content

Commit

Permalink
Hydrogent: renamed HnRenderTask to HnRenderRprimsTask
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 19, 2023
1 parent dfee169 commit 73a6f42
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions Hydrogent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(SOURCE
src/HnTextureUtils.cpp
src/HnTypeConversions.cpp
src/Tasks/HnTask.cpp
src/Tasks/HnRenderTask.cpp
src/Tasks/HnRenderRprimsTask.cpp
src/Tasks/HnPostProcessTask.cpp
src/Tasks/HnTaskController.cpp
)
Expand All @@ -36,7 +36,7 @@ set(INCLUDE
include/HnTextureUtils.hpp
include/HnTypeConversions.hpp
include/Tasks/HnTask.hpp
include/Tasks/HnRenderTask.hpp
include/Tasks/HnRenderRprimsTask.hpp
include/Tasks/HnPostProcessTask.hpp
include/Tasks/HnTaskController.hpp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ namespace Diligent
namespace USD
{

struct HnRenderTaskParams
struct HnRenderRprimsTaskParams
{
constexpr bool operator==(const HnRenderTaskParams& rhs) const
constexpr bool operator==(const HnRenderRprimsTaskParams& rhs) const
{
return true;
}
constexpr bool operator!=(const HnRenderTaskParams& rhs) const
constexpr bool operator!=(const HnRenderRprimsTaskParams& rhs) const
{
return !(*this == rhs);
}
};

/// Render task implementation in Hydrogent.
class HnRenderTask final : public HnTask
class HnRenderRprimsTask final : public HnTask
{
public:
using TaskSharedPtr = std::shared_ptr<HnRenderTask>;
using TaskSharedPtr = std::shared_ptr<HnRenderRprimsTask>;

static TaskSharedPtr Create(pxr::HdSceneDelegate& ParamsDelegate, const pxr::SdfPath& Id);

HnRenderTask(pxr::HdSceneDelegate* ParamsDelegate, const pxr::SdfPath& Id);
~HnRenderTask();
HnRenderRprimsTask(pxr::HdSceneDelegate* ParamsDelegate, const pxr::SdfPath& Id);
~HnRenderRprimsTask();

virtual void Sync(pxr::HdSceneDelegate* Delegate,
pxr::HdTaskContext* TaskCtx,
Expand Down
24 changes: 12 additions & 12 deletions Hydrogent/include/Tasks/HnTaskController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ namespace Diligent
namespace USD
{

struct HnRenderTaskParams;
struct HnRenderRprimsTaskParams;
struct HnPostProcessTaskParams;

/// Task controller implementation in Hydrogent.
class HnTaskController
{
public:
using TaskUID = uint64_t;
static constexpr TaskUID TaskUID_RenderDefault = 0x287af907f3a740a0;
static constexpr TaskUID TaskUID_RenderMasked = 0xf5290fec47594711;
static constexpr TaskUID TaskUID_RenderAdditive = 0x37d45531106c4c52;
static constexpr TaskUID TaskUID_RenderTranslucent = 0xa015c7e45941407e;
static constexpr TaskUID TaskUID_PostProcess = 0x1f5367e65d034500;
using TaskUID = uint64_t;
static constexpr TaskUID TaskUID_RenderRprimsDefault = 0x287af907f3a740a0;
static constexpr TaskUID TaskUID_RenderRprimsMasked = 0xf5290fec47594711;
static constexpr TaskUID TaskUID_RenderRprimsAdditive = 0x37d45531106c4c52;
static constexpr TaskUID TaskUID_RenderRprimsTranslucent = 0xa015c7e45941407e;
static constexpr TaskUID TaskUID_PostProcess = 0x1f5367e65d034500;

HnTaskController(pxr::HdRenderIndex& RenderIndex,
const pxr::SdfPath& ControllerId);
Expand All @@ -79,7 +79,7 @@ class HnTaskController
void SetCollection(const pxr::HdRprimCollection& Collection);

/// Sets new params for the render tasks.
void SetRenderParams(const HnRenderTaskParams& Params);
void SetRenderParams(const HnRenderRprimsTaskParams& Params);

/// Sets new params for the post-process task.
void SetPostProcessParams(const HnPostProcessTaskParams& Params);
Expand All @@ -99,9 +99,9 @@ class HnTaskController
void RemoveTask(TaskUID UID);

private:
pxr::SdfPath GetRenderTaskId(const pxr::TfToken& MaterialTag) const;
pxr::SdfPath GetRenderRprimsTaskId(const pxr::TfToken& MaterialTag) const;

void CreateRenderTask(const pxr::TfToken& MaterialTag, TaskUID UID);
void CreateRenderRprimsTask(const pxr::TfToken& MaterialTag, TaskUID UID);
void CreatePostProcessTask();

private:
Expand All @@ -122,9 +122,9 @@ template <typename TaskType>
void HnTaskController::CreateTask(const pxr::SdfPath& TaskId,
TaskUID UID)
{
m_RenderIndex.InsertTask<HnRenderTask>(m_ParamsDelegate.get(), TaskId);
m_RenderIndex.InsertTask<HnRenderRprimsTask>(m_ParamsDelegate.get(), TaskId);
auto it_inserted = m_TaskUIDs.emplace(UID, TaskId);
VERIFY(!it_inserted.second, "Task with UID ", UID, " already exists: ", it_inserted.first->second.GetText());
VERIFY(it_inserted.second, "Task with UID ", UID, " already exists: ", it_inserted.first->second.GetText());
}

} // namespace USD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,40 @@
* of the possibility of such damages.
*/

#include "Tasks/HnRenderTask.hpp"
#include "Tasks/HnRenderRprimsTask.hpp"

namespace Diligent
{

namespace USD
{

HnRenderTask::TaskSharedPtr HnRenderTask::Create(pxr::HdSceneDelegate& ParamsDelegate, const pxr::SdfPath& Id)
HnRenderRprimsTask::TaskSharedPtr HnRenderRprimsTask::Create(pxr::HdSceneDelegate& ParamsDelegate, const pxr::SdfPath& Id)
{
return TaskSharedPtr(new HnRenderTask{&ParamsDelegate, Id});
return TaskSharedPtr(new HnRenderRprimsTask{&ParamsDelegate, Id});
}

HnRenderTask::HnRenderTask(pxr::HdSceneDelegate* ParamsDelegate, const pxr::SdfPath& Id) :
HnRenderRprimsTask::HnRenderRprimsTask(pxr::HdSceneDelegate* ParamsDelegate, const pxr::SdfPath& Id) :
HnTask{Id}
{
}

HnRenderTask::~HnRenderTask()
HnRenderRprimsTask::~HnRenderRprimsTask()
{
}

void HnRenderTask::Sync(pxr::HdSceneDelegate* Delegate,
pxr::HdTaskContext* TaskCtx,
pxr::HdDirtyBits* DirtyBits)
void HnRenderRprimsTask::Sync(pxr::HdSceneDelegate* Delegate,
pxr::HdTaskContext* TaskCtx,
pxr::HdDirtyBits* DirtyBits)
{
}

void HnRenderTask::Prepare(pxr::HdTaskContext* TaskCtx,
pxr::HdRenderIndex* RenderIndex)
void HnRenderRprimsTask::Prepare(pxr::HdTaskContext* TaskCtx,
pxr::HdRenderIndex* RenderIndex)
{
}

void HnRenderTask::Execute(pxr::HdTaskContext* TaskCtx)
void HnRenderRprimsTask::Execute(pxr::HdTaskContext* TaskCtx)
{
}

Expand Down
42 changes: 21 additions & 21 deletions Hydrogent/src/Tasks/HnTaskController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <atomic>
#include <array>

#include "Tasks/HnRenderTask.hpp"
#include "Tasks/HnRenderRprimsTask.hpp"
#include "Tasks/HnPostProcessTask.hpp"
#include "HnTokens.hpp"
#include "HashUtils.hpp"
Expand Down Expand Up @@ -167,19 +167,19 @@ HnTaskController::HnTaskController(pxr::HdRenderIndex& RenderIndex,
m_ControllerId{ControllerId},
m_ParamsDelegate{std::make_unique<TaskParamsDelegate>(RenderIndex, ControllerId)}
{
CreateRenderTask(HnMaterialTagTokens->defaultTag, TaskUID_RenderDefault);
CreateRenderTask(HnMaterialTagTokens->masked, TaskUID_RenderMasked);
CreateRenderTask(HnMaterialTagTokens->additive, TaskUID_RenderAdditive);
CreateRenderTask(HnMaterialTagTokens->translucent, TaskUID_RenderTranslucent);
CreateRenderRprimsTask(HnMaterialTagTokens->defaultTag, TaskUID_RenderRprimsDefault);
CreateRenderRprimsTask(HnMaterialTagTokens->masked, TaskUID_RenderRprimsMasked);
CreateRenderRprimsTask(HnMaterialTagTokens->additive, TaskUID_RenderRprimsAdditive);
CreateRenderRprimsTask(HnMaterialTagTokens->translucent, TaskUID_RenderRprimsTranslucent);

CreatePostProcessTask();

m_DefaultTaskOrder =
{
TaskUID_RenderDefault,
TaskUID_RenderMasked,
TaskUID_RenderAdditive,
TaskUID_RenderTranslucent,
TaskUID_RenderRprimsDefault,
TaskUID_RenderRprimsMasked,
TaskUID_RenderRprimsAdditive,
TaskUID_RenderRprimsTranslucent,
TaskUID_PostProcess,
};
}
Expand Down Expand Up @@ -212,9 +212,9 @@ void HnTaskController::RemoveTask(TaskUID UID)
m_TaskUIDs.erase(it);
}

pxr::SdfPath HnTaskController::GetRenderTaskId(const pxr::TfToken& MaterialTag) const
pxr::SdfPath HnTaskController::GetRenderRprimsTaskId(const pxr::TfToken& MaterialTag) const
{
std::string Id = std::string{"renderTask_"} + MaterialTag.GetString();
std::string Id = std::string{"RenderRprimsTask_"} + MaterialTag.GetString();
std::replace(Id.begin(), Id.end(), ':', '_');
return GetControllerId().AppendChild(TfToken{Id});
}
Expand All @@ -224,14 +224,14 @@ void HnTaskController::SetParameter(const pxr::SdfPath& Id, const TfToken& Value
m_ParamsDelegate->SetParameter(Id, ValueKey, std::move(Value));
}

void HnTaskController::CreateRenderTask(const pxr::TfToken& MaterialTag, TaskUID UID)
void HnTaskController::CreateRenderRprimsTask(const pxr::TfToken& MaterialTag, TaskUID UID)
{
pxr::SdfPath RenderTaskId = GetRenderTaskId(MaterialTag);
pxr::SdfPath RenderRprimsTaskId = GetRenderRprimsTaskId(MaterialTag);
// Note that we pass the delegate to the scene index. This delegate will be passed
// to the task's Sync() method.
CreateTask<HnRenderTask>(RenderTaskId, UID);
CreateTask<HnRenderRprimsTask>(RenderRprimsTaskId, UID);

HnRenderTaskParams TaskParams;
HnRenderRprimsTaskParams TaskParams;

pxr::HdRprimCollection Collection{
pxr::HdTokens->geometry,
Expand All @@ -243,11 +243,11 @@ void HnTaskController::CreateRenderTask(const pxr::TfToken& MaterialTag, TaskUID

pxr::TfTokenVector RenderTags = {pxr::HdRenderTagTokens->geometry};

m_ParamsDelegate->SetParameter(RenderTaskId, pxr::HdTokens->params, TaskParams);
m_ParamsDelegate->SetParameter(RenderTaskId, pxr::HdTokens->collection, Collection);
m_ParamsDelegate->SetParameter(RenderTaskId, pxr::HdTokens->renderTags, RenderTags);
m_ParamsDelegate->SetParameter(RenderRprimsTaskId, pxr::HdTokens->params, TaskParams);
m_ParamsDelegate->SetParameter(RenderRprimsTaskId, pxr::HdTokens->collection, Collection);
m_ParamsDelegate->SetParameter(RenderRprimsTaskId, pxr::HdTokens->renderTags, RenderTags);

m_RenderTaskIds.emplace_back(std::move(RenderTaskId));
m_RenderTaskIds.emplace_back(std::move(RenderRprimsTaskId));
}

void HnTaskController::CreatePostProcessTask()
Expand Down Expand Up @@ -295,11 +295,11 @@ void HnTaskController::SetCollection(const pxr::HdRprimCollection& Collection)
}
}

void HnTaskController::SetRenderParams(const HnRenderTaskParams& Params)
void HnTaskController::SetRenderParams(const HnRenderRprimsTaskParams& Params)
{
for (const auto& TaskId : m_RenderTaskIds)
{
HnRenderTaskParams OldParams = m_ParamsDelegate->GetParameter<HnRenderTaskParams>(TaskId, pxr::HdTokens->params);
HnRenderRprimsTaskParams OldParams = m_ParamsDelegate->GetParameter<HnRenderRprimsTaskParams>(TaskId, pxr::HdTokens->params);
if (OldParams == Params)
continue;

Expand Down

0 comments on commit 73a6f42

Please sign in to comment.