예제 #1
0
        protected internal Texture3D(GraphicsDevice device, TextureDescription description3D, DataBox[] dataBoxes = null) : base(device, description3D, ViewType.Full, 0, 0)
        {
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            throw new NotImplementedException();
#else
            Target = TextureTarget.Texture3D;
#endif
        }
예제 #2
0
 protected internal Texture3D(GraphicsDevice device, TextureDescription description3D, DataBox[] dataBoxes = null)
     : base(device, description3D)
 {
 }
예제 #3
0
 /// <summary>
 /// Creates a new 3D <see cref="Texture"/>.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="depth">The depth.</param>
 /// <param name="mipCount">Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <returns>
 /// A new instance of 3D <see cref="Texture"/> class.
 /// </returns>
 public static Texture New3D(GraphicsDevice device, int width, int height, int depth, MipMapCount mipCount, PixelFormat format, DataBox[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)
 {
     return(new Texture(device).InitializeFrom(TextureDescription.New3D(width, height, depth, mipCount, format, textureFlags, usage), textureData));
 }
예제 #4
0
 protected internal Texture2D(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null, bool initialize = true) : base(device, description2D, TextureTarget.Texture2D, dataBoxes, initialize)
 {
 }
예제 #5
0
        private static TextureDescription ConvertFromNativeDescription(Texture2DDescription description)
        {
            var desc = new TextureDescription()
            {
                Dimension = TextureDimension.Texture2D,
                Width = description.Width,
                Height = description.Height,
                Depth = 1,
                MultiSampleLevel = (MSAALevel)description.SampleDescription.Count,
                Format = (PixelFormat)description.Format,
                MipLevels = description.MipLevels,
                Usage = (GraphicsResourceUsage)description.Usage,
                ArraySize = description.ArraySize,
                Flags = TextureFlags.None
            };

            if ((description.BindFlags & BindFlags.RenderTarget) != 0)
                desc.Flags |= TextureFlags.RenderTarget;
            if ((description.BindFlags & BindFlags.UnorderedAccess) != 0)
                desc.Flags |= TextureFlags.UnorderedAccess;
            if ((description.BindFlags & BindFlags.DepthStencil) != 0)
                desc.Flags |= TextureFlags.DepthStencil;
            if ((description.BindFlags & BindFlags.ShaderResource) != 0)
                desc.Flags |= TextureFlags.ShaderResource;

            return desc;
        }
예제 #6
0
 protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
     : base(device, description1D, ViewType.Full, 0, 0)
 {
     Target = TextureTarget1D;
 }
예제 #7
0
 /// <summary>
 /// Creates a new 1D <see cref="Texture" /> with a single level of mipmap.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice" />.</param>
 /// <param name="width">The width.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="dataPtr">Data ptr</param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <param name="usage">The usage.</param>
 /// <returns>A new instance of 1D <see cref="Texture" /> class.</returns>
 /// <remarks>The first dimension of mipMapTextures describes the number of array (Texture Array), second dimension is the mipmap, the third is the texture data for a particular mipmap.</remarks>
 public static Texture New1D(GraphicsDevice device, int width, PixelFormat format, IntPtr dataPtr, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable)
 {
     return(New(device, TextureDescription.New1D(width, format, textureFlags, usage), new[] { new DataBox(dataPtr, 0, 0), }));
 }
예제 #8
0
 /// <summary>
 /// Creates a new 1D <see cref="Texture"/>.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="width">The width.</param>
 /// <param name="mipCount">Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <param name="arraySize">Size of the texture 2D array, default to 1.</param>
 /// <returns>
 /// A new instance of 1D <see cref="Texture"/> class.
 /// </returns>
 public static Texture New1D(GraphicsDevice device, int width, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)
 {
     return(New(device, TextureDescription.New1D(width, mipCount, format, textureFlags, arraySize, usage)));
 }
예제 #9
0
 protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
     : base(device, description1D, ViewType.Full, 0, 0)
 {
     Target = TextureTarget1D;
 }
예제 #10
0
 internal TextureCube(GraphicsDevice device, TextureDescription description2D) : base(device, description2D, null)
 {
 }
예제 #11
0
 internal TextureCube(GraphicsDevice device, TextureDescription description2D, params DataBox[] dataBoxes) : base(device, description2D, dataBoxes)
 {
 }
예제 #12
0
 /// <summary>
 /// Creates a new texture from a <see cref="Texture2DDescription"/>.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="description">The description.</param>
 /// <returns>
 /// A new instance of <see cref="TextureCube"/> class.
 /// </returns>
 public static TextureCube New(GraphicsDevice device, TextureDescription description)
 {
     return(new TextureCube(device, description));
 }
예제 #13
0
 protected internal Texture2DBase(GraphicsDevice device, TextureDescription description2D, TextureTarget textureTarget, DataBox[] dataBoxes = null, bool initialize = true) : base(device, description2D, ViewType.Full, 0, 0)
 {
     Target = textureTarget;
     if (initialize)
         Init(dataBoxes);
 }
예제 #14
0
        protected static Texture2DDescription ConvertToNativeDescription(GraphicsDevice device, TextureDescription description)
        {
            var format = (Format)description.Format;
            var flags  = description.Flags;

            // If the texture is going to be bound on the depth stencil, for to use TypeLess format
            if ((flags & TextureFlags.DepthStencil) != 0)
            {
                if (device.Features.Profile < GraphicsProfile.Level_10_0)
                {
                    flags &= ~TextureFlags.ShaderResource;
                }
                else
                {
                    // Determine TypeLess Format and ShaderResourceView Format
                    switch (description.Format)
                    {
                    case PixelFormat.D16_UNorm:
                        format = SharpDX.DXGI.Format.R16_Typeless;
                        break;

                    case PixelFormat.D32_Float:
                        format = SharpDX.DXGI.Format.R32_Typeless;
                        break;

                    case PixelFormat.D24_UNorm_S8_UInt:
                        format = SharpDX.DXGI.Format.R24G8_Typeless;
                        break;

                    case PixelFormat.D32_Float_S8X24_UInt:
                        format = SharpDX.DXGI.Format.R32G8X24_Typeless;
                        break;

                    default:
                        throw new InvalidOperationException(string.Format("Unsupported DepthFormat [{0}] for depth buffer", description.Format));
                    }
                }
            }

            var desc = new Texture2DDescription()
            {
                Width     = description.Width,
                Height    = description.Height,
                ArraySize = description.ArraySize,
                // TODO calculate appropriate MultiSamples
                SampleDescription = new SampleDescription(1, 0),
                BindFlags         = GetBindFlagsFromTextureFlags(flags),
                Format            = format,
                MipLevels         = description.MipLevels,
                Usage             = (ResourceUsage)description.Usage,
                CpuAccessFlags    = GetCpuAccessFlagsFromUsage(description.Usage),
                OptionFlags       = ResourceOptionFlags.None
            };

            if (description.Dimension == TextureDimension.TextureCube)
            {
                desc.OptionFlags = ResourceOptionFlags.TextureCube;
            }

            return(desc);
        }
예제 #15
0
 /// <summary>
 /// Creates a texture for output.
 /// </summary>
 /// <param name="description">The description.</param>
 /// <returns>Texture.</returns>
 protected virtual Texture CreateTexture(TextureDescription description)
 {
     return(Texture.New(GraphicsDevice, description));
 }
예제 #16
0
 protected internal Texture3D(GraphicsDevice device, TextureDescription description3D, DataBox[] dataBoxes = null)
     : base(device, description3D)
 {
 }
예제 #17
0
 protected internal TextureCube(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null) : base(device, description2D, TextureTarget.TextureCubeMap)
 {
     throw new NotImplementedException();
 }
예제 #18
0
 protected internal Texture2D(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null, bool initialize = true) : base(device, description2D, TextureTarget.Texture2D, dataBoxes, initialize)
 {
 }
예제 #19
0
 /// <summary>
 /// Creates a new 1D <see cref="Texture" /> with a single level of mipmap.
 /// </summary>
 /// <typeparam name="T">Type of the initial data to upload to the texture</typeparam>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="width">The width.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="textureData">Texture data. Size of must be equal to sizeof(Format) * width </param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <returns>A new instance of <see cref="Texture" /> class.</returns>
 /// <remarks>
 /// The first dimension of mipMapTextures describes the number of array (Texture Array), second dimension is the mipmap, the third is the texture data for a particular mipmap.
 /// </remarks>
 public unsafe static Texture New1D <T>(GraphicsDevice device, int width, PixelFormat format, T[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : struct
 {
     return(New(device, TextureDescription.New1D(width, format, textureFlags, usage), new[] { GetDataBox(format, width, 1, 1, textureData, (IntPtr)Interop.Fixed(textureData)) }));
 }
예제 #20
0
 protected Texture2D(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null)
     : base(device, description2D, dataBoxes)
 {
 }
예제 #21
0
 /// <summary>
 /// Creates a new texture from a <see cref="Direct3D11.Texture2D"/>.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="texture">The native texture <see cref="Direct3D11.Texture2D"/>.</param>
 /// <returns>
 /// A new instance of <see cref="Texture2D"/> class.
 /// </returns>
 public static Texture2D New(GraphicsDevice device, TextureDescription textureDescription)
 {
     return(new Texture2D(device, textureDescription));
 }
예제 #22
0
 protected Texture2D(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null)
     : base(device, description2D, dataBoxes)
 {
 }
예제 #23
0
 protected internal TextureCube(GraphicsDevice device, TextureDescription description2D, DataBox[] dataBoxes = null) : base(device, description2D, TextureTarget.TextureCubeMap)
 {
     throw new NotImplementedException();
 }
예제 #24
0
 /// <summary>
 /// Creates a new Cube <see cref="Texture" />.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice" />.</param>
 /// <param name="size">The size (in pixels) of the top-level faces of the cube texture.</param>
 /// <param name="mipCount">Number of mipmaps, set to true to have all mipmaps, set to an int &gt;=1 for a particular mipmap count.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="textureFlags">The texture flags.</param>
 /// <param name="usage">The usage.</param>
 /// <returns>A new instance of 2D <see cref="Texture" /> class.</returns>
 public static Texture NewCube(GraphicsDevice device, int size, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)
 {
     return(new Texture(device).InitializeFrom(TextureDescription.NewCube(size, mipCount, format, textureFlags, usage)));
 }
예제 #25
0
 /// <summary>
 /// Check and modify if necessary the mipmap levels of the image (Troubles with DXT images whose resolution in less than 4x4 in DX9.x).
 /// </summary>
 /// <param name="device">The graphics device.</param>
 /// <param name="description">The texture description.</param>
 /// <returns>The updated texture description.</returns>
 private static TextureDescription CheckMipLevels(GraphicsDevice device, ref TextureDescription description)
 {
     if (device.Features.Profile < GraphicsProfile.Level_10_0 && (description.Flags & TextureFlags.DepthStencil) == 0 && description.Format.IsCompressed())
     {
         description.MipLevels = Math.Min(CalculateMipCount(description.Width, description.Height), description.MipLevels);
     }
     return description;
 }
예제 #26
0
 /// <summary>
 /// Creates a new 2D <see cref="Texture" />.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="mipCount">Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.</param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <param name="arraySize">Size of the texture 2D array, default to 1.</param>
 /// <param name="usage">The usage.</param>
 /// <returns>A new instance of 2D <see cref="Texture" /> class.</returns>
 public static Texture New2D(GraphicsDevice device, int width, int height, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)
 {
     return(new Texture(device).InitializeFrom(TextureDescription.New2D(width, height, mipCount, format, textureFlags, arraySize, usage)));
 }
예제 #27
0
 // Gets a new temporary render target matching the description, but with scale and format overridable.
 private Texture GetScopedRenderTarget(TextureDescription desc, float scale, PixelFormat format) 
 {
     return NewScopedRenderTarget2D(
                 (int)(desc.Width  * scale),
                 (int)(desc.Height * scale),
                 format,
                 TextureFlags.ShaderResource | TextureFlags.RenderTarget);
 }
예제 #28
0
 /// <summary>
 /// Gets a render target with the specified description, scoped for the duration of the <see cref="DrawEffect.DrawCore"/>.
 /// </summary>
 /// <returns>A new instance of texture.</returns>
 protected Texture NewScopedRenderTarget2D(TextureDescription description)
 {
     // TODO: Check if we should introduce an enum for the kind of scope (per DrawCore, per Frame...etc.)
     CheckIsInDrawCore();
     return PushScopedResource(Context.Allocator.GetTemporaryTexture2D(description));
 }