void PhotonTracerCL::compileKernels() {
    removeKernel(photonTracerKernel_);
    removeKernel(recomputePhotonTracerKernel_);
    std::string defines = "";
    if (onlyMultipleScattering_) {
        defines = " -D NO_SINGLE_SCATTERING";
    }
    if (isProgressive()) {
        defines = " -D PROGRESSIVE_PHOTON_MAPPING";
    }
    photonTracerKernel_ = addKernel("photontracer.cl", "photonTracerKernel", "", defines);
    recomputePhotonTracerKernel_ = addKernel("photontracer.cl", "photonTracerKernel", "", defines + " -D PHOTON_RECOMPUTATION");
}
RunningImageMeanAndStandardDeviationCL::RunningImageMeanAndStandardDeviationCL(const uvec2& layerDimension, const size2_t& workgroupSize)
    : pingPongIndex_(0)
    , workGroupSize_(workgroupSize)
    , kernel_(nullptr) {
    standardDeviation_[0] = Layer(layerDimension, DataVec4Float32::get());
    standardDeviation_[1] = Layer(layerDimension, DataVec4Float32::get());
    mean_[0] = Layer(layerDimension, DataVec4Float32::get());
    mean_[1] = Layer(layerDimension, DataVec4Float32::get());
    kernel_ = addKernel("statistics/runningmeanandstandarddeviationkernel.cl", "runningMeanAndStandardDeviationKernel");
}
void VolumeMaxCLProcessor::buildKernel() {
    std::stringstream defines;
    std::string extensions = OpenCL::getPtr()->getDevice().getInfo<CL_DEVICE_EXTENSIONS>();
    if (extensions.find("cl_khr_3d_image_writes") != std::string::npos) {
        supportsVolumeWrite_ = true;
        defines << " -D SUPPORTS_VOLUME_WRITE ";
    } else {
        supportsVolumeWrite_ = false;
    }
    kernel_ = addKernel("volumemax.cl", "volumeMaxKernel", "", defines.str());
}
Пример #4
0
void VolumeRaycasterCL::compileKernel() {
    if (kernel_) {
        removeKernel(kernel_);
    }
    std::stringstream defines;
    if (light_.shadingMode != 0) defines << " -D SHADING_MODE=" << light_.shadingMode;
    // Will compile kernel and make sure that it it
    // recompiled whenever the file changes
    // If the kernel fails to compile it will be set to nullptr
    kernel_ = addKernel("volumeraycaster.cl", "raycaster", defines.str());
    setKernelArguments();
}
GrayscaleCLProcessor::GrayscaleCLProcessor()
    : Processor()
    , ProcessorKernelOwner(this)
    , input_("color image")
    , outport_("outport")
    , useGLSharing_("glsharing", "Use OpenGL sharing", true)
    , kernel_(nullptr) {
    addPort(input_, "ImagePortGroup1");
    addPort(outport_, "ImagePortGroup1");

    addProperty(useGLSharing_);

    kernel_ = addKernel("grayscale.cl", "grayscaleKernel");
    if (!InviwoApplication::getPtr()->getSettingsByType<OpenCLSettings>()->isSharingEnabled()) {
        useGLSharing_.setReadOnly(true);
        useGLSharing_.set(false);
    }
}
Пример #6
0
int main(void) {
   
   cl::vector<cl::Platform> platforms;
   cl::vector<cl::Device> devices;
   cl::vector<cl::Kernel> allKernels;
   std::string kernelName;

   try {
      // Place the GPU devices of the first platform into a context
      cl::Platform::get(&platforms);
      platforms[0].getDevices(CL_DEVICE_TYPE_GPU, &devices);
      cl::Context context(devices);
      
      // Create and build program
      std::ifstream programFile("kernels.cl");
      std::string programString(std::istreambuf_iterator<char>(programFile),
            (std::istreambuf_iterator<char>()));
      cl::Program::Sources source(1, std::make_pair(programString.c_str(),
            programString.length()+1));
      cl::Program program(context, source);
      program.build(devices);

      // Create individual kernels
      cl::Kernel addKernel(program, "add");
      cl::Kernel subKernel(program, "subtract");
      cl::Kernel multKernel(program, "multiply");

      // Create all kernels in program
      program.createKernels(&allKernels);
      for(unsigned int i=0; i<allKernels.size(); i++) {
         kernelName = allKernels[i].getInfo<CL_KERNEL_FUNCTION_NAME>();
         std::cout << "Kernel: " << kernelName << std::endl;
      }
   }
   catch(cl::Error e) {
      std::cout << e.what() << ": Error code " << e.err() << std::endl;   
   }

   return 0;
}
UniformSampleGenerator2DCL::UniformSampleGenerator2DCL(bool useGLSharing)
    : SampleGenerator2DCL(useGLSharing), KernelOwner()
    , kernel_(NULL)
{
    kernel_ = addKernel("uniformsamplegenerator2d.cl", "uniformSampleGenerator2DKernel");
}
Пример #8
0
MeshEntryExitPointsCL::MeshEntryExitPointsCL(const glm::size2_t& workGroupSize /*= size2_t(16)*/)
    : workGroupSize_(workGroupSize), kernel_(nullptr) {
    kernel_ = addKernel("entryexitpoints.cl", "entryExitPointsKernel");
}
MWC64XRandomNumberGenerator::MWC64XRandomNumberGenerator(bool useGLSharing /*= true*/) 
: KernelOwner(), useGLSharing_(useGLSharing) {
    kernel_ = addKernel("randomnumbergenerator.cl", "randomNumberGeneratorKernel");
}