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"); } }
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"); } }
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"); } }
/// <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 } }
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}\"."); }
/// <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); }
/// <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))); }
/// <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)); }