Exemplo n.º 1
0
            /// <summary>
            /// Creates the view from 3D texture byte array.
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="pixels">The pixels.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="depth">The depth.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            /// <exception cref="ArgumentOutOfRangeException"/>
            public void CreateView <T>(T[] pixels, int width, int height, int depth,
                                       global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true) where T : struct
            {
                this.DisposeAndClear();
                if (width * height * depth > pixels.Length)
                {
                    throw new ArgumentOutOfRangeException($"Width*Height*Depth = {width * height * depth} is larger than array size {pixels.Length}.");
                }
                var texture = Collect(global::SharpDX.Toolkit.Graphics.Texture3D.New(device, width, height, depth,
                                                                                     format, pixels));

                TextureFormat = format;
                if (texture.Description.MipLevels == 1 && generateMipMaps)
                {
                    if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                    {
                        resource = Collect(mipmapTexture);
                        RemoveAndDispose(ref texture);
                    }
                    else
                    {
                        resource = texture;
                    }
                }
                else
                {
                    resource = texture;
                }
                if (createSRV)
                {
                    textureView = Collect(new ShaderResourceView(device, resource));
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the view from 3D texture byte array.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pixels">The pixels.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="format">The format.</param>
        /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
        /// <param name="generateMipMaps"></param>
        public void CreateView <T>(T[] pixels, int width, int height, int depth,
                                   global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true) where T : struct
        {
            this.DisposeAndClear();
            var texture = Collect(global::SharpDX.Toolkit.Graphics.Texture3D.New(device, width, height, depth,
                                                                                 format, pixels));

            if (texture.Description.MipLevels == 1 && generateMipMaps)
            {
                if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                {
                    resource = Collect(mipmapTexture);
                    RemoveAndDispose(ref texture);
                }
                else
                {
                    resource = texture;
                }
            }
            else
            {
                resource = texture;
            }
            if (createSRV)
            {
                textureView = Collect(new ShaderResourceView(device, resource));
            }
        }
Exemplo n.º 3
0
            /// <summary>
            /// Creates the 1D texture view from data array.
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="array">The array.</param>
            /// <param name="length">data length</param>
            /// <param name="format">The pixel format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            public void CreateView <T>(T[] array, int length, global::SharpDX.DXGI.Format format,
                                       bool createSRV = true, bool generateMipMaps = true) where T : struct
            {
                this.DisposeAndClear();
                var texture = Collect(global::SharpDX.Toolkit.Graphics.Texture1D.New(device, Math.Min(array.Length, length), format, array));

                TextureFormat = format;
                if (texture.Description.MipLevels == 1 && generateMipMaps)
                {
                    if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                    {
                        resource = Collect(mipmapTexture);
                        RemoveAndDispose(ref texture);
                    }
                    else
                    {
                        resource = texture;
                    }
                }
                else
                {
                    resource = texture;
                }
                if (createSRV)
                {
                    textureView = Collect(new ShaderResourceView(device, resource));
                }
            }
 /// <summary>
 /// Creates the view from texture model.
 /// </summary>
 /// <param name="texture">The stream.</param>
 /// <param name="disableAutoGenMipMap">Disable auto mipmaps generation</param>
 /// <exception cref="ArgumentOutOfRangeException"/>
 public void CreateView(TextureModel texture, bool disableAutoGenMipMap = false)
 {
     this.DisposeAndClear();
     if (texture != null && device != null)
     {
         if (texture.IsCompressed && texture.CompressedStream != null)
         {
             resource      = Collect(TextureLoader.FromMemoryAsShaderResource(device, texture.CompressedStream, disableAutoGenMipMap));
             textureView   = Collect(new ShaderResourceView(device, resource));
             TextureFormat = textureView.Description.Format;
         }
         else if (texture.NonCompressedData != null && texture.NonCompressedData.Length > 0)
         {
             if (texture.Width * texture.Height > texture.NonCompressedData.Length)
             {
                 throw new ArgumentOutOfRangeException($"Texture width * height = {texture.Width * texture.Height} is larger than texture data length {texture.NonCompressedData.Length}.");
             }
             else if (texture.Height <= 1)
             {
                 if (texture.Width == 0)
                 {
                     CreateView(texture.NonCompressedData, texture.UncompressedFormat, true, disableAutoGenMipMap);
                 }
                 else
                 {
                     CreateView(texture.NonCompressedData, texture.Width, texture.UncompressedFormat, true, disableAutoGenMipMap);
                 }
             }
             else
             {
                 CreateView(texture.NonCompressedData, texture.Width, texture.Height, texture.UncompressedFormat, true, disableAutoGenMipMap);
             }
         }
     }
 }
Exemplo n.º 5
0
            /// <summary>
            /// Creates the view.
            /// </summary>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="depth">The depth.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="dataPtr"></param>
            /// <param name="generateMipMaps"></param>
            public unsafe void CreateView(IntPtr dataPtr, int width, int height, int depth,
                                          global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true)
            {
                this.DisposeAndClear();
                var ptr     = (IntPtr)dataPtr;
                var img     = global::SharpDX.Toolkit.Graphics.Image.New3D(width, height, depth, global::SharpDX.Toolkit.Graphics.MipMapCount.Auto, format, dataPtr);
                var databox = img.ToDataBox();
                var texture = Collect(global::SharpDX.Toolkit.Graphics.Texture3D.New(device, width, height, depth, format,
                                                                                     databox));

                TextureFormat = format;
                if (texture.Description.MipLevels == 1 && generateMipMaps)
                {
                    if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                    {
                        resource = Collect(mipmapTexture);
                        RemoveAndDispose(ref texture);
                    }
                    else
                    {
                        resource = texture;
                    }
                }
                else
                {
                    resource = texture;
                }
                if (createSRV)
                {
                    textureView = Collect(new ShaderResourceView(device, resource));
                }
            }
Exemplo n.º 6
0
            /// <summary>
            /// Creates the 2D texture view from data array.
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="array">The array.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            /// <exception cref="ArgumentOutOfRangeException"/>
            public void CreateView <T>(T[] array, int width, int height, global::SharpDX.DXGI.Format format,
                                       bool createSRV = true, bool generateMipMaps = true) where T : unmanaged
            {
                DisposeAll();
                if (width * height > array.Length)
                {
                    throw new ArgumentOutOfRangeException($"Width*Height = {width * height} is larger than array size {array.Length}.");
                }
                var texture = global::SharpDX.Toolkit.Graphics.Texture2D.New(device, width, height,
                                                                             format, array);

                TextureFormat = format;
                if (texture.Description.MipLevels == 1 && generateMipMaps)
                {
                    if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                    {
                        resource = mipmapTexture;
                        RemoveAndDispose(ref texture);
                    }
                    else
                    {
                        resource = texture;
                    }
                }
                else
                {
                    resource = texture;
                }
                if (createSRV)
                {
                    textureView = new ShaderResourceView(device, resource);
                }
            }
Exemplo n.º 7
0
 public VolumeTextureGradientParams(Half4[] data, int width, int height, int depth)
 {
     VolumeTextures = data;
     Width          = width;
     Height         = height;
     Depth          = depth;
     Format         = global::SharpDX.DXGI.Format.R16G16B16A16_Float;
 }
Exemplo n.º 8
0
            /// <summary>
            /// Creates the 2D texture view from data array
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="device">The device.</param>
            /// <param name="array">The array.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            /// <returns></returns>
            public static ShaderResourceViewProxy CreateView <T>(Device device, T[] array, int width, int height,
                                                                 global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true) where T : struct
            {
                var proxy = new ShaderResourceViewProxy(device);

                proxy.CreateView(array, width, height, format, createSRV, generateMipMaps);
                return(proxy);
            }
Exemplo n.º 9
0
            /// <summary>
            /// Creates the 2D texture view from raw pixel byte array
            /// </summary>
            /// <param name="device">The device.</param>
            /// <param name="dataPtr">The data PTR.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            /// <returns></returns>
            public unsafe static ShaderResourceViewProxy CreateView(Device device, IntPtr dataPtr, int width, int height,
                                                                    global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true)
            {
                var proxy = new ShaderResourceViewProxy(device);

                proxy.CreateView(dataPtr, width, height, format, createSRV, generateMipMaps);
                return(proxy);
            }
Exemplo n.º 10
0
 public VolumeTextureParams(byte[] data, int width, int height, int depth, global::SharpDX.DXGI.Format format)
 {
     VolumeTextures = data;
     Width          = width;
     Height         = height;
     Depth          = depth;
     Format         = format;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates the 1D texture view from data array.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="array">The array.</param>
 /// <param name="format">The pixel format.</param>
 /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
 public void CreateView <T>(T[] array, global::SharpDX.DXGI.Format format, bool createSRV = true) where T : struct
 {
     this.DisposeAndClear();
     resource = Collect(global::SharpDX.Toolkit.Graphics.Texture1D.New(device, array.Length, format, array));
     if (createSRV)
     {
         textureView = Collect(new ShaderResourceView(device, resource));
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates the 2D texture view from data array.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="array">The array.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="format">The format.</param>
 /// <param name="mipCount">The mipCount. Default = 0 Auto</param>
 /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
 public void CreateView <T>(T[] array, int width, int height, global::SharpDX.DXGI.Format format, int mipCount = 0, bool createSRV = true) where T : struct
 {
     this.DisposeAndClear();
     resource = Collect(global::SharpDX.Toolkit.Graphics.Texture2D.New(device, width, height, mipCount, format));
     if (createSRV)
     {
         textureView = Collect(new ShaderResourceView(device, resource));
     }
 }
Exemplo n.º 13
0
            /// <summary>
            /// Creates the view from pixel data.
            /// </summary>
            /// <param name="device">The device.</param>
            /// <param name="pixels">The pixels.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="depth">The depth.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps">if set to <c>true</c> [generate mip maps].</param>
            /// <returns></returns>
            public static ShaderResourceViewProxy CreateViewFromPixelData(Device device, Half4[] pixels,
                                                                          int width, int height, int depth,
                                                                          global::SharpDX.DXGI.Format format, bool createSRV = true, bool generateMipMaps = true)
            {
                var proxy = new ShaderResourceViewProxy(device);

                proxy.CreateView(pixels, width, height, depth, format, createSRV, generateMipMaps);
                return(proxy);
            }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostEffectMeshOutlineBlurCore"/> class.
 /// </summary>
 public PostEffectBlurCore(global::SharpDX.DXGI.Format textureFormat,
                           ShaderPass blurVerticalPass, ShaderPass blurHorizontalPass, int textureSlot, int samplerSlot,
                           SamplerStateDescription sampler, IEffectsManager manager)
 {
     screenBlurPassVertical   = blurVerticalPass;
     screenBlurPassHorizontal = blurHorizontalPass;
     this.textureSlot         = textureSlot;
     this.samplerSlot         = samplerSlot;
     this.sampler             = Collect(manager.StateManager.Register(sampler));
     texture2DDesc.Format     = targetResourceViewDesc.Format = renderTargetViewDesc.Format = textureFormat;
 }
Exemplo n.º 15
0
            private static Guid GetPfGuid(global::SharpDX.DXGI.Format format, ref bool sRGB)
            {
                var pfGuid = Guid.Empty;

                sRGB = false;
                switch (format)
                {
                case global::SharpDX.DXGI.Format.R32G32B32A32_Float:
                    pfGuid = PixelFormat.Format128bppRGBAFloat;
                    break;

                case global::SharpDX.DXGI.Format.R16G16B16A16_Float:
                    pfGuid = PixelFormat.Format64bppRGBAHalf;
                    break;

                case global::SharpDX.DXGI.Format.R16G16B16A16_UNorm:
                    pfGuid = PixelFormat.Format64bppRGBA;
                    break;

                case global::SharpDX.DXGI.Format.R32_Float:
                    pfGuid = PixelFormat.Format32bppGrayFloat;
                    break;

                case global::SharpDX.DXGI.Format.R16_Float:
                    pfGuid = PixelFormat.Format16bppGrayHalf;
                    break;

                case global::SharpDX.DXGI.Format.R16_UNorm:
                    pfGuid = PixelFormat.Format16bppGray;
                    break;

                case global::SharpDX.DXGI.Format.R8G8B8A8_UNorm:
                    pfGuid = PixelFormat.Format32bppRGBA;
                    break;

                case global::SharpDX.DXGI.Format.R8G8B8A8_UNorm_SRgb:
                    pfGuid = PixelFormat.Format32bppRGBA;
                    sRGB   = true;
                    break;

                case global::SharpDX.DXGI.Format.B8G8R8A8_UNorm:
                    pfGuid = PixelFormat.Format32bppBGR;
                    break;

                case global::SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb:
                    pfGuid = PixelFormat.Format32bppBGR;
                    sRGB   = true;
                    break;

                default:
                    break;
                }
                return(pfGuid);
            }
Exemplo n.º 16
0
 /// <summary>
 /// Creates the view from texture model.
 /// </summary>
 /// <param name="texture">The stream.</param>
 /// <param name="disableAutoGenMipMap">Disable auto mipmaps generation</param>
 public void CreateView(TextureModel texture, bool disableAutoGenMipMap = false)
 {
     this.DisposeAndClear();
     if (texture != null && device != null)
     {
         if (texture.IsCompressed)
         {
             resource      = Collect(TextureLoader.FromMemoryAsShaderResource(device, texture.CompressedStream, disableAutoGenMipMap));
             textureView   = Collect(new ShaderResourceView(device, resource));
             TextureFormat = textureView.Description.Format;
         }
         else
         {
             CreateView(texture.NonCompressedData, texture.UncompressedFormat, true, disableAutoGenMipMap);
         }
     }
 }
Exemplo n.º 17
0
        public ShaderResourceViewProxy GetOffScreenDS(OffScreenTextureSize size, global::SharpDX.DXGI.Format format)
        {
            switch (size)
            {
            case OffScreenTextureSize.Full:
                return(RenderHost.RenderBuffer.FullResDepthStencilPool.Get(format));

            case OffScreenTextureSize.Half:
                return(RenderHost.RenderBuffer.HalfResDepthStencilPool.Get(format));

            case OffScreenTextureSize.Quarter:
                return(RenderHost.RenderBuffer.QuarterResDepthStencilPool.Get(format));

            default:
                return(ShaderResourceViewProxy.Empty);
            }
        }
Exemplo n.º 18
0
            /// <summary>
            /// Creates the shader resource view from data ptr.
            /// </summary>
            /// <param name="dataPtr">The data PTR.</param>
            /// <param name="width">The width.</param>
            /// <param name="height">The height.</param>
            /// <param name="format">The format.</param>
            /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
            /// <param name="generateMipMaps"></param>
            public unsafe void CreateView(IntPtr dataPtr, int width, int height,
                                          global::SharpDX.DXGI.Format format,
                                          bool createSRV = true, bool generateMipMaps = true)
            {
                this.DisposeAndClear();
                var ptr = (IntPtr)dataPtr;

                global::SharpDX.Toolkit.Graphics.Image
                .ComputePitch(format, width, height,
                              out var rowPitch, out var slicePitch, out var widthCount, out var heightCount);

                var databox = new DataBox(ptr, rowPitch, slicePitch);

                var texture = Collect(global::SharpDX.Toolkit.Graphics.Texture2D.New(device, width, height, 1, format,
                                                                                     new[] { databox }));

                TextureFormat = format;
                if (texture.Description.MipLevels == 1 && generateMipMaps)
                {
                    if (TextureLoader.GenerateMipMaps(device, texture, out var mipmapTexture))
                    {
                        resource = Collect(mipmapTexture);
                        RemoveAndDispose(ref texture);
                    }
                    else
                    {
                        resource = texture;
                    }
                }
                else
                {
                    resource = texture;
                }
                if (createSRV)
                {
                    textureView = Collect(new ShaderResourceView(device, resource));
                }
            }
Exemplo n.º 19
0
        public ShaderResourceViewProxy GetOffScreenDS(OffScreenTextureSize size, global::SharpDX.DXGI.Format format, out int width, out int height)
        {
            switch (size)
            {
            case OffScreenTextureSize.Full:
                width  = RenderHost.RenderBuffer.FullResDepthStencilPool.Width;
                height = RenderHost.RenderBuffer.FullResDepthStencilPool.Height;
                return(RenderHost.RenderBuffer.FullResDepthStencilPool.Get(format));

            case OffScreenTextureSize.Half:
                width  = RenderHost.RenderBuffer.HalfResDepthStencilPool.Width;
                height = RenderHost.RenderBuffer.HalfResDepthStencilPool.Height;
                return(RenderHost.RenderBuffer.HalfResDepthStencilPool.Get(format));

            case OffScreenTextureSize.Quarter:
                width  = RenderHost.RenderBuffer.QuarterResDepthStencilPool.Width;
                height = RenderHost.RenderBuffer.QuarterResDepthStencilPool.Height;
                return(RenderHost.RenderBuffer.QuarterResDepthStencilPool.Get(format));

            default:
                width = height = 0;
                return(ShaderResourceViewProxy.Empty);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShaderResourceViewProxy"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="textureDesc">The texture desc.</param>
 public ShaderResourceViewProxy(Device device, Texture1DDescription textureDesc) : this(device)
 {
     resource      = Collect(new Texture1D(device, textureDesc));
     TextureFormat = textureDesc.Format;
 }
Exemplo n.º 21
0
        public ShaderResourceViewProxy GetOffScreenTexture(OffScreenTextureType type, OffScreenTextureSize size, global::SharpDX.DXGI.Format format)
        {
            switch (type)
            {
            case OffScreenTextureType.RenderTarget:
                return(GetOffScreenRT(size, format));

            case OffScreenTextureType.DepthStencil:
                return(GetOffScreenDS(size, format));

            default:
                return(ShaderResourceViewProxy.Empty);
            }
        }
            private bool HandleTextureContent(TextureInfo content, bool createSRV, bool enableAutoGenMipMap)
            {
                if (content == TextureInfo.Null)
                {
                    return(false);
                }
                if (content.IsCompressed)
                {
                    var stream = content.Texture;
                    if (stream == null || !stream.CanRead)
                    {
                        Debug.WriteLine("Stream is null or unreadable.");
                        return(false);
                    }
                    resource = Collect(TextureLoader.FromMemoryAsShaderResource(device, stream, !enableAutoGenMipMap));
                    if (createSRV)
                    {
                        textureView = Collect(new ShaderResourceView(device, resource));
                    }
                    TextureFormat = textureView.Description.Format;
                }
                else
                {
                    var handle   = new GCHandle();
                    var pixelPtr = IntPtr.Zero;
                    try
                    {
                        switch (content.DataType)
                        {
                        case TextureDataType.ByteArray:
                            handle   = GCHandle.Alloc(content.TextureRaw, GCHandleType.Pinned);
                            pixelPtr = handle.AddrOfPinnedObject();
                            break;

                        case TextureDataType.Color4:
                            handle   = GCHandle.Alloc(content.Color4Array, GCHandleType.Pinned);
                            pixelPtr = handle.AddrOfPinnedObject();
                            break;

                        case TextureDataType.Stream:
                            if (content.Texture == null || !content.Texture.CanRead)
                            {
                                Debug.WriteLine("Data is null or unreadable.");
                                return(false);
                            }
                            var temp = new byte[content.Texture.Length];
                            using (var pixelStream = new MemoryStream(temp))
                            {
                                lock (content.Texture)
                                {
                                    content.Texture.Position = 0;
                                    content.Texture.CopyTo(pixelStream);
                                }
                            }
                            handle   = GCHandle.Alloc(temp, GCHandleType.Pinned);
                            pixelPtr = handle.AddrOfPinnedObject();
                            break;

                        case TextureDataType.RawPointer:
                            pixelPtr = content.RawPointer;
                            break;
                        }
                        if (pixelPtr != IntPtr.Zero)
                        {
                            switch (content.Dimension)
                            {
                            case 1:
                                CreateView(pixelPtr, content.Width, content.PixelFormat, createSRV, enableAutoGenMipMap);
                                break;

                            case 2:
                                CreateView(pixelPtr, content.Width, content.Height, content.PixelFormat, createSRV, enableAutoGenMipMap);
                                break;

                            case 3:
                                CreateView(pixelPtr, content.Width, content.Height, content.Depth, content.PixelFormat, createSRV, enableAutoGenMipMap);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    finally
                    {
                        handle.Free();
                    }
                }
                return(true);
            }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShaderResourceViewProxy"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="textureDesc">The texture desc.</param>
 public ShaderResourceViewProxy(Device device, ref Texture3DDescription textureDesc) : this(device)
 {
     resource      = new Texture3D(device, textureDesc);
     TextureFormat = textureDesc.Format;
 }
 public void SetIndexBuffer(Buffer indexBufferRef, global::SharpDX.DXGI.Format format, int offset)
 {
     deviceContext.InputAssembler.SetIndexBuffer(indexBufferRef, format, offset);
 }
Exemplo n.º 25
0
 public void ResolveSubresource(Resource source, int sourceSubresource, Resource destination, int destinationSubresource, global::SharpDX.DXGI.Format format)
 {
     deviceContext.ResolveSubresource(source, sourceSubresource, destination, destinationSubresource, format);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShaderResourceViewProxy"/> class.
 /// </summary>
 /// <param name="view">The view.</param>
 public ShaderResourceViewProxy(ShaderResourceView view) : this(view.Device)
 {
     textureView   = Collect(view);
     TextureFormat = view.Description.Format;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Creates the 1D texture view from data array.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="array">The array.</param>
 /// <param name="format">The format.</param>
 /// <param name="createSRV">if set to <c>true</c> [create SRV].</param>
 /// <param name="generateMipMaps">if set to <c>true</c> [generate mip maps].</param>
 public void CreateView <T>(T[] array, global::SharpDX.DXGI.Format format,
                            bool createSRV = true, bool generateMipMaps = true) where T : struct
 {
     CreateView(array, array.Length, format, createSRV, generateMipMaps);
 }
Exemplo n.º 28
0
        public static Guid PixelFormatFromFormat(global::SharpDX.DXGI.Format format)
        {
            switch (format)
            {
            case global::SharpDX.DXGI.Format.R32G32B32A32_Typeless:
            case global::SharpDX.DXGI.Format.R32G32B32A32_Float:
                return(global::SharpDX.WIC.PixelFormat.Format128bppRGBAFloat);

            case global::SharpDX.DXGI.Format.R32G32B32A32_UInt:
            case global::SharpDX.DXGI.Format.R32G32B32A32_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format128bppRGBAFixedPoint);

            case global::SharpDX.DXGI.Format.R32G32B32_Typeless:
            case global::SharpDX.DXGI.Format.R32G32B32_Float:
                return(global::SharpDX.WIC.PixelFormat.Format96bppRGBFloat);

            case global::SharpDX.DXGI.Format.R32G32B32_UInt:
            case global::SharpDX.DXGI.Format.R32G32B32_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format96bppRGBFixedPoint);

            case global::SharpDX.DXGI.Format.R16G16B16A16_Typeless:
            case global::SharpDX.DXGI.Format.R16G16B16A16_Float:
            case global::SharpDX.DXGI.Format.R16G16B16A16_UNorm:
            case global::SharpDX.DXGI.Format.R16G16B16A16_UInt:
            case global::SharpDX.DXGI.Format.R16G16B16A16_SNorm:
            case global::SharpDX.DXGI.Format.R16G16B16A16_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format64bppRGBA);

            case global::SharpDX.DXGI.Format.R32G32_Typeless:
            case global::SharpDX.DXGI.Format.R32G32_Float:
            case global::SharpDX.DXGI.Format.R32G32_UInt:
            case global::SharpDX.DXGI.Format.R32G32_SInt:
            case global::SharpDX.DXGI.Format.R32G8X24_Typeless:
            case global::SharpDX.DXGI.Format.D32_Float_S8X24_UInt:
            case global::SharpDX.DXGI.Format.R32_Float_X8X24_Typeless:
            case global::SharpDX.DXGI.Format.X32_Typeless_G8X24_UInt:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R10G10B10A2_Typeless:
            case global::SharpDX.DXGI.Format.R10G10B10A2_UNorm:
            case global::SharpDX.DXGI.Format.R10G10B10A2_UInt:
                return(global::SharpDX.WIC.PixelFormat.Format32bppRGBA1010102);

            case global::SharpDX.DXGI.Format.R11G11B10_Float:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R8G8B8A8_Typeless:
            case global::SharpDX.DXGI.Format.R8G8B8A8_UNorm:
            case global::SharpDX.DXGI.Format.R8G8B8A8_UNorm_SRgb:
            case global::SharpDX.DXGI.Format.R8G8B8A8_UInt:
            case global::SharpDX.DXGI.Format.R8G8B8A8_SNorm:
            case global::SharpDX.DXGI.Format.R8G8B8A8_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format32bppRGBA);

            case global::SharpDX.DXGI.Format.R16G16_Typeless:
            case global::SharpDX.DXGI.Format.R16G16_Float:
            case global::SharpDX.DXGI.Format.R16G16_UNorm:
            case global::SharpDX.DXGI.Format.R16G16_UInt:
            case global::SharpDX.DXGI.Format.R16G16_SNorm:
            case global::SharpDX.DXGI.Format.R16G16_SInt:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R32_Typeless:
            case global::SharpDX.DXGI.Format.D32_Float:
            case global::SharpDX.DXGI.Format.R32_Float:
            case global::SharpDX.DXGI.Format.R32_UInt:
            case global::SharpDX.DXGI.Format.R32_SInt:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R24G8_Typeless:
            case global::SharpDX.DXGI.Format.D24_UNorm_S8_UInt:
            case global::SharpDX.DXGI.Format.R24_UNorm_X8_Typeless:
                return(global::SharpDX.WIC.PixelFormat.Format32bppGrayFloat);

            case global::SharpDX.DXGI.Format.X24_Typeless_G8_UInt:
            case global::SharpDX.DXGI.Format.R9G9B9E5_Sharedexp:
            case global::SharpDX.DXGI.Format.R8G8_B8G8_UNorm:
            case global::SharpDX.DXGI.Format.G8R8_G8B8_UNorm:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.B8G8R8A8_UNorm:
            case global::SharpDX.DXGI.Format.B8G8R8X8_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format32bppBGRA);

            case global::SharpDX.DXGI.Format.R10G10B10_Xr_Bias_A2_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format32bppBGR101010);

            case global::SharpDX.DXGI.Format.B8G8R8A8_Typeless:
            case global::SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb:
            case global::SharpDX.DXGI.Format.B8G8R8X8_Typeless:
            case global::SharpDX.DXGI.Format.B8G8R8X8_UNorm_SRgb:
                return(global::SharpDX.WIC.PixelFormat.Format32bppBGRA);

            case global::SharpDX.DXGI.Format.R8G8_Typeless:
            case global::SharpDX.DXGI.Format.R8G8_UNorm:
            case global::SharpDX.DXGI.Format.R8G8_UInt:
            case global::SharpDX.DXGI.Format.R8G8_SNorm:
            case global::SharpDX.DXGI.Format.R8G8_SInt:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R16_Typeless:
            case global::SharpDX.DXGI.Format.R16_Float:
            case global::SharpDX.DXGI.Format.D16_UNorm:
            case global::SharpDX.DXGI.Format.R16_UNorm:
            case global::SharpDX.DXGI.Format.R16_SNorm:
                return(global::SharpDX.WIC.PixelFormat.Format16bppGrayHalf);

            case global::SharpDX.DXGI.Format.R16_UInt:
            case global::SharpDX.DXGI.Format.R16_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format16bppGrayFixedPoint);

            case global::SharpDX.DXGI.Format.B5G6R5_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format16bppBGR565);

            case global::SharpDX.DXGI.Format.B5G5R5A1_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format16bppBGRA5551);

            case global::SharpDX.DXGI.Format.B4G4R4A4_UNorm:
                return(Guid.Empty);

            case global::SharpDX.DXGI.Format.R8_Typeless:
            case global::SharpDX.DXGI.Format.R8_UNorm:
            case global::SharpDX.DXGI.Format.R8_UInt:
            case global::SharpDX.DXGI.Format.R8_SNorm:
            case global::SharpDX.DXGI.Format.R8_SInt:
                return(global::SharpDX.WIC.PixelFormat.Format8bppGray);

            case global::SharpDX.DXGI.Format.A8_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format8bppAlpha);

            case global::SharpDX.DXGI.Format.R1_UNorm:
                return(global::SharpDX.WIC.PixelFormat.Format1bppIndexed);

            default:
                return(Guid.Empty);
            }
        }