Skip to content

Commit

Permalink
[dataflow] add rendergraph ssubcomponent
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Sep 29, 2022
1 parent 1bca400 commit 177728c
Show file tree
Hide file tree
Showing 12 changed files with 1,272 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Dataflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ if(RADIUM_GENERATE_LIB_CORE)
target_link_libraries(${ra_dataflow_target} INTERFACE DataflowCore)
endif()

if(OFF)
if(RADIUM_GENERATE_LIB_ENGINE)
add_subdirectory(Rendering)
add_dependencies(${ra_dataflow_target} DataflowRendering)
target_link_libraries(${ra_dataflow_target} INTERFACE DataflowRendering)
endif()
if(RADIUM_GENERATE_LIB_ENGINE)
add_subdirectory(Rendering)
add_dependencies(${ra_dataflow_target} DataflowRendering)
target_link_libraries(${ra_dataflow_target} INTERFACE DataflowRendering)
endif()

if(RADIUM_GENERATE_LIB_GUI)
Expand Down
10 changes: 10 additions & 0 deletions src/Dataflow/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ if (Dataflow_FOUND AND NOT TARGET Dataflow)
endif()
endif()

if(NOT DataflowRendering_FOUND)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../DataflowRendering/RadiumDataflowRenderingConfig.cmake")
set(DataflowRendering_FOUND TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/../DataflowRendering/RadiumDataflowRenderingConfig.cmake)
else()
set(Radium_FOUND False)
set(Radium_NOT_FOUND_MESSAGE "Radium::Dataflow: dependency DataflowRendering not found")
set(Configure_Dataflow OFF)
endif()
endif()
endif()

# configure Dataflow component
Expand Down
41 changes: 41 additions & 0 deletions src/Dataflow/Rendering/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
set(ra_dataflowrendering_target DataflowRendering)
list(APPEND CMAKE_MESSAGE_INDENT "[${ra_dataflowrendering_target}] ")

project(${ra_dataflowrendering_target} LANGUAGES CXX VERSION ${Radium_VERSION})

include(filelist.cmake)

# configure library
add_library(
${ra_dataflowrendering_target} SHARED
${dataflow_rendering_sources} ${dataflow_rendering_headers} ${dataflow_rendering_inlines}
)

# This one should be extracted directly from parent project properties.
target_compile_definitions(${ra_dataflowrendering_target} PRIVATE RA_DATAFLOW_EXPORTS)

target_compile_options(${ra_dataflowrendering_target} PUBLIC ${RA_DEFAULT_COMPILE_OPTIONS})

add_dependencies(${ra_dataflowrendering_target} DataflowCore Engine)
target_link_libraries(${ra_dataflowrendering_target} PUBLIC DataflowCore Engine)

message(STATUS "Configuring library ${ra_dataflowrendering_target} with standard settings")
configure_radium_target(${ra_dataflowrendering_target})
# configure the library only. The package is a sub-package and should be configured independently
configure_radium_library(
TARGET ${ra_dataflowrendering_target} COMPONENT TARGET_DIR "Dataflow/Rendering"
FILES "${dataflow_rendering_headers};${dataflow_rendering_inlines}"
)
# Generate cmake package
configure_radium_package(
NAME ${ra_dataflowrendering_target} PACKAGE_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
PACKAGE_DIR "lib/cmake/Radium/${ra_dataflowrendering_target}" NAME_PREFIX "Radium"
)

set(RADIUM_COMPONENTS ${RADIUM_COMPONENTS} ${ra_dataflowrendering_target} PARENT_SCOPE)

if(RADIUM_ENABLE_PCH)
target_precompile_headers(${ra_dataflowrendering_target} PRIVATE pch.hpp)
endif()

list(REMOVE_AT CMAKE_MESSAGE_INDENT -1)
38 changes: 38 additions & 0 deletions src/Dataflow/Rendering/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -------------- Configuration of the Radium DataflowCore targets and definitions -----------------------
# Setup Engine and check for dependencies

