public Buffer(BufferDescription description, BufferFlags flags) { _description = description; _flags = flags; _nativeBuffer = new SharpDX.Direct3D11.Buffer(GraphicManager.Device, description); }
/// <summary> /// Initializes a new instance of <see cref="BufferDescription"/> struct. /// </summary> /// <param name="sizeInBytes">Size of the buffer in bytes.</param> /// <param name="bufferFlags">Buffer flags describing the type of buffer.</param> /// <param name="usage">Usage of this buffer.</param> /// <param name="structureByteStride">The size of the structure (in bytes) when it represents a structured/typed buffer. Default = 0.</param> public BufferDescription(int sizeInBytes, BufferFlags bufferFlags, GraphicsResourceUsage usage, int structureByteStride = 0) { SizeInBytes = sizeInBytes; BufferFlags = bufferFlags; Usage = usage; StructureByteStride = structureByteStride; }
public Buffer(BufferDescription description) { _description = description; _flags = GetBufferFlagsFromDescription(description); _nativeBuffer = new SharpDX.Direct3D11.Buffer(GraphicManager.Device, description); }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="description">The description.</param> /// <param name="bufferFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer(GraphicsDevice device, BufferDescription description, BufferFlags bufferFlags, PixelFormat viewFormat, IntPtr dataPointer) : base(device) { Description = description; BufferFlags = bufferFlags; ViewFormat = viewFormat; //InitCountAndViewFormat(out this.elementCount, ref ViewFormat); //Initialize(device.RootDevice, null); }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="description">The description.</param> /// <param name="viewFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer) { bufferDescription = description; nativeDescription = ConvertToNativeDescription(Description); ViewFlags = viewFlags; InitCountAndViewFormat(out this.elementCount, ref viewFormat); ViewFormat = viewFormat; NativeDeviceChild = new SharpDX.Direct3D11.Buffer(GraphicsDevice.RootDevice.NativeDevice, dataPointer, nativeDescription); // Staging resource don't have any views if (nativeDescription.Usage != ResourceUsage.Staging) this.InitializeViews(); return this; }
private static BufferDescription NewDescription(int bufferSize, int elementSize, BufferFlags bufferFlags, ResourceUsage usage) { var desc = new BufferDescription() { SizeInBytes = bufferSize, StructureByteStride = elementSize, // We keep the element size in the structure byte stride, even if it is not a structured buffer CpuAccessFlags = GetCputAccessFlagsFromUsage(usage), BindFlags = BindFlags.None, OptionFlags = ResourceOptionFlags.None, Usage = usage, }; if ((bufferFlags & BufferFlags.ConstantBuffer) != 0) desc.BindFlags |= BindFlags.ConstantBuffer; if ((bufferFlags & BufferFlags.IndexBuffer) != 0) desc.BindFlags |= BindFlags.IndexBuffer; if ((bufferFlags & BufferFlags.VertexBuffer) != 0) desc.BindFlags |= BindFlags.VertexBuffer; if ((bufferFlags & BufferFlags.RenderTarget) != 0) desc.BindFlags |= BindFlags.RenderTarget; if ((bufferFlags & BufferFlags.ShaderResource) != 0) desc.BindFlags |= BindFlags.ShaderResource; if ((bufferFlags & BufferFlags.UnorderedAccess) != 0) desc.BindFlags |= BindFlags.UnorderedAccess; if ((bufferFlags & BufferFlags.StreamOutput) != 0) desc.BindFlags |= BindFlags.StreamOutput; if ((bufferFlags & BufferFlags.StructuredBuffer) != 0) { desc.OptionFlags |= ResourceOptionFlags.BufferStructured; if (elementSize == 0) throw new ArgumentException("Element size cannot be set to 0 for structured buffer"); } if ((bufferFlags & BufferFlags.RawBuffer) == BufferFlags.RawBuffer) desc.OptionFlags |= ResourceOptionFlags.BufferAllowRawViews; if ((bufferFlags & BufferFlags.ArgumentBuffer) == BufferFlags.ArgumentBuffer) desc.OptionFlags |= ResourceOptionFlags.DrawIndirectArguments; return desc; }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="description">The description.</param> /// <param name="viewFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer) { bufferDescription = description; nativeDescription = ConvertToNativeDescription(GraphicsDevice, Description); ViewFlags = viewFlags; InitCountAndViewFormat(out this.elementCount, ref viewFormat); ViewFormat = viewFormat; Recreate(dataPointer); if (GraphicsDevice != null) { GraphicsDevice.BuffersMemory += SizeInBytes/(float)0x100000; } return this; }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="description">The description.</param> /// <param name="viewFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer) { bufferDescription = description; ViewFlags = viewFlags; #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES int pixelSize; bool isCompressed; OpenGLConvertExtensions.ConvertPixelFormat(GraphicsDevice, ref viewFormat, out internalFormat, out glPixelFormat, out type, out pixelSize, out isCompressed); #endif ViewFormat = viewFormat; Recreate(dataPointer); return this; }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="description">The description.</param> /// <param name="viewFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer) { bufferDescription = description; ViewFlags = viewFlags; bool isCompressed; OpenGLConvertExtensions.ConvertPixelFormat(GraphicsDevice, ref viewFormat, out TextureInternalFormat, out TextureFormat, out TextureType, out bufferTextureElementSize, out isCompressed); ViewFormat = viewFormat; Recreate(dataPointer); if (GraphicsDevice != null) { GraphicsDevice.BuffersMemory += SizeInBytes/(float)0x100000; } return this; }
/// <summary> /// Initializes a new instance of the <see cref="Buffer" /> class. /// </summary> /// <param name="description">The description.</param> /// <param name="viewFlags">Type of the buffer.</param> /// <param name="viewFormat">The view format.</param> /// <param name="dataPointer">The data pointer.</param> protected Buffer InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer) { bufferDescription = description; ViewFlags = viewFlags; #if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES int pixelSize; bool isCompressed; OpenGLConvertExtensions.ConvertPixelFormat(GraphicsDevice, ref viewFormat, out internalFormat, out glPixelFormat, out type, out pixelSize, out isCompressed); #endif ViewFormat = viewFormat; Recreate(dataPointer); if (GraphicsDevice != null) { GraphicsDevice.BuffersMemory += SizeInBytes/(float)0x100000; } return this; }
/// <summary> /// Initializes a new instance of the <see cref="IndexBuffer"/> struct. /// </summary> /// <param name="memory">The 16-bit index data used to populate the buffer.</param> /// <param name="flags">Flags used to control buffer behavior.</param> public IndexBuffer(MemoryBlock memory, BufferFlags flags = BufferFlags.None) { handle = NativeMethods.bgfx_create_index_buffer(memory.ptr, flags); }
private static BufferDescription NewDescription(int bufferSize, int elementSize, BufferFlags bufferFlags, GraphicsResourceUsage usage) { return(new BufferDescription() { SizeInBytes = bufferSize, StructureByteStride = (bufferFlags & BufferFlags.StructuredBuffer) != 0 ? elementSize : 0, BufferFlags = bufferFlags, Usage = usage, }); }
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="dataPointer">The data pointer.</param> /// <param name="elementSize">Size of the element.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer New(GraphicsDevice device, DataPointer dataPointer, int elementSize, BufferFlags bufferFlags, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) { return(New(device, dataPointer, elementSize, bufferFlags, PixelFormat.None, usage)); }
/// <summary> /// Initializes a new instance of the <see cref="VertexBuffer"/> struct. /// </summary> /// <param name="memory">The vertex data with which to populate the buffer.</param> /// <param name="layout">The layout of the vertex data.</param> /// <param name="flags">Flags used to control buffer behavior.</param> public VertexBuffer(MemoryBlock memory, VertexLayout layout, BufferFlags flags = BufferFlags.None) { handle = NativeMethods.bgfx_create_vertex_buffer(memory.ptr, ref layout.data, flags); }
public static extern ushort bgfx_create_dynamic_vertex_buffer(int vertexCount, ref VertexLayout.Data decl, BufferFlags flags);
public static extern ushort bgfx_create_dynamic_index_buffer(int indexCount, BufferFlags flags);
public BufferData(BufferFlags bufferFlags, byte[] content) { Content = content; BufferFlags = bufferFlags; }
/// <summary> /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Default"/> uasge by default. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="size">The size in bytes.</param> /// <param name="usage">The usage.</param> /// <param name="bindFlags">The bind flags, can be combined with <see cref="BufferFlags.StreamOutput"/> to use the buffer as a stream output target.</param> /// <returns> /// A Vertex buffer /// </returns> public static Buffer New(GraphicsDevice device, int size, GraphicsResourceUsage usage = GraphicsResourceUsage.Default, BufferFlags bindFlags = BufferFlags.VertexBuffer) { return(Buffer.New(device, size, bindFlags, usage)); }
/// <summary> /// Creates a new StructuredCounter buffer <see cref="GraphicsResourceUsage.Default" /> uasge. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="value">The value to initialize the StructuredCounter buffer.</param> /// <param name="elementSize">Size of the element.</param> /// <returns>A StructuredCounter buffer</returns> public static Buffer New(GraphicsDevice device, DataPointer value, int elementSize) { const BufferFlags BufferFlags = BufferFlags.StructuredCounterBuffer | BufferFlags.ShaderResource | BufferFlags.UnorderedAccess; return(Buffer.New(device, value, elementSize, BufferFlags)); }
/// <summary> /// Creates a new StructuredCounter buffer <see cref="GraphicsResourceUsage.Default" /> uasge. /// </summary> /// <typeparam name="T">Type of the StructuredCounter buffer to get the sizeof from</typeparam> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="value">The value to initialize the StructuredCounter buffer.</param> /// <returns>A StructuredCounter buffer</returns> public static Buffer New <T>(GraphicsDevice device, T[] value) where T : struct { const BufferFlags BufferFlags = BufferFlags.StructuredCounterBuffer | BufferFlags.ShaderResource | BufferFlags.UnorderedAccess; return(Buffer.New(device, value, BufferFlags)); }
/// <summary> /// Creates a new StructuredCounter buffer accessible as a <see cref="ShaderResourceView" /> and optionaly as a <see cref="UnorderedAccessView" />. /// </summary> /// <typeparam name="T">Type of the element in the structured buffer</typeparam> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="count">The number of element in this buffer.</param> /// <returns>A Structured buffer</returns> public static Buffer <T> New <T>(GraphicsDevice device, int count) where T : struct { const BufferFlags BufferFlags = BufferFlags.StructuredCounterBuffer | BufferFlags.ShaderResource | BufferFlags.UnorderedAccess; return(Buffer.New <T>(device, count, BufferFlags)); }
/// <summary> /// Creates a new StructuredAppend buffer accessible as a <see cref="ShaderResourceView" /> and as a <see cref="UnorderedAccessView" />. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="count">The number of element in this buffer.</param> /// <param name="elementSize">Size of the struct.</param> /// <returns>A StructuredAppend buffer</returns> public static Buffer New(GraphicsDevice device, int count, int elementSize) { const BufferFlags BufferFlags = BufferFlags.StructuredAppendBuffer | BufferFlags.ShaderResource | BufferFlags.UnorderedAccess; return(Buffer.New(device, count * elementSize, elementSize, BufferFlags)); }
/// <summary> /// Creates a new Raw buffer <see cref="ResourceUsage.Default"/> usage. /// </summary> /// <typeparam name="T">Type of the Raw buffer to get the sizeof from</typeparam> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="value">The value to initialize the Raw buffer.</param> /// <param name="additionalBindings">The additional bindings (for example, to create a combined raw/index buffer, pass <see cref="BufferFlags.IndexBuffer" />)</param> /// <param name="usage">The usage of this resource.</param> /// <returns>A Raw buffer</returns> public static Buffer <T> New <T>(GraphicsDevice device, T[] value, BufferFlags additionalBindings = BufferFlags.None, ResourceUsage usage = ResourceUsage.Default) where T : struct { return(Buffer.New(device, value, BufferFlags.RawBuffer | additionalBindings, usage)); }
public EditBuffer(string name, BufferFlags flags) { this.name = name; this.flags = flags; }
public static extern void hb_buffer_set_flags(hb_buffer_t buffer, BufferFlags flags);
public static extern ushort bgfx_create_dynamic_index_buffer_mem(MemoryBlock.DataPtr *memory, BufferFlags flags);
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="bufferSize">Size of the buffer in bytes.</param> /// <param name="elementSize">Size of an element in the buffer.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer New(GraphicsDevice device, int bufferSize, int elementSize, BufferFlags bufferFlags, PixelFormat viewFormat, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) { viewFormat = CheckPixelFormat(bufferFlags, elementSize, viewFormat); var description = NewDescription(bufferSize, elementSize, bufferFlags, usage); return(new Buffer(device, description, bufferFlags, viewFormat, IntPtr.Zero)); }
public static extern ushort bgfx_create_dynamic_vertex_buffer_mem(MemoryBlock.DataPtr *memory, ref VertexLayout.Data decl, BufferFlags flags);
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <typeparam name="T">Type of the buffer, to get the sizeof from.</typeparam> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="initialValue">The initial value of this buffer.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static unsafe Buffer <T> New <T>(GraphicsDevice device, T[] initialValue, BufferFlags bufferFlags, PixelFormat viewFormat, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) where T : struct { int bufferSize = Utilities.SizeOf <T>() * initialValue.Length; int elementSize = Utilities.SizeOf <T>(); viewFormat = CheckPixelFormat(bufferFlags, elementSize, viewFormat); var description = NewDescription(bufferSize, elementSize, bufferFlags, usage); return(new Buffer <T>(device, description, bufferFlags, viewFormat, (IntPtr)Interop.Fixed(initialValue))); }
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="bufferSize">Size of the buffer in bytes.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer New(GraphicsDevice device, int bufferSize, BufferFlags bufferFlags, PixelFormat viewFormat, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) { return(New(device, bufferSize, 0, bufferFlags, viewFormat, usage)); }
void SetOrClearFlag(bool set, BufferFlags f) { if (set) SetFlag(f); else ClearFlag(f); }
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <typeparam name="T">Type of the buffer, to get the sizeof from.</typeparam> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="initialValue">The initial value of this buffer.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer <T> New <T>(GraphicsDevice device, T[] initialValue, BufferFlags bufferFlags, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) where T : struct { return(New(device, initialValue, bufferFlags, PixelFormat.None, usage)); }
internal static IPythonBuffer?GetBufferNoThrow(this IBufferProtocol bufferProtocol, BufferFlags flags = BufferFlags.Simple) { try { return(bufferProtocol.GetBuffer(flags)); } catch (BufferException) { return(null); } }
/// <summary> /// Creates a new <see cref="Buffer" /> instance from a byte array. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="initialValue">The initial value of this buffer.</param> /// <param name="elementSize">Size of an element. Must be equal to 2 or 4 for an index buffer, or to the size of a struct for a structured/typed buffer. Can be set to 0 for other buffers.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static unsafe Buffer New(GraphicsDevice device, byte[] initialValue, int elementSize, BufferFlags bufferFlags, PixelFormat viewFormat = PixelFormat.None, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) { int bufferSize = initialValue.Length; viewFormat = CheckPixelFormat(bufferFlags, elementSize, viewFormat); var description = NewDescription(bufferSize, elementSize, bufferFlags, usage); return(new Buffer(device, description, bufferFlags, viewFormat, (IntPtr)Interop.Fixed(initialValue))); }
/// <summary> /// Initializes a new instance of the <see cref="DynamicIndexBuffer"/> struct. /// </summary> /// <param name="indexCount">The number of indices that can fit in the buffer.</param> /// <param name="flags">Flags used to control buffer behavior.</param> public DynamicIndexBuffer(int indexCount, BufferFlags flags = BufferFlags.None) { handle = NativeMethods.bgfx_create_dynamic_index_buffer(indexCount, flags); }
/// <summary> /// Creates a new <see cref="Buffer" /> instance. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="dataPointer">The data pointer.</param> /// <param name="elementSize">Size of the element.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer New(GraphicsDevice device, DataPointer dataPointer, int elementSize, BufferFlags bufferFlags, PixelFormat viewFormat, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) { int bufferSize = dataPointer.Size; viewFormat = CheckPixelFormat(bufferFlags, elementSize, viewFormat); var description = NewDescription(bufferSize, elementSize, bufferFlags, usage); return(new Buffer(device, description, bufferFlags, viewFormat, dataPointer.Pointer)); }
public static extern ushort bgfx_create_dynamic_vertex_buffer(int vertexCount, ref VertexLayout.Data decl, BufferFlags flags);
/// <summary> /// Creates a new Raw buffer with <see cref="GraphicsResourceUsage.Default"/> uasge by default. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="value">The value to initialize the Raw buffer.</param> /// <param name="additionalBindings">The additional bindings (for example, to create a combined raw/index buffer, pass <see cref="BufferFlags.IndexBuffer" />)</param> /// <param name="usage">The usage of this resource.</param> /// <returns>A Raw buffer</returns> public static Buffer New(GraphicsDevice device, DataPointer value, BufferFlags additionalBindings = BufferFlags.None, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) { return(Buffer.New(device, value, 0, BufferFlags.RawBuffer | additionalBindings, usage)); }
public static extern ushort bgfx_create_index_buffer(MemoryBlock.DataPtr* memory, BufferFlags flags);
/// <summary> /// Creates a new Raw buffer <see cref="ResourceUsage.Default" /> usage. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="size">The size in bytes.</param> /// <param name="additionalBindings">The additional bindings (for example, to create a combined raw/index buffer, pass <see cref="BufferFlags.IndexBuffer" />)</param> /// <param name="usage">The usage.</param> /// <returns>A Raw buffer</returns> public static Buffer New(GraphicsDevice device, int size, BufferFlags additionalBindings = BufferFlags.None, ResourceUsage usage = ResourceUsage.Default) { return(Buffer.New(device, size, BufferFlags.RawBuffer | additionalBindings, usage)); }
void SetFlag(BufferFlags f) { flags |= f; }
/// <summary> /// Creates a new <see cref="Buffer" /> instance from a byte array. /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/>.</param> /// <param name="initialValue">The initial value of this buffer.</param> /// <param name="elementSize">Size of an element. Must be equal to 2 or 4 for an index buffer, or to the size of a struct for a structured/typed buffer. Can be set to 0 for other buffers.</param> /// <param name="bufferFlags">The buffer flags to specify the type of buffer.</param> /// <param name="viewFormat">The view format must be specified if the buffer is declared as a shared resource view.</param> /// <param name="usage">The usage.</param> /// <returns>An instance of a new <see cref="Buffer" /></returns> public static Buffer New(GraphicsDevice device, byte[] initialValue, int elementSize, BufferFlags bufferFlags, PixelFormat viewFormat = PixelFormat.None, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) { return(new Buffer(device).InitializeFrom(initialValue, elementSize, bufferFlags, viewFormat, usage)); }
void ClearFlag(BufferFlags f) { flags &= ~f; }
public static extern ushort bgfx_create_dynamic_index_buffer(int indexCount, BufferFlags flags);
public MemoryView([NotNull] IBufferProtocol @object) { _exporter = @object; // MemoryView should support all possible buffer exports (BufferFlags.FullRO) // but handling of suboffsets (BufferFlags.Indirect) is not implemented yet. // Hence the request is for BufferFlags.RecordsRO _flags = BufferFlags.RecordsRO; _buffer = @object.GetBuffer(_flags); // doublecheck that we don't have to deal with suboffsets if (_buffer.SubOffsets != null) { throw PythonOps.NotImplementedError("memoryview: indirect buffers are not supported"); } ReadOnlySpan <byte> memblock = _buffer.AsReadOnlySpan(); if ((_buffer.ItemCount != 0 && !VerifyStructure(memblock.Length, _buffer.ItemSize, _buffer.NumOfDims, _buffer.Shape, _buffer.Strides, _buffer.Offset)) || (_buffer.Shape == null && (_buffer.Offset != 0 || _buffer.NumBytes() != memblock.Length)) ) { throw PythonOps.BufferError("memoryview: invalid buffer exported from object of type {0}", PythonOps.GetPythonTypeName(@object)); } _offset = _buffer.Offset; _isReadOnly = _buffer.IsReadOnly; _numDims = _buffer.NumOfDims; // in flags we requested format be provided, check that the exporter complied if (_buffer.Format == null) { throw PythonOps.BufferError("memoryview: object of type {0} did not report its format", PythonOps.GetPythonTypeName(@object)); } _format = _buffer.Format; _itemSize = _buffer.ItemSize; // for convenience _shape and _strides are never null, even if _numDims == 0 or _flags indicate no _shape or _strides _shape = _buffer.Shape ?? (_numDims > 0 ? new int[] { _buffer.ItemCount } : new int[0]); // TODO: use a static singleton if (_shape.Count == 0) { _strides = _shape; // TODO: use a static singleton _isCContig = true; } else if (_buffer.Strides != null) { _strides = _buffer.Strides; _isCContig = true; for (int i = _strides.Count - 1, curStride = _itemSize; i >= 0 && _isCContig; i--) { _isCContig &= _strides[i] == curStride; curStride *= _shape[i]; } } else { _strides = GetContiguousStrides(_shape, _itemSize); _isCContig = true; } // invariants _numItems = _buffer.ItemCount; _isFContig = _isCContig && _numDims <= 1; // TODO: support for ND Fortran arrays not implemented // sanity check Debug.Assert(_numItems == 0 || VerifyStructure(memblock.Length, _itemSize, _numDims, _numDims > 0 ? _shape : null, _numDims > 0 ? _strides : null, _offset)); }
public static extern ushort bgfx_create_dynamic_vertex_buffer_mem(MemoryBlock.DataPtr* memory, ref VertexLayout.Data decl, BufferFlags flags);
/// <summary> /// Initializes a new instance of the <see cref="DynamicVertexBuffer"/> struct. /// </summary> /// <param name="vertexCount">The number of vertices that fit in the buffer.</param> /// <param name="layout">The layout of the vertex data.</param> /// <param name="flags">Flags used to control buffer behavior.</param> public DynamicVertexBuffer(int vertexCount, VertexLayout layout, BufferFlags flags = BufferFlags.None) { handle = NativeMethods.bgfx_create_dynamic_vertex_buffer(vertexCount, ref layout.data, flags); }
public BytesView(Bytes bytes, BufferFlags flags) { _exporter = bytes; _flags = flags; }
bool IsFlagSet(BufferFlags f) { return (flags & f) != 0; }