Lumiera  0.pre.03
»edit your freedom«
job-ticket.cpp
Go to the documentation of this file.
1 /*
2  JobTicket - execution plan for render jobs
3 
4  Copyright (C)
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
26 #include "lib/hash-combine.hpp"
27 #include "lib/depend.hpp"
28 #include "lib/util.hpp"
29 
30 
31 namespace steam {
32 namespace engine {
33 
34  using vault::gear::Job;
36  using lib::HashVal;
37  using lib::unConst;
38  using lib::time::FSecs;
39 
40 
41  namespace { // Details...
43 
44  /* ======== hard wired =================*/
45  const FSecs JOB_MINIMUM_RUNTIME{1,1000};
46 
47  } // (END) Details...
48 
49 
50 
51 
52 
55 
57  : provision_{nopFunctor(), ExitNode::NIL}
58  { }
59 
60 
70  Job
72  {
73  if (this->empty())
74  {
75  return Job(nopFunctor(), InvocationInstanceID(), nominalTime);
76  }
77  else
78  {
79  REQUIRE (this->isValid(), "Attempt to generate render job for incomplete or unspecified render plan.");
80  JobClosure& functor = static_cast<JobClosure&> (unConst(provision_.jobFunctor));
81  InvocationInstanceID invoKey{timeHash (nominalTime, provision_.invocationSeed)};
82 
83  return Job(functor, invoKey, nominalTime);
84  }
85  }
86 
87 
93  Duration
95  {
96  if (this->empty())
97  return Duration{JOB_MINIMUM_RUNTIME};
98  else
99  {
100  REQUIRE (isValid(), "Attempt to determine timings for incomplete or unspecified render plan.");
101  return provision_.exitNode.getUpperBoundRuntime();
102  }
103  }
104 
105 
110  JobTicket::timeHash (Time nominalTime, InvocationInstanceID const& seed)
111  {
112  InvocationInstanceID res{seed};
113  HashVal timeMark = res.part.t;
114  lib::hash::combine (timeMark, hash_value (nominalTime));
115  res.part.t = timeMark;
116  return res;
117  }
118 
119 
120  namespace {
121  inline bool
122  operator== (InvocationInstanceID const& l, InvocationInstanceID const& r)
123  {
124  return lumiera_invokey_eq (unConst(&l), unConst(&r));
125  }
126  }
127 
131  bool
132  JobTicket::verifyInstance (JobFunctor& functor, InvocationInstanceID const& invoKey, Time nominalTime) const
133  {
134  return util::isSameObject (provision_.jobFunctor, functor)
135  and invoKey == timeHash (nominalTime, provision_.invocationSeed);
136  }
137 
138 
139 
140 
141 }} // namespace steam::engine
bool verifyInstance(JobFunctor &, InvocationInstanceID const &, Time) const
Helper for tests: verify the given invocation parameters match this JobTicket.
Definition: job-ticket.cpp:132
Execution plan to generate render jobs within a specific render process.
Generic implementation of a JobFunctor to perform no calculations.
void combine(size_t &combinedHash, size_t additionalHash)
meld the additional hash value into the given base hash value.
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
static JobTicket NOP
special »do nothing« JobTicket marker
Definition: job-ticket.hpp:127
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
static InvocationInstanceID timeHash(Time, InvocationInstanceID const &)
Tag the precomputed invocation ID with the nominal frame time.
Definition: job-ticket.cpp:110
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:220
Singleton services and Dependency Injection.
opaque ID attached to each individual job invocation.
Definition: job.h:103
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
Interface of the closure for frame rendering jobs.
Definition: job.h:235
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:468
Individual frame rendering task, forwarding to a closure.
Definition: job.h:268
HashVal hash_value(ProcID const &procID)
generate registry hash value based on the distinct data in ProcID.
Definition: proc-node.cpp:105
static ExitNode NIL
storage for the »inactive« ExitNode marker
Definition: exit-node.hpp:94
execution plan for pulling a specific exit node.
Definition: job-ticket.hpp:78
Duration getExpectedRuntime()
Core operation: guess expected runtime for rendering.
Definition: job-ticket.cpp:94
Job createJobFor(Time nominalTime)
Core operation: build a concrete render job based on this blueprint.
Definition: job-ticket.cpp:71