/// <summary> /// Creates a <see cref="Framebuffer2D"/> with the given width, height, and other optional parameters. /// </summary> /// <param name="graphicsDevice">The <see cref="GraphicsDevice"/> this <see cref="Framebuffer2D"/> will use.</param> /// <param name="width">The width of the <see cref="Framebuffer2D"/>'s image.</param> /// <param name="height">The height of the <see cref="Framebuffer2D"/>'s image.</param> /// <param name="depthStencilFormat">The depth-stencil format for an optional renderbuffer attachment.</param> /// <param name="samples">The amount of samples for the <see cref="Framebuffer2D"/>'s image.</param> /// <param name="imageFormat">The format of the <see cref="Framebuffer2D"/>'s image.</param> /// <param name="useDepthStencilTexture">Whether to use a texture for the depth-stencil buffer instead of a renderbuffer.</param> public Framebuffer2D(GraphicsDevice graphicsDevice, uint width, uint height, DepthStencilFormat depthStencilFormat, uint samples = 0, TextureImageFormat imageFormat = TextureImageFormat.Color4b, bool useDepthStencilTexture = false) { Framebuffer = new FramebufferObject(graphicsDevice); Texture = new Texture2D(graphicsDevice, width, height, false, samples, imageFormat); if (depthStencilFormat != DepthStencilFormat.None) { if (useDepthStencilTexture) { TextureImageFormat dsFormat = TrippyUtils.DepthStencilFormatToTextureFormat(depthStencilFormat); Texture2D dsTexture = new Texture2D(graphicsDevice, width, height, false, samples, dsFormat); Framebuffer.Attach(dsTexture, TrippyUtils.GetCorrespondingTextureFramebufferAttachmentPoint(dsFormat)); } else { RenderbufferObject rbo = new RenderbufferObject(graphicsDevice, width, height, (RenderbufferFormat)depthStencilFormat, samples); Framebuffer.Attach(rbo, TrippyUtils.GetCorrespondingRenderbufferFramebufferAttachmentPoint(rbo.Format)); } } Framebuffer.Attach(Texture, FramebufferAttachmentPoint.Color0); Framebuffer.UpdateFramebufferData(); }
/// <summary> /// Gets the <see cref="TextureImageFormat"/> that corresponds for a give <see cref="DepthStencilFormat"/>. /// </summary> public static TextureImageFormat DepthStencilFormatToTextureFormat(DepthStencilFormat depthStencilFormat) { return(depthStencilFormat switch { DepthStencilFormat.Depth16 => TextureImageFormat.Depth16, DepthStencilFormat.Depth24 => TextureImageFormat.Depth24, DepthStencilFormat.Depth32f => TextureImageFormat.Depth32f, DepthStencilFormat.Depth24Stencil8 => TextureImageFormat.Depth24Stencil8, _ => throw new ArgumentException("Specified depth-stencil format can't be used in a texture.", nameof(DepthStencilFormat)) });
public override DepthStencilBase CreateDepthStencil(int width, int height, DepthStencilFormat format, StencilUsage stencilUsage, DepthStencilMode mode, MSAALevel msaaLevel) { var abstraction = new DepthStencil(this, stencilUsage, mode); if (!abstraction.Init(width, height, format, msaaLevel)) { abstraction.Dispose(); throw new Exception("Failed to create DepthStencil"); } return(abstraction); }
public override SwapChainBase CreateSwapChain(WindowBase window, int bufferCount, bool fullscreen, bool ensureSizeMatchesWindowSize, SwapChainFormat format, SwapChainType type, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, SwapChainVSyncMode vSyncMode) { throw new NotImplementedException(); }
public abstract SwapChainBase CreateSwapChain(WindowBase window, int bufferCount, bool fullscreen, bool ensureSizeMatchesWindowSize, SwapChainFormat format, SwapChainType type, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, SwapChainVSyncMode vSyncMode);
public abstract DepthStencilBase CreateDepthStencil(int width, int height, DepthStencilFormat format, StencilUsage stencilUsage, DepthStencilMode mode, MSAALevel msaaLevel);
public abstract Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility);
public override SwapChainBase CreateSwapChain(WindowBase window, int bufferCount, bool fullscreen, bool ensureSizeMatchesWindowSize, SwapChainFormat format, SwapChainType type, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, SwapChainVSyncMode vSyncMode) { return(primaryDevice.CreateSwapChain(window, bufferCount, fullscreen, ensureSizeMatchesWindowSize, format, type, stencilUsage, depthStencilFormat, depthStencilMode, vSyncMode)); }
public unsafe bool Init(int width, int height, DepthStencilFormat format, MSAALevel msaaLevel) { this.width = width; this.height = height; return(Orbital_Video_D3D12_DepthStencil_Init(handle, format, (uint)width, (uint)height, msaaLevel) != 0); }
/// <summary> /// Returns whether a <see cref="DepthStencilFormat"/> is a stencil-only format. /// </summary> public static bool IsDepthStencilFormatStencilOnly(DepthStencilFormat format) { return(format == DepthStencilFormat.Stencil8); }
/// <summary> /// Returns whether a <see cref="DepthStencilFormat"/> is a depth-and-stencil format. /// </summary> public static bool IsDepthStencilFormatDepthAndStencil(DepthStencilFormat format) { return(format == DepthStencilFormat.Depth24Stencil8 || format == DepthStencilFormat.Depth32fStencil8); }
/// <summary> /// Returns whether a <see cref="DepthStencilFormat"/> is a depth-only format. /// </summary> public static bool IsDepthStencilFormatDepthOnly(DepthStencilFormat format) { return(format == DepthStencilFormat.Depth16 || format == DepthStencilFormat.Depth24 || format == DepthStencilFormat.Depth32f); }
public override DepthStencilBase CreateDepthStencil(int width, int height, DepthStencilFormat format, StencilUsage stencilUsage, DepthStencilMode mode, MSAALevel msaaLevel) { return(activeDevice.CreateDepthStencil(width, height, format, stencilUsage, mode, msaaLevel)); }
public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility) { return(activeDevice.CreateRenderTexture2D(width, height, format, usage, data, mode, stencilUsage, depthStencilFormat, depthStencilMode, allowRandomAccess, nodeVisibility)); }
public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility) { throw new NotImplementedException(); }
public override DepthStencilBase CreateDepthStencil(int width, int height, DepthStencilFormat format, StencilUsage stencilUsage, DepthStencilMode mode, MSAALevel msaaLevel) { throw new NotImplementedException(); }
public override SwapChainBase CreateSwapChain(WindowBase window, int bufferCount, bool fullscreen, bool ensureSizeMatchesWindowSize, SwapChainFormat format, SwapChainType type, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, SwapChainVSyncMode vSyncMode) { var abstraction = new SwapChain(this, ensureSizeMatchesWindowSize, type); if (!abstraction.Init(window, bufferCount, fullscreen, format, stencilUsage, depthStencilFormat, depthStencilMode, vSyncMode)) { abstraction.Dispose(); throw new Exception("Failed to create SwapChain"); } return(abstraction); }
private static extern int Orbital_Video_D3D12_DepthStencil_Init(IntPtr handle, DepthStencilFormat format, uint width, uint height, MSAALevel msaaLevel);
public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility) { var abstraction = new RenderTexture2D(this, usage, mode); if (!abstraction.Init(width, height, format, data, stencilUsage, depthStencilFormat, depthStencilMode, allowRandomAccess, nodeVisibility)) { abstraction.Dispose(); throw new Exception("Failed to create RenderTexture2D"); } return(abstraction); }
public bool Init(WindowBase window, int bufferCount, bool fullscreen, SwapChainFormat format, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, SwapChainVSyncMode vSyncMode) { var size = window.GetSize(WindowSizeType.WorkingArea); depthStencilD3D12 = new DepthStencil(deviceD3D12, stencilUsage, depthStencilMode); depthStencil = depthStencilD3D12; if (!depthStencilD3D12.Init(size.width, size.height, depthStencilFormat, MSAALevel.Disabled)) { return(false); } return(Init(window, bufferCount, fullscreen, format, vSyncMode)); }
public bool Init(int width, int height, TextureFormat format, byte[] data, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility) { depthStencil = new DepthStencil(deviceD3D12, stencilUsage, depthStencilMode); if (!depthStencil.Init(width, height, depthStencilFormat, MSAALevel.Disabled)) { return(false); } return(Init(width, height, format, data, true, allowRandomAccess, MSAALevel.Disabled, nodeVisibility)); }