openclnet hinzugefügt
This commit is contained in:
commit
18fd14e197
102
OpenCLNet.sln
Normal file
102
OpenCLNet.sln
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLNet", "OpenCLNet\OpenCLNet.csproj", "{758285C6-1ACA-458A-9906-EE6701D5AF87}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLTest", "examples\OpenCLTest\OpenCLTest.csproj", "{68E39C68-7A11-4AF8-9FEA-3147E720D96D}"
|
||||||
|
EndProject
|
||||||
|
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "OpenCLVBTest", "examples\OpenCLVBTest\OpenCLVBTest.vbproj", "{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{264E13EF-4308-4033-96C1-54C13C82D7C0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageCrossFade", "examples\ImageCrossFade\ImageCrossFade.csproj", "{F7D24581-6EA3-4D20-A722-1BACC34B94AA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLImageTest", "examples\OpenCLImageTest\OpenCLImageTest.csproj", "{64E8D6E8-B245-47E4-BA61-9BD000E187FA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|x64.Build.0 = Release|x64
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{758285C6-1ACA-458A-9906-EE6701D5AF87}.Release|x86.Build.0 = Release|x86
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|x64.Build.0 = Release|x64
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{68E39C68-7A11-4AF8-9FEA-3147E720D96D}.Release|x86.Build.0 = Release|x86
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|x64.Build.0 = Release|x64
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}.Release|x86.Build.0 = Release|x86
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|x64.Build.0 = Release|x64
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{264E13EF-4308-4033-96C1-54C13C82D7C0}.Release|x86.Build.0 = Release|x86
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{F7D24581-6EA3-4D20-A722-1BACC34B94AA}.Release|x86.Build.0 = Release|x86
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|x64.Build.0 = Release|x64
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{64E8D6E8-B245-47E4-BA61-9BD000E187FA}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
385
OpenCLNet/AlignedArray.cs
Normal file
385
OpenCLNet/AlignedArray.cs
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
|
||||||
|
unsafe public class AlignedArray<T> where T : struct
|
||||||
|
{
|
||||||
|
protected IntPtr UnmanagedMemory;
|
||||||
|
protected IntPtr AlignedMemory;
|
||||||
|
|
||||||
|
public long Length { get; protected set; }
|
||||||
|
public long ByteLength { get; protected set; }
|
||||||
|
protected long ByteAlignment;
|
||||||
|
protected long AlignedArraySize;
|
||||||
|
protected int TStride = Marshal.SizeOf( typeof( T ) );
|
||||||
|
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
public AlignedArray( long size, long byteAlignment )
|
||||||
|
{
|
||||||
|
long alignmentMask;
|
||||||
|
|
||||||
|
Length = size;
|
||||||
|
ByteLength = size*TStride;
|
||||||
|
AlignedArraySize = size*TStride;
|
||||||
|
ByteAlignment = byteAlignment;
|
||||||
|
UnmanagedMemory = Marshal.AllocHGlobal( new IntPtr( AlignedArraySize+byteAlignment-1 ) );
|
||||||
|
alignmentMask = ByteAlignment-1;
|
||||||
|
AlignedMemory = new IntPtr( (UnmanagedMemory.ToInt64()+byteAlignment-1)&~alignmentMask );
|
||||||
|
}
|
||||||
|
|
||||||
|
~AlignedArray()
|
||||||
|
{
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
Marshal.FreeHGlobal( UnmanagedMemory );
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region AlignedArrayByte
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aligned 1D array class for bytes
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class AlignedArrayByte : AlignedArray<byte>
|
||||||
|
{
|
||||||
|
byte* pAlignedArray;
|
||||||
|
|
||||||
|
public AlignedArrayByte( long size, long byteAlignment )
|
||||||
|
: base( size, byteAlignment )
|
||||||
|
{
|
||||||
|
pAlignedArray = (byte*)AlignedMemory.ToPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GetPtr( long index )
|
||||||
|
{
|
||||||
|
if( index>=Length || index<0 )
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return new IntPtr( pAlignedArray+index );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extract( long index, byte[] destinationArray, long destinationIndex, long length )
|
||||||
|
{
|
||||||
|
if( index+length>Length || index+length<0 )
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for( long i=0; i<length; i++ )
|
||||||
|
destinationArray[destinationIndex+i] = pAlignedArray[index+i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert( long index, byte[] sourceArray, long sourceIndex, long length )
|
||||||
|
{
|
||||||
|
if( index+length>Length || index+length<0 )
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for( long i=0; i<length; i++ )
|
||||||
|
pAlignedArray[index+i] = sourceArray[sourceIndex+i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte this[long index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if( index<0 || index>Length )
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return pAlignedArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if( index<0 || index>Length )
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
pAlignedArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr( AlignedArrayByte array )
|
||||||
|
{
|
||||||
|
return new IntPtr( array.pAlignedArray );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AlignedArrayInt
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aligned 1D array class for ints
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class AlignedArrayInt : AlignedArray<int>
|
||||||
|
{
|
||||||
|
int* pAlignedArray;
|
||||||
|
|
||||||
|
public AlignedArrayInt(long size, long byteAlignment)
|
||||||
|
: base(size, byteAlignment)
|
||||||
|
{
|
||||||
|
pAlignedArray = (int*)AlignedMemory.ToPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GetPtr(long index)
|
||||||
|
{
|
||||||
|
if (index >= Length || index < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return new IntPtr(pAlignedArray + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extract(long index, int[] destinationArray, long destinationIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
destinationArray[destinationIndex + i] = pAlignedArray[index + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(long index, int[] sourceArray, long sourceIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
pAlignedArray[index + i] = sourceArray[sourceIndex + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int this[long index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return pAlignedArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
pAlignedArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr(AlignedArrayInt array)
|
||||||
|
{
|
||||||
|
return new IntPtr(array.pAlignedArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AlignedArrayLong
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aligned 1D array class for longs
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class AlignedArrayLong : AlignedArray<long>
|
||||||
|
{
|
||||||
|
long* pAlignedArray;
|
||||||
|
|
||||||
|
public AlignedArrayLong(long size, long byteAlignment)
|
||||||
|
: base(size, byteAlignment)
|
||||||
|
{
|
||||||
|
pAlignedArray = (long*)AlignedMemory.ToPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GetPtr(long index)
|
||||||
|
{
|
||||||
|
if (index >= Length || index < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return new IntPtr(pAlignedArray + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extract(long index, long[] destinationArray, long destinationIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
destinationArray[destinationIndex + i] = pAlignedArray[index + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(long index, long[] sourceArray, long sourceIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
pAlignedArray[index + i] = sourceArray[sourceIndex + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public long this[long index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return pAlignedArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
pAlignedArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr(AlignedArrayLong array)
|
||||||
|
{
|
||||||
|
return new IntPtr(array.pAlignedArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AlignedArrayFloat
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aligned 1D array class for floats
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class AlignedArrayFloat : AlignedArray<float>
|
||||||
|
{
|
||||||
|
float* pAlignedArray;
|
||||||
|
|
||||||
|
public AlignedArrayFloat(long size, long byteAlignment)
|
||||||
|
: base(size, byteAlignment)
|
||||||
|
{
|
||||||
|
pAlignedArray = (float*)AlignedMemory.ToPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GetPtr(long index)
|
||||||
|
{
|
||||||
|
if (index >= Length || index < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return new IntPtr(pAlignedArray + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extract(long index, float[] destinationArray, long destinationIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
destinationArray[destinationIndex + i] = pAlignedArray[index + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(long index, float[] sourceArray, long sourceIndex, long length)
|
||||||
|
{
|
||||||
|
if (index + length > Length || index + length < 0)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
for (long i = 0; i < length; i++)
|
||||||
|
pAlignedArray[index + i] = sourceArray[sourceIndex + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float this[long index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
return pAlignedArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Length)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
|
||||||
|
pAlignedArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr(AlignedArrayFloat array)
|
||||||
|
{
|
||||||
|
return new IntPtr(array.pAlignedArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
1229
OpenCLNet/CommandQueue.cs
Normal file
1229
OpenCLNet/CommandQueue.cs
Normal file
File diff suppressed because it is too large
Load Diff
517
OpenCLNet/Context.cs
Normal file
517
OpenCLNet/Context.cs
Normal file
@ -0,0 +1,517 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
|
||||||
|
unsafe public class Context : IDisposable, InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
public IntPtr ContextID { get; protected set; }
|
||||||
|
public Platform Platform { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if there is at least one 64 bit device in the context.
|
||||||
|
/// This guarantees that variables such as intptr_t, size_t etc are 64 bit
|
||||||
|
/// </summary>
|
||||||
|
public bool Is64BitContext { get; protected set; }
|
||||||
|
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
#region Construction / Destruction
|
||||||
|
|
||||||
|
internal Context( Platform platform, IntPtr contextID )
|
||||||
|
{
|
||||||
|
Platform = platform;
|
||||||
|
ContextID = contextID;
|
||||||
|
Is64BitContext = ContainsA64BitDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Context( Platform platform, ContextProperties[] properties, Device[] devices )
|
||||||
|
{
|
||||||
|
IntPtr[] intPtrProperties;
|
||||||
|
IntPtr[] deviceIDs;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
Platform = platform;
|
||||||
|
deviceIDs = InteropTools.ConvertDevicesToDeviceIDs( devices );
|
||||||
|
|
||||||
|
intPtrProperties = new IntPtr[properties.Length];
|
||||||
|
for( int i=0; i<properties.Length; i++ )
|
||||||
|
intPtrProperties[i] = new IntPtr( (long)properties[i] );
|
||||||
|
|
||||||
|
ContextID = (IntPtr)OpenCL.CreateContext( intPtrProperties,
|
||||||
|
(uint)devices.Length,
|
||||||
|
deviceIDs,
|
||||||
|
null,
|
||||||
|
IntPtr.Zero,
|
||||||
|
out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateContext failed: "+result , result);
|
||||||
|
Is64BitContext = ContainsA64BitDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use C# destructor syntax for finalization code.
|
||||||
|
// This destructor will run only if the Dispose method
|
||||||
|
// does not get called.
|
||||||
|
// It gives your base class the opportunity to finalize.
|
||||||
|
// Do not provide destructors in types derived from this class.
|
||||||
|
~Context()
|
||||||
|
{
|
||||||
|
// Do not re-create Dispose clean-up code here.
|
||||||
|
// Calling Dispose(false) is optimal in terms of
|
||||||
|
// readability and maintainability.
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool ContainsA64BitDevice()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Devices.Length; i++)
|
||||||
|
if (Devices[i].AddressBits == 64)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
OpenCL.ReleaseContext( ContextID );
|
||||||
|
ContextID = IntPtr.Zero;
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public uint ReferenceCount { get { return InteropTools.ReadUInt( this, (uint)ContextInfo.REFERENCE_COUNT ); } }
|
||||||
|
|
||||||
|
public Device[] Devices
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
IntPtr contextDevicesSize;
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr[] contextDevices;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetContextInfo( ContextID, (uint)ContextInfo.DEVICES, IntPtr.Zero, null, out contextDevicesSize );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get context info for context "+ContextID+" "+result, result);
|
||||||
|
|
||||||
|
contextDevices = new IntPtr[contextDevicesSize.ToInt64()/sizeof( IntPtr )];
|
||||||
|
fixed( IntPtr* pContextDevices = contextDevices )
|
||||||
|
{
|
||||||
|
result = (ErrorCode)OpenCL.GetContextInfo( ContextID, (uint)ContextInfo.DEVICES, contextDevicesSize, (void*)pContextDevices, out contextDevicesSize );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get context info for context "+ContextID+" "+result, result);
|
||||||
|
}
|
||||||
|
return InteropTools.ConvertDeviceIDsToDevices( Platform, contextDevices );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContextProperties[] Properties
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Create Command Queue
|
||||||
|
|
||||||
|
public CommandQueue CreateCommandQueue(Device device)
|
||||||
|
{
|
||||||
|
return CreateCommandQueue(device, (CommandQueueProperties)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandQueue CreateCommandQueue( Device device, CommandQueueProperties properties )
|
||||||
|
{
|
||||||
|
IntPtr commandQueueID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
commandQueueID = (IntPtr)OpenCL.CreateCommandQueue( ContextID, device.DeviceID, (ulong)properties, out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateCommandQueue failed with error code "+result, result);
|
||||||
|
return new CommandQueue( this, device, commandQueueID );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Create Buffer
|
||||||
|
|
||||||
|
public Mem CreateBuffer( MemFlags flags, long size, IntPtr pHost )
|
||||||
|
{
|
||||||
|
return CreateBuffer( flags, size, pHost.ToPointer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mem CreateBuffer( MemFlags flags, long size, void* pHost )
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = (IntPtr)OpenCL.CreateBuffer( ContextID, (ulong)flags, new IntPtr(size), pHost, out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateBuffer failed with error code "+result, result);
|
||||||
|
return new Mem( this, memID );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GL Interop
|
||||||
|
|
||||||
|
public Mem CreateFromGLBuffer(MemFlags flags, IntPtr bufobj)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = OpenCL.CreateFromGLBuffer(ContextID, (ulong)flags, (uint)bufobj, out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateFromGLBuffer failed with error code " + result, result);
|
||||||
|
return new Mem(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mem CreateFromGLTexture2D(MemFlags flags, int target, int mipLevel, int texture)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = OpenCL.CreateFromGLTexture2D(ContextID, (ulong)flags, target, mipLevel, (uint)texture, out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateFromGLTexture2D failed with error code " + result, result);
|
||||||
|
return new Mem(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mem CreateFromGLTexture3D(MemFlags flags, int target, int mipLevel, int texture)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = OpenCL.CreateFromGLTexture3D(ContextID, (ulong)flags, target, mipLevel, (uint)texture, out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateFromGLTexture3D failed with error code " + result, result);
|
||||||
|
return new Mem(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mem CreateFromGLRenderbuffer(MemFlags flags, IntPtr renderbuffer)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = OpenCL.CreateFromGLRenderbuffer(ContextID, (ulong)flags, (uint)renderbuffer, out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateFromGLTexture3D failed with error code " + result, result);
|
||||||
|
return new Mem(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Create Program
|
||||||
|
|
||||||
|
public Program CreateProgramFromFile(string path)
|
||||||
|
{
|
||||||
|
return CreateProgramWithSource(File.ReadAllText(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Program CreateProgramWithSource( string source )
|
||||||
|
{
|
||||||
|
return CreateProgramWithSource( new string[] { source } );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Program CreateProgramWithSource( string[] source )
|
||||||
|
{
|
||||||
|
IntPtr programID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
programID = (IntPtr)OpenCL.CreateProgramWithSource( ContextID, (uint)source.Length, source, (IntPtr[])null, out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateProgramWithSource failed with error code "+result, result);
|
||||||
|
return new Program( this, programID );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Program CreateProgramWithBinary( Device[] devices, byte[][] binaries, int[] binaryStatus )
|
||||||
|
{
|
||||||
|
IntPtr programID;
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr[] lengths;
|
||||||
|
|
||||||
|
lengths = new IntPtr[devices.Length];
|
||||||
|
for (int i = 0; i < lengths.Length; i++)
|
||||||
|
lengths[i] = (IntPtr)binaries[i].Length;
|
||||||
|
programID = OpenCL.CreateProgramWithBinary(ContextID,
|
||||||
|
(uint)devices.Length,
|
||||||
|
InteropTools.ConvertDevicesToDeviceIDs(devices),
|
||||||
|
lengths,
|
||||||
|
binaries,
|
||||||
|
binaryStatus,
|
||||||
|
out result );
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateProgramWithBinary failed with error code " + result, result);
|
||||||
|
return new Program(this, programID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Create Sampler
|
||||||
|
|
||||||
|
public Sampler CreateSampler( bool normalizedCoords, AddressingMode addressingMode, FilterMode filterMode )
|
||||||
|
{
|
||||||
|
IntPtr samplerID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
samplerID = OpenCL.CreateSampler( ContextID, normalizedCoords, (uint)addressingMode, (uint)filterMode, out result );
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateSampler failed with error code " + result, result);
|
||||||
|
return new Sampler(this, samplerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Image2D
|
||||||
|
|
||||||
|
public Image CreateImage2D(MemFlags flags, ImageFormat imageFormat, int imageWidth, int imageHeight, int imageRowPitch)
|
||||||
|
{
|
||||||
|
return CreateImage2D(flags, imageFormat, (IntPtr)imageWidth, (IntPtr)imageHeight, (IntPtr)imageRowPitch, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image CreateImage2D(MemFlags flags, ImageFormat imageFormat, int imageWidth, int imageHeight, int imageRowPitch, IntPtr pHost)
|
||||||
|
{
|
||||||
|
return CreateImage2D(flags, imageFormat, (IntPtr)imageWidth, (IntPtr)imageHeight, (IntPtr)imageRowPitch, pHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image CreateImage2D(MemFlags flags, ImageFormat imageFormat, IntPtr imageWidth, IntPtr imageHeight, IntPtr imageRowPitch, IntPtr pHost)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = (IntPtr)OpenCL.CreateImage2D(ContextID, (ulong)flags, imageFormat, imageWidth, imageHeight, imageRowPitch, pHost.ToPointer(), out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateImage2D failed with error code " + result, result);
|
||||||
|
return new Image(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Image3D
|
||||||
|
|
||||||
|
public Image CreateImage3D(MemFlags flags, ImageFormat imageFormat, int imageWidth, int imageHeight, int imageDepth, int imageRowPitch, int imageSlicePitch)
|
||||||
|
{
|
||||||
|
return CreateImage3D(flags, imageFormat, (IntPtr)imageWidth, (IntPtr)imageHeight, (IntPtr)imageDepth, (IntPtr)imageRowPitch, (IntPtr)imageSlicePitch, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image CreateImage3D(MemFlags flags, ImageFormat imageFormat, int imageWidth, int imageHeight, int imageDepth, int imageRowPitch, int imageSlicePitch, IntPtr pHost)
|
||||||
|
{
|
||||||
|
return CreateImage3D(flags, imageFormat, (IntPtr)imageWidth, (IntPtr)imageHeight, (IntPtr)imageDepth, (IntPtr)imageRowPitch, (IntPtr)imageSlicePitch, pHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image CreateImage3D(MemFlags flags, ImageFormat imageFormat, IntPtr imageWidth, IntPtr imageHeight, IntPtr imageDepth, IntPtr imageRowPitch, IntPtr imageSlicePitch, IntPtr pHost)
|
||||||
|
{
|
||||||
|
IntPtr memID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
memID = (IntPtr)OpenCL.CreateImage3D(ContextID, (ulong)flags, imageFormat, imageWidth, imageHeight, imageDepth, imageRowPitch, imageSlicePitch, pHost.ToPointer(), out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateImage3D failed with error code " + result, result);
|
||||||
|
return new Image(this, memID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Image format queries
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Query which ImageFormats are supported by this context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="flags"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ImageFormat[] GetSupportedImageFormats(MemFlags flags, MemObjectType type)
|
||||||
|
{
|
||||||
|
uint numImageFormats;
|
||||||
|
ImageFormat[] imageFormats;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = OpenCL.GetSupportedImageFormats(ContextID, (ulong)flags, (uint)type, (uint)0, null, out numImageFormats);
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException("GetSupportedImageFormats failed with error code " + result, result);
|
||||||
|
|
||||||
|
imageFormats = new ImageFormat[numImageFormats];
|
||||||
|
|
||||||
|
result = OpenCL.GetSupportedImageFormats(ContextID, (ulong)flags, (uint)type, numImageFormats, imageFormats, out numImageFormats);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("GetSupportedImageFormats failed with error code " + result, result);
|
||||||
|
|
||||||
|
return imageFormats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convenience function. Checks if a context supports a specific image format
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="flags"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="channelOrder"></param>
|
||||||
|
/// <param name="channelType"></param>
|
||||||
|
/// <returns>true if the image format is supported, false otherwise</returns>
|
||||||
|
public bool SupportsImageFormat(MemFlags flags, MemObjectType type, ChannelOrder channelOrder, ChannelType channelType)
|
||||||
|
{
|
||||||
|
ImageFormat[] imageFormats = GetSupportedImageFormats(flags, type);
|
||||||
|
foreach (ImageFormat imageFormat in imageFormats)
|
||||||
|
{
|
||||||
|
if (imageFormat.ChannelOrder == channelOrder && imageFormat.ChannelType == channelType)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region WaitForEvents
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Block until the event fires
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_event"></param>
|
||||||
|
public void WaitForEvent(Event _event)
|
||||||
|
{
|
||||||
|
Event[] event_list = new Event[1];
|
||||||
|
|
||||||
|
event_list[0] = _event;
|
||||||
|
OpenCL.WaitForEvents(1, InteropTools.ConvertEventsToEventIDs(event_list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Block until all events in the array have fired
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="num_events"></param>
|
||||||
|
/// <param name="event_list"></param>
|
||||||
|
public void WaitForEvents(int num_events, Event[] event_list)
|
||||||
|
{
|
||||||
|
OpenCL.WaitForEvents((uint)num_events, InteropTools.ConvertEventsToEventIDs(event_list));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HasExtension
|
||||||
|
|
||||||
|
public bool HasExtension(string extension)
|
||||||
|
{
|
||||||
|
foreach (Device d in Devices)
|
||||||
|
if (!d.HasExtension(extension))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasExtensions(string[] extensions)
|
||||||
|
{
|
||||||
|
foreach (Device d in Devices)
|
||||||
|
if (!d.HasExtensions(extensions))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public static implicit operator IntPtr( Context c )
|
||||||
|
{
|
||||||
|
return c.ContextID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
unsafe public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetContextInfo( ContextID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetContextInfo failed: "+result, result);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetContextInfo( ContextID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetContextInfo failed: "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
398
OpenCLNet/Device.cs
Normal file
398
OpenCLNet/Device.cs
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
unsafe public class Device : InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
protected HashSet<string> ExtensionHashSet = new HashSet<string>();
|
||||||
|
|
||||||
|
internal Device(Platform platform, IntPtr deviceID)
|
||||||
|
{
|
||||||
|
Platform = platform;
|
||||||
|
DeviceID = deviceID;
|
||||||
|
|
||||||
|
InitializeExtensionHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// User-defined conversion from double to Digit
|
||||||
|
public static implicit operator IntPtr( Device d )
|
||||||
|
{
|
||||||
|
return d.DeviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public IntPtr DeviceID { get; protected set; }
|
||||||
|
|
||||||
|
public DeviceType DeviceType { get { return (DeviceType) InteropTools.ReadULong( this, (uint)DeviceInfo.TYPE ); } }
|
||||||
|
public uint VendorID { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.VENDOR_ID ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// The number of parallel compute cores on the OpenCL device. The minimum value is 1.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxComputeUnits { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_COMPUTE_UNITS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum dimensions that specify the global and local work-item IDs used by the data parallel execution model.
|
||||||
|
/// (Refer to clEnqueueNDRangeKernel). The minimum value is 3.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxWorkItemDimensions { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_WORK_ITEM_DIMENSIONS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum number of work-items that can be specified in each dimension of
|
||||||
|
/// the work-group to clEnqueueNDRangeKernel.
|
||||||
|
///
|
||||||
|
/// Returns n size_t entries, where n is the value returned by the query for
|
||||||
|
/// CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS.
|
||||||
|
///
|
||||||
|
/// The minimum value is (1, 1, 1).
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr[] MaxWorkItemSizes { get { return InteropTools.ReadIntPtrArray( this, (uint)DeviceInfo.MAX_WORK_ITEM_SIZES ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum number of work-items in a work-group executing a kernel using the data parallel execution model.
|
||||||
|
/// (Refer to clEnqueueNDRangeKernel).
|
||||||
|
///
|
||||||
|
/// The minimum value is 1.
|
||||||
|
/// </summary>
|
||||||
|
public long MaxWorkGroupSize { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.MAX_WORK_GROUP_SIZE ).ToInt64(); } }
|
||||||
|
public uint PreferredVectorWidthChar { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_CHAR ); } }
|
||||||
|
public uint PreferredVectorWidthShort { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_SHORT ); } }
|
||||||
|
public uint PreferredVectorWidthInt { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_INT ); } }
|
||||||
|
public uint PreferredVectorWidthLong { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_LONG ); } }
|
||||||
|
public uint PreferredVectorWidthFloat { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_FLOAT ); } }
|
||||||
|
public uint PreferredVectorWidthDouble { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.PREFERRED_VECTOR_WIDTH_DOUBLE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum configured clock frequency of the device in MHz.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxClockFrequency { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_CLOCK_FREQUENCY ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// The default compute device address space size specified as an unsigned
|
||||||
|
/// integer value in bits. Currently supported values are 32 or 64 bits.
|
||||||
|
/// </summary>
|
||||||
|
public uint AddressBits { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.ADDRESS_BITS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max size of memory object allocation in bytes. The minimum value is max
|
||||||
|
/// (1/4th of CL_DEVICE_GLOBAL_MEM_SIZE, 128*1024*1024)
|
||||||
|
/// </summary>
|
||||||
|
public ulong MaxMemAllocSize { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.MAX_MEM_ALLOC_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Is true if images are supported by the OpenCL device and CL_FALSE otherwise.
|
||||||
|
/// </summary>
|
||||||
|
public bool ImageSupport { get { return InteropTools.ReadBool( this, (uint)DeviceInfo.IMAGE_SUPPORT ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max number of simultaneous image objects that can be read by a kernel.
|
||||||
|
/// The minimum value is 128 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxReadImageArgs { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_READ_IMAGE_ARGS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max number of simultaneous image objects that can be written to by a
|
||||||
|
/// kernel. The minimum value is 8 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxWriteImageArgs { get { return InteropTools.ReadUInt(this, (uint)DeviceInfo.MAX_WRITE_IMAGE_ARGS); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max width of 2D image in pixels. The minimum value is 8192 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public long Image2DMaxWidth { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.IMAGE2D_MAX_WIDTH ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max height of 2D image in pixels. The minimum value is 8192 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public long Image2DMaxHeight { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.IMAGE2D_MAX_HEIGHT ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max width of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public long Image3DMaxWidth { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.IMAGE3D_MAX_WIDTH ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max height of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public long Image3DMaxHeight { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.IMAGE3D_MAX_HEIGHT ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max depth of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public long Image3DMaxDepth { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.IMAGE3D_MAX_DEPTH ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum number of samplers that can be used in a kernel. Refer to section 6.11.8 for a detailed
|
||||||
|
/// description on samplers. The minimum value is 16 if CL_DEVICE_IMAGE_SUPPORT is true.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxSamplers { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_SAMPLERS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max size in bytes of the arguments that can be passed to a kernel. The minimum value is 256.
|
||||||
|
/// </summary>
|
||||||
|
public long MaxParameterSize { get { return InteropTools.ReadIntPtr( this, (uint)DeviceInfo.MAX_PARAMETER_SIZE ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the alignment in bits of the base address of any allocated memory object.
|
||||||
|
/// </summary>
|
||||||
|
public uint MemBaseAddrAlign { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MEM_BASE_ADDR_ALIGN ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// The smallest alignment in bytes which can be used for any data type.
|
||||||
|
/// </summary>
|
||||||
|
public uint MinDataTypeAlignSize { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MIN_DATA_TYPE_ALIGN_SIZE ); } }
|
||||||
|
public ulong SingleFPConfig { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.SINGLE_FP_CONFIG ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Type of global memory cache supported. Valid values are: CL_NONE, CL_READ_ONLY_CACHE and CL_READ_WRITE_CACHE.
|
||||||
|
/// </summary>
|
||||||
|
public DeviceMemCacheType GlobalMemCacheType { get { return (DeviceMemCacheType)InteropTools.ReadUInt( this, (uint)DeviceInfo.GLOBAL_MEM_CACHE_TYPE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Size of global memory cache line in bytes.
|
||||||
|
/// </summary>
|
||||||
|
public uint GlobalMemCacheLineSize { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.GLOBAL_MEM_CACHELINE_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Size of global memory cache in bytes.
|
||||||
|
/// </summary>
|
||||||
|
public ulong GlobalMemCacheSize { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.GLOBAL_MEM_CACHE_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Size of global device memory in bytes.
|
||||||
|
/// </summary>
|
||||||
|
public ulong GlobalMemSize { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.GLOBAL_MEM_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max size in bytes of a constant buffer allocation. The minimum value is 64 KB.
|
||||||
|
/// </summary>
|
||||||
|
public ulong MaxConstantBufferSize { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.MAX_CONSTANT_BUFFER_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Max number of arguments declared with the __constant qualifier in a kernel. The minimum value is 8.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxConstantArgs { get { return InteropTools.ReadUInt( this, (uint)DeviceInfo.MAX_CONSTANT_ARGS ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Type of local memory supported. This can be set to CL_LOCAL implying dedicated local memory storage such as SRAM, or CL_GLOBAL.
|
||||||
|
/// </summary>
|
||||||
|
public DeviceLocalMemType LocalMemType { get { return (DeviceLocalMemType)InteropTools.ReadUInt( this, (uint)DeviceInfo.LOCAL_MEM_TYPE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Size of local memory arena in bytes. The minimum value is 16 KB.
|
||||||
|
/// </summary>
|
||||||
|
public ulong LocalMemSize { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.LOCAL_MEM_SIZE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Is CL_TRUE if the device implements error correction for the memories,
|
||||||
|
/// caches, registers etc. in the device. Is CL_FALSE if the device does not
|
||||||
|
/// implement error correction. This can be a requirement for certain clients of OpenCL.
|
||||||
|
/// </summary>
|
||||||
|
public bool ErrorCorrectionSupport { get { return InteropTools.ReadBool( this, (uint)DeviceInfo.ERROR_CORRECTION_SUPPORT ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the resolution of device timer. This is measured in nanoseconds. Refer to section 5.9 for details.
|
||||||
|
/// </summary>
|
||||||
|
public ulong ProfilingTimerResolution { get { return (ulong)InteropTools.ReadIntPtr( this, (uint)DeviceInfo.PROFILING_TIMER_RESOLUTION ).ToInt64(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Is CL_TRUE if the OpenCL device is a little endian device and CL_FALSE otherwise.
|
||||||
|
/// </summary>
|
||||||
|
public bool EndianLittle { get { return InteropTools.ReadBool( this, (uint)DeviceInfo.ENDIAN_LITTLE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Is CL_TRUE if the device is available and CL_FALSE if the device is not available.
|
||||||
|
/// </summary>
|
||||||
|
public bool Available { get { return InteropTools.ReadBool( this, (uint)DeviceInfo.AVAILABLE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Is CL_FALSE if the implementation does not have a compiler available to compile the program source.
|
||||||
|
/// Is CL_TRUE if the compiler is available.
|
||||||
|
/// This can be CL_FALSE for the embededed platform profile only.
|
||||||
|
/// </summary>
|
||||||
|
public bool CompilerAvailable { get { return InteropTools.ReadBool( this, (uint)DeviceInfo.COMPILER_AVAILABLE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the execution capabilities of the device. This is a bit-field that describes one or more of the following values:
|
||||||
|
/// CL_EXEC_KERNEL – The OpenCL device can execute OpenCL kernels.
|
||||||
|
/// CL_EXEC_NATIVE_KERNEL – The OpenCL device can execute native kernels.
|
||||||
|
/// The mandated minimum capability is: CL_EXEC_KERNEL.
|
||||||
|
/// </summary>
|
||||||
|
public ulong ExecutionCapabilities { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.EXECUTION_CAPABILITIES ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the command-queue properties supported by the device.
|
||||||
|
/// This is a bit-field that describes one or more of the following values:
|
||||||
|
/// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
|
||||||
|
/// CL_QUEUE_PROFILING_ENABLE
|
||||||
|
/// These properties are described in table 5.1.
|
||||||
|
///
|
||||||
|
/// The mandated minimum capability is:
|
||||||
|
/// CL_QUEUE_PROFILING_ENABLE.
|
||||||
|
/// </summary>
|
||||||
|
public ulong QueueProperties { get { return InteropTools.ReadULong( this, (uint)DeviceInfo.QUEUE_PROPERTIES ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// The platform associated with this device.
|
||||||
|
/// </summary>
|
||||||
|
public Platform Platform { get; protected set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Device name string.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get { return InteropTools.ReadString( this, (uint)DeviceInfo.NAME ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Vendor name string.
|
||||||
|
/// </summary>
|
||||||
|
public string Vendor { get { return InteropTools.ReadString( this, (uint)DeviceInfo.VENDOR ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// OpenCL software driver version string in the form major_number.minor_number.
|
||||||
|
/// </summary>
|
||||||
|
public string DriverVersion { get { return InteropTools.ReadString( this, (uint)DeviceInfo.DRIVER_VERSION ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// OpenCL profile string. Returns the profile name supported by the device.
|
||||||
|
/// The profile name returned can be one of the following strings:
|
||||||
|
/// FULL_PROFILE – if the device supports the OpenCL specification (functionality defined as part of the
|
||||||
|
/// core specification and does not require any extensions to be supported).
|
||||||
|
/// EMBEDDED_PROFILE - if the device supports the OpenCL embedded profile.
|
||||||
|
/// </summary>
|
||||||
|
public string Profile { get { return InteropTools.ReadString( this, (uint)DeviceInfo.PROFILE ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// OpenCL version string. Returns the OpenCL version supported by the device. This version string has the
|
||||||
|
/// following format:
|
||||||
|
/// OpenCL<space><major_version.minor_version><space><vendor-specificinformation>
|
||||||
|
/// The major_version.minor_version value returned will be 1.0.
|
||||||
|
/// </summary>
|
||||||
|
public string Version { get { return InteropTools.ReadString( this, (uint)DeviceInfo.VERSION ); } }
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a space separated list of extension names (the extension names themselves do not contain any spaces).
|
||||||
|
/// The list of extension names returned currently can include one or more of
|
||||||
|
/// the following approved extension names:
|
||||||
|
/// cl_khr_fp64
|
||||||
|
/// cl_khr_select_fprounding_mode
|
||||||
|
/// cl_khr_global_int32_base_atomics
|
||||||
|
/// cl_khr_global_int32_extended_atomics
|
||||||
|
/// cl_khr_local_int32_base_atomics
|
||||||
|
/// cl_khr_local_int32_extended_atomics
|
||||||
|
/// cl_khr_int64_base_atomics
|
||||||
|
/// cl_khr_int64_extended_atomics
|
||||||
|
/// cl_khr_3d_image_writes
|
||||||
|
/// cl_khr_byte_addressable_store
|
||||||
|
/// cl_khr_fp16
|
||||||
|
/// cl_khr_gl_sharing
|
||||||
|
/// Please refer to section 9 for a detailed
|
||||||
|
/// description of these extensions.
|
||||||
|
/// </summary>
|
||||||
|
public string Extensions { get { return InteropTools.ReadString( this, (uint)DeviceInfo.EXTENSIONS ); } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetDeviceInfo( DeviceID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get device info for device "+DeviceID, result);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetDeviceInfo( DeviceID, (uint)key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=(int)ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get device info for device "+DeviceID, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HasExtension
|
||||||
|
|
||||||
|
protected void InitializeExtensionHashSet()
|
||||||
|
{
|
||||||
|
string[] ext = Extensions.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
foreach (string s in ext)
|
||||||
|
ExtensionHashSet.Add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasExtension(string extension)
|
||||||
|
{
|
||||||
|
return ExtensionHashSet.Contains(extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasExtensions(string[] extensions)
|
||||||
|
{
|
||||||
|
foreach (string s in extensions)
|
||||||
|
if (!ExtensionHashSet.Contains(s))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ToString
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.AppendLine( "Name: "+Name );
|
||||||
|
sb.AppendLine( "Vendor: "+Vendor );
|
||||||
|
sb.AppendLine( "VendorID: "+VendorID );
|
||||||
|
sb.AppendLine( "DriverVersion: "+DriverVersion );
|
||||||
|
sb.AppendLine( "Profile: "+Profile );
|
||||||
|
sb.AppendLine( "Version: "+Version );
|
||||||
|
sb.AppendLine( "Extensions: "+Extensions );
|
||||||
|
sb.AppendLine( "DeviceType: "+DeviceType );
|
||||||
|
sb.AppendLine( "MaxComputeUnits: "+MaxComputeUnits );
|
||||||
|
sb.AppendLine( "MaxWorkItemDimensions: "+MaxWorkItemDimensions );
|
||||||
|
sb.Append( "MaxWorkItemSizes:" );
|
||||||
|
for( int i=0; i<MaxWorkItemSizes.Length; i++ )
|
||||||
|
sb.Append( " "+i+"="+(int)MaxWorkItemSizes[i] );
|
||||||
|
sb.AppendLine( "" );
|
||||||
|
sb.AppendLine( "MaxWorkGroupSize: "+MaxWorkGroupSize );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthChar: "+PreferredVectorWidthChar );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthShort: "+PreferredVectorWidthShort );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthInt: "+PreferredVectorWidthInt );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthLong: "+PreferredVectorWidthLong );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthFloat: "+PreferredVectorWidthFloat );
|
||||||
|
sb.AppendLine( "PreferredVectorWidthDouble: "+PreferredVectorWidthDouble );
|
||||||
|
sb.AppendLine( "MaxClockFrequency: "+MaxClockFrequency );
|
||||||
|
sb.AppendLine( "AddressBits: "+AddressBits );
|
||||||
|
sb.AppendLine( "MaxMemAllocSize: "+MaxMemAllocSize );
|
||||||
|
sb.AppendLine( "ImageSupport: "+ImageSupport );
|
||||||
|
sb.AppendLine( "MaxReadImageArgs: "+MaxReadImageArgs );
|
||||||
|
sb.AppendLine( "MaxWriteImageArgs: "+MaxWriteImageArgs );
|
||||||
|
sb.AppendLine( "Image2DMaxWidth: "+Image2DMaxWidth );
|
||||||
|
sb.AppendLine( "Image2DMaxHeight: "+Image2DMaxHeight );
|
||||||
|
sb.AppendLine( "Image3DMaxWidth: "+Image3DMaxWidth );
|
||||||
|
sb.AppendLine( "Image3DMaxHeight: "+Image3DMaxHeight );
|
||||||
|
sb.AppendLine( "Image3DMaxDepth: "+Image3DMaxDepth );
|
||||||
|
sb.AppendLine( "MaxSamplers: "+MaxSamplers );
|
||||||
|
sb.AppendLine( "MaxParameterSize: "+MaxParameterSize );
|
||||||
|
sb.AppendLine( "MemBaseAddrAlign: "+MemBaseAddrAlign );
|
||||||
|
sb.AppendLine( "MinDataTypeAlignSize: "+MinDataTypeAlignSize );
|
||||||
|
sb.AppendLine( "SingleFPConfig: "+SingleFPConfig );
|
||||||
|
sb.AppendLine( "GlobalMemCacheType: "+GlobalMemCacheType );
|
||||||
|
sb.AppendLine( "GlobalMemCacheLineSize: "+GlobalMemCacheLineSize );
|
||||||
|
sb.AppendLine( "GlobalMemCacheSize: "+GlobalMemCacheSize );
|
||||||
|
sb.AppendLine( "GlobalMemSize: "+GlobalMemSize );
|
||||||
|
sb.AppendLine( "MaxConstantBufferSize: "+MaxConstantBufferSize );
|
||||||
|
sb.AppendLine( "MaxConstantArgs: "+MaxConstantArgs );
|
||||||
|
sb.AppendLine( "LocalMemType: "+LocalMemType );
|
||||||
|
sb.AppendLine( "LocalMemSize: "+LocalMemSize );
|
||||||
|
sb.AppendLine( "ErrorCorrectionSupport: "+ErrorCorrectionSupport );
|
||||||
|
sb.AppendLine( "ProfilingTimerResolution: "+ProfilingTimerResolution );
|
||||||
|
sb.AppendLine( "EndianLittle: "+EndianLittle );
|
||||||
|
sb.AppendLine( "Available: "+Available );
|
||||||
|
sb.AppendLine( "CompilerAvailable: "+CompilerAvailable );
|
||||||
|
sb.AppendLine( "ExecutionCapabilities: "+ExecutionCapabilities );
|
||||||
|
sb.AppendLine( "QueueProperties: "+QueueProperties );
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
655
OpenCLNet/Enums.cs
Normal file
655
OpenCLNet/Enums.cs
Normal file
@ -0,0 +1,655 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
#region Using statements
|
||||||
|
|
||||||
|
using cl_char=SByte;
|
||||||
|
using cl_uchar=Byte;
|
||||||
|
using cl_short=Byte;
|
||||||
|
using cl_ushort=Byte;
|
||||||
|
using cl_int=Int32;
|
||||||
|
using cl_uint=UInt32;
|
||||||
|
using cl_long=Int64;
|
||||||
|
using cl_ulong=UInt64;
|
||||||
|
using cl_half=UInt16;
|
||||||
|
using cl_float=Single;
|
||||||
|
using cl_double=Double;
|
||||||
|
|
||||||
|
using cl_platform_id=IntPtr;
|
||||||
|
using cl_device_id=IntPtr;
|
||||||
|
using cl_context=IntPtr;
|
||||||
|
using cl_command_queue=IntPtr;
|
||||||
|
using cl_mem=IntPtr;
|
||||||
|
using cl_program=IntPtr;
|
||||||
|
using cl_kernel=IntPtr;
|
||||||
|
using cl_event=IntPtr;
|
||||||
|
using cl_sampler=IntPtr;
|
||||||
|
|
||||||
|
using cl_bool=UInt32;
|
||||||
|
using cl_bitfield=UInt64;
|
||||||
|
using cl_device_type=UInt64;
|
||||||
|
using cl_platform_info=UInt32;
|
||||||
|
using cl_device_info=UInt32;
|
||||||
|
using cl_device_address_info=UInt64;
|
||||||
|
using cl_device_fp_config=UInt64;
|
||||||
|
using cl_device_mem_cache_type=UInt32;
|
||||||
|
using cl_device_local_mem_type=UInt32;
|
||||||
|
using cl_device_exec_capabilities=UInt64;
|
||||||
|
using cl_command_queue_properties=UInt64;
|
||||||
|
|
||||||
|
using cl_context_properties=IntPtr;
|
||||||
|
using cl_context_info=UInt32;
|
||||||
|
using cl_command_queue_info=UInt32;
|
||||||
|
using cl_channel_order=UInt32;
|
||||||
|
using cl_channel_type=UInt32;
|
||||||
|
using cl_mem_flags=UInt64;
|
||||||
|
using cl_mem_object_type=UInt32;
|
||||||
|
using cl_mem_info=UInt32;
|
||||||
|
using cl_image_info=UInt32;
|
||||||
|
using cl_addressing_mode=UInt32;
|
||||||
|
using cl_filter_mode=UInt32;
|
||||||
|
using cl_sampler_info=UInt32;
|
||||||
|
using cl_map_flags=UInt64;
|
||||||
|
using cl_program_info=UInt32;
|
||||||
|
using cl_program_build_info=UInt32;
|
||||||
|
using cl_build_status=Int32;
|
||||||
|
using cl_kernel_info=UInt32;
|
||||||
|
using cl_kernel_work_group_info=UInt32;
|
||||||
|
using cl_event_info=UInt32;
|
||||||
|
using cl_command_type=UInt32;
|
||||||
|
using cl_profiling_info=UInt32;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential,Pack=1)]
|
||||||
|
public struct ImageFormat
|
||||||
|
{
|
||||||
|
internal cl_channel_order image_channel_order;
|
||||||
|
internal cl_channel_type image_channel_data_type;
|
||||||
|
|
||||||
|
public static readonly ImageFormat RGB8U = new ImageFormat(ChannelOrder.RGB, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RGB8S = new ImageFormat(ChannelOrder.RGB, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RGB16U = new ImageFormat(ChannelOrder.RGB, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RGB16S = new ImageFormat(ChannelOrder.RGB, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RGB32U = new ImageFormat(ChannelOrder.RGB, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RGB32S = new ImageFormat(ChannelOrder.RGB, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RGBFloat = new ImageFormat(ChannelOrder.RGB, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat RGBHalf = new ImageFormat(ChannelOrder.RGB, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat RG8U = new ImageFormat(ChannelOrder.RG, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RG8S = new ImageFormat(ChannelOrder.RG, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RG16U = new ImageFormat(ChannelOrder.RG, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RG16S = new ImageFormat(ChannelOrder.RG, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RG32U = new ImageFormat(ChannelOrder.RG, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RG32S = new ImageFormat(ChannelOrder.RG, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RGFloat = new ImageFormat(ChannelOrder.RG, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat RGHalf = new ImageFormat(ChannelOrder.RG, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat R8U = new ImageFormat(ChannelOrder.R, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat R8S = new ImageFormat(ChannelOrder.R, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat R16U = new ImageFormat(ChannelOrder.R, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat R16S = new ImageFormat(ChannelOrder.R, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat R32U = new ImageFormat(ChannelOrder.R, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat R32S = new ImageFormat(ChannelOrder.R, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RFloat = new ImageFormat(ChannelOrder.R, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat RHalf = new ImageFormat(ChannelOrder.R, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat RA8U = new ImageFormat(ChannelOrder.RA, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RA8S = new ImageFormat(ChannelOrder.RA, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RA16U = new ImageFormat(ChannelOrder.RA, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RA16S = new ImageFormat(ChannelOrder.RA, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RA32U = new ImageFormat(ChannelOrder.RA, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RA32S = new ImageFormat(ChannelOrder.RA, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RAFloat = new ImageFormat(ChannelOrder.RA, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat RAHalf = new ImageFormat(ChannelOrder.RA, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat RGBA8U = new ImageFormat(ChannelOrder.RGBA, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RGBA8S = new ImageFormat(ChannelOrder.RGBA, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat RGBA16U = new ImageFormat(ChannelOrder.RGBA, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RGBA16S = new ImageFormat(ChannelOrder.RGBA, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat RGBA32U = new ImageFormat(ChannelOrder.RGBA, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RGBA32S = new ImageFormat(ChannelOrder.RGBA, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat RGBAFloat = new ImageFormat(ChannelOrder.RGBA, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat RGBAHalf = new ImageFormat(ChannelOrder.RGBA, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat BGRA8U = new ImageFormat(ChannelOrder.BGRA, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat BGRA8S = new ImageFormat(ChannelOrder.BGRA, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat BGRA16U = new ImageFormat(ChannelOrder.BGRA, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat BGRA16S = new ImageFormat(ChannelOrder.BGRA, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat BGRA32U = new ImageFormat(ChannelOrder.BGRA, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat BGRA32S = new ImageFormat(ChannelOrder.BGRA, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat BGRAFloat = new ImageFormat(ChannelOrder.BGRA, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat BGRAHalf = new ImageFormat(ChannelOrder.BGRA, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat ARGB8U = new ImageFormat(ChannelOrder.ARGB, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat ARGB8S = new ImageFormat(ChannelOrder.ARGB, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat ARGB16U = new ImageFormat(ChannelOrder.ARGB, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat ARGB16S = new ImageFormat(ChannelOrder.ARGB, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat ARGB32U = new ImageFormat(ChannelOrder.ARGB, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat ARGB32S = new ImageFormat(ChannelOrder.ARGB, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat ARGBFloat = new ImageFormat(ChannelOrder.ARGB, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat ARGBHalf = new ImageFormat(ChannelOrder.ARGB, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat A8U = new ImageFormat(ChannelOrder.A, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat A8S = new ImageFormat(ChannelOrder.A, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat A16U = new ImageFormat(ChannelOrder.A, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat A16S = new ImageFormat(ChannelOrder.A, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat A32U = new ImageFormat(ChannelOrder.A, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat A32S = new ImageFormat(ChannelOrder.A, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat AFloat = new ImageFormat(ChannelOrder.A, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat AHalf = new ImageFormat(ChannelOrder.A, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat INTENSITY8U = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat INTENSITY8S = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat INTENSITY16U = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat INTENSITY16S = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat INTENSITY32U = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat INTENSITY32S = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat INTENSITYFloat = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat INTENSITYHalf = new ImageFormat(ChannelOrder.INTENSITY, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public static readonly ImageFormat LUMINANCE8U = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.UNSIGNED_INT8);
|
||||||
|
public static readonly ImageFormat LUMINANCE8S = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.SIGNED_INT8);
|
||||||
|
public static readonly ImageFormat LUMINANCE16U = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.UNSIGNED_INT16);
|
||||||
|
public static readonly ImageFormat LUMINANCE16S = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.SIGNED_INT16);
|
||||||
|
public static readonly ImageFormat LUMINANCE32U = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.UNSIGNED_INT32);
|
||||||
|
public static readonly ImageFormat LUMINANCE32S = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.SIGNED_INT32);
|
||||||
|
public static readonly ImageFormat LUMINANCEFloat = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.FLOAT);
|
||||||
|
public static readonly ImageFormat LUMINANCEHalf = new ImageFormat(ChannelOrder.LUMINANCE, ChannelType.HALF_FLOAT);
|
||||||
|
|
||||||
|
public ImageFormat(ChannelOrder channelOrder, ChannelType channelType)
|
||||||
|
{
|
||||||
|
image_channel_order = (cl_channel_order)channelOrder;
|
||||||
|
image_channel_data_type = (cl_channel_type)channelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelOrder ChannelOrder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ChannelOrder)image_channel_order;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
image_channel_order = (cl_channel_order)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ChannelType ChannelType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ChannelType)image_channel_data_type;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
image_channel_data_type = (cl_channel_type)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ErrorCode: int
|
||||||
|
{
|
||||||
|
SUCCESS = 0,
|
||||||
|
DEVICE_NOT_FOUND = -1,
|
||||||
|
DEVICE_NOT_AVAILABLE = -2,
|
||||||
|
COMPILER_NOT_AVAILABLE = -3,
|
||||||
|
MEM_OBJECT_ALLOCATION_FAILURE = -4,
|
||||||
|
OUT_OF_RESOURCES = -5,
|
||||||
|
OUT_OF_HOST_MEMORY = -6,
|
||||||
|
PROFILING_INFO_NOT_AVAILABLE = -7,
|
||||||
|
MEM_COPY_OVERLAP = -8,
|
||||||
|
IMAGE_FORMAT_MISMATCH = -9,
|
||||||
|
IMAGE_FORMAT_NOT_SUPPORTED = -10,
|
||||||
|
BUILD_PROGRAM_FAILURE = -11,
|
||||||
|
MAP_FAILURE = -12,
|
||||||
|
|
||||||
|
INVALID_VALUE = -30,
|
||||||
|
INVALID_DEVICE_TYPE = -31,
|
||||||
|
INVALID_PLATFORM = -32,
|
||||||
|
INVALID_DEVICE = -33,
|
||||||
|
INVALID_CONTEXT = -34,
|
||||||
|
INVALID_QUEUE_PROPERTIES = -35,
|
||||||
|
INVALID_COMMAND_QUEUE = -36,
|
||||||
|
INVALID_HOST_PTR = -37,
|
||||||
|
INVALID_MEM_OBJECT = -38,
|
||||||
|
INVALID_IMAGE_FORMAT_DESCRIPTOR = -39,
|
||||||
|
INVALID_IMAGE_SIZE = -40,
|
||||||
|
INVALID_SAMPLER = -41,
|
||||||
|
INVALID_BINARY = -42,
|
||||||
|
INVALID_BUILD_OPTIONS = -43,
|
||||||
|
INVALID_PROGRAM = -44,
|
||||||
|
INVALID_PROGRAM_EXECUTABLE = -45,
|
||||||
|
INVALID_KERNEL_NAME = -46,
|
||||||
|
INVALID_KERNEL_DEFINITION = -47,
|
||||||
|
INVALID_KERNEL = -48,
|
||||||
|
INVALID_ARG_INDEX = -49,
|
||||||
|
INVALID_ARG_VALUE = -50,
|
||||||
|
INVALID_ARG_SIZE = -51,
|
||||||
|
INVALID_KERNEL_ARGS = -52,
|
||||||
|
INVALID_WORK_DIMENSION = -53,
|
||||||
|
INVALID_WORK_GROUP_SIZE = -54,
|
||||||
|
INVALID_WORK_ITEM_SIZE = -55,
|
||||||
|
INVALID_GLOBAL_OFFSET = -56,
|
||||||
|
INVALID_EVENT_WAIT_LIST = -57,
|
||||||
|
INVALID_EVENT = -58,
|
||||||
|
INVALID_OPERATION = -59,
|
||||||
|
INVALID_GL_OBJECT = -60,
|
||||||
|
INVALID_BUFFER_SIZE = -61,
|
||||||
|
INVALID_MIP_LEVEL = -62,
|
||||||
|
|
||||||
|
// CL_GL Error Codes
|
||||||
|
INVALID_GL_SHAREGROUP_REFERENCE_KHR= -1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
public enum Bool
|
||||||
|
{
|
||||||
|
FALSE = 0,
|
||||||
|
TRUE = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
public enum PlatformInfo
|
||||||
|
{
|
||||||
|
PROFILE = 0x0900,
|
||||||
|
VERSION = 0x0901,
|
||||||
|
NAME = 0x0902,
|
||||||
|
VENDOR = 0x0903,
|
||||||
|
EXTENSIONS = 0x0904,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_type - bitfield
|
||||||
|
public enum DeviceType : ulong
|
||||||
|
{
|
||||||
|
DEFAULT = (1 << 0),
|
||||||
|
CPU = (1 << 1),
|
||||||
|
GPU = (1 << 2),
|
||||||
|
ACCELERATOR = (1 << 3),
|
||||||
|
ALL = 0xFFFFFFFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_info
|
||||||
|
public enum DeviceInfo
|
||||||
|
{
|
||||||
|
TYPE = 0x1000,
|
||||||
|
VENDOR_ID = 0x1001,
|
||||||
|
MAX_COMPUTE_UNITS = 0x1002,
|
||||||
|
MAX_WORK_ITEM_DIMENSIONS = 0x1003,
|
||||||
|
MAX_WORK_GROUP_SIZE = 0x1004,
|
||||||
|
MAX_WORK_ITEM_SIZES = 0x1005,
|
||||||
|
PREFERRED_VECTOR_WIDTH_CHAR = 0x1006,
|
||||||
|
PREFERRED_VECTOR_WIDTH_SHORT = 0x1007,
|
||||||
|
PREFERRED_VECTOR_WIDTH_INT = 0x1008,
|
||||||
|
PREFERRED_VECTOR_WIDTH_LONG = 0x1009,
|
||||||
|
PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A,
|
||||||
|
PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B,
|
||||||
|
MAX_CLOCK_FREQUENCY = 0x100C,
|
||||||
|
ADDRESS_BITS = 0x100D,
|
||||||
|
MAX_READ_IMAGE_ARGS = 0x100E,
|
||||||
|
MAX_WRITE_IMAGE_ARGS = 0x100F,
|
||||||
|
MAX_MEM_ALLOC_SIZE = 0x1010,
|
||||||
|
IMAGE2D_MAX_WIDTH = 0x1011,
|
||||||
|
IMAGE2D_MAX_HEIGHT = 0x1012,
|
||||||
|
IMAGE3D_MAX_WIDTH = 0x1013,
|
||||||
|
IMAGE3D_MAX_HEIGHT = 0x1014,
|
||||||
|
IMAGE3D_MAX_DEPTH = 0x1015,
|
||||||
|
IMAGE_SUPPORT = 0x1016,
|
||||||
|
MAX_PARAMETER_SIZE = 0x1017,
|
||||||
|
MAX_SAMPLERS = 0x1018,
|
||||||
|
MEM_BASE_ADDR_ALIGN = 0x1019,
|
||||||
|
MIN_DATA_TYPE_ALIGN_SIZE = 0x101A,
|
||||||
|
SINGLE_FP_CONFIG = 0x101B,
|
||||||
|
GLOBAL_MEM_CACHE_TYPE = 0x101C,
|
||||||
|
GLOBAL_MEM_CACHELINE_SIZE = 0x101D,
|
||||||
|
GLOBAL_MEM_CACHE_SIZE = 0x101E,
|
||||||
|
GLOBAL_MEM_SIZE = 0x101F,
|
||||||
|
MAX_CONSTANT_BUFFER_SIZE = 0x1020,
|
||||||
|
MAX_CONSTANT_ARGS = 0x1021,
|
||||||
|
LOCAL_MEM_TYPE = 0x1022,
|
||||||
|
LOCAL_MEM_SIZE = 0x1023,
|
||||||
|
ERROR_CORRECTION_SUPPORT = 0x1024,
|
||||||
|
PROFILING_TIMER_RESOLUTION = 0x1025,
|
||||||
|
ENDIAN_LITTLE = 0x1026,
|
||||||
|
AVAILABLE = 0x1027,
|
||||||
|
COMPILER_AVAILABLE = 0x1028,
|
||||||
|
EXECUTION_CAPABILITIES = 0x1029,
|
||||||
|
QUEUE_PROPERTIES = 0x102A,
|
||||||
|
NAME = 0x102B,
|
||||||
|
VENDOR = 0x102C,
|
||||||
|
DRIVER_VERSION = 0x102D,
|
||||||
|
PROFILE = 0x102E,
|
||||||
|
VERSION = 0x102F,
|
||||||
|
EXTENSIONS = 0x1030,
|
||||||
|
PLATFORM = 0x1031,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_fp_config - bitfield
|
||||||
|
public enum FpConfig : ulong
|
||||||
|
{
|
||||||
|
DENORM = (1 << 0),
|
||||||
|
INF_NAN = (1 << 1),
|
||||||
|
ROUND_TO_NEAREST = (1 << 2),
|
||||||
|
ROUND_TO_ZERO = (1 << 3),
|
||||||
|
ROUND_TO_INF = (1 << 4),
|
||||||
|
FMA = (1 << 5),
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_mem_cache_type
|
||||||
|
public enum DeviceMemCacheType
|
||||||
|
{
|
||||||
|
NONE = 0x0,
|
||||||
|
READ_ONLY_CACHE = 0x1,
|
||||||
|
READ_WRITE_CACHE = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_local_mem_type
|
||||||
|
public enum DeviceLocalMemType
|
||||||
|
{
|
||||||
|
LOCAL = 0x1,
|
||||||
|
GLOBAL = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_device_exec_capabilities - bitfield
|
||||||
|
public enum DeviceExecCapabilities : ulong
|
||||||
|
{
|
||||||
|
KERNEL = (1 << 0),
|
||||||
|
NATIVE_KERNEL = (1 << 1),
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_command_queue_properties - bitfield
|
||||||
|
public enum CommandQueueProperties : ulong
|
||||||
|
{
|
||||||
|
NONE = 0,
|
||||||
|
OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0),
|
||||||
|
PROFILING_ENABLE = (1 << 1),
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_context_info
|
||||||
|
public enum ContextInfo
|
||||||
|
{
|
||||||
|
REFERENCE_COUNT = 0x1080,
|
||||||
|
DEVICES = 0x1081,
|
||||||
|
PROPERTIES = 0x1082,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_gl_context_info
|
||||||
|
public enum GLContextInfo
|
||||||
|
{
|
||||||
|
CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006,
|
||||||
|
DEVICES_FOR_GL_CONTEXT_KHR = 0x2007,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_context_properties
|
||||||
|
public enum ContextProperties : ulong
|
||||||
|
{
|
||||||
|
PLATFORM = 0x1084,
|
||||||
|
|
||||||
|
// Additional cl_context_properties for GL support
|
||||||
|
GL_CONTEXT_KHR = 0x2008,
|
||||||
|
EGL_DISPLAY_KHR = 0x2009,
|
||||||
|
GLX_DISPLAY_KHR = 0x200A,
|
||||||
|
WGL_HDC_KHR = 0x200B,
|
||||||
|
CGL_SHAREGROUP_KHR = 0x200C,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_command_queue_info
|
||||||
|
public enum CommandQueueInfo
|
||||||
|
{
|
||||||
|
CONTEXT = 0x1090,
|
||||||
|
DEVICE = 0x1091,
|
||||||
|
REFERENCE_COUNT = 0x1092,
|
||||||
|
PROPERTIES = 0x1093,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_mem_flags - bitfield
|
||||||
|
public enum MemFlags : ulong
|
||||||
|
{
|
||||||
|
READ_WRITE = (1 << 0),
|
||||||
|
WRITE_ONLY = (1 << 1),
|
||||||
|
READ_ONLY = (1 << 2),
|
||||||
|
USE_HOST_PTR = (1 << 3),
|
||||||
|
ALLOC_HOST_PTR = (1 << 4),
|
||||||
|
COPY_HOST_PTR = (1 << 5),
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_channel_order
|
||||||
|
public enum ChannelOrder
|
||||||
|
{
|
||||||
|
R = 0x10B0,
|
||||||
|
A = 0x10B1,
|
||||||
|
RG = 0x10B2,
|
||||||
|
RA = 0x10B3,
|
||||||
|
RGB = 0x10B4,
|
||||||
|
RGBA = 0x10B5,
|
||||||
|
BGRA = 0x10B6,
|
||||||
|
ARGB = 0x10B7,
|
||||||
|
INTENSITY = 0x10B8,
|
||||||
|
LUMINANCE = 0x10B9,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_channel_type
|
||||||
|
public enum ChannelType
|
||||||
|
{
|
||||||
|
SNORM_INT8 = 0x10D0,
|
||||||
|
SNORM_INT16 = 0x10D1,
|
||||||
|
UNORM_INT8 = 0x10D2,
|
||||||
|
UNORM_INT16 = 0x10D3,
|
||||||
|
UNORM_SHORT_565 = 0x10D4,
|
||||||
|
UNORM_SHORT_555 = 0x10D5,
|
||||||
|
UNORM_INT_101010 = 0x10D6,
|
||||||
|
SIGNED_INT8 = 0x10D7,
|
||||||
|
SIGNED_INT16 = 0x10D8,
|
||||||
|
SIGNED_INT32 = 0x10D9,
|
||||||
|
UNSIGNED_INT8 = 0x10DA,
|
||||||
|
UNSIGNED_INT16 = 0x10DB,
|
||||||
|
UNSIGNED_INT32 = 0x10DC,
|
||||||
|
HALF_FLOAT = 0x10DD,
|
||||||
|
FLOAT = 0x10DE,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_mem_object_type
|
||||||
|
public enum MemObjectType
|
||||||
|
{
|
||||||
|
BUFFER = 0x10F0,
|
||||||
|
IMAGE2D = 0x10F1,
|
||||||
|
IMAGE3D = 0x10F2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_mem_info
|
||||||
|
public enum MemInfo
|
||||||
|
{
|
||||||
|
TYPE = 0x1100,
|
||||||
|
FLAGS = 0x1101,
|
||||||
|
SIZE = 0x1102,
|
||||||
|
HOST_PTR = 0x1103,
|
||||||
|
MAP_COUNT = 0x1104,
|
||||||
|
REFERENCE_COUNT = 0x1105,
|
||||||
|
CONTEXT = 0x1106,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_image_info
|
||||||
|
public enum ImageInfo
|
||||||
|
{
|
||||||
|
FORMAT = 0x1110,
|
||||||
|
ELEMENT_SIZE = 0x1111,
|
||||||
|
ROW_PITCH = 0x1112,
|
||||||
|
SLICE_PITCH = 0x1113,
|
||||||
|
WIDTH = 0x1114,
|
||||||
|
HEIGHT = 0x1115,
|
||||||
|
DEPTH = 0x1116,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_addressing_mode
|
||||||
|
public enum AddressingMode : uint
|
||||||
|
{
|
||||||
|
NONE = 0x1130,
|
||||||
|
CLAMP_TO_EDGE = 0x1131,
|
||||||
|
CLAMP = 0x1132,
|
||||||
|
REPEAT = 0x1133,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_filter_mode
|
||||||
|
public enum FilterMode : uint
|
||||||
|
{
|
||||||
|
NEAREST = 0x1140,
|
||||||
|
LINEAR = 0x1141,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_sampler_info
|
||||||
|
public enum SamplerInfo : uint
|
||||||
|
{
|
||||||
|
REFERENCE_COUNT = 0x1150,
|
||||||
|
CONTEXT = 0x1151,
|
||||||
|
NORMALIZED_COORDS = 0x1152,
|
||||||
|
ADDRESSING_MODE = 0x1153,
|
||||||
|
FILTER_MODE = 0x1154,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_map_flags - bitfield
|
||||||
|
public enum MapFlags : ulong
|
||||||
|
{
|
||||||
|
READ = (1 << 0),
|
||||||
|
WRITE = (1 << 1),
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_program_info
|
||||||
|
public enum ProgramInfo
|
||||||
|
{
|
||||||
|
REFERENCE_COUNT = 0x1160,
|
||||||
|
CONTEXT = 0x1161,
|
||||||
|
NUM_DEVICES = 0x1162,
|
||||||
|
DEVICES = 0x1163,
|
||||||
|
SOURCE = 0x1164,
|
||||||
|
BINARY_SIZES = 0x1165,
|
||||||
|
BINARIES = 0x1166,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_program_build_info
|
||||||
|
public enum ProgramBuildInfo
|
||||||
|
{
|
||||||
|
STATUS = 0x1181,
|
||||||
|
OPTIONS = 0x1182,
|
||||||
|
LOG = 0x1183,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_build_status
|
||||||
|
public enum BuildStatus
|
||||||
|
{
|
||||||
|
SUCCESS = 0,
|
||||||
|
NONE = -1,
|
||||||
|
ERROR = -2,
|
||||||
|
IN_PROGRESS = -3,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_kernel_info
|
||||||
|
public enum KernelInfo
|
||||||
|
{
|
||||||
|
FUNCTION_NAME = 0x1190,
|
||||||
|
NUM_ARGS = 0x1191,
|
||||||
|
REFERENCE_COUNT = 0x1192,
|
||||||
|
CONTEXT = 0x1193,
|
||||||
|
PROGRAM = 0x1194,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_kernel_work_group_info
|
||||||
|
public enum KernelWorkGroupInfo
|
||||||
|
{
|
||||||
|
WORK_GROUP_SIZE = 0x11B0,
|
||||||
|
COMPILE_WORK_GROUP_SIZE = 0x11B1,
|
||||||
|
LOCAL_MEM_SIZE = 0x11B2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_event_info
|
||||||
|
public enum EventInfo
|
||||||
|
{
|
||||||
|
COMMAND_QUEUE = 0x11D0,
|
||||||
|
COMMAND_TYPE = 0x11D1,
|
||||||
|
REFERENCE_COUNT = 0x11D2,
|
||||||
|
COMMAND_EXECUTION_STATUS = 0x11D3,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_command_type
|
||||||
|
public enum CommandType
|
||||||
|
{
|
||||||
|
NDRANGE_KERNEL = 0x11F0,
|
||||||
|
TASK = 0x11F1,
|
||||||
|
NATIVE_KERNEL = 0x11F2,
|
||||||
|
READ_BUFFER = 0x11F3,
|
||||||
|
WRITE_BUFFER = 0x11F4,
|
||||||
|
COPY_BUFFER = 0x11F5,
|
||||||
|
READ_IMAGE = 0x11F6,
|
||||||
|
WRITE_IMAGE = 0x11F7,
|
||||||
|
COPY_IMAGE = 0x11F8,
|
||||||
|
COPY_IMAGE_TO_BUFFER = 0x11F9,
|
||||||
|
COPY_BUFFER_TO_IMAGE = 0x11FA,
|
||||||
|
MAP_BUFFER = 0x11FB,
|
||||||
|
MAP_IMAGE = 0x11FC,
|
||||||
|
UNMAP_MEM_OBJECT = 0x11FD,
|
||||||
|
MARKER = 0x11FE,
|
||||||
|
ACQUIRE_GL_OBJECTS = 0x11FF,
|
||||||
|
RELEASE_GL_OBJECTS = 0x1200,
|
||||||
|
};
|
||||||
|
|
||||||
|
// command execution status
|
||||||
|
public enum ExecutionStatus
|
||||||
|
{
|
||||||
|
COMPLETE = 0x0,
|
||||||
|
RUNNING = 0x1,
|
||||||
|
SUBMITTED = 0x2,
|
||||||
|
QUEUED = 0x3,
|
||||||
|
};
|
||||||
|
|
||||||
|
// cl_profiling_info
|
||||||
|
public enum ProfilingInfo
|
||||||
|
{
|
||||||
|
QUEUED = 0x1280,
|
||||||
|
SUBMIT = 0x1281,
|
||||||
|
START = 0x1282,
|
||||||
|
END = 0x1283,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ********************************************
|
||||||
|
// * CLGL enums
|
||||||
|
// ********************************************
|
||||||
|
public enum CLGLObjectType
|
||||||
|
{
|
||||||
|
BUFFER = 0x2000,
|
||||||
|
TEXTURE2D = 0x2001,
|
||||||
|
TEXTURE3D = 0x2002,
|
||||||
|
RENDERBUFFER = 0x2003,
|
||||||
|
};
|
||||||
|
|
||||||
|
public enum CLGLTextureInfo
|
||||||
|
{
|
||||||
|
TEXTURE_TARGET = 0x2004,
|
||||||
|
MIPMAP_LEVEL = 0x2005,
|
||||||
|
};
|
||||||
|
}
|
155
OpenCLNet/Event.cs
Normal file
155
OpenCLNet/Event.cs
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public class Event : IDisposable, InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
public IntPtr EventID { get; protected set; }
|
||||||
|
public Context Context { get; protected set; }
|
||||||
|
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
#region Construction / Destruction
|
||||||
|
|
||||||
|
internal Event( Context context, IntPtr eventID )
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
EventID = eventID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use C# destructor syntax for finalization code.
|
||||||
|
// This destructor will run only if the Dispose method
|
||||||
|
// does not get called.
|
||||||
|
// It gives your base class the opportunity to finalize.
|
||||||
|
// Do not provide destructors in types derived from this class.
|
||||||
|
~Event()
|
||||||
|
{
|
||||||
|
// Do not re-create Dispose clean-up code here.
|
||||||
|
// Calling Dispose(false) is optimal in terms of
|
||||||
|
// readability and maintainability.
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
OpenCL.ReleaseEvent( EventID );
|
||||||
|
EventID = IntPtr.Zero;
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
unsafe public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetEventInfo( EventID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetEventInfo failed; "+result, result);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetEventInfo( EventID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetEventInfo failed; "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public unsafe void GetEventProfilingInfo(ProfilingInfo paramName, out ulong paramValue)
|
||||||
|
{
|
||||||
|
IntPtr paramValueSizeRet;
|
||||||
|
ulong v;
|
||||||
|
ErrorCode errorCode;
|
||||||
|
|
||||||
|
errorCode = OpenCL.GetEventProfilingInfo(EventID, paramName, (IntPtr)sizeof(ulong), &v, out paramValueSizeRet);
|
||||||
|
if (errorCode != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("GetEventProfilingInfo failed with error code "+errorCode, errorCode );
|
||||||
|
paramValue = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr( Event _event )
|
||||||
|
{
|
||||||
|
return _event.EventID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
OpenCLNet/Exceptions.cs
Normal file
82
OpenCLNet/Exceptions.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public class OpenCLException : Exception
|
||||||
|
{
|
||||||
|
public ErrorCode ErrorCode = ErrorCode.SUCCESS;
|
||||||
|
|
||||||
|
public OpenCLException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLException(ErrorCode errorCode)
|
||||||
|
{
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLException(string errorMessage)
|
||||||
|
: base(errorMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLException(string errorMessage, ErrorCode errorCode)
|
||||||
|
: base(errorMessage)
|
||||||
|
{
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLException(string message, Exception innerException)
|
||||||
|
: base(message, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLException(string message, ErrorCode errorCode, Exception innerException)
|
||||||
|
: base(message, innerException)
|
||||||
|
{
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OpenCLBuildException : OpenCLException
|
||||||
|
{
|
||||||
|
public List<string> BuildLogs = new List<string>();
|
||||||
|
|
||||||
|
public OpenCLBuildException( Program program, ErrorCode result )
|
||||||
|
: base( "Build failed with error code "+result, result )
|
||||||
|
{
|
||||||
|
foreach (Device d in program.Devices)
|
||||||
|
{
|
||||||
|
BuildLogs.Add( program.GetBuildLog(d) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
OpenCLNet/Image.cs
Normal file
93
OpenCLNet/Image.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public unsafe class Image : Mem
|
||||||
|
{
|
||||||
|
internal Image(Context context, IntPtr memID)
|
||||||
|
: base(context,memID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public ImageFormat ImageFormat
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
IntPtr size = GetPropertySize((uint)ImageInfo.FORMAT);
|
||||||
|
byte* pBuffer = stackalloc byte[(int)size];
|
||||||
|
|
||||||
|
ReadProperty((uint)ImageInfo.FORMAT, size, pBuffer);
|
||||||
|
return (ImageFormat)Marshal.PtrToStructure((IntPtr)pBuffer, typeof(ImageFormat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IntPtr ElementSize { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.ELEMENT_SIZE); } }
|
||||||
|
public IntPtr RowPitch { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.ROW_PITCH); } }
|
||||||
|
public IntPtr SlicePitch { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.SLICE_PITCH); } }
|
||||||
|
public IntPtr Width { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.WIDTH); } }
|
||||||
|
public IntPtr Height { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.HEIGHT); } }
|
||||||
|
public IntPtr Depth { get { return InteropTools.ReadIntPtr(this, (uint)ImageInfo.DEPTH); } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Override the IPropertyContainer interface of the Mem class.
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public override unsafe IntPtr GetPropertySize(uint key)
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetImageInfo(MemID, key, IntPtr.Zero, null, out size);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
{
|
||||||
|
size = base.GetPropertySize(key);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override unsafe void ReadProperty(uint key, IntPtr keyLength, void* pBuffer)
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetImageInfo(MemID, key, keyLength, pBuffer, out size);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
{
|
||||||
|
base.ReadProperty(key, keyLength, pBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
206
OpenCLNet/InteropTools.cs
Normal file
206
OpenCLNet/InteropTools.cs
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public class InteropTools
|
||||||
|
{
|
||||||
|
public unsafe interface IPropertyContainer
|
||||||
|
{
|
||||||
|
IntPtr GetPropertySize(uint key);
|
||||||
|
void ReadProperty(uint key, IntPtr keyLength, void* pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] CreateNullTerminatedString(string s)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
byte[] data;
|
||||||
|
|
||||||
|
len = Encoding.UTF8.GetByteCount(s);
|
||||||
|
data = new byte[len + 1];
|
||||||
|
Encoding.UTF8.GetBytes(s, 0, s.Length, data, 0);
|
||||||
|
data[len] = 0;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr[] ConvertDevicesToDeviceIDs(Device[] devices)
|
||||||
|
{
|
||||||
|
IntPtr[] deviceIDs;
|
||||||
|
|
||||||
|
if (devices == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
deviceIDs = new IntPtr[devices.Length];
|
||||||
|
for (int i = 0; i < devices.Length; i++)
|
||||||
|
deviceIDs[i] = devices[i];
|
||||||
|
return deviceIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Device[] ConvertDeviceIDsToDevices(Platform platform, IntPtr[] deviceIDs)
|
||||||
|
{
|
||||||
|
Device[] devices;
|
||||||
|
|
||||||
|
if (deviceIDs == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
devices = new Device[deviceIDs.Length];
|
||||||
|
for (int i = 0; i < deviceIDs.Length; i++)
|
||||||
|
devices[i] = platform.GetDevice(deviceIDs[i]);
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr[] ConvertMemToMemIDs(Mem[] mems)
|
||||||
|
{
|
||||||
|
IntPtr[] memIDs;
|
||||||
|
|
||||||
|
if (mems == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
memIDs = new IntPtr[mems.Length];
|
||||||
|
for (int i = 0; i < mems.Length; i++)
|
||||||
|
memIDs[i] = mems[i].MemID;
|
||||||
|
return memIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr[] ConvertEventsToEventIDs(Event[] events)
|
||||||
|
{
|
||||||
|
IntPtr[] eventIDs;
|
||||||
|
|
||||||
|
if (events == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
eventIDs = new IntPtr[events.Length];
|
||||||
|
for (int i = 0; i < events.Length; i++)
|
||||||
|
eventIDs[i] = events[i];
|
||||||
|
return eventIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Helper functions to read properties
|
||||||
|
|
||||||
|
unsafe public static bool ReadBool(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
return ReadUInt(propertyContainer, key) == (uint)Bool.TRUE ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static byte[] ReadBytes(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
size = propertyContainer.GetPropertySize(key);
|
||||||
|
byte[] data = new byte[size.ToInt64()];
|
||||||
|
fixed (byte* pData = data)
|
||||||
|
{
|
||||||
|
propertyContainer.ReadProperty(key, size, pData);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static string ReadString(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
string s;
|
||||||
|
|
||||||
|
size = propertyContainer.GetPropertySize((uint)key);
|
||||||
|
byte[] stringData = new byte[size.ToInt64()];
|
||||||
|
fixed (byte* pStringData = stringData)
|
||||||
|
{
|
||||||
|
propertyContainer.ReadProperty((uint)key, size, pStringData);
|
||||||
|
}
|
||||||
|
|
||||||
|
s = Encoding.UTF8.GetString(stringData);
|
||||||
|
int nullIndex = s.IndexOf('\0');
|
||||||
|
if (nullIndex >= 0)
|
||||||
|
return s.Substring(0, nullIndex);
|
||||||
|
else
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static int ReadInt(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
int output;
|
||||||
|
|
||||||
|
propertyContainer.ReadProperty(key, new IntPtr(sizeof(int)), &output);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static uint ReadUInt(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
uint output;
|
||||||
|
|
||||||
|
propertyContainer.ReadProperty(key, new IntPtr(sizeof(uint)), &output);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static long ReadLong(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
long output;
|
||||||
|
|
||||||
|
propertyContainer.ReadProperty(key, new IntPtr(sizeof(long)), &output);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static ulong ReadULong(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
ulong output;
|
||||||
|
|
||||||
|
propertyContainer.ReadProperty(key, new IntPtr(sizeof(ulong)), &output);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static IntPtr ReadIntPtr(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
IntPtr output;
|
||||||
|
|
||||||
|
propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr)), &output);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public static IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, uint key)
|
||||||
|
{
|
||||||
|
IntPtr size = propertyContainer.GetPropertySize(key);
|
||||||
|
long numElements = (long)size / sizeof(IntPtr);
|
||||||
|
IntPtr[] ptrs = new IntPtr[numElements];
|
||||||
|
byte[] data = InteropTools.ReadBytes(propertyContainer, key);
|
||||||
|
|
||||||
|
fixed (byte* pData = data)
|
||||||
|
{
|
||||||
|
void** pBS = (void**)pData;
|
||||||
|
for (int i = 0; i < numElements; i++)
|
||||||
|
ptrs[i] = new IntPtr(pBS[i]);
|
||||||
|
}
|
||||||
|
return ptrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
651
OpenCLNet/Kernel.cs
Normal file
651
OpenCLNet/Kernel.cs
Normal file
@ -0,0 +1,651 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The Kernel class wraps an OpenCL kernel handle
|
||||||
|
///
|
||||||
|
/// The main purposes of this class is to serve as a handle to
|
||||||
|
/// a compiled OpenCL function and to set arguments on the function
|
||||||
|
/// before enqueueing calls.
|
||||||
|
///
|
||||||
|
/// Arguments are set using either the overloaded SetArg functions or
|
||||||
|
/// explicit Set*Arg functions where * is a type. The most usual types
|
||||||
|
/// are supported, but no vectors. If you need to set a parameter that's
|
||||||
|
/// more advanced than what's supported here, use the version of SetArg
|
||||||
|
/// that takes a pointer and size.
|
||||||
|
///
|
||||||
|
/// Note that pointer arguments are set by passing their OpenCL memory object,
|
||||||
|
/// not native pointers.
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class Kernel : InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
public string FunctionName { get { return InteropTools.ReadString( this, (uint)KernelInfo.FUNCTION_NAME ); } }
|
||||||
|
public uint NumArgs { get { return InteropTools.ReadUInt( this, (uint)KernelInfo.NUM_ARGS ); } }
|
||||||
|
public uint ReferenceCount { get { return InteropTools.ReadUInt( this, (uint)KernelInfo.REFERENCE_COUNT ); } }
|
||||||
|
public Context Context { get; protected set; }
|
||||||
|
public Program Program { get; protected set; }
|
||||||
|
public IntPtr KernelID { get; set; }
|
||||||
|
|
||||||
|
internal Kernel( Context context, Program program, IntPtr kernelID )
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
Program = program;
|
||||||
|
KernelID = kernelID;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Kernel()
|
||||||
|
{
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
OpenCL.ReleaseKernel( KernelID );
|
||||||
|
KernelID = IntPtr.Zero;
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public void SetArg( int argIndex, IntPtr argSize, IntPtr argValue )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg( KernelID, (uint)argIndex, argSize, argValue.ToPointer() );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "SetArg failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region SetArg functions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, sbyte c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(sbyte)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, byte c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(byte)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, short c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(short)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, ushort c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(ushort)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, int c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(int)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, uint c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(uint)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, long c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(long)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, ulong c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(ulong)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg( int argIndex, float c )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(float)), &c);
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "SetArg failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg(int argIndex, double c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(double)), &c);
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "SetArg failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to c
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
public void SetArg( int argIndex, IntPtr c )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
if (Context.Is64BitContext)
|
||||||
|
{
|
||||||
|
long l = c.ToInt64();
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(8), &l);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = c.ToInt32();
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(4), &i);
|
||||||
|
}
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "SetArg failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to mem
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="mem"></param>
|
||||||
|
public void SetArg(int argIndex, Mem mem)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr p = mem.MemID;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(IntPtr)), &p);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set argument argIndex to sampler
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argIndex"></param>
|
||||||
|
/// <param name="sampler"></param>
|
||||||
|
public void SetArg(int argIndex, Sampler sampler)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr p = sampler.SamplerID;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(IntPtr)), &p);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Setargs with explicit function names(For VB mostly)
|
||||||
|
|
||||||
|
public void SetSByteArg(int argIndex, sbyte c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(sbyte)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetByteArg(int argIndex, byte c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(byte)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetShortArg(int argIndex, short c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(short)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUShortArg(int argIndex, ushort c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(ushort)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIntArg(int argIndex, int c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(int)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUIntArg(int argIndex, uint c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(uint)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLongArg(int argIndex, long c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(long)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetULongArg(int argIndex, ulong c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(ulong)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSingleArg(int argIndex, float c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(float)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDoubleArg(int argIndex, double c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(double)), &c);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIntPtrArg(int argIndex, IntPtr c)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
if (Context.Is64BitContext)
|
||||||
|
{
|
||||||
|
long l = c.ToInt64();
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(8), &l);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = c.ToInt32();
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(4), &i);
|
||||||
|
}
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMemArg(int argIndex, Mem mem)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr p = mem.MemID;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(IntPtr)), &p);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSamplerArg(int argIndex, Sampler sampler)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr p = sampler.SamplerID;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(IntPtr)), &p);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("SetArg failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#if false
|
||||||
|
// Have to add some endian checking before compiling these into the library
|
||||||
|
|
||||||
|
#region Set Char vectors
|
||||||
|
|
||||||
|
public void SetChar2Arg(int argIndex, sbyte s0, sbyte s1)
|
||||||
|
{
|
||||||
|
sbyte* pBuffer = stackalloc sbyte[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(sbyte) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChar4Arg(int argIndex, sbyte s0, sbyte s1, sbyte s2, sbyte s3)
|
||||||
|
{
|
||||||
|
sbyte* pBuffer = stackalloc sbyte[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(sbyte) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set UChar vectors
|
||||||
|
|
||||||
|
public void SetUChar2Arg(int argIndex, byte s0, byte s1)
|
||||||
|
{
|
||||||
|
byte* pBuffer = stackalloc byte[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(byte) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUChar4Arg(int argIndex, byte s0, byte s1, byte s2, byte s3)
|
||||||
|
{
|
||||||
|
byte* pBuffer = stackalloc byte[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(byte) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set Int vectors
|
||||||
|
|
||||||
|
public void SetInt2Arg(int argIndex, int s0, int s1)
|
||||||
|
{
|
||||||
|
int* pBuffer = stackalloc int[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(int) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetInt4Arg(int argIndex, int s0, int s1, int s2, int s3)
|
||||||
|
{
|
||||||
|
int* pBuffer = stackalloc int[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(int) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set UInt vectors
|
||||||
|
|
||||||
|
public void SetUInt2Arg(int argIndex, uint s0, uint s1)
|
||||||
|
{
|
||||||
|
uint* pBuffer = stackalloc uint[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(uint) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUInt4Arg(int argIndex, uint s0, uint s1, uint s2, uint s3)
|
||||||
|
{
|
||||||
|
uint* pBuffer = stackalloc uint[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(uint) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set Long vectors
|
||||||
|
|
||||||
|
public void SetLong2Arg(int argIndex, long s0, long s1)
|
||||||
|
{
|
||||||
|
long* pBuffer = stackalloc long[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(long) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLong4Arg(int argIndex, long s0, long s1, long s2, long s3)
|
||||||
|
{
|
||||||
|
long* pBuffer = stackalloc long[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(long) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set ULong vectors
|
||||||
|
|
||||||
|
public void SetULong2Arg(int argIndex, ulong s0, ulong s1)
|
||||||
|
{
|
||||||
|
ulong* pBuffer = stackalloc ulong[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(ulong) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetULong4Arg(int argIndex, ulong s0, ulong s1, ulong s2, ulong s3)
|
||||||
|
{
|
||||||
|
ulong* pBuffer = stackalloc ulong[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(ulong) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Set Float vectors
|
||||||
|
|
||||||
|
public void SetFloat2Arg(int argIndex, float s0, float s1)
|
||||||
|
{
|
||||||
|
float* pBuffer = stackalloc float[2];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(float) * 2), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFloat4Arg(int argIndex, float s0, float s1, float s2, float s3)
|
||||||
|
{
|
||||||
|
float* pBuffer = stackalloc float[4];
|
||||||
|
pBuffer[0] = s0;
|
||||||
|
pBuffer[1] = s1;
|
||||||
|
pBuffer[2] = s2;
|
||||||
|
pBuffer[3] = s3;
|
||||||
|
SetArg(argIndex, (IntPtr)(sizeof(float) * 4), (IntPtr)pBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public static implicit operator IntPtr( Kernel k )
|
||||||
|
{
|
||||||
|
return k.KernelID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetKernelInfo( KernelID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get kernel info for kernel "+KernelID, result);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetKernelInfo( KernelID, (uint)key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=(int)ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get kernel info for kernel "+KernelID, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
206
OpenCLNet/Mem.cs
Normal file
206
OpenCLNet/Mem.cs
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
unsafe public class Mem : IDisposable, InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
private TextureInfo TxInfo;
|
||||||
|
|
||||||
|
public IntPtr MemID { get; protected set; }
|
||||||
|
public Context Context { get; protected set; }
|
||||||
|
public MemObjectType MemType { get { return (MemObjectType)InteropTools.ReadUInt( this, (uint)MemInfo.TYPE ); } }
|
||||||
|
public MemFlags MemFlags { get { return (MemFlags)InteropTools.ReadULong( this, (uint)MemInfo.FLAGS ); } }
|
||||||
|
public IntPtr MemSize { get { return InteropTools.ReadIntPtr( this, (uint)MemInfo.SIZE ); } }
|
||||||
|
public IntPtr HostPtr { get { return InteropTools.ReadIntPtr( this, (uint)MemInfo.HOST_PTR ); } }
|
||||||
|
public uint MapCount { get { return InteropTools.ReadUInt( this, (uint)MemInfo.MAP_COUNT ); } }
|
||||||
|
public uint ReferenceCount { get { return InteropTools.ReadUInt( this, (uint)MemInfo.REFERENCE_COUNT ); } }
|
||||||
|
|
||||||
|
public uint TextureTarget { get { return InteropTools.ReadUInt(TxInfo, (uint)CLGLTextureInfo.TEXTURE_TARGET); } }
|
||||||
|
public int MipMapLevel { get { return InteropTools.ReadInt(TxInfo, (uint)CLGLTextureInfo.MIPMAP_LEVEL); } }
|
||||||
|
|
||||||
|
|
||||||
|
#region Construction / Destruction
|
||||||
|
|
||||||
|
internal Mem( Context context, IntPtr memID )
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
MemID = memID;
|
||||||
|
TxInfo = new TextureInfo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use C# destructor syntax for finalization code.
|
||||||
|
// This destructor will run only if the Dispose method
|
||||||
|
// does not get called.
|
||||||
|
// It gives your base class the opportunity to finalize.
|
||||||
|
// Do not provide destructors in types derived from this class.
|
||||||
|
~Mem()
|
||||||
|
{
|
||||||
|
// Do not re-create Dispose clean-up code here.
|
||||||
|
// Calling Dispose(false) is optimal in terms of
|
||||||
|
// readability and maintainability.
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
OpenCL.ReleaseMemObject( MemID );
|
||||||
|
MemID = IntPtr.Zero;
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public void GetGLObjectInfo(out CLGLObjectType glObjectType, out IntPtr glObjectName)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
uint type;
|
||||||
|
uint name;
|
||||||
|
|
||||||
|
result = OpenCL.GetGLObjectInfo(MemID, out type, out name);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("GetGLObjectInfo failed: " + result, result);
|
||||||
|
glObjectType = (CLGLObjectType)type;
|
||||||
|
glObjectName = (IntPtr)name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
unsafe public virtual IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetMemObjectInfo( MemID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetMemObjectInfo failed: "+result, result );
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe public virtual void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr size;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetMemObjectInfo( MemID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetMemObjectInfo failed: "+result, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
class TextureInfo : InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
Mem Mem;
|
||||||
|
|
||||||
|
public TextureInfo(Mem mem)
|
||||||
|
{
|
||||||
|
Mem = mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize(uint key)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetGLTextureInfo(Mem.MemID, key, IntPtr.Zero, null, out size);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("GetGLTextureInfo failed with error code " + result, result);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty(uint key, IntPtr keyLength, void* pBuffer)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetGLTextureInfo(Mem.MemID, key, keyLength, pBuffer, out size);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("GetGLTextureInfo failed with error code " + result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
617
OpenCLNet/OpenCL.cs
Normal file
617
OpenCLNet/OpenCL.cs
Normal file
@ -0,0 +1,617 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
#region Using statements
|
||||||
|
|
||||||
|
using cl_char = SByte;
|
||||||
|
using cl_uchar = Byte;
|
||||||
|
using cl_short = Byte;
|
||||||
|
using cl_ushort = Byte;
|
||||||
|
using cl_int = Int32;
|
||||||
|
using cl_uint = UInt32;
|
||||||
|
using cl_long = Int64;
|
||||||
|
using cl_ulong = UInt64;
|
||||||
|
using cl_half = UInt16;
|
||||||
|
using cl_float = Single;
|
||||||
|
using cl_double = Double;
|
||||||
|
|
||||||
|
using cl_platform_id = IntPtr;
|
||||||
|
using cl_device_id = IntPtr;
|
||||||
|
using cl_context = IntPtr;
|
||||||
|
using cl_command_queue = IntPtr;
|
||||||
|
using cl_mem = IntPtr;
|
||||||
|
using cl_program = IntPtr;
|
||||||
|
using cl_kernel = IntPtr;
|
||||||
|
using cl_event = IntPtr;
|
||||||
|
using cl_sampler = IntPtr;
|
||||||
|
|
||||||
|
using cl_bool = UInt32;
|
||||||
|
using cl_bitfield = UInt64;
|
||||||
|
using cl_device_type = UInt64;
|
||||||
|
using cl_platform_info = UInt32;
|
||||||
|
using cl_device_info = UInt32;
|
||||||
|
using cl_device_address_info = UInt64;
|
||||||
|
using cl_device_fp_config = UInt64;
|
||||||
|
using cl_device_mem_cache_type = UInt32;
|
||||||
|
using cl_device_local_mem_type = UInt32;
|
||||||
|
using cl_device_exec_capabilities = UInt64;
|
||||||
|
using cl_command_queue_properties = UInt64;
|
||||||
|
|
||||||
|
using cl_context_properties = IntPtr;
|
||||||
|
using cl_context_info = UInt32;
|
||||||
|
using cl_command_queue_info = UInt32;
|
||||||
|
using cl_channel_order = UInt32;
|
||||||
|
using cl_channel_type = UInt32;
|
||||||
|
using cl_mem_flags = UInt64;
|
||||||
|
using cl_mem_object_type = UInt32;
|
||||||
|
using cl_mem_info = UInt32;
|
||||||
|
using cl_image_info = UInt32;
|
||||||
|
using cl_addressing_mode = UInt32;
|
||||||
|
using cl_filter_mode = UInt32;
|
||||||
|
using cl_sampler_info = UInt32;
|
||||||
|
using cl_map_flags = UInt64;
|
||||||
|
using cl_program_info = UInt32;
|
||||||
|
using cl_program_build_info = UInt32;
|
||||||
|
using cl_build_status = Int32;
|
||||||
|
using cl_kernel_info = UInt32;
|
||||||
|
using cl_kernel_work_group_info = UInt32;
|
||||||
|
using cl_event_info = UInt32;
|
||||||
|
using cl_command_type = UInt32;
|
||||||
|
using cl_profiling_info = UInt32;
|
||||||
|
|
||||||
|
using cl_gl_object_type = UInt32;
|
||||||
|
using cl_gl_texture_info = UInt32;
|
||||||
|
using cl_gl_platform_info = UInt32;
|
||||||
|
using GLuint = UInt32;
|
||||||
|
using GLint = Int32;
|
||||||
|
using GLenum = Int32;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public delegate void ContextNotify(string errInfo, byte[] data, IntPtr cb, IntPtr userData);
|
||||||
|
public delegate void ProgramNotify(cl_program program, IntPtr userData);
|
||||||
|
public delegate void NativeKernel(IntPtr args);
|
||||||
|
|
||||||
|
public unsafe static class OpenCL
|
||||||
|
{
|
||||||
|
static Dictionary<IntPtr, Platform> _Platforms = new Dictionary<IntPtr, Platform>();
|
||||||
|
static IntPtr[] PlatformIDs;
|
||||||
|
static Platform[] Platforms;
|
||||||
|
|
||||||
|
static OpenCL()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
_Platforms.Clear();
|
||||||
|
PlatformIDs = new IntPtr[0];
|
||||||
|
Platforms = new Platform[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Initialize()
|
||||||
|
{
|
||||||
|
PlatformIDs = GetPlatformIDs();
|
||||||
|
if (PlatformIDs == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Platforms = new Platform[PlatformIDs.Length];
|
||||||
|
for (int i = 0; i < PlatformIDs.Length; i++)
|
||||||
|
{
|
||||||
|
Platform p;
|
||||||
|
|
||||||
|
p = new Platform(PlatformIDs[i]);
|
||||||
|
Platforms[i] = p;
|
||||||
|
_Platforms[PlatformIDs[i]] = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int NumberOfPlatforms
|
||||||
|
{
|
||||||
|
get { return _Platforms.Count; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Platform[] GetPlatforms()
|
||||||
|
{
|
||||||
|
return (Platform[])Platforms.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Platform GetPlatform(int index)
|
||||||
|
{
|
||||||
|
return _Platforms[PlatformIDs[index]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Platform GetPlatform(IntPtr platformID)
|
||||||
|
{
|
||||||
|
return _Platforms[platformID];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe static private IntPtr[] GetPlatformIDs()
|
||||||
|
{
|
||||||
|
IntPtr[] platformIDs;
|
||||||
|
ErrorCode result;
|
||||||
|
uint returnedPlatforms;
|
||||||
|
|
||||||
|
result = (ErrorCode)GetPlatformIDs(0, null, out returnedPlatforms);
|
||||||
|
if (result == ErrorCode.INVALID_VALUE)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
platformIDs = new IntPtr[returnedPlatforms];
|
||||||
|
result = (ErrorCode)GetPlatformIDs((uint)platformIDs.Length, platformIDs, out returnedPlatforms);
|
||||||
|
if (result == ErrorCode.INVALID_VALUE)
|
||||||
|
return null;
|
||||||
|
return platformIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region Platform API
|
||||||
|
|
||||||
|
public static ErrorCode GetPlatformIDs(uint num_entries, IntPtr[] platforms, out uint num_platforms)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetPlatformIDs(num_entries, platforms, out num_platforms);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetPlatformInfo(IntPtr platform, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetPlatformInfo(platform, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Device API
|
||||||
|
|
||||||
|
public static ErrorCode GetDeviceIDs(IntPtr platform, DeviceType device_type, uint num_entries, IntPtr[] devices, out uint num_devices)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetDeviceIDs(platform, device_type, num_entries, devices, out num_devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetDeviceInfo(IntPtr device, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetDeviceInfo(device, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Context API
|
||||||
|
|
||||||
|
public static IntPtr CreateContext(IntPtr[] properties, uint num_devices, IntPtr[] devices, ContextNotify pfn_notify, IntPtr user_data, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateContext(properties, num_devices, devices, pfn_notify, user_data, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr CreateContextFromType(IntPtr[] properties, DeviceType device_type, ContextNotify pfn_notify, IntPtr user_data, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateContextFromType(properties, device_type, pfn_notify, user_data, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainContext(IntPtr context)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clRetainContext(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseContext(IntPtr context)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clReleaseContext(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetContextInfo(IntPtr context, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetContextInfo(context, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Program Object API
|
||||||
|
|
||||||
|
public static IntPtr CreateProgramWithSource(IntPtr context, uint count, string[] strings, IntPtr[] lengths, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateProgramWithSource(context, count, strings, lengths, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte[][] binaries, int[] binary_status, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
IntPtr program;
|
||||||
|
|
||||||
|
program = OpenCLAPI.clCreateProgramWithBinary(context, num_devices, device_list, lengths, binaries, binary_status, out errcode_ret);
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainProgram(IntPtr program)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clRetainProgram(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseProgram(IntPtr program)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clReleaseProgram(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode BuildProgram(IntPtr program, uint num_devices, IntPtr[] device_list, string options, ProgramNotify pfn_notify, IntPtr user_data)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clBuildProgram(program, num_devices, device_list, options, pfn_notify, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode UnloadCompiler()
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clUnloadCompiler();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetProgramInfo(IntPtr program, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetProgramInfo(program, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetProgramBuildInfo(IntPtr program, IntPtr device, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetProgramBuildInfo(program, device, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Command Queue API
|
||||||
|
|
||||||
|
public static IntPtr CreateCommandQueue(IntPtr context, IntPtr device, ulong properties, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateCommandQueue(context, device, properties, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainCommandQueue(IntPtr command_queue)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clRetainCommandQueue(command_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseCommandQueue(IntPtr command_queue)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clReleaseCommandQueue(command_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetCommandQueueInfo(IntPtr command_queue, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetCommandQueueInfo(command_queue, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode SetCommandQueueProperty(IntPtr command_queue, ulong properties, bool enable, out ulong old_properties)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clSetCommandQueueProperty(command_queue, properties, enable, out old_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Memory Object API
|
||||||
|
|
||||||
|
public static IntPtr CreateBuffer(IntPtr context, ulong flags, IntPtr size, void* host_ptr, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateBuffer(context, flags, size, host_ptr, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr CreateImage2D(IntPtr context, ulong flags, ImageFormat image_format, IntPtr image_width, IntPtr image_height, IntPtr image_row_pitch, void* host_ptr, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateImage2D(context, flags, &image_format, image_width, image_height, image_row_pitch, host_ptr, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr CreateImage3D(IntPtr context, ulong flags, ImageFormat image_format, IntPtr image_width, IntPtr image_height, IntPtr image_depth, IntPtr image_row_pitch, IntPtr image_slice_pitch, void* host_ptr, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateImage3D(context, flags, &image_format, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainMemObject(IntPtr memobj)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clRetainMemObject(memobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseMemObject(IntPtr memobj)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clReleaseMemObject(memobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetSupportedImageFormats(IntPtr context, ulong flags, uint image_type, uint num_entries, ImageFormat[] image_formats, out uint num_image_formats)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetSupportedImageFormats(context, flags, image_type, num_entries, image_formats, out num_image_formats);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetMemObjectInfo(IntPtr memobj, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetMemObjectInfo(memobj, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetImageInfo(IntPtr image, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetImageInfo(image, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Kernel Object API
|
||||||
|
|
||||||
|
public static cl_kernel CreateKernel(IntPtr program, string kernel_name, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateKernel(program, kernel_name, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr[] kernels, out uint num_kernels_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateKernelsInProgram(program, num_kernels, kernels, out num_kernels_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainKernel(IntPtr kernel)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clRetainKernel(kernel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseKernel(IntPtr kernel)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clReleaseKernel(kernel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode SetKernelArg(IntPtr kernel, uint arg_index, IntPtr arg_size, void* arg_value)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clSetKernelArg(kernel, arg_index, arg_size, arg_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetKernelInfo(IntPtr kernel, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetKernelInfo(kernel, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetKernelWorkGroupInfo(IntPtr kernel, IntPtr device, uint param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetKernelWorkGroupInfo(kernel, device, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Enqueued Commands API
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueReadBuffer(IntPtr command_queue, IntPtr buffer, uint blocking_read, IntPtr offset, IntPtr cb, void* ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueReadBuffer(command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueWriteBuffer(IntPtr command_queue, IntPtr buffer, uint blocking_write, IntPtr offset, IntPtr cb, void* ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueCopyBuffer(IntPtr command_queue, IntPtr src_buffer, IntPtr dst_buffer, IntPtr src_offset, IntPtr dst_offset, IntPtr cb, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueReadImage(IntPtr command_queue, IntPtr image, uint blocking_read, IntPtr[] origin, IntPtr[] region, IntPtr row_pitch, IntPtr slice_pitch, void* ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueReadImage(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueWriteImage(IntPtr command_queue, IntPtr image, uint blocking_write, IntPtr[] origin, IntPtr[] region, IntPtr input_row_pitch, IntPtr input_slice_pitch, void* ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueWriteImage(command_queue, image, blocking_write, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueCopyImage(IntPtr command_queue, IntPtr src_image, IntPtr dst_image, IntPtr[] src_origin, IntPtr[] dst_origin, IntPtr[] region, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueCopyImage(command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueCopyImageToBuffer(IntPtr command_queue, IntPtr src_image, IntPtr dst_buffer, IntPtr[] src_origin, IntPtr[] region, IntPtr dst_offset, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueCopyImageToBuffer(command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueCopyBufferToImage(IntPtr command_queue, IntPtr src_buffer, IntPtr dst_image, IntPtr src_offset, IntPtr[] dst_origin, IntPtr[] region, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueCopyBufferToImage(command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void* EnqueueMapBuffer(IntPtr command_queue, IntPtr buffer, uint blocking_map, ulong map_flags, IntPtr offset, IntPtr cb, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueMapBuffer(command_queue, buffer, blocking_map, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, _event, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void* EnqueueMapImage(IntPtr command_queue, IntPtr image, uint blocking_map, ulong map_flags, IntPtr[] origin, IntPtr[] region, out IntPtr image_row_pitch, out IntPtr image_slice_pitch, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueMapImage(command_queue, image, blocking_map, map_flags, origin, region, out image_row_pitch, out image_slice_pitch, num_events_in_wait_list, event_wait_list, _event, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueUnmapMemObject(IntPtr command_queue, IntPtr memobj, void* mapped_ptr, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueUnmapMemObject(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueNDRangeKernel(IntPtr command_queue, IntPtr kernel, uint work_dim, IntPtr[] global_work_offset, IntPtr[] global_work_size, IntPtr[] local_work_size, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueNDRangeKernel(command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueTask(IntPtr command_queue, IntPtr kernel, uint num_events_in_wait_list, IntPtr[] event_wait_list, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueTask(command_queue, kernel, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueNativeKernel(cl_command_queue command_queue,
|
||||||
|
NativeKernel user_func,
|
||||||
|
void* args,
|
||||||
|
IntPtr cb_args,
|
||||||
|
cl_uint num_mem_objects,
|
||||||
|
cl_mem[] mem_list,
|
||||||
|
IntPtr[] args_mem_loc,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
cl_event[] event_wait_list,
|
||||||
|
cl_event* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueNativeKernel(command_queue,
|
||||||
|
user_func,
|
||||||
|
args,
|
||||||
|
cb_args,
|
||||||
|
num_mem_objects,
|
||||||
|
mem_list,
|
||||||
|
args_mem_loc,
|
||||||
|
num_events_in_wait_list,
|
||||||
|
event_wait_list,
|
||||||
|
_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueMarker(IntPtr command_queue, IntPtr* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueMarker(command_queue, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueWaitForEvents(IntPtr command_queue, uint num_events, IntPtr[] _event_list)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueWaitForEvents(command_queue, num_events, _event_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode EnqueueBarrier(IntPtr command_queue)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueBarrier(command_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Flush and Finish API
|
||||||
|
|
||||||
|
public static ErrorCode Flush(cl_command_queue command_queue)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clFlush(command_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode Finish(cl_command_queue command_queue)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clFinish(command_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event Object API
|
||||||
|
|
||||||
|
public static ErrorCode WaitForEvents(cl_uint num_events, cl_event[] _event_list)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clWaitForEvents(num_events, _event_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetEventInfo(cl_event _event, cl_event_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetEventInfo(_event, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainEvent(cl_event _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clRetainEvent(_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseEvent(cl_event _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clReleaseEvent(_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Sampler API
|
||||||
|
|
||||||
|
public static cl_sampler CreateSampler(cl_context context, bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateSampler(context, normalized_coords ? (cl_bool)Bool.TRUE : (cl_bool)Bool.FALSE, addressing_mode, filter_mode, out errcode_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode RetainSampler(cl_sampler sampler)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clRetainSampler(sampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode ReleaseSampler(cl_sampler sampler)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clReleaseSampler(sampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetSamplerInfo(sampler, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GLObject API
|
||||||
|
|
||||||
|
public static cl_mem CreateFromGLBuffer(cl_context context, cl_mem_flags flags, GLuint bufobj, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateFromGLBuffer(context, flags, bufobj, out errcode_ret);
|
||||||
|
}
|
||||||
|
public static cl_mem CreateFromGLTexture2D(cl_context context, cl_mem_flags flags, GLenum target, GLint mipLevel, GLuint texture, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateFromGLTexture2D(context, flags, target, mipLevel, texture, out errcode_ret);
|
||||||
|
}
|
||||||
|
public static cl_mem CreateFromGLTexture3D(cl_context context, cl_mem_flags flags, GLenum target, GLint mipLevel, GLuint texture, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateFromGLTexture3D(context, flags, target, mipLevel, texture, out errcode_ret);
|
||||||
|
}
|
||||||
|
public static cl_mem CreateFromGLRenderbuffer(cl_context context, cl_mem_flags flags, GLuint renderbuffer, out ErrorCode errcode_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clCreateFromGLRenderbuffer(context, flags, renderbuffer, out errcode_ret);
|
||||||
|
}
|
||||||
|
public static ErrorCode GetGLObjectInfo(cl_mem memobj, out cl_gl_object_type gl_object_type, out GLuint gl_object_name)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetGLObjectInfo(memobj, out gl_object_type, out gl_object_name);
|
||||||
|
}
|
||||||
|
public static ErrorCode GetGLTextureInfo(cl_mem memobj, cl_gl_texture_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetGLTextureInfo(memobj, param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
public static ErrorCode EnqueueAcquireGLObjects(cl_command_queue command_queue, cl_uint num_objects, cl_mem[] mem_objects, cl_uint num_events_in_wait_list, cl_event[] event_wait_list, cl_event* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueAcquireGLObjects(command_queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
public static ErrorCode EnqueueReleaseGLObjects(cl_command_queue command_queue, cl_uint num_objects, cl_mem[] mem_objects, cl_uint num_events_in_wait_list, cl_event[] event_wait_list, cl_event* _event)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clEnqueueAcquireGLObjects(command_queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, _event);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
// Extension function access
|
||||||
|
public static IntPtr GetExtensionFunctionAddress(string func_name)
|
||||||
|
{
|
||||||
|
return OpenCLAPI.clGetExtensionFunctionAddress(func_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode GetEventProfilingInfo(cl_event _event, ProfilingInfo param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret)
|
||||||
|
{
|
||||||
|
return (ErrorCode)OpenCLAPI.clGetEventProfilingInfo(_event, (uint)param_name, param_value_size, param_value, out param_value_size_ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
514
OpenCLNet/OpenCLAPI.cs
Normal file
514
OpenCLNet/OpenCLAPI.cs
Normal file
@ -0,0 +1,514 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
#region Using statements
|
||||||
|
|
||||||
|
using cl_char=SByte;
|
||||||
|
using cl_uchar=Byte;
|
||||||
|
using cl_short=Byte;
|
||||||
|
using cl_ushort=Byte;
|
||||||
|
using cl_int=Int32;
|
||||||
|
using cl_uint=UInt32;
|
||||||
|
using cl_long=Int64;
|
||||||
|
using cl_ulong=UInt64;
|
||||||
|
using cl_half=UInt16;
|
||||||
|
using cl_float=Single;
|
||||||
|
using cl_double=Double;
|
||||||
|
|
||||||
|
using cl_platform_id=IntPtr;
|
||||||
|
using cl_device_id=IntPtr;
|
||||||
|
using cl_context=IntPtr;
|
||||||
|
using cl_command_queue=IntPtr;
|
||||||
|
using cl_mem=IntPtr;
|
||||||
|
using cl_program=IntPtr;
|
||||||
|
using cl_kernel=IntPtr;
|
||||||
|
using cl_event=IntPtr;
|
||||||
|
using cl_sampler=IntPtr;
|
||||||
|
|
||||||
|
using cl_bool=UInt32;
|
||||||
|
using cl_bitfield=UInt64;
|
||||||
|
using cl_device_type=UInt64;
|
||||||
|
using cl_platform_info=UInt32;
|
||||||
|
using cl_device_info=UInt32;
|
||||||
|
using cl_device_address_info=UInt64;
|
||||||
|
using cl_device_fp_config=UInt64;
|
||||||
|
using cl_device_mem_cache_type=UInt32;
|
||||||
|
using cl_device_local_mem_type=UInt32;
|
||||||
|
using cl_device_exec_capabilities=UInt64;
|
||||||
|
using cl_command_queue_properties=UInt64;
|
||||||
|
|
||||||
|
using cl_context_properties=IntPtr;
|
||||||
|
using cl_context_info=UInt32;
|
||||||
|
using cl_command_queue_info=UInt32;
|
||||||
|
using cl_channel_order=UInt32;
|
||||||
|
using cl_channel_type=UInt32;
|
||||||
|
using cl_mem_flags=UInt64;
|
||||||
|
using cl_mem_object_type=UInt32;
|
||||||
|
using cl_mem_info=UInt32;
|
||||||
|
using cl_image_info=UInt32;
|
||||||
|
using cl_addressing_mode=UInt32;
|
||||||
|
using cl_filter_mode=UInt32;
|
||||||
|
using cl_sampler_info=UInt32;
|
||||||
|
using cl_map_flags=UInt64;
|
||||||
|
using cl_program_info=UInt32;
|
||||||
|
using cl_program_build_info=UInt32;
|
||||||
|
using cl_build_status=Int32;
|
||||||
|
using cl_kernel_info=UInt32;
|
||||||
|
using cl_kernel_work_group_info=UInt32;
|
||||||
|
using cl_event_info=UInt32;
|
||||||
|
using cl_command_type=UInt32;
|
||||||
|
using cl_profiling_info=UInt32;
|
||||||
|
|
||||||
|
using cl_gl_object_type=UInt32;
|
||||||
|
using cl_gl_texture_info=UInt32;
|
||||||
|
using cl_gl_platform_info=UInt32;
|
||||||
|
using cl_gl_context_info=UInt32;
|
||||||
|
using GLuint=UInt32;
|
||||||
|
using GLint=Int32;
|
||||||
|
using GLenum=Int32;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// OpenCLAPI - native bindings
|
||||||
|
/// </summary>
|
||||||
|
[SuppressUnmanagedCodeSecurity()]
|
||||||
|
unsafe public static class OpenCLAPI
|
||||||
|
{
|
||||||
|
internal static class Configuration
|
||||||
|
{
|
||||||
|
public const string Library = "opencl.dll";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Platform API
|
||||||
|
|
||||||
|
// Platform API
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetPlatformIDs(cl_uint num_entries, [Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] cl_platform_id[] platforms, out cl_uint num_platforms);
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Device API
|
||||||
|
|
||||||
|
// Device APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetDeviceIDs(cl_platform_id platform, [MarshalAs(UnmanagedType.U8)]DeviceType device_type, cl_uint num_entries, [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)]cl_device_id[] devices, out cl_uint num_devices);
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetDeviceInfo(cl_device_id device, cl_device_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Context API
|
||||||
|
|
||||||
|
// Context APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_context clCreateContext([In] cl_context_properties[] properties, cl_uint num_devices, [In]cl_device_id[] devices, ContextNotify pfn_notify, IntPtr user_data, [MarshalAs(UnmanagedType.I4)] out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_context clCreateContextFromType([In] cl_context_properties[] properties, [MarshalAs(UnmanagedType.U8)]DeviceType device_type, ContextNotify pfn_notify, IntPtr user_data, [MarshalAs(UnmanagedType.I4)] out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clRetainContext(cl_context context);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clReleaseContext(cl_context context);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetContextInfo(cl_context context, cl_context_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Program Object API
|
||||||
|
|
||||||
|
// Program Object APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_program clCreateProgramWithSource(cl_context context,
|
||||||
|
cl_uint count,
|
||||||
|
[In] string[] strings,
|
||||||
|
[In] IntPtr[] lengths,
|
||||||
|
[MarshalAs(UnmanagedType.I4)] out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_program clCreateProgramWithBinary(cl_context context,
|
||||||
|
cl_uint num_devices,
|
||||||
|
[In] cl_device_id[] device_list,
|
||||||
|
[In] IntPtr[] lengths,
|
||||||
|
[In] byte[][] binaries,
|
||||||
|
[Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] cl_int[] binary_status,
|
||||||
|
[MarshalAs(UnmanagedType.I4)] out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clRetainProgram(cl_program program);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clReleaseProgram(cl_program program);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clBuildProgram(cl_program program,
|
||||||
|
cl_uint num_devices,
|
||||||
|
[In] cl_device_id[] device_list,
|
||||||
|
string options,
|
||||||
|
ProgramNotify pfn_notify,
|
||||||
|
IntPtr user_data);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clUnloadCompiler();
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetProgramInfo(cl_program program, cl_program_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Command Queue API
|
||||||
|
|
||||||
|
// Command Queue APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static IntPtr clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, [MarshalAs(UnmanagedType.I4)] out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clRetainCommandQueue(cl_command_queue command_queue);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clReleaseCommandQueue(cl_command_queue command_queue);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clSetCommandQueueProperty(cl_command_queue command_queue, cl_command_queue_properties properties, [MarshalAs(UnmanagedType.I4)]bool enable, out cl_command_queue_properties old_properties);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Memory Object API
|
||||||
|
|
||||||
|
// Memory Object APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateBuffer(cl_context context, cl_mem_flags flags, IntPtr size, void* host_ptr, out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateImage2D(cl_context context, cl_mem_flags flags, ImageFormat* image_format, IntPtr image_width, IntPtr image_height, IntPtr image_row_pitch, void* host_ptr, out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateImage3D(cl_context context, cl_mem_flags flags, ImageFormat* image_format, IntPtr image_width, IntPtr image_height, IntPtr image_depth, IntPtr image_row_pitch, IntPtr image_slice_pitch, void* host_ptr, out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clRetainMemObject(cl_mem memobj);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clReleaseMemObject(cl_mem memobj);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetSupportedImageFormats(cl_context context,
|
||||||
|
cl_mem_flags flags,
|
||||||
|
cl_mem_object_type image_type,
|
||||||
|
cl_uint num_entries,
|
||||||
|
[Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ImageFormat[] image_formats,
|
||||||
|
out cl_uint num_image_formats);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetMemObjectInfo(cl_mem memobj, cl_mem_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetImageInfo(cl_mem image, cl_image_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Kernel Object API
|
||||||
|
|
||||||
|
// Kernel Object APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_kernel clCreateKernel(cl_program program, string kernel_name, out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clCreateKernelsInProgram(cl_program program,
|
||||||
|
cl_uint num_kernels,
|
||||||
|
[Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]cl_kernel[] kernels,
|
||||||
|
out cl_uint num_kernels_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clRetainKernel(cl_kernel kernel);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clReleaseKernel(cl_kernel kernel);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clSetKernelArg(cl_kernel kernel, cl_uint arg_index, IntPtr arg_size, void* arg_value);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetKernelInfo(cl_kernel kernel, cl_kernel_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Enqueued Commands API
|
||||||
|
|
||||||
|
// Enqueued Commands APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueReadBuffer(cl_command_queue command_queue,
|
||||||
|
cl_mem buffer,
|
||||||
|
cl_bool blocking_read,
|
||||||
|
IntPtr offset,
|
||||||
|
IntPtr cb,
|
||||||
|
void* ptr,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueWriteBuffer(cl_command_queue command_queue,
|
||||||
|
cl_mem buffer,
|
||||||
|
cl_bool blocking_write,
|
||||||
|
IntPtr offset,
|
||||||
|
IntPtr cb,
|
||||||
|
void* ptr,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueCopyBuffer(cl_command_queue command_queue,
|
||||||
|
cl_mem src_buffer,
|
||||||
|
cl_mem dst_buffer,
|
||||||
|
IntPtr src_offset,
|
||||||
|
IntPtr dst_offset,
|
||||||
|
IntPtr cb,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueReadImage(cl_command_queue command_queue,
|
||||||
|
cl_mem image,
|
||||||
|
cl_bool blocking_read,
|
||||||
|
IntPtr[] origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
IntPtr row_pitch,
|
||||||
|
IntPtr slice_pitch,
|
||||||
|
void* ptr,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueWriteImage(cl_command_queue command_queue,
|
||||||
|
cl_mem image,
|
||||||
|
cl_bool blocking_write,
|
||||||
|
IntPtr[] origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
IntPtr input_row_pitch,
|
||||||
|
IntPtr input_slice_pitch,
|
||||||
|
void* ptr,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueCopyImage(cl_command_queue command_queue,
|
||||||
|
cl_mem src_image,
|
||||||
|
cl_mem dst_image,
|
||||||
|
IntPtr[] src_origin,
|
||||||
|
IntPtr[] dst_origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
|
||||||
|
cl_mem src_image,
|
||||||
|
cl_mem dst_buffer,
|
||||||
|
IntPtr[] src_origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
IntPtr dst_offset,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueCopyBufferToImage(cl_command_queue command_queue,
|
||||||
|
cl_mem src_buffer,
|
||||||
|
cl_mem dst_image,
|
||||||
|
IntPtr src_offset,
|
||||||
|
IntPtr[] dst_origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static void* clEnqueueMapBuffer(cl_command_queue command_queue,
|
||||||
|
cl_mem buffer,
|
||||||
|
cl_bool blocking_map,
|
||||||
|
cl_map_flags map_flags,
|
||||||
|
IntPtr offset,
|
||||||
|
IntPtr cb,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static void* clEnqueueMapImage(cl_command_queue command_queue,
|
||||||
|
cl_mem image,
|
||||||
|
cl_bool blocking_map,
|
||||||
|
cl_map_flags map_flags,
|
||||||
|
IntPtr[] origin,
|
||||||
|
IntPtr[] region,
|
||||||
|
out IntPtr image_row_pitch,
|
||||||
|
out IntPtr image_slice_pitch,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueUnmapMemObject(cl_command_queue command_queue,
|
||||||
|
cl_mem memobj,
|
||||||
|
void* mapped_ptr,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueNDRangeKernel(cl_command_queue command_queue,
|
||||||
|
cl_kernel kernel,
|
||||||
|
cl_uint work_dim,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] IntPtr[] global_work_offset,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] IntPtr[] global_work_size,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] IntPtr[] local_work_size,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueTask(cl_command_queue command_queue,
|
||||||
|
cl_kernel kernel,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueNativeKernel(cl_command_queue command_queue,
|
||||||
|
NativeKernel user_func,
|
||||||
|
void* args,
|
||||||
|
IntPtr cb_args,
|
||||||
|
cl_uint num_mem_objects,
|
||||||
|
[In] cl_mem[] mem_list,
|
||||||
|
[Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] IntPtr[] args_mem_loc,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In]cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueMarker(cl_command_queue command_queue, cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueWaitForEvents(cl_command_queue command_queue,
|
||||||
|
cl_uint num_events,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] _event_list);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueBarrier(cl_command_queue command_queue);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Flush and Finish API
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clFlush(cl_command_queue command_queue);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clFinish(cl_command_queue command_queue);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event Object API
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clWaitForEvents(cl_uint num_events,
|
||||||
|
[In] [MarshalAs(UnmanagedType.LPArray)] cl_event[] _event_list);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetEventInfo(cl_event _event,
|
||||||
|
cl_event_info param_name,
|
||||||
|
IntPtr param_value_size,
|
||||||
|
void* param_value,
|
||||||
|
out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clRetainEvent(cl_event _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clReleaseEvent(cl_event _event);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Sampler API
|
||||||
|
|
||||||
|
// Sampler APIs
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_sampler clCreateSampler(cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clRetainSampler(cl_sampler sampler);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clReleaseSampler(cl_sampler sampler);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GLObject API
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateFromGLBuffer(cl_context context,
|
||||||
|
cl_mem_flags flags,
|
||||||
|
GLuint bufobj,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateFromGLTexture2D(cl_context context,
|
||||||
|
cl_mem_flags flags,
|
||||||
|
GLenum target,
|
||||||
|
GLint mipLevel,
|
||||||
|
GLuint texture,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateFromGLTexture3D(cl_context context,
|
||||||
|
cl_mem_flags flags,
|
||||||
|
GLenum target,
|
||||||
|
GLint mipLevel,
|
||||||
|
GLuint texture,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_mem clCreateFromGLRenderbuffer(cl_context context,
|
||||||
|
cl_mem_flags flags,
|
||||||
|
GLuint renderBuffer,
|
||||||
|
out ErrorCode errcode_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetGLObjectInfo(cl_mem memobj,
|
||||||
|
out cl_gl_object_type gl_object_type,
|
||||||
|
out GLuint gl_object_name);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clGetGLTextureInfo(cl_mem memobj,
|
||||||
|
cl_gl_texture_info param_name,
|
||||||
|
IntPtr param_value_size,
|
||||||
|
void* param_value,
|
||||||
|
out IntPtr param_value_size_ret);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueAcquireGLObjects(cl_command_queue command_queue,
|
||||||
|
cl_uint num_objects,
|
||||||
|
[In] cl_mem[] mem_objects,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static ErrorCode clEnqueueReleaseGLObjects(cl_command_queue command_queue,
|
||||||
|
cl_uint num_objects,
|
||||||
|
[In] cl_mem[] mem_objects,
|
||||||
|
cl_uint num_events_in_wait_list,
|
||||||
|
[In] cl_event[] event_wait_list,
|
||||||
|
cl_event* _event);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
// Extension function access
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static IntPtr clGetExtensionFunctionAddress(string func_name);
|
||||||
|
|
||||||
|
[DllImport(Configuration.Library)]
|
||||||
|
public extern static cl_int clGetEventProfilingInfo(cl_event _event, cl_profiling_info param_name, IntPtr param_value_size, void* param_value, out IntPtr param_value_size_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
OpenCLNet/OpenCLManager.Designer.cs
generated
Normal file
36
OpenCLNet/OpenCLManager.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
partial class OpenCLManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
40
OpenCLNet/OpenCLManager.cs
Normal file
40
OpenCLNet/OpenCLManager.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public partial class OpenCLManager : Component
|
||||||
|
{
|
||||||
|
public List<string> RequireExtensions = new List<string>();
|
||||||
|
public bool RequireImageSupport { get; set; }
|
||||||
|
public bool UseMultiplePlatforms { get; set; }
|
||||||
|
public List<DeviceType> DeviceTypes = new List<DeviceType>();
|
||||||
|
|
||||||
|
public OpenCLManager()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCLManager(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitializeOpenCL()
|
||||||
|
{
|
||||||
|
if (OpenCL.NumberOfPlatforms == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (Platform p in OpenCL.GetPlatforms())
|
||||||
|
{
|
||||||
|
//p.QueryDevices(DeviceType DeviceType.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
162
OpenCLNet/OpenCLNet.csproj
Normal file
162
OpenCLNet/OpenCLNet.csproj
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{758285C6-1ACA-458A-9906-EE6701D5AF87}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenCLNet</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLNet</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AlignedArray.cs" />
|
||||||
|
<Compile Include="CommandQueue.cs" />
|
||||||
|
<Compile Include="Context.cs" />
|
||||||
|
<Compile Include="Device.cs" />
|
||||||
|
<Compile Include="Enums.cs" />
|
||||||
|
<Compile Include="Event.cs" />
|
||||||
|
<Compile Include="Exceptions.cs" />
|
||||||
|
<Compile Include="Image.cs" />
|
||||||
|
<Compile Include="InteropTools.cs" />
|
||||||
|
<Compile Include="Kernel.cs" />
|
||||||
|
<Compile Include="Mem.cs" />
|
||||||
|
<Compile Include="OpenCL.cs" />
|
||||||
|
<Compile Include="OpenCLAPI.cs" />
|
||||||
|
<Compile Include="OpenCLManager.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="OpenCLManager.Designer.cs">
|
||||||
|
<DependentUpon>OpenCLManager.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Platform.cs" />
|
||||||
|
<Compile Include="Platforms.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Sampler.cs" />
|
||||||
|
<Compile Include="SimpleOCLHelper.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
19
OpenCLNet/OpenCLNet.csproj.user
Normal file
19
OpenCLNet/OpenCLNet.csproj.user
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
209
OpenCLNet/Platform.cs
Normal file
209
OpenCLNet/Platform.cs
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
|
||||||
|
unsafe public class Platform : InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
public IntPtr PlatformID { get; protected set; }
|
||||||
|
public string Profile { get { return InteropTools.ReadString( this, (uint)PlatformInfo.PROFILE ); } }
|
||||||
|
public string Version { get { return InteropTools.ReadString( this, (uint)PlatformInfo.VERSION ); } }
|
||||||
|
public string Name { get { return InteropTools.ReadString( this, (uint)PlatformInfo.NAME ); } }
|
||||||
|
public string Vendor { get { return InteropTools.ReadString( this, (uint)PlatformInfo.VENDOR ); } }
|
||||||
|
public string Extensions { get { return InteropTools.ReadString( this, (uint)PlatformInfo.EXTENSIONS ); } }
|
||||||
|
|
||||||
|
protected Dictionary<IntPtr,Device> _Devices = new Dictionary<IntPtr, Device>();
|
||||||
|
Device[] DeviceList;
|
||||||
|
IntPtr[] DeviceIDs;
|
||||||
|
|
||||||
|
protected HashSet<string> ExtensionHashSet = new HashSet<string>();
|
||||||
|
|
||||||
|
public Platform( IntPtr platformID )
|
||||||
|
{
|
||||||
|
PlatformID = platformID;
|
||||||
|
|
||||||
|
// Create a local representation of all devices
|
||||||
|
DeviceIDs = QueryDeviceIntPtr( DeviceType.ALL );
|
||||||
|
for( int i=0; i<DeviceIDs.Length; i++ )
|
||||||
|
_Devices[DeviceIDs[i]] = new Device( this, DeviceIDs[i] );
|
||||||
|
DeviceList = InteropTools.ConvertDeviceIDsToDevices( this, DeviceIDs );
|
||||||
|
|
||||||
|
InitializeExtensionHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context CreateDefaultContext()
|
||||||
|
{
|
||||||
|
return CreateDefaultContext(null, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context CreateDefaultContext( ContextNotify notify, IntPtr userData )
|
||||||
|
{
|
||||||
|
IntPtr[] properties = new IntPtr[]
|
||||||
|
{
|
||||||
|
new IntPtr((long)ContextProperties.PLATFORM), PlatformID,
|
||||||
|
IntPtr.Zero,
|
||||||
|
};
|
||||||
|
|
||||||
|
IntPtr contextID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
contextID = (IntPtr)OpenCL.CreateContext( properties,
|
||||||
|
(uint)DeviceIDs.Length,
|
||||||
|
DeviceIDs,
|
||||||
|
notify,
|
||||||
|
userData,
|
||||||
|
out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateContext failed with error code: "+result, result);
|
||||||
|
return new Context( this, contextID );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context CreateContext(IntPtr[] contextProperties, Device[] devices, ContextNotify notify, IntPtr userData)
|
||||||
|
{
|
||||||
|
IntPtr contextID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
IntPtr[] deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);
|
||||||
|
contextID = (IntPtr)OpenCL.CreateContext(contextProperties,
|
||||||
|
(uint)deviceIDs.Length,
|
||||||
|
deviceIDs,
|
||||||
|
notify,
|
||||||
|
userData,
|
||||||
|
out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateContext failed with error code: " + result, result);
|
||||||
|
return new Context(this, contextID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context CreateContextFromType(IntPtr[] contextProperties, DeviceType deviceType, ContextNotify notify, IntPtr userData)
|
||||||
|
{
|
||||||
|
IntPtr contextID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
contextID = (IntPtr)OpenCL.CreateContextFromType(contextProperties,
|
||||||
|
deviceType,
|
||||||
|
notify,
|
||||||
|
userData,
|
||||||
|
out result);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException("CreateContextFromType failed with error code: " + result, result);
|
||||||
|
return new Context(this, contextID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Device GetDevice( IntPtr index )
|
||||||
|
{
|
||||||
|
return _Devices[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IntPtr[] QueryDeviceIntPtr( DeviceType deviceType )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
uint numberOfDevices;
|
||||||
|
IntPtr[] deviceIDs;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetDeviceIDs( PlatformID, deviceType, 0, null, out numberOfDevices );
|
||||||
|
if (result == ErrorCode.DEVICE_NOT_FOUND)
|
||||||
|
return new IntPtr[0];
|
||||||
|
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "GetDeviceIDs failed: "+((ErrorCode)result).ToString(), result);
|
||||||
|
|
||||||
|
deviceIDs = new IntPtr[numberOfDevices];
|
||||||
|
result = (ErrorCode)OpenCL.GetDeviceIDs( PlatformID, deviceType, numberOfDevices, deviceIDs, out numberOfDevices );
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLException( "GetDeviceIDs failed: "+((ErrorCode)result).ToString(), result);
|
||||||
|
|
||||||
|
return deviceIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Device[] QueryDevices( DeviceType deviceType )
|
||||||
|
{
|
||||||
|
IntPtr[] deviceIDs;
|
||||||
|
|
||||||
|
deviceIDs = QueryDeviceIntPtr( deviceType );
|
||||||
|
return InteropTools.ConvertDeviceIDsToDevices( this, deviceIDs );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void InitializeExtensionHashSet()
|
||||||
|
{
|
||||||
|
string[] ext = Extensions.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
foreach (string s in ext)
|
||||||
|
ExtensionHashSet.Add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasExtension(string extension)
|
||||||
|
{
|
||||||
|
return ExtensionHashSet.Contains(extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasExtensions(string[] extensions)
|
||||||
|
{
|
||||||
|
foreach (string s in extensions)
|
||||||
|
if (!ExtensionHashSet.Contains(s))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr( Platform p )
|
||||||
|
{
|
||||||
|
return p.PlatformID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
IntPtr propertySize;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetPlatformInfo( PlatformID, key, IntPtr.Zero, null, out propertySize );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get platform info for platform "+PlatformID+": "+result, result);
|
||||||
|
return propertySize;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
IntPtr propertySize;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetPlatformInfo( PlatformID, key, keyLength, (void*)pBuffer, out propertySize );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "Unable to get platform info for platform "+PlatformID+": "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
35
OpenCLNet/Platforms.cs
Normal file
35
OpenCLNet/Platforms.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
}
|
347
OpenCLNet/Program.cs
Normal file
347
OpenCLNet/Program.cs
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for an OpenCL Program
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class Program : IDisposable, InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public Context Context { get; protected set; }
|
||||||
|
public IntPtr ProgramID { get; protected set; }
|
||||||
|
public string Source { get { return InteropTools.ReadString( this, (uint)ProgramInfo.SOURCE ); } }
|
||||||
|
public uint ReferenceCount { get { return InteropTools.ReadUInt( this, (uint)ProgramInfo.REFERENCE_COUNT ); } }
|
||||||
|
public uint NumDevices { get { return InteropTools.ReadUInt( this, (uint)ProgramInfo.NUM_DEVICES ); } }
|
||||||
|
|
||||||
|
public Device[] Devices
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
uint numDevices = NumDevices;
|
||||||
|
if( numDevices==0 )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
byte[] data = InteropTools.ReadBytes( this, (uint)ProgramInfo.DEVICES );
|
||||||
|
IntPtr[] deviceIDs = new IntPtr[numDevices];
|
||||||
|
fixed( byte* pData = data )
|
||||||
|
{
|
||||||
|
void** pBS = (void**)pData;
|
||||||
|
for( int i=0; i<numDevices; i++ )
|
||||||
|
deviceIDs[i] = new IntPtr( pBS[i] );
|
||||||
|
}
|
||||||
|
return InteropTools.ConvertDeviceIDsToDevices( Context.Platform, deviceIDs );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IntPtr[] BinarySizes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
uint numDevices = NumDevices;
|
||||||
|
if( numDevices==0 )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
byte[] data = InteropTools.ReadBytes( this, (uint)ProgramInfo.BINARY_SIZES );
|
||||||
|
IntPtr[] binarySizes = new IntPtr[numDevices];
|
||||||
|
fixed( byte* pData = data )
|
||||||
|
{
|
||||||
|
void** pBS = (void**)pData;
|
||||||
|
for( int i=0; i<numDevices; i++ )
|
||||||
|
binarySizes[i] = new IntPtr(pBS[i]);
|
||||||
|
}
|
||||||
|
return binarySizes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] Binaries
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
uint numDevices = NumDevices;
|
||||||
|
if( numDevices==0 )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IntPtr[] binarySizes = BinarySizes;
|
||||||
|
byte[] data = InteropTools.ReadBytes( this, (uint)ProgramInfo.BINARIES );
|
||||||
|
byte[][] binaries = new byte[numDevices][];
|
||||||
|
fixed( byte* pData = data )
|
||||||
|
{
|
||||||
|
byte** pBinaries = (byte**)pData;
|
||||||
|
for( int i=0; i<numDevices; i++ )
|
||||||
|
{
|
||||||
|
binaries[i] = new byte[(int)binarySizes[i]];
|
||||||
|
if( pBinaries[i]!=null && binaries[i]!=null )
|
||||||
|
Marshal.Copy( new IntPtr(pBinaries[i]), binaries[i], 0, (int)binarySizes[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return binaries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal Program( Context context, IntPtr programID )
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
ProgramID = programID;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Program()
|
||||||
|
{
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
ErrorCode result = (ErrorCode)OpenCL.ReleaseProgram( ProgramID );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "ReleaseProgram failed: "+result, result);
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
Build( null, null, IntPtr.Zero );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build(Device[] devices, ProgramNotify notify, IntPtr userData)
|
||||||
|
{
|
||||||
|
Build(devices, null, notify, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build(Device[] devices, string options, ProgramNotify notify, IntPtr userData)
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr[] deviceIDs;
|
||||||
|
int deviceLength = 0;
|
||||||
|
|
||||||
|
if (devices != null)
|
||||||
|
deviceLength = devices.Length;
|
||||||
|
|
||||||
|
deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);
|
||||||
|
result = (ErrorCode)OpenCL.BuildProgram(ProgramID,
|
||||||
|
(uint)deviceLength,
|
||||||
|
deviceIDs,
|
||||||
|
options,
|
||||||
|
notify,
|
||||||
|
userData);
|
||||||
|
if (result != ErrorCode.SUCCESS)
|
||||||
|
throw new OpenCLBuildException(this, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Kernel CreateKernel( string kernelName )
|
||||||
|
{
|
||||||
|
IntPtr kernelID;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
kernelID = (IntPtr)OpenCL.CreateKernel( ProgramID, kernelName, out result );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateKernel failed with error code "+result, result);
|
||||||
|
return new Kernel( Context, this, kernelID );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Kernel[] CreateKernels()
|
||||||
|
{
|
||||||
|
uint numKernels;
|
||||||
|
ErrorCode result;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.CreateKernelsInProgram( ProgramID, 0, null, out numKernels );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateKernels failed with error code "+result, result);
|
||||||
|
|
||||||
|
IntPtr[] kernelIDs = new IntPtr[numKernels];
|
||||||
|
result = (ErrorCode)OpenCL.CreateKernelsInProgram( ProgramID, numKernels, kernelIDs, out numKernels );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "CreateKernels failed with error code "+result, result);
|
||||||
|
|
||||||
|
Kernel[] kernels = new Kernel[numKernels];
|
||||||
|
for( int i=0; i<kernels.Length; i++ )
|
||||||
|
kernels[i] = new Kernel( Context, this, kernelIDs[i] );
|
||||||
|
return kernels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, Kernel> CreateKernelDictionary()
|
||||||
|
{
|
||||||
|
Kernel[] kernels = CreateKernels();
|
||||||
|
Dictionary<string, Kernel> kernelDictionary = new Dictionary<string, Kernel>();
|
||||||
|
|
||||||
|
foreach (Kernel k in kernels)
|
||||||
|
kernelDictionary[k.FunctionName] = k;
|
||||||
|
|
||||||
|
return kernelDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntPtr( Program p )
|
||||||
|
{
|
||||||
|
return p.ProgramID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetBuildOptions( Device device )
|
||||||
|
{
|
||||||
|
BuildInfo buildInfo;
|
||||||
|
|
||||||
|
buildInfo = new BuildInfo( this, device );
|
||||||
|
return InteropTools.ReadString( buildInfo, (uint)ProgramBuildInfo.OPTIONS );
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetBuildLog( Device device )
|
||||||
|
{
|
||||||
|
BuildInfo buildInfo;
|
||||||
|
|
||||||
|
buildInfo = new BuildInfo( this, device );
|
||||||
|
return InteropTools.ReadString( buildInfo, (uint)ProgramBuildInfo.LOG );
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildStatus GetBuildStatus( Device device )
|
||||||
|
{
|
||||||
|
BuildInfo buildInfo;
|
||||||
|
|
||||||
|
buildInfo = new BuildInfo( this, device );
|
||||||
|
return (BuildStatus)InteropTools.ReadInt( buildInfo, (uint)ProgramBuildInfo.STATUS );
|
||||||
|
}
|
||||||
|
|
||||||
|
class BuildInfo : InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
Program Program;
|
||||||
|
Device Device;
|
||||||
|
|
||||||
|
public BuildInfo( Program p, Device d )
|
||||||
|
{
|
||||||
|
Program = p;
|
||||||
|
Device = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetProgramBuildInfo( Program.ProgramID, Device.DeviceID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetProgramBuildInfo failed with error code "+result, result);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetProgramBuildInfo( Program.ProgramID, Device.DeviceID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetProgramBuildInfo failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetProgramInfo( ProgramID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetProgramInfo failed with error code "+result, result);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetProgramInfo( ProgramID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetProgramInfo failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
36
OpenCLNet/Properties/AssemblyInfo.cs
Normal file
36
OpenCLNet/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenCLNet")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("OpenCLNet")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("c5dc037e-4b59-408c-b17e-2757fa1fab10")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
154
OpenCLNet/Sampler.cs
Normal file
154
OpenCLNet/Sampler.cs
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for an OpenCL sampler
|
||||||
|
/// </summary>
|
||||||
|
unsafe public class Sampler : IDisposable, InteropTools.IPropertyContainer
|
||||||
|
{
|
||||||
|
// Track whether Dispose has been called.
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public IntPtr SamplerID { get; protected set; }
|
||||||
|
public Context Context { get; protected set; }
|
||||||
|
|
||||||
|
public uint ReferenceCount { get { return InteropTools.ReadUInt( this, (uint)SamplerInfo.REFERENCE_COUNT ); } }
|
||||||
|
public AddressingMode AddressingMode { get { return (AddressingMode)InteropTools.ReadUInt( this, (uint)SamplerInfo.ADDRESSING_MODE ); } }
|
||||||
|
public FilterMode FilterMode { get { return (FilterMode)InteropTools.ReadUInt( this, (uint)SamplerInfo.FILTER_MODE ); } }
|
||||||
|
public bool NormalizedCoords { get { return InteropTools.ReadBool( this, (uint)SamplerInfo.NORMALIZED_COORDS ); } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Construction / Destruction
|
||||||
|
|
||||||
|
internal Sampler( Context context, IntPtr samplerID )
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
SamplerID = samplerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use C# destructor syntax for finalization code.
|
||||||
|
// This destructor will run only if the Dispose method
|
||||||
|
// does not get called.
|
||||||
|
// It gives your base class the opportunity to finalize.
|
||||||
|
// Do not provide destructors in types derived from this class.
|
||||||
|
~Sampler()
|
||||||
|
{
|
||||||
|
// Do not re-create Dispose clean-up code here.
|
||||||
|
// Calling Dispose(false) is optimal in terms of
|
||||||
|
// readability and maintainability.
|
||||||
|
Dispose( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
// Implement IDisposable.
|
||||||
|
// Do not make this method virtual.
|
||||||
|
// A derived class should not be able to override this method.
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose( true );
|
||||||
|
// This object will be cleaned up by the Dispose method.
|
||||||
|
// Therefore, you should call GC.SupressFinalize to
|
||||||
|
// take this object off the finalization queue
|
||||||
|
// and prevent finalization code for this object
|
||||||
|
// from executing a second time.
|
||||||
|
GC.SuppressFinalize( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose(bool disposing) executes in two distinct scenarios.
|
||||||
|
// If disposing equals true, the method has been called directly
|
||||||
|
// or indirectly by a user's code. Managed and unmanaged resources
|
||||||
|
// can be disposed.
|
||||||
|
// If disposing equals false, the method has been called by the
|
||||||
|
// runtime from inside the finalizer and you should not reference
|
||||||
|
// other objects. Only unmanaged resources can be disposed.
|
||||||
|
private void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
// Check to see if Dispose has already been called.
|
||||||
|
if( !this.disposed )
|
||||||
|
{
|
||||||
|
// If disposing equals true, dispose all managed
|
||||||
|
// and unmanaged resources.
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
// Dispose managed resources.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the appropriate methods to clean up
|
||||||
|
// unmanaged resources here.
|
||||||
|
// If disposing is false,
|
||||||
|
// only the following code is executed.
|
||||||
|
OpenCL.ReleaseSampler( SamplerID );
|
||||||
|
SamplerID = IntPtr.Zero;
|
||||||
|
|
||||||
|
// Note disposing has been done.
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyContainer Members
|
||||||
|
|
||||||
|
|
||||||
|
public IntPtr GetPropertySize( uint key )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetSamplerInfo( SamplerID, key, IntPtr.Zero, null, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetSamplerInfo failed with error code "+result, result);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadProperty( uint key, IntPtr keyLength, void* pBuffer )
|
||||||
|
{
|
||||||
|
ErrorCode result;
|
||||||
|
IntPtr size;
|
||||||
|
|
||||||
|
result = (ErrorCode)OpenCL.GetSamplerInfo( SamplerID, key, keyLength, pBuffer, out size );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new OpenCLException( "clGetSamplerInfo failed with error code "+result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
82
OpenCLNet/SimpleOCLHelper.cs
Normal file
82
OpenCLNet/SimpleOCLHelper.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenCLNet
|
||||||
|
{
|
||||||
|
public class SimpleOCLHelper
|
||||||
|
{
|
||||||
|
public Platform Platform;
|
||||||
|
/// <summary>
|
||||||
|
/// The devices bound to the Helper
|
||||||
|
/// </summary>
|
||||||
|
public Device[] Devices;
|
||||||
|
/// <summary>
|
||||||
|
/// The Context associated with this Helper
|
||||||
|
/// </summary>
|
||||||
|
public Context Context;
|
||||||
|
/// <summary>
|
||||||
|
/// CommandQueue for device with same index
|
||||||
|
/// </summary>
|
||||||
|
public CommandQueue[] CQs;
|
||||||
|
/// <summary>
|
||||||
|
/// Alias for CQs[0]
|
||||||
|
/// </summary>
|
||||||
|
public CommandQueue CQ;
|
||||||
|
protected Program Program;
|
||||||
|
protected Dictionary<string, Kernel> Kernels;
|
||||||
|
|
||||||
|
public SimpleOCLHelper(Platform platform, DeviceType deviceType, string source)
|
||||||
|
{
|
||||||
|
Platform = platform;
|
||||||
|
Initialize(deviceType, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Initialize(DeviceType deviceType, string source)
|
||||||
|
{
|
||||||
|
Devices = Platform.QueryDevices(deviceType);
|
||||||
|
if (Devices.Length == 0)
|
||||||
|
throw new OpenCLException("No devices of type "+deviceType+" present");
|
||||||
|
|
||||||
|
Context = Platform.CreateContext(null,Devices,null, IntPtr.Zero);
|
||||||
|
CQs = new CommandQueue[Devices.Length];
|
||||||
|
for( int i=0; i<CQs.Length; i++ )
|
||||||
|
CQs[i] = Context.CreateCommandQueue(Devices[i], CommandQueueProperties.PROFILING_ENABLE);
|
||||||
|
CQ = CQs[0];
|
||||||
|
Program = Context.CreateProgramWithSource(source);
|
||||||
|
Program.Build();
|
||||||
|
Kernels = Program.CreateKernelDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Kernel GetKernel(string kernelName)
|
||||||
|
{
|
||||||
|
return Kernels[kernelName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
173
UnitTests/Form1.Designer.cs
generated
Normal file
173
UnitTests/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
namespace UnitTests
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.startToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.listBoxOutput = new System.Windows.Forms.ListBox();
|
||||||
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.listBoxWarnings = new System.Windows.Forms.ListBox();
|
||||||
|
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.listBoxErrors = new System.Windows.Forms.ListBox();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
this.groupBox2.SuspendLayout();
|
||||||
|
this.groupBox3.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.testToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(685, 24);
|
||||||
|
this.menuStrip1.TabIndex = 0;
|
||||||
|
this.menuStrip1.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// testToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.testToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.startToolStripMenuItem});
|
||||||
|
this.testToolStripMenuItem.Name = "testToolStripMenuItem";
|
||||||
|
this.testToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
|
||||||
|
this.testToolStripMenuItem.Text = "&Test";
|
||||||
|
//
|
||||||
|
// startToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.startToolStripMenuItem.Name = "startToolStripMenuItem";
|
||||||
|
this.startToolStripMenuItem.Size = new System.Drawing.Size(98, 22);
|
||||||
|
this.startToolStripMenuItem.Text = "&Start";
|
||||||
|
this.startToolStripMenuItem.Click += new System.EventHandler(this.startToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBox1.Controls.Add(this.listBoxOutput);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(0, 27);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(685, 269);
|
||||||
|
this.groupBox1.TabIndex = 4;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Output";
|
||||||
|
//
|
||||||
|
// listBoxOutput
|
||||||
|
//
|
||||||
|
this.listBoxOutput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listBoxOutput.FormattingEnabled = true;
|
||||||
|
this.listBoxOutput.IntegralHeight = false;
|
||||||
|
this.listBoxOutput.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.listBoxOutput.Name = "listBoxOutput";
|
||||||
|
this.listBoxOutput.Size = new System.Drawing.Size(679, 250);
|
||||||
|
this.listBoxOutput.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBox2.Controls.Add(this.listBoxWarnings);
|
||||||
|
this.groupBox2.Location = new System.Drawing.Point(0, 302);
|
||||||
|
this.groupBox2.Name = "groupBox2";
|
||||||
|
this.groupBox2.Size = new System.Drawing.Size(685, 121);
|
||||||
|
this.groupBox2.TabIndex = 5;
|
||||||
|
this.groupBox2.TabStop = false;
|
||||||
|
this.groupBox2.Text = "Warnings";
|
||||||
|
//
|
||||||
|
// listBoxWarnings
|
||||||
|
//
|
||||||
|
this.listBoxWarnings.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listBoxWarnings.FormattingEnabled = true;
|
||||||
|
this.listBoxWarnings.IntegralHeight = false;
|
||||||
|
this.listBoxWarnings.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.listBoxWarnings.Name = "listBoxWarnings";
|
||||||
|
this.listBoxWarnings.Size = new System.Drawing.Size(679, 102);
|
||||||
|
this.listBoxWarnings.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// groupBox3
|
||||||
|
//
|
||||||
|
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBox3.Controls.Add(this.listBoxErrors);
|
||||||
|
this.groupBox3.Location = new System.Drawing.Point(0, 426);
|
||||||
|
this.groupBox3.Name = "groupBox3";
|
||||||
|
this.groupBox3.Size = new System.Drawing.Size(685, 111);
|
||||||
|
this.groupBox3.TabIndex = 6;
|
||||||
|
this.groupBox3.TabStop = false;
|
||||||
|
this.groupBox3.Text = "Errors";
|
||||||
|
//
|
||||||
|
// listBoxErrors
|
||||||
|
//
|
||||||
|
this.listBoxErrors.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listBoxErrors.FormattingEnabled = true;
|
||||||
|
this.listBoxErrors.IntegralHeight = false;
|
||||||
|
this.listBoxErrors.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.listBoxErrors.Name = "listBoxErrors";
|
||||||
|
this.listBoxErrors.Size = new System.Drawing.Size(679, 92);
|
||||||
|
this.listBoxErrors.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(685, 537);
|
||||||
|
this.Controls.Add(this.groupBox3);
|
||||||
|
this.Controls.Add(this.groupBox2);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.menuStrip1);
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox2.ResumeLayout(false);
|
||||||
|
this.groupBox3.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem startToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
private System.Windows.Forms.ListBox listBoxOutput;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox2;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox3;
|
||||||
|
private System.Windows.Forms.ListBox listBoxWarnings;
|
||||||
|
private System.Windows.Forms.ListBox listBoxErrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
555
UnitTests/Form1.cs
Normal file
555
UnitTests/Form1.cs
Normal file
@ -0,0 +1,555 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using OpenCLNet;
|
||||||
|
|
||||||
|
namespace UnitTests
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
Platform[] Platforms;
|
||||||
|
Regex ParseOpenCLVersion = new Regex(@"OpenCL (?<MajorVersion>\d+)\.(?<MinorVersion>\d+).*");
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
listBoxErrors.Items.Clear();
|
||||||
|
listBoxWarnings.Items.Clear();
|
||||||
|
listBoxOutput.Items.Clear();
|
||||||
|
RunTests();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.ToString(), "Test terminated with a fatal exception.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunTests()
|
||||||
|
{
|
||||||
|
TestOpenCLClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestOpenCLClass()
|
||||||
|
{
|
||||||
|
if (OpenCL.NumberOfPlatforms <= 0)
|
||||||
|
{
|
||||||
|
listBoxOutput.Items.Add("OpenCL.NumberOfPlatforms=" + OpenCL.NumberOfPlatforms);
|
||||||
|
throw new Exception("TestOpenCLClass: NumberOfPlatforms<0. Is the API available at all?");
|
||||||
|
}
|
||||||
|
|
||||||
|
Platforms = OpenCL.GetPlatforms();
|
||||||
|
if (Platforms.Length != OpenCL.NumberOfPlatforms)
|
||||||
|
Error("OpenCL.NumberOfPlatforms!=Length of openCL.GetPlatforms()" + OpenCL.NumberOfPlatforms);
|
||||||
|
|
||||||
|
for (int platformIndex = 0; platformIndex < Platforms.Length; platformIndex++)
|
||||||
|
{
|
||||||
|
if (OpenCL.GetPlatform(platformIndex) != Platforms[platformIndex])
|
||||||
|
Error("openCL.GetPlatform(platformIndex)!=Platforms[platformIndex]");
|
||||||
|
|
||||||
|
Output("Testing Platform " + platformIndex);
|
||||||
|
TestPlatform(Platforms[platformIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestPlatform(Platform p)
|
||||||
|
{
|
||||||
|
Device[] allDevices;
|
||||||
|
Device[] cpuDevices;
|
||||||
|
Device[] gpuDevices;
|
||||||
|
Device[] acceleratorDevices;
|
||||||
|
|
||||||
|
Output("Name: " + p.Name);
|
||||||
|
Output("Vendor:" + p.Vendor);
|
||||||
|
Output("Version:" + p.Version);
|
||||||
|
|
||||||
|
// Check format of version string
|
||||||
|
Match m = ParseOpenCLVersion.Match(p.Version);
|
||||||
|
if (!m.Success)
|
||||||
|
Warning("Platform " + p.Name + " has an invalid version string");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m.Groups["MajorVersion"].Value != "1" && m.Groups["MinorVersion"].Value != "0")
|
||||||
|
Warning("Platform " + p.Name + " has a version number!=1.0(Not really a problem, but this test is written for 1.0)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check format of profile
|
||||||
|
Output("Profile:" + p.Profile);
|
||||||
|
if (p.Profile == "FULL_PROFILE" || p.Profile == "EMBEDDED_PROFILE")
|
||||||
|
Output("Profile:" + p.Profile);
|
||||||
|
else
|
||||||
|
Warning("Platform " + p.Name + " has unknown profile "+p.Profile);
|
||||||
|
|
||||||
|
Output("Extensions: " + p.Extensions);
|
||||||
|
|
||||||
|
// Test whether number of devices is consistent
|
||||||
|
allDevices = p.QueryDevices(DeviceType.ALL);
|
||||||
|
if( allDevices.Length<=0 )
|
||||||
|
Warning( "Platform "+p.Name+" has no devices" );
|
||||||
|
|
||||||
|
cpuDevices = p.QueryDevices(DeviceType.CPU);
|
||||||
|
gpuDevices = p.QueryDevices(DeviceType.GPU);
|
||||||
|
acceleratorDevices = p.QueryDevices(DeviceType.ACCELERATOR);
|
||||||
|
if( allDevices.Length!=cpuDevices.Length+gpuDevices.Length+acceleratorDevices.Length )
|
||||||
|
Warning( "QueryDevices( DeviceType.ALL ) return length inconsistent with sum of special purpose queries" );
|
||||||
|
|
||||||
|
// Create a few contexts and test them
|
||||||
|
Output( "Testing Platform.CreateDefaultContext()" );
|
||||||
|
using (Context c = p.CreateDefaultContext())
|
||||||
|
{
|
||||||
|
Output("Testing context"+c);
|
||||||
|
TestContext(c);
|
||||||
|
}
|
||||||
|
Output("");
|
||||||
|
Output("");
|
||||||
|
|
||||||
|
if (cpuDevices.Length > 0)
|
||||||
|
{
|
||||||
|
Output("Testing Platform.CreateContext()");
|
||||||
|
using (Context c = p.CreateContext(null, cpuDevices, new ContextNotify(ContextNotifyFunc), (IntPtr)0x01234567))
|
||||||
|
{
|
||||||
|
Output("Testing context" + c);
|
||||||
|
TestContext(c);
|
||||||
|
}
|
||||||
|
Output("");
|
||||||
|
Output("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gpuDevices.Length > 0)
|
||||||
|
{
|
||||||
|
Output("Testing Platform.CreateContext()");
|
||||||
|
using (Context c = p.CreateContext(null, gpuDevices, new ContextNotify(ContextNotifyFunc), (IntPtr)0x01234567))
|
||||||
|
{
|
||||||
|
Output("Testing context" + c);
|
||||||
|
TestContext(c);
|
||||||
|
}
|
||||||
|
Output("");
|
||||||
|
Output("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpuDevices.Length > 0)
|
||||||
|
{
|
||||||
|
Output("Testing Platform.CreateContextFromType()");
|
||||||
|
IntPtr[] contextProperties = new IntPtr[]
|
||||||
|
{
|
||||||
|
(IntPtr)ContextProperties.PLATFORM, p.PlatformID,
|
||||||
|
IntPtr.Zero
|
||||||
|
};
|
||||||
|
using (Context c = p.CreateContextFromType(contextProperties, DeviceType.CPU, new ContextNotify(ContextNotifyFunc), (IntPtr)0x01234567))
|
||||||
|
{
|
||||||
|
Output("Testing context" + c);
|
||||||
|
TestContext(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gpuDevices.Length > 0)
|
||||||
|
{
|
||||||
|
Output("Testing Platform.CreateContextFromType()");
|
||||||
|
IntPtr[] contextProperties = new IntPtr[]
|
||||||
|
{
|
||||||
|
(IntPtr)ContextProperties.PLATFORM, p.PlatformID,
|
||||||
|
IntPtr.Zero
|
||||||
|
};
|
||||||
|
using (Context c = p.CreateContextFromType(contextProperties, DeviceType.GPU, new ContextNotify(ContextNotifyFunc), (IntPtr)0x01234567))
|
||||||
|
{
|
||||||
|
Output("Testing context" + c);
|
||||||
|
TestContext(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ContextNotifyFunc( string errInfo, byte[] privateInfo, IntPtr cb, IntPtr userData )
|
||||||
|
{
|
||||||
|
Error(errInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
int NativeKernelCalled = 0;
|
||||||
|
NativeKernel NativeKernelCallRef;
|
||||||
|
|
||||||
|
private void TestContext(Context c)
|
||||||
|
{
|
||||||
|
Device[] devices = c.Devices;
|
||||||
|
OpenCLNet.Program p = c.CreateProgramFromFile("MemoryTests.cl");
|
||||||
|
Dictionary<string, Kernel> kernelDictionary;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p.Build();
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
throw ocle;
|
||||||
|
}
|
||||||
|
kernelDictionary = p.CreateKernelDictionary();
|
||||||
|
NativeKernelCallRef = new NativeKernel(NativeKernelTest);
|
||||||
|
for (int deviceIndex = 0; deviceIndex < devices.Length; deviceIndex++)
|
||||||
|
{
|
||||||
|
Device d;
|
||||||
|
|
||||||
|
d = devices[deviceIndex];
|
||||||
|
using (CommandQueue cq = c.CreateCommandQueue(d))
|
||||||
|
{
|
||||||
|
if ( (d.ExecutionCapabilities & (ulong)DeviceExecCapabilities.NATIVE_KERNEL)!=0 )
|
||||||
|
{
|
||||||
|
Output("Testing native kernel execution");
|
||||||
|
cq.EnqueueNativeKernel(NativeKernelCallRef);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
if (NativeKernelCalled != 1)
|
||||||
|
Error("EnqueueNativeKernel failed");
|
||||||
|
Interlocked.Decrement(ref NativeKernelCalled);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Output("Testing native kernel execution: Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
TestMem(c, cq, kernelDictionary);
|
||||||
|
TestDevice(d);
|
||||||
|
TestCommandQueue(c, cq);
|
||||||
|
TestKernel(c, cq, kernelDictionary["ArgIO"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe void NativeKernelTest(IntPtr args)
|
||||||
|
{
|
||||||
|
Interlocked.Increment(ref NativeKernelCalled);
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||||
|
internal struct IOKernelArgs
|
||||||
|
{
|
||||||
|
internal long outLong;
|
||||||
|
internal int outInt;
|
||||||
|
internal float outSingle;
|
||||||
|
internal IntPtr outIntPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void TestKernel(Context c, CommandQueue cq, Kernel argIOKernel)
|
||||||
|
{
|
||||||
|
Mem outArgBuffer = c.CreateBuffer(MemFlags.WRITE_ONLY, sizeof(IOKernelArgs), IntPtr.Zero);
|
||||||
|
|
||||||
|
Output("Testing kernel - Argument return");
|
||||||
|
|
||||||
|
argIOKernel.SetIntArg(0, 1);
|
||||||
|
argIOKernel.SetLongArg(1, 65);
|
||||||
|
argIOKernel.SetSingleArg(2, 38.4f);
|
||||||
|
argIOKernel.SetIntPtrArg(3, new IntPtr(0x01234567));
|
||||||
|
argIOKernel.SetIntPtrArg(4, outArgBuffer.MemID);
|
||||||
|
|
||||||
|
cq.EnqueueTask(argIOKernel);
|
||||||
|
|
||||||
|
IntPtr outArgPtr = cq.EnqueueMapBuffer( outArgBuffer, true, MapFlags.READ, IntPtr.Zero, (IntPtr)sizeof(IOKernelArgs) );
|
||||||
|
IOKernelArgs args = (IOKernelArgs)Marshal.PtrToStructure(outArgPtr, typeof(IOKernelArgs));
|
||||||
|
cq.EnqueueUnmapMemObject(outArgBuffer, outArgPtr);
|
||||||
|
|
||||||
|
if (args.outInt != 1)
|
||||||
|
Error("argIOKernel failed to return correct arguments");
|
||||||
|
if (args.outLong != 65)
|
||||||
|
Error("argIOKernel failed to return correct arguments");
|
||||||
|
if (args.outSingle != 38.4f)
|
||||||
|
Error("argIOKernel failed to return correct arguments");
|
||||||
|
if (args.outIntPtr != new IntPtr(0x01234567))
|
||||||
|
Error("argIOKernel failed to return correct arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestMem(Context c, CommandQueue cq, Dictionary<string, Kernel> kernelDictionary )
|
||||||
|
{
|
||||||
|
long size = 8192;
|
||||||
|
|
||||||
|
Output( "Testing Mem class" );
|
||||||
|
Output( "Allocating "+size+" bytes of READ_WRITE memory" );
|
||||||
|
using (Mem buffer = c.CreateBuffer(MemFlags.READ_WRITE, size, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
Output("Mem.MemSize=" + size);
|
||||||
|
if (buffer.MemSize.ToInt64() != size)
|
||||||
|
Error("Mem.Size!=input size");
|
||||||
|
Output("Mem.MemType=" + buffer.MemType);
|
||||||
|
if (buffer.MemType != MemObjectType.BUFFER)
|
||||||
|
Error("Mem.MemType!=MemObjectType.BUFFER");
|
||||||
|
|
||||||
|
Output("Mem.MapCount=" + buffer.MapCount);
|
||||||
|
if (buffer.MapCount != 0)
|
||||||
|
Error("Mem.MapCount!=0");
|
||||||
|
|
||||||
|
Kernel k = kernelDictionary["TestReadWriteMemory"];
|
||||||
|
k.SetArg(0, buffer);
|
||||||
|
k.SetArg(1, (IntPtr)size);
|
||||||
|
cq.EnqueueTask(k);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
Output("Allocating " + size + " bytes of READ memory");
|
||||||
|
using (Mem buffer = c.CreateBuffer(MemFlags.READ_ONLY, size, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
Output("Mem.MemSize=" + size);
|
||||||
|
if (buffer.MemSize.ToInt64() != size)
|
||||||
|
Error("Mem.Size!=input size");
|
||||||
|
Output("Mem.MemType=" + buffer.MemType);
|
||||||
|
if (buffer.MemType != MemObjectType.BUFFER)
|
||||||
|
Error("Mem.MemType!=MemObjectType.BUFFER");
|
||||||
|
|
||||||
|
Output("Mem.MapCount=" + buffer.MapCount);
|
||||||
|
if (buffer.MapCount != 0)
|
||||||
|
Error("Mem.MapCount!=0");
|
||||||
|
|
||||||
|
Kernel k = kernelDictionary["TestReadMemory"];
|
||||||
|
k.SetArg(0, buffer);
|
||||||
|
k.SetArg(1, (IntPtr)size);
|
||||||
|
cq.EnqueueTask(k);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
Output("Allocating " + size + " bytes of WRITE memory");
|
||||||
|
using (Mem buffer = c.CreateBuffer(MemFlags.WRITE_ONLY, size, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
Output("Mem.MemSize=" + size);
|
||||||
|
if (buffer.MemSize.ToInt64() != size)
|
||||||
|
Error("Mem.Size!=input size");
|
||||||
|
Output("Mem.MemType=" + buffer.MemType);
|
||||||
|
if (buffer.MemType != MemObjectType.BUFFER)
|
||||||
|
Error("Mem.MemType!=MemObjectType.BUFFER");
|
||||||
|
|
||||||
|
Output("Mem.MapCount=" + buffer.MapCount);
|
||||||
|
if (buffer.MapCount != 0)
|
||||||
|
Error("Mem.MapCount!=0");
|
||||||
|
|
||||||
|
Kernel k = kernelDictionary["TestWriteMemory"];
|
||||||
|
k.SetArg(0, buffer);
|
||||||
|
k.SetArg(1, (IntPtr)size);
|
||||||
|
cq.EnqueueTask(k);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestDevice( Device d )
|
||||||
|
{
|
||||||
|
Output("Testing device: " + d.Name);
|
||||||
|
// d.ToString() is overloaded to output all properties as a string, so every property will be used that way
|
||||||
|
Output(d.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestCommandQueue(Context c, CommandQueue cq )
|
||||||
|
{
|
||||||
|
string programName = @"MemoryTests.cl";
|
||||||
|
|
||||||
|
Output("Testing compilation of: " + programName);
|
||||||
|
OpenCLNet.Program p0 = c.CreateProgramWithSource(File.ReadAllLines(programName));
|
||||||
|
OpenCLNet.Program p = c.CreateProgramWithSource(File.ReadAllText(programName));
|
||||||
|
p0.Build();
|
||||||
|
p.Build();
|
||||||
|
Kernel k = p.CreateKernel(@"LoopAndDoNothing");
|
||||||
|
|
||||||
|
TestCommandQueueMemCopy(c, cq);
|
||||||
|
TestCommandQueueAsync(c, cq, k );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region TestCommandQueue helper functions
|
||||||
|
|
||||||
|
private void TestCommandQueueAsync(Context c, CommandQueue cq, Kernel kernel )
|
||||||
|
{
|
||||||
|
List<Event> events = new List<Event>();
|
||||||
|
Event clEvent;
|
||||||
|
|
||||||
|
Output("Testing asynchronous task issuing (clEnqueueTask) and waiting for events");
|
||||||
|
|
||||||
|
// Issue a bunch of slow operations
|
||||||
|
kernel.SetArg(0, 5000000);
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
cq.EnqueueTask(kernel, 0, null, out clEvent);
|
||||||
|
events.Add(clEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue a bunch of fast operations
|
||||||
|
kernel.SetArg(0, 500);
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
cq.EnqueueTask(kernel, 0, null, out clEvent);
|
||||||
|
events.Add(clEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
Event[] eventList = events.ToArray();
|
||||||
|
cq.EnqueueWaitForEvents(eventList.Length, eventList);
|
||||||
|
while (events.Count > 0)
|
||||||
|
{
|
||||||
|
events[0].Dispose();
|
||||||
|
events.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestCommandQueueMemCopy(Context c, CommandQueue cq)
|
||||||
|
{
|
||||||
|
AlignedArrayFloat aafSrc = new AlignedArrayFloat(1024 * 1024, 64);
|
||||||
|
AlignedArrayFloat aafDst = new AlignedArrayFloat(1024 * 1024, 64);
|
||||||
|
|
||||||
|
SetAAF(aafSrc, 0.0f);
|
||||||
|
SetAAF(aafDst, 1.0f);
|
||||||
|
|
||||||
|
/// Test HOST_PTR -> HOST_PTR copy
|
||||||
|
/// The call to EnqueueMapBuffer synchronizes caches before testing the result
|
||||||
|
Output("Testing synchronous host memory->memory copy(clEnqueueCopyBuffer)");
|
||||||
|
using (Mem memSrc = c.CreateBuffer(MemFlags.USE_HOST_PTR, aafSrc.ByteLength, aafSrc))
|
||||||
|
{
|
||||||
|
using (Mem memDst = c.CreateBuffer(MemFlags.USE_HOST_PTR, aafDst.ByteLength, aafDst))
|
||||||
|
{
|
||||||
|
cq.EnqueueCopyBuffer(memSrc, memDst, IntPtr.Zero, IntPtr.Zero, (IntPtr)aafSrc.ByteLength);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
IntPtr mappedPtr = cq.EnqueueMapBuffer(memDst, true, MapFlags.READ, (IntPtr)0, (IntPtr)aafDst.ByteLength);
|
||||||
|
if (!TestAAF(aafDst, 0.0f))
|
||||||
|
Error("EnqueueCopyBuffer failed, destination is invalid");
|
||||||
|
cq.EnqueueUnmapMemObject(memDst, mappedPtr);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test COPY_HOST_PTR -> COPY_HOST_PTR copy
|
||||||
|
/// Verify that original source buffers are intact and that the copy was successful
|
||||||
|
Output("Testing synchronous host memory->memory copy(clEnqueueCopyBuffer)");
|
||||||
|
SetAAF(aafSrc, 0.0f);
|
||||||
|
SetAAF(aafDst, 1.0f);
|
||||||
|
using (Mem memSrc = c.CreateBuffer(MemFlags.COPY_HOST_PTR, aafSrc.ByteLength, aafSrc))
|
||||||
|
{
|
||||||
|
using (Mem memDst = c.CreateBuffer(MemFlags.COPY_HOST_PTR, aafSrc.ByteLength, aafDst))
|
||||||
|
{
|
||||||
|
SetAAF(aafSrc, 2.0f);
|
||||||
|
SetAAF(aafDst, 3.0f);
|
||||||
|
|
||||||
|
cq.EnqueueCopyBuffer(memSrc, memDst, IntPtr.Zero, IntPtr.Zero, (IntPtr)aafSrc.ByteLength);
|
||||||
|
cq.Finish();
|
||||||
|
|
||||||
|
if (!TestAAF(aafSrc, 2.0f))
|
||||||
|
Error("Memory copy destroyed src buffer");
|
||||||
|
if (!TestAAF(aafDst, 3.0f))
|
||||||
|
Error("Memory copy destroyed dst buffer");
|
||||||
|
|
||||||
|
cq.EnqueueReadBuffer(memDst, true, IntPtr.Zero, (IntPtr)aafDst.ByteLength, aafDst);
|
||||||
|
cq.Finish();
|
||||||
|
if (!TestAAF(aafDst, 0.0f))
|
||||||
|
Error("Memory copy failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test ALLOC_HOST_PTR -> ALLOC_HOST_PTR copy
|
||||||
|
Output("Testing synchronous host memory->memory copy(clEnqueueCopyBuffer)");
|
||||||
|
SetAAF(aafSrc, 0.0f);
|
||||||
|
SetAAF(aafDst, 1.0f);
|
||||||
|
using (Mem memSrc = c.CreateBuffer((MemFlags)((ulong)MemFlags.ALLOC_HOST_PTR + (ulong)MemFlags.READ_WRITE), aafSrc.ByteLength, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
using (Mem memDst = c.CreateBuffer((MemFlags)((ulong)MemFlags.ALLOC_HOST_PTR + (ulong)MemFlags.WRITE_ONLY), aafSrc.ByteLength, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
cq.EnqueueWriteBuffer(memSrc, false, (IntPtr)0, (IntPtr)aafSrc.ByteLength, aafSrc);
|
||||||
|
cq.EnqueueWriteBuffer(memDst, false, (IntPtr)0, (IntPtr)aafSrc.ByteLength, aafSrc);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
|
||||||
|
cq.EnqueueCopyBuffer(memSrc, memDst, IntPtr.Zero, IntPtr.Zero, (IntPtr)aafSrc.ByteLength);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
|
||||||
|
cq.EnqueueReadBuffer(memDst, true, IntPtr.Zero, (IntPtr)aafDst.ByteLength, aafDst);
|
||||||
|
if (!TestAAF(aafDst, 0.0f))
|
||||||
|
Error("Memory copy failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test DEFAULT -> DEFAULT copy
|
||||||
|
Output("Testing synchronous host memory->memory copy(clEnqueueCopyBuffer)");
|
||||||
|
SetAAF(aafSrc, 0.0f);
|
||||||
|
SetAAF(aafDst, 1.0f);
|
||||||
|
using (Mem memSrc = c.CreateBuffer((MemFlags)((ulong)MemFlags.ALLOC_HOST_PTR + (ulong)MemFlags.READ_ONLY), aafSrc.ByteLength, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
using (Mem memDst = c.CreateBuffer((MemFlags)((ulong)MemFlags.ALLOC_HOST_PTR + (ulong)MemFlags.WRITE_ONLY), aafSrc.ByteLength, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
cq.EnqueueWriteBuffer(memSrc, false, (IntPtr)0, (IntPtr)aafSrc.ByteLength, aafSrc);
|
||||||
|
cq.EnqueueWriteBuffer(memDst, false, (IntPtr)0, (IntPtr)aafSrc.ByteLength, aafSrc);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
|
||||||
|
cq.EnqueueCopyBuffer(memSrc, memDst, IntPtr.Zero, IntPtr.Zero, (IntPtr)aafSrc.ByteLength);
|
||||||
|
cq.EnqueueBarrier();
|
||||||
|
|
||||||
|
cq.EnqueueReadBuffer(memDst, true, IntPtr.Zero, (IntPtr)aafDst.ByteLength, aafDst);
|
||||||
|
if (!TestAAF(aafDst, 0.0f))
|
||||||
|
Error("Memory copy failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TestAAF(AlignedArrayFloat aaf, float c)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < aaf.Length; i++)
|
||||||
|
if (aaf[i] != c)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetAAF(AlignedArrayFloat aaf, float c)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < aaf.Length; i++)
|
||||||
|
aaf[i] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetAAFLinear(AlignedArrayFloat aaf)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < aaf.Length; i++)
|
||||||
|
aaf[i] = (float)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void Output(string s)
|
||||||
|
{
|
||||||
|
listBoxOutput.Items.Add(s);
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Warning(string s)
|
||||||
|
{
|
||||||
|
listBoxWarnings.Items.Add(s);
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Error(string s)
|
||||||
|
{
|
||||||
|
listBoxErrors.Items.Add(s);
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
UnitTests/Form1.resx
Normal file
123
UnitTests/Form1.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
141
UnitTests/Mandelbrot.cl
Normal file
141
UnitTests/Mandelbrot.cl
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
__constant uint Palette[17][4] =
|
||||||
|
{
|
||||||
|
{ 0x00, 0x00, 0x00, 0xFF },
|
||||||
|
{ 0x00, 0xA8, 0x76, 0xFF },
|
||||||
|
{ 0x20, 0x7E, 0x62, 0xFF },
|
||||||
|
{ 0x00, 0x6D, 0x4C, 0xFF },
|
||||||
|
{ 0x35, 0xD4, 0xA4, 0xFF },
|
||||||
|
{ 0x5F, 0xD4, 0xB1, 0xFF },
|
||||||
|
{ 0x0D, 0x56, 0xA6, 0xFF },
|
||||||
|
{ 0x27, 0x4F, 0x7D, 0xFF },
|
||||||
|
{ 0x04, 0x35, 0x6C, 0xFF },
|
||||||
|
{ 0x41, 0x86, 0xD3, 0xFF },
|
||||||
|
{ 0x68, 0x9A, 0xD3, 0xFF },
|
||||||
|
{ 0x4D, 0xDE, 0x00, 0xFF },
|
||||||
|
{ 0x55, 0xA6, 0x2A, 0xFF },
|
||||||
|
{ 0x32, 0x90, 0x00, 0xFF },
|
||||||
|
{ 0x7A, 0xEE, 0x3C, 0xFF },
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF },
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF },
|
||||||
|
/*
|
||||||
|
{0x00, 0x00, 0x5a, 0xff,},
|
||||||
|
{0x39, 0x8c, 0xdb, 0xff,},
|
||||||
|
{0x9b, 0xb9, 0xff, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAXITER 100
|
||||||
|
#define PALETTELENGTH 16
|
||||||
|
|
||||||
|
__constant int8 i8_01234567 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
__constant int8 i8_00000000 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
__constant int8 i8_11111111 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
|
||||||
|
__kernel void Mandelbrot( float left, float top, float right, float bottom, int stride, __global uchar4* pOutput )
|
||||||
|
{
|
||||||
|
size_t width = get_global_size(0);
|
||||||
|
size_t height = get_global_size(1);
|
||||||
|
size_t cx = get_global_id(0);
|
||||||
|
size_t cy = get_global_id(1);
|
||||||
|
float dx = (right-left)/(float)width;
|
||||||
|
float dy = (bottom-top)/(float)height;
|
||||||
|
|
||||||
|
float x0 = left+dx*(float)cx;
|
||||||
|
float y0 = top+dy*(float)cy;
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
int iteration = 0;
|
||||||
|
int max_iteration = MAXITER;
|
||||||
|
|
||||||
|
while( x*x-y*y<=(2*2) && iteration<max_iteration )
|
||||||
|
{
|
||||||
|
float xtemp = x*x-y*y+x0;
|
||||||
|
y = 2*x*y+y0;
|
||||||
|
x = xtemp;
|
||||||
|
iteration++;
|
||||||
|
}
|
||||||
|
int index;
|
||||||
|
index = iteration*PALETTELENGTH/MAXITER;
|
||||||
|
//index = iteration%PALETTELENGTH;
|
||||||
|
float4 color0 = (float4)(Palette[index][0],Palette[index][1],Palette[index][2],Palette[index][3]);
|
||||||
|
float4 color1 = (float4)(Palette[index+1][0],Palette[index+1][1],Palette[index+1][2],Palette[index+1][3]);
|
||||||
|
float mixFactor = clamp( (iteration%(MAXITER/PALETTELENGTH))/(float)(MAXITER/PALETTELENGTH), 0.0f, 1.0f);
|
||||||
|
float4 mixFactors = (float4)(1.0f-mixFactor, 1.0f-mixFactor, 1.0f-mixFactor, 1.0f);
|
||||||
|
float4 mixfc = mix( color0, color1, mixFactors );
|
||||||
|
mixfc = color0*mixFactors+color1*((float4)(1.0f)-mixFactors);
|
||||||
|
pOutput[width*cy+cx] = convert_uchar4( mixfc );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
__kernel void MandelbrotVectorized( float left, float top, float right, float bottom, int stride, __global uchar4* pOutput )
|
||||||
|
{
|
||||||
|
size_t width = get_global_size(0);
|
||||||
|
size_t height = get_global_size(1);
|
||||||
|
size_t cx = get_global_id(0);
|
||||||
|
size_t cy = get_global_id(1);
|
||||||
|
float dx = (right-left)/(float)width;
|
||||||
|
float dy = (bottom-top)/(float)height;
|
||||||
|
|
||||||
|
float8 dxs = (float8)(dxs)*i8_01234567;
|
||||||
|
int8 cxs = (int8)(cx)*(int8)(8)+i8_01234567;
|
||||||
|
float8 x0s = (float8)(left)+(float8)(cx)+dxs;
|
||||||
|
float8 xs = i8_00000000;
|
||||||
|
float8 ys = i8_00000000;
|
||||||
|
|
||||||
|
float x0 = left+dx*(float)cx;
|
||||||
|
float y0 = top+dy*(float)cy;
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
int8 iterations = (int8)(0);
|
||||||
|
int8 max_iterations = (int8)(255);
|
||||||
|
|
||||||
|
loop:
|
||||||
|
float8 doneflags = (float8)(0);
|
||||||
|
float8 looptest = (xs*xs-ys*ys)<=(float8)(2*2);
|
||||||
|
doneflags |= ~loopTest;
|
||||||
|
|
||||||
|
if( !any( (xs*xs-ys*ys)<=(float8)(2*2) ) && all( iterations<max_iterations ) )
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
float8 xtemp = xs*xs-ys*ys+x0s;
|
||||||
|
float8 ytemp = 2*xs*ys+y0s;
|
||||||
|
xs = select( xs, xtemp, doneflags );
|
||||||
|
ys = select( ys, ytemp, doneflags );
|
||||||
|
|
||||||
|
iterations = select( iterations, iterations+i8_11111111, doneflags );
|
||||||
|
goto loop;
|
||||||
|
|
||||||
|
done:
|
||||||
|
|
||||||
|
int index;
|
||||||
|
color = iteration==max_iteration?0.0f: (float)iteration/255.0f;
|
||||||
|
index = clamp( iteration, 0.0f, 255.0f )/64;
|
||||||
|
pOutput[width*cy+cx] = (uchar4)(Palette[index][0],Palette[index][1],Palette[index][2],Palette[index][3]);
|
||||||
|
}
|
||||||
|
#endif
|
83
UnitTests/MemoryTests.cl
Normal file
83
UnitTests/MemoryTests.cl
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
|
||||||
|
|
||||||
|
constant char TestMemory[] = "TestMemory";
|
||||||
|
|
||||||
|
kernel void MemoryCopy( global float* pSrc, global float* pDst, size_t length )
|
||||||
|
{
|
||||||
|
global float* pEnd;
|
||||||
|
|
||||||
|
pEnd = pSrc+length;
|
||||||
|
while( pSrc<pEnd )
|
||||||
|
*pDst++ = *pSrc++;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void LoopAndDoNothing( int iterations )
|
||||||
|
{
|
||||||
|
for( int i=0; i<iterations; i++ )
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IOKernelArgs
|
||||||
|
{
|
||||||
|
long outLong;
|
||||||
|
int outInt;
|
||||||
|
float outSingle;
|
||||||
|
intptr_t outIntPtr;
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel void ArgIO( int i,
|
||||||
|
long l,
|
||||||
|
float s,
|
||||||
|
intptr_t p,
|
||||||
|
global struct IOKernelArgs* pA)
|
||||||
|
{
|
||||||
|
pA->outInt = i;
|
||||||
|
pA->outLong = l;
|
||||||
|
pA->outSingle = s;
|
||||||
|
pA->outIntPtr = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void TestReadMemory( global char* pData, size_t length )
|
||||||
|
{
|
||||||
|
int sum;
|
||||||
|
|
||||||
|
for( size_t i=0; i<length; i++ )
|
||||||
|
sum += pData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void TestWriteMemory( global char* pData, size_t length )
|
||||||
|
{
|
||||||
|
for( size_t i=0; i<length; i++ )
|
||||||
|
pData[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void TestReadWriteMemory( global char* pData, size_t length )
|
||||||
|
{
|
||||||
|
for( size_t i=0; i<length; i++ )
|
||||||
|
pData[length-1-i] = pData[i];
|
||||||
|
}
|
21
UnitTests/Program.cs
Normal file
21
UnitTests/Program.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace UnitTests
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
UnitTests/Properties/AssemblyInfo.cs
Normal file
36
UnitTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("UnitTests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("UnitTests")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("943b1a5e-83e4-42f1-8187-a852dc5ef2a4")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
UnitTests/Properties/Resources.Designer.cs
generated
Normal file
63
UnitTests/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace UnitTests.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UnitTests.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
UnitTests/Properties/Resources.resx
Normal file
117
UnitTests/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
26
UnitTests/Properties/Settings.Designer.cs
generated
Normal file
26
UnitTests/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace UnitTests.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
UnitTests/Properties/Settings.settings
Normal file
7
UnitTests/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
183
UnitTests/UnitTests.csproj
Normal file
183
UnitTests/UnitTests.csproj
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{264E13EF-4308-4033-96C1-54C13C82D7C0}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>UnitTests</RootNamespace>
|
||||||
|
<AssemblyName>UnitTests</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="MemoryTests.cl">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Mandelbrot.cl">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{758285C6-1ACA-458A-9906-EE6701D5AF87}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
25
UnitTests/UnitTests.csproj.user
Normal file
25
UnitTests/UnitTests.csproj.user
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
102
examples/ImageCrossFade/Form1.Designer.cs
generated
Normal file
102
examples/ImageCrossFade/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
namespace ImageCrossFade
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.hScrollBarRatio = new System.Windows.Forms.HScrollBar();
|
||||||
|
this.comboBoxDeviceSelector = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 5);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(32, 13);
|
||||||
|
this.label1.TabIndex = 1;
|
||||||
|
this.label1.Text = "Ratio";
|
||||||
|
//
|
||||||
|
// hScrollBarRatio
|
||||||
|
//
|
||||||
|
this.hScrollBarRatio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.hScrollBarRatio.LargeChange = 1;
|
||||||
|
this.hScrollBarRatio.Location = new System.Drawing.Point(59, 0);
|
||||||
|
this.hScrollBarRatio.Name = "hScrollBarRatio";
|
||||||
|
this.hScrollBarRatio.Size = new System.Drawing.Size(480, 21);
|
||||||
|
this.hScrollBarRatio.TabIndex = 2;
|
||||||
|
this.hScrollBarRatio.ValueChanged += new System.EventHandler(this.hScrollBarRatio_ValueChanged);
|
||||||
|
//
|
||||||
|
// comboBoxDeviceSelector
|
||||||
|
//
|
||||||
|
this.comboBoxDeviceSelector.FormattingEnabled = true;
|
||||||
|
this.comboBoxDeviceSelector.Location = new System.Drawing.Point(59, 24);
|
||||||
|
this.comboBoxDeviceSelector.Name = "comboBoxDeviceSelector";
|
||||||
|
this.comboBoxDeviceSelector.Size = new System.Drawing.Size(480, 21);
|
||||||
|
this.comboBoxDeviceSelector.TabIndex = 3;
|
||||||
|
this.comboBoxDeviceSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxDeviceSelector_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 27);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(41, 13);
|
||||||
|
this.label2.TabIndex = 4;
|
||||||
|
this.label2.Text = "Device";
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(548, 557);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.comboBoxDeviceSelector);
|
||||||
|
this.Controls.Add(this.hScrollBarRatio);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.DoubleBuffered = true;
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
|
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.HScrollBar hScrollBarRatio;
|
||||||
|
private System.Windows.Forms.ComboBox comboBoxDeviceSelector;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
185
examples/ImageCrossFade/Form1.cs
Normal file
185
examples/ImageCrossFade/Form1.cs
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using OpenCLNet;
|
||||||
|
|
||||||
|
namespace ImageCrossFade
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
bool Initialized = false;
|
||||||
|
|
||||||
|
Bitmap InputBitmap0;
|
||||||
|
Bitmap InputBitmap1;
|
||||||
|
BitmapData InputBitmapData0;
|
||||||
|
BitmapData InputBitmapData1;
|
||||||
|
Bitmap OutputBitmap;
|
||||||
|
|
||||||
|
SimpleOCLHelper OCLHelper;
|
||||||
|
Mem InputBuffer0;
|
||||||
|
Mem InputBuffer1;
|
||||||
|
Kernel CrossFadeKernel;
|
||||||
|
IntPtr[] CrossFadeGlobalWorkSize = new IntPtr[2];
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InitializeOpenCL();
|
||||||
|
SetupBitmaps();
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show( ex.Message, "Initiation failed...");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads two bitmaps and locks them for the duration of the program.
|
||||||
|
/// Also creates two OpenCL buffers that map to the locked images
|
||||||
|
/// </summary>
|
||||||
|
private void SetupBitmaps()
|
||||||
|
{
|
||||||
|
InputBitmap0 = (Bitmap)Bitmap.FromFile(@"Input0.png");
|
||||||
|
InputBitmap1 = (Bitmap)Bitmap.FromFile(@"Input1.png");
|
||||||
|
if (InputBitmap1.Size != InputBitmap0.Size)
|
||||||
|
InputBitmap1 = new Bitmap(InputBitmap1, InputBitmap0.Size);
|
||||||
|
OutputBitmap = new Bitmap(InputBitmap0);
|
||||||
|
|
||||||
|
InputBitmapData0 = InputBitmap0.LockBits(new Rectangle(0, 0, InputBitmap0.Width, InputBitmap0.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
InputBitmapData1 = InputBitmap1.LockBits(new Rectangle(0, 0, InputBitmap1.Width, InputBitmap1.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
InputBuffer0 = OCLHelper.Context.CreateBuffer(MemFlags.USE_HOST_PTR, InputBitmapData0.Stride * InputBitmapData0.Height, InputBitmapData0.Scan0);
|
||||||
|
InputBuffer1 = OCLHelper.Context.CreateBuffer(MemFlags.USE_HOST_PTR, InputBitmapData1.Stride * InputBitmapData1.Height, InputBitmapData1.Scan0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a SimpleOCLHelper, using platform 0, default device type and a source containing test functions.
|
||||||
|
/// The Helper automatically compiles and creates kernels.
|
||||||
|
/// We can then extract named kernels using the GetKernel method.
|
||||||
|
///
|
||||||
|
/// For more advanced scenarios, one might use the functions in the Platform class
|
||||||
|
/// to query devices, create contexts etc. Platforms can be enumerated using
|
||||||
|
/// for( int i=0; i<OpenCL.NumberofPlatforms; i++ )
|
||||||
|
/// Platform p = OpenCL.GetPlatform(i);
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeOpenCL()
|
||||||
|
{
|
||||||
|
if (OpenCL.NumberOfPlatforms == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("OpenCL not available");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
string source = File.ReadAllText(@"OpenCLFunctions.cl");
|
||||||
|
|
||||||
|
OCLHelper = new SimpleOCLHelper(OpenCL.GetPlatform(0), DeviceType.ALL, source );
|
||||||
|
|
||||||
|
for (int i = 0; i < OCLHelper.Devices.Length; i++)
|
||||||
|
comboBoxDeviceSelector.Items.Add(OCLHelper.Devices[i].Vendor+":"+OCLHelper.Devices[i].Name);
|
||||||
|
comboBoxDeviceSelector.SelectedIndex = 0;
|
||||||
|
|
||||||
|
CrossFadeKernel = OCLHelper.GetKernel("CrossFade");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Launch the CrossFadeKernel
|
||||||
|
///
|
||||||
|
/// First we set its arguments,
|
||||||
|
/// then we enqueue the kernel using EnqueueNDRangeKernel,
|
||||||
|
/// and finally, map the buffer for reading to make sure
|
||||||
|
/// there aren't any cache issues when OpenCL completes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ratio"></param>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="height"></param>
|
||||||
|
/// <param name="input0"></param>
|
||||||
|
/// <param name="inputStride0"></param>
|
||||||
|
/// <param name="input1"></param>
|
||||||
|
/// <param name="inputStride1"></param>
|
||||||
|
/// <param name="output"></param>
|
||||||
|
private void DoCrossFade( float ratio,
|
||||||
|
int width, int height,
|
||||||
|
Mem input0, int inputStride0,
|
||||||
|
Mem input1, int inputStride1,
|
||||||
|
BitmapData output )
|
||||||
|
{
|
||||||
|
Mem outputBuffer;
|
||||||
|
|
||||||
|
int deviceIndex = comboBoxDeviceSelector.SelectedIndex;
|
||||||
|
|
||||||
|
outputBuffer = OCLHelper.Context.CreateBuffer(MemFlags.USE_HOST_PTR, output.Stride * output.Height, output.Scan0);
|
||||||
|
|
||||||
|
CrossFadeGlobalWorkSize[0] = (IntPtr)width;
|
||||||
|
CrossFadeGlobalWorkSize[1] = (IntPtr)height;
|
||||||
|
CrossFadeKernel.SetArg(0, ratio);
|
||||||
|
CrossFadeKernel.SetArg(1, width);
|
||||||
|
CrossFadeKernel.SetArg(2, height);
|
||||||
|
CrossFadeKernel.SetArg(3, input0);
|
||||||
|
CrossFadeKernel.SetArg(4, inputStride0);
|
||||||
|
CrossFadeKernel.SetArg(5, input1);
|
||||||
|
CrossFadeKernel.SetArg(6, inputStride1);
|
||||||
|
CrossFadeKernel.SetArg(7, outputBuffer);
|
||||||
|
CrossFadeKernel.SetArg(8, output.Stride);
|
||||||
|
|
||||||
|
OCLHelper.CQs[deviceIndex].EnqueueNDRangeKernel(CrossFadeKernel, 2, null, CrossFadeGlobalWorkSize, null);
|
||||||
|
OCLHelper.CQs[deviceIndex].EnqueueBarrier();
|
||||||
|
IntPtr p = OCLHelper.CQs[deviceIndex].EnqueueMapBuffer(outputBuffer, true, MapFlags.READ, IntPtr.Zero, (IntPtr)(output.Stride * output.Height));
|
||||||
|
OCLHelper.CQs[deviceIndex].EnqueueUnmapMemObject(outputBuffer, p);
|
||||||
|
OCLHelper.CQs[deviceIndex].Finish();
|
||||||
|
outputBuffer.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
|
||||||
|
if (!Initialized)
|
||||||
|
{
|
||||||
|
g.FillRectangle(new SolidBrush(BackColor), 0, 0, Width, Height);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g.FillRectangle(new SolidBrush(BackColor), 0, 0, Width, Height);
|
||||||
|
g.DrawImageUnscaled(OutputBitmap, 0, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaintBackground(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hScrollBarRatio_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!Initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BitmapData bd = OutputBitmap.LockBits(new Rectangle(0, 0, OutputBitmap.Width, OutputBitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
DoCrossFade(hScrollBarRatio.Value*0.01f,
|
||||||
|
InputBitmapData0.Width, InputBitmapData0.Height,
|
||||||
|
InputBuffer0, InputBitmapData0.Stride,
|
||||||
|
InputBuffer1, InputBitmapData1.Stride,
|
||||||
|
bd);
|
||||||
|
OutputBitmap.UnlockBits(bd);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxDeviceSelector_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
examples/ImageCrossFade/Form1.resx
Normal file
120
examples/ImageCrossFade/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
184
examples/ImageCrossFade/ImageCrossFade.csproj
Normal file
184
examples/ImageCrossFade/ImageCrossFade.csproj
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{F7D24581-6EA3-4D20-A722-1BACC34B94AA}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ImageCrossFade</RootNamespace>
|
||||||
|
<AssemblyName>ImageCrossFade</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="OpenCLFunctions.cl">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{758285C6-1ACA-458A-9906-EE6701D5AF87}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\..\shared\Input0.png">
|
||||||
|
<Link>Input0.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\shared\Input1.png">
|
||||||
|
<Link>Input1.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
22
examples/ImageCrossFade/ImageCrossFade.csproj.user
Normal file
22
examples/ImageCrossFade/ImageCrossFade.csproj.user
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
20
examples/ImageCrossFade/OpenCLFunctions.cl
Normal file
20
examples/ImageCrossFade/OpenCLFunctions.cl
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
kernel void CrossFade( float ratio,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
global uchar* pInput0,
|
||||||
|
int inputStride0,
|
||||||
|
global uchar* pInput1,
|
||||||
|
int inputStride1,
|
||||||
|
global uchar* pOutput,
|
||||||
|
int outputStride )
|
||||||
|
{
|
||||||
|
size_t x = get_global_id(0);
|
||||||
|
size_t y = get_global_id(1);
|
||||||
|
global uchar4* pI0 = (global uchar4*)(pInput0+y*inputStride0);
|
||||||
|
global uchar4* pI1 = (global uchar4*)(pInput1+y*inputStride1);
|
||||||
|
global uchar4* pO = (global uchar4*)(pOutput+y*outputStride);
|
||||||
|
uchar4 mixed;
|
||||||
|
|
||||||
|
mixed = convert_uchar4_sat_rte( mix( convert_float4(pI0[x]), convert_float4(pI1[x]), ratio ) );
|
||||||
|
pO[x] = mixed;
|
||||||
|
}
|
21
examples/ImageCrossFade/Program.cs
Normal file
21
examples/ImageCrossFade/Program.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ImageCrossFade
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
examples/ImageCrossFade/Properties/AssemblyInfo.cs
Normal file
36
examples/ImageCrossFade/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ImageFilter")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("ImageFilter")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("315618e7-3602-40a3-bf55-fe4ece44e3e2")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
examples/ImageCrossFade/Properties/Resources.Designer.cs
generated
Normal file
63
examples/ImageCrossFade/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrossFade.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageCrossFade.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
examples/ImageCrossFade/Properties/Resources.resx
Normal file
117
examples/ImageCrossFade/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
26
examples/ImageCrossFade/Properties/Settings.Designer.cs
generated
Normal file
26
examples/ImageCrossFade/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrossFade.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
examples/ImageCrossFade/Properties/Settings.settings
Normal file
7
examples/ImageCrossFade/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
214
examples/OpenCLImageTest/Form1.Designer.cs
generated
Normal file
214
examples/OpenCLImageTest/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
namespace OpenCLImageTest
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonScaleImage = new System.Windows.Forms.Button();
|
||||||
|
this.groupBoxScaled = new System.Windows.Forms.GroupBox();
|
||||||
|
this.panelScaled = new System.Windows.Forms.Panel();
|
||||||
|
this.groupBoxOriginal = new System.Windows.Forms.GroupBox();
|
||||||
|
this.panelOriginal = new System.Windows.Forms.Panel();
|
||||||
|
this.comboBoxOpenCLDevices = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.labelImageSupportIndicator = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxOpenCLPlatforms = new System.Windows.Forms.ComboBox();
|
||||||
|
this.groupBoxCallBackEvents = new System.Windows.Forms.GroupBox();
|
||||||
|
this.textBoxCallBackEvents = new System.Windows.Forms.TextBox();
|
||||||
|
this.groupBoxScaled.SuspendLayout();
|
||||||
|
this.groupBoxOriginal.SuspendLayout();
|
||||||
|
this.groupBoxCallBackEvents.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonScaleImage
|
||||||
|
//
|
||||||
|
this.buttonScaleImage.Location = new System.Drawing.Point(753, 455);
|
||||||
|
this.buttonScaleImage.Name = "buttonScaleImage";
|
||||||
|
this.buttonScaleImage.Size = new System.Drawing.Size(93, 24);
|
||||||
|
this.buttonScaleImage.TabIndex = 0;
|
||||||
|
this.buttonScaleImage.Text = "Scale Image";
|
||||||
|
this.buttonScaleImage.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonScaleImage.Click += new System.EventHandler(this.buttonScaleImage_Click);
|
||||||
|
//
|
||||||
|
// groupBoxScaled
|
||||||
|
//
|
||||||
|
this.groupBoxScaled.Controls.Add(this.panelScaled);
|
||||||
|
this.groupBoxScaled.Location = new System.Drawing.Point(262, 0);
|
||||||
|
this.groupBoxScaled.Name = "groupBoxScaled";
|
||||||
|
this.groupBoxScaled.Size = new System.Drawing.Size(587, 385);
|
||||||
|
this.groupBoxScaled.TabIndex = 1;
|
||||||
|
this.groupBoxScaled.TabStop = false;
|
||||||
|
this.groupBoxScaled.Text = "Scaled";
|
||||||
|
//
|
||||||
|
// panelScaled
|
||||||
|
//
|
||||||
|
this.panelScaled.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panelScaled.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.panelScaled.Name = "panelScaled";
|
||||||
|
this.panelScaled.Size = new System.Drawing.Size(581, 366);
|
||||||
|
this.panelScaled.TabIndex = 0;
|
||||||
|
this.panelScaled.Paint += new System.Windows.Forms.PaintEventHandler(this.panelScaled_Paint);
|
||||||
|
//
|
||||||
|
// groupBoxOriginal
|
||||||
|
//
|
||||||
|
this.groupBoxOriginal.Controls.Add(this.panelOriginal);
|
||||||
|
this.groupBoxOriginal.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.groupBoxOriginal.Name = "groupBoxOriginal";
|
||||||
|
this.groupBoxOriginal.Size = new System.Drawing.Size(256, 256);
|
||||||
|
this.groupBoxOriginal.TabIndex = 2;
|
||||||
|
this.groupBoxOriginal.TabStop = false;
|
||||||
|
this.groupBoxOriginal.Text = "Original";
|
||||||
|
//
|
||||||
|
// panelOriginal
|
||||||
|
//
|
||||||
|
this.panelOriginal.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panelOriginal.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.panelOriginal.Name = "panelOriginal";
|
||||||
|
this.panelOriginal.Size = new System.Drawing.Size(250, 237);
|
||||||
|
this.panelOriginal.TabIndex = 0;
|
||||||
|
this.panelOriginal.Paint += new System.Windows.Forms.PaintEventHandler(this.panelOriginal_Paint);
|
||||||
|
//
|
||||||
|
// comboBoxOpenCLDevices
|
||||||
|
//
|
||||||
|
this.comboBoxOpenCLDevices.FormattingEnabled = true;
|
||||||
|
this.comboBoxOpenCLDevices.Location = new System.Drawing.Point(86, 429);
|
||||||
|
this.comboBoxOpenCLDevices.Name = "comboBoxOpenCLDevices";
|
||||||
|
this.comboBoxOpenCLDevices.Size = new System.Drawing.Size(763, 21);
|
||||||
|
this.comboBoxOpenCLDevices.TabIndex = 3;
|
||||||
|
this.comboBoxOpenCLDevices.SelectedIndexChanged += new System.EventHandler(this.comboBoxOpenCLDevices_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(-3, 432);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(86, 13);
|
||||||
|
this.label1.TabIndex = 4;
|
||||||
|
this.label1.Text = "OpenCL Device:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(-3, 461);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(77, 13);
|
||||||
|
this.label2.TabIndex = 5;
|
||||||
|
this.label2.Text = "Image support:";
|
||||||
|
//
|
||||||
|
// labelImageSupportIndicator
|
||||||
|
//
|
||||||
|
this.labelImageSupportIndicator.AutoSize = true;
|
||||||
|
this.labelImageSupportIndicator.Location = new System.Drawing.Point(83, 461);
|
||||||
|
this.labelImageSupportIndicator.Name = "labelImageSupportIndicator";
|
||||||
|
this.labelImageSupportIndicator.Size = new System.Drawing.Size(0, 13);
|
||||||
|
this.labelImageSupportIndicator.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(-3, 405);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(90, 13);
|
||||||
|
this.label3.TabIndex = 8;
|
||||||
|
this.label3.Text = "OpenCL Platform:";
|
||||||
|
//
|
||||||
|
// comboBoxOpenCLPlatforms
|
||||||
|
//
|
||||||
|
this.comboBoxOpenCLPlatforms.FormattingEnabled = true;
|
||||||
|
this.comboBoxOpenCLPlatforms.Location = new System.Drawing.Point(86, 402);
|
||||||
|
this.comboBoxOpenCLPlatforms.Name = "comboBoxOpenCLPlatforms";
|
||||||
|
this.comboBoxOpenCLPlatforms.Size = new System.Drawing.Size(763, 21);
|
||||||
|
this.comboBoxOpenCLPlatforms.TabIndex = 7;
|
||||||
|
this.comboBoxOpenCLPlatforms.SelectedIndexChanged += new System.EventHandler(this.comboBoxOpenCLPlatforms_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// groupBoxCallBackEvents
|
||||||
|
//
|
||||||
|
this.groupBoxCallBackEvents.Controls.Add(this.textBoxCallBackEvents);
|
||||||
|
this.groupBoxCallBackEvents.Location = new System.Drawing.Point(3, 263);
|
||||||
|
this.groupBoxCallBackEvents.Name = "groupBoxCallBackEvents";
|
||||||
|
this.groupBoxCallBackEvents.Size = new System.Drawing.Size(249, 118);
|
||||||
|
this.groupBoxCallBackEvents.TabIndex = 9;
|
||||||
|
this.groupBoxCallBackEvents.TabStop = false;
|
||||||
|
this.groupBoxCallBackEvents.Text = "CallBack Events";
|
||||||
|
//
|
||||||
|
// textBoxCallBackEvents
|
||||||
|
//
|
||||||
|
this.textBoxCallBackEvents.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.textBoxCallBackEvents.Location = new System.Drawing.Point(3, 16);
|
||||||
|
this.textBoxCallBackEvents.Multiline = true;
|
||||||
|
this.textBoxCallBackEvents.Name = "textBoxCallBackEvents";
|
||||||
|
this.textBoxCallBackEvents.ReadOnly = true;
|
||||||
|
this.textBoxCallBackEvents.Size = new System.Drawing.Size(243, 99);
|
||||||
|
this.textBoxCallBackEvents.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(853, 485);
|
||||||
|
this.Controls.Add(this.groupBoxCallBackEvents);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.comboBoxOpenCLPlatforms);
|
||||||
|
this.Controls.Add(this.labelImageSupportIndicator);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.comboBoxOpenCLDevices);
|
||||||
|
this.Controls.Add(this.groupBoxScaled);
|
||||||
|
this.Controls.Add(this.buttonScaleImage);
|
||||||
|
this.Controls.Add(this.groupBoxOriginal);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "OpenCL Image Test";
|
||||||
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
|
this.groupBoxScaled.ResumeLayout(false);
|
||||||
|
this.groupBoxOriginal.ResumeLayout(false);
|
||||||
|
this.groupBoxCallBackEvents.ResumeLayout(false);
|
||||||
|
this.groupBoxCallBackEvents.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonScaleImage;
|
||||||
|
private System.Windows.Forms.GroupBox groupBoxScaled;
|
||||||
|
private System.Windows.Forms.GroupBox groupBoxOriginal;
|
||||||
|
private System.Windows.Forms.ComboBox comboBoxOpenCLDevices;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
private System.Windows.Forms.Label labelImageSupportIndicator;
|
||||||
|
private System.Windows.Forms.Panel panelScaled;
|
||||||
|
private System.Windows.Forms.Panel panelOriginal;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.ComboBox comboBoxOpenCLPlatforms;
|
||||||
|
private System.Windows.Forms.GroupBox groupBoxCallBackEvents;
|
||||||
|
private System.Windows.Forms.TextBox textBoxCallBackEvents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
341
examples/OpenCLImageTest/Form1.cs
Normal file
341
examples/OpenCLImageTest/Form1.cs
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using OpenCLNet;
|
||||||
|
using CL = OpenCLNet;
|
||||||
|
|
||||||
|
namespace OpenCLImageTest
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
string OpenCLSource;
|
||||||
|
Bitmap TestImage;
|
||||||
|
Bitmap TestImageOutput;
|
||||||
|
|
||||||
|
// Currently selected platform
|
||||||
|
Platform oclPlatform;
|
||||||
|
// All devices in the currently selected platform
|
||||||
|
Device[] oclDevices;
|
||||||
|
// Currently selected device
|
||||||
|
Device oclDevice;
|
||||||
|
// Currently active context
|
||||||
|
Context oclContext;
|
||||||
|
// Command queue to selected device
|
||||||
|
CommandQueue oclCQ;
|
||||||
|
|
||||||
|
// Current program+data
|
||||||
|
CL.Program oclProgram;
|
||||||
|
CL.Image OCLInputImage;
|
||||||
|
CL.Image OCLOutputImage;
|
||||||
|
Sampler OCLSampler;
|
||||||
|
Kernel FilterKernel;
|
||||||
|
|
||||||
|
bool oclFullyInitialized = false;
|
||||||
|
ContextNotify oclContextNotify;
|
||||||
|
List<string> CallBackEventList = new List<string>();
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
oclContextNotify = new ContextNotify(OpenCLContextNotifyCallBack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetupOpenCL()
|
||||||
|
{
|
||||||
|
if (OpenCL.NumberOfPlatforms == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("OpenCL not available");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PopulateOCLPlatformsComboBox()
|
||||||
|
{
|
||||||
|
comboBoxOpenCLPlatforms.Items.Clear();
|
||||||
|
for (int platformID = 0; platformID < OpenCL.NumberOfPlatforms; platformID++)
|
||||||
|
{
|
||||||
|
Platform p = OpenCL.GetPlatform(platformID);
|
||||||
|
|
||||||
|
comboBoxOpenCLPlatforms.Items.Add(p.Vendor+":"+p.Name+" "+p.Version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PopulateOCLDevicesComboBox(Platform p, DeviceType deviceType)
|
||||||
|
{
|
||||||
|
Device[] devices = p.QueryDevices(deviceType);
|
||||||
|
comboBoxOpenCLDevices.Items.Clear();
|
||||||
|
foreach (Device d in devices)
|
||||||
|
{
|
||||||
|
comboBoxOpenCLDevices.Items.Add(d.Vendor + " " + d.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateContext( Platform platform, Device device )
|
||||||
|
{
|
||||||
|
IntPtr[] contextProperties = new IntPtr[]
|
||||||
|
{
|
||||||
|
(IntPtr)ContextProperties.PLATFORM, platform.PlatformID,
|
||||||
|
IntPtr.Zero, IntPtr.Zero
|
||||||
|
};
|
||||||
|
|
||||||
|
Device[] devices = new Device[]
|
||||||
|
{
|
||||||
|
device
|
||||||
|
};
|
||||||
|
|
||||||
|
oclContext = platform.CreateContext(contextProperties, devices, oclContextNotify, IntPtr.Zero);
|
||||||
|
oclCQ = oclContext.CreateCommandQueue(device, CommandQueueProperties.PROFILING_ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenCLContextNotifyCallBack(string errInfo, byte[] privateInfo, IntPtr cb, IntPtr userData)
|
||||||
|
{
|
||||||
|
CallBackEventList.Add( errInfo );
|
||||||
|
textBoxCallBackEvents.Lines = CallBackEventList.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildOCLSource(string source)
|
||||||
|
{
|
||||||
|
oclProgram = oclContext.CreateProgramWithSource(source);
|
||||||
|
oclProgram.Build();
|
||||||
|
FilterKernel = oclProgram.CreateKernel("FilterImage");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOCLImages(Context context)
|
||||||
|
{
|
||||||
|
OCLInputImage = CreateOCLBitmapFromBitmap(TestImage);
|
||||||
|
OCLOutputImage = oclContext.CreateImage2D(MemFlags.WRITE_ONLY, CL.ImageFormat.RGBA8U, panelScaled.Width, panelScaled.Height, 0, IntPtr.Zero);
|
||||||
|
OCLSampler = oclContext.CreateSampler(true, AddressingMode.CLAMP_TO_EDGE, FilterMode.LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseDeviceResources()
|
||||||
|
{
|
||||||
|
oclFullyInitialized = false;
|
||||||
|
if (OCLSampler != null)
|
||||||
|
{
|
||||||
|
OCLSampler.Dispose();
|
||||||
|
OCLSampler = null;
|
||||||
|
}
|
||||||
|
if (OCLInputImage != null)
|
||||||
|
{
|
||||||
|
OCLInputImage.Dispose();
|
||||||
|
OCLInputImage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OCLOutputImage != null)
|
||||||
|
{
|
||||||
|
OCLOutputImage.Dispose();
|
||||||
|
OCLOutputImage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FilterKernel != null)
|
||||||
|
{
|
||||||
|
FilterKernel.Dispose();
|
||||||
|
FilterKernel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oclProgram != null)
|
||||||
|
{
|
||||||
|
oclProgram.Dispose();
|
||||||
|
oclProgram = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oclCQ != null)
|
||||||
|
{
|
||||||
|
oclCQ.Dispose();
|
||||||
|
oclCQ = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oclContext != null)
|
||||||
|
{
|
||||||
|
oclContext.Dispose();
|
||||||
|
oclContext = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
TestImage = (Bitmap)Bitmap.FromFile(@"Input0.png");
|
||||||
|
TestImage = new Bitmap(TestImage, 256, 256);
|
||||||
|
TestImageOutput = new Bitmap(panelScaled.Width, panelScaled.Height, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
if (OpenCL.NumberOfPlatforms <= 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("OpenCL not available");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
PopulateOCLPlatformsComboBox();
|
||||||
|
oclPlatform = OpenCL.GetPlatform(0);
|
||||||
|
comboBoxOpenCLPlatforms.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CL.Image CreateOCLBitmapFromBitmap(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
CL.Image oclImage;
|
||||||
|
|
||||||
|
BitmapData bd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
oclImage = oclContext.CreateImage2D((MemFlags)((long)MemFlags.READ_ONLY | (long)MemFlags.COPY_HOST_PTR),
|
||||||
|
CL.ImageFormat.RGBA8U, bd.Width, bd.Height, bd.Stride, bd.Scan0);
|
||||||
|
bitmap.UnlockBits(bd);
|
||||||
|
return oclImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe void CopyOCLBitmapToBitmap(Mem oclBitmap, Bitmap bitmap)
|
||||||
|
{
|
||||||
|
IntPtr[] origin = new IntPtr[3];
|
||||||
|
IntPtr[] region = new IntPtr[3];
|
||||||
|
Mem buffer;
|
||||||
|
|
||||||
|
BitmapData bd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
buffer = oclContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY | (long)MemFlags.USE_HOST_PTR), bd.Height * bd.Stride, bd.Scan0);
|
||||||
|
origin[0] = (IntPtr)0;
|
||||||
|
origin[1] = (IntPtr)0;
|
||||||
|
origin[2] = (IntPtr)0;
|
||||||
|
region[0] = (IntPtr)bd.Width;
|
||||||
|
region[1] = (IntPtr)bd.Height;
|
||||||
|
region[2] = (IntPtr)1;
|
||||||
|
oclCQ.EnqueueCopyImageToBuffer(oclBitmap, buffer, origin, region, IntPtr.Zero);
|
||||||
|
oclCQ.EnqueueBarrier();
|
||||||
|
IntPtr p = oclCQ.EnqueueMapBuffer(buffer, true, MapFlags.READ, IntPtr.Zero, (IntPtr)(bd.Height * bd.Stride));
|
||||||
|
oclCQ.EnqueueUnmapMemObject(buffer, p);
|
||||||
|
oclCQ.Finish();
|
||||||
|
buffer.Dispose();
|
||||||
|
bitmap.UnlockBits(bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScaleImage()
|
||||||
|
{
|
||||||
|
IntPtr[] globalWorkSize = new IntPtr[3];
|
||||||
|
|
||||||
|
globalWorkSize[0] = (IntPtr)TestImageOutput.Width;
|
||||||
|
globalWorkSize[1] = (IntPtr)TestImageOutput.Height;
|
||||||
|
FilterKernel.SetArg(0, 0.0f);
|
||||||
|
FilterKernel.SetArg(1, 0.0f);
|
||||||
|
FilterKernel.SetArg(2, 1.0f);
|
||||||
|
FilterKernel.SetArg(3, 1.0f);
|
||||||
|
FilterKernel.SetArg(4, 0.0f);
|
||||||
|
FilterKernel.SetArg(5, 0.0f);
|
||||||
|
FilterKernel.SetArg(6, 1.0f);
|
||||||
|
FilterKernel.SetArg(7, 1.0f);
|
||||||
|
FilterKernel.SetArg(8, OCLInputImage);
|
||||||
|
FilterKernel.SetArg(9, OCLOutputImage);
|
||||||
|
FilterKernel.SetArg(10, OCLSampler);
|
||||||
|
oclCQ.EnqueueNDRangeKernel(FilterKernel, 2, null, globalWorkSize, null);
|
||||||
|
oclCQ.EnqueueBarrier();
|
||||||
|
CopyOCLBitmapToBitmap(OCLOutputImage, TestImageOutput);
|
||||||
|
oclCQ.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Setup();
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ocle.Message);
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonScaleImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (oclFullyInitialized)
|
||||||
|
{
|
||||||
|
ScaleImage();
|
||||||
|
}
|
||||||
|
groupBoxScaled.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelOriginal_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
|
||||||
|
if (TestImage != null)
|
||||||
|
g.DrawImageUnscaled(TestImage, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelScaled_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
|
||||||
|
if (oclFullyInitialized)
|
||||||
|
{
|
||||||
|
if (TestImageOutput != null)
|
||||||
|
g.DrawImageUnscaled(TestImageOutput, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxOpenCLDevices_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
bool supportsImages;
|
||||||
|
bool supportsImageFormat;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReleaseDeviceResources();
|
||||||
|
panelScaled.Refresh();
|
||||||
|
|
||||||
|
oclDevice = oclDevices[comboBoxOpenCLDevices.SelectedIndex];
|
||||||
|
CreateContext(oclPlatform, oclDevice);
|
||||||
|
supportsImages = oclDevice.ImageSupport;
|
||||||
|
supportsImageFormat = oclContext.SupportsImageFormat(MemFlags.READ_WRITE, MemObjectType.IMAGE2D, ChannelOrder.RGBA, ChannelType.UNSIGNED_INT8);
|
||||||
|
if (oclDevice.ImageSupport && supportsImageFormat)
|
||||||
|
{
|
||||||
|
buttonScaleImage.Enabled = true;
|
||||||
|
labelImageSupportIndicator.Text = "Yes";
|
||||||
|
OpenCLSource = File.ReadAllText(@"OpenCLFunctions.cl");
|
||||||
|
BuildOCLSource(OpenCLSource);
|
||||||
|
CreateOCLImages(oclContext);
|
||||||
|
oclFullyInitialized = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonScaleImage.Enabled = false;
|
||||||
|
labelImageSupportIndicator.Text = "No " + (supportsImageFormat ? "(No Image support at all)" : "(Images supported, but no support for RGBA8888)");
|
||||||
|
oclContext = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OpenCLBuildException oclbe)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, oclbe.BuildLogs[0], "OpenCL build error");
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, ocle.Message, "OpenCL exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxOpenCLPlatforms_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReleaseDeviceResources();
|
||||||
|
|
||||||
|
oclPlatform = OpenCL.GetPlatform(comboBoxOpenCLPlatforms.SelectedIndex);
|
||||||
|
oclDevices = oclPlatform.QueryDevices(DeviceType.ALL);
|
||||||
|
PopulateOCLDevicesComboBox(oclPlatform, DeviceType.ALL);
|
||||||
|
if (comboBoxOpenCLDevices.Items.Count > 0)
|
||||||
|
{
|
||||||
|
comboBoxOpenCLDevices.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oclDevice = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, ocle.Message, "OpenCL exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
examples/OpenCLImageTest/Form1.resx
Normal file
120
examples/OpenCLImageTest/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
58
examples/OpenCLImageTest/OpenCLFunctions.cl
Normal file
58
examples/OpenCLImageTest/OpenCLFunctions.cl
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
kernel void FilterImage( float inputLeft,
|
||||||
|
float inputTop,
|
||||||
|
float inputWidth,
|
||||||
|
float inputHeight,
|
||||||
|
float outputLeft,
|
||||||
|
float outputTop,
|
||||||
|
float outputWidth,
|
||||||
|
float outputHeight,
|
||||||
|
read_only image2d_t input,
|
||||||
|
write_only image2d_t output,
|
||||||
|
sampler_t sampler )
|
||||||
|
{
|
||||||
|
size_t x = get_global_id(0);
|
||||||
|
size_t y = get_global_id(1);
|
||||||
|
int width = get_global_size(0);
|
||||||
|
int height = get_global_size(1);
|
||||||
|
|
||||||
|
float nX = x/(float)(width-1);
|
||||||
|
float nY = y/(float)(height-1);
|
||||||
|
float inputX = inputLeft+inputWidth*nX;
|
||||||
|
float inputY = inputTop+inputHeight*nY;
|
||||||
|
float outputX = outputLeft+width*outputWidth*nX;
|
||||||
|
float outputY = outputTop+height*outputHeight*nY;
|
||||||
|
float4 rgba = read_imagef( input, sampler, (float2)(inputX,inputY) );
|
||||||
|
write_imagef(output,convert_int2((float2)(outputX,outputY)),rgba);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
kernel void FilterHorz( read_only image2d_t input,
|
||||||
|
write_only image2d_t output,
|
||||||
|
sampler_t sampler,
|
||||||
|
local float4* pFilter,
|
||||||
|
int filterWidth )
|
||||||
|
{
|
||||||
|
int width = get_global_size(0);
|
||||||
|
int height = get_global_size(1);
|
||||||
|
float pixelWidth = 1.0f/width;
|
||||||
|
float pixelHeight = 1.0f/height;
|
||||||
|
float y = pixelHeight/2+get_global_id(1)*pixelHeight;
|
||||||
|
int filterWidthHalf = filterWidth/2;
|
||||||
|
|
||||||
|
for( float x=pixelWidth/2; x<1.0f; x+=pixelWidth )
|
||||||
|
{
|
||||||
|
float4 rgba = 0;
|
||||||
|
for( int df=0; df<filterWidth; df++ )
|
||||||
|
rgba += read_imagef( input, sampler, (float2)(x+(df-filterWidthHalf)*pixelWidth,y) )*pFilter[df];
|
||||||
|
write_imagef(output,convert_int2((float2)(x*width,y*height)),rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
float nX = x/(float)(width-1);
|
||||||
|
float nY = y/(float)(height-1);
|
||||||
|
float inputX = inputLeft+inputWidth*nX;
|
||||||
|
float inputY = inputTop+inputHeight*nY;
|
||||||
|
float outputX = outputLeft+width*outputWidth*nX;
|
||||||
|
float outputY = outputTop+height*outputHeight*nY;
|
||||||
|
float4 rgba = read_imagef( input, sampler, (float2)(inputX,inputY) );
|
||||||
|
write_imagef(output,convert_int2((float2)(outputX,outputY)),rgba);
|
||||||
|
}
|
||||||
|
*/
|
186
examples/OpenCLImageTest/OpenCLImageTest.csproj
Normal file
186
examples/OpenCLImageTest/OpenCLImageTest.csproj
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{64E8D6E8-B245-47E4-BA61-9BD000E187FA}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenCLImageTest</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLImageTest</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="OpenCLFunctions.cl">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{758285C6-1ACA-458A-9906-EE6701D5AF87}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\..\shared\Input0.png">
|
||||||
|
<Link>Input0.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
31
examples/OpenCLImageTest/OpenCLImageTest.csproj.user
Normal file
31
examples/OpenCLImageTest/OpenCLImageTest.csproj.user
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
21
examples/OpenCLImageTest/Program.cs
Normal file
21
examples/OpenCLImageTest/Program.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace OpenCLImageTest
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
examples/OpenCLImageTest/Properties/AssemblyInfo.cs
Normal file
36
examples/OpenCLImageTest/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenCLImageTest")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("OpenCLImageTest")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("d51ba871-9ff1-4d35-a993-6d6d60ecfd07")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
examples/OpenCLImageTest/Properties/Resources.Designer.cs
generated
Normal file
63
examples/OpenCLImageTest/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OpenCLImageTest.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCLImageTest.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
examples/OpenCLImageTest/Properties/Resources.resx
Normal file
117
examples/OpenCLImageTest/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
26
examples/OpenCLImageTest/Properties/Settings.Designer.cs
generated
Normal file
26
examples/OpenCLImageTest/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OpenCLImageTest.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
examples/OpenCLImageTest/Properties/Settings.settings
Normal file
7
examples/OpenCLImageTest/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
106
examples/OpenCLTest/Form1.Designer.cs
generated
Normal file
106
examples/OpenCLTest/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
namespace OpenCLTest
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
if( disposing && (components != null) )
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose( disposing );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.commandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.startToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.stopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.timer = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.commandToolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(656, 24);
|
||||||
|
this.menuStrip.TabIndex = 0;
|
||||||
|
this.menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// commandToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.commandToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.startToolStripMenuItem,
|
||||||
|
this.stopToolStripMenuItem});
|
||||||
|
this.commandToolStripMenuItem.Name = "commandToolStripMenuItem";
|
||||||
|
this.commandToolStripMenuItem.Size = new System.Drawing.Size(76, 20);
|
||||||
|
this.commandToolStripMenuItem.Text = "&Command";
|
||||||
|
//
|
||||||
|
// startToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.startToolStripMenuItem.Name = "startToolStripMenuItem";
|
||||||
|
this.startToolStripMenuItem.Size = new System.Drawing.Size(98, 22);
|
||||||
|
this.startToolStripMenuItem.Text = "&Start";
|
||||||
|
this.startToolStripMenuItem.Click += new System.EventHandler(this.startToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// stopToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.stopToolStripMenuItem.Enabled = false;
|
||||||
|
this.stopToolStripMenuItem.Name = "stopToolStripMenuItem";
|
||||||
|
this.stopToolStripMenuItem.Size = new System.Drawing.Size(98, 22);
|
||||||
|
this.stopToolStripMenuItem.Text = "&Stop";
|
||||||
|
this.stopToolStripMenuItem.Click += new System.EventHandler(this.stopToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// timer
|
||||||
|
//
|
||||||
|
this.timer.Interval = 3;
|
||||||
|
this.timer.Tick += new System.EventHandler(this.timer_Tick);
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(656, 331);
|
||||||
|
this.Controls.Add(this.menuStrip);
|
||||||
|
this.MainMenuStrip = this.menuStrip;
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem commandToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem startToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem stopToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.Timer timer;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
224
examples/OpenCLTest/Form1.cs
Normal file
224
examples/OpenCLTest/Form1.cs
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using OpenCLNet;
|
||||||
|
|
||||||
|
namespace OpenCLTest
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
Mandelbrot Mandelbrot;
|
||||||
|
int FromSetPtr = 0;
|
||||||
|
int ToSetPtr = 0;
|
||||||
|
float[,] Sets = new float[2, 4]
|
||||||
|
{
|
||||||
|
{-2.0f, 2.0f, 2.0f, -2.0f},
|
||||||
|
{-0.17225f, 0.66116f, -0.17115f, 0.660347f},
|
||||||
|
};
|
||||||
|
|
||||||
|
TimeSpan ZoomTime = TimeSpan.FromSeconds(30);
|
||||||
|
DateTime ZoomStart;
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Load( object sender, EventArgs e )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Platform platform = OpenCL.GetPlatform(0);
|
||||||
|
Mandelbrot = new Mandelbrot(platform, Width, Height);
|
||||||
|
Mandelbrot.AllocBuffers();
|
||||||
|
UpdateMandelbrot();
|
||||||
|
}
|
||||||
|
catch (Exception oex)
|
||||||
|
{
|
||||||
|
MessageBox.Show( oex.ToString(), "OpenCL Initialization failed" );
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int Align(int i, int align)
|
||||||
|
{
|
||||||
|
return (i + align - 1) / align * align;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaintBackground(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateMandelbrot();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ZoomMandelbrot()
|
||||||
|
{
|
||||||
|
float zoomFactor = (float)((DateTime.Now - ZoomStart).TotalMilliseconds / ZoomTime.TotalMilliseconds);
|
||||||
|
Mandelbrot.Left = Sets[FromSetPtr, 0]+(float)((Sets[ToSetPtr, 0] - Sets[FromSetPtr, 0]) * zoomFactor);
|
||||||
|
Mandelbrot.Right = Sets[FromSetPtr, 2] + (float)((Sets[ToSetPtr, 2] - Sets[FromSetPtr, 2]) * zoomFactor);
|
||||||
|
Mandelbrot.Top = Sets[FromSetPtr, 1] + (float)((Sets[ToSetPtr, 1] - Sets[FromSetPtr, 1]) * zoomFactor);
|
||||||
|
Mandelbrot.Bottom = Sets[FromSetPtr, 3] + (float)((Sets[ToSetPtr, 3] - Sets[FromSetPtr, 3]) * zoomFactor);
|
||||||
|
UpdateMandelbrot();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateMandelbrot()
|
||||||
|
{
|
||||||
|
Mandelbrot.Calculate();
|
||||||
|
|
||||||
|
using (Graphics gfx = this.CreateGraphics())
|
||||||
|
{
|
||||||
|
gfx.DrawImageUnscaled(Mandelbrot.Bitmap, 0, 0);
|
||||||
|
gfx.DrawString("ms per frame="+Mandelbrot.CalculationTimeMS, Font, Brushes.Yellow, new PointF(50.0f, 50.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
startToolStripMenuItem.Enabled = false;
|
||||||
|
stopToolStripMenuItem.Enabled = true;
|
||||||
|
ToSetPtr = 1;
|
||||||
|
ZoomStart = DateTime.Now;
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
startToolStripMenuItem.Enabled = true;
|
||||||
|
stopToolStripMenuItem.Enabled = false;
|
||||||
|
ToSetPtr = 0;
|
||||||
|
ZoomStart = DateTime.Now;
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TimeSpan dt = DateTime.Now - ZoomStart;
|
||||||
|
if (dt >= ZoomTime)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
FromSetPtr = ToSetPtr;
|
||||||
|
}
|
||||||
|
ZoomMandelbrot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if false
|
||||||
|
ErrorCode result;
|
||||||
|
uint numPlatforms;
|
||||||
|
IntPtr[] platformIDs;
|
||||||
|
|
||||||
|
// Get number of platforms
|
||||||
|
result = cl.GetPlatformIDs( 0, null, out numPlatforms );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new Exception( "GetPlatformIDs failed with ErrorCode."+result );
|
||||||
|
Debug.WriteLine( "Number of platforms: "+numPlatforms );
|
||||||
|
if( numPlatforms==0 )
|
||||||
|
throw new Exception( "No openCL platforms available." );
|
||||||
|
|
||||||
|
// Create an array of platform IDs
|
||||||
|
platformIDs = new IntPtr[numPlatforms];
|
||||||
|
result = cl.GetPlatformIDs( numPlatforms, platformIDs, out numPlatforms );
|
||||||
|
if( result!=ErrorCode.SUCCESS )
|
||||||
|
throw new Exception( "GetPlatformIDs failed with ErrorCode."+result );
|
||||||
|
Debug.WriteLine("");
|
||||||
|
|
||||||
|
|
||||||
|
int[] globSize = new int[3];
|
||||||
|
int[] globID = new int[3];
|
||||||
|
float left;
|
||||||
|
float top;
|
||||||
|
float right;
|
||||||
|
float bottom;
|
||||||
|
AlignedArrayFloat aaf;
|
||||||
|
|
||||||
|
private void KernelIterator2d()
|
||||||
|
{
|
||||||
|
int activeIndex = globSize.Length-1;
|
||||||
|
|
||||||
|
while( activeIndex>=0 )
|
||||||
|
{
|
||||||
|
MandelBrotKernel( left, top, right, bottom, aaf );
|
||||||
|
while( activeIndex>=0 )
|
||||||
|
{
|
||||||
|
globID[activeIndex]++;
|
||||||
|
if( globID[activeIndex]>=globSize[activeIndex] )
|
||||||
|
{
|
||||||
|
globID[activeIndex] = 0;
|
||||||
|
activeIndex--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activeIndex = globSize.Length-1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int get_global_size( int dimension ) { return globSize[dimension]; }
|
||||||
|
private int get_global_id( int dimension ) { return globID[dimension]; }
|
||||||
|
private void MandelBrotKernel( float left, float top, float right, float bottom, AlignedArrayFloat af )
|
||||||
|
{
|
||||||
|
int width = get_global_size(0);
|
||||||
|
int height = get_global_size(1);
|
||||||
|
int cx = get_global_id(0);
|
||||||
|
int cy = get_global_id(1);
|
||||||
|
float dx = (right-left)/(float)width;
|
||||||
|
float dy = (bottom-top)/(float)height;
|
||||||
|
|
||||||
|
float x0 = left+dx*(float)cx;
|
||||||
|
float y0 = top+dy*(float)cy;
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
int iteration = 0;
|
||||||
|
int max_iteration = 1000;
|
||||||
|
|
||||||
|
while( x*x-y*y<=(2*2) && iteration<max_iteration )
|
||||||
|
{
|
||||||
|
float xtemp = x*x-y*y+x0;
|
||||||
|
y = 2*x*y+y0;
|
||||||
|
x = xtemp;
|
||||||
|
iteration++;
|
||||||
|
}
|
||||||
|
float color;
|
||||||
|
color = iteration==max_iteration?0.0f: (float)iteration/(float)max_iteration;
|
||||||
|
af[width*4*cy+cx*4+0] = 1.0f;
|
||||||
|
af[width*4*cy+cx*4+1] = color;
|
||||||
|
af[width*4*cy+cx*4+2] = color;
|
||||||
|
af[width*4*cy+cx*4+3] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
126
examples/OpenCLTest/Form1.resx
Normal file
126
examples/OpenCLTest/Form1.resx
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>132, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
22
examples/OpenCLTest/MainProgram.cs
Normal file
22
examples/OpenCLTest/MainProgram.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using OpenCLNet;
|
||||||
|
|
||||||
|
namespace OpenCLTest
|
||||||
|
{
|
||||||
|
static class MainProgram
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault( false );
|
||||||
|
Application.Run( new Form1() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
examples/OpenCLTest/Mandelbrot.cl
Normal file
93
examples/OpenCLTest/Mandelbrot.cl
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
constant uint Palette[17][4] =
|
||||||
|
{
|
||||||
|
{ 0x00, 0x00, 0x00, 0xFF},
|
||||||
|
{ 0x00, 0xA8, 0x76, 0xFF},
|
||||||
|
{ 0x20, 0x7E, 0x62, 0xFF},
|
||||||
|
{ 0x00, 0x6D, 0x4C, 0xFF},
|
||||||
|
{ 0x35, 0xD4, 0xA4, 0xFF},
|
||||||
|
{ 0x5F, 0xD4, 0xB1, 0xFF},
|
||||||
|
{ 0x0D, 0x56, 0xA6, 0xFF},
|
||||||
|
{ 0x27, 0x4F, 0x7D, 0xFF},
|
||||||
|
{ 0x04, 0x35, 0x6C, 0xFF},
|
||||||
|
{ 0x41, 0x86, 0xD3, 0xFF},
|
||||||
|
{ 0x68, 0x9A, 0xD3, 0xFF},
|
||||||
|
{ 0x4D, 0xDE, 0x00, 0xFF},
|
||||||
|
{ 0x55, 0xA6, 0x2A, 0xFF},
|
||||||
|
{ 0x32, 0x90, 0x00, 0xFF},
|
||||||
|
{ 0x7A, 0xEE, 0x3C, 0xFF},
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF},
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF},
|
||||||
|
/*
|
||||||
|
{0x00, 0x00, 0x5a, 0xff,},
|
||||||
|
{0x39, 0x8c, 0xdb, 0xff,},
|
||||||
|
{0x9b, 0xb9, 0xff, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAXITER 100
|
||||||
|
#define PALETTELENGTH 16
|
||||||
|
|
||||||
|
constant int8 i8_01234567 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
constant int8 i8_00000000 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
constant int8 i8_11111111 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
|
||||||
|
kernel void Mandelbrot( float left, float top, float right, float bottom, int stride, global uchar4* pOutput )
|
||||||
|
{
|
||||||
|
size_t width = get_global_size(0);
|
||||||
|
size_t height = get_global_size(1);
|
||||||
|
size_t cx = get_global_id(0);//
|
||||||
|
size_t cy = get_global_id(1);//
|
||||||
|
float dx = (right-left)/(float)width;
|
||||||
|
float dy = (bottom-top)/(float)height;
|
||||||
|
|
||||||
|
float x0 = left+dx*(float)cx;
|
||||||
|
float y0 = top+dy*(float)cy;
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
int iteration = 0;
|
||||||
|
int max_iteration = MAXITER;
|
||||||
|
|
||||||
|
while( x*x-y*y<=(2*2) && iteration<max_iteration )
|
||||||
|
{
|
||||||
|
float xtemp = x*x-y*y+x0;
|
||||||
|
y = 2*x*y+y0;
|
||||||
|
x = xtemp;
|
||||||
|
iteration++;
|
||||||
|
}
|
||||||
|
int index;
|
||||||
|
index = iteration*PALETTELENGTH/MAXITER;
|
||||||
|
//index = iteration%PALETTELENGTH;
|
||||||
|
float4 color0 = (float4)(Palette[index][0],Palette[index][1],Palette[index][2],Palette[index][3]);
|
||||||
|
float4 color1 = (float4)(Palette[index+1][0],Palette[index+1][1],Palette[index+1][2],Palette[index+1][3]);
|
||||||
|
float mixFactor = clamp( (iteration%(MAXITER/PALETTELENGTH))/(float)(MAXITER/PALETTELENGTH), 0.0f, 1.0f);
|
||||||
|
float4 mixFactors = (float4)(1.0f-mixFactor, 1.0f-mixFactor, 1.0f-mixFactor, 1.0f);
|
||||||
|
float4 mixfc = mix( color0, color1, mixFactors );
|
||||||
|
mixfc = color0*mixFactors+color1*((float4)(1.0f)-mixFactors);
|
||||||
|
pOutput[stride*cy+cx] = convert_uchar4( mixfc );
|
||||||
|
}
|
146
examples/OpenCLTest/Mandelbrot.cs
Normal file
146
examples/OpenCLTest/Mandelbrot.cs
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using OpenCLNet;
|
||||||
|
|
||||||
|
namespace OpenCLTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public class Mandelbrot
|
||||||
|
{
|
||||||
|
public float Left { get; set; }
|
||||||
|
public float Top { get; set; }
|
||||||
|
public float Right { get; set; }
|
||||||
|
public float Bottom { get; set; }
|
||||||
|
|
||||||
|
public int BitmapWidth { get; set; }
|
||||||
|
public int BitmapHeight { get; set; }
|
||||||
|
|
||||||
|
public Bitmap Bitmap { get; protected set; }
|
||||||
|
|
||||||
|
Platform openCLPlatform;
|
||||||
|
Device[] openCLDevices;
|
||||||
|
Context openCLContext;
|
||||||
|
CommandQueue openCLCQ;
|
||||||
|
Program mandelBrotProgram;
|
||||||
|
Kernel mandelbrotKernel;
|
||||||
|
Mem mandelbrotMemBuffer;
|
||||||
|
|
||||||
|
public Mandelbrot( Platform platform, int width, int height )
|
||||||
|
{
|
||||||
|
openCLPlatform = platform;
|
||||||
|
openCLDevices = openCLPlatform.QueryDevices(DeviceType.ALL);
|
||||||
|
openCLContext = openCLPlatform.CreateDefaultContext();
|
||||||
|
openCLCQ = openCLContext.CreateCommandQueue(openCLDevices[0], CommandQueueProperties.PROFILING_ENABLE);
|
||||||
|
mandelBrotProgram = openCLContext.CreateProgramWithSource(File.ReadAllText("Mandelbrot.cl"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mandelBrotProgram.Build();
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
string buildLog = mandelBrotProgram.GetBuildLog(openCLDevices[0]);
|
||||||
|
MessageBox.Show(buildLog,"Build error(64 bit debug sessions in vs2008 always fail like this - debug in 32 bit)");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
mandelbrotKernel = mandelBrotProgram.CreateKernel("Mandelbrot");
|
||||||
|
|
||||||
|
Left = -2.0f;
|
||||||
|
Top = 2.0f;
|
||||||
|
Right = 2.0f;
|
||||||
|
Bottom = -2.0f;
|
||||||
|
BitmapWidth = width;
|
||||||
|
BitmapHeight = height;
|
||||||
|
|
||||||
|
mandelbrotMemBuffer = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY), width*height*4, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AllocBuffers()
|
||||||
|
{
|
||||||
|
Bitmap = new Bitmap( BitmapWidth, BitmapHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Calculate()
|
||||||
|
{
|
||||||
|
BitmapData bd = Bitmap.LockBits(new Rectangle(0, 0, Bitmap.Width, Bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
int bitmapSize = bd.Width * bd.Height;
|
||||||
|
|
||||||
|
mandelbrotKernel.SetArg( 0, Left );
|
||||||
|
mandelbrotKernel.SetArg( 1, Top );
|
||||||
|
mandelbrotKernel.SetArg( 2, Right );
|
||||||
|
mandelbrotKernel.SetArg( 3, Bottom );
|
||||||
|
mandelbrotKernel.SetArg( 4, BitmapWidth );
|
||||||
|
mandelbrotKernel.SetArg( 5, mandelbrotMemBuffer );
|
||||||
|
|
||||||
|
Event calculationStart;
|
||||||
|
Event calculationEnd;
|
||||||
|
|
||||||
|
openCLCQ.EnqueueMarker(out calculationStart);
|
||||||
|
|
||||||
|
IntPtr[] globalWorkSize = new IntPtr[2];
|
||||||
|
|
||||||
|
globalWorkSize[0] = (IntPtr)BitmapWidth;
|
||||||
|
globalWorkSize[1] = (IntPtr)BitmapHeight;
|
||||||
|
openCLCQ.EnqueueNDRangeKernel(mandelbrotKernel, 2, null, globalWorkSize, null);
|
||||||
|
|
||||||
|
for (int y = 0; y < BitmapHeight; y++)
|
||||||
|
openCLCQ.EnqueueReadBuffer(mandelbrotMemBuffer, true, (IntPtr)(BitmapWidth*4*y), (IntPtr)(BitmapWidth*4), (IntPtr)(bd.Scan0.ToInt64()+y*bd.Stride));
|
||||||
|
openCLCQ.Finish();
|
||||||
|
openCLCQ.EnqueueMarker(out calculationEnd);
|
||||||
|
openCLCQ.Finish();
|
||||||
|
|
||||||
|
ulong start = 0;
|
||||||
|
ulong end = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
calculationStart.GetEventProfilingInfo(ProfilingInfo.QUEUED, out start);
|
||||||
|
calculationEnd.GetEventProfilingInfo(ProfilingInfo.END, out end);
|
||||||
|
}
|
||||||
|
catch (OpenCLException ocle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CalculationTimeMS = (end - start) / 1000000;
|
||||||
|
calculationStart.Dispose();
|
||||||
|
calculationEnd.Dispose();
|
||||||
|
}
|
||||||
|
Bitmap.UnlockBits(bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong CalculationTimeMS;
|
||||||
|
}
|
||||||
|
}
|
182
examples/OpenCLTest/OpenCLTest.csproj
Normal file
182
examples/OpenCLTest/OpenCLTest.csproj
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{68E39C68-7A11-4AF8-9FEA-3147E720D96D}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenCLTest</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLTest</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainProgram.cs" />
|
||||||
|
<Compile Include="Mandelbrot.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="Mandelbrot.cl">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{758285C6-1ACA-458A-9906-EE6701D5AF87}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
25
examples/OpenCLTest/OpenCLTest.csproj.user
Normal file
25
examples/OpenCLTest/OpenCLTest.csproj.user
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
36
examples/OpenCLTest/Properties/AssemblyInfo.cs
Normal file
36
examples/OpenCLTest/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle( "OpenCLTest" )]
|
||||||
|
[assembly: AssemblyDescription( "" )]
|
||||||
|
[assembly: AssemblyConfiguration( "" )]
|
||||||
|
[assembly: AssemblyCompany( "Microsoft" )]
|
||||||
|
[assembly: AssemblyProduct( "OpenCLTest" )]
|
||||||
|
[assembly: AssemblyCopyright( "Copyright © Microsoft 2009" )]
|
||||||
|
[assembly: AssemblyTrademark( "" )]
|
||||||
|
[assembly: AssemblyCulture( "" )]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible( false )]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid( "3732edb1-5d60-4c9b-a883-c28c0c67f0bb" )]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion( "1.0.0.0" )]
|
||||||
|
[assembly: AssemblyFileVersion( "1.0.0.0" )]
|
63
examples/OpenCLTest/Properties/Resources.Designer.cs
generated
Normal file
63
examples/OpenCLTest/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OpenCLTest.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCLTest.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
examples/OpenCLTest/Properties/Resources.resx
Normal file
117
examples/OpenCLTest/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
26
examples/OpenCLTest/Properties/Settings.Designer.cs
generated
Normal file
26
examples/OpenCLTest/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OpenCLTest.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
examples/OpenCLTest/Properties/Settings.settings
Normal file
7
examples/OpenCLTest/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
38
examples/OpenCLVBTest/Form1.Designer.vb
generated
Normal file
38
examples/OpenCLVBTest/Form1.Designer.vb
generated
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||||
|
Partial Class Form1
|
||||||
|
Inherits System.Windows.Forms.Form
|
||||||
|
|
||||||
|
'Form overrides dispose to clean up the component list.
|
||||||
|
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||||
|
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||||
|
Try
|
||||||
|
If disposing AndAlso components IsNot Nothing Then
|
||||||
|
components.Dispose()
|
||||||
|
End If
|
||||||
|
Finally
|
||||||
|
MyBase.Dispose(disposing)
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Required by the Windows Form Designer
|
||||||
|
Private components As System.ComponentModel.IContainer
|
||||||
|
|
||||||
|
'NOTE: The following procedure is required by the Windows Form Designer
|
||||||
|
'It can be modified using the Windows Form Designer.
|
||||||
|
'Do not modify it using the code editor.
|
||||||
|
<System.Diagnostics.DebuggerStepThrough()> _
|
||||||
|
Private Sub InitializeComponent()
|
||||||
|
Me.SuspendLayout()
|
||||||
|
'
|
||||||
|
'Form1
|
||||||
|
'
|
||||||
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
|
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||||
|
Me.ClientSize = New System.Drawing.Size(834, 659)
|
||||||
|
Me.Name = "Form1"
|
||||||
|
Me.Text = "Form1"
|
||||||
|
Me.ResumeLayout(False)
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
120
examples/OpenCLVBTest/Form1.resx
Normal file
120
examples/OpenCLVBTest/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
79
examples/OpenCLVBTest/Form1.vb
Normal file
79
examples/OpenCLVBTest/Form1.vb
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
Imports System.IO
|
||||||
|
Imports System.Drawing.Imaging
|
||||||
|
Imports OpenCLNet
|
||||||
|
|
||||||
|
|
||||||
|
Public Class Form1
|
||||||
|
Dim platform As OpenCLNet.Platform
|
||||||
|
Dim context As OpenCLNet.Context
|
||||||
|
Dim program As OpenCLNet.Program
|
||||||
|
Dim kernel As OpenCLNet.Kernel
|
||||||
|
Dim bitmap As System.Drawing.Bitmap
|
||||||
|
Dim cq As OpenCLNet.CommandQueue
|
||||||
|
Dim devices
|
||||||
|
Dim mandelbrotMemBuffer As OpenCLNet.Mem
|
||||||
|
|
||||||
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||||
|
Try
|
||||||
|
platform = OpenCLNet.OpenCL.GetPlatform(0)
|
||||||
|
devices = platform.QueryDevices(DeviceType.ALL)
|
||||||
|
context = platform.CreateDefaultContext(Nothing, Nothing)
|
||||||
|
cq = context.CreateCommandQueue(devices(0), 0)
|
||||||
|
program = context.CreateProgramWithSource(System.IO.File.ReadAllText("Mandelbrot.cl"))
|
||||||
|
program.Build()
|
||||||
|
Catch ex As Exception
|
||||||
|
Print(ex.ToString())
|
||||||
|
End Try
|
||||||
|
|
||||||
|
kernel = program.CreateKernel("Mandelbrot")
|
||||||
|
bitmap = New Bitmap(1024, 1024, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
|
||||||
|
mandelbrotMemBuffer = context.CreateBuffer(MemFlags.WRITE_ONLY, bitmap.Width * bitmap.Height * 4, Nothing)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub DrawMandelbrot(ByVal g As Graphics)
|
||||||
|
CalcMandelbrot()
|
||||||
|
g.DrawImageUnscaled(bitmap, 0, 0)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CalcMandelbrot()
|
||||||
|
Dim bd = bitmap.LockBits(New Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb)
|
||||||
|
Dim clEvent As OpenCLNet.Event
|
||||||
|
Dim globalWorkSize(0 To 1) As IntPtr
|
||||||
|
Dim eventWaitList(0 To 0) As OpenCLNet.Event
|
||||||
|
Dim _Left
|
||||||
|
Dim _Top
|
||||||
|
Dim _Right
|
||||||
|
Dim _Bottom
|
||||||
|
|
||||||
|
_Left = -2.0
|
||||||
|
_Top = 2.0
|
||||||
|
_Right = 2.0
|
||||||
|
_Bottom = -2.0
|
||||||
|
kernel.SetSingleArg(0, _Left)
|
||||||
|
kernel.SetSingleArg(1, _Top)
|
||||||
|
kernel.SetSingleArg(2, _Right)
|
||||||
|
kernel.SetSingleArg(3, _Bottom)
|
||||||
|
kernel.SetIntArg(4, bitmap.Width)
|
||||||
|
kernel.SetMemArg(5, mandelbrotMemBuffer)
|
||||||
|
|
||||||
|
clEvent = Nothing
|
||||||
|
globalWorkSize(0) = New IntPtr(CType(bd.Width, Long))
|
||||||
|
globalWorkSize(1) = New IntPtr(CType(bd.Height, Long))
|
||||||
|
cq.EnqueueNDRangeKernel(kernel, 2, Nothing, globalWorkSize, Nothing, 0, Nothing, clEvent)
|
||||||
|
cq.Finish()
|
||||||
|
For i = 0 To bitmap.Width - 1
|
||||||
|
cq.EnqueueReadBuffer(mandelbrotMemBuffer, False, bitmap.Width * 4 * i, bitmap.Width * 4, bd.Scan0.ToInt32 + bd.Stride * i)
|
||||||
|
Next i
|
||||||
|
cq.Finish()
|
||||||
|
bitmap.UnlockBits(bd)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
|
||||||
|
Try
|
||||||
|
DrawMandelbrot(e.Graphics)
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Print(ex.ToString())
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
End Class
|
93
examples/OpenCLVBTest/Mandelbrot.cl
Normal file
93
examples/OpenCLVBTest/Mandelbrot.cl
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Olav Kalgraf(olav.kalgraf@gmail.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
constant uint Palette[17][4] =
|
||||||
|
{
|
||||||
|
{ 0x00, 0x00, 0x00, 0xFF },
|
||||||
|
{ 0x00, 0xA8, 0x76, 0xFF },
|
||||||
|
{ 0x20, 0x7E, 0x62, 0xFF },
|
||||||
|
{ 0x00, 0x6D, 0x4C, 0xFF },
|
||||||
|
{ 0x35, 0xD4, 0xA4, 0xFF },
|
||||||
|
{ 0x5F, 0xD4, 0xB1, 0xFF },
|
||||||
|
{ 0x0D, 0x56, 0xA6, 0xFF },
|
||||||
|
{ 0x27, 0x4F, 0x7D, 0xFF },
|
||||||
|
{ 0x04, 0x35, 0x6C, 0xFF },
|
||||||
|
{ 0x41, 0x86, 0xD3, 0xFF },
|
||||||
|
{ 0x68, 0x9A, 0xD3, 0xFF },
|
||||||
|
{ 0x4D, 0xDE, 0x00, 0xFF },
|
||||||
|
{ 0x55, 0xA6, 0x2A, 0xFF },
|
||||||
|
{ 0x32, 0x90, 0x00, 0xFF },
|
||||||
|
{ 0x7A, 0xEE, 0x3C, 0xFF },
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF },
|
||||||
|
{ 0x99, 0xEE, 0x6B, 0xFF },
|
||||||
|
/*
|
||||||
|
{0x00, 0x00, 0x5a, 0xff,},
|
||||||
|
{0x39, 0x8c, 0xdb, 0xff,},
|
||||||
|
{0x9b, 0xb9, 0xff, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},
|
||||||
|
{0x4a, 0xae, 0x92, 0xff,},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAXITER 100
|
||||||
|
#define PALETTELENGTH 16
|
||||||
|
|
||||||
|
constant int8 i8_01234567 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
constant int8 i8_00000000 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
constant int8 i8_11111111 = (int8)( 0, 1, 2, 3, 4, 5, 6, 7 );
|
||||||
|
|
||||||
|
__kernel void Mandelbrot( float left, float top, float right, float bottom, int stride, global uchar4* pOutput )
|
||||||
|
{
|
||||||
|
size_t width = get_global_size(0);
|
||||||
|
size_t height = get_global_size(1);
|
||||||
|
size_t cx = get_global_id(0);
|
||||||
|
size_t cy = get_global_id(1);
|
||||||
|
float dx = (right-left)/(float)width;
|
||||||
|
float dy = (bottom-top)/(float)height;
|
||||||
|
|
||||||
|
float x0 = left+dx*(float)cx;
|
||||||
|
float y0 = top+dy*(float)cy;
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
int iteration = 0;
|
||||||
|
int max_iteration = MAXITER;
|
||||||
|
|
||||||
|
while( x*x-y*y<=(2*2) && iteration<max_iteration )
|
||||||
|
{
|
||||||
|
float xtemp = x*x-y*y+x0;
|
||||||
|
y = 2*x*y+y0;
|
||||||
|
x = xtemp;
|
||||||
|
iteration++;
|
||||||
|
}
|
||||||
|
int index;
|
||||||
|
index = iteration*PALETTELENGTH/MAXITER;
|
||||||
|
//index = iteration%PALETTELENGTH;
|
||||||
|
float4 color0 = (float4)(Palette[index][0],Palette[index][1],Palette[index][2],Palette[index][3]);
|
||||||
|
float4 color1 = (float4)(Palette[index+1][0],Palette[index+1][1],Palette[index+1][2],Palette[index+1][3]);
|
||||||
|
float mixFactor = clamp( (iteration%(MAXITER/PALETTELENGTH))/(float)(MAXITER/PALETTELENGTH), 0.0f, 1.0f);
|
||||||
|
float4 mixFactors = (float4)(1.0f-mixFactor, 1.0f-mixFactor, 1.0f-mixFactor, 1.0f);
|
||||||
|
float4 mixfc = mix( color0, color1, mixFactors );
|
||||||
|
mixfc = color0*mixFactors+color1*((float4)(1.0f)-mixFactors);
|
||||||
|
pOutput[width*cy+cx] = convert_uchar4( mixfc );
|
||||||
|
}
|
38
examples/OpenCLVBTest/My Project/Application.Designer.vb
generated
Normal file
38
examples/OpenCLVBTest/My Project/Application.Designer.vb
generated
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
'------------------------------------------------------------------------------
|
||||||
|
' <auto-generated>
|
||||||
|
' This code was generated by a tool.
|
||||||
|
' Runtime Version:2.0.50727.4918
|
||||||
|
'
|
||||||
|
' Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
' the code is regenerated.
|
||||||
|
' </auto-generated>
|
||||||
|
'------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Option Strict On
|
||||||
|
Option Explicit On
|
||||||
|
|
||||||
|
|
||||||
|
Namespace My
|
||||||
|
|
||||||
|
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
|
||||||
|
' or if you encounter build errors in this file, go to the Project Designer
|
||||||
|
' (go to Project Properties or double-click the My Project node in
|
||||||
|
' Solution Explorer), and make changes on the Application tab.
|
||||||
|
'
|
||||||
|
Partial Friend Class MyApplication
|
||||||
|
|
||||||
|
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||||
|
Public Sub New()
|
||||||
|
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
|
||||||
|
Me.IsSingleInstance = false
|
||||||
|
Me.EnableVisualStyles = true
|
||||||
|
Me.SaveMySettingsOnExit = true
|
||||||
|
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||||
|
Protected Overrides Sub OnCreateMainForm()
|
||||||
|
Me.MainForm = Global.OpenCLVBTest.Form1
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
|
End Namespace
|
11
examples/OpenCLVBTest/My Project/Application.myapp
Normal file
11
examples/OpenCLVBTest/My Project/Application.myapp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<MySubMain>true</MySubMain>
|
||||||
|
<MainForm>Form1</MainForm>
|
||||||
|
<SingleInstance>false</SingleInstance>
|
||||||
|
<ShutdownMode>0</ShutdownMode>
|
||||||
|
<EnableVisualStyles>true</EnableVisualStyles>
|
||||||
|
<AuthenticationMode>0</AuthenticationMode>
|
||||||
|
<ApplicationType>0</ApplicationType>
|
||||||
|
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||||
|
</MyApplicationData>
|
35
examples/OpenCLVBTest/My Project/AssemblyInfo.vb
Normal file
35
examples/OpenCLVBTest/My Project/AssemblyInfo.vb
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
Imports System
|
||||||
|
Imports System.Reflection
|
||||||
|
Imports System.Runtime.InteropServices
|
||||||
|
|
||||||
|
' General Information about an assembly is controlled through the following
|
||||||
|
' set of attributes. Change these attribute values to modify the information
|
||||||
|
' associated with an assembly.
|
||||||
|
|
||||||
|
' Review the values of the assembly attributes
|
||||||
|
|
||||||
|
<Assembly: AssemblyTitle("OpenCLVBTest")>
|
||||||
|
<Assembly: AssemblyDescription("")>
|
||||||
|
<Assembly: AssemblyCompany("Microsoft")>
|
||||||
|
<Assembly: AssemblyProduct("OpenCLVBTest")>
|
||||||
|
<Assembly: AssemblyCopyright("Copyright © Microsoft 2009")>
|
||||||
|
<Assembly: AssemblyTrademark("")>
|
||||||
|
|
||||||
|
<Assembly: ComVisible(False)>
|
||||||
|
|
||||||
|
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
<Assembly: Guid("d38f29e8-0797-40d0-9539-88a27be8ea18")>
|
||||||
|
|
||||||
|
' Version information for an assembly consists of the following four values:
|
||||||
|
'
|
||||||
|
' Major Version
|
||||||
|
' Minor Version
|
||||||
|
' Build Number
|
||||||
|
' Revision
|
||||||
|
'
|
||||||
|
' You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
' by using the '*' as shown below:
|
||||||
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
|
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||||
|
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
62
examples/OpenCLVBTest/My Project/Resources.Designer.vb
generated
Normal file
62
examples/OpenCLVBTest/My Project/Resources.Designer.vb
generated
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
'------------------------------------------------------------------------------
|
||||||
|
' <auto-generated>
|
||||||
|
' This code was generated by a tool.
|
||||||
|
' Runtime Version:2.0.50727.4918
|
||||||
|
'
|
||||||
|
' Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
' the code is regenerated.
|
||||||
|
' </auto-generated>
|
||||||
|
'------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Option Strict On
|
||||||
|
Option Explicit On
|
||||||
|
|
||||||
|
|
||||||
|
Namespace My.Resources
|
||||||
|
|
||||||
|
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
'class via a tool like ResGen or Visual Studio.
|
||||||
|
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
'with the /str option, or rebuild your VS project.
|
||||||
|
'<summary>
|
||||||
|
' A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
'</summary>
|
||||||
|
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0"), _
|
||||||
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
|
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||||
|
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||||
|
Friend Module Resources
|
||||||
|
|
||||||
|
Private resourceMan As Global.System.Resources.ResourceManager
|
||||||
|
|
||||||
|
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||||
|
|
||||||
|
'<summary>
|
||||||
|
' Returns the cached ResourceManager instance used by this class.
|
||||||
|
'</summary>
|
||||||
|
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||||
|
Get
|
||||||
|
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||||
|
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("OpenCLVBTest.Resources", GetType(Resources).Assembly)
|
||||||
|
resourceMan = temp
|
||||||
|
End If
|
||||||
|
Return resourceMan
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
'<summary>
|
||||||
|
' Overrides the current thread's CurrentUICulture property for all
|
||||||
|
' resource lookups using this strongly typed resource class.
|
||||||
|
'</summary>
|
||||||
|
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||||
|
Get
|
||||||
|
Return resourceCulture
|
||||||
|
End Get
|
||||||
|
Set(ByVal value As Global.System.Globalization.CultureInfo)
|
||||||
|
resourceCulture = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
End Module
|
||||||
|
End Namespace
|
117
examples/OpenCLVBTest/My Project/Resources.resx
Normal file
117
examples/OpenCLVBTest/My Project/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
73
examples/OpenCLVBTest/My Project/Settings.Designer.vb
generated
Normal file
73
examples/OpenCLVBTest/My Project/Settings.Designer.vb
generated
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
'------------------------------------------------------------------------------
|
||||||
|
' <auto-generated>
|
||||||
|
' This code was generated by a tool.
|
||||||
|
' Runtime Version:2.0.50727.4918
|
||||||
|
'
|
||||||
|
' Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
' the code is regenerated.
|
||||||
|
' </auto-generated>
|
||||||
|
'------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Option Strict On
|
||||||
|
Option Explicit On
|
||||||
|
|
||||||
|
|
||||||
|
Namespace My
|
||||||
|
|
||||||
|
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||||
|
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0"), _
|
||||||
|
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Partial Friend NotInheritable Class MySettings
|
||||||
|
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||||
|
|
||||||
|
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
|
||||||
|
|
||||||
|
#Region "My.Settings Auto-Save Functionality"
|
||||||
|
#If _MyType = "WindowsForms" Then
|
||||||
|
Private Shared addedHandler As Boolean
|
||||||
|
|
||||||
|
Private Shared addedHandlerLockObject As New Object
|
||||||
|
|
||||||
|
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||||
|
If My.Application.SaveMySettingsOnExit Then
|
||||||
|
My.Settings.Save()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
#End If
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
Public Shared ReadOnly Property [Default]() As MySettings
|
||||||
|
Get
|
||||||
|
|
||||||
|
#If _MyType = "WindowsForms" Then
|
||||||
|
If Not addedHandler Then
|
||||||
|
SyncLock addedHandlerLockObject
|
||||||
|
If Not addedHandler Then
|
||||||
|
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||||
|
addedHandler = True
|
||||||
|
End If
|
||||||
|
End SyncLock
|
||||||
|
End If
|
||||||
|
#End If
|
||||||
|
Return defaultInstance
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
|
|
||||||
|
Namespace My
|
||||||
|
|
||||||
|
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||||
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
|
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||||
|
Friend Module MySettingsProperty
|
||||||
|
|
||||||
|
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||||
|
Friend ReadOnly Property Settings() As Global.OpenCLVBTest.My.MySettings
|
||||||
|
Get
|
||||||
|
Return Global.OpenCLVBTest.My.MySettings.Default
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
End Module
|
||||||
|
End Namespace
|
7
examples/OpenCLVBTest/My Project/Settings.settings
Normal file
7
examples/OpenCLVBTest/My Project/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
171
examples/OpenCLVBTest/OpenCLVBTest.vbproj
Normal file
171
examples/OpenCLVBTest/OpenCLVBTest.vbproj
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{397E0A3D-6B9B-4718-8DA2-421AA5EF8864}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<StartupObject>OpenCLVBTest.My.MyApplication</StartupObject>
|
||||||
|
<RootNamespace>OpenCLVBTest</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLVBTest</AssemblyName>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<MyType>WindowsForms</MyType>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<OptionExplicit>On</OptionExplicit>
|
||||||
|
<OptionCompare>Binary</OptionCompare>
|
||||||
|
<OptionStrict>Off</OptionStrict>
|
||||||
|
<OptionInfer>On</OptionInfer>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<DefineDebug>true</DefineDebug>
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<DefineDebug>false</DefineDebug>
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DefineDebug>true</DefineDebug>
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DefineDebug>true</DefineDebug>
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<DefineTrace>true</DefineTrace>
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DocumentationFile>OpenCLVBTest.xml</DocumentationFile>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Import Include="Microsoft.VisualBasic" />
|
||||||
|
<Import Include="System" />
|
||||||
|
<Import Include="System.Collections" />
|
||||||
|
<Import Include="System.Collections.Generic" />
|
||||||
|
<Import Include="System.Data" />
|
||||||
|
<Import Include="System.Drawing" />
|
||||||
|
<Import Include="System.Diagnostics" />
|
||||||
|
<Import Include="System.Windows.Forms" />
|
||||||
|
<Import Include="System.Linq" />
|
||||||
|
<Import Include="System.Xml.Linq" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.vb">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.vb">
|
||||||
|
<DependentUpon>Form1.vb</DependentUpon>
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||||
|
<Compile Include="My Project\Application.Designer.vb">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Application.myapp</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="My Project\Resources.Designer.vb">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="My Project\Settings.Designer.vb">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.vb</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="My Project\Resources.resx">
|
||||||
|
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||||
|
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Mandelbrot.cl">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="My Project\Application.myapp">
|
||||||
|
<Generator>MyApplicationCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<None Include="My Project\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<CustomToolNamespace>My</CustomToolNamespace>
|
||||||
|
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\source\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{758285C6-1ACA-458A-9906-EE6701D5AF87}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
11
examples/OpenCLVBTest/OpenCLVBTest.vbproj.user
Normal file
11
examples/OpenCLVBTest/OpenCLVBTest.vbproj.user
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
153
vs2010/ImageCrossFade/ImageCrossFade.csproj
Normal file
153
vs2010/ImageCrossFade/ImageCrossFade.csproj
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{2C20473B-CD81-422C-B525-33A14F13B1A5}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ImageCrossFade</RootNamespace>
|
||||||
|
<AssemblyName>ImageCrossFade</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\..\examples\ImageCrossFade\Form1.cs">
|
||||||
|
<Link>Form1.cs</Link>
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\ImageCrossFade\Form1.designer.cs">
|
||||||
|
<Link>Form1.designer.cs</Link>
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\ImageCrossFade\Program.cs">
|
||||||
|
<Link>Program.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="..\..\..\examples\ImageCrossFade\Form1.resx">
|
||||||
|
<Link>Form1.resx</Link>
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<None Include="..\..\..\examples\ImageCrossFade\OpenCLFunctions.cl">
|
||||||
|
<Link>OpenCLFunctions.cl</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{0946E1A6-5488-4711-AD10-D54D6A5D2F32}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\..\..\shared\Input0.png">
|
||||||
|
<Link>Input0.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\..\shared\Input1.png">
|
||||||
|
<Link>Input1.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
9
vs2010/ImageCrossFade/ImageCrossFade.csproj.user
Normal file
9
vs2010/ImageCrossFade/ImageCrossFade.csproj.user
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
36
vs2010/ImageCrossFade/Properties/AssemblyInfo.cs
Normal file
36
vs2010/ImageCrossFade/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ImageCrossFade")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("ImageCrossFade")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("6a122d8c-3ad1-475e-b302-8448d9e39678")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
71
vs2010/ImageCrossFade/Properties/Resources.Designer.cs
generated
Normal file
71
vs2010/ImageCrossFade/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.21006.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrossFade.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ((resourceMan == null))
|
||||||
|
{
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageCrossFade.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
vs2010/ImageCrossFade/Properties/Resources.resx
Normal file
117
vs2010/ImageCrossFade/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
30
vs2010/ImageCrossFade/Properties/Settings.Designer.cs
generated
Normal file
30
vs2010/ImageCrossFade/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.21006.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrossFade.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
vs2010/ImageCrossFade/Properties/Settings.settings
Normal file
7
vs2010/ImageCrossFade/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
158
vs2010/OpenCLImageTest/OpenCLImageTest.csproj
Normal file
158
vs2010/OpenCLImageTest/OpenCLImageTest.csproj
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{75B0ED06-EC94-489B-B951-A4D4970A8B94}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenCLImageTest</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLImageTest</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Form1.cs">
|
||||||
|
<Link>Form1.cs</Link>
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Form1.designer.cs">
|
||||||
|
<Link>Form1.designer.cs</Link>
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Program.cs">
|
||||||
|
<Link>Program.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Properties\AssemblyInfo.cs">
|
||||||
|
<Link>AssemblyInfo.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Properties\Resources.Designer.cs">
|
||||||
|
<Link>Resources.Designer.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\..\examples\OpenCLImageTest\Properties\Settings.Designer.cs">
|
||||||
|
<Link>Settings.Designer.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="..\..\..\examples\OpenCLImageTest\Form1.resx">
|
||||||
|
<Link>Form1.resx</Link>
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="..\..\..\examples\OpenCLImageTest\Properties\Resources.resx">
|
||||||
|
<Link>Resources.resx</Link>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\..\..\examples\OpenCLImageTest\OpenCLFunctions.cl">
|
||||||
|
<Link>OpenCLFunctions.cl</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="..\..\..\examples\OpenCLImageTest\Properties\Settings.settings">
|
||||||
|
<Link>Settings.settings</Link>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenCLNet\OpenCLNet.csproj">
|
||||||
|
<Project>{0946E1A6-5488-4711-AD10-D54D6A5D2F32}</Project>
|
||||||
|
<Name>OpenCLNet</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\..\..\shared\Input0.png">
|
||||||
|
<Link>Input0.png</Link>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
21
vs2010/OpenCLImageTest/OpenCLImageTest.csproj.user
Normal file
21
vs2010/OpenCLImageTest/OpenCLImageTest.csproj.user
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
148
vs2010/OpenCLNet/OpenCLNet.csproj
Normal file
148
vs2010/OpenCLNet/OpenCLNet.csproj
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{0946E1A6-5488-4711-AD10-D54D6A5D2F32}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenCLNet</RootNamespace>
|
||||||
|
<AssemblyName>OpenCLNet</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\..\OpenCLNet\AlignedArray.cs">
|
||||||
|
<Link>AlignedArray.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\CommandQueue.cs">
|
||||||
|
<Link>CommandQueue.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Context.cs">
|
||||||
|
<Link>Context.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Device.cs">
|
||||||
|
<Link>Device.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Enums.cs">
|
||||||
|
<Link>Enums.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Event.cs">
|
||||||
|
<Link>Event.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Exceptions.cs">
|
||||||
|
<Link>Exceptions.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Image.cs">
|
||||||
|
<Link>Image.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\InteropTools.cs">
|
||||||
|
<Link>InteropTools.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Kernel.cs">
|
||||||
|
<Link>Kernel.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Mem.cs">
|
||||||
|
<Link>Mem.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\OpenCL.cs">
|
||||||
|
<Link>OpenCL.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\OpenCLAPI.cs">
|
||||||
|
<Link>OpenCLAPI.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Platform.cs">
|
||||||
|
<Link>Platform.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Platforms.cs">
|
||||||
|
<Link>Platforms.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Program.cs">
|
||||||
|
<Link>Program.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\Sampler.cs">
|
||||||
|
<Link>Sampler.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\..\OpenCLNet\SimpleOCLHelper.cs">
|
||||||
|
<Link>SimpleOCLHelper.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
21
vs2010/OpenCLNet/OpenCLNet.csproj.user
Normal file
21
vs2010/OpenCLNet/OpenCLNet.csproj.user
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
110
vs2010/OpenCLNet/OpenCLNet.sln
Normal file
110
vs2010/OpenCLNet/OpenCLNet.sln
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLNet", "OpenCLNet.csproj", "{0946E1A6-5488-4711-AD10-D54D6A5D2F32}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "..\UnitTests\UnitTests.csproj", "{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLTest", "..\OpenCLTest\OpenCLTest.csproj", "{5667200A-99B7-4A42-B170-E7D4371631D6}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageCrossFade", "..\ImageCrossFade\ImageCrossFade.csproj", "{2C20473B-CD81-422C-B525-33A14F13B1A5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLImageTest", "..\OpenCLImageTest\OpenCLImageTest.csproj", "{75B0ED06-EC94-489B-B951-A4D4970A8B94}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|Mixed Platforms = Release|Mixed Platforms
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|x64.Build.0 = Release|x64
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{0946E1A6-5488-4711-AD10-D54D6A5D2F32}.Release|x86.Build.0 = Release|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{D1EE52C7-C504-4BE2-9546-315B1E2CA2D5}.Release|x86.Build.0 = Release|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|x64.Build.0 = Release|x64
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{5667200A-99B7-4A42-B170-E7D4371631D6}.Release|x86.Build.0 = Release|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|x64.Build.0 = Release|x64
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{2C20473B-CD81-422C-B525-33A14F13B1A5}.Release|x86.Build.0 = Release|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|x64.Build.0 = Release|x64
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{75B0ED06-EC94-489B-B951-A4D4970A8B94}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
BIN
vs2010/OpenCLNet/OpenCLNet.suo
Normal file
BIN
vs2010/OpenCLNet/OpenCLNet.suo
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user