please help
Create a FBO and also create a CL memory buffer using that FBO (see OpenGL/DX interop examples in SDK 2.2).
Do a render of depth buffer to that FBO and then after using glFinish() you are able to use that FBO as an OpenCL buffer.
please, precise in which file did you find it (and notice I am not talking about color attachment)
You can also use a 2D texture directly for interoperability between CL and GL/DX. Here is a code snippet in GL - for the full code see VolumeRendering sample available at http://developer.amd.com/samples/opencl/Pages/default.aspx
/* * Create texture object */ glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); /* Set parameters */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)WINDOW_WIDTH, (GLsizei)WINDOW_HEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); // Create output buffer to render using GL outputBuffer = clCreateFromGLTexture2D(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, tex, &status);
As you can see I have used GL_LUMINANCE and GL_UNSIGNED_BYTE flags (8-bit intensity values) to create a texture, similarly you have to put flags according to your depth buffer format.
err = -39
CL_INVALID_IMAGE_FORMAT_DESCRIPTOR
GLuint depth_tex; glGenTextures(1, &depth_tex); glBindTexture(GL_TEXTURE_2D, depth_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, 256, 256, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); GLuint fbo; glGenFramebuffersEXT(1, &fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_tex, 0); glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); GLenum status; status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) std::cout << "no good"<<std::endl; cl_int err; cl_mem clbuf = clCreateFromGLTexture2D((*cxContext)(), CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, depth_tex, &err); std::cout << err << std::endl;
Try using GL_RGBA instead of GL_DEPTH_COMPONENT32 in glTexImage2D.
have tried, framebuffer will not be built
and the same cl err
What is the format of depth buffer? What does GL_DEPTH_COMPONENT signifies?
as depth attachment you may use only texture with internal format GL_DEPTH_COMPONENT*. but OpenCL spec stated only CL_RGB(A)* formats mapping to CL types. IMHO currently you can't share depth texture.
you may try attach one color channel texture to FBO and share that texture.
Originally posted by: nou IMHO currently you can't share depth texture.
looks like true
sorry for offtopic, but may be it is possible to copy them via shaders ?
Originally posted by: n0thing What is the format of depth buffer? What does GL_DEPTH_COMPONENT signifies?
GL_FLOAT, but it will not change anything
so I should ask gurus from AMD: is it possible to share depth buffer via render/tex or not ? Please answer (it is a critical for my PhD project, cause of significant performance down with pbo's)
try create GL_R32F color texture and write depth into this color atachment.
Originally posted by: nou try create GL_R32F color texture and write depth into this color atachment.
did not work, i think one should use shaders instead and write values to color texture