本文整理汇总了C++中cl::CommandQueue::enqueueWriteBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandQueue::enqueueWriteBuffer方法的具体用法?C++ CommandQueue::enqueueWriteBuffer怎么用?C++ CommandQueue::enqueueWriteBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::CommandQueue
的用法示例。
在下文中一共展示了CommandQueue::enqueueWriteBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initParticles
void initParticles(uint32_t num_particles)
{
m_geom = gl::Geometry::create();
m_geom->setPrimitiveType(GL_POINTS);
m_mesh = gl::Mesh::create(m_geom, m_pointMaterial);
m_numParticles = num_particles;
GLsizei numBytes = m_numParticles * sizeof(vec4);
m_geom->vertices().resize(m_numParticles, vec3(0));
m_geom->colors().resize(m_numParticles, vec4(1));
m_geom->point_sizes().resize(m_numParticles, 9.f);
m_geom->createGLBuffers();
m_mesh->material()->setPointSize(2.f);
scene().addObject(m_mesh);
try
{
// shared position buffer for OpenGL / OpenCL
m_positions = cl::BufferGL(m_context, CL_MEM_READ_WRITE, m_geom->vertexBuffer().id());
m_colors = cl::BufferGL(m_context, CL_MEM_READ_WRITE, m_geom->colorBuffer().id());
//create the OpenCL only arrays
m_velocities = cl::Buffer( m_context, CL_MEM_WRITE_ONLY, numBytes );
m_positionGen = cl::Buffer( m_context, CL_MEM_WRITE_ONLY, numBytes );
m_velocityGen = cl::Buffer( m_context, CL_MEM_WRITE_ONLY, numBytes );
vector<vec4> posGen, velGen;
for (int i = 0; i < m_numParticles; i++)
{
posGen.push_back( vec4(glm::ballRand(20.0f), 1.f) );
vec2 tmp = glm::linearRand(vec2(-100), vec2(100));
float life = kinski::random(2.f, 5.f);
float yVel = kinski::random<float>(5, 15);
velGen.push_back(vec4(tmp.x, yVel, tmp.y, life));
m_geom->point_sizes()[i] = kinski::random(5.f, 15.f);
}
m_geom->createGLBuffers();
m_queue.enqueueWriteBuffer(m_velocities, CL_TRUE, 0, numBytes, &velGen[0]);
m_queue.enqueueWriteBuffer(m_positionGen, CL_TRUE, 0, numBytes, &posGen[0]);
m_queue.enqueueWriteBuffer(m_velocityGen, CL_TRUE, 0, numBytes, &velGen[0]);
m_particleKernel.setArg(0, m_positions);
m_particleKernel.setArg(1, m_colors);
m_particleKernel.setArg(2, m_velocities);
m_particleKernel.setArg(3, m_positionGen);
m_particleKernel.setArg(4, m_velocityGen);
}
catch(cl::Error &error)
{
LOG_ERROR << error.what() << "(" << oclErrorString(error.err()) << ")";
}
}
示例2: copyToDevice
void copyToDevice(cl::CommandQueue &queue)
{
if(m_pElts==NULL)
throw cl::Error(CL_INVALID_MEM_OBJECT, "copyToDevice - Buffer is not initialised.");
queue.enqueueWriteBuffer(m_buffer, CL_TRUE, 0, m_cb, m_pElts);
}
示例3: simulationStep
void simulationStep() {
try {
// copy
auto buffer = cl::Buffer(context, CL_MEM_READ_ONLY,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
nullptr, nullptr);
queue.enqueueWriteBuffer(buffer, CL_TRUE, 0,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
visualizationBufferCPU, NULL, NULL);
// enque
stepKernel.setArg(2, buffer);
cl::NDRange global((size_t) (fieldWidth * fieldHeight));
queue.enqueueNDRangeKernel(stepKernel, cl::NullRange, global, cl::NullRange);
// read back
queue.enqueueReadBuffer(visualizationBufferGPU, CL_TRUE, 0,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
visualizationBufferCPU, NULL, NULL);
// finish
queue.finish();
} catch (cl::Error err) {
std::cout << "Error: " << err.what() << "(" << err.err() << ")" << std::endl;
exit(3);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fieldWidth, fieldHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
visualizationBufferCPU);
}
示例4: addkernelarg
inline void OpenCL::addkernelarg(std::size_t i, T const (& arg)[N], cl::Kernel & kernel,cl::CommandQueue &quene) const
{
cl::Buffer buffer(this->context,CL_MEM_READ_WRITE,N*sizeof(T));
// std::cout << "enqeue\n";
quene.enqueueWriteBuffer(buffer,CL_FALSE,0,sizeof(T)*N,&arg);
kernel.setArg(i,buffer);
}
示例5: copyToDeviceAsync
cl::Event copyToDeviceAsync(cl::CommandQueue &queue)
{
if(m_pElts==NULL)
throw cl::Error(CL_INVALID_MEM_OBJECT, "copyToDevice - Buffer is not initialised.");
cl::Event complete;
queue.enqueueWriteBuffer(m_buffer, CL_FALSE, 0, m_cb, m_pElts, NULL, &complete);
return complete;
}
示例6: write
void write(const cl::CommandQueue &q, size_t offset, size_t size, const T *host,
bool blocking = false) const
{
if (size)
q.enqueueWriteBuffer(
buffer, blocking ? CL_TRUE : CL_FALSE,
sizeof(T) * offset, sizeof(T) * size, host
);
}
示例7: updateBuffer
void Skeleton::updateBuffer(cl::CommandQueue _queue) const
{
bindPose->calculateOffsetTo(currentPose, bindToCurrentTransforms);
for (auto& transform : bindToCurrentTransforms)
{
transform = glm::transpose(world * transform);
}
_queue.enqueueWriteBuffer(transformBuffer, false, 0, sizeof(glm::mat4) * bindToCurrentTransforms.size(), bindToCurrentTransforms.data());
}
示例8: randomizeField
void randomizeField() {
for (int i = 0; i < fieldHeight * fieldWidth; i++) {
visualizationBufferCPU[i * 4 + 0] = 0;
visualizationBufferCPU[i * 4 + 1] = 0;
visualizationBufferCPU[i * 4 + 2] = 0;
visualizationBufferCPU[i * 4 + 3] = (rand() % 5) * 255;
}
queue.enqueueWriteBuffer(visualizationBufferGPU, CL_TRUE, 0,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
visualizationBufferCPU, NULL, NULL);
}
示例9: copyToDevice
void CLArgument::copyToDevice( cl::CommandQueue &queue )
{
assert( myBufferInitialized );
if ( !myCopyTo )
return;
queue.enqueueWriteBuffer(
myBuffer,
CL_TRUE,
0,
mySize,
myPtr
);
}
示例10: initialize_by_array
/**
* initialize tinymt status in device global memory
* using 1 parameter for all generators.
*@param tinymt_status device global memories
*@param total total number of work items
*@param local_item number of local work items
*@param seed_array seeds for initialization
*@param seed_size size of seed_array
*/
static void initialize_by_array(Buffer& tinymt_status,
int total,
int local_item,
uint64_t seed_array[],
int seed_size)
{
#if defined(DEBUG)
cout << "initialize_by_array start" << endl;
#endif
Buffer seed_array_buffer(context,
CL_MEM_READ_WRITE,
seed_size * sizeof(uint64_t));
queue.enqueueWriteBuffer(seed_array_buffer,
CL_TRUE,
0,
seed_size * sizeof(uint64_t),
seed_array);
Kernel init_kernel(program, "tinymt_init_array_kernel");
init_kernel.setArg(0, tinymt_status);
init_kernel.setArg(1, seed_array_buffer);
init_kernel.setArg(2, seed_size);
NDRange global(total);
NDRange local(local_item);
Event event;
queue.enqueueNDRangeKernel(init_kernel,
NullRange,
global,
local,
NULL,
&event);
double time = get_time(event);
tinymt64j_t status[total];
queue.enqueueReadBuffer(tinymt_status,
CL_TRUE,
0,
sizeof(tinymt64j_t) * total,
status);
cout << "initializing time = " << time * 1000 << "ms" << endl;
check_status(status, total);
#if defined(DEBUG)
cout << "initialize_by_array end" << endl;
#endif
}
示例11: updateMarching
void MetaBallsApp::updateMarching()
{
static const cl_int3 size{ VOLUME_WIDTH, VOLUME_HEIGHT, VOLUME_DEPTH };
mClCommandQueue.enqueueNDRangeKernel( mKernWriteClear,
cl::NullRange,
cl::NDRange( VOLUME_SIZE ) );
/* Update volumes */
mClCommandQueue.enqueueNDRangeKernel( mKernWriteMetaballs,
cl::NullRange,
cl::NDRange( VOLUME_SIZE ) );
/* End */
int zero = 0;
auto kernelRange = (size.s[0]-1) * (size.s[1]-1) * (size.s[2]-1);
mClCommandQueue.enqueueWriteBuffer( mClVertIndex, true, 0, sizeof(int), &zero );
mClCommandQueue.enqueueNDRangeKernel( mKernConstructSurface,
cl::NullRange,
cl::NDRange( kernelRange ) );
mClCommandQueue.enqueueReadBuffer( mClVertIndex,
true, 0, sizeof(cl_int),
&mMarchingVertsWritten );
/* Generate Normals */
if (mMarchingVertsWritten > 0) {
bool smooth = true;
if( ! smooth )
mClCommandQueue.enqueueNDRangeKernel( mKernGenNormals,
cl::NullRange,
cl::NDRange( mMarchingVertsWritten ) );
else
mClCommandQueue.enqueueNDRangeKernel( mKernGenNormalsSmooth,
cl::NullRange,
cl::NDRange( mMarchingVertsWritten ) );
}
//if( mDebugDraw )
mClCommandQueue.enqueueNDRangeKernel( mKernWritePointColorBack,
cl::NullRange,
cl::NDRange( VOLUME_SIZE ) );
}
示例12: runTransferBandwidthTest
int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, device_info_t &devInfo)
{
if(!isTransferBW)
return 0;
float timed, gbps;
cl::NDRange globalSize, localSize;
cl::Context ctx = queue.getInfo<CL_QUEUE_CONTEXT>();
int iters = devInfo.transferBWIters;
Timer timer;
float *arr = NULL;
cl_uint maxItems = devInfo.maxAllocSize / sizeof(float) / 2;
cl_uint numItems;
// Set an upper-limit for cpu devies
if(devInfo.deviceType & CL_DEVICE_TYPE_CPU) {
numItems = roundToPowOf2(maxItems, 26);
} else {
numItems = roundToPowOf2(maxItems);
}
try
{
arr = new float[numItems];
cl::Buffer clBuffer = cl::Buffer(ctx, (CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR), (numItems * sizeof(float)));
log->print(NEWLINE TAB TAB "Transfer bandwidth (GBPS)" NEWLINE);
log->xmlOpenTag("transfer_bandwidth");
log->xmlAppendAttribs("unit", "gbps");
///////////////////////////////////////////////////////////////////////////
// enqueueWriteBuffer
log->print(TAB TAB TAB "enqueueWriteBuffer : ");
// Dummy warm-up
queue.enqueueWriteBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
queue.finish();
timed = 0;
if(useEventTimer)
{
for(int i=0; i<iters; i++)
{
cl::Event timeEvent;
queue.enqueueWriteBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr, NULL, &timeEvent);
queue.finish();
timed += timeInUS(timeEvent);
}
} else
{
Timer timer;
timer.start();
for(int i=0; i<iters; i++)
{
queue.enqueueWriteBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
}
queue.finish();
timed = timer.stopAndTime();
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
log->print(gbps); log->print(NEWLINE);
log->xmlRecord("enqueuewritebuffer", gbps);
///////////////////////////////////////////////////////////////////////////
// enqueueReadBuffer
log->print(TAB TAB TAB "enqueueReadBuffer : ");
// Dummy warm-up
queue.enqueueReadBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
queue.finish();
timed = 0;
if(useEventTimer)
{
for(int i=0; i<iters; i++)
{
cl::Event timeEvent;
queue.enqueueReadBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr, NULL, &timeEvent);
queue.finish();
timed += timeInUS(timeEvent);
}
} else
{
Timer timer;
timer.start();
for(int i=0; i<iters; i++)
{
queue.enqueueReadBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
}
queue.finish();
timed = timer.stopAndTime();
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
//.........这里部分代码省略.........
示例13: setup
//.........这里部分代码省略.........
/* create kernel and set the kernel arguments */
kernel = cl::Kernel(program, "path_tracing", &clStatus);
pt_assert(clStatus, "Could not create kernel");
img_width = getWindowWidth();
img_height = getWindowHeight();
true_img_width = getWindowWidth();
true_img_height = getWindowHeight();
local_size = device.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>(); //TODO: throws
local_width = (size_t)pow(2, ceilf(log2f((floorf(sqrtf(local_size))))));
local_height = local_size / local_width;
img_width = ceilf((float)img_width / (float)local_width) * local_width;
img_height = ceilf((float)img_height / (float)local_height) * local_height;
unsigned int samples = 16;
/* Create GL texture and CL wrapper */
glGenTextures(1, &imgTexName);
glBindTexture(GL_TEXTURE_2D, imgTexName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_width, img_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
imgTex = gl::Texture2d::create(GL_TEXTURE_2D, imgTexName, img_width, img_height, true);
glFinish();
img_buffer.push_back(cl::Image2DGL(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, imgTexName, &clStatus));
pt_assert(clStatus, "Could not create buffer");
/* Create all buffers */
cam_buffer = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(cl_pinhole_cam), NULL, &clStatus);
pt_assert(clStatus, "Could not create camera buffer");
primitive_buffer = cl::Buffer (context, CL_MEM_READ_ONLY, MAX_PRIMITIVES * sizeof(cl_sphere), NULL, &clStatus);
pt_assert(clStatus, "Could not create primitive buffer");
material_buffer = cl::Buffer (context, CL_MEM_READ_ONLY, MAX_PRIMITIVES * sizeof(cl_material), NULL, &clStatus);
pt_assert(clStatus, "Could not create primitive buffer");
sky_buffer = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(cl_sky_material), NULL, &clStatus);
pt_assert(clStatus, "Could not create sky buffer");
/* Upload scene (static) */
size_t sceneObjectCount = 5;
cl_sphere* primitive_array = (cl_sphere*)malloc(sceneObjectCount * sizeof(cl_sphere));
cl_material* material_array = (cl_material*)malloc(sceneObjectCount * sizeof(cl_material));
primitive_array[0] = cl_make_sphere(glm::vec3(1, 0, -1), 0.5f);
material_array[0] = cl_make_material(pt::ColorHex_to_RGBfloat<float>("0x730202"), 0, MAT_LAMBERTIAN);
primitive_array[1] = cl_make_sphere(glm::vec3(-1, 0, -1), 0.5f);
material_array[1] = cl_make_material(pt::ColorHex_to_RGBfloat<float>("0xF89000"), 0, MAT_LAMBERTIAN);
primitive_array[2] = cl_make_sphere(glm::vec3(0, 0, 0), 0.5f);
material_array[2] = cl_make_material(pt::ColorHex_to_RGBfloat<float>("0x97A663"), 0.1f, MAT_METALLIC);
primitive_array[3] = cl_make_sphere(glm::vec3(0, 0, -2), 0.5f);
material_array[3] = cl_make_material(glm::vec3(0.8f, 0.6f, 0.2f), 0.3f, MAT_METALLIC);
primitive_array[4] = cl_make_sphere(glm::vec3(0,-100.5f, 1.0f), 100.0f);
material_array[4] = cl_make_material(glm::vec3(0.5f), 0, MAT_LAMBERTIAN);
clStatus = cmd_queue.enqueueWriteBuffer(primitive_buffer, CL_TRUE, 0, sceneObjectCount * sizeof(cl_sphere), primitive_array, NULL, NULL);
pt_assert(clStatus, "Could not fill primitive buffer");
clStatus = cmd_queue.enqueueWriteBuffer(material_buffer, CL_TRUE, 0, sceneObjectCount * sizeof(cl_material), material_array, NULL, NULL);
pt_assert(clStatus, "Could not fill material buffer");
pt_assert(cl_set_skycolors(bottom_sky_color, top_sky_color, sky_buffer, cmd_queue),
"Could not fill sky buffer");
clStatus = kernel.setArg(1, primitive_buffer);
pt_assert(clStatus, "Could not set primitive buffer argument");
clStatus = kernel.setArg(2, material_buffer);
pt_assert(clStatus, "Could not set material buffer argument");
clStatus = kernel.setArg(3, sky_buffer);
pt_assert(clStatus, "Could not set sky buffer argument");
clStatus = kernel.setArg(4, sceneObjectCount);
pt_assert(clStatus, "Could not set primitive count count argument");
clStatus = kernel.setArg(5, img_buffer[0]);
pt_assert(clStatus, "Could not set img buffer argument");
clStatus = kernel.setArg(6, samples);
pt_assert(clStatus, "Could not set samples argument");
clStatus = kernel.setArg(0, cam_buffer);
pt_assert(clStatus, "Could not set camera buffer argument");
}
示例14: watershed
void watershed(int width, int height,
cl::Buffer& src,
cl::Buffer& labeled,
ProgramCache& cache,
cl::CommandQueue& queue)
{
#ifdef OPENCL_PROFILE
watershed_descent_kernel_time = 0;
watershed_increment_kernel_time = 0;
watershed_minima_kernel_time = 0;
watershed_plateau_kernel_time = 0;
watershed_flood_kernel_time = 0;
#endif
cl::Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
std::stringstream params_stream;
params_stream << "-DBLOCK_SIZE=";
params_stream << BLOCK_SIZE;
std::string program_params = params_stream.str();
cl::Program& program = cache.getProgram("Watershed", program_params);
cl::Kernel descent_kernel(program, "descent_kernel");
cl::Kernel increment_kernel(program, "increment_kernel");
cl::Kernel minima_kernel(program, "minima_kernel");
cl::Kernel plateau_kernel(program, "plateau_kernel");
cl::Kernel flood_kernel(program, "flood_kernel");
//setting constant memory with neigbourhood
cl::Buffer cl_neighbourhood_x = cl::Buffer(context,CL_MEM_READ_ONLY,
sizeof(neighbourhood_x));
cl::Buffer cl_neighbourhood_y = cl::Buffer(context, CL_MEM_READ_ONLY,
sizeof(neighbourhood_y));
#ifdef OPENCL_PROFILE
cl::Event first_event;
queue.enqueueWriteBuffer(cl_neighbourhood_x, CL_TRUE, 0,
sizeof(neighbourhood_x),
neighbourhood_x, __null, &first_event);
#else
queue.enqueueWriteBuffer(cl_neighbourhood_x, CL_TRUE, 0,
sizeof(neighbourhood_x), neighbourhood_x);
#endif
queue.enqueueWriteBuffer(cl_neighbourhood_y, CL_TRUE, 0,
sizeof(neighbourhood_y), neighbourhood_y);
//const size_t block_size = 6;
//cl::LocalSpaceArg local_mem = cl::__local(block_size * block_size * sizeof(float));
cl::LocalSpaceArg local_mem = cl::__local(BLOCK_SIZE * BLOCK_SIZE * sizeof(float));
//setting args for descent_kernel
descent_kernel.setArg(0, src);
descent_kernel.setArg(1, labeled);
descent_kernel.setArg(2, cl_neighbourhood_x);
descent_kernel.setArg(3, cl_neighbourhood_y);
descent_kernel.setArg(4, local_mem);
descent_kernel.setArg(5, width);
descent_kernel.setArg(6, height);
size_t global_width = (width / (BLOCK_SIZE - 2) + 1) * BLOCK_SIZE;
size_t global_height = (height / (BLOCK_SIZE - 2) + 1) * BLOCK_SIZE;
#ifdef DEBUG_PRINT
std::cout << "global width=" << global_width
<< " global height=" << global_height << std::endl;
#endif
cl::NDRange global(global_width, global_height);
cl::NDRange local(BLOCK_SIZE, BLOCK_SIZE);
cl_int status;
#ifdef OPENCL_PROFILE
{
VECTOR_CLASS<cl::Event> events_vector(1);
status = queue.enqueueNDRangeKernel(descent_kernel, cl::NullRange,
global, local, __null,
&events_vector[0]);
cl::WaitForEvents(events_vector);
cl::Event& event = events_vector[0];
cl_ulong start = event.getProfilingInfo<CL_PROFILING_COMMAND_START>();
cl_ulong end = event.getProfilingInfo<CL_PROFILING_COMMAND_END>();
cl_ulong total_time = end - start;
watershed_descent_kernel_time = total_time;
}
#else
status = queue.enqueueNDRangeKernel(descent_kernel, cl::NullRange,
global, local);
#endif
#ifdef DEBUG_PRINT
std::cout << "kernel execution " << status << std::endl;
//.........这里部分代码省略.........
示例15: mainLoop
void mainLoop( cl::CommandQueue& queue, cl::Context& context, cl::Kernel kernel, cl::Buffer clImgDesc, cl::Buffer clCamera ){
cl::Event eAcquire, eRelease, eExecute;
cl_int err;
glFinish();
checkGLErr( "glFinish()" );
queue.enqueueWriteBuffer( clImgDesc, CL_TRUE, 0, 1 * sizeof(ImageDescriptor), (const void*)&imgDesc);
err = queue.enqueueAcquireGLObjects( vSharedUnits, NULL, &eAcquire );
checkErr(err, "CommandQueue::enqueueAcquireGLObjects()");
eAcquire.wait();
err = queue.enqueueNDRangeKernel( kernel, cl::NullRange, cl::NDRange(WIDTH, HEIGHT), cl::NullRange, NULL, &eExecute);
checkErr(err, "CommandQueue::enqueueNDRangeKernel()");
//std::cout<<"Kernel executing"<< std::endl ;
clock_t ti = clock();
eExecute.wait();
clock_t tf = clock();
queue.finish();
err = queue.enqueueReleaseGLObjects( vSharedUnits, NULL, &eRelease );
checkErr(err, "CommandQueue::enqueueReleaseGLObjects()");
eRelease.wait();
imgDesc.numSamples += SAMPLES;
pAccumulator->glBind( GL_DRAW_FRAMEBUFFER );
checkGLErr( "glBind GL_DRAW_FRAMEBUFFER, Accumulator " );
pCLTarget->glBind( GL_READ_FRAMEBUFFER );
checkGLErr( "glBind GL_READ_FRAMEBUFFER, Main Target " );
glBlitFramebuffer( 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST );
checkGLErr( "glBlitFramebuffer" );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
checkGLErr( "glBind GL_DRAW_FRAMEBUFFER, 0 " );
pCLTarget->glBind( GL_READ_FRAMEBUFFER );
checkGLErr( "glBind GL_READ_FRAMEBUFFER, something " );
glBlitFramebuffer( 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST );
checkGLErr( "glBlitFramebuffer" );
glfwPollEvents();
pCamera->glfwHandleCursor( ((float)(tf - ti))/(CLOCKS_PER_SEC * 1.0f) );
if( sceneChanged() ){
//printf("scene changed..!");
imgDesc.numSamples = 0;
CLCamera* cam = pCamera->getCLCamera();
queue.enqueueWriteBuffer( clCamera, CL_TRUE, 0, 1 * sizeof(CLCamera), (const void*)cam );
delete cam;
}
glfwSwapBuffers( window );
checkGLErr( "glSwapBuffers" );
//Block for a while.
//int i;
//std::cin >> i;
//float timeTaken = ( (float)(tf - ti) ) / (float)CLOCKS_PER_SEC;
//std::cout<<"Time taken: "<< timeTaken * 1000 << "ms" << std::endl;
//std::cout<<"Predicted FPS: "<< 1 / timeTaken << " FPS"<< std::endl;
if( imgDesc.numSamples % 10 == 0 )
std::cout<<"numSamples: "<<imgDesc.numSamples<<std::endl;
//handleFrameCounter();
}