本文整理汇总了C#中DataBox类的典型用法代码示例。如果您正苦于以下问题:C# DataBox类的具体用法?C# DataBox怎么用?C# DataBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataBox类属于命名空间,在下文中一共展示了DataBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:barograf,项目名称:VoxelTerrain,代码行数:30,代码来源:NoiseCube.cs
示例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
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:8,代码来源:Texture3D.OpenGL.cs
示例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;
}
开发者ID:Powerino73,项目名称:paradox,代码行数:16,代码来源:MappedResource.cs
示例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);
}
开发者ID:JoeErickson,项目名称:SharpDX,代码行数:15,代码来源:Texture1D.cs
示例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);
}
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:17,代码来源:Texture1D.cs
示例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);
}
开发者ID:numo16,项目名称:SharpDX,代码行数:22,代码来源:Texture1D.cs
示例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);
}
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:22,代码来源:Texture2D.cs
示例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();
}
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:90,代码来源:Texture.Vulkan.cs
示例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;
}
开发者ID:releed,项目名称:paradox,代码行数:11,代码来源:Texture.Direct3D.cs
示例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);
}
开发者ID:releed,项目名称:paradox,代码行数:29,代码来源:Texture.Direct3D.cs
示例11: TextureCube
protected internal TextureCube(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null) : base(device, description2D, TextureTarget.TextureCubeMap)
{
throw new NotImplementedException();
}
开发者ID:Powerino73,项目名称:paradox,代码行数:4,代码来源:TextureCube.OpenGL.cs
示例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));
}
开发者ID:cg123,项目名称:xenko,代码行数:5,代码来源:CommandList.Direct3D.cs
示例13: Texture1D
protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
: base(device, description1D)
{
}
开发者ID:cg123,项目名称:xenko,代码行数:4,代码来源:Texture1D.Null.cs
示例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);
}
开发者ID:pH200,项目名称:SharpDX,代码行数:15,代码来源:Texture1DBase.cs
示例15: Recreate
public void Recreate(DataBox[] dataBoxes = null)
{
InitializeFromImpl(dataBoxes);
}
开发者ID:psowinski,项目名称:xenko,代码行数:4,代码来源:Texture.OpenGL.cs
示例16: InitializeImage
private unsafe void InitializeImage(DataBox[] dataBoxes)
{
var commandBuffer = GraphicsDevice.NativeCopyCommandBuffer;
var beginInfo = new CommandBufferBeginInfo { StructureType = StructureType.CommandBufferBeginInfo };
commandBuffer.Begin(ref beginInfo);
if (dataBoxes != null && dataBoxes.Length > 0)
{
// Buffer-to-image copies need to be aligned to the pixel size and 4 (always a power of 2)
var blockSize = Format.IsCompressed() ? NativeFormat.BlockSizeInBytes() : TexturePixelSize;
var alignmentMask = (blockSize < 4 ? 4 : blockSize) - 1;
int totalSize = dataBoxes.Length * alignmentMask;
for (int i = 0; i < dataBoxes.Length; i++)
{
totalSize += dataBoxes[i].SlicePitch;
}
SharpVulkan.Buffer uploadResource;
int uploadOffset;
var uploadMemory = GraphicsDevice.AllocateUploadBuffer(totalSize, out uploadResource, out uploadOffset);
// Upload buffer barrier
var bufferMemoryBarrier = new BufferMemoryBarrier(uploadResource, AccessFlags.HostWrite, AccessFlags.TransferRead, (ulong)uploadOffset, (ulong)totalSize);
// Image barrier
var initialBarrier = new ImageMemoryBarrier(NativeImage, ImageLayout.Undefined, ImageLayout.TransferDestinationOptimal, AccessFlags.None, AccessFlags.TransferWrite, new ImageSubresourceRange(NativeImageAspect));
commandBuffer.PipelineBarrier(PipelineStageFlags.TopOfPipe, PipelineStageFlags.Transfer, DependencyFlags.None, 0, null, 1, &bufferMemoryBarrier, 1, &initialBarrier);
// Copy data boxes to upload buffer
var copies = new BufferImageCopy[dataBoxes.Length];
for (int i = 0; i < copies.Length; i++)
{
var slicePitch = dataBoxes[i].SlicePitch;
int arraySlice = i / MipLevels;
int mipSlice = i % MipLevels;
var mipMapDescription = GetMipMapDescription(mipSlice);
SubresourceLayout layout;
GraphicsDevice.NativeDevice.GetImageSubresourceLayout(NativeImage, new ImageSubresource(NativeImageAspect, (uint)arraySlice, (uint)mipSlice), out layout);
var alignment = ((uploadOffset + alignmentMask) & ~alignmentMask) - uploadOffset;
uploadMemory += alignment;
uploadOffset += alignment;
Utilities.CopyMemory(uploadMemory, dataBoxes[i].DataPointer, slicePitch);
// TODO VULKAN: Check if pitches are valid
copies[i] = new BufferImageCopy
{
BufferOffset = (ulong)uploadOffset,
ImageSubresource = new ImageSubresourceLayers(ImageAspectFlags.Color, (uint)arraySlice, 1, (uint)mipSlice),
BufferRowLength = 0, //(uint)(dataBoxes[i].RowPitch / pixelSize),
BufferImageHeight = 0, //(uint)(dataBoxes[i].SlicePitch / dataBoxes[i].RowPitch),
ImageOffset = new Offset3D(0, 0, arraySlice),
ImageExtent = new Extent3D((uint)mipMapDescription.Width, (uint)mipMapDescription.Height, 1)
};
uploadMemory += slicePitch;
uploadOffset += slicePitch;
}
// Copy from upload buffer to image
fixed (BufferImageCopy* copiesPointer = &copies[0])
{
commandBuffer.CopyBufferToImage(uploadResource, NativeImage, ImageLayout.TransferDestinationOptimal, (uint)copies.Length, copiesPointer);
}
IsInitialized = true;
}
// Transition to default layout
var imageMemoryBarrier = new ImageMemoryBarrier(NativeImage,
dataBoxes == null || dataBoxes.Length == 0 ? ImageLayout.Undefined : ImageLayout.TransferDestinationOptimal, NativeLayout,
dataBoxes == null || dataBoxes.Length == 0 ? AccessFlags.None : AccessFlags.TransferWrite, NativeAccessMask, new ImageSubresourceRange(NativeImageAspect));
commandBuffer.PipelineBarrier(PipelineStageFlags.Transfer, PipelineStageFlags.AllCommands, DependencyFlags.None, 0, null, 0, null, 1, &imageMemoryBarrier);
// Close and submit
commandBuffer.End();
var submitInfo = new SubmitInfo
{
StructureType = StructureType.SubmitInfo,
CommandBufferCount = 1,
CommandBuffers = new IntPtr(&commandBuffer),
};
lock (GraphicsDevice.QueueLock)
{
GraphicsDevice.NativeCommandQueue.Submit(1, &submitInfo, Fence.Null);
GraphicsDevice.NativeCommandQueue.WaitIdle();
commandBuffer.Reset(CommandBufferResetFlags.None);
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:95,代码来源:Texture.Vulkan.cs
示例17: Texture3D
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D10.Texture3D" /> 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">The initial texture data.</param>
public Texture3D(Device device, Texture3DDescription description, DataBox data)
: this(device, description, new[] {data})
{
}
开发者ID:Nezz,项目名称:SharpDX,代码行数:10,代码来源:Texture3D.cs
示例18: UploadCharacterBitmap
/// <summary>
/// Upload a character's bitmap into the current cache.
/// </summary>
/// <param name="character">The character specifications corresponding to the bitmap</param>
public void UploadCharacterBitmap(CharacterSpecification character)
{
if(character.Bitmap == null)
throw new ArgumentNullException("character");
if(character.IsBitmapUploaded)
throw new InvalidOperationException("The character '"+character.Character+"' upload has been requested while its current glyph is valid.");
var targetSize = new Int2(character.Bitmap.Width, character.Bitmap.Rows);
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
{
// not enough space to place the new character -> remove less used characters and try again
RemoveLessUsedCharacters();
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
{
// memory is too fragmented in order to place the new character -> clear all the characters and restart.
ClearCache();
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
throw new InvalidOperationException("The rendered character is too big for the cache texture");
}
}
// updload the bitmap on the texture (if the size in the bitmap is not null)
if (character.Bitmap.Rows != 0 && character.Bitmap.Width != 0)
{
var dataBox = new DataBox(character.Bitmap.Buffer, character.Bitmap.Pitch, character.Bitmap.Pitch * character.Bitmap.Rows);
var region = new ResourceRegion(character.Glyph.Subrect.Left, character.Glyph.Subrect.Top, 0, character.Glyph.Subrect.Right, character.Glyph.Subrect.Bottom, 1);
system.GraphicsDevice.UpdateSubresource(cacheTextures[0], 0, dataBox, region);
}
// update the glyph data
character.IsBitmapUploaded = true;
character.Glyph.BitmapIndex = 0;
}
开发者ID:Powerino73,项目名称:paradox,代码行数:37,代码来源:FontCacheManager.cs
示例19: UpdateBufferData
public void UpdateBufferData(string bufferName, DataStream data)
{
var buffer = GetBuffer(bufferName);
DataBox src = new DataBox((int)data.Length, 0, data);
Engine.Global.Device3d.GetImmediateContext().UpdateSubresource(src, buffer, 0);
}
开发者ID:aik6980,项目名称:GameFramework,代码行数:7,代码来源:Device3dD3d11.cs
示例20: Texture1D
protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
: base(device, description1D, ViewType.Full, 0, 0)
{
Target = TextureTarget1D;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:5,代码来源:Texture1D.OpenGL.cs
注:本文中的DataBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论