Package foundry.veil.opencl
Class CLKernel
java.lang.Object
foundry.veil.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 TypeMethodDescriptioncreateBuffer(int flags, long size) Creates a new CL memory 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.ResourceLocationvoidsetByte(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.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:
-
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:
-
CL10.clCreateBuffer(long, long, long, IntBuffer)
-
createBuffer
Creates a new CL memory buffer. The creation- 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:
-
CL10.clCreateBuffer(long, long, long, IntBuffer)
-
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
-
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
-