| 21 | } |
| 22 | |
| 23 | void Tr2RenderJobs::Run( Be::Time realTime, Be::Time simTime ) |
| 24 | { |
| 25 | CCP_STATS_SCOPED_TIME( deviceRenderJobs ); |
| 26 | CCP_STATS_SET( deviceChainedRenderJobsCount, m_scheduledChained.size() ); |
| 27 | CCP_STATS_SET( deviceOnceRenderJobsCount, m_scheduledOnce.size() ); |
| 28 | |
| 29 | D3DPERF_EVENT( L"RenderJobs" ); |
| 30 | |
| 31 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 32 | |
| 33 | std::vector<TriRenderJobPtr> copyOfJobs; |
| 34 | |
| 35 | Tr2PushPopRT pushPopRT( renderContext ); |
| 36 | Tr2PushPopDS pushPopDS( renderContext ); |
| 37 | |
| 38 | copyOfJobs.insert( copyOfJobs.end(), m_scheduledRecurring.begin(), m_scheduledRecurring.end() ); |
| 39 | |
| 40 | for( auto it = copyOfJobs.cbegin(); it != copyOfJobs.cend(); ++it ) |
| 41 | { |
| 42 | TriRenderJob* rj = *it; |
| 43 | TriRenderJobStatus status = rj->Run( realTime, simTime ); |
| 44 | CCP_ASSERT( status != RJ_FAILED ); |
| 45 | } |
| 46 | |
| 47 | // Process jobs scheduled for one-off execution. Every job on this list is run, |
| 48 | // jobs that are still in progress are continued next frame. |
| 49 | copyOfJobs.clear(); |
| 50 | copyOfJobs.insert( copyOfJobs.end(), m_scheduledOnce.begin(), m_scheduledOnce.end() ); |
| 51 | |
| 52 | CTriRenderJobVector continuedJobs; |
| 53 | for( auto it = copyOfJobs.cbegin(); it != copyOfJobs.cend(); ++it ) |
| 54 | { |
| 55 | TriRenderJob* rj = *it; |
| 56 | TriRenderJobStatus status = rj->Run( realTime, simTime ); |
| 57 | if( status == RJ_IN_PROGRESS ) |
| 58 | { |
| 59 | continuedJobs.Insert( -1, rj ); |
| 60 | } |
| 61 | } |
| 62 | m_scheduledOnce.Remove( -1 ); |
| 63 | |
| 64 | for( auto it = continuedJobs.cbegin(); it != continuedJobs.cend(); ++it ) |
| 65 | { |
| 66 | TriRenderJob* rj = *it; |
| 67 | m_scheduledOnce.Insert( -1, rj ); |
| 68 | } |
| 69 | continuedJobs.Remove( -1 ); |
| 70 | |
| 71 | // Process jobs scheduled for chained one-off execution. Jobs on this list are run |
| 72 | // until a job is found still in progress. That job and the remaining jobs are then |
| 73 | // continued on the next frame. |
| 74 | copyOfJobs.clear(); |
| 75 | copyOfJobs.insert( copyOfJobs.end(), m_scheduledChained.begin(), m_scheduledChained.end() ); |
| 76 | for( auto it = copyOfJobs.cbegin(); it != copyOfJobs.cend(); ++it ) |
| 77 | { |
| 78 | TriRenderJob* rj = *it; |
| 79 | TriRenderJobStatus status = rj->Run( realTime, simTime ); |
| 80 | if( status == RJ_IN_PROGRESS ) |