diff --git a/c++/contourgl/cl/contour-base.cl b/c++/contourgl/cl/contour-base.cl index a29a829..fa16b9c 100644 --- a/c++/contourgl/cl/contour-base.cl +++ b/c++/contourgl/cl/contour-base.cl @@ -124,11 +124,6 @@ kernel void fill( //int ialpha; int icover = 0, c0 = bounds.s0, c1 = bounds.s0; while(c0 < bounds.s2) { - c1 = min(c1, bounds.s2); - mark = &row[c1]; - m = *mark; - *mark = (int4)(0, 0, c1 | (c1 + 1), 0); - //ialpha = abs(icover); //ialpha = evenodd ? ONE - abs((ialpha % TWO) - ONE) // : min(ialpha, ONE); @@ -139,6 +134,10 @@ kernel void fill( if (c1 >= bounds.s2) return; + mark = &row[c1]; + m = *mark; + *mark = (int4)(0, 0, c1 | (c1 + 1), 0); + //ialpha = abs(mark.x + icover); //ialpha = evenodd ? ONE - abs((ialpha % TWO) - ONE) // : min(ialpha, ONE); @@ -150,7 +149,7 @@ kernel void fill( min(pixel->w + alpha, 1.f) ); c0 = c1 + 1; - c1 = m.z; + c1 = min(m.z, bounds.s2); icover += m.y; } } diff --git a/c++/contourgl/clcontext.cpp b/c++/contourgl/clcontext.cpp index 1d35e13..5d1b7bb 100644 --- a/c++/contourgl/clcontext.cpp +++ b/c++/contourgl/clcontext.cpp @@ -100,17 +100,42 @@ ClContext::ClContext(): max_group_size = max_group_sizes.front(); //cout << "Device " << device_index << " max group size " << max_group_size << endl; - // context + size_t timer_resolution; + err |= clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(timer_resolution), &timer_resolution, NULL); + assert(!err); + //cout << "Device " << device_index << " timer resolution " << timer_resolution << " ns" << endl; + + unsigned long long global_mem_size; + err |= clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(global_mem_size), &global_mem_size, NULL); + assert(!err); + //cout << "Device " << device_index << " global mem size " << global_mem_size << endl; + + unsigned long long local_mem_size; + err |= clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(local_mem_size), &local_mem_size, NULL); + assert(!err); + //cout << "Device " << device_index << " local mem size " << local_mem_size << endl; + + unsigned long long max_constant_buffer_size; + err |= clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(max_constant_buffer_size), &max_constant_buffer_size, NULL); + assert(!err); + //cout << "Device " << device_index << " max constant buffer size " << max_constant_buffer_size << endl; + + // context cl_context_properties context_props[] = { - CL_CONTEXT_PLATFORM, (cl_context_properties)platform, + CL_CONTEXT_PLATFORM, (cl_context_properties)platform, CL_NONE }; context = clCreateContext(context_props, 1, &device, callback, NULL, &err); assert(context); // command queue - queue = clCreateCommandQueue(context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, NULL); + cl_command_queue_properties props = 0 + | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE + //| CL_QUEUE_PROFILING_ENABLE + | 0; + queue = clCreateCommandQueue( + context, device, props, NULL); assert(queue); //hello();