Package foundry.veil.api.opencl
Class CLEnvironment
java.lang.Object
foundry.veil.api.opencl.CLEnvironment
- All Implemented Interfaces:
AutoCloseable,org.lwjgl.system.NativeResource
An OpenCL runtime environment on a specific device.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateKernel(net.minecraft.resources.ResourceLocation program, String kernelName) Creates a kernel for the specified shader program.voidfinish()Blocks until all CL commands have completed.voidfree()voidfreeProgram(net.minecraft.resources.ResourceLocation program) Destroys the program with the specified name.longlongbooleanvoidloadProgram(net.minecraft.resources.ResourceLocation name, CharSequence source) Loads the specified source code under the specified name.voidloadProgram(net.minecraft.resources.ResourceLocation name, net.minecraft.server.packs.resources.ResourceProvider provider) Loads the specified program binary from file.booleanMethods 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
-
Constructor Details
-
CLEnvironment
- Throws:
CLException
-
-
Method Details
-
loadProgram
Loads the specified source code under the specified name.- Parameters:
name- The name of the shader to loadsource- The source code to compile
-
loadProgram
public void loadProgram(net.minecraft.resources.ResourceLocation name, net.minecraft.server.packs.resources.ResourceProvider provider) throws IOException Loads the specified program binary from file. They are expected to be located atnamespace:pinwheel/compute/path.cl.- Parameters:
name- The name of the shader fileprovider- The provider for files- Throws:
IOException- If any errors occurs
-
createKernel
public CLKernel createKernel(net.minecraft.resources.ResourceLocation program, String kernelName) throws CLException Creates a kernel for the specified shader program.
The returned kernel should be freed when it is no longer needed. To be clear, after the last kernel for a program has been freed the program WILL be freed and must be loaded again.
- Parameters:
program- The name of the program to get the kernel fromkernelName- The name of the kernel- Returns:
- The kernel created
- Throws:
CLException- If there was an error creating the kernel for any reason
-
finish
Blocks until all CL commands have completed.- Throws:
CLException- If any error occurs while trying to block
-
freeProgram
public void freeProgram(net.minecraft.resources.ResourceLocation program) Destroys the program with the specified name. This will do nothing if the program doesn't exist.- Parameters:
program- The name of the program to free
-
isOpenGLSupported
public boolean isOpenGLSupported()- Returns:
- Whether this environment supports OpenGL interoperability
-
requireManualInteropSync
public boolean requireManualInteropSync()- Returns:
- Whether the user is expected to sync GL/CL buffers
-
free
@Internal public void free()- Specified by:
freein interfaceorg.lwjgl.system.NativeResource
-
getDevice
- Returns:
- The device this environment is in
-
getEventDispatcher
- Returns:
- The dispatcher for event callbacks
-
getContext
public long getContext()- Returns:
- The pointer to the OpenCL context
-
getCommandQueue
public long getCommandQueue()- Returns:
- The pointer to the OpenCL queue
-