Fixed DepthStencilTarget

This commit is contained in:
Simon Lübeß
2024-05-20 13:34:41 +02:00
parent 1a43ff2971
commit e5139ee3e8
6 changed files with 25 additions and 29 deletions
@@ -8,27 +8,6 @@ using internal GlitchyEngine.Platform.DX11;
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;
case .None:
Log.EngineLogger.Assert(false, "None is not a valid depth stencil format");
return .Unknown;
}
}
}
// TODO: Depth stencil target is technically just a RenderTarget
extension DepthStencilTarget
{
@@ -39,7 +18,7 @@ namespace GlitchyEngine.Renderer
Debug.Profiler.ProfileResourceFunction!();
Texture2DDescription desc = .();
desc.Format = (.)_format;
desc.Format = (Format)_format;
desc.ArraySize = 1;
desc.BindFlags = .DepthStencil;
desc.Width = _width;
@@ -63,7 +63,7 @@ namespace GlitchyEngine.Renderer
PlatformCreateTexture();
}
if(_description.DepthStencilFormat != .None)
if(_description.DepthStencilFormat != .Unknown)
{
_depthStenilTarget = new DepthStencilTarget(_description.Width, _description.Height, _description.DepthStencilFormat);
}
@@ -4,11 +4,28 @@ namespace GlitchyEngine.Renderer
{
public enum DepthStencilFormat
{
case Unknown,
D16_UNorm,
D24_UNorm_S8_UInt,
D32_Float,
D32_Float_S8X24_UInt,
None
D32_Float_S8X24_UInt;
public static Format operator explicit(Self depthFormat)
{
switch (depthFormat)
{
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;
default:
return .Unknown;
}
}
}
// TODO: add all features.
@@ -23,7 +40,7 @@ namespace GlitchyEngine.Renderer
public this(uint32 width, uint32 height, DepthStencilFormat format = .D32_Float)
{
Log.EngineLogger.Assert(format != .None, "DepthStencilFormat None is only valid for RenderTarget");
Log.EngineLogger.Assert(format != .Unknown, "DepthStencilFormat None is only valid for RenderTarget");
_width = width;
_height = height;
+1 -1
View File
@@ -20,7 +20,7 @@ namespace GlitchyEngine.Renderer
public bool IsSwapchainTarget;
public this(Format pixelFormat, uint32 width, uint32 height, uint32 arraySize = 1, uint32 mipLevels = 1,
DepthStencilFormat depthStencilFormat = .None, CPUAccessFlags cpuAccess = .None, uint32 sampleCount = 1, uint32 sampleQuality = 0, bool isSwapchainTarget = false)
DepthStencilFormat depthStencilFormat = .Unknown, CPUAccessFlags cpuAccess = .None, uint32 sampleCount = 1, uint32 sampleQuality = 0, bool isSwapchainTarget = false)
{
PixelFormat = pixelFormat;
Width = width;
+1 -1
View File
@@ -148,7 +148,7 @@ namespace GlitchyEngine.Renderer
* Clamping value used if FilterMode.Anisotropic is specified in the Filters.
* Valid values are between 1 and 16.
*/
public uint8 MaxAnisotropy = 1; // TODO: we could use a smaller int
public uint8 MaxAnisotropy = 1;
/**
* Border color to use if TextureAddressMode.Border is specified for AddressModeU, AddressModeV, or AddressModeW.
+1 -1
View File
@@ -10,7 +10,7 @@ namespace GlitchyEngine.Renderer
private Viewport _backBufferViewport;
private DepthStencilFormat _depthStencilFormat = .None;
private DepthStencilFormat _depthStencilFormat = .Unknown;
public RenderTarget2D _backBuffer ~ _?.ReleaseRef();