本文整理汇总了C#中DataBox类的典型用法代码示例。如果您正苦于以下问题:C# DataBox类的具体用法?C# DataBox怎么用?C# DataBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataBox类属于命名空间,在下文中一共展示了DataBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToTexture3D
public ShaderResourceView ToTexture3D(Device graphicsDevice, Format format)
{
int sizeInBytes = sizeof(float) * width * height * depth;
DataStream stream = new DataStream(sizeInBytes, true, true);
for (int x = 0; x < width; x++)
for (int y = 0; y < height; y++)
for (int z = 0; z < depth; z++)
stream.Write(values[x, y, z]);
stream.Position = 0;
DataBox dataBox = new DataBox(sizeof(float) * width, sizeof(float) * width * height, stream);
Texture3DDescription description = new Texture3DDescription()
{
BindFlags = BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Depth = depth,
Format = format,
Height = height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
Usage = ResourceUsage.Default,
Width = width
};
Texture3D texture = new Texture3D(graphicsDevice, description, dataBox);
stream.Dispose();
return new ShaderResourceView(graphicsDevice, texture);
}
示例2: Texture3D
protected internal Texture3D(GraphicsDevice device, TextureDescription description3D, DataBox[] dataBoxes = null) : base(device, description3D, ViewType.Full, 0, 0)
{
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
throw new NotImplementedException();
#else
Target = TextureTarget.Texture3D;
#endif
}
示例3: MappedResource
/// <summary>
/// Initializes a new instance of the <see cref="MappedResource"/> struct.
/// </summary>
/// <param name="resource">The resource.</param>
/// <param name="subResourceIndex">Index of the sub resource.</param>
/// <param name="dataBox">The data box.</param>
/// <param name="offsetInBytes">Offset since the beginning of the buffer.</param>
/// <param name="sizeInBytes">Size of the mapped resource.</param>
internal MappedResource(GraphicsResource resource, int subResourceIndex, DataBox dataBox, int offsetInBytes, int sizeInBytes)
{
Resource = resource;
SubResourceIndex = subResourceIndex;
DataBox = dataBox;
OffsetInBytes = offsetInBytes;
SizeInBytes = sizeInBytes;
}
示例4: Texture1D
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Texture1D" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
public Texture1D(Device device, Texture1DDescription description, DataStream[] data)
: base(IntPtr.Zero)
{
var subResourceDatas = new DataBox[data.Length];
for (int i = 0; i < subResourceDatas.Length; i++)
subResourceDatas[i].DataPointer = data[i].DataPointer;
device.CreateTexture1D(ref description, subResourceDatas, this);
}
示例5: Texture1D
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Texture1D" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
public Texture1D(Device device, Texture1DDescription description, DataStream[] data)
: base(IntPtr.Zero)
{
System.Diagnostics.Debug.Assert(data != null);
var subResourceDatas = new DataBox[data.Length];
for (int i = 0; i < subResourceDatas.Length; i++)
subResourceDatas[i].DataPointer = data[i].DataPointer;
device.CreateTexture1D(ref description, subResourceDatas, this);
}
示例6: Texture1D
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture1D" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
/// <msdn-id>ff476520</msdn-id>
/// <unmanaged>HRESULT ID3D11Device::CreateTexture1D([In] const D3D11_TEXTURE1D_DESC* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture1D** ppTexture1D)</unmanaged>
/// <unmanaged-short>ID3D11Device::CreateTexture1D</unmanaged-short>
public Texture1D(Device device, Texture1DDescription description, params IntPtr[] data)
: base(IntPtr.Zero)
{
DataBox[] subResourceDatas = null;
if (data != null && data.Length > 0)
{
subResourceDatas = new DataBox[data.Length];
for (int i = 0; i < subResourceDatas.Length; i++)
subResourceDatas[i].DataPointer = data[i];
}
device.CreateTexture1D(ref description, subResourceDatas, this);
}
示例7: Texture2D
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Texture2D" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
public Texture2D(Device device, Texture2DDescription description, DataRectangle[] data)
: base(IntPtr.Zero)
{
DataBox[] subResourceDatas = null;
if (data != null)
{
subResourceDatas = new DataBox[data.Length];
for (int i = 0; i < subResourceDatas.Length; i++)
{
subResourceDatas[i].DataPointer = data[i].DataPointer;
subResourceDatas[i].RowPitch = data[i].Pitch;
}
}
device.CreateTexture2D(ref description, subResourceDatas, this);
}
示例8: InitializeFromImpl
private void InitializeFromImpl(DataBox[] dataBoxes = null)
{
NativeFormat = VulkanConvertExtensions.ConvertPixelFormat(ViewFormat);
HasStencil = IsStencilFormat(ViewFormat);
NativeImageAspect = IsDepthStencil ? ImageAspectFlags.Depth : ImageAspectFlags.Color;
if (HasStencil)
NativeImageAspect |= ImageAspectFlags.Stencil;
// For depth-stencil formats, automatically fall back to a supported one
if (IsDepthStencil && HasStencil)
{
NativeFormat = GetFallbackDepthStencilFormat(GraphicsDevice, NativeFormat);
}
if (Usage == GraphicsResourceUsage.Staging)
{
if (NativeImage != SharpVulkan.Image.Null)
throw new InvalidOperationException();
if (isNotOwningResources)
throw new InvalidOperationException();
if (ParentTexture != null)
{
// Create only a view
NativeBuffer = ParentTexture.NativeBuffer;
NativeMemory = ParentTexture.NativeMemory;
}
else
{
CreateBuffer();
if (dataBoxes != null)
throw new InvalidOperationException();
}
}
else
{
if (NativeImage != SharpVulkan.Image.Null)
throw new InvalidOperationException();
NativeLayout =
IsRenderTarget ? ImageLayout.ColorAttachmentOptimal :
IsDepthStencil ? ImageLayout.DepthStencilAttachmentOptimal :
IsShaderResource ? ImageLayout.ShaderReadOnlyOptimal :
ImageLayout.General;
if (NativeLayout == ImageLayout.TransferDestinationOptimal)
NativeAccessMask = AccessFlags.TransferRead;
if (NativeLayout == ImageLayout.ColorAttachmentOptimal)
NativeAccessMask = AccessFlags.ColorAttachmentWrite;
if (NativeLayout == ImageLayout.DepthStencilAttachmentOptimal)
NativeAccessMask = AccessFlags.DepthStencilAttachmentWrite;
if (NativeLayout == ImageLayout.ShaderReadOnlyOptimal)
NativeAccessMask = AccessFlags.ShaderRead | AccessFlags.InputAttachmentRead;
NativePipelineStageMask =
IsRenderTarget ? PipelineStageFlags.ColorAttachmentOutput :
IsDepthStencil ? PipelineStageFlags.ColorAttachmentOutput | PipelineStageFlags.EarlyFragmentTests | PipelineStageFlags.LateFragmentTests :
IsShaderResource ? PipelineStageFlags.VertexInput | PipelineStageFlags.FragmentShader :
PipelineStageFlags.None;
if (ParentTexture != null)
{
// Create only a view
NativeImage = ParentTexture.NativeImage;
NativeMemory = ParentTexture.NativeMemory;
}
else
{
if (!isNotOwningResources)
{
CreateImage();
InitializeImage(dataBoxes);
}
}
if (!isNotOwningResources)
{
NativeImageView = GetImageView(ViewType, ArraySlice, MipLevel);
NativeColorAttachmentView = GetColorAttachmentView(ViewType, ArraySlice, MipLevel);
NativeDepthStencilView = GetDepthStencilView();
}
}
}
示例9: ConvertDataBoxes
internal unsafe static SharpDX.DataBox[] ConvertDataBoxes(DataBox[] dataBoxes)
{
if (dataBoxes == null || dataBoxes.Length == 0)
return null;
var sharpDXDataBoxes = new SharpDX.DataBox[dataBoxes.Length];
fixed (void* pDataBoxes = sharpDXDataBoxes)
Utilities.Write((IntPtr)pDataBoxes, dataBoxes, 0, dataBoxes.Length);
return sharpDXDataBoxes;
}
示例10: InitializeFromImpl
private void InitializeFromImpl(DataBox[] dataBoxes = null)
{
if (ParentTexture != null)
{
NativeDeviceChild = ParentTexture.NativeDeviceChild;
}
if (NativeDeviceChild == null)
{
switch (Dimension)
{
case TextureDimension.Texture1D:
NativeDeviceChild = new Texture1D(GraphicsDevice.NativeDevice, ConvertToNativeDescription1D(), ConvertDataBoxes(dataBoxes));
break;
case TextureDimension.Texture2D:
case TextureDimension.TextureCube:
NativeDeviceChild = new Texture2D(GraphicsDevice.NativeDevice, ConvertToNativeDescription2D(), ConvertDataBoxes(dataBoxes));
break;
case TextureDimension.Texture3D:
NativeDeviceChild = new Texture3D(GraphicsDevice.NativeDevice, ConvertToNativeDescription3D(), ConvertDataBoxes(dataBoxes));
break;
}
}
NativeShaderResourceView = GetShaderResourceView(ViewType, ArraySlice, MipLevel);
NativeUnorderedAccessView = GetUnorderedAccessView(ViewType, ArraySlice, MipLevel);
NativeRenderTargetView = GetRenderTargetView(ViewType, ArraySlice, MipLevel);
NativeDepthStencilView = GetDepthStencilView(out HasStencil);
}
示例11: TextureCube
protected internal TextureCube(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null) : base(device, description2D, TextureTarget.TextureCubeMap)
{
throw new NotImplementedException();
}
示例12: UpdateSubresource
internal unsafe void UpdateSubresource(GraphicsResource resource, int subResourceIndex, DataBox databox, ResourceRegion region)
{
if (resource == null) throw new ArgumentNullException("resource");
NativeDeviceContext.UpdateSubresource(*(SharpDX.DataBox*)Interop.Cast(ref databox), resource.NativeResource, subResourceIndex, *(SharpDX.Direct3D11.ResourceRegion*)Interop.Cast(ref region));
}
示例13: Texture1D
protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
: base(device, description1D)
{
}
示例14: Texture1DBase
/// <summary>
/// Initializes a new instance of the <see cref="Texture1DBase" /> class.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/>.</param>
/// <param name="description1D">The description.</param>
/// <param name="dataBox">A variable-length parameters list containing data rectangles.</param>
/// <msdn-id>ff476520</msdn-id>
/// <unmanaged>HRESULT ID3D11Device::CreateTexture1D([In] const D3D11_TEXTURE1D_DESC* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture1D** ppTexture1D)</unmanaged>
/// <unmanaged-short>ID3D11Device::CreateTexture1D</unmanaged-short>
protected internal Texture1DBase(GraphicsDevice device, Texture1DDescription description1D, DataBox[] dataBox)
: base(device, description1D)
{
Resource = new Direct3D11.Texture1D(device, description1D, dataBox);
Initialize(Resource);
}
示例15: Recreate
public void Recreate(DataBox[] dataBoxes = null)
{
InitializeFromImpl(dataBoxes);
}