My kernel is able to write to the first mip map level of a 3D texture but not the second. As background for this problem, I am trying to create an OpenCL mip map generator.

I created an OpenGL 3d texture that has two mip-map levels and am sharing it with OpenCL through two calls to clCreateFromGLTexture3D (with miplevel being 0 and 1). This gives me two cl images which I send to my kernel. No errors are generated so far.

In the kernel I am using the cl_khr_image_writes extension. Now I write the color white to the first texel of the first image and the first texel of the second image. I see white for the first mip but not the second.

The way I verify whether the write works or not is by using a separate 3D texture viewer, where each texel is represented by a colored cube. The viewer also allows switching between the mipmap levels, so I can clearly see that writing to the first mip works but writing to the second doesn't.

I am using a Radeon 7750 with Catalyst version 12.8

Now here most of the code. I omitted some lines where I do error checking

Creation of 3D texture:
Code :
glGenTextures(1, &voxelTexture);
glBindTexture(GL_TEXTURE_3D, voxelTexture);
glTexStorage3D(GL_TEXTURE_3D, numMipMapLevels, GL_RGBA8, sideLength, sideLength, sideLength);
During initialization:

Code :
clVoxelTextureMip0 = clCreateFromGLTexture3D(clGPUContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_3D, 0, voxelTexture, &clError);
clVoxelTextureMip1 = clCreateFromGLTexture3D(clGPUContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_3D, 1, voxelTexture, &clError);
clError  = clSetKernelArg(clMipMapGeneratorKernel, 0, sizeof(cl_mem), &clVoxelTextureMip0);
clError |= clSetKernelArg(clMipMapGeneratorKernel, 1, sizeof(cl_mem), &clVoxelTextureMip1);


Code :
clError  = clEnqueueAcquireGLObjects(clCommandQueue, 1, &clVoxelTextureMip0, 0,0,0);
clError |= clEnqueueAcquireGLObjects(clCommandQueue, 1, &clVoxelTextureMip1, 0,0,0);	
const unsigned int globalWorkOffset[3] = {0,0,0};
const unsigned int globalWorkSize[3] = {textureSideLength/2, textureSideLength/2, textureSideLength/2};
const unsigned int localWorkSize[3] = {4,4,4};
clError = clEnqueueNDRangeKernel(clCommandQueue, clMipMapGeneratorKernel, 3, globalWorkOffset, globalWorkSize, localWorkSize, 0,0,0);
clError  = clEnqueueReleaseGLObjects(clCommandQueue, 1, &clVoxelTextureMip0, 0,0,0);
clError |= clEnqueueReleaseGLObjects(clCommandQueue, 1, &clVoxelTextureMip1, 0,0,0);	

And the kernel:

Code :
#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
__kernel void mipMapGenerator(write_only image3d_t mipLevel0, write_only image3d_t mipLevel1)
    float4 white = (float4)(1,1,1,1);
    int4 first = (int4)(0,0,0,0);
    write_imagef(mipLevel0, first, white);
    write_imagef(mipLevel1, first, white);

I hope this gives a good idea of my problem. Any thoughts?