Open ghost opened 8 years ago
I am sorry, I have little experience with OpenCL to OpenGL interaction. Also, I don't really understand what you are saying here. Could you provide a minimal, single-file example demonstrating the problem that I could compile and test (on linux)?
I thinking and means that long == int64_t.
sizeof(cl_long) == sizeof(int64_t)
, but on Windows, in host code, sizeof(long) == sizeof(int32_t)
. Could that be a problem?
Error and code.
I'm solved first problem. But I get new error. Also, I had BSOD in Nvidia Pascal (GTX 1070).
Function: sorting
struct less_t {
typedef bool result_type;
less_t() {}
VEX_DUAL_FUNCTOR(result_type, (cl_int, a1)(cl_long, a2)(cl_int, b1)(cl_long, b2),
return (a1 == b1) ? (a2 < b2) : (a1 < b1);
)
} comp;
Also, I used boost compute.
glFinish();
boost::compute::opengl_buffer clkeys(c, triangleKeys.id());
boost::compute::opengl_buffer clids(c, triangleIds.id());
boost::compute::opengl_buffer clpair(c, trianglePair.id());
boost::compute::opengl_enqueue_acquire_gl_objects(1, &clkeys.get(), q);
boost::compute::opengl_enqueue_acquire_gl_objects(1, &clids.get(), q);
boost::compute::opengl_enqueue_acquire_gl_objects(1, &clpair.get(), q);
cl::CommandQueue qu(q.get());
vex::vector<cl_long> clkeysv(qu, cl::BufferGL(clkeys.get()), size_t(nodeCount));
vex::vector<cl_long> clidsv(qu, cl::BufferGL(clids.get()), size_t(nodeCount));
vex::vector<cl_long2> clpairv(qu, cl::BufferGL(clpair.get()), size_t(nodeCount));
vex::sort_by_key(boost::fusion::vector_tie(clidsv, clkeysv), clpairv, comp);
boost::compute::opengl_enqueue_release_gl_objects(1, &clkeys.get(), q);
boost::compute::opengl_enqueue_release_gl_objects(1, &clids.get(), q);
boost::compute::opengl_enqueue_release_gl_objects(1, &clpair.get(), q);
q.finish();
ptxas error : Entry function 'merge' uses too much shared data (0xc008 bytes, 0xc000 max)
You could try to reduce the block size (and the required shared memory size) by changing 256 to 128 here:
https://github.com/ddemidov/vexcl/blob/6578ce2c4d77f01971a6e896f42eb0164de637ed/vexcl/sort.hpp#L1791
Would that work for you? Also, since you are using boost.compute anyway, you could try to switch to their sort algorithm.
I simplified code, but get errors. Error code: CL_MAP_FAILURE
glFinish();
cl_mem cl_buf = clCreateFromGLBuffer((*c)(), CL_MEM_READ_WRITE, trianglePair.id(), nullptr);
clEnqueueAcquireGLObjects((*q)(), 1, &cl_buf, 0, 0, 0);
vex::vector<cl_int2> p(*q, cl::Buffer(cl_buf), nodeCount);
vex::sort(p, sortfunc<cl_int2>());
clEnqueueReleaseGLObjects((*q)(), 1, &cl_buf, 0, 0, 0);
try {
q->finish();
}
catch (cl::Error) {
}
Also
std::vector<cl::Device> device = vex::backend::device_list(
vex::Filter::Env &&
vex::Filter::GLSharing &&
vex::Filter::Count(1)
);
cl_context_properties ctx_prop[] = {
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
CL_CONTEXT_PLATFORM, (cl_context_properties)device[0].getInfo<CL_DEVICE_PLATFORM>(),
0
};
c = std::make_shared<cl::Context>(device, ctx_prop);
q = std::make_shared<cl::CommandQueue>(*c, device[0]);
I am sorry, I can not reproduce this, so I won't be able to help you unless you give me a minimal compilable test-case demonstrating the problem.
I think rewrite OpenGL API for C++ Now my path tracer disabled any sorting, and preparing to rewrite with next-gen API. I want to resolve any problems with OpenCL, and other API.
Hello. I trying add vexcl sorting with OpenGL buffers, that also uses int64. https://github.com/acterhd/magnum-tracer/blob/master/include/tobject.hpp
I tried, but not working sorting for opengl buffers.
Although I kind of respect all the laws of bits and bytes. And again, I try with the structures but not c ++ compiled with them at all. So replaced with long2.
I thinking and means that
long == int64_t
. Also, I'm sure that SSBO and opencl buffer are equivalent.