public void TestImage2DReadWrite() { checkSetup(); CommandQueue queue = CommandQueue.Create(context, device, CommandQueueFlags.ProfilingEnable); ImageFormat fmt = new ImageFormat(ChannelOrder.R, ChannelType.Float); Image2D img = Image2D.Create(context, MemFlags.ReadOnly, fmt, 4, 2); Assert.AreEqual((IntPtr)4, img.ElementSize); float[,] pix = new float[, ] { { 1.0f, 0.0f, 1.0f, 0.0f }, { 2.0f, 0.0f, 2.0f, 0.0f } }; float[,] ret = new float[2, 4]; img.Write(queue, pix); img.Read(queue, ret); for (int r = 0; r < pix.GetLength(0); r++) { for (int c = 0; c < pix.GetLength(1); c++) { Assert.AreEqual(pix[r, c], ret[r, c]); } } img.Dispose(); queue.Dispose(); }
public void TestImage2DProperties() { checkSetup(); CommandQueue queue = CommandQueue.Create(context, device, CommandQueueFlags.ProfilingEnable); ImageFormat fmt = new ImageFormat(ChannelOrder.Ra, ChannelType.Float); Image2D img = Image2D.Create(context, MemFlags.ReadOnly, fmt, 2, 2); Assert.AreEqual(2, img.Width); Assert.AreEqual(2, img.Height); Assert.AreEqual(fmt, img.ImageFormat); Assert.AreEqual((IntPtr)8, img.ElementSize); img.Dispose(); queue.Dispose(); }
public Image2D CreateImage2D(MemFlags flags, ImageFormat format, int width, int height) { return(Image2D.Create(this, flags, format, width, height)); }