Class CLEnvironment

java.lang.Object
foundry.veil.api.opencl.CLEnvironment
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource

public class CLEnvironment extends Object implements org.lwjgl.system.NativeResource
An OpenCL runtime environment on a specific device.
  • Constructor Details

  • Method Details

    • loadProgram

      public void loadProgram(net.minecraft.resources.ResourceLocation name, CharSequence source)
      Loads the specified source code under the specified name.
      Parameters:
      name - The name of the shader to load
      source - 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 at namespace:pinwheel/compute/path.cl.
      Parameters:
      name - The name of the shader file
      provider - 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 from
      kernelName - The name of the kernel
      Returns:
      The kernel created
      Throws:
      CLException - If there was an error creating the kernel for any reason
    • finish

      public void finish() throws CLException
      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:
      free in interface org.lwjgl.system.NativeResource
    • getDevice

      public VeilOpenCL.DeviceInfo getDevice()
      Returns:
      The device this environment is in
    • getEventDispatcher

      public CLEventDispatcher 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