public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            ComputeErrorCode error = ComputeErrorCode.Success;
            Handle = CLInterface.CL12.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out error);
            ComputeException.ThrowOnError(error);

            SetID(Handle.Value);

            this.context = context;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Creates a new <see cref="ComputeSampler"/>. </summary>
        ///
        /// <param name="context">          A <see cref="ComputeContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a
        ///                                 <see cref="ComputeImage"/> in a <see cref="ComputeKernel"/>. </param>
        /// <param name="addressing">       The <see cref="ComputeImageAddressing"/> mode of the
        ///                                 <see cref="ComputeSampler"/>. Specifies how out-of-range
        ///                                 image coordinates are handled while reading. </param>
        /// <param name="filtering">        The <see cref="ComputeImageFiltering"/> mode of the
        ///                                 <see cref="ComputeSampler"/>. Specifies the type of filter
        ///                                 that must be applied when reading data from an image. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            Handle = CL12.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out var error);
            ComputeException.ThrowOnError(error);

            SetID(Handle.Value);

            this.addressing       = addressing;
            this.context          = context;
            this.filtering        = filtering;
            this.normalizedCoords = normalizedCoords;

            RILogManager.Default?.SendTrace(string.Intern("Create ") + this + string.Intern(" in Thread(") + Thread.CurrentThread.ManagedThreadId + string.Intern(")."), string.Intern("Information"));
        }
        /// <summary>
        /// Creates a new <see cref="ComputeSampler"/>.
        /// </summary>
        /// <param name="context"> A <see cref="ComputeContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <see cref="ComputeImage"/> in a <see cref="ComputeKernel"/>. </param>
        /// <param name="addressing"> The <see cref="ComputeImageAddressing"/> mode of the <see cref="ComputeSampler"/>. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="ComputeImageFiltering"/> mode of the <see cref="ComputeSampler"/>. Specifies the type of filter that must be applied when reading data from an image. </param>
        public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            ComputeErrorCode error = ComputeErrorCode.Success;

            Handle = CLInterface.CL12.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out error);
            ComputeException.ThrowOnError(error);

            SetID(Handle.Value);

            this.addressing       = addressing;
            this.context          = context;
            this.filtering        = filtering;
            this.normalizedCoords = normalizedCoords;
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new <see cref="ComputeSampler"/>.
        /// </summary>
        /// <param name="context"> A <see cref="ComputeContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <see cref="ComputeImage"/> in a <see cref="ComputeKernel"/>. </param>
        /// <param name="addressing"> The <see cref="ComputeImageAddressing"/> mode of the <see cref="ComputeSampler"/>. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="ComputeImageFiltering"/> mode of the <see cref="ComputeSampler"/>. Specifies the type of filter that must be applied when reading data from an image. </param>
        public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            ComputeErrorCode error = ComputeErrorCode.Success;
            Handle = CL12.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out error);
            ComputeException.ThrowOnError(error);

            SetID(Handle.Value);

            this.addressing = addressing;
            this.context = context;
            this.filtering = filtering;
            this.normalizedCoords = normalizedCoords;

            Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new <see cref="ComputeSampler"/>.
        /// </summary>
        /// <param name="context"> A <see cref="ComputeContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <see cref="ComputeImage"/> in a <see cref="ComputeKernel"/>. </param>
        /// <param name="addressing"> The <see cref="ComputeImageAddressing"/> mode of the <see cref="ComputeSampler"/>. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="ComputeImageFiltering"/> mode of the <see cref="ComputeSampler"/>. Specifies the type of filter that must be applied when reading data from an image. </param>
        public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            ComputeErrorCode error = ComputeErrorCode.Success;

            Handle = CL12.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out error);
            ComputeException.ThrowOnError(error);

            SetID(Handle.Value);

            this.addressing       = addressing;
            this.context          = context;
            this.filtering        = filtering;
            this.normalizedCoords = normalizedCoords;

            Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
        /// <summary>
        /// Creates a new sampler.
        /// </summary>
        /// <param name="context"> A context. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a image in a kernel. </param>
        /// <param name="addressing"> The <see cref="ComputeImageAddressing"/> mode of the sampler. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="ComputeImageFiltering"/> mode of the sampler. Specifies the type of filter that must be applied when reading data from an image. </param>
        public IComputeSampler CreateSampler(IComputeContext context, bool normalizedCoords,
                                             ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            var sampler = new ComputeSampler120();

            sampler.Handle = OpenCL120.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out ComputeErrorCode error);
            ComputeException.ThrowOnError(error);

            sampler.SetID(sampler.Handle.Value);

            sampler.Addressing       = addressing;
            sampler.Filtering        = filtering;
            sampler.NormalizedCoords = normalizedCoords;

            logger.Info("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
            return(sampler);
        }
