diff options
Diffstat (limited to 'balls.c')
| -rw-r--r-- | balls.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -533,7 +533,6 @@ setKernelArgs(void) { void animate(int v) { - cl_event readEvent; int err; clock_t tstart, elapsed; unsigned int nextFrame; @@ -544,20 +543,18 @@ animate(int v) { collideBalls(); collideWalls(); - /* Copy new positions from CPU to host asynchronously. */ - err = clEnqueueReadBuffer(cpuQueue, positionsCpuBuf, CL_FALSE, 0, nBalls*2*sizeof(float), positionsHostBuf, 0, NULL, &readEvent); + display(); + + /* Copy new positions from CPU to host. */ + err = clEnqueueReadBuffer(cpuQueue, positionsCpuBuf, CL_TRUE, 0, nBalls*2*sizeof(float), positionsHostBuf, 0, NULL, NULL); if (err < 0) sysfatal("Failed to copy positions from CPU to host.\n"); - display(); - /* Copy new positions from host to GPU. */ - err = clEnqueueWriteBuffer(gpuQueue, positionsGpuBuf, CL_TRUE, 0, nBalls*2*sizeof(float), positionsHostBuf, 1, &readEvent, NULL); + err = clEnqueueWriteBuffer(gpuQueue, positionsGpuBuf, CL_TRUE, 0, nBalls*2*sizeof(float), positionsHostBuf, 0, NULL, NULL); if (err < 0) sysfatal("Failed to copy positions from host to GPU.\n"); - clReleaseEvent(readEvent); - elapsed = (clock() - tstart) / (CLOCKS_PER_SEC / MS_PER_S); nextFrame = (elapsed > FRAME_TIME_MS) ? 0 : FRAME_TIME_MS-elapsed; glutTimerFunc(nextFrame, animate, 0); |