Refactor GGXMipGenerationJobSPMD for SPMD support
Replaced struct with generic SPMD version for SIMD, added type aliases (commented), optimized RadicalInverse_VdC, and adjusted SampleEquirectangularMap for better performance and code separation.
This commit is contained in:
@@ -10,6 +10,9 @@ using System.Runtime.CompilerServices;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using static Misaki.HighPerformance.Mathematics.math;
|
using static Misaki.HighPerformance.Mathematics.math;
|
||||||
|
|
||||||
|
//using TFloat = Misaki.HighPerformance.Mathematics.SPMD.WideLane<float>;
|
||||||
|
//using TInt = Misaki.HighPerformance.Mathematics.SPMD.WideLane<int>;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Test.Benchmark;
|
namespace Misaki.HighPerformance.Test.Benchmark;
|
||||||
|
|
||||||
internal unsafe struct MipLevel
|
internal unsafe struct MipLevel
|
||||||
@@ -21,6 +24,7 @@ internal unsafe struct MipLevel
|
|||||||
public float roughness;
|
public float roughness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//internal unsafe struct GGXMipGenerationJobSPMD : IJobParallelFor
|
||||||
internal unsafe struct GGXMipGenerationJobSPMD<TFloat, TInt> : IJobParallelFor
|
internal unsafe struct GGXMipGenerationJobSPMD<TFloat, TInt> : IJobParallelFor
|
||||||
where TFloat : unmanaged, ISPMDLane<TFloat, float>
|
where TFloat : unmanaged, ISPMDLane<TFloat, float>
|
||||||
where TInt : unmanaged, ISPMDLane<TInt, int>
|
where TInt : unmanaged, ISPMDLane<TInt, int>
|
||||||
@@ -32,7 +36,7 @@ internal unsafe struct GGXMipGenerationJobSPMD<TFloat, TInt> : IJobParallelFor
|
|||||||
public float* radicalInverse_VdCLut;
|
public float* radicalInverse_VdCLut;
|
||||||
public int numMipLevels;
|
public int numMipLevels;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public static float RadicalInverse_VdC(uint bits)
|
public static float RadicalInverse_VdC(uint bits)
|
||||||
{
|
{
|
||||||
bits = (bits << 16) | (bits >> 16);
|
bits = (bits << 16) | (bits >> 16);
|
||||||
@@ -96,6 +100,7 @@ internal unsafe struct GGXMipGenerationJobSPMD<TFloat, TInt> : IJobParallelFor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Samples the source HDR image using bilinear interpolation (simplified to nearest neighbor for brevity here)
|
// Samples the source HDR image using bilinear interpolation (simplified to nearest neighbor for brevity here)
|
||||||
|
// Do not inline this function to avoid register pressure and code bloat in the main sampling loop, as this is a relatively heavy operation and we want to keep it separate for better instruction cache usage.
|
||||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private static Vector3<TFloat, float> SampleEquirectangularMap(float* img, int w, int h, Vector3<TFloat, float> dir)
|
private static Vector3<TFloat, float> SampleEquirectangularMap(float* img, int w, int h, Vector3<TFloat, float> dir)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user