chevydevil

3d image writes

Discussion created by chevydevil on Oct 30, 2011
Latest reply on Nov 2, 2011 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?

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[i]<<std::endl;

Outcomes