if (DataflowRendering_FOUND AND NOT TARGET DataflowRendering)
set(Configure_DataflowRendering ON)
# verify dependencies
if(NOT DataflowCore_FOUND)
# if in source dir
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../Dataflow/Core/RadiumDataflowCoreConfig.cmake")
set(DataflowCore_FOUND TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/../Dataflow/Core/RadiumDataflowCoreConfig.cmake)
else()
# if in install dir
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../DataflowCore/RadiumDataflowCoreConfig.cmake")
set(DataflowCore_FOUND TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/../DataflowCore/RadiumDataflowCoreConfig.cmake)
else()
set(Radium_FOUND False)
set(Radium_NOT_FOUND_MESSAGE "Radium::DataflowQtGui: dependency DataflowCore not found")
set(Configure_DataflowRendering OFF)
endif()
endif()
endif()
if(NOT Engine_FOUND)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../Engine/RadiumEngineConfig.cmake")
set(Gui_FOUND TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/../Engine/RadiumEngineConfig.cmake)
else()
set(Radium_FOUND False)
set(Radium_NOT_FOUND_MESSAGE "Radium::DataflowRendering: dependency Engine not found")
set(Configure_DataflowRendering OFF)
endif()
endif()
endif()

if(Configure_DataflowRendering)
include("${CMAKE_CURRENT_LIST_DIR}/../Dataflow/Rendering/DataflowRenderingTargets.cmake")
endif()
75 changes: 75 additions & 0 deletions src/Dataflow/Rendering/Nodes/RenderingNode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once
#include <Dataflow/RaDataflow.hpp>

#include <Dataflow/Core/Node.hpp>

#include <Core/Utils/Color.hpp>
#include <Engine/Data/Texture.hpp>
#include <Engine/Data/ViewingParameters.hpp>
#include <Engine/Rendering/RenderObject.hpp>
#include <Engine/Scene/Light.hpp>

namespace Ra::Engine::Data {
class ShaderProgramManager;
}

namespace Ra {
namespace Dataflow {
namespace Rendering {
namespace Nodes {

/**
* Defining some useful aliases for data type
*
*/

using RenderObjectType = std::shared_ptr<Ra::Engine::Rendering::RenderObject>;
using LightType = const Ra::Engine::Scene::Light*;
using CameraType = Ra::Engine::Data::ViewingParameters;
using ColorType = Ra::Core::Utils::Color;
using TextureType = Ra::Engine::Data::Texture;

/**
* Base class for Rendering nodes.
* Rendering nodes are nodes with some interface needed to render the scene.
*/
class RA_DATAFLOW_API RenderingNode : public Dataflow::Core::Node,
public Ra::Core::Utils::IndexedObject
{
public:
using Dataflow::Core::Node::Node;

/// The resize(uint32_t width, uint32_t height) function is called when the application gets
/// resized. Its goal is to resize the potential internal textures if needed.
/// @param width The new width of the surface.
/// @param height The new height of the surface.
virtual void resize( uint32_t width, uint32_t height ) = 0;

/// Build a render technic per material.
/// @param ro The render object to get the material from
/// @param rt The render technic to build
virtual void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject*,
Ra::Engine::Rendering::RenderTechnique& ) const {};

/// Indicate if the nod needs to setup a rendertechnique on RenderObjects
virtual bool hasRenderTechnique() { return false; }

/// Sets the shader program manager
void setShaderProgramManager( Ra::Engine::Data::ShaderProgramManager* shaderMngr ) {
m_shaderMngr = shaderMngr;
}

static const std::string getTypename() { return "RenderingNode"; }

protected:
void toJsonInternal( nlohmann::json& ) const override {}
void fromJsonInternal( const nlohmann::json& ) override {}

/// The renderer's shader program manager
Ra::Engine::Data::ShaderProgramManager* m_shaderMngr;
};

} // namespace Nodes
} // namespace Rendering
} // namespace Dataflow
} // namespace Ra
Loading

0 comments on commit 177728c

Please sign in to comment.