Ejemplo n.º 1
0
        /// <summary>
        /// Maps the data contained in a subresource to a memory pointer, and denies the GPU access to that subresource.
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="stream">The output stream containing the pointer.</param>
        /// <returns>
        /// The locked <see cref="SharpDX.DataBox"/>
        /// </returns>
        /// <unmanaged>HRESULT ID3D11DeviceContext::Map([In] ID3D11Resource* pResource,[In] unsigned int Subresource,[In] D3D11_MAP MapType,[In] D3D11_MAP_FLAG MapFlags,[Out] D3D11_MAPPED_SUBRESOURCE* pMappedResource)</unmanaged>
        public DataBox MapSubresource(Buffer resource, MapMode mode, MapFlags flags, out DataStream stream)
        {
            var box = MapSubresource(resource, 0, mode, flags);

            stream = new DataStream(box.DataPointer, resource.Description.SizeInBytes, true, true);
            return(box);
        }
Ejemplo n.º 2
0
 public Details(JToken j)
 {
     Flags   = j[nameof(Flags)].EnumValue <MapFlags>();
     Section = j[nameof(Section)].EnumValue <MapSection>();
     Weather = j[nameof(Weather)].EnumValue <MapWeather>();
     Music   = j[nameof(Music)].EnumValue <Song>();
 }
Ejemplo n.º 3
0
 public static extern ErrorCode EnqueueSVMMap(IntPtr commandQueue,
                                              int blockingMap,
                                              MapFlags mapFlags,
                                              IntPtr svmPtr,
                                              IntPtr size,
                                              uint numEventsInWaitList,
                                              [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysUInt, SizeParamIndex = 6)] Event[] eventWaitList,
                                              [Out][MarshalAs(UnmanagedType.Struct)] out Event e);
Ejemplo n.º 4
0
 internal static extern IntPtr clEnqueueMapBuffer(IntPtr commandQueue,
                                                  IntPtr buffer,
                                                  uint blockingMap,
                                                  MapFlags mapFlags,
                                                  IntPtr offset,
                                                  IntPtr cb,
                                                  uint numEventsInWaitList, [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysUInt, SizeParamIndex = 6)] Event[] eventWaitList, [Out] out Event e,
                                                  out ErrorCode errCodeRet);
Ejemplo n.º 5
0
 internal static extern IntPtr clEnqueueMapImage(IntPtr commandQueue,
                                                 IntPtr image,
                                                 uint blockingMap,
                                                 MapFlags mapFlags, [In][MarshalAs(UnmanagedType.LPArray, SizeConst = 3)] IntPtr[] origin, [In][MarshalAs(UnmanagedType.LPArray, SizeConst = 3)] IntPtr[] region,
                                                 out IntPtr imageRowPitch,
                                                 out IntPtr imageSlicePitch,
                                                 uint numEventsInWaitList, [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysUInt, SizeParamIndex = 8)] Event[] eventWaitList, [Out] out Event e,
                                                 out ErrorCode errCodeRet);
Ejemplo n.º 6
0
 public Details(EndianBinaryReader r)
 {
     Flags     = r.ReadEnum <MapFlags>();
     Section   = r.ReadEnum <MapSection>();
     Weather   = r.ReadEnum <MapWeather>();
     Music     = r.ReadEnum <Song>();
     BurmyForm = r.ReadEnum <PBEForm>();
 }
Ejemplo n.º 7
0
 public Details(JToken j)
 {
     Flags     = j[nameof(Flags)].ReadFlagsEnumValue <MapFlags>();
     Section   = j[nameof(Section)].ReadEnumValue <MapSection>();
     Weather   = j[nameof(Weather)].ReadEnumValue <MapWeather>();
     Music     = j[nameof(Music)].ReadEnumValue <Song>();
     BurmyForm = j[nameof(BurmyForm)].ReadEnumValue <PBEForm>();
 }
Ejemplo n.º 8
0
 public void Map <T>(DeviceContext4 context4,
                     T[]            data,
                     MapMode mapMode   = MapMode.WriteDiscard,
                     MapFlags mapFlags = MapFlags.None)
     where T : unmanaged
 {
     Map(context4, 0, data, 0, data.Length, mapMode, mapFlags);
 }
