From dc088dcb0a4fd9fa94766fb0293442054d54b1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Wed, 2 Jun 2021 16:51:25 +0200 Subject: [PATCH] Added pixelformat parameter to DepthStencilTarget-constructor --- .../DX11/Renderer/Dx11DepthStencilTarget.bf | 20 ++++++++++++++++++- .../src/Renderer/DepthStencilTarget.bf | 13 +++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf index fa262c0..ea25cc3 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf @@ -3,6 +3,24 @@ using internal GlitchyEngine.Renderer; namespace GlitchyEngine.Renderer { + extension DepthStencilFormat + { + public static explicit operator Format(Self self) + { + switch(self) + { + case .D16_UNorm: + return .D16_UNorm; + case .D24_UNorm_S8_UInt: + return .D24_UNorm_S8_UInt; + case .D32_Float: + return .D32_Float; + case .D32_Float_S8X24_UInt: + return .D32_Float_S8X24_UInt; + } + } + } + extension DepthStencilTarget { internal ID3D11DepthStencilView* nativeView ~ _?.Release(); @@ -10,7 +28,7 @@ namespace GlitchyEngine.Renderer protected override void PlatformCreate() { Texture2DDescription desc = .(); - desc.Format = .D32_Float; + desc.Format = (.)_format; desc.ArraySize = 1; desc.BindFlags = .DepthStencil; desc.Width = _width; diff --git a/GlitchyEngine/src/Renderer/DepthStencilTarget.bf b/GlitchyEngine/src/Renderer/DepthStencilTarget.bf index 9497b0b..c28d264 100644 --- a/GlitchyEngine/src/Renderer/DepthStencilTarget.bf +++ b/GlitchyEngine/src/Renderer/DepthStencilTarget.bf @@ -1,21 +1,32 @@ using System; namespace GlitchyEngine.Renderer { + public enum DepthStencilFormat + { + D16_UNorm, + D24_UNorm_S8_UInt, + D32_Float, + D32_Float_S8X24_UInt + } + // TODO: add all features. public class DepthStencilTarget : RefCounted { protected internal GraphicsContext _context ~ _?.ReleaseRef(); protected uint32 _width, _height; + protected DepthStencilFormat _format; public uint32 Width => _width; public uint32 Height => _height; + public DepthStencilFormat Format => _format; - public this(GraphicsContext context, uint32 width, uint32 height) + public this(GraphicsContext context, uint32 width, uint32 height, DepthStencilFormat format = .D32_Float) { _context = context..AddRef(); _width = width; _height = height; + _format = format; PlatformCreate(); }