improve format and rm trailing whitespace (10 files in com.jme3.opencl)

master
Stephen Gold 5 years ago
parent a5e0213b01
commit 7212f9b2b2
  1. 17
      jme3-core/src/main/java/com/jme3/opencl/Buffer.java
  2. 6
      jme3-core/src/main/java/com/jme3/opencl/CommandQueue.java
  3. 26
      jme3-core/src/main/java/com/jme3/opencl/Context.java
  4. 54
      jme3-core/src/main/java/com/jme3/opencl/Device.java
  5. 4
      jme3-core/src/main/java/com/jme3/opencl/Event.java
  6. 41
      jme3-core/src/main/java/com/jme3/opencl/Image.java
  7. 34
      jme3-core/src/main/java/com/jme3/opencl/Kernel.java
  8. 6
      jme3-core/src/main/java/com/jme3/opencl/KernelCompilationException.java
  9. 5
      jme3-core/src/main/java/com/jme3/opencl/OpenCLException.java
  10. 12
      jme3-core/src/main/java/com/jme3/opencl/Program.java

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2016 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -75,6 +75,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Performs a blocking read of the buffer.
* The target buffer must have at least {@code size} bytes remaining.
* This method may set the limit to the last byte read.
*
* @param queue the command queue
* @param dest the target buffer
* @param size the size in bytes being read
@ -102,6 +103,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Performs an async/non-blocking read of the buffer.
* The target buffer must have at least {@code size} bytes remaining.
* This method may set the limit to the last byte read.
*
* @param queue the command queue
* @param dest the target buffer
* @param size the size in bytes being read
@ -130,6 +132,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Performs a blocking write to the buffer.
* The target buffer must have at least {@code size} bytes remaining.
* This method may set the limit to the last byte that will be written.
*
* @param queue the command queue
* @param src the source buffer, its data is written to this buffer
* @param size the size in bytes to write
@ -157,6 +160,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Performs an async/non-blocking write to the buffer.
* The target buffer must have at least {@code size} bytes remaining.
* This method may set the limit to the last byte that will be written.
*
* @param queue the command queue
* @param src the source buffer, its data is written to this buffer
* @param size the size in bytes to write
@ -183,6 +187,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
/**
* Performs a blocking copy operation from this buffer to the specified buffer.
*
* @param queue the command queue
* @param dest the target buffer
* @param size the size in bytes to copy
@ -209,6 +214,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
/**
* Performs an async/non-blocking copy operation from this buffer to the specified buffer.
*
* @param queue the command queue
* @param dest the target buffer
* @param size the size in bytes to copy
@ -240,6 +246,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* provides the memory.<br>
* <b>Important:</b> The mapped memory MUST be released by calling
* {@link #unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer) }.
*
* @param queue the command queue
* @param size the size in bytes to map
* @param offset the offset into this buffer
@ -272,6 +279,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Unmaps a previously mapped memory.
* This releases the native resources and for WRITE_ONLY or READ_WRITE access,
* the memory content is sent back to the GPU.
*
* @param queue the command queue
* @param ptr the buffer that was previously mapped
*/
@ -283,6 +291,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* provides the memory.<br>
* <b>Important:</b> The mapped memory MUST be released by calling
* {@link #unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer) }.
*
* @param queue the command queue
* @param size the size in bytes to map
* @param offset the offset into this buffer
@ -291,6 +300,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* and the event indicating when the buffer contents are available
*/
public abstract AsyncMapping mapAsync(CommandQueue queue, long size, long offset, MappingAccess access);
/**
* Alternative version of {@link #mapAsync(com.jme3.opencl.CommandQueue, long, long, com.jme3.opencl.MappingAccess) },
* sets {@code offset} to zero.
@ -300,6 +310,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
public AsyncMapping mapAsync(CommandQueue queue, long size, MappingAccess access) {
return mapAsync(queue, size, 0, access);
}
/**
* Alternative version of {@link #mapAsync(com.jme3.opencl.CommandQueue, long, com.jme3.opencl.MappingAccess) },
* sets {@code size} to {@link #getSize() }.
@ -313,6 +324,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
/**
* Enqueues a fill operation. This method can be used to initialize or clear
* a buffer with a certain value.
*
* @param queue the command queue
* @param pattern the buffer containing the filling pattern.
* The remaining bytes specify the pattern length
@ -379,6 +391,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* done, the buffer must be released by calling
* {@link #releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue) }
* so that OpenGL can use the VertexBuffer again.
*
* @param queue the command queue
* @return the event object
*/
@ -411,6 +424,7 @@ public abstract class Buffer extends AbstractOpenCLObject {
* Call this method after the buffer object was acquired by
* {@link #acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue) }
* to hand the control back to OpenGL.
*
* @param queue the command queue
* @return the event object
*/
@ -434,5 +448,4 @@ public abstract class Buffer extends AbstractOpenCLObject {
public String toString() {
return "Buffer (" + getSize() + "B)";
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2016 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,10 +40,10 @@ package com.jme3.opencl;
* Each command queue is associtated with exactly one device: that device
* is specified on creation ({@link Context#createQueue(com.jme3.opencl.Device) })
* and all commands are sent to this device.
*
* @author shaman
*/
public abstract class CommandQueue extends AbstractOpenCLObject {
protected Device device;
protected CommandQueue(ObjectReleaser releaser, Device device) {
@ -61,6 +61,7 @@ public abstract class CommandQueue extends AbstractOpenCLObject {
* Returns the device associated with this command queue.
* It can be used to query properties of the device that is used to execute
* the commands issued to this command queue.
*
* @return the associated device
*/
public Device getDevice() {
@ -83,5 +84,4 @@ public abstract class CommandQueue extends AbstractOpenCLObject {
* processed and completed. Finish is also a synchronization point.
*/
public abstract void finish();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -63,6 +63,7 @@ import java.util.logging.Logger;
* <li>Created buffers and images shared with OpenGL vertex buffers, textures and renderbuffers</li>
* <li>Create program objects from source code and source files</li>
* </ul>
*
* @author shaman
*/
public abstract class Context extends AbstractOpenCLObject {
@ -87,6 +88,7 @@ public abstract class Context extends AbstractOpenCLObject {
* memory size and so on, are queried over the Device instances.
* <br>
* The available devices were specified by a {@link PlatformChooser}.
*
* @return a list of devices
*/
public abstract List<? extends Device> getDevices();
@ -94,14 +96,17 @@ public abstract class Context extends AbstractOpenCLObject {
/**
* Alternative version of {@link #createQueue(com.jme3.opencl.Device) },
* just uses the first device returned by {@link #getDevices() }.
*
* @return the command queue
*/
public CommandQueue createQueue() {
return createQueue(getDevices().get(0));
}
/**
* Creates a command queue sending commands to the specified device.
* The device must be an entry of {@link #getDevices() }.
*
* @param device the target device
* @return the command queue
*/
@ -109,14 +114,17 @@ public abstract class Context extends AbstractOpenCLObject {
/**
* Allocates a new buffer of the specific size and access type on the device.
*
* @param size the size of the buffer in bytes
* @param access the allowed access of this buffer from kernel code
* @return the new buffer
*/
public abstract Buffer createBuffer(long size, MemoryAccess access);
/**
* Alternative version of {@link #createBuffer(long, com.jme3.opencl.MemoryAccess) },
* creates a buffer with read and write access.
*
* @param size the size of the buffer in bytes
* @return the new buffer
*/
@ -129,14 +137,17 @@ public abstract class Context extends AbstractOpenCLObject {
* specified by a ByteBuffer can then be used directly by kernel code,
* although the access might be slower than with native buffers
* created by {@link #createBuffer(long, com.jme3.opencl.MemoryAccess) }.
*
* @param data the host buffer to use
* @param access the allowed access of this buffer from kernel code
* @return the new buffer
*/
public abstract Buffer createBufferFromHost(ByteBuffer data, MemoryAccess access);
/**
* Alternative version of {@link #createBufferFromHost(java.nio.ByteBuffer, com.jme3.opencl.MemoryAccess) },
* creates a buffer with read and write access.
*
* @param data the host buffer to use
* @return the new buffer
*/
@ -152,6 +163,7 @@ public abstract class Context extends AbstractOpenCLObject {
* with row and slice pitches. This buffer is then used to store the image.
* If no ByteBuffer is specified, a new buffer is allocated (this is the
* normal behaviour).
*
* @param access the allowed access of this image from kernel code
* @param format the image format
* @param descr the image descriptor
@ -168,6 +180,7 @@ public abstract class Context extends AbstractOpenCLObject {
* where {@code ImageChannelType} or {@code ImageChannelOrder} are {@code null}
* (or both). This is the case when the device supports new formats that
* are not included in this wrapper yet.
*
* @param access the memory access type
* @param type the image type (1D, 2D, 3D, ...)
* @return an array of all supported image formats
@ -188,6 +201,7 @@ public abstract class Context extends AbstractOpenCLObject {
* by {@link Buffer#acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue) }
* and after modifying it, released by {@link Buffer#releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue) }.
* This is needed so that OpenGL and OpenCL operations do not interfere with each other.
*
* @param vb the vertex buffer to share
* @param access the memory access for the kernel
* @return the new buffer
@ -216,6 +230,7 @@ public abstract class Context extends AbstractOpenCLObject {
* @return the OpenCL image
*/
public abstract Image bindImage(com.jme3.texture.Image image, Texture.Type textureType, int miplevel, MemoryAccess access);
/**
* Creates a shared image object from a jME3 texture.
* The returned image shares the same memory with the jME3 texture, changes
@ -242,9 +257,11 @@ public abstract class Context extends AbstractOpenCLObject {
public Image bindImage(Texture texture, int miplevel, MemoryAccess access) {
return bindImage(texture.getImage(), texture.getType(), miplevel, access);
}
/**
* Alternative version to {@link #bindImage(com.jme3.texture.Texture, int, com.jme3.opencl.MemoryAccess) },
* uses {@code miplevel=0}.
*
* @param texture the jME3 texture
* @param access the allowed memory access for kernels
* @return the OpenCL image
@ -252,6 +269,7 @@ public abstract class Context extends AbstractOpenCLObject {
public Image bindImage(Texture texture, MemoryAccess access) {
return bindImage(texture, 0, access);
}
/**
* Creates a shared image object from a jME3 render buffer.
* The returned image shares the same memory with the jME3 render buffer, changes
@ -279,6 +297,7 @@ public abstract class Context extends AbstractOpenCLObject {
return bindImage(buffer.getTexture(), access);
}
}
protected abstract Image bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access);
/**
@ -295,6 +314,7 @@ public abstract class Context extends AbstractOpenCLObject {
* and delegates the combined source code to
* {@link #createProgramFromSourceCode(java.lang.String) }.
* Important: only absolute paths are allowed.
*
* @param sourceCode the original source code
* @param assetManager the asset manager to load the files
* @return the created program object
@ -310,6 +330,7 @@ public abstract class Context extends AbstractOpenCLObject {
}
return createProgramFromSourceCode(builder.toString());
}
private void buildSourcesRec(BufferedReader reader, StringBuilder builder, AssetManager assetManager) throws IOException {
String ln;
while ((ln = reader.readLine()) != null) {
@ -410,6 +431,7 @@ public abstract class Context extends AbstractOpenCLObject {
/**
* Alternative version of {@link #createProgramFromSourceFilesWithInclude(com.jme3.asset.AssetManager, java.lang.String, java.lang.String...) }
* with an empty include string
*
* @throws AssetNotFoundException if a file could not be loaded
*/
public Program createProgramFromSourceFiles(AssetManager assetManager, String... resources) {
@ -419,6 +441,7 @@ public abstract class Context extends AbstractOpenCLObject {
/**
* Alternative version of {@link #createProgramFromSourceFilesWithInclude(com.jme3.asset.AssetManager, java.lang.String, java.util.List) }
* with an empty include string
*
* @throws AssetNotFoundException if a file could not be loaded
*/
public Program createProgramFromSourceFiles(AssetManager assetManager, List<String> resources) {
@ -447,5 +470,4 @@ public abstract class Context extends AbstractOpenCLObject {
public String toString() {
return "Context (" + getDevices() + ')';
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -45,12 +45,10 @@ import java.util.Collection;
* @author shaman
*/
public interface Device {
/**
* @return the platform associated with this device
*/
Platform getPlatform();
/**
* The device type
*/
@ -61,16 +59,20 @@ public interface Device {
ACCELEARTOR,
ALL
}
/**
* @return queries the device type
*/
DeviceType getDeviceType();
/**
* @return the vendor id
*/
int getVendorId();
/**
* checks if this device is available at all, must always be tested
*
* @return checks if this device is available at all, must always be tested
*/
boolean isAvailable();
@ -79,42 +81,53 @@ public interface Device {
* @return if this device has a compiler for kernel code
*/
boolean hasCompiler();
/**
* @return supports double precision floats (64 bit)
*/
boolean hasDouble();
/**
* @return supports half precision floats (16 bit)
*/
boolean hasHalfFloat();
/**
* @return supports error correction for every access to global or constant memory
*/
boolean hasErrorCorrectingMemory();
/**
* @return supports unified virtual memory (OpenCL 2.0)
*/
boolean hasUnifiedMemory();
/**
* @return supports images
*/
boolean hasImageSupport();
/**
* @return supports writes to 3d images (this is an extension)
*/
boolean hasWritableImage3D();
/**
* @return supports sharing with OpenGL
*/
boolean hasOpenGLInterop();
/**
* Explictly tests for the availability of the specified extension
*
* @param extension the name of the extension
* @return {@code true} iff this extension is supported
*/
boolean hasExtension(String extension);
/**
* Lists all available extensions
*
* @return all available extensions
*/
Collection<? extends String> getExtensions();
@ -129,18 +142,22 @@ public interface Device {
* @see #getMaximumWorkItemSizes()
*/
int getComputeUnits();
/**
* @return maximum clock frequency of the device in MHz
*/
int getClockFrequency();
/**
* Returns the default compute device address space
* size specified as an unsigned integer value
* in bits. Currently supported values are 32
* or 64 bits.
*
* @return the size of an address
*/
int getAddressBits();
/**
* @return {@code true} if this device is little endian
*/
@ -150,21 +167,26 @@ public interface Device {
* The maximum dimension that specify the local and global work item ids.
* You can always assume to be this at least 3.
* Therefore, the ids are always three integers x,y,z.
*
* @return the maximum dimension of work item ids
*/
long getMaximumWorkItemDimensions();
/**
* Maximum number of work-items that can be specified in each dimension of the
* work-group to {@link Kernel#Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...)}.
* The array has a length of at least 3.
*
* @return the maximum size of the work group in each dimension
*/
long[] getMaximumWorkItemSizes();
/**
* Maximum number of work-items in a
* work-group executing a kernel on a single
* compute unit, using the data parallel
* execution model.
*
* @return maximum number of work-items in a work-group
*/
long getMaxiumWorkItemsPerGroup();
@ -173,21 +195,27 @@ public interface Device {
* @return the maximum number of samples that can be used in a kernel
*/
int getMaximumSamplers();
/**
* @return the maximum number of images that can be used for reading in a kernel
*/
int getMaximumReadImages();
/**
* @return the maximum number of images that can be used for writing in a kernel
*/
int getMaximumWriteImages();
/**
* Queries the maximal size of a 2D image
*
* @return an array of length 2 with the maximal size of a 2D image
*/
long[] getMaximumImage2DSize();
/**
* Queries the maximal size of a 3D image
*
* @return an array of length 3 with the maximal size of a 3D image
*/
long[] getMaximumImage3DSize();
@ -196,14 +224,17 @@ public interface Device {
* @return the maximal size of a memory object (buffer and image) in bytes
*/
long getMaximumAllocationSize();
/**
* @return the total available global memory in bytes
*/
long getGlobalMemorySize();
/**
* @return the total available local memory in bytes
*/
long getLocalMemorySize();
/**
* Returns the maximal size of a constant buffer.
* <br>
@ -214,6 +245,7 @@ public interface Device {
* @return the maximal size of a constant buffer
*/
long getMaximumConstantBufferSize();
/**
* @return the maximal number of constant buffer arguments in a kernel call
*/
@ -231,6 +263,7 @@ public interface Device {
* @return the profile string
*/
String getProfile();
/**
* OpenCL version string. Returns the OpenCL version supported by the
* device. This version string has the following format: OpenCL space
@ -241,14 +274,18 @@ public interface Device {
* @return the version string
*/
String getVersion();
/**
* Extracts the major version from the version string
*
* @return the major version
* @see #getVersion()
*/
int getVersionMajor();
/**
* Extracts the minor version from the version string
*
* @return the minor version
* @see #getVersion() }
*/
@ -269,31 +306,40 @@ public interface Device {
* @return the compiler version
*/
String getCompilerVersion();
/**
* Extracts the major version from the compiler version
*
* @return the major compiler version
* @see #getCompilerVersion()
*/
int getCompilerVersionMajor();
/**
* Extracts the minor version from the compiler version
*
* @return the minor compiler version
* @see #getCompilerVersion()
*/
int getCompilerVersionMinor();
/**
* @return the OpenCL software driver version string in the form
* major_number.minor_number
*/
String getDriverVersion();
/**
* Extracts the major version from the driver version
*
* @return the major driver version
* @see #getDriverVersion()
*/
int getDriverVersionMajor();
/**
* Extracts the minor version from the driver version
*
* @return the minor driver version
* @see #getDriverVersion()
*/
@ -303,9 +349,9 @@ public interface Device {
* @return the device name
*/
String getName();
/**
* @return the vendor
*/
String getVendor();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2016 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@ package com.jme3.opencl;
* Events are returned from kernel launches and all asynchronous operations.
* They allow to test if the action has completed and to block until the operation
* is done.
*
* @author shaman
*/
public abstract class Event extends AbstractOpenCLObject {
@ -59,6 +60,7 @@ public abstract class Event extends AbstractOpenCLObject {
/**
* Tests if the action is completed.
* If the action is completed, the event is released.
*
* @return {@code true} if the action is completed
*/
public abstract boolean isCompleted();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -75,7 +75,6 @@ import java.util.Objects;
* @author shaman
*/
public abstract class Image extends AbstractOpenCLObject {
/**
* {@code ImageChannelType} describes the size of the channel data type.
*/
@ -99,7 +98,7 @@ public abstract class Image extends AbstractOpenCLObject {
/**
* {@code ImageChannelOrder} specifies the number of channels and the channel layout i.e. the
memory layout in which channels are stored in the image.
* memory layout in which channels are stored in the image.
*/
public static enum ImageChannelOrder {
R, Rx, A,
@ -157,7 +156,6 @@ memory layout in which channels are stored in the image.
}
return true;
}
}
/**
@ -200,6 +198,7 @@ memory layout in which channels are stored in the image.
/**
* Used to specify an image with the provided ByteBuffer as soruce
*
* @param type the image type
* @param width the width
* @param height the height, unused for image types {@code ImageType.IMAGE_1D*}
@ -219,9 +218,11 @@ memory layout in which channels are stored in the image.
this.slicePitch = slicePitch;
this.hostPtr = hostPtr;
}
/**
* Specifies an image without a host buffer, a new chunk of memory
* will be allocated.
*
* @param type the image type
* @param width the width
* @param height the height, unused for image types {@code ImageType.IMAGE_1D*}
@ -243,7 +244,6 @@ memory layout in which channels are stored in the image.
public String toString() {
return "ImageDescriptor{" + "type=" + type + ", width=" + width + ", height=" + height + ", depth=" + depth + ", arraySize=" + arraySize + ", rowPitch=" + rowPitch + ", slicePitch=" + slicePitch + '}';
}
}
protected Image(ObjectReleaser releaser) {
@ -260,36 +260,44 @@ memory layout in which channels are stored in the image.
* @return the width of the image
*/
public abstract long getWidth();
/**
* @return the height of the image
*/
public abstract long getHeight();
/**
* @return the depth of the image
*/
public abstract long getDepth();
/**
* @return the row pitch when the image was created from a host buffer
*/
public abstract long getRowPitch();
/**
* @return the slice pitch when the image was created from a host buffer
*/
public abstract long getSlicePitch();
/**
* @return the number of elements in the image array
* @see ImageType#IMAGE_1D_ARRAY
* @see ImageType#IMAGE_2D_ARRAY
*/
public abstract long getArraySize();
/**
* @return the image format
*/
public abstract ImageFormat getImageFormat();
/**
* @return the image type
*/
public abstract ImageType getImageType();
/**
* @return the number of bytes per pixel
*/
@ -297,6 +305,7 @@ memory layout in which channels are stored in the image.
/**
* Performs a blocking read of the image into the specified byte buffer.
*
* @param queue the command queue
* @param dest the target byte buffer
* @param origin the image origin location, see class description for the format
@ -307,8 +316,10 @@ memory layout in which channels are stored in the image.
* If set to 0 for 3D images, the slice pitch is calculated as {@code rowPitch * height}
*/
public abstract void readImage(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch);
/**
* Performs an async/non-blocking read of the image into the specified byte buffer.
*
* @param queue the command queue
* @param dest the target byte buffer
* @param origin the image origin location, see class description for the format
@ -323,6 +334,7 @@ memory layout in which channels are stored in the image.
/**
* Performs a blocking write from the specified byte buffer into the image.
*
* @param queue the command queue
* @param src the source buffer
* @param origin the image origin location, see class description for the format
@ -333,8 +345,10 @@ memory layout in which channels are stored in the image.
* If set to 0 for 3D images, the slice pitch is calculated as {@code rowPitch * height}
*/
public abstract void writeImage(CommandQueue queue, ByteBuffer src, long[] origin, long[] region, long rowPitch, long slicePitch);
/**
* Performs an async/non-blocking write from the specified byte buffer into the image.
*
* @param queue the command queue
* @param src the source buffer
* @param origin the image origin location, see class description for the format
@ -350,6 +364,7 @@ memory layout in which channels are stored in the image.
/**
* Performs a blocking copy operation from one image to another.
* <b>Important:</b> Both images must have the same format!
*
* @param queue the command queue
* @param dest the target image
* @param srcOrigin the source image origin, see class description for the format
@ -357,9 +372,11 @@ memory layout in which channels are stored in the image.
* @param region the copied region, see class description for the format
*/
public abstract void copyTo(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region);
/**
* Performs an async/non-blocking copy operation from one image to another.
* <b>Important:</b> Both images must have the same format!
*
* @param queue the command queue
* @param dest the target image
* @param srcOrigin the source image origin, see class description for the format
@ -374,6 +391,7 @@ memory layout in which channels are stored in the image.
* The returned structure contains the mapped byte buffer and row and slice pitch.
* The event object is set to {@code null}, it is needed for the asnyc
* version {@link #mapAsync(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess) }.
*
* @param queue the command queue
* @param origin the image origin, see class description for the format
* @param region the mapped region, see class description for the format
@ -382,6 +400,7 @@ memory layout in which channels are stored in the image.
* @see #unmap(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image.ImageMapping)
*/
public abstract ImageMapping map(CommandQueue queue, long[] origin, long[] region, MappingAccess access);
/**
* Non-blocking version of {@link #map(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess) }.
* The returned structure contains the mapped byte buffer and row and slice pitch.
@ -394,8 +413,10 @@ memory layout in which channels are stored in the image.
* @see #unmap(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image.ImageMapping)
*/
public abstract ImageMapping mapAsync(CommandQueue queue, long[] origin, long[] region, MappingAccess access);
/**
* Unmaps the mapped memory
*
* @param queue the command queue
* @param mapping the mapped memory
*/
@ -421,6 +442,7 @@ memory layout in which channels are stored in the image.
public final long slicePitch;
/**
* The event object used to detect when the memory is available.
*
* @see #mapAsync(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess)
*/
public final Event event;
@ -431,19 +453,20 @@ memory layout in which channels are stored in the image.
this.slicePitch = slicePitch;
this.event = event;
}
public ImageMapping(ByteBuffer buffer, long rowPitch, long slicePitch) {
this.buffer = buffer;
this.rowPitch = rowPitch;
this.slicePitch = slicePitch;
this.event = null;
}
}
/**
* Fills the image with the specified color.
* Does <b>only</b> work if the image channel is {@link ImageChannelType#FLOAT}
* or {@link ImageChannelType#HALF_FLOAT}.
*
* @param queue the command queue
* @param origin the image origin, see class description for the format
* @param region the size of the region, see class description for the format
@ -455,6 +478,7 @@ memory layout in which channels are stored in the image.
* Fills the image with the specified color given as four integer variables.
* Does <b>not</b> work if the image channel is {@link ImageChannelType#FLOAT}
* or {@link ImageChannelType#HALF_FLOAT}.
*
* @param queue the command queue
* @param origin the image origin, see class description for the format
* @param region the size of the region, see class description for the format
@ -467,6 +491,7 @@ memory layout in which channels are stored in the image.
* Copies this image into the specified buffer, no format conversion is done.
* This is the dual function to
* {@link Buffer#copyToImageAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image, long, long[], long[]) }.
*
* @param queue the command queue
* @param dest the target buffer
* @param srcOrigin the image origin, see class description for the format
@ -485,6 +510,7 @@ memory layout in which channels are stored in the image.
* done, the image must be released by calling
* {@link #releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) }
* so that OpenGL can use the image/texture/renderbuffer again.
*
* @param queue the command queue
* @return the event object
*/
@ -518,6 +544,7 @@ memory layout in which channels are stored in the image.
* Call this method after the image object was acquired by
* {@link #acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) }
* to hand the control back to OpenGL.
*
* @param queue the command queue
* @return the event object
*/
@ -530,6 +557,7 @@ memory layout in which channels are stored in the image.
* to hand the control back to OpenGL.
* The generated event object is directly released, resulting in
* performance improvements.
*
* @param queue the command queue
*/
public void releaseImageForSharingNoEvent(CommandQueue queue) {
@ -557,5 +585,4 @@ memory layout in which channels are stored in the image.
str.append(')');
return str.toString();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2018 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -122,6 +122,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the global work size.
*
* @param ws the work size to set
*/
public void setGlobalWorkSize(WorkSize ws) {
@ -130,6 +131,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the global work size to a 1D grid
*
* @param size the size in 1D
*/
public void setGlobalWorkSize(int size) {
@ -138,6 +140,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the global work size to be a 2D grid
*
* @param width the width
* @param height the height
*/
@ -147,6 +150,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the global work size to be a 3D grid
*
* @param width the width
* @param height the height
* @param depth the depth
@ -164,6 +168,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the work group size
*
* @param ws the work group size to set
*/
public void setWorkGroupSize(WorkSize ws) {
@ -172,6 +177,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the work group size to be a 1D grid
*
* @param size the size to set
*/
public void setWorkGroupSize(int size) {
@ -180,6 +186,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the work group size to be a 2D grid
*
* @param width the width
* @param height the height
*/
@ -189,6 +196,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the work group size to be a 3D grid
*
* @param width the width
* @param height the height
* @param depth the depth
@ -211,6 +219,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Returns the maximal work group size when this kernel is executed on
* the specified device
*
* @param device the device
* @return the maximal work group size
*/
@ -266,6 +275,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* argument. The size in bytes must match exactly the argument size
* as defined in the kernel code.
* Use this method to send custom structures to the kernel
*
* @param index the index of the argument
* @param buffer the raw buffer
* @param size the size in bytes
@ -279,6 +289,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* long, float, double, Vector2f, Vector4f, Quaternion, Matrix3f, Matrix4f}.
* <br>
* Note: Matrix3f and Matrix4f will be mapped to a {@code float16} (row major).
*
* @param index the index of the argument, from 0 to {@link #getArgCount()}-1
* @param arg the argument
* @throws IllegalArgumentException if the argument type is not one of the listed ones
@ -331,6 +342,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* If the returned event object is not needed and would otherwise be
* released immediately, {@link #RunNoEvent(com.jme3.opencl.CommandQueue) }
* might bring a better performance.
*
* @param queue the command queue
* @return an event object indicating when the kernel is finished
* @see #setGlobalWorkSize(com.jme3.opencl.Kernel.WorkSize)
@ -345,6 +357,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* The generated event is directly released. Therefore, the performance
* is better, but there is no way to detect when the kernel execution
* has finished. For this purpose, use {@link #Run(com.jme3.opencl.CommandQueue) }.
*
* @param queue the command queue
* @see #setGlobalWorkSize(com.jme3.opencl.Kernel.WorkSize)
* @see #setWorkGroupSize(com.jme3.opencl.Kernel.WorkSize)
@ -361,6 +374,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* size is automatically determined by the driver.
* Each object in the argument array is sent to the kernel by
* {@link #setArg(int, java.lang.Object) }.
*
* @param queue the command queue
* @param globalWorkSize the global work size
* @param args the kernel arguments
@ -384,6 +398,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* is better, but there is no way to detect when the kernel execution
* has finished. For this purpose, use
* {@link #Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }.
*
* @param queue the command queue
* @param globalWorkSize the global work size
* @param args the kernel arguments
@ -398,6 +413,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Sets the work sizes and arguments in one call and launches the kernel.
*
* @param queue the command queue
* @param globalWorkSize the global work size
* @param workGroupSize the work group size
@ -418,6 +434,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
* is better, but there is no way to detect when the kernel execution
* has finished. For this purpose, use
* {@link #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }.
*
* @param queue the command queue
* @param globalWorkSize the global work size
* @param workGroupSize the work group size
@ -437,16 +454,16 @@ public abstract class Kernel extends AbstractOpenCLObject {
}
/**
* A placeholder for kernel arguments representing local kernel memory.
* This defines the size of available shared memory of a {@code __shared} kernel
* A placeholder for kernel arguments representing local kernel memory. This
* defines the size of available shared memory of a {@code __shared} kernel
* argument
*/
public static final class LocalMem {
private int size;
/**
* Creates a new LocalMem instance
*
* @param size the size of the available shared memory in bytes
*/
public LocalMem(int size) {
@ -498,11 +515,11 @@ public abstract class Kernel extends AbstractOpenCLObject {
* (e.g. by {@link #setWorkGroupSizeToNull()} or {@link #Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }.
*/
public static final class LocalMemPerElement {
private int size;
/**
* Creates a new LocalMemPerElement instance
*
* @param size the number of bytes available for each thread within
* a work group
*/
@ -546,6 +563,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* The work size (global and local) for executing a kernel
*
* @author shaman
*/
public static final class WorkSize {
@ -555,6 +573,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Creates a new work size object
*
* @param dimension the dimension (1,2,3)
* @param sizes the sizes in each dimension, the length must match the specified dimension
*/
@ -572,6 +591,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Creates a 1D work size of the specified extend
*
* @param size the size
*/
public WorkSize(long size) {
@ -580,6 +600,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Creates a 2D work size of the specified extend
*
* @param width the width
* @param height the height
*/
@ -589,6 +610,7 @@ public abstract class Kernel extends AbstractOpenCLObject {
/**
* Creates a 3D work size of the specified extend.
*
* @param width the width
* @param height the height
* @param depth the depth
@ -660,7 +682,5 @@ public abstract class Kernel extends AbstractOpenCLObject {
str.append(']');
return str.toString();
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,10 +36,10 @@ package com.jme3.opencl;
* when the compilation failed.
* The error log returned by {@link #getLog() } contains detailed information
* where the error occurred.
*
* @author shaman
*/
public class KernelCompilationException extends OpenCLException {
private final String log;
public KernelCompilationException(String msg, int errorCode, String log) {
@ -49,10 +49,10 @@ public class KernelCompilationException extends OpenCLException {
/**
* The output of the compiler
*
* @return the output text
*/
public String getLog() {
return log;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2016 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@ package com.jme3.opencl;
* The error code and its name is reported in the message string as well as the OpenCL call that
* causes this exception. Please refer to the official OpenCL specification
* to see what might cause this exception.
*
* @author shaman
*/
public class OpenCLException extends RuntimeException {
@ -73,6 +74,4 @@ public class OpenCLException extends RuntimeException {
public int getErrorCode() {
return errorCode;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -71,8 +71,10 @@ public abstract class Program extends AbstractOpenCLObject {
* @see #build()
*/
public abstract void build(String args, Device... devices) throws KernelCompilationException;
/**
* Builds this program without additional arguments
*
* @throws KernelCompilationException if the compilation fails
*/
public void build() throws KernelCompilationException {
@ -81,16 +83,18 @@ public abstract class Program extends AbstractOpenCLObject {
/**
* Creates the kernel with the specified name.
*
* @param name the name of the kernel as defined in the source code
* @return the kernel object
* @throws OpenCLException if the kernel was not found or some other
* error occurred
* @throws OpenCLException if the kernel was not found or some other error
* occurred
*/
public abstract Kernel createKernel(String name);
/**
* Creates all available kernels in this program.
* The names of the kernels can then by queried by {@link Kernel#getName() }.
*
* @return an array of all kernels
*/
public abstract Kernel[] createAllKernels();
@ -100,10 +104,10 @@ public abstract class Program extends AbstractOpenCLObject {
* device. This binary can then be used e.g. in the next application launch
* to create the program from the binaries and not from the sources.
* This saves time.
*
* @param device the device from which the binaries are taken
* @return the binaries
* @see Context#createProgramFromBinary(java.nio.ByteBuffer, com.jme3.opencl.Device)
*/
public abstract ByteBuffer getBinary(Device device);
}

Loading…
Cancel
Save