Ejemplo n.º 9
0
        /// <summary>
        ///  文字列を変換する(LCMapStringWのラッパ)
        /// </summary>
        /// <param name="s">string : 変換元の文字列</param>
        /// <param name="flags">MapFlags : 変換条件</param>
        /// <returns>string</returns>
        public static string StringConvert(this string s, MapFlags flags)
        {
            var ci     = CultureInfo.CurrentCulture;
            var result = new string(' ', s.Length);

            LCMapStringW(ci.LCID, (uint)flags, s, s.Length, result, result.Length);
            return(result);
        }
Ejemplo n.º 10
0
        IntPtr MappingAsync(bool blocking, Memory buffer, MapFlags flags, int offset, int cb)
        {
            int    errcode;
            IntPtr ptr = Native.clEnqueueMapBuffer(_handle, buffer.Handle, blocking ? CL_Bool.True : CL_Bool.False,
                                                   flags, new IntPtr(offset), new IntPtr(cb), 0, null, IntPtr.Zero, out errcode);

            OpenCLException.Check(errcode);
            return(ptr);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <returns>
        /// A databox containing the mapped data. This data stream is invalidated when the buffer is unmapped.
        /// </returns>
        public DataBox Map(int mipSlice, MapMode mode, MapFlags flags)
        {
            var desc = Description;
            int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels);

            DataBox mappedTexture3D;
            Map(subresource, mode, flags, out mappedTexture3D);

            return mappedTexture3D;
        }
Ejemplo n.º 12
0
 public extern static IntPtr clEnqueueMapBuffer(
     IntPtr command_queue,
     IntPtr buffer,
     CL_Bool blocking_map,
     MapFlags map_flags,
     IntPtr offset,
     IntPtr cb,
     uint num_events_in_wait_list,
     IntPtr[] event_wait_list,
     IntPtr event_wait,
     out int errcode_ret);
Ejemplo n.º 13
0
        public unsafe IntPtr Map(CommandQueue queue, MapFlags flags, IntPtr offset, IntPtr size)
        {
            ErrorCode errorCode = ErrorCode.Success;
            IntPtr    result    = Native.EnqueueMapBuffer(queue.Handle, this.Handle, true, flags, offset, size, 0, null, null, &errorCode);

            if (errorCode != ErrorCode.Success)
            {
                throw new OpenCLCallFailedException(errorCode);
            }
            return(result);
        }
Ejemplo n.º 14
0
 public Map()
 {
     Id           = 0;
     Height       = 0;
     Width        = 0;
     ExpModifier  = 0;
     DropModifier = 0;
     Flags        = 0;
     Weather      = WeatherType.None;
     Portals      = new Dictionary <int, Portal>();
     Entities     = new ConcurrentDictionary <int, YiObj>();
 }
Ejemplo n.º 15
0
Archivo: Map.cs Proyecto: Pircs/Yi
 public Map()
 {
     Id           = 0;
     Height       = 0;
     Width        = 0;
     ExpModifier  = 0;
     DropModifier = 0;
     Flags        = 0;
     SpawnVector2 = new Vector2(0, 0);
     Weather      = WeatherType.None;
     Entities     = new ConcurrentDictionary <int, YiObj>();
 }
Ejemplo n.º 16
0
        public Event EnqueueMapBuffer(Buffer buffer, bool blocking, MapFlags mapFlags, long offset, long size, out IntPtr mappedPointer, params Event[] eventWaitList)
        {
            EventSafeHandle[] eventHandles = null;
            if (eventWaitList != null)
            {
                eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle);
            }

            EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapBuffer(Handle, buffer.Handle, blocking, mapFlags, (IntPtr)offset, (IntPtr)size, out mappedPointer, eventHandles);

            return(new Event(handle));
        }
Ejemplo n.º 17
0
        public Map(string name, int id, int variant, MapType type, MapFlags flags)
        {
            Name           = name;
            MapID          = id;
            VariantID      = variant;
            Type           = type;
            Flags          = flags;
            Clients        = new List <Client>();
            GenerationArgs = new GenParam();

            Objects = ObjectManager.Instance.GetObjectsForZone(Name);
            NPCs    = ObjectManager.Instance.getNPCSForZone(Name);
        }
