/// <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(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; 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; }
private static SharpDX.Direct3D12.ResourceDescription ConvertToNativeDescription(GraphicsDevice graphicsDevice, BufferDescription bufferDescription) { var size = bufferDescription.SizeInBytes; // TODO D3D12 for now, ensure size is multiple of ConstantBufferDataPlacementAlignment (for cbuffer views) size = (size + graphicsDevice.ConstantBufferDataPlacementAlignment - 1) / graphicsDevice.ConstantBufferDataPlacementAlignment * graphicsDevice.ConstantBufferDataPlacementAlignment; return SharpDX.Direct3D12.ResourceDescription.Buffer(size); }
private static SharpDX.Direct3D12.ResourceDescription ConvertToNativeDescription(BufferDescription bufferDescription) { var size = bufferDescription.SizeInBytes; // TODO D3D12 for now, ensure size is multiple of 256 (for cbuffer views) size = (size + 255) & ~255; return SharpDX.Direct3D12.ResourceDescription.Buffer(size); }
private static SharpDX.Direct3D12.ResourceDescription ConvertToNativeDescription(BufferDescription bufferDescription) { var size = bufferDescription.SizeInBytes; // TODO D3D12 for now, ensure size is multiple of 256 (for cbuffer views) size = (size + 255) & ~255; return(SharpDX.Direct3D12.ResourceDescription.Buffer(size)); }