internal static SamplerSafeHandle CreateSampler(ContextSafeHandle context, bool normalizedCoordinates, AddressingMode addressingMode, FilterMode filterMode) { if (context == null) { throw new ArgumentNullException(nameof(context)); } ErrorCode errorCode; SamplerSafeHandle handle = clCreateSampler(context, normalizedCoordinates, addressingMode, filterMode, out errorCode); ErrorHandler.ThrowOnFailure(errorCode); return(handle); }
internal Sampler(SamplerSafeHandle handle, Context context) { if (handle == null) { throw new ArgumentNullException("handle"); } if (context == null) { throw new ArgumentNullException("context"); } _handle = handle; _context = context; }
internal static T GetSamplerInfo <T>(SamplerSafeHandle sampler, SamplerParameterInfo <T> parameter) { if (sampler == null) { throw new ArgumentNullException(nameof(sampler)); } if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } int?fixedSize = parameter.ParameterInfo.FixedSize; #if DEBUG bool verifyFixedSize = true; #else bool verifyFixedSize = false; #endif UIntPtr requiredSize; if (fixedSize.HasValue && !verifyFixedSize) { requiredSize = (UIntPtr)fixedSize; } else { ErrorHandler.ThrowOnFailure(clGetSamplerInfo(sampler, parameter.ParameterInfo.Name, UIntPtr.Zero, IntPtr.Zero, out requiredSize)); } if (verifyFixedSize && fixedSize.HasValue) { if (requiredSize.ToUInt64() != (ulong)fixedSize.Value) { throw new ArgumentException("The parameter definition includes a fixed size that does not match the required size according to the runtime."); } } IntPtr memory = IntPtr.Zero; try { memory = Marshal.AllocHGlobal((int)requiredSize.ToUInt32()); UIntPtr actualSize; ErrorHandler.ThrowOnFailure(clGetSamplerInfo(sampler, parameter.ParameterInfo.Name, requiredSize, memory, out actualSize)); return(parameter.ParameterInfo.Deserialize(actualSize, memory)); } finally { Marshal.FreeHGlobal(memory); } }
/// <summary> /// Creates a sampler object. Samplers controls how elements of an <see cref="Image"/> object are read by /// <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/imageFunctions.html"><c>read_image{f|i|ui}</c></a> /// </summary> /// <param name="normalizedCoordinates"><c>true</c> to use normalized coordinates, otherwise <c>false</c>. /// For more information, see <see cref="Sampler.NormalizedCoordinates"/>.</param> /// <param name="addressingMode">Specifies the image addressing-mode, i.e. /// how out-of-range image coordinates are handled.</param> /// <param name="filterMode">Specifies the filtering mode to use.</param> /// <returns>A new sampler.</returns> public Sampler CreateSampler(bool normalizedCoordinates, AddressingMode addressingMode, FilterMode filterMode) { SamplerSafeHandle handle = UnsafeNativeMethods.CreateSampler(Handle, normalizedCoordinates, addressingMode, filterMode); return(new Sampler(handle, this)); }
private static extern ErrorCode clRetainSampler(SamplerSafeHandle sampler);
private static extern ErrorCode clGetSamplerInfo( SamplerSafeHandle sampler, int paramName, UIntPtr paramValueSize, IntPtr paramValue, out UIntPtr paramValueSizeRet);