Skip to content

Commit

Permalink
Fixed occlusion culling bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
JunaMeinhold committed Apr 25, 2024
1 parent 9a8bbec commit 7719a06
Show file tree
Hide file tree
Showing 33 changed files with 879 additions and 76 deletions.
3 changes: 2 additions & 1 deletion HexaEngine.Core/Graphics/DepthMipChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ public DepthMipChain(int width, int height, [CallerFilePath] string filename = "
/// </summary>
public int MipLevels => mipLevels;

public string DebugName => dbgName;

/// <summary>
/// Resizes the depth mip chain to the specified width and height.
/// </summary>
/// <param name="device">The graphics device for rendering.</param>
/// <param name="width">The new width for the depth mip chain.</param>
/// <param name="height">The new height for the depth mip chain.</param>
public void Resize(int width, int height)
Expand Down
1 change: 1 addition & 0 deletions HexaEngine.Core/Graphics/Shaders/CrossCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public static bool CompileSPIRVFromSource(string source, string filename, string

ShadercCompileOptions options = Shaderc.ShadercCompileOptionsInitialize();
Shaderc.ShadercCompileOptionsSetOptimizationLevel(options, ShadercOptimizationLevel.Performance);
options.SetGenerateDebugInfo();
Shaderc.ShadercCompileOptionsSetSourceLanguage(options, sourceLanguage);

for (int i = 0; i < macros.Length; i++)
Expand Down
13 changes: 13 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/ArrayTraits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct ArrayTraits
{
public uint DimsCount;

public unsafe fixed uint Dims[32];

public unsafe fixed uint SpecConstantOpIds[32];

public uint Stride;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public unsafe struct ConstantBufferMemberInfo
{
public string Name;

public uint Offset;
public uint AbsoluteOffset;
public uint Size;
public uint PaddedSize;
public TypeInfo* Type;

public void Release()
{
if (Type != null)
{
Type->Release();

Free(Type);
Type = null;
}
}
}
}
23 changes: 23 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/DecorationFlags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
[Flags]
public enum DecorationFlags
{
None = 0,
Block = 1,
BufferBlock = 2,
RowMajor = 4,
ColumnMajor = 8,
BuiltIn = 0x10,
NoPerspective = 0x20,
Flat = 0x40,
NonWritable = 0x80,
RelaxedPrecision = 0x100,
NonReadable = 0x200,
Patch = 0x400,
PerVertex = 0x800,
PerTask = 0x1000,
WeightTexture = 0x2000,
BlockMatchTexture = 0x4000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
using Silk.NET.SPIRV.Reflect;

public struct DescriptorBindingInfo
{
public string Name;
public DescriptorType Type;
public int BufferSize;
public ConstantBufferMemberInfo[] Members;
}
}
15 changes: 15 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/Dimension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public enum Dimension
{
Texture1D = 0,
Texture2D = 1,
Texture3D = 2,
TextureCube = 3,
Rect = 4,
Buffer = 5,
SubpassData = 6,
TileImageDataExt = 4173,
Max = int.MaxValue
}
}
49 changes: 49 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/ImageFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public enum ImageFormat
{
Unknown = 0,
RGBA32F = 1,
RGBA16F = 2,
R32F = 3,
RGBA8 = 4,
RGBA8SNorm = 5,
RG32F = 6,
RG16F = 7,
R11FG11FB10F = 8,
R16F = 9,
RGBA16 = 10,
RGB10A2 = 11,
RG16 = 12,
RG8 = 13,
R16 = 14,
R8 = 15,
RGBA16SNorm = 16,
RG16SNorm = 17,
RG8SNorm = 18,
R16SNorm = 19,
R8SNorm = 20,
RGBA32I = 21,
RGBA16I = 22,
RGBA8I = 23,
R32I = 24,
RG32I = 25,
RG16I = 26,
RG8I = 27,
R16I = 28,
R8I = 29,
RGBA32UI = 30,
RGBA16UI = 31,
RGBA8UI = 32,
R32UI = 33,
RGB10A2UI = 34,
RG32UI = 35,
RG16UI = 36,
RG8UI = 37,
R16UI = 38,
R8UI = 39,
R64UI = 40,
R64I = 41,
Max = int.MaxValue
}
}
12 changes: 12 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/ImageTraits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct ImageTraits
{
public Dimension Dim;
public uint Depth;
public bool Arrayed;
public bool Ms;
public bool Sampled;
public ImageFormat ImageFormat;
}
}
9 changes: 9 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/Matrix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct Matrix
{
public uint ColumnCount;
public uint RowCount;
public uint Stride;
}
}
9 changes: 9 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/NumericTraits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct NumericTraits
{
public Scalar Scalar;
public Vector Vector;
public Matrix Matrix;
}
}
8 changes: 8 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/Scalar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct Scalar
{
public uint Width;
public bool Signed;
}
}
74 changes: 74 additions & 0 deletions HexaEngine.Core/Graphics/Shaders/Reflection/ShaderReflection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
namespace HexaEngine.Core.Graphics.Shaders.Reflection
{
public struct ConstantBuffer
{
public string? Name;
public uint Slot;
public uint Size;
public uint PaddedSize;
public ConstantBufferMemberInfo[] Members;

public ConstantBuffer(string? name, uint slot, uint size, uint paddedSize, ConstantBufferMemberInfo[] members)
{
Name = name;
Slot = slot;
Size = size;
PaddedSize = paddedSize;
Members = members;
}

public void Release()
{
if (Members != null)
{
for (int i = 0; i < Members.Length; i++)
{
Members[i].Release();
}
}

this = default;
}
}

public class ShaderReflection : IDisposable
{
public readonly ConstantBuffer[] ConstantBuffers;

private bool disposedValue;

public ShaderReflection(ConstantBuffer[] constantBuffers)
{
ConstantBuffers = constantBuffers;
}

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
for (var i = 0; i < ConstantBuffers.Length; i++)
{
ConstantBuffers[i].Release();
}
}

disposedValue = true;
}
}

~ShaderReflection()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: false);
}

public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
Loading

0 comments on commit 7719a06

Please sign in to comment.