From dff7004fa078d55911664c0f513b5dc6c9449420 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 14 Apr 2021 14:42:11 +0300 Subject: [PATCH] Rename Pipeline to Sequence Pipeline::Pass is now Sequence::Step. These better match what the classes do. --- demos/desertpillars.cpp | 40 ++++---- source/builders/pipelinebuilder.cpp | 98 ------------------- source/builders/sequencebuilder.cpp | 98 +++++++++++++++++++ .../{pipelinebuilder.h => sequencebuilder.h} | 22 ++--- ...elinetemplate.cpp => sequencetemplate.cpp} | 87 ++++++++-------- ...{pipelinetemplate.h => sequencetemplate.h} | 37 ++++--- source/effects/environmentmap.h | 4 +- source/materials/light.h | 2 +- source/render/{pipeline.cpp => sequence.cpp} | 56 +++++------ source/render/{pipeline.h => sequence.h} | 51 +++++----- source/resources/resources.cpp | 4 +- tools/viewer.cpp | 16 +-- 12 files changed, 261 insertions(+), 254 deletions(-) delete mode 100644 source/builders/pipelinebuilder.cpp create mode 100644 source/builders/sequencebuilder.cpp rename source/builders/{pipelinebuilder.h => sequencebuilder.h} (55%) rename source/builders/{pipelinetemplate.cpp => sequencetemplate.cpp} (60%) rename source/builders/{pipelinetemplate.h => sequencetemplate.h} (80%) rename source/render/{pipeline.cpp => sequence.cpp} (75%) rename source/render/{pipeline.h => sequence.h} (67%) diff --git a/demos/desertpillars.cpp b/demos/desertpillars.cpp index 89a0fe51..d741beea 100644 --- a/demos/desertpillars.cpp +++ b/demos/desertpillars.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ including: - Shadow mapping - Environment mapped reflections - Skybox using a cube map texture -- Effects with nested pipelines +- Effects with nested sequences - Complex multitexturing - Shader-based deformations - Creating a normalmapped texture through rendering @@ -132,7 +132,7 @@ private: GL::EnvironmentMap *env_cube; GL::WindowView view; - GL::Pipeline pipeline; + GL::Sequence sequence; GL::Camera camera; GL::SimpleScene sky_scene; GL::InstanceScene scene; @@ -142,7 +142,7 @@ private: GL::Bloom bloom; GL::ColorCurve colorcurve; - GL::Pipeline env_pipeline; + GL::Sequence env_sequence; Time::TimeStamp last_tick; float camera_angle; @@ -166,7 +166,7 @@ public: private: void setup_view(); - void create_pipeline(); + void create_sequence(); void create_skybox(); static void create_skybox_face(GL::TextureCube &, GL::TextureCubeFace); void create_tiles_texture(); @@ -299,11 +299,11 @@ DesertPillars::DesertPillars(int argc, char **argv): cube_shprog(cube_src), cube_shadow_shprog(string(cube_src)+cube_shadow_src_tail), view(window, gl_context), - pipeline(view), + sequence(view), shadow_scene(resources, 2048, scene, light), bloom(resources, window.get_width(), window.get_height()), colorcurve(resources), - env_pipeline(512, 512), + env_sequence(512, 512), camera_angle(0), camera_stopped(false), cube_angle(0), @@ -319,7 +319,7 @@ DesertPillars::DesertPillars(int argc, char **argv): keyboard.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &DesertPillars::key_press), false)); setup_view(); - create_pipeline(); + create_sequence(); create_skybox(); create_ground(); create_pillars(); @@ -340,13 +340,13 @@ void DesertPillars::setup_view() camera.set_up_direction(GL::Vector3(0, 0, 1)); camera.set_depth_clip(1, 50); view.set_camera(&camera); - view.set_content(&pipeline); + view.set_content(&sequence); } -void DesertPillars::create_pipeline() +void DesertPillars::create_sequence() { - pipeline.set_multisample(8); - pipeline.set_hdr(true); + sequence.set_multisample(8); + sequence.set_hdr(true); /* The shadow map is focused on the part of the scene that contains the pillars and the cube. Making the ground cast shadows as well would result @@ -362,26 +362,26 @@ void DesertPillars::create_pipeline() lighting.set_ambient(GL::Color(0.2)); // The skybox is rendered first - pipeline.add_pass(0, sky_scene); + sequence.add_pass(0, sky_scene); - GL::Pipeline::Pass *pass = &pipeline.add_pass(0, shadow_scene); + GL::Sequence::Pass *pass = &sequence.add_pass(0, shadow_scene); pass->set_lighting(&lighting); pass->set_depth_test(&GL::DepthTest::lequal()); /* A bloom filter enhances the realism of bright surfaces, even if there isn't anything really glowy in the scene. */ bloom.set_strength(0.3); - pipeline.add_postprocessor(bloom); + sequence.add_postprocessor(bloom); /* Lighting calculations are best done in linear color space, so the final image must be converted to srgb for display. */ colorcurve.set_srgb(); - pipeline.add_postprocessor(colorcurve); + sequence.add_postprocessor(colorcurve); - /* Initialize a second pipeline to render the environment map. It has the + /* Initialize a second sequence to render the environment map. It has the same renderables and passes, but no postprocessors or camera. */ - env_pipeline.add_pass(0, sky_scene); - pass = &env_pipeline.add_pass(0, shadow_scene); + env_sequence.add_pass(0, sky_scene); + pass = &env_sequence.add_pass(0, shadow_scene); pass->set_lighting(&lighting); pass->set_depth_test(&GL::DepthTest::lequal()); } @@ -778,7 +778,7 @@ void DesertPillars::create_cube() cube_data.object = new GL::Object(cube_data.mesh, &cube_tech); cube = new Cube(*cube_data.object); - env_cube = new GL::EnvironmentMap(resources, 512, *cube, env_pipeline); + env_cube = new GL::EnvironmentMap(resources, 512, *cube, env_sequence); scene.add(*env_cube); } diff --git a/source/builders/pipelinebuilder.cpp b/source/builders/pipelinebuilder.cpp deleted file mode 100644 index 12a5312f..00000000 --- a/source/builders/pipelinebuilder.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include "error.h" -#include "pipeline.h" -#include "pipelinebuilder.h" -#include "pipelinetemplate.h" -#include "renderbuffer.h" - -using namespace std; - -namespace Msp { -namespace GL { - -PipelineBuilder::PipelineBuilder(const PipelineTemplate &t): - tmpl(t) -{ - const vector &passes = tmpl.get_passes(); - for(vector::const_iterator i=passes.begin(); i!=passes.end(); ++i) - renderables[i->renderable_name] = 0; - const vector &postprocs = tmpl.get_postprocessors(); - for(PipelineTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) - if(!i->slot_name.empty()) - postprocessors[i->slot_name] = 0; -} - -void PipelineBuilder::set_renderable(const string &name, Renderable &rend) -{ - get_item(renderables, name) = &rend; -} - -void PipelineBuilder::set_postprocessor(const string &name, PostProcessor &pproc) -{ - get_item(postprocessors, name) = &pproc; -} - -void PipelineBuilder::build(Pipeline &pipeline) const -{ - pipeline.set_hdr(tmpl.get_hdr()); - pipeline.set_alpha(tmpl.get_alpha()); - unsigned samples = min(tmpl.get_maximum_multisample(), Renderbuffer::get_max_samples()); - if(samplesrenderable_name); - if(!renderable) - continue; - - Pipeline::Pass &pass = pipeline.add_pass(i->tag, *renderable); - pass.set_blend(i->blend.get()); - pass.set_depth_test(i->depth_test.get()); - pass.set_lighting(i->lighting.get()); - } - - const PipelineTemplate::PostProcessorArray &postprocs = tmpl.get_postprocessors(); - for(PipelineTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) - { - PostProcessor *proc = 0; - if(!i->slot_name.empty()) - proc = get_item(postprocessors, i->slot_name); - if(proc) - pipeline.add_postprocessor(*proc); - else if(i->postprocessor_template) - { - proc = i->postprocessor_template->create(tmpl.get_resources(), pipeline.get_width(), pipeline.get_height()); - if(proc) - pipeline.add_postprocessor_owned(proc); - } - } -} - -Pipeline *PipelineBuilder::build(unsigned w, unsigned h) const -{ - RefPtr pipeline = new Pipeline(w, h); - build(*pipeline); - return pipeline.release(); -} - -Pipeline *PipelineBuilder::build(const View &view) const -{ - RefPtr pipeline = new Pipeline(view); - build(*pipeline); - return pipeline.release(); -} - -Pipeline *PipelineBuilder::build(const Framebuffer &fbo) const -{ - RefPtr pipeline = new Pipeline(fbo); - build(*pipeline); - return pipeline.release(); -} - -} // namespace GL -} // namespace Msp diff --git a/source/builders/sequencebuilder.cpp b/source/builders/sequencebuilder.cpp new file mode 100644 index 00000000..0f2a1b54 --- /dev/null +++ b/source/builders/sequencebuilder.cpp @@ -0,0 +1,98 @@ +#include +#include +#include "error.h" +#include "renderbuffer.h" +#include "sequence.h" +#include "sequencebuilder.h" +#include "sequencetemplate.h" + +using namespace std; + +namespace Msp { +namespace GL { + +SequenceBuilder::SequenceBuilder(const SequenceTemplate &t): + tmpl(t) +{ + const vector &steps = tmpl.get_steps(); + for(vector::const_iterator i=steps.begin(); i!=steps.end(); ++i) + renderables[i->renderable_name] = 0; + const vector &postprocs = tmpl.get_postprocessors(); + for(SequenceTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) + if(!i->slot_name.empty()) + postprocessors[i->slot_name] = 0; +} + +void SequenceBuilder::set_renderable(const string &name, Renderable &rend) +{ + get_item(renderables, name) = &rend; +} + +void SequenceBuilder::set_postprocessor(const string &name, PostProcessor &pproc) +{ + get_item(postprocessors, name) = &pproc; +} + +void SequenceBuilder::build(Sequence &sequence) const +{ + sequence.set_hdr(tmpl.get_hdr()); + sequence.set_alpha(tmpl.get_alpha()); + unsigned samples = min(tmpl.get_maximum_multisample(), Renderbuffer::get_max_samples()); + if(samples &steps = tmpl.get_steps(); + for(vector::const_iterator i=steps.begin(); i!=steps.end(); ++i) + { + Renderable *renderable = get_item(renderables, i->renderable_name); + if(!renderable) + continue; + + Sequence::Step &step = sequence.add_step(i->tag, *renderable); + step.set_blend(i->blend.get()); + step.set_depth_test(i->depth_test.get()); + step.set_lighting(i->lighting.get()); + } + + const SequenceTemplate::PostProcessorArray &postprocs = tmpl.get_postprocessors(); + for(SequenceTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) + { + PostProcessor *proc = 0; + if(!i->slot_name.empty()) + proc = get_item(postprocessors, i->slot_name); + if(proc) + sequence.add_postprocessor(*proc); + else if(i->postprocessor_template) + { + proc = i->postprocessor_template->create(tmpl.get_resources(), sequence.get_width(), sequence.get_height()); + if(proc) + sequence.add_postprocessor_owned(proc); + } + } +} + +Sequence *SequenceBuilder::build(unsigned w, unsigned h) const +{ + RefPtr sequence = new Sequence(w, h); + build(*sequence); + return sequence.release(); +} + +Sequence *SequenceBuilder::build(const View &view) const +{ + RefPtr sequence = new Sequence(view); + build(*sequence); + return sequence.release(); +} + +Sequence *SequenceBuilder::build(const Framebuffer &fbo) const +{ + RefPtr sequence = new Sequence(fbo); + build(*sequence); + return sequence.release(); +} + +} // namespace GL +} // namespace Msp diff --git a/source/builders/pipelinebuilder.h b/source/builders/sequencebuilder.h similarity index 55% rename from source/builders/pipelinebuilder.h rename to source/builders/sequencebuilder.h index ab0dc4b9..739cc5ed 100644 --- a/source/builders/pipelinebuilder.h +++ b/source/builders/sequencebuilder.h @@ -1,5 +1,5 @@ -#ifndef PIPELINEBUILDER_H_ -#define PIPELINEBUILDER_H_ +#ifndef SEQUENCEBUILDER_H_ +#define SEQUENCEBUILDER_H_ #include #include @@ -8,29 +8,29 @@ namespace Msp { namespace GL { class Framebuffer; -class Pipeline; -class PipelineTemplate; +class Sequence; +class SequenceTemplate; class PostProcessor; class Renderable; class View; -class PipelineBuilder +class SequenceBuilder { private: - const PipelineTemplate &tmpl; + const SequenceTemplate &tmpl; std::map renderables; std::map postprocessors; public: - PipelineBuilder(const PipelineTemplate &); + SequenceBuilder(const SequenceTemplate &); void set_renderable(const std::string &, Renderable &); void set_postprocessor(const std::string &, PostProcessor &); - void build(Pipeline &) const; - Pipeline *build(unsigned, unsigned) const; - Pipeline *build(const View &) const; - Pipeline *build(const Framebuffer &) const; + void build(Sequence &) const; + Sequence *build(unsigned, unsigned) const; + Sequence *build(const View &) const; + Sequence *build(const Framebuffer &) const; }; } // namespace GL diff --git a/source/builders/pipelinetemplate.cpp b/source/builders/sequencetemplate.cpp similarity index 60% rename from source/builders/pipelinetemplate.cpp rename to source/builders/sequencetemplate.cpp index de91450e..bfab2804 100644 --- a/source/builders/pipelinetemplate.cpp +++ b/source/builders/sequencetemplate.cpp @@ -5,8 +5,8 @@ #include "bloom.h" #include "colorcurve.h" #include "lighting.h" -#include "pipelinetemplate.h" #include "resources.h" +#include "sequencetemplate.h" #include "tests.h" using namespace std; @@ -14,7 +14,7 @@ using namespace std; namespace Msp { namespace GL { -PipelineTemplate::PipelineTemplate(): +SequenceTemplate::SequenceTemplate(): resources(0), hdr(false), alpha(false), @@ -22,13 +22,13 @@ PipelineTemplate::PipelineTemplate(): max_multisample(0) { } -PipelineTemplate::~PipelineTemplate() +SequenceTemplate::~SequenceTemplate() { for(PostProcessorArray::iterator i=postprocessors.begin(); i!=postprocessors.end(); ++i) delete i->postprocessor_template; } -Resources &PipelineTemplate::get_resources() const +Resources &SequenceTemplate::get_resources() const { if(!resources) throw logic_error("no resources"); @@ -36,7 +36,7 @@ Resources &PipelineTemplate::get_resources() const } -PipelineTemplate::PostProcessorRegistry &PipelineTemplate::get_postprocessor_registry() +SequenceTemplate::PostProcessorRegistry &SequenceTemplate::get_postprocessor_registry() { static PostProcessorRegistry registry; static bool initialized = false; @@ -51,65 +51,55 @@ PipelineTemplate::PostProcessorRegistry &PipelineTemplate::get_postprocessor_reg } -PipelineTemplate::Pass::~Pass() +SequenceTemplate::Step::~Step() { } -PipelineTemplate::PostProcessor::PostProcessor(GL::PostProcessor::Template *ppt): +SequenceTemplate::PostProcessor::PostProcessor(GL::PostProcessor::Template *ppt): postprocessor_template(ppt) { } -PipelineTemplate::PostProcLoader::PostProcLoader() +SequenceTemplate::PostProcLoader::PostProcLoader() { get_postprocessor_registry().invoke_all(*this); } -PipelineTemplate::Loader::Loader(PipelineTemplate &t, Collection &c): - DataFile::CollectionObjectLoader(t, &c) +SequenceTemplate::Loader::Loader(SequenceTemplate &t, Collection &c): + DataFile::CollectionObjectLoader(t, &c) { - add("hdr", &PipelineTemplate::hdr); - add("alpha", &PipelineTemplate::alpha); + add("hdr", &SequenceTemplate::hdr); + add("alpha", &SequenceTemplate::alpha); add("multisample", &Loader::multisample); add("multisample", &Loader::multisample_range); - add("pass", &Loader::pass); add("postprocessor", &Loader::postprocessor); + add("step", &Loader::step); + + // Deprecated + add("pass", &Loader::step); obj.resources = &c; } -void PipelineTemplate::Loader::postprocessor_loaded() +void SequenceTemplate::Loader::postprocessor_loaded() { obj.postprocessors.push_back(get_postprocessor_template()); } -void PipelineTemplate::Loader::multisample(unsigned samples) +void SequenceTemplate::Loader::multisample(unsigned samples) { obj.required_multisample = samples; obj.max_multisample = samples; } -void PipelineTemplate::Loader::multisample_range(unsigned req, unsigned max) +void SequenceTemplate::Loader::multisample_range(unsigned req, unsigned max) { obj.required_multisample = req; obj.max_multisample = max; } -void PipelineTemplate::Loader::pass(const string &tag, const string &rend) -{ - Pass pss;; - pss.tag = tag; - pss.renderable_name = rend; - if(coll) - load_sub(pss, *coll); - else - load_sub(pss); - - obj.passes.push_back(pss); -} - -void PipelineTemplate::Loader::postprocessor(const string &slot) +void SequenceTemplate::Loader::postprocessor(const string &slot) { PostProcLoader ldr; load_sub_with(ldr); @@ -119,20 +109,33 @@ void PipelineTemplate::Loader::postprocessor(const string &slot) obj.postprocessors.push_back(pp); } +void SequenceTemplate::Loader::step(const string &tag, const string &rend) +{ + Step stp; + stp.tag = tag; + stp.renderable_name = rend; + if(coll) + load_sub(stp, *coll); + else + load_sub(stp); + + obj.steps.push_back(stp); +} + -PipelineTemplate::Pass::Loader::Loader(Pass &p): - DataFile::CollectionObjectLoader(p, 0) +SequenceTemplate::Step::Loader::Loader(Step &p): + DataFile::CollectionObjectLoader(p, 0) { init(); } -PipelineTemplate::Pass::Loader::Loader(Pass &p, Collection &c): - DataFile::CollectionObjectLoader(p, &c) +SequenceTemplate::Step::Loader::Loader(Step &p, Collection &c): + DataFile::CollectionObjectLoader(p, &c) { init(); } -void PipelineTemplate::Pass::Loader::init() +void SequenceTemplate::Step::Loader::init() { add("blend", &Loader::blend); add("blend", &Loader::blend_predefined); @@ -142,7 +145,7 @@ void PipelineTemplate::Pass::Loader::init() add("lighting", &Loader::lighting_inline); } -void PipelineTemplate::Pass::Loader::blend_predefined(const string &name) +void SequenceTemplate::Step::Loader::blend_predefined(const string &name) { const Blend *bln = 0; if(name=="alpha") @@ -158,12 +161,12 @@ void PipelineTemplate::Pass::Loader::blend_predefined(const string &name) obj.blend.keep(); } -void PipelineTemplate::Pass::Loader::blend(BlendFactor src, BlendFactor dest) +void SequenceTemplate::Step::Loader::blend(BlendFactor src, BlendFactor dest) { obj.blend = new Blend(src, dest); } -void PipelineTemplate::Pass::Loader::depth_test_predefined(const string &name) +void SequenceTemplate::Step::Loader::depth_test_predefined(const string &name) { const DepthTest *dtest = 0; if(name=="lequal") @@ -175,25 +178,25 @@ void PipelineTemplate::Pass::Loader::depth_test_predefined(const string &name) obj.depth_test.keep(); } -void PipelineTemplate::Pass::Loader::depth_test(Predicate pred) +void SequenceTemplate::Step::Loader::depth_test(Predicate pred) { obj.depth_test = new DepthTest(pred); } -void PipelineTemplate::Pass::Loader::lighting_inline() +void SequenceTemplate::Step::Loader::lighting_inline() { RefPtr lightn = new Lighting; load_sub(*lightn); obj.lighting = lightn; } -void PipelineTemplate::Pass::Loader::lighting(const string &name) +void SequenceTemplate::Step::Loader::lighting(const string &name) { obj.lighting = &get_collection().get(name); obj.lighting.keep(); } -/*void PipelineTemplate::Pass::Loader::scene(const string &name) +/*void SequenceTemplate::Step::Loader::scene(const string &name) { obj.default_renderable = get_collection().get(name); }*/ diff --git a/source/builders/pipelinetemplate.h b/source/builders/sequencetemplate.h similarity index 80% rename from source/builders/pipelinetemplate.h rename to source/builders/sequencetemplate.h index 515ebfaf..5c5b04b5 100644 --- a/source/builders/pipelinetemplate.h +++ b/source/builders/sequencetemplate.h @@ -1,5 +1,5 @@ -#ifndef PIPELINETEMPLATE_H_ -#define PIPELINETEMPLATE_H_ +#ifndef SEQUENCETEMPLATE_H_ +#define SEQUENCETEMPLATE_H_ #include #include @@ -15,7 +15,7 @@ namespace GL { class DepthTest; class Lighting; -class PipelineTemplate +class SequenceTemplate { private: class PostProcLoader: virtual public DataFile::Loader @@ -42,29 +42,29 @@ private: template void postprocessor(); - friend class PipelineTemplate; + friend class SequenceTemplate; }; public: - class Loader: public DataFile::CollectionObjectLoader, public PostProcLoader + class Loader: public DataFile::CollectionObjectLoader, public PostProcLoader { public: - Loader(PipelineTemplate &, Collection &); + Loader(SequenceTemplate &, Collection &); virtual void postprocessor_loaded(); void multisample(unsigned); void multisample_range(unsigned, unsigned); - void pass(const std::string &, const std::string &); void postprocessor(const std::string &); + void step(const std::string &, const std::string &); }; - struct Pass + struct Step { - class Loader: public DataFile::CollectionObjectLoader + class Loader: public DataFile::CollectionObjectLoader { public: - Loader(Pass &); - Loader(Pass &, Collection &); + Loader(Step &); + Loader(Step &, Collection &); private: void init(); @@ -85,7 +85,7 @@ public: std::string renderable_name; //Renderable *default_renderable; - ~Pass(); + ~Step(); }; struct PostProcessor @@ -96,7 +96,6 @@ public: PostProcessor(GL::PostProcessor::Template * = 0); }; - typedef std::vector PassArray; typedef std::vector PostProcessorArray; private: @@ -107,19 +106,19 @@ private: bool alpha; unsigned required_multisample; unsigned max_multisample; - PassArray passes; + std::vector steps; PostProcessorArray postprocessors; public: - PipelineTemplate(); - ~PipelineTemplate(); + SequenceTemplate(); + ~SequenceTemplate(); Resources &get_resources() const; bool get_hdr() const { return hdr; } bool get_alpha() const { return alpha; } unsigned get_required_multisample() const { return required_multisample; } unsigned get_maximum_multisample() const { return max_multisample; } - const PassArray &get_passes() const { return passes; } + const std::vector &get_steps() const { return steps; } const PostProcessorArray &get_postprocessors() const { return postprocessors; } template @@ -129,13 +128,13 @@ private: }; template -void PipelineTemplate::register_postprocessor(const std::string &kw) +void SequenceTemplate::register_postprocessor(const std::string &kw) { get_postprocessor_registry().register_type(kw); } template -void PipelineTemplate::PostProcLoader::postprocessor() +void SequenceTemplate::PostProcLoader::postprocessor() { if(postproc) throw std::logic_error("Only one postprocessor allowed per slot"); diff --git a/source/effects/environmentmap.h b/source/effects/environmentmap.h index bd6800a6..a13bea3f 100644 --- a/source/effects/environmentmap.h +++ b/source/effects/environmentmap.h @@ -19,9 +19,9 @@ class Resources; Creates a cube map texture of the surroundings of the renderable. This texture can then be used to implement effects such as reflections or refractions. -If the EnvironmentMap is used in a Pipeline, it's worth noting that the cube +If the EnvironmentMap is used in a Sequence, it's worth noting that the cube map will be prepared outside of any rendering pass. It's recommended to use -another Pipeline to define which passes should be used to render the +another Sequence to define which passes should be used to render the environment. */ class EnvironmentMap: public Effect diff --git a/source/materials/light.h b/source/materials/light.h index e94f3c5a..c7e28188 100644 --- a/source/materials/light.h +++ b/source/materials/light.h @@ -21,7 +21,7 @@ is not 180 degrees, it's a spotlight. Otherwise it's an omnidirectional point light. Lights are usually grouped with a Lighting object, which can be used in a -Pipeline::Pass. +Sequence::Step. Lights do not cast shadows by themselves. See ShadowMap for that. */ diff --git a/source/render/pipeline.cpp b/source/render/sequence.cpp similarity index 75% rename from source/render/pipeline.cpp rename to source/render/sequence.cpp index 21f9e85e..6898e668 100644 --- a/source/render/pipeline.cpp +++ b/source/render/sequence.cpp @@ -3,10 +3,10 @@ #include "camera.h" #include "framebuffer.h" #include "lighting.h" -#include "pipeline.h" #include "postprocessor.h" #include "renderbuffer.h" #include "renderer.h" +#include "sequence.h" #include "tests.h" #include "texture2d.h" #include "view.h" @@ -16,23 +16,23 @@ using namespace std; namespace Msp { namespace GL { -Pipeline::Pipeline(unsigned w, unsigned h, bool d) +Sequence::Sequence(unsigned w, unsigned h, bool d) { init(w, h); hdr = d; } -Pipeline::Pipeline(const View &view) +Sequence::Sequence(const View &view) { init(view.get_width(), view.get_height()); } -Pipeline::Pipeline(const Framebuffer &fbo) +Sequence::Sequence(const Framebuffer &fbo) { init(fbo.get_width(), fbo.get_height()); } -void Pipeline::init(unsigned w, unsigned h) +void Sequence::init(unsigned w, unsigned h) { camera = 0; width = w; @@ -45,14 +45,14 @@ void Pipeline::init(unsigned w, unsigned h) target[1] = 0; } -Pipeline::~Pipeline() +Sequence::~Sequence() { delete target[0]; delete target[1]; delete target_ms; } -void Pipeline::set_hdr(bool h) +void Sequence::set_hdr(bool h) { if(h==hdr) return; @@ -70,7 +70,7 @@ void Pipeline::set_hdr(bool h) } } -void Pipeline::set_alpha(bool a) +void Sequence::set_alpha(bool a) { if(a==alpha) return; @@ -88,7 +88,7 @@ void Pipeline::set_alpha(bool a) } } -void Pipeline::set_multisample(unsigned s) +void Sequence::set_multisample(unsigned s) { if(s==samples) return; @@ -106,23 +106,23 @@ void Pipeline::set_multisample(unsigned s) } } -Pipeline::Pass &Pipeline::add_pass(Tag tag, Renderable &r) +Sequence::Step &Sequence::add_step(Tag tag, Renderable &r) { - passes.push_back(Pass(tag, &r)); - return passes.back(); + steps.push_back(Step(tag, &r)); + return steps.back(); } -void Pipeline::add_postprocessor(PostProcessor &pp) +void Sequence::add_postprocessor(PostProcessor &pp) { add_postprocessor(&pp, true); } -void Pipeline::add_postprocessor_owned(PostProcessor *pp) +void Sequence::add_postprocessor_owned(PostProcessor *pp) { add_postprocessor(pp, false); } -void Pipeline::add_postprocessor(PostProcessor *pp, bool keep) +void Sequence::add_postprocessor(PostProcessor *pp, bool keep) { postproc.push_back(pp); if(keep) @@ -138,25 +138,25 @@ void Pipeline::add_postprocessor(PostProcessor *pp, bool keep) } } -void Pipeline::setup_frame(Renderer &renderer) +void Sequence::setup_frame(Renderer &renderer) { - for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i) + for(StepList::const_iterator i=steps.begin(); i!=steps.end(); ++i) if(Renderable *renderable = i->get_renderable()) renderable->setup_frame(renderer); for(vector::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) i->renderable->setup_frame(renderer); } -void Pipeline::finish_frame() +void Sequence::finish_frame() { - for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i) + for(StepList::const_iterator i=steps.begin(); i!=steps.end(); ++i) if(Renderable *renderable = i->get_renderable()) renderable->finish_frame(); for(vector::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) i->renderable->finish_frame(); } -void Pipeline::render(Renderer &renderer, Tag tag) const +void Sequence::render(Renderer &renderer, Tag tag) const { if(tag.id) return; @@ -174,7 +174,7 @@ void Pipeline::render(Renderer &renderer, Tag tag) const fbo.clear(); } - for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i) + for(StepList::const_iterator i=steps.begin(); i!=steps.end(); ++i) { if(const DepthTest *dt = i->get_depth_test()) dt->bind(); @@ -219,7 +219,7 @@ void Pipeline::render(Renderer &renderer, Tag tag) const } } -void Pipeline::create_targets(unsigned recreate) +void Sequence::create_targets(unsigned recreate) { if(recreate>=2) { @@ -249,7 +249,7 @@ void Pipeline::create_targets(unsigned recreate) } -Pipeline::Pass::Pass(Tag t, Renderable *r): +Sequence::Step::Step(Tag t, Renderable *r): tag(t), lighting(0), depth_test(0), @@ -258,28 +258,28 @@ Pipeline::Pass::Pass(Tag t, Renderable *r): renderable(r) { } -void Pipeline::Pass::set_lighting(const Lighting *l) +void Sequence::Step::set_lighting(const Lighting *l) { lighting = l; } -void Pipeline::Pass::set_depth_test(const DepthTest *d) +void Sequence::Step::set_depth_test(const DepthTest *d) { depth_test = d; } -void Pipeline::Pass::set_blend(const Blend *b) +void Sequence::Step::set_blend(const Blend *b) { blend = b; } -void Pipeline::Pass::set_clipping(const Clipping *c) +void Sequence::Step::set_clipping(const Clipping *c) { clipping =c; } -Pipeline::Slot::Slot(Renderable *r): +Sequence::Slot::Slot(Renderable *r): renderable(r) { } diff --git a/source/render/pipeline.h b/source/render/sequence.h similarity index 67% rename from source/render/pipeline.h rename to source/render/sequence.h index 91996186..97d376d1 100644 --- a/source/render/pipeline.h +++ b/source/render/sequence.h @@ -1,5 +1,5 @@ -#ifndef MSP_GL_PIPELINE_H_ -#define MSP_GL_PIPELINE_H_ +#ifndef MSP_GL_SEQUENCE_H_ +#define MSP_GL_SEQUENCE_H_ #include #include @@ -21,22 +21,23 @@ class PostProcessor; class View; /** -Top-level content class. Typically a Pipeline is used as the content +Top-level content class. Typically a Sequence is used as the content Renderable for a View or effects such as ShadowMap or EnvironmentMap. -A Pipeline contains a sequence of passes. Each pass has a Renderable along -with Lighting, Clipping, DepthTest and Blend states. Scenes can be used to -organize Renderables within a pass. +A Sequence consists of a number of steps. Each step is defined with a +Renderable and a tag to render it with and may also have Lighting, Clipping, +DepthTest and Blend states. Scenes can be used to further organize Renderables +within a step. -PostProcessors can be applied after all of the passes in the Pipeline have been -rendered. Framebuffer objects are automatically used to pass render results to -the PostProcessors. High dynamic range and multisample rendering can be +PostProcessors can be applied after all of the steps in the Sequence have been +processed. Framebuffer objects are automatically used to pass render results +to the PostProcessors. High dynamic range and multisample rendering can be requested for increased quality. */ -class Pipeline: public Renderable +class Sequence: public Renderable { public: - class Pass + class Step { private: Tag tag; @@ -47,7 +48,7 @@ public: Renderable *renderable; public: - Pass(Tag, Renderable *); + Step(Tag, Renderable *); Tag get_tag() const { return tag; } @@ -62,6 +63,8 @@ public: Renderable *get_renderable() const { return renderable; } }; + DEPRECATED typedef Step Pass; + private: struct Slot { @@ -71,9 +74,9 @@ private: Slot(Renderable *); }; - typedef std::list PassList; + typedef std::list StepList; - PassList passes; + StepList steps; const Camera *camera; std::vector renderables; std::vector > postproc; @@ -86,13 +89,13 @@ private: RenderTarget *target_ms; public: - Pipeline(unsigned, unsigned, bool = false); - Pipeline(const View &); - Pipeline(const Framebuffer &); + Sequence(unsigned, unsigned, bool = false); + Sequence(const View &); + Sequence(const Framebuffer &); private: void init(unsigned, unsigned); public: - ~Pipeline(); + ~Sequence(); /* Sets high dynamic range mode. Requires floating-point texture support. A ColorCurve postprocessor is recommended for full benefit. */ @@ -109,15 +112,17 @@ public: bool get_hdr() const { return hdr; } unsigned get_multisample() const { return samples; } - /** Adds a pass to the pipeline. It's permissible to add the same + /** Adds a step to the sequence. It's permissible to add the same Renderable multiple times. */ - Pass &add_pass(Tag, Renderable &); + Step &add_step(Tag, Renderable &); + + DEPRECATED Step &add_pass(Tag t, Renderable &r) { return add_step(t, r); } - /** Adds a postprocessor to the pipeline. */ + /** Adds a postprocessor to the sequence. */ void add_postprocessor(PostProcessor &); - /** Adds a postprocessor to the pipeline, transferring ownership. The - postprocessor will be deleted together with with pipeline. It is also + /** Adds a postprocessor to the sequence, transferring ownership. The + postprocessor will be deleted together with with sequence. It is also deleted if this call throws an exception. */ void add_postprocessor_owned(PostProcessor *); diff --git a/source/resources/resources.cpp b/source/resources/resources.cpp index dca3e8d3..e83f33eb 100644 --- a/source/resources/resources.cpp +++ b/source/resources/resources.cpp @@ -10,7 +10,7 @@ #include "mesh.h" #include "module.h" #include "object.h" -#include "pipelinetemplate.h" +#include "sequencetemplate.h" #include "pose.h" #include "program.h" #include "resourcemanager.h" @@ -48,7 +48,7 @@ Resources::Resources(): add_type().keyword("mesh").creator(&Resources::create_mesh); add_type().suffix(".glsl").suffix(".spv").creator(&Resources::create_module); add_type().keyword("object"); - add_type().suffix(".pipe").keyword("pipeline"); + add_type().suffix(".seq").keyword("sequence"); add_type().keyword("pose"); add_type().keyword("shader").creator(&Resources::create_program); add_type().suffix(".samp").keyword("sampler"); diff --git a/tools/viewer.cpp b/tools/viewer.cpp index 4ae9c87b..ffdc4ec6 100644 --- a/tools/viewer.cpp +++ b/tools/viewer.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,7 +65,7 @@ private: Input::Mouse mouse; Resources resources; GL::WindowView view; - GL::Pipeline pipeline; + GL::Sequence sequence; GL::Renderable *renderable; GL::AnimatedObject *anim_object; GL::AnimationPlayer *anim_player; @@ -121,7 +121,7 @@ Viewer::Viewer(int argc, char **argv): gl_ctx(window, opts.gl_opts), mouse(window), view(window, gl_ctx), - pipeline(view), + sequence(view), renderable(0), anim_object(0), anim_player(0), @@ -212,12 +212,12 @@ Viewer::Viewer(int argc, char **argv): camera.set_up_direction(GL::Vector3(0, 0, 1)); update_camera(); - GL::Pipeline::Pass &pass = pipeline.add_pass(0, *renderable); - pass.set_lighting(&lighting); - pass.set_depth_test(&GL::DepthTest::lequal()); - pass.set_blend(&GL::Blend::alpha()); + GL::Sequence::Step &step = sequence.add_step(0, *renderable); + step.set_lighting(&lighting); + step.set_depth_test(&GL::DepthTest::lequal()); + step.set_blend(&GL::Blend::alpha()); - view.set_content(&pipeline); + view.set_content(&sequence); view.set_camera(&camera); } -- 2.45.2