Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Cloo/Source/Bindings/CL12.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ namespace Cloo.Bindings
/// <remarks> See the OpenCL specification for documentation regarding these functions. </remarks>
[SuppressUnmanagedCodeSecurity]
public class CL12 : CL11
{
{
/// <summary>
/// Introduced in OpenCL 1.2.
/// </summary>
[DllImport(libName, EntryPoint = "clCreateImage")]
public static extern CLMemoryHandle CreateImage(
CLContextHandle context,
ComputeMemoryFlags flags,
ref ComputeImageFormat imageFormat,
ref ComputeImageDescription imageDesc,
IntPtr hostPointer,
out ComputeErrorCode resultCode);

/// <summary>
/// See the OpenCL specification.
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion Cloo/Source/Bindings/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,13 @@ public enum ComputeMemoryType : int
/// <summary> </summary>
Image2D = 0x10F1,
/// <summary> </summary>
Image3D = 0x10F2
Image3D = 0x10F2,
Image2DArray = 0x10F3,
Image1D = 0x10F4,
Image1DArray = 0x10F5,
Image1DBuffer = 0x10F6,
Pipe = 0x10F7

}

/// <summary>
Expand Down
9 changes: 8 additions & 1 deletion Cloo/Source/ComputeImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Cloo
/// <remarks> A memory object that stores a two- or three- dimensional structured array. Image data can only be accessed with read and write functions. The read functions use a sampler. </remarks>
/// <seealso cref="ComputeMemory"/>
/// <seealso cref="ComputeSampler"/>
public abstract class ComputeImage : ComputeMemory
public class ComputeImage : ComputeMemory
{
#region Properties

Expand Down Expand Up @@ -86,6 +86,13 @@ public abstract class ComputeImage : ComputeMemory
#endregion

#region Constructors
public ComputeImage(ComputeContext context, ComputeMemoryFlags flags, ComputeImageFormat format, ComputeImageDescription desc, IntPtr data) : base(context, flags)
{
Handle = CL12.CreateImage(context.Handle, flags, ref format, ref desc, data, out ComputeErrorCode error);
ComputeException.ThrowOnError(error);

Init();
}

/// <summary>
///
Expand Down
70 changes: 70 additions & 0 deletions Cloo/Source/ComputeImageDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Cloo
{

[StructLayout(LayoutKind.Sequential)]
public struct ComputeImageDescription
{
public ComputeMemoryType ImageType;
public UIntPtr Width;
public UIntPtr Height;
public UIntPtr Depth;
public UIntPtr ArraySize;
public UIntPtr RowPitch;
public UIntPtr SlicePitch;
public uint MipLevels;
public uint Samples;
public IntPtr Buffer;

public static ComputeImageDescription Create2D(uint width, uint height)
{
return new ComputeImageDescription()
{
ImageType = ComputeMemoryType.Image2D,
Width = (UIntPtr)width,
Height = (UIntPtr)height,
Depth = (UIntPtr)1,
};
}

public static ComputeImageDescription Create2D(uint width, uint height, uint rowPitch)
{
return new ComputeImageDescription()
{
ImageType = ComputeMemoryType.Image2D,
Width = (UIntPtr)width,
Height = (UIntPtr)height,
Depth = (UIntPtr)1,
RowPitch = (UIntPtr)rowPitch
};
}

public static ComputeImageDescription Create3D(uint width, uint height, uint depth)
{
return new ComputeImageDescription()
{
ImageType = ComputeMemoryType.Image3D,
Width = (UIntPtr)width,
Height = (UIntPtr)height,
Depth = (UIntPtr)depth,
};
}

public static ComputeImageDescription Create3D(uint width, uint height, uint depth, uint rowPitch, uint slicePitch)
{
return new ComputeImageDescription()
{
ImageType = ComputeMemoryType.Image3D,
Width = (UIntPtr)width,
Height = (UIntPtr)height,
Depth = (UIntPtr)depth,
RowPitch = (UIntPtr)rowPitch,
SlicePitch = (UIntPtr)slicePitch
};
}
}
}