Ejemplo n.º 18
0
        public Map(string name, int id, int variant, MapType type, MapFlags flags)
        {
            Name = name;
            MapID = id;
            VariantID = variant;
            Type = type;
            Flags = flags;
            Clients = new List<Client>();
            GenerationArgs = new GenParam();

            Objects = ObjectManager.Instance.GetObjectsForZone(Name);
            NPCs = ObjectManager.Instance.getNPCSForZone(Name);
        }
Ejemplo n.º 19
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ContrailFlags             = ((Flags)(binaryReader.ReadInt16()));
     this.ContrailScaleFlags        = ((ScaleFlags)(binaryReader.ReadInt16()));
     this.PointGenerationRate       = binaryReader.ReadSingle();
     this.PointVelocity             = binaryReader.ReadRange();
     this.PointVelocityConeAngle    = binaryReader.ReadSingle();
     this.InheritedVelocityFraction = binaryReader.ReadSingle();
     this.RenderType                = ((RenderTypeEnum)(binaryReader.ReadInt16()));
     this.fieldpad                  = binaryReader.ReadBytes(2);
     this.TextureRepeatsU           = binaryReader.ReadSingle();
     this.TextureRepeatsV           = binaryReader.ReadSingle();
     this.TextureAnimationU         = binaryReader.ReadSingle();
     this.TextureAnimationV         = binaryReader.ReadSingle();
     this.AnimationRate             = binaryReader.ReadSingle();
     this.Bitmap                    = binaryReader.ReadTagReference();
     this.FirstSequenceIndex        = binaryReader.ReadInt16();
     this.SequenceCount             = binaryReader.ReadInt16();
     this.fieldpad0                 = binaryReader.ReadBytes(40);
     this.ContrailShaderFlags       = ((ShaderFlags)(binaryReader.ReadInt16()));
     this.FramebufferBlendFunction  = ((FramebufferBlendFunctionEnum)(binaryReader.ReadInt16()));
     this.FramebufferFadeMode       = ((FramebufferFadeModeEnum)(binaryReader.ReadInt16()));
     this.ContrailMapFlags          = ((MapFlags)(binaryReader.ReadInt16()));
     this.fieldpad1                 = binaryReader.ReadBytes(28);
     this.Bitmap0                   = binaryReader.ReadTagReference();
     this.Anchor                    = ((AnchorEnum)(binaryReader.ReadInt16()));
     this.ContrailContrailFlags0    = ((ContrailFlags0)(binaryReader.ReadInt16()));
     this.fieldpad2                 = binaryReader.ReadBytes(2);
     this.UanimationFunction        = ((UanimationFunctionEnum)(binaryReader.ReadInt16()));
     this.UanimationPeriod          = binaryReader.ReadSingle();
     this.UanimationPhase           = binaryReader.ReadSingle();
     this.UanimationScale           = binaryReader.ReadSingle();
     this.fieldpad3                 = binaryReader.ReadBytes(2);
     this.VanimationFunction        = ((VanimationFunctionEnum)(binaryReader.ReadInt16()));
     this.VanimationPeriod          = binaryReader.ReadSingle();
     this.VanimationPhase           = binaryReader.ReadSingle();
     this.VanimationScale           = binaryReader.ReadSingle();
     this.fieldpad4                 = binaryReader.ReadBytes(2);
     this.RotationanimationFunction = ((RotationanimationFunctionEnum)(binaryReader.ReadInt16()));
     this.RotationanimationPeriod   = binaryReader.ReadSingle();
     this.RotationanimationPhase    = binaryReader.ReadSingle();
     this.RotationanimationScale    = binaryReader.ReadSingle();
     this.RotationanimationCenter   = binaryReader.ReadVector2();
     this.fieldpad5                 = binaryReader.ReadBytes(4);
     this.ZspriteRadiusScale        = binaryReader.ReadSingle();
     this.fieldpad6                 = binaryReader.ReadBytes(20);
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(64));
     return(pointerQueue);
 }
