Last active
May 9, 2019 12:27
-
-
Save Nehon/738817897dde56564c8843f737232a81 to your computer and use it in GitHub Desktop.
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
// Transform tree example | |
TransformNodesSystem transformTreeSystem; | |
TransformLeavesSystem transformLeavesSystem; | |
// First step: update squentially all nodes (can't be multithreaded as parents need to be updated before children | |
ecs // no lint | |
->beginSequentialTransaction() | |
.executeSystem(&transformTreeSystem) | |
.end(); | |
// Second step: update all leaves of the tree (geometries), this can be parallelized as the order doesn't matter. | |
ecs // no lint | |
->beginParallelTransaction(scheduler) | |
.executeSystem(&transformLeavesSystem) | |
.end(); | |
// Other example: creating render resources from components (WIP) | |
// a context object needed by my systems (can be whatever) | |
// usually it's something either used by several system to write into it (but you must be carfull that thread safety is maintained) | |
// ort it can be a global context containing accessors to various read only data. | |
Context context; | |
_ecs // no lint | |
.beginParallelTransaction(&_scheduler) | |
.executeSystem(&_renderer.createPipelinesSystem, &context) | |
.executeSystem(&_renderer.initRenderBatchesSystem, &context) | |
.end(); | |
// could be run in parallel with the previous transaction | |
_renderer.createBuffers(_bufferStore.get()); | |
_ecs // no lint | |
.beginParallelTransaction(&_scheduler) | |
.executeSystem(&_renderer.createBufferBindingsSystem, &context) | |
.end(); | |
_ecs // no lint | |
.beginParallelTransaction(&_scheduler) | |
.executeSystem(&_renderer.bindMeshSystem, context) | |
.end(); | |
ecs::CommandBuffer commandBuffer; | |
_ecs // no lint | |
.beginSequentialTransaction() | |
.executeFunction([](ecs::ECS::Transaction tr){ | |
// can do whatever I want here | |
// like creating entities, manipulating components (with th etransaction object) | |
// or totally ecs unrelated stuff like | |
printf("Starting the last transaction\n"); | |
}) | |
.executeSystem(&_renderer.finishRenderBatchesSystem, &context) | |
.executeSystem(&_renderer.clearRenderDirtyTagSystem, &commandBuffer) | |
.executeCommandBuffer(commandBuffer) | |
.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment