Example usage for org.lwjgl.opengl ARBBindlessTexture glMakeImageHandleResidentARB

List of usage examples for org.lwjgl.opengl ARBBindlessTexture glMakeImageHandleResidentARB

Introduction

In this page you can find the example usage for org.lwjgl.opengl ARBBindlessTexture glMakeImageHandleResidentARB.

Prototype

public static native void glMakeImageHandleResidentARB(@NativeType("GLuint64") long handle,
        @NativeType("GLenum") int access);

Source Link

Document

Makes an image handle resident, so that it is accessible to shaders for image loads, stores, and atomic operations.

Usage

From source file:org.lwjgl.demo.opengl.raytracing.PhotonMappingBindlessDemo.java

License:Open Source License

/**
 * Create the cubemap texture array for our photon map.
 *///from   w ww  .j  a v  a 2s  . c  om
private void createPhotonMapTextures() {
    /* Create them */
    IntBuffer textures = BufferUtils.createIntBuffer(photonMapTextures.length);
    glGenTextures(textures);
    for (int i = 0; i < photonMapTextures.length; i++) {
        TextureInfo info = new TextureInfo();
        info.openGlHandle = textures.get(i);
        Vector3f min = boxes[2 * i + 0];
        Vector3f max = boxes[2 * i + 1];
        float maxExtent = Math.max(Math.max(max.x - min.x, max.y - min.y), max.z - min.z);
        int texSize = (int) (maxExtent * texelsPerUnit);
        info.textureWidth = texSize;
        info.textureHeight = texSize;
        glBindTexture(GL_TEXTURE_CUBE_MAP, info.openGlHandle);
        glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RG16F, texSize, texSize);
        glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
        info.bindlessImageHandle = ARBBindlessTexture.glGetImageHandleARB(info.openGlHandle, 0, true, 0,
                GL_RG16F);
        info.bindlessTextureAndSamplerHandle = ARBBindlessTexture
                .glGetTextureSamplerHandleARB(info.openGlHandle, sampler);
        ARBBindlessTexture.glMakeImageHandleResidentARB(info.bindlessImageHandle, GL_READ_WRITE);
        ARBBindlessTexture.glMakeTextureHandleResidentARB(info.bindlessTextureAndSamplerHandle);
        photonMapTextures[i] = info;
    }
    /* Clear them */
    clearPhotonMapTextures();
    /* Update SSBO with bindless image handles */
    updateImageHandlesUbo();
    /* Update UBO with bindless sampler handles */
    updateSamplerHandlesUbo();
}