Ejemplo n.º 20
0
        public Event EnqueueMapBuffer(
            Buffer buffer, bool blocking, MapFlags flags,
            long offset, long size, Event[] events, out IntPtr pointer)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", offset, "offset is less than zero.");
            }
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", size, "size is less than zero.");
            }

            return(EnqueueMapBuffer(buffer, blocking, flags, (ulong)offset, (ulong)size, events, out pointer));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <returns>A data stream containing the mapped data. This data stream is invalidated
        /// when the buffer is unmapped.</returns>
        public DataStream Map(int mipSlice, MapMode mode, MapFlags flags)
        {
            var desc = Description;
		    int subresource = CalculateSubResourceIndex( mipSlice, 0, desc.MipLevels );
		    int mipWidth = GetMipSize( mipSlice, desc.Width );
		    int bufferSize = (int)(mipWidth * FormatHelper.SizeOfInBytes(desc.Format));

            IntPtr dataPointer;
            Map(subresource, mode, flags, out dataPointer);

            bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;

            return new DataStream(dataPointer, bufferSize, canRead, canWrite);
        }
Ejemplo n.º 22
0
Archivo: Util.cs Proyecto: gageas/lutea
        /// <summary>
        /// LCMapStringのwrapper
        /// ref. http://d.hatena.ne.jp/deraw/20060831/1156992224
        /// sourceがnullのとき、nullを返す
        /// </summary>
        /// <param name="source">ソース文字列</param>
        /// <param name="mapFlags">変換フラグ</param>
        /// <returns>変換後の文字列</returns>
        public static String LCMapString(string source, MapFlags mapFlags)
        {
            if (source == null)
            {
                return(null);
            }
            char[] buffer = new char[source.Length * 2];
            int    len    = _LCMapString(System.Threading.Thread.CurrentThread.CurrentCulture.LCID, (uint)mapFlags, source, source.Length, buffer, buffer.Length);

            if (len < 0)
            {
                throw new ArgumentException("\"LCMAP_SORTKEY\" is not support ");
            }

            return(new String(buffer, 0, len));
        }
Ejemplo n.º 23
0
        public Event EnqueueMapImage(Image image, bool blocking, MapFlags mapFlags, BufferCoordinates origin, BufferSize region, out long rowPitch, out long slicePitch, out IntPtr mappedPointer, params Event[] eventWaitList)
        {
            EventSafeHandle[] eventHandles = null;
            if (eventWaitList != null)
            {
                eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle);
            }

            IntPtr          imageRowPitch;
            IntPtr          imageSlicePitch;
            EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapImage(Handle, image.Handle, blocking, mapFlags, ref origin, ref region, out imageRowPitch, out imageSlicePitch, out mappedPointer, eventHandles);

            rowPitch   = imageRowPitch.ToInt64();
            slicePitch = imageSlicePitch.ToInt64();
            return(new Event(handle));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <returns>A data stream containing the mapped data. This data stream is invalidated
        /// when the buffer is unmapped.</returns>
        public DataStream Map(int mipSlice, MapMode mode, MapFlags flags)
        {
            var desc        = Description;
            int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels);
            int mipWidth    = GetMipSize(mipSlice, desc.Width);
            int bufferSize  = (int)(mipWidth * FormatHelper.SizeOfInBytes(desc.Format));

            IntPtr dataPointer;

            Map(subresource, mode, flags, out dataPointer);

            bool canRead  = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;

            return(new DataStream(dataPointer, bufferSize, canRead, canWrite));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <param name="dataStream">The data stream.</param>
        /// <returns>
        /// A databox containing the mapped data. This data stream is invalidated when the buffer is unmapped.
        /// </returns>
        public DataBox Map(int mipSlice, MapMode mode, MapFlags flags, out DataStream dataStream)
        {
            var desc        = Description;
            int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels);

            DataBox mappedTexture3D;

            Map(subresource, mode, flags, out mappedTexture3D);

            bool canRead  = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;
            int  mipDepth = GetMipSize(mipSlice, desc.Depth);

            dataStream = new DataStream(mappedTexture3D.DataPointer, mipDepth * mappedTexture3D.SlicePitch, canRead, canWrite);

            return(mappedTexture3D);
        }
        private Map()
        {
            level       = 0;
            name        = "<insert name here>";
            description = "<insert desc here>";
            flags       = new MapFlags(128);

            InitialScore      = 0;
            InitialLivesCount = 5;
            InitialWeapon     = new MachineGun();

            events = new List <Event>();
            EnemyRessourcesToLoad = new List <BadGuy>();
            MusicRessourcesToLoad = new List <MySong>();

            Ended     = EndMode.None;
            StartTime = 0.0f;
        }
