/** * Alternative version to {@link #bindImage(com.jme3.texture.Texture, int, com.jme3.opencl.MemoryAccess) }, * uses {@code miplevel=0}. * @param texture the jME3 texture * @param access the allowed memory access for kernels * @return the OpenCL image */ public Image bindImage(Texture texture, MemoryAccess access) { return bindImage(texture, 0, access); } /**
private void initOpenCL2() { //bind image to OpenCL texCL = clContext.bindImage(tex, MemoryAccess.WRITE_ONLY).register(); } private void updateOpenCL(float tpf) {
/** * Creates a shared image object from a jME3 texture. * The returned image shares the same memory with the jME3 texture, changes * in one view are visible in the other view. * This can be used to modify textures and images directly from OpenCL * (e.g. for post processing effects and other texture effects). * <br> * <b>Note:</b> The image must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. * <p> * Before the returned image can be used, it must be acquried explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } * This is needed so that OpenGL and OpenCL operations do not interfer with each other. * <p> * This method is equivalent to calling * {@code bindImage(texture.getImage(), texture.getType(), miplevel, access)}. * * @param texture the jME3 texture * @param miplevel the mipmap level that should be shared * @param access the allowed memory access for kernels * @return the OpenCL image */ public Image bindImage(Texture texture, int miplevel, MemoryAccess access) { return bindImage(texture.getImage(), texture.getType(), miplevel, access); } /**
/** * Creates a shared image object from a jME3 render buffer. * The returned image shares the same memory with the jME3 render buffer, changes * in one view are visible in the other view. * <br> * This can be used as an alternative to post processing effects * (e.g. reduce sum operations, needed e.g. for tone mapping). * <br> * <b>Note:</b> The renderbuffer must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. * <p> * Before the returned image can be used, it must be acquried explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } * This is needed so that OpenGL and OpenCL operations do not interfer with each other. * * @param buffer * @param access * @return */ public Image bindRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access) { if (buffer.getTexture() == null) { return bindPureRenderBuffer(buffer, access); } else { return bindImage(buffer.getTexture(), access); } } protected abstract Image bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access);
/** * Alternative version to {@link #bindImage(com.jme3.texture.Texture, int, com.jme3.opencl.MemoryAccess) }, * uses {@code miplevel=0}. * @param texture the jME3 texture * @param access the allowed memory access for kernels * @return the OpenCL image */ public Image bindImage(Texture texture, MemoryAccess access) { return bindImage(texture, 0, access); } /**
/** * Creates a shared image object from a jME3 texture. * The returned image shares the same memory with the jME3 texture, changes * in one view are visible in the other view. * This can be used to modify textures and images directly from OpenCL * (e.g. for post processing effects and other texture effects). * <br> * <b>Note:</b> The image must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. * <p> * Before the returned image can be used, it must be acquried explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } * This is needed so that OpenGL and OpenCL operations do not interfer with each other. * <p> * This method is equivalent to calling * {@code bindImage(texture.getImage(), texture.getType(), miplevel, access)}. * * @param texture the jME3 texture * @param miplevel the mipmap level that should be shared * @param access the allowed memory access for kernels * @return the OpenCL image */ public Image bindImage(Texture texture, int miplevel, MemoryAccess access) { return bindImage(texture.getImage(), texture.getType(), miplevel, access); } /**
/** * Creates a shared image object from a jME3 render buffer. * The returned image shares the same memory with the jME3 render buffer, changes * in one view are visible in the other view. * <br> * This can be used as an alternative to post processing effects * (e.g. reduce sum operations, needed e.g. for tone mapping). * <br> * <b>Note:</b> The renderbuffer must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. * <p> * Before the returned image can be used, it must be acquried explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } * This is needed so that OpenGL and OpenCL operations do not interfer with each other. * * @param buffer * @param access * @return */ public Image bindRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access) { if (buffer.getTexture() == null) { return bindPureRenderBuffer(buffer, access); } else { return bindImage(buffer.getTexture(), access); } } protected abstract Image bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access);