From 409f2f20b890984af47b9d0c475c57750b1f0fbc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 3 Aug 2024 03:21:59 +0200 Subject: [PATCH] Invocation: introduce engine-context for dependency injection ...by relying on DI for some effectively global services, notably the cache provider, the API for building and wiring render nodes can be simplified to cover only the actual node connectivity --- ...fer-local-key.hpp => buffer-local-tag.hpp} | 10 +- src/steam/engine/buffer-metadata.hpp | 2 +- src/steam/engine/buffer-provider.hpp | 5 +- src/steam/engine/engine-ctx.hpp | 73 ++++++++++++ src/steam/engine/weaving-pattern-builder.hpp | 1 + wiki/thinkPad.ichthyo.mm | 110 ++++++++++++++---- 6 files changed, 173 insertions(+), 28 deletions(-) rename src/steam/engine/{buffer-local-key.hpp => buffer-local-tag.hpp} (93%) create mode 100644 src/steam/engine/engine-ctx.hpp diff --git a/src/steam/engine/buffer-local-key.hpp b/src/steam/engine/buffer-local-tag.hpp similarity index 93% rename from src/steam/engine/buffer-local-key.hpp rename to src/steam/engine/buffer-local-tag.hpp index 84c5513ce..4349cdef4 100644 --- a/src/steam/engine/buffer-local-key.hpp +++ b/src/steam/engine/buffer-local-tag.hpp @@ -1,5 +1,5 @@ /* - BUFFER-LOCAL-KEY.hpp - opaque data for BufferProvider implementation + BUFFER-LOCAL-TAG.hpp - opaque data for BufferProvider implementation Copyright (C) Lumiera.org 2011, Hermann Vosseler @@ -21,13 +21,13 @@ */ -/** @file buffer-local-key.hpp +/** @file buffer-local-tag.hpp ** A marker data type used in metadata / buffer management of the render engine. */ -#ifndef STEAM_ENGINE_BUFFR_LOCAL_KEY_H -#define STEAM_ENGINE_BUFFR_LOCAL_KEY_H +#ifndef STEAM_ENGINE_BUFFR_LOCAL_TAG_H +#define STEAM_ENGINE_BUFFR_LOCAL_TAG_H #include "lib/error.hpp" @@ -130,4 +130,4 @@ namespace engine { }} // namespace steam::engine -#endif +#endif /*STEAM_ENGINE_BUFFR_LOCAL_TAG_H*/ diff --git a/src/steam/engine/buffer-metadata.hpp b/src/steam/engine/buffer-metadata.hpp index 255aa4067..3a51743ee 100644 --- a/src/steam/engine/buffer-metadata.hpp +++ b/src/steam/engine/buffer-metadata.hpp @@ -61,7 +61,7 @@ #include "include/logging.h" #include "steam/streamtype.hpp" #include "steam/engine/type-handler.hpp" -#include "steam/engine/buffer-local-key.hpp" +#include "steam/engine/buffer-local-tag.hpp" #include "lib/nocopy.hpp" #include diff --git a/src/steam/engine/buffer-provider.hpp b/src/steam/engine/buffer-provider.hpp index a4f2f32e1..e8cae91aa 100644 --- a/src/steam/engine/buffer-provider.hpp +++ b/src/steam/engine/buffer-provider.hpp @@ -46,8 +46,9 @@ #include "lib/symbol.hpp" #include "lib/hash-value.h" #include "steam/engine/buffhandle.hpp" +#include "steam/engine/engine-ctx.hpp" #include "steam/engine/type-handler.hpp" -#include "steam/engine/buffer-local-key.hpp" +#include "steam/engine/buffer-local-tag.hpp" #include "lib/nocopy.hpp" #include @@ -173,4 +174,4 @@ namespace engine { }} // namespace steam::engine -#endif +#endif /*STEAM_ENGINE_BUFFR_PROVIDER_H*/ diff --git a/src/steam/engine/engine-ctx.hpp b/src/steam/engine/engine-ctx.hpp new file mode 100644 index 000000000..02312b34e --- /dev/null +++ b/src/steam/engine/engine-ctx.hpp @@ -0,0 +1,73 @@ +/* + ENGINE-CTX.hpp - Services and parameters used globally within the render engine + + Copyright (C) Lumiera.org + 2024, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file engine-ctx.hpp + ** Dependency context to hold global parameters and services for the render engine. + ** Notably the services to provide access to working buffers are linked directly into the + ** render node connectivity, where they are used for each invocation of a render job. + ** + ** The EngineCtx itself is meant to be [dependency injected](\ref lib::Depend), so that + ** tests can use suitably adapted variants for verifications. + ** @todo who is responsible for setup of the services for the actual render engine? + ** Might be closely related to brining up façade interfaces. + ** @todo WIP 8/2024 provide render node structures + ** + ** @see buffer-provider.hpp + ** @see buffhandle.hpp + */ + +#ifndef STEAM_ENGINE_ENGINE_CTX_H +#define STEAM_ENGINE_ENGINE_CTX_H + + +#include "lib/depend.hpp" +#include "steam/engine/buffhandle.hpp" +#include "lib/nocopy.hpp" + +//#include +#include + + +namespace steam { +namespace engine { + +// using lib::Literal; + using std::unique_ptr; +// using std::forward; + + class EngineCtx + : util::NonCopyable + { + public: + BufferProvider& mem; + BufferProvider& cache; + BufferProvider& output; + + class Services; + + EngineCtx(); + }; + + + +}} // namespace steam::engine +#endif /*STEAM_ENGINE_ENGINE_CTX_H*/ diff --git a/src/steam/engine/weaving-pattern-builder.hpp b/src/steam/engine/weaving-pattern-builder.hpp index 288125221..b8a30df1a 100644 --- a/src/steam/engine/weaving-pattern-builder.hpp +++ b/src/steam/engine/weaving-pattern-builder.hpp @@ -41,6 +41,7 @@ //#include "vault/gear/job.h" #include "lib/several-builder.hpp" #include "steam/engine/turnout.hpp" +#include "steam/engine/engine-ctx.hpp" #include "steam/engine/buffer-provider.hpp" //#include "lib/util-foreach.hpp" //#include "lib/iter-adapter.hpp" diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 662aaae2a..494436795 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -88552,10 +88552,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + @@ -88640,8 +88641,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + + @@ -88681,7 +88683,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -88844,7 +88846,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -88862,10 +88864,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -88875,6 +88877,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+
@@ -88884,11 +88887,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
dieser würde dann nur von top-Level aus so erfolgen, womit der Spezialfall ganz natürlich ausgewählt wäre

- -
+
- + @@ -88900,8 +88902,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
...d.h. daß man das Output-Protokoll hinter einem BufferProvider versteckt, um einen uniformen Zugriff zu ermöglichen.

- - +
@@ -88997,6 +88998,71 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + +

+ nämlich den OutputBufferProvider explizit eine Ebene darüber verwenden und dann das BuffHandle direkt in den weave()-Aufruf geben +

+ + +
+
+
+ + + + + + +

+ Den OutputBufferProvider handhaben wir jetzt eine Ebene höher, und dort können wir direkt ein LocalTag setzen und dann ein zugehöriges BuffHandle erstellen, das nur an einen bestimmten Buffer im Output-system gebunden ist. Alle anderen Use-Cases (Memory-Blöcke und Cache) sind ohnehin global für die gesamte RenderEngine +

+ + +
+
+
+ + + + + + + + + + +

+ wenngleich auch dort Zweifel zum Namen bestehen +

+ + +
+ +
+
+ + + + + + + + + + +

+ damit lib::Depend ohne Weiteres einfach funktioniert +

+ + +
+
+
@@ -89008,18 +89074,21 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + + + - + + - - - + + + @@ -89079,13 +89148,14 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

- + + + -