Ejemplo n.º 27
0
        public unsafe void Map <T>(DeviceContext4 context4,
                                   int offset,
                                   T[]            data,
                                   int dataOffset,
                                   int dataLength,
                                   MapMode mapMode   = MapMode.WriteDiscard,
                                   MapFlags mapFlags = MapFlags.None)
            where T : unmanaged
        {
            DataBox box     = context4.MapSubresource(_buffer, 0, mapMode, mapFlags);
            T *     vpctPtr = (T *)box.DataPointer;

            for (int i = 0; i < dataLength; i++)
            {
                *(vpctPtr + offset + i) = data[i + dataOffset];
            }
            context4.UnmapSubresource(_buffer, 0);
        }
Ejemplo n.º 28
0
        public IntPtr Map(CommandQueue queue, MapFlags flags, Offset2D origin, Dim2D region, out IntPtr pitch)
        {
            Offset3D  origin_buf = new Offset3D(origin.X, origin.Y, (IntPtr)0);
            Dim3D     region_buf = new Dim3D(region.X, region.Y, (IntPtr)1);
            IntPtr    tempPitch  = IntPtr.Zero;
            ErrorCode errorCode;
            IntPtr    result = IntPtr.Zero;

            unsafe {
                result = Native.EnqueueMapImage(queue.Handle, this.Handle, true, flags, &origin_buf, &region_buf, &tempPitch, null, 0, null, null, &errorCode);
                pitch  = tempPitch;
            }
            if (errorCode != ErrorCode.Success)
            {
                throw new OpenCLCallFailedException(errorCode);
            }
            return(result);
        }
Ejemplo n.º 29
0
        public Event EnqueueMapBuffer(
            Buffer buffer, bool blocking, MapFlags flags,
            ulong offset, ulong size, Event[] events, out IntPtr pointer)
        {
            ClHelper.ThrowNullException(Handle);

            if (buffer == Buffer.Null)
            {
                throw new ArgumentNullException("buffer");
            }

            unsafe
            {
                int     num_events_in_wait_list = events == null ? 0 : events.Length;
                IntPtr *wait_list = stackalloc IntPtr[num_events_in_wait_list];
                for (int i = 0; i < num_events_in_wait_list; ++i)
                {
                    wait_list[i] = events[i].Handle;
                }
                if (events == null)
                {
                    wait_list = null;
                }

                IntPtr event_ptr = IntPtr.Zero;

                int   error;
                void *result = Cl.EnqueueMapBuffer(Handle,
                                                   buffer.Handle, blocking ? 1u : 0u, (ulong)flags,
                                                   new UIntPtr(offset), new UIntPtr(size),
                                                   (uint)num_events_in_wait_list, wait_list, &event_ptr, &error);
                ClHelper.GetError(error);

                pointer = new IntPtr(result);

                return(new Event(event_ptr));
            }
        }
Ejemplo n.º 30
0
        public IntPtr EnqueueMap(CommandQueue queue, MapFlags flags, Offset2D origin, Dim2D region, out IntPtr pitch, Event[] waitList, out Event evt)
        {
            Offset3D origin_buf = new Offset3D(origin.X, origin.Y, (IntPtr)0);
            Dim3D    region_buf = new Dim3D(region.X, region.Y, (IntPtr)1);
            IntPtr   tempPitch  = IntPtr.Zero;
            uint     waitCount  = (waitList == null ? 0 : (uint)waitList.Length);

            IntPtr[]  wlh       = CLObject.GetHandles(waitList);
            IntPtr    evtHandle = IntPtr.Zero;
            ErrorCode errorCode;
            IntPtr    result = IntPtr.Zero;

            unsafe {
                result = Native.EnqueueMapImage(queue.Handle, this.Handle, true, flags, &origin_buf, &region_buf, &tempPitch, null, waitCount, wlh, &evtHandle, &errorCode);
            }
            if (errorCode != ErrorCode.Success)
            {
                throw new OpenCLCallFailedException(errorCode);
            }
            pitch = tempPitch;
            evt   = new Event(evtHandle);
            return(result);
        }
