示例#1
0
        internal static D3D.RenderTargetViewDimension ToD3DRenderTargetViewDimension(TextureDimensions dimensions, bool multisampleEnabled)
        {
            switch (dimensions)
            {
            case TextureDimensions.One:
                return(D3D.RenderTargetViewDimension.Texture1DArray);

            case TextureDimensions.Two:
                if (multisampleEnabled)
                {
                    return(D3D.RenderTargetViewDimension.Texture2DMultisampled);
                }
                else
                {
                    return(D3D.RenderTargetViewDimension.Texture2D);
                }

            case TextureDimensions.Three:
                return(D3D.RenderTargetViewDimension.Texture3D);

            case TextureDimensions.Cube:
                if (multisampleEnabled)
                {
                    return(D3D.RenderTargetViewDimension.Texture2DMultisampledArray);
                }
                else
                {
                    return(D3D.RenderTargetViewDimension.Texture2DArray);
                }

            default:
                throw new ArgumentException("Invalid dimensions for render target creation");
            }
        }
示例#2
0
        internal static D3D.DepthStencilViewDimension ToD3DDepthStencilViewDimension(TextureDimensions dimensions, bool multisampleEnabled)
        {
            switch (dimensions)
            {
            case TextureDimensions.One:
                return(D3D.DepthStencilViewDimension.Texture1DArray);

            case TextureDimensions.Two:
                if (multisampleEnabled)
                {
                    return(D3D.DepthStencilViewDimension.Texture2DMultisampled);
                }
                else
                {
                    return(D3D.DepthStencilViewDimension.Texture2D);
                }

            case TextureDimensions.Cube:
                if (multisampleEnabled)
                {
                    return(D3D.DepthStencilViewDimension.Texture2DMultisampledArray);
                }
                else
                {
                    return(D3D.DepthStencilViewDimension.Texture2DArray);
                }

            case TextureDimensions.Three:
            default:
                throw new ArgumentException("Invalid dimensions for depth buffer creation");
            }
        }
示例#3
0
        public override Texture Load(IResource resource, LoaderParameters parameters)
        {
            Stream       stream = resource.OpenStream();
            BinaryReader input  = new BinaryReader(stream);

            DDSImageInfo image = ReadHeaderInfo(input);

            SurfaceFormat     format     = DetermineFormat(image);
            TextureDimensions dimensions = DetermineTextureDimensions(image);

            switch (dimensions)
            {
            case TextureDimensions.Two:
                Texture2D tex2d = LoadTexture2D(image, input, format);
                tex2d.Name = resource.Name;
                input.Close();
                return(tex2d);

            case TextureDimensions.Three:
                Texture3D tex3d = LoadTexture3D(image, input, format);
                tex3d.Name = resource.Name;
                input.Close();
                return(tex3d);

            case TextureDimensions.Cube:
                TextureCube texcube = LoadTextureCube(image, input, format);
                texcube.Name = resource.Name;
                input.Close();
                return(texcube);

            default:
                input.Close();
                throw new InvalidOperationException("Error loading DDS file");
            }
        }
示例#4
0
 /// <summary>
 /// Queries if the specified surface format is valid for vertex texture resources.
 /// </summary>
 /// <param name="surfaceFormat">Surface format</param>
 /// <param name="surfaceFormat">Surface format</param>
 /// <returns>True if valid, false otherwise</returns>
 public bool QueryVertexTextureFormat(SurfaceFormat surfaceFormat, TextureDimensions texType)
 {
     if (_graphicsDevice.GraphicsProfile == XFG.GraphicsProfile.HiDef)
     {
         return(_supportedVertexTextureFormats.Contains(XNAHelper.ToXNASurfaceFormat(surfaceFormat)));
     }
     else
     {
         return(false); //Vertex textures not supported
     }
 }
示例#5
0
        private static SamplerType ConvertSamplerType(TextureDimensions dimensions)
        {
            switch (dimensions)
            {
            case TextureDimensions.Texture1D:   return(SamplerType.Texture1D);

            case TextureDimensions.Texture2D:   return(SamplerType.Texture2D);

            case TextureDimensions.Texture3D:   return(SamplerType.Texture3D);

            case TextureDimensions.TextureCube: return(SamplerType.TextureCube);
            }

            throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\".");
        }
示例#6
0
        /// <summary>
        /// Queries if the specified surface format is valid for texture resources.
        /// </summary>
        /// <param name="surfaceFormat">Surface format</param>
        /// <param name="texType">The texture type</param>
        /// <returns>True if valid, false otherwise</returns>
        public bool QueryTextureFormat(SurfaceFormat surfaceFormat, TextureDimensions texType)
        {
            DXGI.Format       format  = D3D10Helper.ToD3DSurfaceFormat(surfaceFormat);
            D3D.FormatSupport support = _graphicsDevice.CheckFormatSupport(format);
            switch (texType)
            {
            case TextureDimensions.One:
                return((support & D3D.FormatSupport.Texture1D) == D3D.FormatSupport.Texture1D);

            case TextureDimensions.Two:
                return((support & D3D.FormatSupport.Texture2D) == D3D.FormatSupport.Texture2D);

            case TextureDimensions.Three:
                return((support & D3D.FormatSupport.Texture3D) == D3D.FormatSupport.Texture3D);

            case TextureDimensions.Cube:
                return((support & D3D.FormatSupport.TextureCube) == D3D.FormatSupport.TextureCube);
            }
            return(false);
        }
示例#7
0
 /// <summary>
 /// Queries if the specified surface format is valid for texture resources.
 /// </summary>
 /// <param name="surfaceFormat">Surface format</param>
 /// <param name="surfaceFormat">Surface format</param>
 /// <returns>True if valid, false otherwise</returns>
 public bool QueryTextureFormat(SurfaceFormat surfaceFormat, TextureDimensions texType)
 {
     return(_supportedTextureFormats.Contains(XNAHelper.ToXNASurfaceFormat(surfaceFormat)));
 }
示例#8
0
 /// <summary>
 /// Queries if the specified surface format is valid for vertex texture resources.
 /// </summary>
 /// <param name="surfaceFormat">Surface format</param>
 /// <param name="texType">The texture type</param>
 /// <returns>True if valid, false otherwise</returns>
 public bool QueryVertexTextureFormat(SurfaceFormat surfaceFormat, TextureDimensions texType)
 {
     //TODO: Is there an explict check for vertex texture formats? For now just mimic the regular format check.
     //Might have to check which formats support manually.
     return(QueryTextureFormat(surfaceFormat, texType));
 }