Cast texture or renderbuffer to different type

Is it possible to typecast a texture or renderbuffer to a different type?

In other words, detach the data from its type container and reattach it to a different type container. Don’t think so but I wanted to be sure.

Why would I ask?: I’d like to use OpenCL to do a reduction on the depth buffer (texture or renderbuffer – don’t care). The concept isn’t new – it was presented at SIGGRAPH last year for instance.

The problem is that OpenCL only lets you attach to color buffers, not depth buffers (with clCreateFromGLTexture2D and clCreateFromGLRenderbuffer). For instance, even though it supports GL_R32F (1 GL_FLOAT), by spec, it just won’t take GL_DEPTH_COMPONENT32F (also 1 GL_FLOAT).

I can additionally write depth redundantly to a GL_R32F color channel just to appease this GL->CL limitation, but I’d rather not if it’s avoidable.

Alternatively, is it possible in GLSL to use shared memory and do cooperative operations between threads including barrier syncs on the same GPU multiprocessor core yet?

It’s not designed for this, so I doubt it. But doesn’t hurt to ask. :slight_smile: