cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

chevydevil
Adept II

3d image writes

Hello. I am trying to write to a 3D Image I recieved from OpenGL. After that I read it down to the host for debug reasons. But there is nothing in the buffer.

 

What am I doing wrong?

OpenGL: glGenTextures(1, &g_volumeTextureId); glBindTexture(GL_TEXTURE_3D, g_volumeTextureId); glTexImage3D(GL_TEXTURE_3D ,0, GL_RGBA, 96,96,96, 0, GL_RGBA, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_WRAP_R, GL_CLAMP); Create Memory Object: outputDensity = clCreateFromGLTexture3D(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_3D,0, texid, &status); if(status != CL_SUCCESS) std::cout<<"Error: clCreateFromGLBuffer (Texture3D)"<< "("<< status <<")" << std::endl; Kernel: #pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable __kernel void outputDensity(__global float* densityField, __write_only image3d_t image) { uint i = get_global_id(0); uint j = get_global_id(1); uint k = get_global_id(2); uint X = get_global_size(0)-2; uint Y = get_global_size(1)-2; uint Z = get_global_size(2)-2; if(i > 0 && i <= X && j > 0 && j <= Y && k > 0 && k <= Z) { int4 coord; coord.x = i; coord.y = j; coord.z = k; float4 out; out.x =128.f;// 0.5 * (densityField[IX3(i-1,j,k)] + densityField[IX3(i+1,j,k)]); out.y = 128.f;//0.5 * (densityField[IX3(i,j-1,k)] + densityField[IX3(i,j+1,k)]); out.z = 128.f;//0.5 * (densityField[IX3(i,j,k-1)] + densityField[IX3(i,j,k+1)]); out.w = 1.f;//densityField[IX3(i,j,k)]; write_imagef(image, coord, (float4)(1.0f,1.0f,1.0f,1.0f)); } } Reading: size_t s[3] = {96,96,96}; size_t s2[3] = {0,0,0}; status = clEnqueueReadImage(commandQueue, outputDensity, CL_TRUE,s2 , s, 0,0, densityOut,0,NULL,NULL ); if(status != CL_SUCCESS) std::cout<<"Error: clEnqueueAquireGLObjects ( outputDensity"<< "("<< status <<")" << std::endl; for(int i =0; i < (96*96*96); ++i) std::cout<<densityOut<<std::endl;

0 Likes
4 Replies
genaganna
Journeyman III

Originally posted by: chevydevil Hello. I am trying to write to a 3D Image I recieved from OpenGL. After that I read it down to the host for debug reasons. But there is nothing in the buffer.

 

 

 

What am I doing wrong?

 

Are you calling clEnqueueAquireGLObjects before calling kernel and clEnqueueReleaseGLObject after calling kernel?

0 Likes

Yes, I do:

Btw. I'm running this on Radeon 5870 so it should be possible. There are also no error messages.

status = clEnqueueAcquireGLObjects(commandQueue, 1, &outputDensity, 0, NULL, NULL); if(status != CL_SUCCESS) std::cout<<"Error: clEnqueueAquireGLObjects ( outputDensity"<< "("<< status <<")" << std::endl; status = clEnqueueNDRangeKernel(commandQueue, outputDensity_kernel, 3, NULL, globalSize3D, NULL,0, NULL, NULL); if(status != CL_SUCCESS) std::cout<<"Error: clEnqueueNDRangeKernel ( outputDensity_kernel)"<< "("<< status <<")" << std::endl; status = clEnqueueReleaseGLObjects(commandQueue, 1, &outputDensity, 0, NULL, NULL); if(status != CL_SUCCESS) std::cout<<"Error: clEnqueueAquireGLObjects ( outputDensity"<< "("<< status <<")" << std::endl;

0 Likes

I ran a testcase where I create a 3d Image with clCreateImage3D. This worked. Then I tried the OpenGL 3D Texture and got qnans. I tried gDEBugger and it tells me for OpenGL Texture: Texture type is unknown and for OpenCL Image Type is unknown too. Has anyone an idea?

0 Likes

Done. The problem was within gdebugger-plugin which told me my texture was not correct. gdebugger standalone said it is alright and showed me the correct data in my texture.

0 Likes