-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,198 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#pragma once | ||
|
||
#define CodeGenerator_Prefix "CodeGenerator" | ||
#define CodeGenerator_BuildNumber 605 | ||
#define CodeGenerator_BuildNumber 606 | ||
#define CodeGenerator_MinorNumber 0 | ||
#define CodeGenerator_MajorNumber 0 | ||
#define CodeGenerator_BuildId "0.0.605" | ||
#define CodeGenerator_BuildId "0.0.606" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#pragma once | ||
|
||
#define PostProcessing_Prefix "PostProcessing" | ||
#define PostProcessing_BuildNumber 509 | ||
#define PostProcessing_BuildNumber 522 | ||
#define PostProcessing_MinorNumber 1 | ||
#define PostProcessing_MajorNumber 0 | ||
#define PostProcessing_BuildId "0.1.509" | ||
#define PostProcessing_BuildId "0.1.522" |
249 changes: 249 additions & 0 deletions
249
Plugins/PostProcessing/src/Modules/PostPro/Effects/DilationModule.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
/* | ||
Copyright 2022 - 2022 Stephane Cuillerdier(aka aiekick) | ||
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 permissionsand | ||
limitations under the License. | ||
*/ | ||
|
||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it. | ||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com | ||
|
||
#include "DilationModule.h" | ||
|
||
#include <cinttypes> | ||
#include <functional> | ||
#include <ctools/Logger.h> | ||
#include <ctools/FileHelper.h> | ||
#include <LumoBackend/Graph/Base/BaseNode.h> | ||
#include <ImGuiPack.h> | ||
#include <LumoBackend/Systems/CommonSystem.h> | ||
#include <Gaia/Core/VulkanCore.h> | ||
#include <Gaia/Shader/VulkanShader.h> | ||
#include <Gaia/Core/VulkanSubmitter.h> | ||
#include <LumoBackend/Utils/Mesh/VertexStruct.h> | ||
#include <Gaia/Buffer/FrameBuffer.h> | ||
|
||
#include <Modules/PostPro/Effects/Pass/DilationModule_Comp_2D_Pass.h> | ||
|
||
using namespace GaiApi; | ||
|
||
#ifdef PROFILER_INCLUDE | ||
#include PROFILER_INCLUDE | ||
#endif | ||
#ifndef ZoneScoped | ||
#define ZoneScoped | ||
#endif | ||
|
||
////////////////////////////////////////////////////////////// | ||
//// STATIC ////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////// | ||
|
||
std::shared_ptr<DilationModule> DilationModule::Create(GaiApi::VulkanCorePtr vVulkanCorePtr, BaseNodeWeak vParentNode) { | ||
ZoneScoped; | ||
|
||
if (!vVulkanCorePtr) | ||
return nullptr; | ||
auto res = std::make_shared<DilationModule>(vVulkanCorePtr); | ||
res->SetParentNode(vParentNode); | ||
res->m_This = res; | ||
if (!res->Init()) { | ||
res.reset(); | ||
} | ||
|
||
return res; | ||
} | ||
|
||
////////////////////////////////////////////////////////////// | ||
//// CTOR / DTOR ///////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////// | ||
|
||
DilationModule::DilationModule(GaiApi::VulkanCorePtr vVulkanCorePtr) : BaseRenderer(vVulkanCorePtr) { | ||
ZoneScoped; | ||
} | ||
|
||
DilationModule::~DilationModule() { | ||
ZoneScoped; | ||
|
||
Unit(); | ||
} | ||
|
||
////////////////////////////////////////////////////////////// | ||
//// INIT / UNIT ///////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////// | ||
|
||
bool DilationModule::Init() { | ||
ZoneScoped; | ||
|
||
m_Loaded = false; | ||
|
||
ct::uvec2 map_size = 512; | ||
if (BaseRenderer::InitCompute2D(map_size)) { | ||
// SetExecutionWhenNeededOnly(true); | ||
m_DilationModule_Comp_2D_Pass_Ptr = DilationModule_Comp_2D_Pass::Create(map_size, m_VulkanCorePtr); | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
// by default but can be changed via widget | ||
m_DilationModule_Comp_2D_Pass_Ptr->AllowResizeOnResizeEvents(true); | ||
m_DilationModule_Comp_2D_Pass_Ptr->AllowResizeByHandOrByInputs(false); | ||
AddGenericPass(m_DilationModule_Comp_2D_Pass_Ptr); | ||
m_Loaded = true; | ||
} | ||
} | ||
|
||
return m_Loaded; | ||
} | ||
|
||
////////////////////////////////////////////////////////////// | ||
//// OVERRIDES /////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////// | ||
|
||
bool DilationModule::ExecuteAllTime(const uint32_t& vCurrentFrame, vk::CommandBuffer* vCmd, BaseNodeState* vBaseNodeState) { | ||
ZoneScoped; | ||
BaseRenderer::Render("Dilation", vCmd); | ||
return true; | ||
} | ||
|
||
bool DilationModule::ExecuteWhenNeeded(const uint32_t& vCurrentFrame, vk::CommandBuffer* vCmd, BaseNodeState* vBaseNodeState) { | ||
ZoneScoped; | ||
BaseRenderer::Render("Dilation", vCmd); | ||
return true; | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
//// DRAW WIDGETS //////////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
bool DilationModule::DrawWidgets(const uint32_t& vCurrentFrame, ImGuiContext* vContextPtr, const std::string& vUserDatas) { | ||
ZoneScoped; | ||
|
||
assert(vContextPtr); | ||
ImGui::SetCurrentContext(vContextPtr); | ||
|
||
if (m_LastExecutedFrame == vCurrentFrame) { | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
return m_DilationModule_Comp_2D_Pass_Ptr->DrawWidgets(vCurrentFrame, vContextPtr, vUserDatas); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool DilationModule::DrawOverlays(const uint32_t& vCurrentFrame, const ImRect& vRect, ImGuiContext* vContextPtr, const std::string& vUserDatas) { | ||
ZoneScoped; | ||
|
||
assert(vContextPtr); | ||
ImGui::SetCurrentContext(vContextPtr); | ||
if (m_LastExecutedFrame == vCurrentFrame) { | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
return m_DilationModule_Comp_2D_Pass_Ptr->DrawOverlays(vCurrentFrame, vRect, vContextPtr, vUserDatas); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool DilationModule::DrawDialogsAndPopups( | ||
const uint32_t& vCurrentFrame, const ImVec2& vMaxSize, ImGuiContext* vContextPtr, const std::string& vUserDatas) { | ||
ZoneScoped; | ||
|
||
assert(vContextPtr); | ||
ImGui::SetCurrentContext(vContextPtr); | ||
if (m_LastExecutedFrame == vCurrentFrame) { | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
return m_DilationModule_Comp_2D_Pass_Ptr->DrawDialogsAndPopups(vCurrentFrame, vMaxSize, vContextPtr, vUserDatas); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void DilationModule::NeedResizeByResizeEvent(ct::ivec2* vNewSize, const uint32_t* vCountColorBuffers) { | ||
ZoneScoped; | ||
|
||
// do some code | ||
|
||
BaseRenderer::NeedResizeByResizeEvent(vNewSize, vCountColorBuffers); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
//// TEXTURE SLOT INPUT ////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
void DilationModule::SetTexture(const uint32_t& vBindingPoint, vk::DescriptorImageInfo* vImageInfo, ct::fvec2* vTextureSize) { | ||
ZoneScoped; | ||
|
||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
m_DilationModule_Comp_2D_Pass_Ptr->SetTexture(vBindingPoint, vImageInfo, vTextureSize); | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
//// TEXTURE SLOT OUTPUT ///////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
vk::DescriptorImageInfo* DilationModule::GetDescriptorImageInfo(const uint32_t& vBindingPoint, ct::fvec2* vOutSize) { | ||
ZoneScoped; | ||
|
||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
return m_DilationModule_Comp_2D_Pass_Ptr->GetDescriptorImageInfo(vBindingPoint, vOutSize); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
//// CONFIGURATION ///////////////////////////////////////////////////////////////////////////////////////// | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
std::string DilationModule::getXml(const std::string& vOffset, const std::string& vUserDatas) { | ||
ZoneScoped; | ||
std::string str; | ||
str += vOffset + "<dilation_module>\n"; | ||
str += vOffset + "\t<can_we_render>" + (m_CanWeRender ? "true" : "false") + "</can_we_render>\n"; | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
str += m_DilationModule_Comp_2D_Pass_Ptr->getXml(vOffset + "\t", vUserDatas); | ||
} | ||
str += vOffset + "</dilation_module>\n"; | ||
return str; | ||
} | ||
|
||
bool DilationModule::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent, const std::string& vUserDatas) { | ||
ZoneScoped; | ||
|
||
// The value of this child identifies the name of this element | ||
std::string strName; | ||
std::string strValue; | ||
std::string strParentName; | ||
|
||
strName = vElem->Value(); | ||
if (vElem->GetText()) | ||
strValue = vElem->GetText(); | ||
if (vParent != nullptr) | ||
strParentName = vParent->Value(); | ||
|
||
if (strParentName == "dilation_module") { | ||
if (strName == "can_we_render") { | ||
m_CanWeRender = ct::ivariant(strValue).GetB(); | ||
} | ||
} | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
m_DilationModule_Comp_2D_Pass_Ptr->setFromXml(vElem, vParent, vUserDatas); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void DilationModule::AfterNodeXmlLoading() { | ||
ZoneScoped; | ||
if (m_DilationModule_Comp_2D_Pass_Ptr) { | ||
m_DilationModule_Comp_2D_Pass_Ptr->AfterNodeXmlLoading(); | ||
} | ||
} |
Oops, something went wrong.