Commit c2c43066 authored by Marek Horský's avatar Marek Horský Committed by Radek Ošlejšek
Browse files

Poisson sub-sampling with GPU-based projector rotation, re-using octrees, and...

Poisson sub-sampling with GPU-based projector rotation, re-using octrees, and asynchronous upload of mesh facets.
parent 72e13694
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ public enum CLProgramDef {
            List.of(CLSourceDef.SPATIAL_DATA_UTILS,
                    CLSourceDef.BOUNDING_BOX_UTILS,
                    CLSourceDef.TRIANGLE_STACK_STRUCTURES,
                    CLSourceDef.OCTREE_CONSTRUCTION_UTILS,
                    CLSourceDef.OCTREE_BUILDER),
            List.of(CLProgram.CompilerOptions.ENABLE_MAD,
                    CLProgram.CompilerOptions.FAST_RELAXED_MATH,
@@ -51,6 +50,17 @@ public enum CLProgramDef {
            List.of(CLProgram.CompilerOptions.ENABLE_MAD,
                    CLProgram.CompilerOptions.FAST_RELAXED_MATH,
                    CLProgram.CompilerOptions.NO_SIGNED_ZEROS)
    ),

    /**
     * Kernels specific to GPU-based Poisson sub-sampling
     */
    POISSON_GPU_UTILS(
            List.of(CLSourceDef.SPATIAL_DATA_UTILS,
                    CLSourceDef.POISSON_GPU_UTILS),
            List.of(CLProgram.CompilerOptions.ENABLE_MAD,
                    CLProgram.CompilerOptions.FAST_RELAXED_MATH,
                    CLProgram.CompilerOptions.NO_SIGNED_ZEROS)
    );

    private final List<CLSourceDef> sources = new ArrayList<>();
+2 −2
Original line number Diff line number Diff line
@@ -13,11 +13,11 @@ public enum CLSourceDef {
    RAY_INTERSECTION("RayIntersection.c"),
    COMPUTE_INTERSECTIONS("ComputeIntersections.c"),
    OCTREE_TRAVERSAL("OctreeTraversal.c"),
    OCTREE_CONSTRUCTION_UTILS("OctreeConstruction.c"),
    OCTREE_BUILDER("OctreeBuilder.c"),
    COMMON_KERNEL_SERVICES("CommonKernelServices.c"),
    TRIANGLE_STACK_STRUCTURES("TriangleStackStructures.c"),
    OCTREE_TRAVERSAL_STRUCTURES("OctreeTraversalStructures.c");
    OCTREE_TRAVERSAL_STRUCTURES("OctreeTraversalStructures.c"),
    POISSON_GPU_UTILS("ProjectorUtils.c");
    private final String file;

    CLSourceDef(String file) {
+0 −39
Original line number Diff line number Diff line
package cz.fidentis.analyst.opencl;

import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLPlatform;

/**
 * Provides access to OpenCL Context
 *
 * @author Marek Horský
 */
public interface OpenCLProvider {

    /**
     * Checks if any present device supports OpenCL or returns false straight away, if initialization is impossible
     *
     * @return true, if OpenCL is available, false otherwise
     */
    static boolean isOpenCLAvailable() {
        try {
            return CLPlatform.listCLPlatforms().length != 0;
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * Creates OpenCL Context using most powerful available device
     * The decision of the device relies on inner calculations of JogAmp's implementation,
     * which can mistake number of processing units on cards RTX 4xxx as of version 2.5.0
     *
     * @return OpenCL context
     */

    static CLContext createContext() {
        return isOpenCLAvailable()
                ? CLContext.create() //CLPlatform.listCLPlatforms()[0] //Toggle index to manually change device
                : null;
    }
}
+34 −1
Original line number Diff line number Diff line
package cz.fidentis.analyst.opencl;

import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLPlatform;
import cz.fidentis.analyst.opencl.impl.SingletonGpuManagerCL;

/**
@@ -8,11 +9,43 @@ import cz.fidentis.analyst.opencl.impl.SingletonGpuManagerCL;
 *
 * @author Ondrej Simecek
 * @author Radek Oslejsek
 * @author Pavol Kycina
 * @author Marek Horský
 */
public interface OpenCLServices {

    /**
     * Checks if any present device supports OpenCL or returns false straight away, if initialization is impossible
     * Also enforces minimal supported work group size to 256 as this value needs to be present as constant in .c source files
     *
     * @return true, if OpenCL is available, false otherwise
     */
    static boolean isOpenCLAvailable() {
        try {
            if (CLPlatform.listCLPlatforms().length != 0) {
                CLContext clContext = CLContext.create();
                int maxSupportedWorkGroupSize = clContext.getMaxFlopsDevice().getMaxWorkGroupSize();
                clContext.release();
                return maxSupportedWorkGroupSize >= 256;
            }
        } catch (Exception ignored) {
        }
        return false;
    }

    /**
     * Creates OpenCL Context using most powerful available device
     * The decision of the device relies on inner calculations of JogAmp's implementation,
     * which can mistake number of processing units on cards RTX 4xxx as of version 2.5.0
     *
     * @return OpenCL context
     */

    static CLContext createContext() {
        return isOpenCLAvailable()
                ? CLContext.create() //Toggle index to manually change device
                : null;
    }

    /**
     * Compiles the OpenCL program, re-uses already compiled programs.
     *
+13 −1
Original line number Diff line number Diff line
@@ -2,12 +2,15 @@ package cz.fidentis.analyst.opencl.memory;

import com.jogamp.opencl.CLContext;
import cz.fidentis.analyst.data.mesh.MeshTriangle;
import cz.fidentis.analyst.opencl.memory.impl.IntegerBuffer;
import cz.fidentis.analyst.opencl.memory.impl.MeshTriangleBuffer;
import cz.fidentis.analyst.opencl.memory.impl.RayIntersectionBuffer;
import cz.fidentis.analyst.opencl.memory.impl.VoxelBuffer;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

/**
 * Factory for OpenCL buffers with additional functionality
@@ -15,6 +18,15 @@ import javax.vecmath.Vector3d;
 * @author Marek Horský
 */
public interface BufferFactory {
    /**
     * Creates resizable {@link IntegerBuffer}
     *
     * @return IntegerBuffer
     */
    static BufferGPU<IntBuffer> getIntBuffer(CLContext clContext) {
        return new IntegerBuffer(clContext);
    }

    /**
     * Creates resizable {@link VoxelBuffer}
     *
@@ -38,7 +50,7 @@ public interface BufferFactory {
     *
     * @return RayIntersectionBuffer
     */
    static BufferGPU getRayIntersectionBuffer(CLContext context) {
    static BufferGPU<FloatBuffer> getRayIntersectionBuffer(CLContext context) {
        return new RayIntersectionBuffer(context);
    }

Loading