• R/O
  • SSH
  • HTTPS

eirsamples: Commit


Commit MetaInfo

Revision3 (tree)
Time2017-09-27 12:20:26
Authorquiret

Log Message

- added fence for CPU and GPU synchronization

Change Summary

Incremental Difference

--- magicrwsample/src/main.cpp (revision 2)
+++ magicrwsample/src/main.cpp (revision 3)
@@ -58,6 +58,11 @@
5858
5959 assert( cmdQueue != NULL );
6060
61+ // Fence for GPU and CPU synchronization.
62+ DriverFence *cmdFence = d3dDriver->CreateFence( 0 );
63+
64+ assert( cmdFence != NULL );
65+
6166 // Set up the game resources.
6267 DriverSwapChain *swapChain = d3dDriver->CreateSwapChain( rwWindow, 2, cmdQueue ); // we want to double-buffer.
6368
@@ -97,6 +102,19 @@
97102 // Present the rendered result.
98103 swapChain->Present( false );
99104
105+ // Wait for finish of the command buffer.
106+ {
107+ cmdFence->Signal( 0 );
108+
109+ bool gotToSignal = cmdQueue->Signal( cmdFence, 1 );
110+
111+ assert( gotToSignal == true );
112+
113+ cmdFence->SingleWaitForSignal( 1, RW_DRIVER_FENCE_NO_TIMEOUT );
114+ }
115+
116+ // TODO: clear command buffers.
117+
100118 // Give cycles to the window manager.
101119 // In the multi-threaded environment, this will effectively be a no-op.
102120 PulseWindowingSystem( engineInterface );
@@ -117,6 +135,8 @@
117135 // Release the swap chain device resource.
118136 d3dDriver->DestroySwapChain( swapChain );
119137
138+ d3dDriver->DestroyFence( cmdFence );
139+
120140 d3dDriver->DestroyCommandQueue( cmdQueue );
121141
122142 // Terminate the driver.
Show on old repository browser