Ejemplo n.º 31
0
        public IntPtr EnqueueMapBuffer(Mem buffer, bool blockingMap, MapFlags map_flags, long offset, long cb)
        {
            void* pMappedPtr;
            ErrorCode result;

            pMappedPtr = OpenCL.EnqueueMapBuffer(CommandQueueID, buffer, blockingMap ? (uint)Bool.TRUE : (uint)Bool.FALSE, (ulong)map_flags, offset, cb, 0, null, null, out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapBuffer failed with error code " + result, result);
            return (IntPtr)pMappedPtr;
        }
Ejemplo n.º 32
0
        public IntPtr EnqueueMapBuffer(Mem buffer, bool blockingMap, MapFlags map_flags, IntPtr offset, IntPtr cb)
        {
            ErrorCode result;
            IntPtr ptr;

            ptr = (IntPtr)OpenCL.EnqueueMapBuffer(CommandQueueID,
                buffer.MemID,
                (uint)(blockingMap ? Bool.TRUE : Bool.FALSE),
                (ulong)map_flags,
                offset,
                cb,
                (uint)0,
                null,
                null,
                out result);

            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapBuffer failed with error code " + result, result);
            return ptr;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <param name="dataStream">The data stream.</param>
        /// <returns>
        /// A databox containing the mapped data. This data stream is invalidated when the buffer is unmapped.
        /// </returns>
        public DataBox Map(int mipSlice, MapMode mode, MapFlags flags, out DataStream dataStream)
        {
            var desc = Description;
            int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels);

            DataBox mappedTexture3D;
            Map(subresource, mode, flags, out mappedTexture3D);

            bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;
            int mipDepth = GetMipSize(mipSlice, desc.Depth);
            dataStream = new DataStream(mappedTexture3D.DataPointer, mipDepth * mappedTexture3D.SlicePitch, canRead, canWrite);

            return mappedTexture3D;
        }
Ejemplo n.º 34
0
 internal extern static unsafe IntPtr EnqueueMapImage(IntPtr command_queue, IntPtr image, bool blocking_map, MapFlags map_flags, IntPtr** origin, IntPtr** region, IntPtr* image_row_pitch, IntPtr* image_slice_pitch, uint num_events_in_wait_list, IntPtr* event_wait_list, IntPtr* @event, [OutAttribute] int* errcode_ret);
Ejemplo n.º 35
0
 /// <summary>
 /// Acquires access to the surface data.
 /// </summary>
 /// <param name="flags">Flags specifying CPU access permissions.</param>
 /// <returns>A <see cref="T:SharpDX.DataRectangle" /> for accessing the mapped data, or <c>null</c> on failure.</returns>.
 public DataRectangle Map(MapFlags flags)
 {
     MappedRectangle mappedRect;
     Map(out mappedRect, (int) flags);
     return new DataRectangle(mappedRect.PBits, mappedRect.Pitch);
 }
Ejemplo n.º 36
0
        public Event EnqueueMapImage(Image image, bool blocking, MapFlags mapFlags, BufferCoordinates origin, BufferSize region, out long rowPitch, out long slicePitch, out IntPtr mappedPointer, params Event[] eventWaitList)
        {
            EventSafeHandle[] eventHandles = null;
            if (eventWaitList != null)
                eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle);

            IntPtr imageRowPitch;
            IntPtr imageSlicePitch;
            EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapImage(this.Handle, image.Handle, blocking, mapFlags, ref origin, ref region, out imageRowPitch, out imageSlicePitch, out mappedPointer, eventHandles);
            rowPitch = imageRowPitch.ToInt64();
            slicePitch = imageSlicePitch.ToInt64();
            return new Event(handle);
        }
Ejemplo n.º 37
0
        public Event EnqueueMapBuffer(Buffer buffer, bool blocking, MapFlags mapFlags, long offset, long size, out IntPtr mappedPointer, params Event[] eventWaitList)
        {
            EventSafeHandle[] eventHandles = null;
            if (eventWaitList != null)
                eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle);

            EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapBuffer(this.Handle, buffer.Handle, blocking, mapFlags, (IntPtr)offset, (IntPtr)size, out mappedPointer, eventHandles);
            return new Event(handle);
        }
