当前位置: 首页>>代码示例>>C#>>正文


C# DataBox类代码示例

本文整理汇总了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);
        }
开发者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


注:本文中的DataBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。