]> git.tdb.fi Git - libs/gl.git/blobdiff - source/builders/sequencebuilder.cpp
Redesign depth and stencil test and blend state management
[libs/gl.git] / source / builders / sequencebuilder.cpp
index 3abfca81f3d6a3f0b7263c0ca98b18369c91dba6..12e7bdf3df96ea43c415e3674c5ffdf19d7cf764 100644 (file)
@@ -1,5 +1,7 @@
 #include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
+#include <msp/strings/format.h>
+#include "deviceinfo.h"
 #include "error.h"
 #include "renderbuffer.h"
 #include "sequence.h"
@@ -16,7 +18,7 @@ SequenceBuilder::SequenceBuilder(const SequenceTemplate &t):
 {
        const vector<SequenceTemplate::Step> &steps = tmpl.get_steps();
        for(vector<SequenceTemplate::Step>::const_iterator i=steps.begin(); i!=steps.end(); ++i)
-               renderables[i->slot_name] = 0;
+               renderables[i->slot_name] = i->default_renderable;
        const vector<SequenceTemplate::PostProcessor> &postprocs = tmpl.get_postprocessors();
        for(SequenceTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i)
                if(!i->slot_name.empty())
@@ -33,11 +35,25 @@ void SequenceBuilder::set_postprocessor(const string &name, PostProcessor &pproc
        get_item(postprocessors, name) = &pproc;
 }
 
+void SequenceBuilder::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+       debug_name = name;
+#else
+       (void)name;
+#endif
+}
+
 void SequenceBuilder::build(Sequence &sequence) const
 {
+#ifdef DEBUG
+       if(!debug_name.empty())
+               sequence.set_debug_name(debug_name);
+#endif
+
        sequence.set_hdr(tmpl.get_hdr());
        sequence.set_alpha(tmpl.get_alpha());
-       unsigned samples = min(tmpl.get_maximum_multisample(), Renderbuffer::get_max_samples());
+       unsigned samples = min(tmpl.get_maximum_multisample(), Limits::get_global().max_samples);
        if(samples<tmpl.get_required_multisample())
                throw invalid_operation("SequenceBuilder::build");
 
@@ -51,9 +67,10 @@ void SequenceBuilder::build(Sequence &sequence) const
                        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());
+               step.set_blend(i->blend);
+               step.set_depth_test(i->depth_test);
+               step.set_stencil_test(i->stencil_test);
+               step.set_lighting(i->lighting);
        }
 
        const SequenceTemplate::PostProcessorArray &postprocs = tmpl.get_postprocessors();
@@ -66,9 +83,15 @@ void SequenceBuilder::build(Sequence &sequence) const
                        sequence.add_postprocessor(*proc);
                else if(i->postprocessor_template)
                {
-                       proc = i->postprocessor_template->create(tmpl.get_resources(), sequence.get_width(), sequence.get_height());
+                       proc = i->postprocessor_template->create(sequence.get_width(), sequence.get_height());
                        if(proc)
+                       {
+#ifdef DEBUG
+                               if(!debug_name.empty())
+                                       proc->set_debug_name(format("%s/%d.pproc", debug_name, i-postprocs.begin()));
+#endif
                                sequence.add_postprocessor_owned(proc);
+                       }
                }
        }
 }