Package foundry.veil.api.opencl
Class CLKernel
java.lang.Object
foundry.veil.api.opencl.CLKernel
- All Implemented Interfaces:
AutoCloseable,org.lwjgl.system.NativeResource
Manages the OpenCL kernel object. Buffers can be created with
createBuffer(int, long) and createBufferUnsafe(int, long)-
Method Summary
Modifier and TypeMethodDescriptionvoidacquireFromGL(CLMemObject... objects) Acquires the data referenced by this object from OpenGL to allow OpenCL to safely modify it.createBuffer(int flags, long size) Creates a new CL memory buffer.createBufferFromGL(int flags, int buffer) Creates a new CL memory buffer that reflects the data in an OpenGL buffer.@Nullable CLBuffercreateBufferFromGLUnsafe(int flags, int buffer) Creates a new CL memory buffer that reflects the data in an OpenGL buffer.@Nullable CLBuffercreateBufferUnsafe(int flags, long size) Creates a new CL memory buffer.voidexecute(int[] globalWorkSizes, int[] localWorkSizes) Executes this kernel in n dimensions.voidexecute(int globalWorkSize, int localWorkSize) Executes this kernel in 1 dimension.voidexecute(int globalWorkSizeX, int localWorkSizeX, int globalWorkSizeY, int localWorkSizeY) Executes this kernel in 2 dimensions.voidexecute(int globalWorkSizeX, int localWorkSizeX, int globalWorkSizeY, int localWorkSizeY, int globalWorkSizeZ, int localWorkSizeZ) Executes this kernel in 3 dimensions.voidfree()longintnet.minecraft.resources.ResourceLocationvoidreleaseToGL(CLMemObject... objects) Releases the data referenced by this object from OpenCL to allow OpenGL to safely modify it again.voidsetByte(int index, byte value) Sets a single byte parameter.voidsetDouble(int index, double value) Sets a single double parameter.voidsetFloat(int index, float value) Sets a single float parameter.voidsetInt(int index, int value) Sets a single int parameter.voidsetLong(int index, long value) Sets a single long parameter.voidsetPointers(int index, long... value) Sets an array of pointers to the specified parameter.voidsetPointers(int index, CLMemObject... value) Sets an array of memory object pointers to the specified parameter.voidsetShort(int index, short value) Sets a single short parameter.voidsetVector2f(int index, float x, float y) Sets a single float2 parameter.voidsetVector2f(int index, org.joml.Vector2fc value) Sets a single float2 parameter.voidsetVector3f(int index, org.joml.Vector3fc value) Sets a single float4 parameter.voidsetVector4f(int index, float x, float y, float z, float w) Sets a single float4 parameter.voidsetVector4f(int index, org.joml.Vector4fc value) Sets a single float4 parameter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.lwjgl.system.NativeResource
close
-
Method Details
-
execute
Executes this kernel in 1 dimension.globalWorkSizemust be evenly divisible bylocalWorkSize- Parameters:
globalWorkSize- The size of the global work grouplocalWorkSize- The size of each local work group- Throws:
CLException- If any error occurs while executing the kernel- See Also:
-
execute
public void execute(int globalWorkSizeX, int localWorkSizeX, int globalWorkSizeY, int localWorkSizeY) throws CLException Executes this kernel in 2 dimensions.globalWorkSizemust be evenly divisible bylocalWorkSize- Parameters:
globalWorkSizeX- The size of the global work group in the XlocalWorkSizeX- The size of each local work group in the XglobalWorkSizeY- The size of the global work group in the YlocalWorkSizeY- The size of each local work group in the Y- Throws:
CLException- If any error occurs while executing the kernel- See Also:
-
execute
public void execute(int globalWorkSizeX, int localWorkSizeX, int globalWorkSizeY, int localWorkSizeY, int globalWorkSizeZ, int localWorkSizeZ) throws CLException Executes this kernel in 3 dimensions.globalWorkSizemust be evenly divisible bylocalWorkSize- Parameters:
globalWorkSizeX- The size of the global work group in the XlocalWorkSizeX- The size of each local work group in the XglobalWorkSizeY- The size of the global work group in the YlocalWorkSizeY- The size of each local work group in the YglobalWorkSizeZ- The size of the global work group in the ZlocalWorkSizeZ- The size of each local work group in the Z- Throws:
CLException- If any error occurs while executing the kernel- See Also:
-
execute
public void execute(int[] globalWorkSizes, int[] localWorkSizes) throws CLException, IllegalArgumentException Executes this kernel in n dimensions.globalWorkSizemust be evenly divisible bylocalWorkSize- Parameters:
globalWorkSizes- The size of each global work grouplocalWorkSizes- The size of each local work group- Throws:
CLException- If any error occurs while executing the kernelIllegalArgumentException- If the length ofglobalWorkSizesandlocalWorkSizesare not equal- See Also:
-
acquireFromGL
Acquires the data referenced by this object from OpenGL to allow OpenCL to safely modify it.- Parameters:
objects- The objects to acquire from OpenGL- Throws:
CLException- If any error occurs while trying to sync data
-
releaseToGL
Releases the data referenced by this object from OpenCL to allow OpenGL to safely modify it again.- Parameters:
objects- The objects to acquire from OpenGL- Throws:
CLException- If any error occurs while trying to sync data
-
createBufferUnsafe
Creates a new CL memory buffer. Any errors are consumed and printed to console.- Parameters:
flags- a bit-field that is used to specify allocation and usage information such as the memory area that should be used to allocate the buffer object and how it will be used. If value specified for flags is 0, the default is used which isMEM_READ_WRITE. One of:
All possible OpenCL memory buffer flags MEM_READ_WRITEMEM_WRITE_ONLYMEM_READ_ONLYMEM_USE_HOST_PTRMEM_ALLOC_HOST_PTRMEM_COPY_HOST_PTRMEM_HOST_WRITE_ONLYMEM_HOST_READ_ONLYMEM_HOST_NO_ACCESSsize- The size of the buffer in bytes- Returns:
- A data buffer that can be used with
setPointers(int, long...)orsetPointers(int, CLMemObject...)ornullif an error occurred - See Also:
-
createBuffer
Creates a new CL memory buffer.- Parameters:
flags- a bit-field that is used to specify allocation and usage information such as the memory area that should be used to allocate the buffer object and how it will be used. If value specified for flags is 0, the default is used which isMEM_READ_WRITE. One of:
OpenCL memory buffer flags MEM_READ_WRITEMEM_WRITE_ONLYMEM_READ_ONLYMEM_USE_HOST_PTRMEM_ALLOC_HOST_PTRMEM_COPY_HOST_PTRMEM_HOST_WRITE_ONLYMEM_HOST_READ_ONLYMEM_HOST_NO_ACCESSsize- The size of the buffer in bytes- Returns:
- A data buffer that can be used with
setPointers(int, long...)orsetPointers(int, CLMemObject...) - Throws:
CLException- If there is any problem creating the buffer- See Also:
-
createBufferFromGLUnsafe
Creates a new CL memory buffer that reflects the data in an OpenGL buffer. Any errors are consumed and printed to console.- Parameters:
flags- a bit-field that is used to specify allocation and usage information such as the memory area that should be used to allocate the buffer object and how it will be used. If value specified for flags is 0, the default is used which isMEM_READ_WRITE. One of:
OpenCL memory buffer flags MEM_READ_WRITEMEM_WRITE_ONLYMEM_READ_ONLYbuffer- The OpenGL buffer to attach to- Returns:
- A data buffer that can be used with
setPointers(int, long...)orsetPointers(int, CLMemObject...)ornullif an error occurred - See Also:
-
createBufferFromGL
Creates a new CL memory buffer that reflects the data in an OpenGL buffer.- Parameters:
flags- a bit-field that is used to specify allocation and usage information such as the memory area that should be used to allocate the buffer object and how it will be used. If value specified for flags is 0, the default is used which isMEM_READ_WRITE. One of:
OpenCL memory buffer flags MEM_READ_WRITEMEM_WRITE_ONLYMEM_READ_ONLYbuffer- The OpenGL buffer to attach to- Returns:
- A data buffer that can be used with
setPointers(int, long...)orsetPointers(int, CLMemObject...) - Throws:
CLException- If there is any problem creating the buffer- See Also:
-
setByte
Sets a single byte parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setShort
Sets a single short parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setInt
Sets a single int parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setLong
Sets a single long parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setFloat
Sets a single float parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setVector2f
Sets a single float2 parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setVector2f
Sets a single float2 parameter.- Parameters:
index- The index to set the parameter forx- The X value of the parametery- The Y value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setVector3f
Sets a single float4 parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setVector4f
Sets a single float4 parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setVector4f
Sets a single float4 parameter.- Parameters:
index- The index to set the parameter forx- The X value of the parametery- The Y value of the parameterz- The Z value of the parameterw- The W value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setDouble
Sets a single double parameter.- Parameters:
index- The index to set the parameter forvalue- The value of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setPointers
Sets an array of pointers to the specified parameter.- Parameters:
index- The index to set the parameter forvalue- The values of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
setPointers
Sets an array of memory object pointers to the specified parameter.- Parameters:
index- The index to set the parameter forvalue- The values of the parameter- Throws:
CLException- If there is any problem setting the kernel argument
-
getEnvironment
- Returns:
- The environment this kernel is in
-
getProgram
public net.minecraft.resources.ResourceLocation getProgram()- Returns:
- The name of the program this kernel is created from
-
getHandle
public long getHandle()- Returns:
- The pointer to the kernel object
-
getMaxWorkGroupSize
public int getMaxWorkGroupSize()- Returns:
- The maximum size a work group can be
-
free
public void free()- Specified by:
freein interfaceorg.lwjgl.system.NativeResource
-