Search in sources :

Example 1 with ImageFormat

use of com.jme3.opencl.Image.ImageFormat in project jmonkeyengine by jMonkeyEngine.

the class JoclContext method querySupportedFormats.

@Override
public ImageFormat[] querySupportedFormats(MemoryAccess access, Image.ImageType type) {
    if (type != Image.ImageType.IMAGE_2D && type != Image.ImageType.IMAGE_3D) {
        throw new UnsupportedOperationException("Jocl only supports 2D and 3D images");
    }
    long memFlags = Utils.getMemoryAccessFlags(access);
    CLImageFormat[] fx;
    if (type == Image.ImageType.IMAGE_2D) {
        fx = context.getSupportedImage2dFormats(Mem.valueOf((int) memFlags));
    } else {
        fx = context.getSupportedImage3dFormats(Mem.valueOf((int) memFlags));
    }
    //convert formats
    ImageFormat[] formats = new ImageFormat[fx.length];
    for (int i = 0; i < fx.length; ++i) {
        Image.ImageChannelOrder channelOrder = JoclImage.encodeImageChannelOrder(fx[i].getFormatImpl().getImageChannelOrder());
        Image.ImageChannelType channelType = JoclImage.encodeImageChannelType(fx[i].getFormatImpl().getImageChannelDataType());
        formats[i] = new ImageFormat(channelOrder, channelType);
    }
    return formats;
}
Also used : CLImageFormat(com.jogamp.opencl.CLImageFormat) ImageFormat(com.jme3.opencl.Image.ImageFormat) CLImageFormat(com.jogamp.opencl.CLImageFormat)

Example 2 with ImageFormat

use of com.jme3.opencl.Image.ImageFormat in project jmonkeyengine by jMonkeyEngine.

the class EnvMapUtils method createPrefilteredEnvMap.

/**
     * initialize the pem map
     * @param size the size of the map
     * @param imageFormat the format of the image
     * @return the initialized prefiltered env map
     */
public static TextureCubeMap createPrefilteredEnvMap(int size, Image.Format imageFormat) {
    TextureCubeMap pem = new TextureCubeMap(size, size, imageFormat);
    pem.setMagFilter(Texture.MagFilter.Bilinear);
    pem.setMinFilter(Texture.MinFilter.Trilinear);
    pem.getImage().setColorSpace(ColorSpace.Linear);
    int nbMipMap = (int) (Math.log(size) / Math.log(2) - 1);
    CubeMapWrapper targetWrapper = new CubeMapWrapper(pem);
    targetWrapper.initMipMaps(nbMipMap);
    return pem;
}
Also used : TextureCubeMap(com.jme3.texture.TextureCubeMap)

Example 3 with ImageFormat

use of com.jme3.opencl.Image.ImageFormat in project jmonkeyengine by jMonkeyEngine.

the class EnvMapUtils method createIrradianceMap.

/**
     * initialize the Irradiancemap
     * @param size the size of the map
     * @param imageFormat the format of the image
     * @return the initialized Irradiance map
     */
public static TextureCubeMap createIrradianceMap(int size, Image.Format imageFormat) {
    TextureCubeMap irrMap = new TextureCubeMap(size, size, imageFormat);
    irrMap.setMagFilter(Texture.MagFilter.Bilinear);
    irrMap.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
    irrMap.getImage().setColorSpace(ColorSpace.Linear);
    return irrMap;
}
Also used : TextureCubeMap(com.jme3.texture.TextureCubeMap)

Example 4 with ImageFormat

use of com.jme3.opencl.Image.ImageFormat in project jmonkeyengine by jMonkeyEngine.

the class LwjglContext method querySupportedFormats.

@Override
public ImageFormat[] querySupportedFormats(MemoryAccess access, Image.ImageType type) {
    long memFlags = Utils.getMemoryAccessFlags(access);
    int typeFlag = LwjglImage.decodeImageType(type);
    Utils.tempBuffers[0].b16i.rewind();
    //query count
    int ret = CL10.clGetSupportedImageFormats(context, memFlags, typeFlag, null, Utils.tempBuffers[0].b16i);
    Utils.checkError(ret, "clGetSupportedImageFormats");
    int count = Utils.tempBuffers[0].b16i.get(0);
    if (count == 0) {
        return new ImageFormat[0];
    }
    //get formats
    CLImageFormat.Buffer formatsB = new CLImageFormat.Buffer(BufferUtils.createByteBuffer(count * CLImageFormat.SIZEOF));
    ret = CL10.clGetSupportedImageFormats(context, memFlags, typeFlag, formatsB, (IntBuffer) null);
    Utils.checkError(ret, "clGetSupportedImageFormats");
    //convert formats
    ImageFormat[] formats = new ImageFormat[count];
    for (int i = 0; i < count; ++i) {
        CLImageFormat f = formatsB.get();
        Image.ImageChannelOrder channelOrder = LwjglImage.encodeImageChannelOrder(f.image_channel_order());
        Image.ImageChannelType channelType = LwjglImage.encodeImageChannelType(f.image_channel_data_type());
        formats[i] = new ImageFormat(channelOrder, channelType);
    }
    return formats;
}
Also used : VertexBuffer(com.jme3.scene.VertexBuffer) FrameBuffer(com.jme3.texture.FrameBuffer) ByteBuffer(java.nio.ByteBuffer) IntBuffer(java.nio.IntBuffer) IntBuffer(java.nio.IntBuffer) ImageFormat(com.jme3.opencl.Image.ImageFormat)

Example 5 with ImageFormat

use of com.jme3.opencl.Image.ImageFormat in project jmonkeyengine by jMonkeyEngine.

the class EnvironmentCamera method render.

@Override
public void render(final RenderManager renderManager) {
    if (jobs.isEmpty()) {
        return;
    }
    final SnapshotJob job = jobs.get(0);
    for (int i = 0; i < 6; i++) {
        viewports[i].clearScenes();
        viewports[i].attachScene(job.scene);
        renderManager.renderViewPort(viewports[i], 0.16f);
        buffers[i] = BufferUtils.createByteBuffer(size * size * imageFormat.getBitsPerPixel() / 8);
        renderManager.getRenderer().readFrameBufferWithFormat(framebuffers[i], buffers[i], imageFormat);
        images[i] = new Image(imageFormat, size, size, buffers[i], ColorSpace.Linear);
    }
    final TextureCubeMap map = EnvMapUtils.makeCubeMap(images[0], images[1], images[2], images[3], images[4], images[5], imageFormat);
    job.callback.done(map);
    map.getImage().dispose();
    jobs.remove(0);
}
Also used : TextureCubeMap(com.jme3.texture.TextureCubeMap) Image(com.jme3.texture.Image)

Aggregations

TextureCubeMap (com.jme3.texture.TextureCubeMap)3 ImageFormat (com.jme3.opencl.Image.ImageFormat)2 Camera (com.jme3.renderer.Camera)1 VertexBuffer (com.jme3.scene.VertexBuffer)1 FrameBuffer (com.jme3.texture.FrameBuffer)1 Image (com.jme3.texture.Image)1 Texture2D (com.jme3.texture.Texture2D)1 CLImageFormat (com.jogamp.opencl.CLImageFormat)1 ByteBuffer (java.nio.ByteBuffer)1 IntBuffer (java.nio.IntBuffer)1