Example usage for org.lwjgl.opengl ARBComputeVariableGroupSize glDispatchComputeGroupSizeARB

List of usage examples for org.lwjgl.opengl ARBComputeVariableGroupSize glDispatchComputeGroupSizeARB

Introduction

In this page you can find the example usage for org.lwjgl.opengl ARBComputeVariableGroupSize glDispatchComputeGroupSizeARB.

Prototype

public static native void glDispatchComputeGroupSizeARB(@NativeType("GLuint") int num_groups_x,
        @NativeType("GLuint") int num_groups_y, @NativeType("GLuint") int num_groups_z,
        @NativeType("GLuint") int group_size_x, @NativeType("GLuint") int group_size_y,
        @NativeType("GLuint") int group_size_z);

Source Link

Document

Launches one or more compute work groups, with arbitrary dimensions.

Usage

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

License:Open Source License

/**
 * Trace some rays from the light.//from  w ww . java 2  s.  c om
 */
private void trace() {
    glUseProgram(photonTraceProgram);

    long thisTime = System.nanoTime();
    float elapsedSeconds = (thisTime - firstTime) / 1E9f;
    glUniform1f(timeUniform, elapsedSeconds);

    /* Bind the SSBO containing our boxes */
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, boxesSsboBinding, ssbo);
    /* Bind the UBO containing the bindless handles of our images */
    glBindBufferBase(GL_UNIFORM_BUFFER, imagesUboBinding, imageHandlesUbo);

    /* Compute appropriate invocation dimension. */
    int invocationsPerDimension = photonsPerFrame;
    int worksizeX = mathRoundPoT(invocationsPerDimension);
    int worksizeY = mathRoundPoT(invocationsPerDimension);

    /* Invoke the compute shader. */
    if (variableGroupSize) {
        ARBComputeVariableGroupSize.glDispatchComputeGroupSizeARB(worksizeX / workGroupSizeX,
                worksizeY / workGroupSizeY, 1, workGroupSizeX, workGroupSizeY, 1);
    } else {
        glDispatchCompute(worksizeX / workGroupSizeX, worksizeY / workGroupSizeY, 1);
    }
    /*
     * Synchronize all writes that the shader did on the photonMap cube map
     * array image before we later let OpenGL source texels from it when
     * rasterizing the scene and sampling the cube maps in the fragment
     * shader.
     */
    glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);

    /* Reset bindings. */
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, boxesSsboBinding, 0);
    glBindBufferBase(GL_UNIFORM_BUFFER, imagesUboBinding, 0);
    glUseProgram(0);
}