Beispiel #7
0
 /// <summary>
 /// Creates a new <c>ComputeSampler</c>.
 /// </summary>
 /// <param name="context"> A <c>ComputeContext</c>. </param>
 /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <c>ComputeImage</c> in a <c>ComputeKernel</c>. </param>
 /// <param name="addressing"> The <c>ComputeImageAddressing</c> mode of the <c>ComputeSampler</c>. Specifies how out-of-range image coordinates are handled while reading. </param>
 /// <param name="filtering"> The <c>ComputeImageFiltering</c> mode of the <c>ComputeSampler</c>. Specifies the type of filter that must be applied when reading data from an image. </param>
 public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
 {
     unsafe
     {
         ComputeErrorCode error = ComputeErrorCode.Success;
         Handle = CL10.CreateSampler(
             context.Handle,
             (normalizedCoords) ? ComputeBoolean.True : ComputeBoolean.False,
             addressing,
             filtering,
             &error);
         ComputeException.ThrowOnError(error);
         this.addressing = addressing;
         this.context = context;
         this.filtering = filtering;
         this.normalizedCoords = normalizedCoords;
     }
 }
Beispiel #8
0
        /// <summary>
        /// Creates a new <see cref="ComputeSampler"/>.
        /// </summary>
        /// <param name="context"> A <see cref="ComputeContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <see cref="ComputeImage"/> in a <see cref="ComputeKernel"/>. </param>
        /// <param name="addressing"> The <see cref="ComputeImageAddressing"/> mode of the <see cref="ComputeSampler"/>. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="ComputeImageFiltering"/> mode of the <see cref="ComputeSampler"/>. Specifies the type of filter that must be applied when reading data from an image. </param>
        public ComputeSampler(ComputeContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
        {
            unsafe
            {
                ComputeErrorCode error = ComputeErrorCode.Success;
                Handle = CL10.CreateSampler(
                    context.Handle,
                    (normalizedCoords) ? ComputeBoolean.True : ComputeBoolean.False,
                    addressing,
                    filtering,
                    &error);
                ComputeException.ThrowOnError(error);
                this.addressing = addressing;
                this.context = context;
                this.filtering = filtering;
                this.normalizedCoords = normalizedCoords;
            }

            Trace.WriteLine("Created " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").");
        }
Beispiel #9
0
 public extern static CLSamplerHandle CreateSampler(
     CLContextHandle context,
     [MarshalAs(UnmanagedType.Bool)] bool normalized_coords,
     ComputeImageAddressing addressing_mode,
     ComputeImageFiltering filter_mode,
     out ComputeErrorCode errcode_ret);
Beispiel #10
0
 public static extern CLSamplerHandle CreateSampler(
     CLContextHandle context,
     [MarshalAs(UnmanagedType.Bool)] bool normalized_coords,
     ComputeImageAddressing addressing_mode,
     ComputeImageFiltering filter_mode,
     out ComputeErrorCode errcode_ret);
Beispiel #11
0
        public static CLSamplerHandle CreateSamplerWrapper(CLContextHandle context, bool normalized_coords, ComputeImageAddressing addressing_mode, ComputeImageFiltering filter_mode)
        {
            var handle = CreateSampler(context, normalized_coords, addressing_mode, filter_mode, out ComputeErrorCode errcode_ret);

            ComputeException.ThrowOnError(errcode_ret);
            return(handle);
        }
Beispiel #12
0
 public static unsafe extern IntPtr CreateSampler(
     IntPtr context,
     ComputeBoolean normalized_coords,
     ComputeImageAddressing addressing_mode,
     ComputeImageFiltering filter_mode,
     ComputeErrorCode* errcode_ret);
Beispiel #13
0
 CLSamplerHandle ICL10.CreateSampler(CLContextHandle context, bool normalized_coords, ComputeImageAddressing addressing_mode,
                                     ComputeImageFiltering filter_mode, out ComputeErrorCode errcode_ret)
 {
     return CreateSampler(context, normalized_coords, addressing_mode, filter_mode, out errcode_ret);
 }
Beispiel #14
0
 new CLSamplerHandle CreateSampler(CLContextHandle context, [MarshalAs(UnmanagedType.Bool)] bool normalized_coords, ComputeImageAddressing addressing_mode, ComputeImageFiltering filter_mode, out ComputeErrorCode errcode_ret)
 {
     Trace.WriteLine("WARNING! GetExtensionFunctionAddress has been deprecated in OpenCL 1.2.");
     return CL12.StaticCreateSampler(context, normalized_coords, addressing_mode, filter_mode, out errcode_ret);
 }
Beispiel #15
0
 CLSamplerHandle ICL10.CreateSampler(CLContextHandle context, bool normalized_coords, ComputeImageAddressing addressing_mode,
                                     ComputeImageFiltering filter_mode, out ComputeErrorCode errcode_ret)
 {
     return(CreateSampler(context, normalized_coords, addressing_mode, filter_mode, out errcode_ret));
 }
Beispiel #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context">Cloo compute context</param>
 /// <param name="normalizedCoords">are coordinates normalized? (between 0 and 1)</param>
 /// <param name="addressing">image addressing mode</param>
 /// <param name="filtering">image filtering mode</param>
 public ClooSampler(ClooContext context, bool normalizedCoords, ComputeImageAddressing addressing, ComputeImageFiltering filtering)
     : base(context, normalizedCoords, addressing, filtering)
 {
     _context = context;
 }