Skip to content

Commit

Permalink
Hydrogent: added HnRenderEnvMapTask stub
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 19, 2023
1 parent 73a6f42 commit 487f187
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Hydrogent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(SOURCE
src/HnTypeConversions.cpp
src/Tasks/HnTask.cpp
src/Tasks/HnRenderRprimsTask.cpp
src/Tasks/HnRenderEnvMapTask.cpp
src/Tasks/HnPostProcessTask.cpp
src/Tasks/HnTaskController.cpp
)
Expand All @@ -37,6 +38,7 @@ set(INCLUDE
include/HnTypeConversions.hpp
include/Tasks/HnTask.hpp
include/Tasks/HnRenderRprimsTask.hpp
include/Tasks/HnRenderEnvMapTask.hpp
include/Tasks/HnPostProcessTask.hpp
include/Tasks/HnTaskController.hpp
)
Expand Down
73 changes: 73 additions & 0 deletions Hydrogent/include/Tasks/HnRenderEnvMapTask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2023 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/

#pragma once

#include "HnTask.hpp"

namespace Diligent
{

namespace USD
{

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

/// Post processing task implementation in Hydrogent.
class HnRenderEnvMapTask final : public HnTask
{
public:
using TaskSharedPtr = std::shared_ptr<HnRenderEnvMapTask>;

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

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

virtual void Sync(pxr::HdSceneDelegate* Delegate,
pxr::HdTaskContext* TaskCtx,
pxr::HdDirtyBits* DirtyBits) override final;

virtual void Prepare(pxr::HdTaskContext* TaskCtx,
pxr::HdRenderIndex* PostProcessIndex) override final;


virtual void Execute(pxr::HdTaskContext* TaskCtx) override final;
};

} // namespace USD

} // namespace Diligent
11 changes: 7 additions & 4 deletions Hydrogent/include/Tasks/HnTaskController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class HnTaskController
static constexpr TaskUID TaskUID_RenderRprimsMasked = 0xf5290fec47594711;
static constexpr TaskUID TaskUID_RenderRprimsAdditive = 0x37d45531106c4c52;
static constexpr TaskUID TaskUID_RenderRprimsTranslucent = 0xa015c7e45941407e;
static constexpr TaskUID TaskUID_RenderEnvMap = 0xf646122e1dc74bab;
static constexpr TaskUID TaskUID_PostProcess = 0x1f5367e65d034500;

HnTaskController(pxr::HdRenderIndex& RenderIndex,
Expand All @@ -67,10 +68,11 @@ class HnTaskController
/// Returns the task list that can be passed to the Hydra engine for execution.
///
/// \param [in] TaskOrder - Optional task order. If not specified, the default order is used:
/// - RenderDefault
/// - RenderMasked
/// - RenderAdditive
/// - RenderTranslucent
/// - RenderRprimsDefault
/// - RenderRprimsMasked
/// - RenderEnvMap
/// - RenderRprimsAdditive
/// - RenderRprimsTranslucent
/// - PostProcess
/// \return The task list that can be passed to pxr::HdEngine::Execute.
const pxr::HdTaskSharedPtrVector GetTasks(const std::vector<TaskUID>* TaskOrder = nullptr) const;
Expand Down Expand Up @@ -102,6 +104,7 @@ class HnTaskController
pxr::SdfPath GetRenderRprimsTaskId(const pxr::TfToken& MaterialTag) const;

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

private:
Expand Down
66 changes: 66 additions & 0 deletions Hydrogent/src/Tasks/HnRenderEnvMapTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/

#include "Tasks/HnRenderEnvMapTask.hpp"

namespace Diligent
{

namespace USD
{

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

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

HnRenderEnvMapTask::~HnRenderEnvMapTask()
{
}

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

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

void HnRenderEnvMapTask::Execute(pxr::HdTaskContext* TaskCtx)
{
}

} // namespace USD

} // namespace Diligent
14 changes: 13 additions & 1 deletion Hydrogent/src/Tasks/HnTaskController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <array>

#include "Tasks/HnRenderRprimsTask.hpp"
#include "Tasks/HnRenderEnvMapTask.hpp"
#include "Tasks/HnPostProcessTask.hpp"
#include "HnTokens.hpp"
#include "HashUtils.hpp"
Expand All @@ -48,6 +49,7 @@ TF_DEFINE_PRIVATE_TOKENS(
HnTaskControllerTokens,

(postProcessTask)
(renderEnvMapTask)

(renderBufferDescriptor)
(renderTags)
Expand Down Expand Up @@ -171,13 +173,14 @@ HnTaskController::HnTaskController(pxr::HdRenderIndex& RenderIndex,
CreateRenderRprimsTask(HnMaterialTagTokens->masked, TaskUID_RenderRprimsMasked);
CreateRenderRprimsTask(HnMaterialTagTokens->additive, TaskUID_RenderRprimsAdditive);
CreateRenderRprimsTask(HnMaterialTagTokens->translucent, TaskUID_RenderRprimsTranslucent);

CreateRenderEnvMapTask();
CreatePostProcessTask();

m_DefaultTaskOrder =
{
TaskUID_RenderRprimsDefault,
TaskUID_RenderRprimsMasked,
TaskUID_RenderEnvMap,
TaskUID_RenderRprimsAdditive,
TaskUID_RenderRprimsTranslucent,
TaskUID_PostProcess,
Expand Down Expand Up @@ -259,6 +262,15 @@ void HnTaskController::CreatePostProcessTask()
m_ParamsDelegate->SetParameter(PostProcessTaskId, pxr::HdTokens->params, TaskParams);
}

void HnTaskController::CreateRenderEnvMapTask()
{
const pxr::SdfPath RenderEnvMapTaskId = GetControllerId().AppendChild(HnTaskControllerTokens->renderEnvMapTask);
CreateTask<HnRenderEnvMapTask>(RenderEnvMapTaskId, TaskUID_RenderEnvMap);

HnRenderEnvMapTaskParams TaskParams;
m_ParamsDelegate->SetParameter(RenderEnvMapTaskId, pxr::HdTokens->params, TaskParams);
}

const pxr::HdTaskSharedPtrVector HnTaskController::GetTasks(const std::vector<TaskUID>* TaskOrder) const
{
if (TaskOrder == nullptr)
Expand Down

0 comments on commit 487f187

Please sign in to comment.