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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations