Skip to content

Commit

Permalink
Merge pull request #74 from KonstantinTomashevich/73-render-foundatio…
Browse files Browse the repository at this point in the history
…n-improvement

Celerity::RenderFoundation: Frame buffers and render to textures.
  • Loading branch information
KonstantinTomashevich committed Jul 5, 2023
2 parents 3f44f2a + 96368bc commit 6167fde
Show file tree
Hide file tree
Showing 59 changed files with 1,384 additions and 292 deletions.
5 changes: 5 additions & 0 deletions Coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"MinimumLinesCoveragePerFilePercent": 65.0,
"Reason": "It's impossible to fully cover `DoWithCorrectComparator` because of asserts and breaks that will be reached only if something really bad happens."
},
{
"Prefix": "./Library/Public/Celerity/Extension/Asset/Celerity/Asset/ManualAssetConstructor.cpp",
"Action": "Exclude",
"Reason": "Manual asset constructor logic is covered only by GPU dependant tests, therefore there is no coverage on CI."
},
{
"Prefix": "./Library/Public/Celerity/Extension/Input/Celerity/Input/FrameInputAccumulator.cpp",
"Action": "CustomMinimumCoverage",
Expand Down
2 changes: 2 additions & 0 deletions Executable/Platformer2dDemo/Game/Modules/Platformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Celerity/Physics2d/Simulation.hpp>
#include <Celerity/PipelineBuilder.hpp>
#include <Celerity/Render/2d/Rendering2d.hpp>
#include <Celerity/Render/Foundation/PostProcess.hpp>
#include <Celerity/Render/Foundation/RenderPipelineFoundation.hpp>
#include <Celerity/Transform/TransformHierarchyCleanup.hpp>
#include <Celerity/Transform/TransformVisualSync.hpp>
Expand Down Expand Up @@ -95,6 +96,7 @@ void Initializer (GameState &_gameState,
Emergence::Celerity::Assembly::AddToNormalUpdate (mainPipelineBuilder, GetAssemblerCustomKeys (),
GetNormalAssemblerTypes (), MAX_ASSEMBLY_TIME_NS);
Emergence::Celerity::Input::AddToNormalUpdate (mainPipelineBuilder, _gameState.GetFrameInputAccumulator ());
Emergence::Celerity::PostProcess::AddToNormalUpdate (mainPipelineBuilder);
Emergence::Celerity::RenderPipelineFoundation::AddToNormalUpdate (mainPipelineBuilder);
Emergence::Celerity::Rendering2d::AddToNormalUpdate (mainPipelineBuilder, worldBox);
Emergence::Celerity::TransformHierarchyCleanup::Add2dToNormalUpdate (mainPipelineBuilder);
Expand Down
2 changes: 2 additions & 0 deletions Executable/Platformer2dDemo/Game/Modules/Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <Celerity/Asset/AssetManagement.hpp>
#include <Celerity/Asset/Events.hpp>
#include <Celerity/Asset/Render/2d/Sprite2dUvAnimationManagement.hpp>
#include <Celerity/Asset/Render/Foundation/FrameBufferManagement.hpp>
#include <Celerity/Asset/Render/Foundation/MaterialInstanceManagement.hpp>
#include <Celerity/Asset/Render/Foundation/MaterialManagement.hpp>
#include <Celerity/Asset/Render/Foundation/TextureManagement.hpp>
Expand Down Expand Up @@ -84,6 +85,7 @@ void Initializer (GameState &_gameState,
assetReferenceBindingEventMap);
Emergence::Celerity::FontManagement::AddToNormalUpdate (pipelineBuilder, _gameState.GetResourceProvider (),
assetReferenceBindingEventMap);
Emergence::Celerity::FrameBufferManagement::AddToNormalUpdate (pipelineBuilder);
Emergence::Celerity::Localization::AddToNormalUpdate (pipelineBuilder, _gameState.GetResourceProvider ());
Emergence::Celerity::MaterialInstanceManagement::AddToNormalUpdate (
pipelineBuilder, _gameState.GetResourceProvider (), assetReferenceBindingEventMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Render::Backend::Texture BakeFontAtlas (ImFontAtlas *_atlas)
_atlas->GetTexDataAsRGBA32 (&textureData, &textureWidth, &textureHeight);
EMERGENCE_ASSERT (textureData);

Render::Backend::Texture texture (textureData, textureWidth, textureHeight, {});
Render::Backend::Texture texture = Render::Backend::Texture::CreateFromRaw (
textureWidth, textureHeight, Render::Backend::TextureFormat::RGBA8, textureData, {});

const Render::Backend::TextureId atlasTextureId = texture.GetId ();
static_assert (sizeof (Render::Backend::TextureId) == sizeof (ImTextureID));

BEGIN_MUTING_STRING_ALIASING_WARNINGS
_atlas->SetTexID (*reinterpret_cast<const ImTextureID *> (&atlasTextureId));
END_MUTING_WARNINGS

return texture;
}
} // namespace Emergence::Celerity
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ void UIRenderer::ProcessRenderPass (const UIRenderPass *_renderPass,

if (availableVertices != totalVertices || availableIndices != totalIndices)
{
EMERGENCE_LOG (WARNING,
"Celerity::UI: Unable to submit all draw calls due to being unable to allocate buffers.");
EMERGENCE_LOG (WARNING, "UI: Unable to submit all draw calls due to being unable to allocate buffers.");
break;
}

Expand Down
1 change: 1 addition & 0 deletions Library/Private/Galleon/Galleon/CargoDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CargoDeck::CargoDeck (Memory::UniqueString _name) noexcept
{
}

// NOLINTNEXTLINE(modernize-use-equals-default): It's not actually default unless assertions are disabled.
CargoDeck::~CargoDeck () noexcept
{
// Assert that all containers are either detached or exist only due to garbage collection disabled flag.
Expand Down
8 changes: 2 additions & 6 deletions Library/Private/Pegasus/Private/Pegasus/RecordUtility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,14 @@ auto DoWithCorrectComparator (const StandardLayout::Field &_field, const Callbac
return _callback (UniqueStringValueComparator {});
}

// _field should be leaf-field, not intermediate nested object.
case StandardLayout::FieldArchetype::NESTED_OBJECT:
{
// _field should be leaf-field, not intermediate nested object.
EMERGENCE_ASSERT (false);
break;
}

// Vectors, patches and external strings aren't supported for indexing.
case StandardLayout::FieldArchetype::UTF8_STRING:
case StandardLayout::FieldArchetype::VECTOR:
case StandardLayout::FieldArchetype::PATCH:
{
// Vectors, patches and external strings aren't supported for indexing.
EMERGENCE_ASSERT (false);
break;
}
Expand Down
1 change: 1 addition & 0 deletions Library/Private/Pegasus/Public/Pegasus/VolumetricIndex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ void PartitioningTree<Dimensions>::DeleteNodeWithChildren (Node *_node)
}

template <std::size_t Dimensions>
// NOLINTNEXTLINE(modernize-use-equals-default): It's actually not default when asserts are enabled.
PartitioningTree<Dimensions>::Node::~Node () noexcept
{
#if defined(EMERGENCE_ASSERT_ENABLED)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <Celerity/Asset/Asset.hpp>
#include <Celerity/Asset/AssetManagerSingleton.hpp>
#include <Celerity/Asset/ManualAssetConstructor.hpp>
#include <Celerity/PipelineBuilderMacros.hpp>

namespace Emergence::Celerity
{
ManualAssetConstructor::ManualAssetConstructor (TaskConstructor &_constructor) noexcept
: modifyAssetManager (MODIFY_SINGLETON (AssetManagerSingleton)),
insertAsset (INSERT_LONG_TERM (Asset))
{
}

void ManualAssetConstructor::ConstructManualAsset (Memory::UniqueString _assetId,
const StandardLayout::Mapping &_assetType) noexcept
{
auto managerCursor = modifyAssetManager.Execute ();
auto *manager = static_cast<AssetManagerSingleton *> (*managerCursor);
++manager->unusedAssetCount;

auto assetCursor = insertAsset.Execute ();
auto *asset = static_cast<Asset *> (++assetCursor);
asset->id = _assetId;
asset->type = _assetType;
asset->state = AssetState::READY;
asset->usages = 0u;
}
} // namespace Emergence::Celerity
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <Celerity/PipelineBuilder.hpp>

namespace Emergence::Celerity
{
/// \brief Utility class for systems that need to manually construct
/// assets instead of constructing them through references.
class ManualAssetConstructor final
{
public:
/// \brief Initializes internal queries using given task constructor,
ManualAssetConstructor (TaskConstructor &_constructor) noexcept;

ManualAssetConstructor (const ManualAssetConstructor &_other) = delete;

ManualAssetConstructor (ManualAssetConstructor &&_other) = delete;

~ManualAssetConstructor () noexcept = default;

/// \brief Constructs ready to use asset with given id, given type and zero references.
/// \warning Asset might be cleaned up later by asset management system unless something references it.
void ConstructManualAsset (Memory::UniqueString _assetId, const StandardLayout::Mapping &_assetType) noexcept;

EMERGENCE_DELETE_ASSIGNMENT (ManualAssetConstructor);

private:
ModifySingletonQuery modifyAssetManager;
InsertLongTermQuery insertAsset;
};
} // namespace Emergence::Celerity
Loading

0 comments on commit 6167fde

Please sign in to comment.