/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D render target /// </summary> /// <param name="format">The <see cref="DataFormat"/> for the render target</param> /// <param name="width">The width, in texels, of the target</param> /// <param name="height">The height, in texels, of the target</param> /// <param name="clearColor">The <see cref="Rgba128"/> to set to be the optimized clear value</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the render target</param> /// <returns>A new <see cref="TextureDesc"/> representing a render target</returns> public static TextureDesc CreateRenderTargetDesc(DataFormat format, uint width, uint height, Rgba128 clearColor, MsaaDesc msaa = default) { return(new TextureDesc { Height = height, Width = width, DepthOrArraySize = 1, MipCount = 1, Dimension = TextureDimension.Tex2D, Format = format, ClearValue = TextureClearValue.CreateForRenderTarget(clearColor), Msaa = msaa, ResourceFlags = ResourceFlags.AllowRenderTarget, Layout = TextureLayout.Optimal }); }
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D depth stencil /// </summary> /// <param name="format">The <see cref="DataFormat"/> for the depth stencil</param> /// <param name="width">The width, in texels, of the depth stencil</param> /// <param name="height">The height, in texels, of the depth stencil</param> /// <param name="clearDepth">The <see cref="float"/> to set to be the optimized clear value for the depth element</param> /// <param name="clearStencil">The <see cref="byte"/> to set to be the optimized clear value for the stencil element</param> /// <param name="shaderVisible">Whether the <see cref="Texture"/> is shader visible. <see langword="true"/> by default</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the depth stencil</param> /// <returns>A new <see cref="TextureDesc"/> representing a depth stencil</returns> public static TextureDesc CreateDepthStencilDesc(DataFormat format, uint width, uint height, float clearDepth, byte clearStencil, bool shaderVisible = true, MsaaDesc msaa = default) { return(new TextureDesc { Height = height, Width = width, DepthOrArraySize = 1, MipCount = 1, Dimension = TextureDimension.Tex2D, Format = format, ClearValue = TextureClearValue.CreateForDepthStencil(clearDepth, clearStencil), Msaa = msaa, ResourceFlags = ResourceFlags.AllowDepthStencil | (shaderVisible ? 0 : ResourceFlags.DenyShaderResource), Layout = TextureLayout.Optimal }); }