/// <summary> /// Creates a new instance of the <see cref="T:SharpDX.Direct3D11.Buffer"/> class. /// </summary> /// <typeparam name="T">Type of the data to upload</typeparam> /// <param name="device">The device with which to associate the buffer.</param> /// <param name="bindFlags">Flags specifying how the buffer will be bound to the pipeline.</param> /// <param name="data">Initial data used to initialize the buffer.</param> /// <param name="sizeInBytes">The size, in bytes, of the buffer. If 0 is specified, sizeof(T) is used. </param> /// <param name="usage">The usage pattern for the buffer.</param> /// <param name="accessFlags">Flags specifying how the buffer will be accessible from the CPU.</param> /// <param name="optionFlags">Miscellaneous resource options.</param> /// <param name="structureByteStride">The size (in bytes) of the structure element for structured buffers.</param> /// <returns>An initialized buffer</returns> /// <msdn-id>ff476501</msdn-id> /// <unmanaged>HRESULT ID3D11Device::CreateBuffer([In] const D3D11_BUFFER_DESC* pDesc,[In, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Buffer** ppBuffer)</unmanaged> /// <unmanaged-short>ID3D11Device::CreateBuffer</unmanaged-short> public static Buffer Create <T>( Device device, BindFlags bindFlags, ref T data, int sizeInBytes = 0, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags accessFlags = CpuAccessFlags.None, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, int structureByteStride = 0) where T : struct { var buffer = new Buffer(IntPtr.Zero); var description = new BufferDescription() { BindFlags = bindFlags, CpuAccessFlags = accessFlags, OptionFlags = optionFlags, SizeInBytes = sizeInBytes == 0 ? Utilities.SizeOf <T>() : sizeInBytes, Usage = usage, StructureByteStride = structureByteStride }; unsafe { device.CreateBuffer(ref description, new DataBox((IntPtr)Interop.Fixed(ref data)), buffer); } return(buffer); }
public D3DTexture2D( Device device, BindFlags bindFlags, ResourceUsage usage, CpuAccessFlags cpuAccessFlags, SharpDX.DXGI.Format format, IntPtr pixelPtr, int width, int height, int stride) { _device = device; Texture2DDescription desc = CreateDescription(width, height, bindFlags, usage, cpuAccessFlags, format); if (pixelPtr != IntPtr.Zero) { DataRectangle dataRectangle = new DataRectangle(pixelPtr, stride); DeviceTexture = new Texture2D(device, desc, dataRectangle); } else { DeviceTexture = new Texture2D(device, desc); } }
/// <summary> /// Creates a new <see cref="ConstantBuffer" />. /// </summary> /// <typeparam name="T"> Generic type parameter. </typeparam> /// <param name="graphicsDevice"> The graphics device. </param> /// <param name="resourceUsage"> (Optional) The resource usage. </param> /// <param name="cpuAccessFlags"> (Optional) The CPU access flags. </param> /// <returns> /// A <see cref="ConstantBuffer" />. /// </returns> public static unsafe ConstantBuffer Create <T>(IGraphicsDevice graphicsDevice, ResourceUsage resourceUsage = ResourceUsage.Default, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) where T : unmanaged { return(Create(graphicsDevice, sizeof(T), resourceUsage, cpuAccessFlags)); }
public void Init( string name, int width, int height, Format resourceFormat, Format srvFormat, BindFlags bindFlags, int samplesCount, int samplesQuality, ResourceOptionFlags roFlags, ResourceUsage ru, int mipmapLevels, CpuAccessFlags cpuAccessFlags) { m_name = name; m_size = new Vector2I(width, height); m_resourceFormat = resourceFormat; m_srvFormat = srvFormat; m_bindFlags = bindFlags; m_samplesCount = samplesCount; m_samplesQuality = samplesQuality; m_roFlags = roFlags; m_resourceUsage = ru; m_mipmapLevels = mipmapLevels; m_cpuAccessFlags = cpuAccessFlags; }
internal static TextureUsage GetVdUsage(BindFlags bindFlags, CpuAccessFlags cpuFlags, ResourceOptionFlags optionFlags) { TextureUsage usage = 0; if ((bindFlags & BindFlags.RenderTarget) != 0) { usage |= TextureUsage.RenderTarget; } if ((bindFlags & BindFlags.DepthStencil) != 0) { usage |= TextureUsage.DepthStencil; } if ((bindFlags & BindFlags.ShaderResource) != 0) { usage |= TextureUsage.Sampled; } if ((bindFlags & BindFlags.UnorderedAccess) != 0) { usage |= TextureUsage.Storage; } if ((optionFlags & ResourceOptionFlags.TextureCube) != 0) { usage |= TextureUsage.Cubemap; } if ((optionFlags & ResourceOptionFlags.GenerateMipMaps) != 0) { usage |= TextureUsage.GenerateMipmaps; } return(usage); }
private void UpdateTexture(EvaluationContext context) { Int3 size = Size.GetValue(context); if (size.X < 1 || size.Y < 1 || size.Z < 1) { Log.Warning($"Requested invalid texture resolution: {size}"); return; } var texDesc = new Texture3DDescription { Width = size.X, Height = size.Y, Depth = size.Z, MipLevels = MipLevels.GetValue(context), Format = Format.GetValue(context), Usage = ResourceUsage.GetValue(context), BindFlags = BindFlags.GetValue(context), CpuAccessFlags = CpuAccessFlags.GetValue(context), OptionFlags = ResourceOptionFlags.GetValue(context) }; var rm = ResourceManager.Instance(); rm.CreateTexture3d(texDesc, "Texture3D", ref _textureResId, ref OutputTexture.Value.Texture); if ((BindFlags.Value & SharpDX.Direct3D11.BindFlags.ShaderResource) > 0) rm.CreateShaderResourceView(_textureResId, "", ref OutputTexture.Value.Srv); if ((BindFlags.Value & SharpDX.Direct3D11.BindFlags.RenderTarget) > 0) rm.CreateRenderTargetView(_textureResId, "", ref OutputTexture.Value.Rtv); if ((BindFlags.Value & SharpDX.Direct3D11.BindFlags.UnorderedAccess) > 0) rm.CreateUnorderedAccessView(_textureResId, "", ref OutputTexture.Value.Uav); }
/// <summary> /// Initializes a new instance of the <see cref="Texture1DDescription"/> struct. /// </summary> /// <param name="format">Texture format.</param> /// <param name="width">Texture width (in texels).</param> /// <param name="arraySize">Number of textures in the array.</param> /// <param name="mipLevels">The maximum number of mipmap levels in the texture.</param> /// <param name="bindFlags">The <see cref="Direct3D11.BindFlags"/> for binding to pipeline stages.</param> /// <param name="usage">Value that identifies how the texture is to be read from and written to.</param> /// <param name="cpuAccessFlags">The <see cref="Direct3D11.CpuAccessFlags"/> to specify the types of CPU access allowed.</param> /// <param name="optionFlags">The <see cref="ResourceOptionFlags"/> that identify other, less common resource options. </param> public Texture1DDescription( Format format, int width, int arraySize = 1, int mipLevels = 0, BindFlags bindFlags = BindFlags.ShaderResource, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None, ResourceOptionFlags optionFlags = ResourceOptionFlags.None) { if (format == Format.Unknown) { throw new ArgumentException($"format need to be valid", nameof(format)); } if (width < 1 || width > ID3D11Resource.MaximumTexture1DSize) { throw new ArgumentException($"Width need to be in range 1-{ID3D11Resource.MaximumTexture1DSize}", nameof(width)); } if (arraySize < 1 || arraySize > ID3D11Resource.MaximumTexture1DArraySize) { throw new ArgumentException($"Array size need to be in range 1-{ID3D11Resource.MaximumTexture1DArraySize}", nameof(arraySize)); } Width = width; MipLevels = mipLevels; ArraySize = arraySize; Format = format; Usage = usage; BindFlags = bindFlags; CpuAccessFlags = cpuAccessFlags; OptionFlags = optionFlags; }
public static void CreateDDSTextureFromMemory(Device d3dDevice, byte[] ddsData, out Resource texture, out ShaderResourceView textureView, int maxsize = 0, ResourceUsage usage = ResourceUsage.Default, BindFlags bindFlags = BindFlags.ShaderResource, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None, ResourceOptionFlags miscFlags = ResourceOptionFlags.None, bool forceSRGB = false ) { GCHandle ddsDataHandle = GCHandle.Alloc(ddsData, GCHandleType.Pinned); try { CreateDDSTextureFromMemory( d3dDevice, new DataPointer(ddsDataHandle.AddrOfPinnedObject(), ddsData.Length), out texture, out textureView, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB); } finally { ddsDataHandle.Free(); } }
private void UpdateTexture(EvaluationContext context) { Size2 size = Size.GetValue(context); if (size.Height <= 0 || size.Width <= 0) { Log.Warning($"Requested invalid texture resolution: {size}"); return; } var texDesc = new Texture2DDescription { Width = size.Width, Height = size.Height, MipLevels = MipLevels.GetValue(context), ArraySize = ArraySize.GetValue(context), Format = Format.GetValue(context), //SampleDescription = SampleDescription.GetValue(context), SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.GetValue(context), BindFlags = BindFlags.GetValue(context), CpuAccessFlags = CpuAccessFlags.GetValue(context), OptionFlags = ResourceOptionFlags.GetValue(context) }; try { ResourceManager.Instance().CreateTexture2d(texDesc, "Texture2D", ref _textureResId, ref Texture.Value); } catch (Exception e) { Log.Error($"Failed to create Texture2D: {e.Message}", SymbolChildId); } //ResourceManager.Instance().id .TestId = _textureResId; }
private Texture2DDescription CreateDescription( int mipLevels, int width, int height, BindFlags bindFlags, ResourceUsage usage, CpuAccessFlags cpuAccessFlags, SharpDX.DXGI.Format format) { Texture2DDescription desc; desc.Width = width; desc.Height = height; desc.ArraySize = 1; desc.BindFlags = bindFlags; desc.Usage = usage; desc.CpuAccessFlags = cpuAccessFlags; desc.Format = format; desc.MipLevels = mipLevels; desc.OptionFlags = ResourceOptionFlags.None; desc.SampleDescription.Count = 1; desc.SampleDescription.Quality = 0; return(desc); }
public static Texture2D CreateTexture2DFromBitmap(Device device, Bitmap bitmap, ResourceUsage Usage = ResourceUsage.Immutable, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { var bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Allocate DataStream to receive the WIC image pixels var stride = bitmapData.Stride; var t = new Texture2D( device, new Texture2DDescription { Width = bitmap.Width, Height = bitmap.Height, ArraySize = 1, BindFlags = BindFlags.ShaderResource, Usage = Usage, CpuAccessFlags = cpuAccessFlags, Format = Format.B8G8R8A8_UNorm, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }, new DataRectangle(bitmapData.Scan0, stride)); bitmap.UnlockBits(bitmapData); return(t); }
public override GraphicBuffer CreateVertexBuffer(int size, int stride, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAcces = CpuAccessFlags.ReadWrite, ResBinding binding = ResBinding.VertexBuffer, IntPtr data = default(IntPtr)) { return(new ESGraphicBuffer(size, stride, All.ArrayBuffer, usage, cpuAcces, binding, data)); }
public override GraphicBuffer CreateIndexBuffer(int size, IndexFormat format = IndexFormat.Index16, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAcces = CpuAccessFlags.ReadWrite, IntPtr data = default(IntPtr)) { return(new ESGraphicBuffer(size, format == IndexFormat.Index16?2:4, All.ElementArrayBuffer, usage, cpuAcces, ResBinding.IndexBuffer, data)); }
/// <summary> /// Initializes a new instance of the <see cref="BufferDescription"/> struct. /// </summary> /// <param name="sizeInBytes">The size in bytes.</param> /// <param name="usage">The usage.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="cpuAccessFlags">The CPU access flags.</param> /// <param name="optionFlags">The option flags.</param> public BufferDescription(int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags, ResourceOptionFlags optionFlags) { SizeInBytes = sizeInBytes; Usage = usage; BindFlags = bindFlags; CpuAccessFlags = cpuAccessFlags; OptionFlags = optionFlags; }
public static Graphics.ResourceUsage ConvertToAccessFlag(CpuAccessFlags accessFlag) { if (!accessFlags.ContainsValue(accessFlag)) { throw new NotImplementedException(); } return(accessFlags.First((f) => f.Value == accessFlag).Key); }
/// <summary> /// Initializes a new instance of the <see cref="BufferDescription"/> struct. /// </summary> /// <param name="sizeInBytes">The size in bytes.</param> /// <param name="usage">The usage.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="cpuAccessFlags">The CPU access flags.</param> /// <param name="optionFlags">The option flags.</param> /// <param name="structureByteStride">The structure byte stride.</param> public BufferDescription(int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags, ResourceOptionFlags optionFlags, int structureByteStride) { SizeInBytes = sizeInBytes; Usage = usage; BindFlags = bindFlags; CpuAccessFlags = cpuAccessFlags; OptionFlags = optionFlags; StructureByteStride = structureByteStride; }
/// <summary> /// Initializes a new instance of the <see cref="BufferDescription"/> struct. /// </summary> /// <param name="sizeInBytes">The size in bytes.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="usage">The usage.</param> /// <param name="cpuAccessFlags">The CPU access flags.</param> public BufferDescription(int sizeInBytes, BindFlags bindFlags, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { SizeInBytes = sizeInBytes; BindFlags = bindFlags; Usage = usage; CpuAccessFlags = cpuAccessFlags; OptionFlags = ResourceOptionFlags.None; StructureByteStride = 0; }
protected GraphicBuffer(long size, int stride, ResourceUsage usage, CpuAccessFlags access, ResourceBinding binding) : base(ResourceType.Buffer) { _lenght = size; _stride = stride; _usage = usage; _cpuAccesType = access; _binding = binding; }
/// <summary> /// Initializes a new instance of the <see cref="BufferDescription"/> struct. /// </summary> /// <param name="sizeInBytes">The size in bytes.</param> /// <param name="usage">The usage.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="cpuAccessFlags">The cpu access flags.</param> /// <param name="optionFlags">The option flags.</param> /// <param name="structureByteStride">The structure byte stride.</param> public BufferDescription(int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags, ResourceOptionFlags optionFlags, int structureByteStride) { SizeInBytes = sizeInBytes; Usage = usage; BindFlags = bindFlags; CpuAccessFlags = cpuAccessFlags; OptionFlags = optionFlags; StructureByteStride = structureByteStride; }
public TextureDesc() { MipLevels = 1; Format = Graphics.Format.UNKNOWN; SamplerDesc = Multisampling.Disable; Usage = ResourceUsage.Default; BindFlags = Graphics.BindFlags.ShaderResource; CPUAccessFlags = CpuAccessFlags.None; Options = ResourceOptionFlags.None; }
/// <summary> /// Initializes a new instance of the <see cref="DynamicBufferProxy"/> class. /// </summary> /// <param name="structureSize">Size of the structure.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="canOverWrite">if set to <c>true</c> [can over write].</param> /// <param name="cpuAccess">The cpu access.</param> /// <param name="optionFlags">The option flags.</param> /// <param name="lazyResize">if set to <c>true</c> [lazy resize].</param> public DynamicBufferProxy(int structureSize, BindFlags bindFlags, bool canOverWrite, CpuAccessFlags cpuAccess, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, bool lazyResize = true) : base(structureSize, bindFlags) { CanOverwrite = canOverWrite; this.OptionFlags = optionFlags; LazyResize = lazyResize; CpuAccess = cpuAccess; }
public D3DBuffer(Device device, int sizeInBytes, BindFlags bindFlags, ResourceUsage resourceUsage, CpuAccessFlags cpuFlags) { _bindFlags = bindFlags; _resourceUsage = resourceUsage; _cpuFlags = cpuFlags; _bufferSizeInBytes = sizeInBytes; Device = device; InitializeDeviceBuffer(); }
/// <summary> /// Initializes a new instance of the <see cref="ImmutableBufferProxy"/> class. /// </summary> /// <param name="structureSize">Size of the structure.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="cpuAccess">The cpu access.</param> /// <param name="optionFlags">The option flags.</param> /// <param name="usage">The usage.</param> public ImmutableBufferProxy(int structureSize, BindFlags bindFlags, CpuAccessFlags cpuAccess, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, ResourceUsage usage = ResourceUsage.Immutable) : base(structureSize, bindFlags) { OptionFlags = optionFlags; Usage = usage; CpuAccess = cpuAccess; }
public void SetDefaults() { MipLevels = 1; Format = Graphics.Format.UNKNOWN; Usage = ResourceUsage.Default; BindFlags = Graphics.BindFlags.ShaderResource; CPUAccessFlags = CpuAccessFlags.None; Options = ResourceOptionFlags.None; Width = 1; ArraySize = 1; }
/// <summary>To initialize this structure with default value, use this constructor. The argument value is ignored.</summary> /// <remarks>This is only here because C# doesn’t support parameterless constructors for structures.</remarks> public BufferDesc(bool unused) { baseStruct = new DeviceObjectAttribs(true); uiSizeInBytes = 0; BindFlags = BindFlags.None; Usage = Usage.Default; CPUAccessFlags = CpuAccessFlags.None; Mode = BufferMode.Undefined; ElementByteStride = 0; CommandQueueMask = 1; }
public ISrvTexture CreateSrv(string debugName, int width, int height, Format format, int samplesCount = 1, int samplesQuality = 0, ResourceOptionFlags optionFlags = 0, ResourceUsage resourceUsage = ResourceUsage.Default, int mipmapLevels = 1, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { MySrvTexture tex; m_srvTextures.AllocateOrCreate(out tex); tex.Init(debugName, width, height, format, format, BindFlags.ShaderResource, samplesCount, samplesQuality, optionFlags, resourceUsage, mipmapLevels, cpuAccessFlags); if (m_isDeviceInit) tex.OnDeviceInit(); return tex; }
public IDepthTexture CreateDepth(string debugName, int width, int height, Format resourceFormat, Format srvFormat, Format dsvFormat, int samplesCount = 1, int samplesQuality = 0, ResourceOptionFlags roFlags = 0, int mipmapLevels = 1, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { MyDepthTexture tex; m_depthTextures.AllocateOrCreate(out tex); tex.Init(debugName, width, height, resourceFormat, srvFormat, dsvFormat, BindFlags.ShaderResource | BindFlags.DepthStencil, samplesCount, samplesQuality, roFlags, ResourceUsage.Default, mipmapLevels, cpuAccessFlags); if (m_isDeviceInit) tex.OnDeviceInit(); return tex; }
public ConstantBufferProxy(int structSize, BindFlags bindFlags = BindFlags.ConstantBuffer, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, ResourceUsage usage = ResourceUsage.Default) : base(structSize) { bufferDesc = new BufferDescription() { SizeInBytes = structSize, BindFlags = bindFlags, CpuAccessFlags = cpuAccessFlags, OptionFlags = optionFlags, Usage = usage, StructureByteStride = 0 }; }
public IUavTexture CreateUav(string debugName, int width, int height, Format format, int samplesCount = 1, int samplesQuality = 0, ResourceOptionFlags roFlags = 0, int mipmapLevels = 1, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { MyUavTexture tex; m_uavTextures.AllocateOrCreate(out tex); tex.Init(debugName, width, height, format, format, BindFlags.ShaderResource | BindFlags.RenderTarget | BindFlags.UnorderedAccess, samplesCount, samplesQuality, roFlags, ResourceUsage.Default, mipmapLevels, cpuAccessFlags); if (m_isDeviceInit) tex.OnDeviceInit(); return tex; }
/// <summary> /// Initializes a new instance of the <see cref="BufferDescription"/> struct. /// </summary> /// <param name="byteWidth">The size in bytes.</param> /// <param name="bindFlags">The bind flags.</param> /// <param name="usage">The usage.</param> /// <param name="cpuAccessFlags">The CPU access flags.</param> /// <param name="miscFlags">The option flags.</param> /// <param name="structureByteStride">The structure byte stride.</param> public BufferDescription(int byteWidth, BindFlags bindFlags, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None, ResourceOptionFlags miscFlags = ResourceOptionFlags.None, int structureByteStride = 0) { ByteWidth = byteWidth; BindFlags = bindFlags; Usage = usage; CPUAccessFlags = cpuAccessFlags; MiscFlags = miscFlags; StructureByteStride = structureByteStride; }
/// <summary> /// Creates a new <see cref="ConstantBuffer" /> with the specified size in bytes. /// </summary> /// <param name="graphicsDevice"> The graphics device. </param> /// <param name="sizeInBytes"> The size in bytes. </param> /// <param name="resourceUsage"> (Optional) The resource usage. </param> /// <param name="cpuAccessFlags"> (Optional) The CPU access flags. </param> /// <returns> /// A <see cref="ConstantBuffer" />. /// </returns> /// <remarks> /// The <paramref name="sizeInBytes" /> must be a multiple of 16, /// if not it will be calculated to the minimum multiple of 16 fitting it in. /// e.g. /// - a size in bytes of 11 will be 16. /// - a size in bytes of 23 will be 32. /// - a size in bytes of 80 will be 80. /// > see https://docs.microsoft.com/de-de/windows/win32/api/d3d11/ns-d3d11-d3d11_buffer_desc#remarks /// </remarks> public static ConstantBuffer Create(IGraphicsDevice graphicsDevice, int sizeInBytes, ResourceUsage resourceUsage = ResourceUsage.Default, CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None) { return(new ConstantBuffer( new Buffer( graphicsDevice.Device, Math2.Ceiling(sizeInBytes / 16.0f) * 16, resourceUsage, BindFlags.ConstantBuffer, cpuAccessFlags, ResourceOptionFlags.None, 0))); }
/// <summary> /// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Buffer" /> class. /// </summary> /// <param name = "device">The device with which to associate the buffer.</param> /// <param name = "sizeInBytes">The size, in bytes, of the buffer.</param> /// <param name = "usage">The usage pattern for the buffer.</param> /// <param name = "bindFlags">Flags specifying how the buffer will be bound to the pipeline.</param> /// <param name = "accessFlags">Flags specifying how the buffer will be accessible from the CPU.</param> /// <param name = "optionFlags">Miscellaneous resource options.</param> public Buffer(Device device, int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags accessFlags, ResourceOptionFlags optionFlags) : base(IntPtr.Zero) { var description = new BufferDescription() { BindFlags = bindFlags, CpuAccessFlags = accessFlags, OptionFlags = optionFlags, SizeInBytes = sizeInBytes, Usage = usage, }; device.CreateBuffer(ref description, null, this); }
/// <summary> /// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Buffer" /> class. /// </summary> /// <param name = "device">The device with which to associate the buffer.</param> /// <param name = "data">Initial data used to initialize the buffer.</param> /// <param name = "sizeInBytes">The size, in bytes, of the buffer.</param> /// <param name = "usage">The usage pattern for the buffer.</param> /// <param name = "bindFlags">Flags specifying how the buffer will be bound to the pipeline.</param> /// <param name = "accessFlags">Flags specifying how the buffer will be accessible from the CPU.</param> /// <param name = "optionFlags">Miscellaneous resource options.</param> public Buffer(Device device, DataStream data, int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags accessFlags, ResourceOptionFlags optionFlags) : base(IntPtr.Zero) { var description = new BufferDescription() { BindFlags = bindFlags, CpuAccessFlags = accessFlags, OptionFlags = optionFlags, SizeInBytes = sizeInBytes, Usage = usage, }; device.CreateBuffer(ref description, new DataBox(data.PositionPointer, 0, 0), this); }
/// <summary>Create and set fields to their defaults</summary> public TextureDesc(bool unused) { baseStruct = new DeviceObjectAttribs(true); Type = ResourceDimension.Undefined; Size = new CSize(0, 0); ArraySizeOrDepth = 1; Format = TextureFormat.Unknown; MipLevels = 1; SampleCount = 1; Usage = Usage.Default; BindFlags = BindFlags.None; CPUAccessFlags = CpuAccessFlags.None; MiscFlags = MiscTextureFlags.None; ClearValue = new OptimizedClearValue(true); CommandQueueMask = 1; }
public void Init( string name, int width, int height, Format resourceFormat, Format srvFormat, Format dsvFormat, BindFlags bindFlags, int samplesCount, int samplesQuality, ResourceOptionFlags roFlags, ResourceUsage ru, int mipmapLevels, CpuAccessFlags cpuAccessFlags) { base.Init(name, width, height, resourceFormat, srvFormat, bindFlags, samplesCount, samplesQuality, roFlags, ru, mipmapLevels, cpuAccessFlags); m_dsvFormat = dsvFormat; }
public static Texture2D CreateDepth( int width, int height, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { return CreateTexture( width, height, 1, 1, Format.D24_UNorm_S8_UInt, usage, bindFlags, cpuAccessFlags ); }
// HACK: figure out a good way...maybe the D3D way really is the right way private static Texture2D CreateTexture( int width, int height, int arraySize, int mipLevels, Format format, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { var wrapper = D3D10Wrapper.Instance; var desc = new Texture2DDescription { Width = width, Height = height, MipLevels = mipLevels, ArraySize = arraySize, Format = format, SampleDescription = new SampleDescription( 1, 0 ), Usage = usage, BindFlags = bindFlags, CpuAccessFlags = cpuAccessFlags, OptionFlags = ResourceOptionFlags.None }; if( mipLevels != 1 ) { desc.OptionFlags = ResourceOptionFlags.GenerateMipMaps; } return new Texture2D( wrapper.Device, desc ); }
public static Texture2D CreateUnsignedByte4MipMapped( int width, int height, int mipLevels, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { return CreateTexture( width, height, 1, mipLevels, Format.R8G8B8A8_UNorm, usage, bindFlags, cpuAccessFlags ); }
public static Texture2D CreateDepth( Vector2i size, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { return CreateDepth( size.x, size.y, usage, bindFlags, cpuAccessFlags ); }
public static Texture2D CreateUnsignedByte4Array( int width, int height, int arraySize, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { return CreateTexture( width, height, arraySize, 1, Format.R8G8B8A8_UNorm, usage, bindFlags, cpuAccessFlags ); }
public static Texture2D CreateFloat4( int width, int height, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags ) { return CreateTexture( width, height, 1, 1, Format.R32G32B32A32_Float, usage, bindFlags, cpuAccessFlags ); }