Removed multiline variable declarations
このコミットが含まれているのは:
1 親
6fa7464f84
コミット
ee0d3a7b68
31ファイル変更
+182
-194
検索条件に一致するファイルはありません
@@ -88,6 +88,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
// Initialize the complex kernels and parameters with the current arguments
|
||||
(KernelParameters, KernelsScale) = GetParameters();
|
||||
Kernels = CreateComplexKernels();
|
||||
|
||||
NormalizeKernels();
|
||||
|
||||
// Store them in the cache for future use
|
||||
@@ -161,6 +162,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
{
|
||||
// Prepare the kernel components
|
||||
int index = Math.Max(0, Math.Min(ComponentsCount - 1, KernelComponents.Count));
|
||||
|
||||
return (KernelComponents[index], KernelScales[index]);
|
||||
}
|
||||
|
||||
@@ -171,9 +173,11 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
{
|
||||
var kernels = new Complex64[KernelParameters.Length][];
|
||||
ref Vector4 baseRef = ref MemoryMarshal.GetReference(KernelParameters.AsSpan());
|
||||
|
||||
for (int i = 0; i < KernelParameters.Length; i++)
|
||||
{
|
||||
ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, i);
|
||||
|
||||
kernels[i] = CreateComplex1DKernel(paramsRef.X, paramsRef.Y);
|
||||
}
|
||||
|
||||
@@ -189,12 +193,14 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
{
|
||||
var kernel = new Complex64[KernelSize];
|
||||
ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan());
|
||||
int r = Radius, n = -r;
|
||||
int r = Radius;
|
||||
int n = -r;
|
||||
|
||||
for (int i = 0; i < KernelSize; i++, n++)
|
||||
{
|
||||
// Incrementally compute the range values
|
||||
float value = n * KernelsScale * (1f / r);
|
||||
|
||||
value *= value;
|
||||
|
||||
// Fill in the complex kernel values
|
||||
@@ -230,6 +236,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
{
|
||||
ref Complex64 jRef = ref Unsafe.Add(ref valueRef, j);
|
||||
ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k);
|
||||
|
||||
total +=
|
||||
paramsRef.Z * (jRef.Real * kRef.Real - jRef.Imaginary * kRef.Imaginary)
|
||||
+ paramsRef.W * (jRef.Real * kRef.Imaginary + jRef.Imaginary * kRef.Real);
|
||||
@@ -239,6 +246,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
|
||||
// Normalize the kernels
|
||||
float scalar = 1f / MathF.Sqrt(total);
|
||||
|
||||
for (int i = 0; i < kernelsSpan.Length; i++)
|
||||
{
|
||||
ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, i);
|
||||
|
||||
@@ -75,9 +75,8 @@ internal unsafe static class Win32ApplicationRunner
|
||||
// Set the target window size
|
||||
_ = Windows.AdjustWindowRect((RECT*)&windowRect, Windows.WS_OVERLAPPEDWINDOW, Windows.FALSE);
|
||||
|
||||
uint
|
||||
height = (uint)(windowRect.Bottom - windowRect.Top),
|
||||
width = (uint)(windowRect.Right - windowRect.Left);
|
||||
uint height = (uint)(windowRect.Bottom - windowRect.Top);
|
||||
uint width = (uint)(windowRect.Right - windowRect.Left);
|
||||
|
||||
// Create the window and store a handle to it
|
||||
hwnd = Windows.CreateWindowExW(
|
||||
@@ -117,9 +116,8 @@ internal unsafe static class Win32ApplicationRunner
|
||||
{
|
||||
(Win32Application application, CancellationToken token) = ((Win32Application, CancellationToken))args!;
|
||||
|
||||
Stopwatch
|
||||
startStopwatch = Stopwatch.StartNew(),
|
||||
frameStopwatch = Stopwatch.StartNew();
|
||||
Stopwatch startStopwatch = Stopwatch.StartNew();
|
||||
Stopwatch frameStopwatch = Stopwatch.StartNew();
|
||||
|
||||
const long targetFrameTimeInTicksFor60fps = 166666;
|
||||
|
||||
@@ -251,11 +249,10 @@ internal unsafe static class Win32ApplicationRunner
|
||||
_ = Windows.GetCursorPos(&point);
|
||||
_ = Windows.GetWindowRect(hwnd, &rect);
|
||||
|
||||
bool
|
||||
isAtTop = Math.Abs(point.y - rect.top) < 12,
|
||||
isAtRight = Math.Abs(point.x - rect.right) < 12,
|
||||
isAtBottom = Math.Abs(point.y - rect.bottom) < 12,
|
||||
isAtLeft = Math.Abs(point.x - rect.left) < 12;
|
||||
bool isAtTop = Math.Abs(point.y - rect.top) < 12;
|
||||
bool isAtRight = Math.Abs(point.x - rect.right) < 12;
|
||||
bool isAtBottom = Math.Abs(point.y - rect.bottom) < 12;
|
||||
bool isAtLeft = Math.Abs(point.x - rect.left) < 12;
|
||||
|
||||
if (isAtTop)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,8 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -148,12 +149,14 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
// Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original.
|
||||
private float CalculateAO(in float3 p, in float3 n)
|
||||
{
|
||||
float sca = 2.0f, occ = 0.0f;
|
||||
float sca = 2.0f;
|
||||
float occ = 0.0f;
|
||||
|
||||
for (int i = (int)Hlsl.Min(time, 0f); i < 5; i++)
|
||||
{
|
||||
float hr = (i + 1f) * 0.15f / 5.0f;
|
||||
float d = M(p + n * hr);
|
||||
|
||||
occ += (hr - d) * sca;
|
||||
sca *= 0.7f;
|
||||
|
||||
@@ -179,16 +182,17 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
{
|
||||
int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
|
||||
float2 u = (coords - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
|
||||
float3
|
||||
r = Hlsl.Normalize(new float3(u, 1)),
|
||||
o = new(0, time / 2.0f, -3),
|
||||
l = o + new float3(0.25f, 0.25f, 2.0f);
|
||||
float3 r = Hlsl.Normalize(new float3(u, 1));
|
||||
float3 o = new(0, time / 2.0f, -3);
|
||||
float3 l = o + new float3(0.25f, 0.25f, 2.0f);
|
||||
|
||||
r.YZ = Hlsl.Mul(Rotate2x2(0.15f), r.YZ);
|
||||
r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(time * 3.14159f / 32.0f) / 8.0f), r.XZ);
|
||||
r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(time * 3.14159f / 32.0f) / 8.0f), r.XY);
|
||||
|
||||
float d, t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f, glow = 0;
|
||||
float d;
|
||||
float t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f;
|
||||
float glow = 0;
|
||||
|
||||
for (int i = 0; i < 96; i++)
|
||||
{
|
||||
@@ -201,7 +205,8 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
}
|
||||
|
||||
int gObjID = objID;
|
||||
float3 p = o + r * t, n = Normal(p);
|
||||
float3 p = o + r * t;
|
||||
float3 n = Normal(p);
|
||||
float2 uv = p.XY;
|
||||
float sc = 0.5f;
|
||||
float2 iuv = Hlsl.Floor(uv / sc) + 0.5f;
|
||||
|
||||
@@ -15,7 +15,8 @@ internal readonly partial struct Octagrams : IPixelShader<float4>
|
||||
|
||||
private static float2x2 Rotate(float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, s, -s, c);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ internal readonly partial struct ProteanClouds : IPixelShader<float4>
|
||||
|
||||
private static float2x2 Rotate(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, s, -s, c);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -141,9 +142,8 @@ internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
float2 oP = p;
|
||||
float m = BMap(p);
|
||||
float3 n = new(0, 0, -1);
|
||||
float
|
||||
edge = 0.0f,
|
||||
bumpFactor = 0.25f;
|
||||
float edge = 0.0f;
|
||||
float bumpFactor = 0.25f;
|
||||
|
||||
n = DoBumpMap(p, n, bumpFactor, ref edge);
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -157,12 +158,11 @@ internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
|
||||
p -= s - (s.X + s.Y) * 0.211324865f;
|
||||
|
||||
float i = p.X < p.Y ? 1.0f : 0.0f;
|
||||
float2
|
||||
ioffs = new(1.0f - i, i),
|
||||
ip0 = 0,
|
||||
ip1 = ioffs - 0.2113248654f,
|
||||
ip2 = 0.577350269f,
|
||||
ctr = (ip0 + ip1 + ip2) / 3.0f;
|
||||
float2 ioffs = new(1.0f - i, i);
|
||||
float2 ip0 = 0;
|
||||
float2 ip1 = ioffs - 0.2113248654f;
|
||||
float2 ip2 = 0.577350269f;
|
||||
float2 ctr = (ip0 + ip1 + ip2) / 3.0f;
|
||||
|
||||
ip0 -= ctr;
|
||||
ip1 -= ctr;
|
||||
@@ -175,15 +175,14 @@ internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
|
||||
n3.Y = IsoFunction(s + ioffs);
|
||||
n3.Z = IsoFunction(s + 1.0f);
|
||||
|
||||
float
|
||||
d = 1e5f,
|
||||
d2 = 1e5f,
|
||||
d3 = 1e5f,
|
||||
d4 = 1e5f,
|
||||
d5 = 1e5f;
|
||||
|
||||
float d = 1e5f;
|
||||
float d2 = 1e5f;
|
||||
float d3 = 1e5f;
|
||||
float d4 = 1e5f;
|
||||
float d5 = 1e5f;
|
||||
float isovalue = 0;
|
||||
float2 p0 = default, p1 = default;
|
||||
float2 p0 = default;
|
||||
float2 p1 = default;
|
||||
int iTh = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
|
||||
|
||||
d = Hlsl.Min(d, distEdge(p - p0, p - p1));
|
||||
|
||||
@@ -679,10 +679,9 @@ public sealed partial class IShaderGenerator
|
||||
|
||||
AppendCharacterAndLF('}');
|
||||
|
||||
int
|
||||
constantBuffersCount = 1,
|
||||
readOnlyBuffersCount = 0,
|
||||
readWriteBuffersCount = 0;
|
||||
int constantBuffersCount = 1;
|
||||
int readOnlyBuffersCount = 0;
|
||||
int readWriteBuffersCount = 0;
|
||||
|
||||
// Optional implicit texture field
|
||||
if (!isComputeShader)
|
||||
|
||||
@@ -67,9 +67,8 @@ public sealed partial class IShaderGenerator
|
||||
|
||||
var pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader<byte>) });
|
||||
var isComputeShader = pixelShaderSymbol is null;
|
||||
int
|
||||
resourceOffset = 0,
|
||||
rawDataOffset = sizeof(int) * (isComputeShader ? 3 : 2);
|
||||
int resourceOffset = 0;
|
||||
int rawDataOffset = sizeof(int) * (isComputeShader ? 3 : 2);
|
||||
|
||||
// Append the statements for the dispatch ranges:
|
||||
//
|
||||
@@ -232,9 +231,8 @@ public sealed partial class IShaderGenerator
|
||||
!fieldSymbol.IsConst && !fieldSymbol.IsStatic && !fieldSymbol.IsFixedSizeBuffer
|
||||
select fieldSymbol)
|
||||
{
|
||||
string
|
||||
fieldName = fieldSymbol.Name,
|
||||
typeName = fieldSymbol.Type.GetFullMetadataName();
|
||||
string fieldName = fieldSymbol.Name;
|
||||
string typeName = fieldSymbol.Type.GetFullMetadataName();
|
||||
|
||||
// Disambiguates the name of target fields against the current input parameters
|
||||
if (fieldName is "loader" or "device" or "x" or "y" or "z")
|
||||
@@ -290,9 +288,8 @@ public sealed partial class IShaderGenerator
|
||||
// each row needs to be at a multiple of 16 bytes (a float4 register).
|
||||
if (HlslKnownTypes.IsNonLinearMatrixType(typeName, out string? elementName, out int rows, out int columns))
|
||||
{
|
||||
string
|
||||
rowTypeName = $"global::ComputeSharp.{elementName}{columns}",
|
||||
rowLocalName = $"__{string.Join("_", fieldPath)}__row0";
|
||||
string rowTypeName = $"global::ComputeSharp.{elementName}{columns}";
|
||||
string rowLocalName = $"__{string.Join("_", fieldPath)}__row0";
|
||||
|
||||
statements.Add(ParseStatement($"ref {rowTypeName} {rowLocalName} = ref global::System.Runtime.CompilerServices.Unsafe.As<global::{typeName}, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in {string.Join(".", fieldPath)}));"));
|
||||
|
||||
|
||||
+4
-5
@@ -122,11 +122,10 @@ public sealed partial class IShaderGenerator
|
||||
yield return ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<int>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 0), {root32BitConstantsCount});");
|
||||
yield return ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<bool>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 4), {isSamplerUsed.ToString().ToLowerInvariant()});");
|
||||
|
||||
int
|
||||
constantBufferOffset = 1,
|
||||
readOnlyResourceOffset = 0,
|
||||
readWriteResourceOffset = 0,
|
||||
resourceOffset = 0;
|
||||
int constantBufferOffset = 1;
|
||||
int readOnlyResourceOffset = 0;
|
||||
int readWriteResourceOffset = 0;
|
||||
int resourceOffset = 0;
|
||||
|
||||
// Add the implicit texture descriptor, if needed
|
||||
if (implicitTextureType is not null)
|
||||
|
||||
@@ -56,11 +56,10 @@ public sealed partial class IShaderGenerator : ISourceGenerator
|
||||
private static void OnExecute(GeneratorExecutionContext context, StructDeclarationSyntax structDeclaration, INamedTypeSymbol structDeclarationSymbol)
|
||||
{
|
||||
// Create the required interface methods for the current shader type
|
||||
MethodDeclarationSyntax
|
||||
getDispatchIdMethod = CreateGetDispatchIdMethod(structDeclarationSymbol),
|
||||
loadDispatchDataMethod = CreateLoadDispatchDataMethod(context, structDeclarationSymbol, out var discoveredResources, out int root32BitConstants),
|
||||
buildHlslStringMethod = CreateBuildHlslStringMethod(context, structDeclaration, structDeclarationSymbol, out string? implicitTextureType, out bool isSamplerUsed),
|
||||
loadDispatchMetadataMethod = CreateLoadDispatchMetadataMethod(implicitTextureType, discoveredResources, root32BitConstants, isSamplerUsed);
|
||||
MethodDeclarationSyntax getDispatchIdMethod = CreateGetDispatchIdMethod(structDeclarationSymbol);
|
||||
MethodDeclarationSyntax loadDispatchDataMethod = CreateLoadDispatchDataMethod(context, structDeclarationSymbol, out var discoveredResources, out int root32BitConstants);
|
||||
MethodDeclarationSyntax buildHlslStringMethod = CreateBuildHlslStringMethod(context, structDeclaration, structDeclarationSymbol, out string? implicitTextureType, out bool isSamplerUsed);
|
||||
MethodDeclarationSyntax loadDispatchMetadataMethod = CreateLoadDispatchMetadataMethod(implicitTextureType, discoveredResources, root32BitConstants, isSamplerUsed);
|
||||
|
||||
// Reorder the method declarations to respect the order in the interface definition
|
||||
MethodDeclarationSyntax[] methods =
|
||||
|
||||
@@ -214,9 +214,8 @@ internal static class HlslKnownMembers
|
||||
where Regex.IsMatch(property.Name, "^M[1-4]{2}$")
|
||||
select (Type: type, Property: property))
|
||||
{
|
||||
char
|
||||
row = (char)(item.Property.Name[1] - 1),
|
||||
column = (char)(item.Property.Name[2] - 1);
|
||||
char row = (char)(item.Property.Name[1] - 1);
|
||||
char column = (char)(item.Property.Name[2] - 1);
|
||||
|
||||
knownMembers.Add($"{item.Type.FullName}{Type.Delimiter}{item.Property.Name}", $"_m{row}{column}");
|
||||
}
|
||||
@@ -254,18 +253,16 @@ internal static class HlslKnownMembers
|
||||
break;
|
||||
case string name when name.Length == 2:
|
||||
{
|
||||
string
|
||||
numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])})",
|
||||
denominator = $"float2(__{char.ToLower(name[0])}, __{char.ToLower(name[1])})";
|
||||
string numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])})";
|
||||
string denominator = $"float2(__{char.ToLower(name[0])}, __{char.ToLower(name[1])})";
|
||||
|
||||
knownMembers.Add(key, $"{numerator} / {denominator}");
|
||||
break;
|
||||
}
|
||||
case string name when name.Length == 3:
|
||||
{
|
||||
string
|
||||
numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])}, {typeof(ThreadIds).Name}.{char.ToLower(name[2])})",
|
||||
denominator = $"float3(__{char.ToLower(name[0])}, __{char.ToLower(name[1])}, __{char.ToLower(name[2])})";
|
||||
string numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])}, {typeof(ThreadIds).Name}.{char.ToLower(name[2])})";
|
||||
string denominator = $"float3(__{char.ToLower(name[0])}, __{char.ToLower(name[1])}, __{char.ToLower(name[2])})";
|
||||
|
||||
knownMembers.Add(key, $"{numerator} / {denominator}");
|
||||
break;
|
||||
|
||||
@@ -404,9 +404,8 @@ internal sealed class ShaderSourceRewriter : HlslSourceRewriter
|
||||
if (!this.staticMethods.ContainsKey(method))
|
||||
{
|
||||
ShaderSourceRewriter shaderSourceRewriter = new(SemanticModel, DiscoveredTypes, this.staticMethods, ConstantDefinitions, Context);
|
||||
MethodDeclarationSyntax
|
||||
methodNode = (MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax(),
|
||||
processedMethod = shaderSourceRewriter.Visit(methodNode)!.NormalizeWhitespace(eol: "\n").WithoutTrivia();
|
||||
MethodDeclarationSyntax methodNode = (MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax();
|
||||
MethodDeclarationSyntax processedMethod = shaderSourceRewriter.Visit(methodNode)!.NormalizeWhitespace(eol: "\n").WithoutTrivia();
|
||||
|
||||
this.staticMethods.Add(method, processedMethod.WithIdentifier(Identifier(methodIdentifier)));
|
||||
}
|
||||
|
||||
@@ -322,7 +322,8 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
out ulong totalSizeInBytes)
|
||||
{
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(dxgiFormat, width, height);
|
||||
ulong a, b;
|
||||
ulong a;
|
||||
ulong b;
|
||||
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* p = &d3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
@@ -357,7 +358,8 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
out ulong totalSizeInBytes)
|
||||
{
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(dxgiFormat, width, height, depth);
|
||||
ulong a, b;
|
||||
ulong a;
|
||||
ulong b;
|
||||
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* p = &d3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
|
||||
@@ -40,9 +40,8 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
|
||||
ushort depth)
|
||||
{
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescriptionSource = d3D12ResourceSource->GetDesc();
|
||||
D3D12_TEXTURE_COPY_LOCATION
|
||||
d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, in *d3D12PlacedSubresourceFootprintDestination),
|
||||
d3D12TextureCopyLocationSource = new(d3D12ResourceSource, 0);
|
||||
D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, in *d3D12PlacedSubresourceFootprintDestination);
|
||||
D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationSource = new(d3D12ResourceSource, 0);
|
||||
D3D12_BOX d3D12Box;
|
||||
D3D12_BOX* pD3D12Box;
|
||||
|
||||
@@ -99,9 +98,8 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
|
||||
uint height,
|
||||
ushort depth)
|
||||
{
|
||||
D3D12_TEXTURE_COPY_LOCATION
|
||||
d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, 0),
|
||||
d3D12TextureCopyLocationSource = new(d3D12ResourceSource, in *d3D12PlacedSubresourceFootprintSource);
|
||||
D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, 0);
|
||||
D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationSource = new(d3D12ResourceSource, in *d3D12PlacedSubresourceFootprintSource);
|
||||
D3D12_BOX d3D12Box;
|
||||
D3D12_BOX* pD3D12Box;
|
||||
|
||||
|
||||
@@ -187,9 +187,8 @@ internal static class MemoryHelper
|
||||
{
|
||||
for (int z = 0; z < depth; z++)
|
||||
{
|
||||
ulong
|
||||
sourceZOffset = (uint)z * widthInBytes * height,
|
||||
destinationZOffset = (uint)z * sliceInBytes;
|
||||
ulong sourceZOffset = (uint)z * widthInBytes * height;
|
||||
ulong destinationZOffset = (uint)z * sliceInBytes;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
@@ -231,9 +230,8 @@ internal static class MemoryHelper
|
||||
{
|
||||
for (int z = 0; z < depth; z++)
|
||||
{
|
||||
ulong
|
||||
sourceZOffset = (uint)z * sliceInBytes,
|
||||
destinationZOffset = (uint)z * widthInBytes * height;
|
||||
ulong sourceZOffset = (uint)z * sliceInBytes;
|
||||
ulong destinationZOffset = (uint)z * widthInBytes * height;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
|
||||
@@ -220,14 +220,14 @@ internal sealed unsafe class WICHelper
|
||||
// Get the first frame of the loaded image (if more are present, they will be ignored)
|
||||
wicBitmapDecoder->GetFrame(0, wicBitmapFrameDecode.GetAddressOf()).Assert();
|
||||
|
||||
uint width, height;
|
||||
uint width;
|
||||
uint height;
|
||||
|
||||
// Extract the image size info
|
||||
wicBitmapFrameDecode.Get()->GetSize(&width, &height).Assert();
|
||||
|
||||
Guid
|
||||
wicTargetPixelFormatGuid = WICFormatHelper.GetForType<T>(),
|
||||
wicActualPixelFormatGuid;
|
||||
Guid wicTargetPixelFormatGuid = WICFormatHelper.GetForType<T>();
|
||||
Guid wicActualPixelFormatGuid;
|
||||
|
||||
// Get the current and target pixel format info
|
||||
wicBitmapFrameDecode.Get()->GetPixelFormat(&wicActualPixelFormatGuid).Assert();
|
||||
|
||||
@@ -55,9 +55,8 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
nint
|
||||
byteOffset = (nint)offset * sizeof(T),
|
||||
byteLength = length * sizeof(T);
|
||||
nint byteOffset = (nint)offset * sizeof(T);
|
||||
nint byteLength = length * sizeof(T);
|
||||
|
||||
using UniquePtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(null, ResourceType.ReadBack, AllocationMode.Default, (ulong)byteLength);
|
||||
|
||||
@@ -115,10 +114,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
ulong
|
||||
byteDestinationOffset = (uint)destinationOffset * (uint)sizeof(T),
|
||||
byteOffset = (uint)offset * (uint)sizeof(T),
|
||||
byteLength = (uint)length * (uint)sizeof(T);
|
||||
ulong byteDestinationOffset = (uint)destinationOffset * (uint)sizeof(T);
|
||||
ulong byteOffset = (uint)offset * (uint)sizeof(T);
|
||||
ulong byteLength = (uint)length * (uint)sizeof(T);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
@@ -153,9 +151,8 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
nint
|
||||
byteOffset = (nint)offset * sizeof(T),
|
||||
byteLength = length * sizeof(T);
|
||||
nint byteOffset = (nint)offset * sizeof(T);
|
||||
nint byteLength = length * sizeof(T);
|
||||
|
||||
using UniquePtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(null, ResourceType.Upload, AllocationMode.Default, (ulong)byteLength);
|
||||
|
||||
@@ -211,10 +208,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
ulong
|
||||
byteSourceOffset = (uint)sourceOffset * (uint)sizeof(T),
|
||||
byteOffset = (uint)offset * (uint)sizeof(T),
|
||||
byteLength = (uint)length * (uint)sizeof(T);
|
||||
ulong byteSourceOffset = (uint)sourceOffset * (uint)sizeof(T);
|
||||
ulong byteOffset = (uint)offset * (uint)sizeof(T);
|
||||
ulong byteLength = (uint)length * (uint)sizeof(T);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
|
||||
@@ -41,15 +41,13 @@ internal static class ShaderRunner<T>
|
||||
// number of registers and any amount of thread local storage. We use the wave size of the device in
|
||||
// use for 1D dispatches, otherwise a multiple of 32 that is greater than or equal to 64, which still
|
||||
// results in an evenly divisible number of waves per thread group on all existing GPU devices.
|
||||
bool
|
||||
xIs1 = x == 1,
|
||||
yIs1 = y == 1,
|
||||
zIs1 = z == 1;
|
||||
int
|
||||
mask = *(byte*)&xIs1 << 2 | *(byte*)&yIs1 << 1 | *(byte*)&zIs1,
|
||||
threadsX,
|
||||
threadsY,
|
||||
threadsZ;
|
||||
bool xIs1 = x == 1;
|
||||
bool yIs1 = y == 1;
|
||||
bool zIs1 = z == 1;
|
||||
int mask = *(byte*)&xIs1 << 2 | *(byte*)&yIs1 << 1 | *(byte*)&zIs1;
|
||||
int threadsX;
|
||||
int threadsY;
|
||||
int threadsZ;
|
||||
|
||||
switch (mask - 1)
|
||||
{
|
||||
@@ -116,10 +114,9 @@ internal static class ShaderRunner<T>
|
||||
Guard.IsBetweenOrEqualTo(threadsZ, 1, 64, nameof(threadsZ));
|
||||
Guard.IsLessThanOrEqualTo(threadsX * threadsY * threadsZ, 1024, "threadsXYZ");
|
||||
|
||||
int
|
||||
groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1),
|
||||
groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1),
|
||||
groupsZ = Math.DivRem(z, threadsZ, out int modZ) + (modZ == 0 ? 0 : 1);
|
||||
int groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1);
|
||||
int groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1);
|
||||
int groupsZ = Math.DivRem(z, threadsZ, out int modZ) + (modZ == 0 ? 0 : 1);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(groupsX, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
Guard.IsBetweenOrEqualTo(groupsY, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
@@ -169,13 +166,12 @@ internal static class ShaderRunner<T>
|
||||
{
|
||||
device.ThrowIfDisposed();
|
||||
|
||||
int
|
||||
x = texture.Width,
|
||||
y = texture.Height,
|
||||
threadsX = 8,
|
||||
threadsY = 8,
|
||||
groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1),
|
||||
groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1);
|
||||
int x = texture.Width;
|
||||
int y = texture.Height;
|
||||
int threadsX = 8;
|
||||
int threadsY = 8;
|
||||
int groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1);
|
||||
int groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(groupsX, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
Guard.IsBetweenOrEqualTo(groupsY, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
|
||||
@@ -37,9 +37,8 @@ internal sealed unsafe partial class ShaderCompiler
|
||||
|
||||
if (isNuGetRuntimeLibrariesDirectoryPresent)
|
||||
{
|
||||
string
|
||||
dxcompilerPath = Path.Combine(AppContext.BaseDirectory, $@"runtimes\{rid}\native\dxcompiler.dll"),
|
||||
dxilPath = Path.Combine(AppContext.BaseDirectory, $@"runtimes\{rid}\native\dxil.dll");
|
||||
string dxcompilerPath = Path.Combine(AppContext.BaseDirectory, $@"runtimes\{rid}\native\dxcompiler.dll");
|
||||
string dxilPath = Path.Combine(AppContext.BaseDirectory, $@"runtimes\{rid}\native\dxil.dll");
|
||||
|
||||
// Load DXIL first so that DXC doesn't fail to load it, and then DXIL, both from the NuGet path
|
||||
if (NativeLibrary.TryLoad(dxilPath, out _) &&
|
||||
|
||||
@@ -29,9 +29,8 @@ public partial class ShaderHashCodeTests
|
||||
|
||||
Shader1 shader1 = new() { A = value, B = buffer };
|
||||
|
||||
int
|
||||
hash1 = ((IShader)shader1).GetDispatchId(),
|
||||
hash2 = ((IShader)shader1).GetDispatchId();
|
||||
int hash1 = ((IShader)shader1).GetDispatchId();
|
||||
int hash2 = ((IShader)shader1).GetDispatchId();
|
||||
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
|
||||
@@ -63,9 +62,8 @@ public partial class ShaderHashCodeTests
|
||||
|
||||
Shader2 shader1 = new() { A = 1, B = buffer, F = f };
|
||||
|
||||
int
|
||||
hash1 = ((IShader)shader1).GetDispatchId(),
|
||||
hash2 = ((IShader)shader1).GetDispatchId();
|
||||
int hash1 = ((IShader)shader1).GetDispatchId();
|
||||
int hash2 = ((IShader)shader1).GetDispatchId();
|
||||
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
|
||||
|
||||
@@ -95,9 +95,8 @@ public class AutoConstructorGeneratorTests
|
||||
|
||||
string outputBody = outputCompilation.SyntaxTrees.Skip(index + 1).First().ToString();
|
||||
|
||||
string[]
|
||||
outputLines = outputBody.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
|
||||
expectedLines = expectedBody.Replace("\r", "").Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
string[] outputLines = outputBody.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
string[] expectedLines = expectedBody.Replace("\r", "").Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
|
||||
Assert.AreEqual(expectedLines.Length, outputLines.Length);
|
||||
|
||||
|
||||
@@ -31,9 +31,8 @@ public class ImageProcessingTests
|
||||
using var cpu = original.Clone(c => c.BokehBlur(40, 2, 3));
|
||||
using var gpu = original.Clone(c => c.ApplyProcessor(new HlslBokehBlurProcessor(device.Get(), 40, 2)));
|
||||
|
||||
string
|
||||
expectedPath = Path.Combine(path, "city_bokeh_cpu.jpg"),
|
||||
actualPath = Path.Combine(path, "city_bokeh_gpu.jpg");
|
||||
string expectedPath = Path.Combine(path, "city_bokeh_cpu.jpg");
|
||||
string actualPath = Path.Combine(path, "city_bokeh_gpu.jpg");
|
||||
|
||||
cpu.Save(expectedPath);
|
||||
gpu.Save(actualPath);
|
||||
@@ -56,9 +55,8 @@ public class ImageProcessingTests
|
||||
using var cpu = original.Clone(c => c.GaussianBlur(30f));
|
||||
using var gpu = original.Clone(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(device.Get(), 90)));
|
||||
|
||||
string
|
||||
expectedPath = Path.Combine(path, "city_gaussian_cpu.jpg"),
|
||||
actualPath = Path.Combine(path, "city_gaussian_gpu.jpg");
|
||||
string expectedPath = Path.Combine(path, "city_gaussian_cpu.jpg");
|
||||
string actualPath = Path.Combine(path, "city_gaussian_gpu.jpg");
|
||||
|
||||
cpu.Save(expectedPath);
|
||||
gpu.Save(actualPath);
|
||||
|
||||
@@ -96,10 +96,9 @@ public class ImagingTests
|
||||
[AllDevices]
|
||||
public void SaveRgba32AsJpeg(Device device)
|
||||
{
|
||||
string
|
||||
path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"),
|
||||
expectedPath = Path.Combine(path, "city.jpg"),
|
||||
actualPath = Path.Combine(path, "city_rgba32_saved.jpg");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
|
||||
string expectedPath = Path.Combine(path, "city.jpg");
|
||||
string actualPath = Path.Combine(path, "city_rgba32_saved.jpg");
|
||||
|
||||
using ReadOnlyTexture2D<Rgba32, float4> texture = device.Get().LoadReadOnlyTexture2D<Rgba32, float4>(expectedPath);
|
||||
|
||||
@@ -112,10 +111,9 @@ public class ImagingTests
|
||||
[AllDevices]
|
||||
public void SaveBgra32AsJpeg(Device device)
|
||||
{
|
||||
string
|
||||
path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"),
|
||||
expectedPath = Path.Combine(path, "city.jpg"),
|
||||
actualPath = Path.Combine(path, "city_bgra32_saved.jpg");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
|
||||
string expectedPath = Path.Combine(path, "city.jpg");
|
||||
string actualPath = Path.Combine(path, "city_bgra32_saved.jpg");
|
||||
|
||||
using ReadOnlyTexture2D<Bgra32, float4> texture = device.Get().LoadReadOnlyTexture2D<Bgra32, float4>(expectedPath);
|
||||
|
||||
@@ -128,11 +126,10 @@ public class ImagingTests
|
||||
[AllDevices]
|
||||
public void SaveR8AsJpeg(Device device)
|
||||
{
|
||||
string
|
||||
path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"),
|
||||
sourcePath = Path.Combine(path, "city.jpg"),
|
||||
expectedPath = Path.Combine(path, "city_r8_reference.jpg"),
|
||||
actualPath = Path.Combine(path, "city_r8_saved.jpg");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
|
||||
string sourcePath = Path.Combine(path, "city.jpg");
|
||||
string expectedPath = Path.Combine(path, "city_r8_reference.jpg");
|
||||
string actualPath = Path.Combine(path, "city_r8_saved.jpg");
|
||||
|
||||
using ReadOnlyTexture2D<R8, float> texture = device.Get().LoadReadOnlyTexture2D<R8, float>(sourcePath);
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -153,12 +154,14 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
// Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original.
|
||||
private float CalculateAO(in float3 p, in float3 n)
|
||||
{
|
||||
float sca = 2.0f, occ = 0.0f;
|
||||
float sca = 2.0f;
|
||||
float occ = 0.0f;
|
||||
|
||||
for (int i = (int)Hlsl.Min(time, 0f); i < 5; i++)
|
||||
{
|
||||
float hr = (i + 1f) * 0.15f / 5.0f;
|
||||
float d = M(p + n * hr);
|
||||
|
||||
occ += (hr - d) * sca;
|
||||
sca *= 0.7f;
|
||||
|
||||
@@ -184,16 +187,17 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
{
|
||||
int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
|
||||
float2 u = (coords - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
|
||||
float3
|
||||
r = Hlsl.Normalize(new float3(u, 1)),
|
||||
o = new(0, time / 2.0f, -3),
|
||||
l = o + new float3(0.25f, 0.25f, 2.0f);
|
||||
float3 r = Hlsl.Normalize(new float3(u, 1));
|
||||
float3 o = new(0, time / 2.0f, -3);
|
||||
float3 l = o + new float3(0.25f, 0.25f, 2.0f);
|
||||
|
||||
r.YZ = Hlsl.Mul(Rotate2x2(0.15f), r.YZ);
|
||||
r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(time * 3.14159f / 32.0f) / 8.0f), r.XZ);
|
||||
r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(time * 3.14159f / 32.0f) / 8.0f), r.XY);
|
||||
|
||||
float d, t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f, glow = 0;
|
||||
float d;
|
||||
float t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f;
|
||||
float glow = 0;
|
||||
|
||||
for (int i = 0; i < 96; i++)
|
||||
{
|
||||
@@ -206,7 +210,8 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
}
|
||||
|
||||
int gObjID = objID;
|
||||
float3 p = o + r * t, n = Normal(p);
|
||||
float3 p = o + r * t;
|
||||
float3 n = Normal(p);
|
||||
float2 uv = p.XY;
|
||||
float sc = 0.5f;
|
||||
float2 iuv = Hlsl.Floor(uv / sc) + 0.5f;
|
||||
|
||||
@@ -20,7 +20,8 @@ internal readonly partial struct Octagrams : IComputeShader
|
||||
|
||||
private static float2x2 Rotate(float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, s, -s, c);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ internal readonly partial struct ProteanClouds : IComputeShader
|
||||
|
||||
private static float2x2 Rotate(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, s, -s, c);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ internal readonly partial struct PyramidPattern : IComputeShader
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -146,9 +147,8 @@ internal readonly partial struct PyramidPattern : IComputeShader
|
||||
float2 oP = p;
|
||||
float m = BMap(p);
|
||||
float3 n = new(0, 0, -1);
|
||||
float
|
||||
edge = 0.0f,
|
||||
bumpFactor = 0.25f;
|
||||
float edge = 0.0f;
|
||||
float bumpFactor = 0.25f;
|
||||
|
||||
n = DoBumpMap(p, n, bumpFactor, ref edge);
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
// Standard 2D rotation formula.
|
||||
private static float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
float c = Hlsl.Cos(a);
|
||||
float s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
@@ -162,12 +163,11 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
p -= s - (s.X + s.Y) * 0.211324865f;
|
||||
|
||||
float i = p.X < p.Y ? 1.0f : 0.0f;
|
||||
float2
|
||||
ioffs = new(1.0f - i, i),
|
||||
ip0 = 0,
|
||||
ip1 = ioffs - 0.2113248654f,
|
||||
ip2 = 0.577350269f,
|
||||
ctr = (ip0 + ip1 + ip2) / 3.0f;
|
||||
float2 ioffs = new(1.0f - i, i);
|
||||
float2 ip0 = 0;
|
||||
float2 ip1 = ioffs - 0.2113248654f;
|
||||
float2 ip2 = 0.577350269f;
|
||||
float2 ctr = (ip0 + ip1 + ip2) / 3.0f;
|
||||
|
||||
ip0 -= ctr;
|
||||
ip1 -= ctr;
|
||||
@@ -180,15 +180,14 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
n3.Y = IsoFunction(s + ioffs);
|
||||
n3.Z = IsoFunction(s + 1.0f);
|
||||
|
||||
float
|
||||
d = 1e5f,
|
||||
d2 = 1e5f,
|
||||
d3 = 1e5f,
|
||||
d4 = 1e5f,
|
||||
d5 = 1e5f;
|
||||
|
||||
float d = 1e5f;
|
||||
float d2 = 1e5f;
|
||||
float d3 = 1e5f;
|
||||
float d4 = 1e5f;
|
||||
float d5 = 1e5f;
|
||||
float isovalue = 0;
|
||||
float2 p0 = default, p1 = default;
|
||||
float2 p0 = default;
|
||||
float2 p1 = default;
|
||||
int iTh = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
|
||||
|
||||
d = Hlsl.Min(d, distEdge(p - p0, p - p1));
|
||||
|
||||
@@ -135,9 +135,8 @@ public partial class Texture2DTests
|
||||
|
||||
texture.CopyTo(result, x, y, width, height);
|
||||
|
||||
Span2D<float>
|
||||
expected = new Span2D<float>(array, 64, 64).Slice(y, x, height, width),
|
||||
data = new(result, height, width);
|
||||
Span2D<float> expected = new Span2D<float>(array, 64, 64).Slice(y, x, height, width);
|
||||
Span2D<float> data = new(result, height, width);
|
||||
|
||||
CollectionAssert.AreEqual(expected.ToArray(), data.ToArray());
|
||||
}
|
||||
|
||||
@@ -150,7 +150,9 @@ public partial class Texture3DTests
|
||||
int[,,] array = new int[3, 64, 64];
|
||||
|
||||
foreach (var item in array.AsSpan().Enumerate())
|
||||
{
|
||||
item.Value = item.Index;
|
||||
}
|
||||
|
||||
using Texture3D<int> texture = device.Get().AllocateTexture3D(textureType, array);
|
||||
|
||||
@@ -160,9 +162,8 @@ public partial class Texture3DTests
|
||||
|
||||
for (int k = 0; k < depth; k++)
|
||||
{
|
||||
Span2D<int>
|
||||
source = array.AsSpan2D(z + k).Slice(y, x, height, width),
|
||||
destination = result.AsSpan2D(k);
|
||||
Span2D<int> source = array.AsSpan2D(z + k).Slice(y, x, height, width);
|
||||
Span2D<int> destination = result.AsSpan2D(k);
|
||||
|
||||
CollectionAssert.AreEqual(source.ToArray(), destination.ToArray());
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする