openclnet hinzugefügt

This commit is contained in:
2015-11-15 22:13:50 +00:00
commit 18fd14e197
110 changed files with 14130 additions and 0 deletions
+214
View 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
View 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
View 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>
@@ -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);
}
*/
@@ -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>
@@ -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
View 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());
}
}
}
@@ -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")]
@@ -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;
}
}
}
}
@@ -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
View 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;
}
}
}
}
@@ -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>