Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data">Data pointer</param>
        /// <param name="offset">Offset in bytes on the Buffer to start reading</param>
        /// <param name="bytes">Number of bytes to read</param>
        public static unsafe void Read(this GraphicBuffer buffer, void *data, int offset, int bytes)
        {
            byte *pBuffer = (byte *)buffer.Map(MapType.Read, false);

            Runtime.Copy(pBuffer + offset, data, bytes);

            buffer.Unmap();
        }
Ejemplo n.º 2
0
        public void SetIndexBuffer(GraphicBuffer indexBuffer, int offset = 0)
        {
            _iaIndexBufferBind.buffer = indexBuffer;
            _iaIndexBufferBind.offset = offset;
            _iaIndexBufferBind.stride = indexBuffer.Stride;

            IASetIndexBufferImpl(indexBuffer, offset);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data">Data pointer</param>
        /// <param name="offset">Offset in bytes on the Buffer to start writing</param>
        /// <param name="bytes">Number of bytes to write</param>
        public static unsafe void Write(this GraphicBuffer buffer, void *data, int offset, int bytes, bool discard = true)
        {
            byte *pBuffer = (byte *)buffer.Map(discard ? MapType.Write_Discard : MapType.Write, false);

            Runtime.Copy(data, pBuffer + offset, bytes);

            buffer.Unmap();
        }
Ejemplo n.º 4
0
        public void SetVertexBuffer(int slot, GraphicBuffer vertexBuffer, int offset = 0)
        {
            BufferBind bind;

            bind.buffer = vertexBuffer;
            bind.offset = offset;
            bind.stride = vertexBuffer.Stride;
            _iaVertexBufferBind[slot] = bind;

            IASetVertexBufferImpl(slot, vertexBuffer, offset, vertexBuffer.Stride);
        }
Ejemplo n.º 5
0
        public static void Read(this GraphicBuffer buffer, byte[] data, int offset, int bytes)
        {
            unsafe
            {
                GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
                var      ptr    = ClrRuntime.Runtime.GetPointer(data, 0);

                try
                {
                    buffer.Read(ptr, offset, bytes);
                }

                finally
                {
                    handle.Free();
                }
            }
        }
Ejemplo n.º 6
0
        public static void Write(this GraphicBuffer buffer, byte[] data, int offset, int bytes, bool discard = true)
        {
            GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);

            unsafe
            {
                var ptr = ClrRuntime.Runtime.GetPointer(data, 0);
                try
                {
                    buffer.Write(ptr, offset, bytes, discard);
                }

                finally
                {
                    handle.Free();
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data">array</param>
        /// <param name="offset">Offset in bytes to start reading</param>
        public static void Read <T>(this GraphicBuffer buffer, T[] data, int offset = 0)
            where T : struct
        {
            unsafe
            {
                GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
                var      ptr    = ClrRuntime.Runtime.GetPointer(data, 0);

                try
                {
                    buffer.Read(ptr, offset, ClrRuntime.Runtime.SizeOf <T>() * data.Length);
                }

                finally
                {
                    handle.Free();
                }
            }
        }
Ejemplo n.º 8
0
 public static T[] ToArray <T>(this GraphicBuffer buffer) where T : struct
 {
     T[] data = new T[buffer.SizeInBytes / ClrRuntime.Runtime.SizeOf <T>()];
     buffer.Read(data);
     return(data);
 }
Ejemplo n.º 9
0
 public abstract void UpdateBuffer(GraphicBuffer buffer, int offset, IntPtr pterData, int dataSize);
Ejemplo n.º 10
0
 protected abstract void IASetIndexBufferImpl(GraphicBuffer indexBuffer, int offset);
Ejemplo n.º 11
0
 protected abstract void IASetVertexBufferImpl(int slot, GraphicBuffer vertexBuffer, int offset, int stride);