if (tex.getType() == Texture.Type.TwoDimensionalArray && !caps.contains(Caps.TextureArray)) return false;
/** * 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); } /**
public void modifyTexture(Texture tex, Image pixels, int x, int y) { setTexture(0, tex); int target = convertTextureType(tex.getType(), pixels.getMultiSamples(), -1); texUtil.uploadSubTexture(pixels, target, 0, x, y, linearizeSrgbImages); }
switch (tex.getType()) { case CubeMap: case ThreeDimensional:
@Override public void setTexture(int unit, Texture tex) { Image image = tex.getImage(); if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) { // Check NPOT requirements boolean scaleToPot = false; try { checkNonPowerOfTwo(tex); } catch (RendererException ex) { if (logger.isLoggable(Level.WARNING)) { int nextWidth = FastMath.nearestPowerOfTwo(tex.getImage().getWidth()); int nextHeight = FastMath.nearestPowerOfTwo(tex.getImage().getHeight()); logger.log(Level.WARNING, "Non-power-of-2 textures are not supported! Scaling texture '" + tex.getName() + "' of size " + tex.getImage().getWidth() + "x" + tex.getImage().getHeight() + " to " + nextWidth + "x" + nextHeight); } scaleToPot = true; } updateTexImageData(image, tex.getType(), unit, scaleToPot); } int texId = image.getId(); assert texId != -1; setupTextureParams(unit, tex); }
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) { Texture tex = rb.getTexture(); Image image = tex.getImage(); if (image.isUpdateNeeded()) { // Check NPOT requirements checkNonPowerOfTwo(tex); updateTexImageData(image, tex.getType(), 0, false); // NOTE: For depth textures, sets nearest/no-mips mode // Required to fix "framebuffer unsupported" // for old NVIDIA drivers! setupTextureParams(0, tex); } if (rb.getLayer() < 0){ glfbo.glFramebufferTexture2DEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()), image.getId(), 0); } else { glfbo.glFramebufferTextureLayerEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), image.getId(), 0, rb.getLayer()); } }
Image image = tex.getImage(); int samples = image != null ? image.getMultiSamples() : 1; int target = convertTextureType(tex.getType(), samples, -1); switch (tex.getType()) { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords throw new UnsupportedOperationException("Unknown texture type: " + tex.getType());
setTexture(0, rb.getTexture()); int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace()); glfbo.glGenerateMipmapEXT(textureType);
if (tex.getType() == Texture.Type.TwoDimensionalArray && !caps.contains(Caps.TextureArray)) return false;
if (tex.getType() == Texture.Type.TwoDimensionalArray && !caps.contains(Caps.TextureArray)) return false;
/** * 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); } /**
public void modifyTexture(Texture tex, Image pixels, int x, int y) { setTexture(0, tex); int target = convertTextureType(tex.getType(), pixels.getMultiSamples(), -1); texUtil.uploadSubTexture(pixels, target, 0, x, y, linearizeSrgbImages); }
public void modifyTexture(Texture tex, Image pixels, int x, int y) { setTexture(0, tex); TextureUtil.uploadSubTexture(caps, pixels, convertTextureType(tex.getType(), pixels.getMultiSamples(), -1), 0, x, y, linearizeSrgbImages); }
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) { Texture tex = rb.getTexture(); Image image = tex.getImage(); if (image.isUpdateNeeded()) { updateTexImageData(image, tex.getType(), 0); // NOTE: For depth textures, sets nearest/no-mips mode // Required to fix "framebuffer unsupported" // for old NVIDIA drivers! setupTextureParams(tex); } glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()), image.getId(), 0); }
public void setTexture(int unit, Texture tex) { Image image = tex.getImage(); if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) { updateTexImageData(image, tex.getType(), unit); int type = convertTextureType(tex.getType(), image.getMultiSamples(), -1);
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) { Texture tex = rb.getTexture(); Image image = tex.getImage(); if (image.isUpdateNeeded()) { // Check NPOT requirements checkNonPowerOfTwo(tex); updateTexImageData(image, tex.getType(), 0, false); // NOTE: For depth textures, sets nearest/no-mips mode // Required to fix "framebuffer unsupported" // for old NVIDIA drivers! setupTextureParams(0, tex); } if (rb.getLayer() < 0){ glfbo.glFramebufferTexture2DEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()), image.getId(), 0); } else { glfbo.glFramebufferTextureLayerEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), image.getId(), 0, rb.getLayer()); } }
@Override public void setTexture(int unit, Texture tex) { Image image = tex.getImage(); if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) { // Check NPOT requirements boolean scaleToPot = false; try { checkNonPowerOfTwo(tex); } catch (RendererException ex) { if (logger.isLoggable(Level.WARNING)) { int nextWidth = FastMath.nearestPowerOfTwo(tex.getImage().getWidth()); int nextHeight = FastMath.nearestPowerOfTwo(tex.getImage().getHeight()); logger.log(Level.WARNING, "Non-power-of-2 textures are not supported! Scaling texture '" + tex.getName() + "' of size " + tex.getImage().getWidth() + "x" + tex.getImage().getHeight() + " to " + nextWidth + "x" + nextHeight); } scaleToPot = true; } updateTexImageData(image, tex.getType(), unit, scaleToPot); } int texId = image.getId(); assert texId != -1; setupTextureParams(unit, tex); }