Ejemplo n.º 38
0
        public IntPtr EnqueueMapImage(Mem image, bool blockingMap, MapFlags map_flags, long[] origin, long[] region, out long image_row_pitch, out long image_slice_pitch)
        {
            void* pMappedPtr;
            ErrorCode result;
            IntPtr* repackedOrigin = stackalloc IntPtr[3];
            IntPtr* repackedRegion = stackalloc IntPtr[3];

            InteropTools.A3ToIntPtr3(origin, repackedOrigin);
            InteropTools.A3ToIntPtr3(region, repackedRegion);

            pMappedPtr = OpenCL.EnqueueMapImage(CommandQueueID, image, (uint)(blockingMap ? Bool.TRUE : Bool.TRUE), (ulong)map_flags, repackedOrigin, repackedRegion, out image_row_pitch, out image_slice_pitch, 0, null, null, out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapImage failed with error code " + result, result);
            return (IntPtr)pMappedPtr;
        }
Ejemplo n.º 39
0
        public IntPtr EnqueueMapBuffer(Mem buffer, bool blockingMap, MapFlags map_flags, long offset, long cb, int num_events_in_wait_list, Event[] event_wait_list)
        {
            void* pMappedPtr;
            ErrorCode result;
            IntPtr* repackedEvents = stackalloc IntPtr[num_events_in_wait_list];

            if (num_events_in_wait_list == 0)
                repackedEvents = null;
            InteropTools.ConvertEventsToEventIDs(num_events_in_wait_list, event_wait_list, repackedEvents);

            pMappedPtr = OpenCL.EnqueueMapBuffer(CommandQueueID, buffer, blockingMap ? (uint)Bool.TRUE : (uint)Bool.FALSE, (ulong)map_flags, offset, cb, num_events_in_wait_list, repackedEvents, null, out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapBuffer failed with error code " + result, result);
            return (IntPtr)pMappedPtr;
        }
Ejemplo n.º 40
0
        public IntPtr EnqueueMapBuffer(Mem buffer, bool blockingMap, MapFlags map_flags, IntPtr offset, IntPtr cb, int num_events_in_wait_list, Event[] event_wait_list)
        {
            ErrorCode result;
            IntPtr ptr;

            ptr = (IntPtr)OpenCL.EnqueueMapBuffer(CommandQueueID,
                buffer.MemID,
                (uint)(blockingMap ? Bool.TRUE : Bool.FALSE),
                (ulong)map_flags,
                offset,
                cb,
                (uint)num_events_in_wait_list,
                InteropTools.ConvertEventsToEventIDs(event_wait_list),
                null,
                out result);

            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapBuffer failed with error code " + result, result);
            return ptr;
        }
Ejemplo n.º 41
0
        public IntPtr EnqueueMapImage(Mem image, bool blockingMap, MapFlags map_flags, IntPtr[] origin, IntPtr[] region, out IntPtr image_row_pitch, out IntPtr image_slice_pitch, int num_events_in_wait_list, Event[] event_wait_list)
        {
            IntPtr ptr;
            ErrorCode result;

            ptr = (IntPtr)OpenCL.EnqueueMapImage(CommandQueueID,
                image.MemID,
                (uint)(blockingMap ? Bool.TRUE : Bool.FALSE),
                (ulong)map_flags,
                origin,
                region,
                out image_row_pitch,
                out image_slice_pitch,
                (uint)num_events_in_wait_list,
                InteropTools.ConvertEventsToEventIDs(event_wait_list),
                null,
                out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapImage failed with error code " + result, result);
            return ptr;
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Maps the texture, providing CPU access to its contents.
        /// </summary>
        /// <param name="mipSlice">The mip slice to map.</param>
        /// <param name="mode">The IO operations to enable on the CPU.</param>
        /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
        /// <param name="dataStream">The data stream.</param>
        /// <returns>
        /// A data rectangle containing the mapped data. This data stream is invalidated when the buffer is unmapped.
        /// </returns>
        public DataRectangle Map(int mipSlice, MapMode mode, MapFlags flags, out DataStream dataStream)
        {
            var desc = Description;
            int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels);
            int mipHeight = GetMipSize(mipSlice, desc.Height);

            DataRectangle mappedTexture2D;
            Map(subresource, mode, flags, out mappedTexture2D);

            bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;
            dataStream = new DataStream(mappedTexture2D.DataPointer, mipHeight * mappedTexture2D.Pitch, canRead, canWrite);

            return mappedTexture2D;
        }
Ejemplo n.º 43
0
        public IntPtr EnqueueMapImage(Mem image, bool blockingMap, MapFlags map_flags, long[] origin, long[] region, out long image_row_pitch, out long image_slice_pitch, int num_events_in_wait_list, Event[] event_wait_list)
        {
            void* pMappedPtr;
            ErrorCode result;
            IntPtr* repackedOrigin = stackalloc IntPtr[3];
            IntPtr* repackedRegion = stackalloc IntPtr[3];
            IntPtr* repackedEvents = stackalloc IntPtr[num_events_in_wait_list];

            if (num_events_in_wait_list == 0)
                repackedEvents = null;
            InteropTools.A3ToIntPtr3(origin, repackedOrigin);
            InteropTools.A3ToIntPtr3(region, repackedRegion);
            InteropTools.ConvertEventsToEventIDs(num_events_in_wait_list, event_wait_list, repackedEvents);

            pMappedPtr = OpenCL.EnqueueMapImage(CommandQueueID, image, (uint)(blockingMap ? Bool.TRUE : Bool.TRUE), (ulong)map_flags, repackedOrigin, repackedRegion, out image_row_pitch, out image_slice_pitch, num_events_in_wait_list, repackedEvents, null, out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapImage failed with error code " + result, result);
            return (IntPtr)pMappedPtr;
        }
Ejemplo n.º 44
0
		public static extern int LCMapStringW(int Local, MapFlags dwMapFlags,
			[MarshalAs(UnmanagedType.LPWStr)]string lpSrcStr, int cchSrc,
			[MarshalAs(UnmanagedType.LPWStr)]string lpDestStr, int cchDest);
Ejemplo n.º 45
0
 /// <summary>
 /// Acquires access to the surface data.
 /// </summary>
 /// <param name="flags">Flags specifying CPU access permissions.</param>
 /// <param name="dataStream">Stream to contain the surface data.</param>
 /// <returns>A <see cref="T:SharpDX.DataRectangle" /> for accessing the mapped data, or <c>null</c> on failure.</returns>.
 public DataRectangle Map(MapFlags flags, out DataStream dataStream)
 {
     var dataRectangle = Map(flags);
     dataStream = new DataStream(dataRectangle.DataPointer, Description.Height * dataRectangle.Pitch, true, true);
     return dataRectangle;
 }
Ejemplo n.º 46
0
 internal extern static unsafe IntPtr EnqueueMapBuffer(IntPtr command_queue, IntPtr buffer, bool blocking_map, MapFlags map_flags, IntPtr offset, IntPtr cb, uint num_events_in_wait_list, IntPtr* event_wait_list, IntPtr* @event, [OutAttribute] int* errcode_ret);
Ejemplo n.º 47
0
        public IntPtr EnqueueMapImage(Mem image, bool blockingMap, MapFlags map_flags, IntPtr[] origin, IntPtr[] region, out IntPtr image_row_pitch, out IntPtr image_slice_pitch)
        {
            IntPtr ptr;
            ErrorCode result;

            ptr = (IntPtr)OpenCL.EnqueueMapImage(CommandQueueID,
                image.MemID,
                (uint)(blockingMap ? Bool.TRUE : Bool.FALSE),
                (ulong)map_flags,
                origin,
                region,
                out image_row_pitch,
                out image_slice_pitch,
                (uint)0,
                null,
                null,
                out result);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueMapImage failed with error code " + result, result);
            return ptr;
        }
Ejemplo n.º 48
0
		public extern static IntPtr clEnqueueMapBuffer (
			IntPtr command_queue,
			IntPtr buffer,
			CL_Bool blocking_map,
			MapFlags map_flags,
			IntPtr offset,
			IntPtr cb,
			uint num_events_in_wait_list,
			IntPtr[] event_wait_list,
			IntPtr event_wait,
			out int errcode_ret);