org.lwjgl.opengl.ARBSync Maven / Gradle / Ivy
Show all versions of org.lwjgl.opengl Show documentation
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.opengl;
import java.nio.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* Native bindings to the ARB_sync extension.
*
* This extension introduces the concept of "sync objects". Sync objects are a synchronization primitive - a representation of events whose completion
* status can be tested or waited upon. One specific type of sync object, the "fence sync object", is supported in this extension, and additional types can
* easily be added in the future.
*
* Fence sync objects have corresponding fences, which are inserted into the OpenGL command stream at the time the sync object is created. A sync object
* can be queried for a given condition. The only condition supported for fence sync objects is completion of the corresponding fence command. Fence
* completion allows applications to request a partial Finish, wherein all commands prior to the fence will be forced to complete before control is
* returned to the calling process.
*
* These new mechanisms allow for synchronization between the host CPU and the GPU, which may be accessing the same resources (typically memory), as well
* as between multiple GL contexts bound to multiple threads in the host CPU.
*
* Requires {@link GL31 OpenGL 3.1}. Promoted to core in {@link GL32 OpenGL 3.2}.
*/
public class ARBSync {
/** Accepted as the {@code pname} parameter of GetInteger64v. */
public static final int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111;
/** Accepted as the {@code pname} parameter of GetSynciv. */
public static final int
GL_OBJECT_TYPE = 0x9112,
GL_SYNC_CONDITION = 0x9113,
GL_SYNC_STATUS = 0x9114,
GL_SYNC_FLAGS = 0x9115;
/** Returned in {@code values} for GetSynciv {@code pname} OBJECT_TYPE. */
public static final int GL_SYNC_FENCE = 0x9116;
/** Returned in {@code values} for GetSynciv {@code pname} SYNC_CONDITION. */
public static final int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117;
/** Returned in {@code values} for GetSynciv {@code pname} SYNC_STATUS. */
public static final int
GL_UNSIGNALED = 0x9118,
GL_SIGNALED = 0x9119;
/** Accepted in the {@code flags} parameter of ClientWaitSync. */
public static final int GL_SYNC_FLUSH_COMMANDS_BIT = 0x1;
/** Accepted in the {@code timeout} parameter of WaitSync. */
public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl;
/** Returned by ClientWaitSync. */
public static final int
GL_ALREADY_SIGNALED = 0x911A,
GL_TIMEOUT_EXPIRED = 0x911B,
GL_CONDITION_SATISFIED = 0x911C,
GL_WAIT_FAILED = 0x911D;
static { GL.initialize(); }
protected ARBSync() {
throw new UnsupportedOperationException();
}
static boolean isAvailable(GLCapabilities caps) {
return checkFunctions(
caps.glFenceSync, caps.glIsSync, caps.glDeleteSync, caps.glClientWaitSync, caps.glWaitSync, caps.glGetInteger64v, caps.glGetSynciv
);
}
// --- [ glFenceSync ] ---
/**
* Creates a new sync object and inserts it into the GL command stream.
*
* @param condition the condition that must be met to set the sync object's state to signaled. Must be:
{@link GL32#GL_SYNC_GPU_COMMANDS_COMPLETE SYNC_GPU_COMMANDS_COMPLETE}
* @param flags a bitwise combination of flags controlling the behavior of the sync object. No flags are presently defined for this operation and {@code flags} must
* be zero.
*/
public static native long glFenceSync(int condition, int flags);
// --- [ glIsSync ] ---
/** Unsafe version of: {@link #glIsSync IsSync} */
public static native boolean nglIsSync(long sync);
/**
* Determines if a name corresponds to a sync object.
*
* @param sync a value that may be the name of a sync object
*/
public static boolean glIsSync(long sync) {
if (CHECKS) {
check(sync);
}
return nglIsSync(sync);
}
// --- [ glDeleteSync ] ---
/** Unsafe version of: {@link #glDeleteSync DeleteSync} */
public static native void nglDeleteSync(long sync);
/**
* Deletes a sync object.
*
* @param sync the sync object to be deleted
*/
public static void glDeleteSync(long sync) {
if (CHECKS) {
check(sync);
}
nglDeleteSync(sync);
}
// --- [ glClientWaitSync ] ---
/** Unsafe version of: {@link #glClientWaitSync ClientWaitSync} */
public static native int nglClientWaitSync(long sync, int flags, long timeout);
/**
* Causes the client to block and wait for a sync object to become signaled. If {@code sync} is signaled when {@code glClientWaitSync} is called,
* {@code glClientWaitSync} returns immediately, otherwise it will block and wait for up to timeout nanoseconds for {@code sync} to become signaled.
*
* The return value is one of four status values:
*
*
* - {@link GL32#GL_ALREADY_SIGNALED ALREADY_SIGNALED} indicates that sync was signaled at the time that glClientWaitSync was called.
* - {@link GL32#GL_TIMEOUT_EXPIRED TIMEOUT_EXPIRED} indicates that at least timeout nanoseconds passed and sync did not become signaled.
* - {@link GL32#GL_CONDITION_SATISFIED CONDITION_SATISFIED} indicates that sync was signaled before the timeout expired.
* - {@link GL32#GL_WAIT_FAILED WAIT_FAILED} indicates that an error occurred. Additionally, an OpenGL error will be generated.
*
*
* @param sync the sync object whose status to wait on
* @param flags a bitfield controlling the command flushing behavior. One or more of:
0 {@link GL32#GL_SYNC_FLUSH_COMMANDS_BIT SYNC_FLUSH_COMMANDS_BIT}
* @param timeout the timeout, specified in nanoseconds, for which the implementation should wait for {@code sync} to become signaled
*/
public static int glClientWaitSync(long sync, int flags, long timeout) {
if (CHECKS) {
check(sync);
}
return nglClientWaitSync(sync, flags, timeout);
}
// --- [ glWaitSync ] ---
/** Unsafe version of: {@link #glWaitSync WaitSync} */
public static native void nglWaitSync(long sync, int flags, long timeout);
/**
* Causes the GL server to block and wait for a sync object to become signaled.
*
* {@code glWaitSync} will always wait no longer than an implementation-dependent timeout. The duration of this timeout in nanoseconds may be queried by
* with {@link GL32#GL_MAX_SERVER_WAIT_TIMEOUT MAX_SERVER_WAIT_TIMEOUT}. There is currently no way to determine whether glWaitSync unblocked because the timeout expired or because the
* sync object being waited on was signaled.
*
* If an error occurs, {@code glWaitSync} does not cause the GL server to block.
*
* @param sync the sync object whose status to wait on
* @param flags a bitfield controlling the command flushing behavior. Must be:
0
* @param timeout the timeout that the server should wait before continuing. Must be:
{@link GL32#GL_TIMEOUT_IGNORED TIMEOUT_IGNORED}
*/
public static void glWaitSync(long sync, int flags, long timeout) {
if (CHECKS) {
check(sync);
}
nglWaitSync(sync, flags, timeout);
}
// --- [ glGetInteger64v ] ---
/** Unsafe version of: {@link #glGetInteger64v GetInteger64v} */
public static native void nglGetInteger64v(int pname, long params);
/**
* Returns the 64bit integer value or values of a selected parameter.
*
* @param pname the parameter value to be returned
* @param params the value or values of the specified parameter
*/
public static void glGetInteger64v(int pname, LongBuffer params) {
if (CHECKS) {
check(params, 1);
}
nglGetInteger64v(pname, memAddress(params));
}
/**
* Returns the 64bit integer value or values of a selected parameter.
*
* @param pname the parameter value to be returned
*/
public static long glGetInteger64(int pname) {
MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
try {
LongBuffer params = stack.callocLong(1);
nglGetInteger64v(pname, memAddress(params));
return params.get(0);
} finally {
stack.setPointer(stackPointer);
}
}
// --- [ glGetSynciv ] ---
/**
* Unsafe version of: {@link #glGetSynciv GetSynciv}
*
* @param bufSize the size of the buffer whose address is given in {@code values}
*/
public static native void nglGetSynciv(long sync, int pname, int bufSize, long length, long values);
/**
* Queries the properties of a sync object.
*
* @param sync the sync object whose properties to query
* @param pname the parameter whose value to retrieve from the sync object specified in {@code sync}. One of:
{@link GL32#GL_OBJECT_TYPE OBJECT_TYPE} {@link GL32#GL_SYNC_CONDITION SYNC_CONDITION} {@link GL32#GL_SYNC_STATUS SYNC_STATUS} {@link GL32#GL_SYNC_FLAGS SYNC_FLAGS}
* @param length the address of an variable to receive the number of integers placed in {@code values}
* @param values the address of an array to receive the values of the queried parameter
*/
public static void glGetSynciv(long sync, int pname, IntBuffer length, IntBuffer values) {
if (CHECKS) {
check(sync);
checkSafe(length, 1);
}
nglGetSynciv(sync, pname, values.remaining(), memAddressSafe(length), memAddress(values));
}
/**
* Queries the properties of a sync object.
*
* @param sync the sync object whose properties to query
* @param pname the parameter whose value to retrieve from the sync object specified in {@code sync}. One of:
{@link GL32#GL_OBJECT_TYPE OBJECT_TYPE} {@link GL32#GL_SYNC_CONDITION SYNC_CONDITION} {@link GL32#GL_SYNC_STATUS SYNC_STATUS} {@link GL32#GL_SYNC_FLAGS SYNC_FLAGS}
* @param length the address of an variable to receive the number of integers placed in {@code values}
*/
public static int glGetSynci(long sync, int pname, IntBuffer length) {
if (CHECKS) {
check(sync);
checkSafe(length, 1);
}
MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
try {
IntBuffer values = stack.callocInt(1);
nglGetSynciv(sync, pname, 1, memAddressSafe(length), memAddress(values));
return values.get(0);
} finally {
stack.setPointer(stackPointer);
}
}
/** Array version of: {@link #glGetInteger64v GetInteger64v} */
public static void glGetInteger64v(int pname, long[] params) {
long __functionAddress = GL.getICD().glGetInteger64v;
if (CHECKS) {
check(__functionAddress);
check(params, 1);
}
callPV(__functionAddress, pname, params);
}
/** Array version of: {@link #glGetSynciv GetSynciv} */
public static void glGetSynciv(long sync, int pname, int[] length, int[] values) {
long __functionAddress = GL.getICD().glGetSynciv;
if (CHECKS) {
check(__functionAddress);
check(sync);
checkSafe(length, 1);
}
callPPPV(__functionAddress, sync, pname, values.length, length, values);
}
}