MCPcopy Create free account
hub / github.com/carbonengine/trinity / Run

Method Run

trinity/RenderJob/TriRenderJob.cpp:18–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2RenderContext* renderContextPtr )
19{
20 D3DPERF_EVENT1( L"TriRenderJob::%S", (const wchar_t*)CA2W( m_name.c_str() ) );
21
22 if( !m_enabled )
23 {
24 return RJ_DONE;
25 }
26
27 typedef std::vector<TriRenderStepPtr> RenderStepVector;
28
29 RenderStepVector copyOfSteps( m_renderSteps.size() ); // we need to copy steps because lists can change when executed
30
31 for( size_t i = 0; i != m_renderSteps.size(); ++i )
32 {
33 copyOfSteps[i] = m_renderSteps[i];
34 }
35
36 // Note that we don't always initialize the cursor here - it is persisted
37 // across runs, in case a step does not finish its execution. Then we need to
38 // continue where we left off last frame.
39 // Changing the list may however result in an out-of-bounds cursor.
40 if( m_status != RJ_IN_PROGRESS || m_currentStep >= copyOfSteps.size() )
41 {
42 m_currentStep = 0;
43 }
44
45 Tr2RenderContext& renderContext =
46 renderContextPtr ? *renderContextPtr : Tr2RenderContext_GetMainThreadRenderContext();
47
48 const size_t preRT = renderContext.GetStackSizeRT();
49 const size_t preDS = renderContext.GetStackSizeDS();
50
51 TriStepResult result = RS_OK;
52 for( ; m_currentStep < copyOfSteps.size(); ++m_currentStep )
53 {
54 if( copyOfSteps[m_currentStep] && copyOfSteps[m_currentStep]->IsEnabled() )
55 {
56 copyOfSteps[m_currentStep]->BeginExecute( renderContext );
57 result = copyOfSteps[m_currentStep]->Execute( realTime, simTime, renderContext );
58 copyOfSteps[m_currentStep]->EndExecute( renderContext );
59
60 // We almost never want a job that leaves the renderTarget/depthStencil stack in a changed state.
61 if( m_stackGuard )
62 {
63 CCP_ASSERT( preRT <= renderContext.GetStackSizeRT() && "Too many Pops (RT)" );
64 CCP_ASSERT( preDS <= renderContext.GetStackSizeDS() && "Too many Pops (DS)" );
65 }
66
67 // A step can potentially disable the render job. We musn't continue with the next steps if this happens.
68 if( result != RS_OK || !m_enabled )
69 {
70 break;
71 }
72 }
73 }
74
75 if( m_stackGuard )

Callers 3

RenderMethod · 0.45
ExecuteMethod · 0.45
RunJobHelperMethod · 0.45

Calls 9

sizeMethod · 0.80
IsEnabledMethod · 0.80
BeginExecuteMethod · 0.80
EndExecuteMethod · 0.80
GetStackSizeRTMethod · 0.45
GetStackSizeDSMethod · 0.45
ExecuteMethod · 0.45
PopRenderTargetMethod · 0.45
PopDepthStencilMethod · 0.45

Tested by

no test coverage detected