mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Some formatting and naming changes, splitting files and some minor improvements.
This commit is contained in:
parent
1e471551d4
commit
a2b62a8b6a
13 changed files with 928 additions and 997 deletions
|
|
@ -8,21 +8,19 @@ public partial class ShpkFile
|
|||
public byte[] Write()
|
||||
{
|
||||
if (SubViewKeys.Length != 2)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
using var stream = new MemoryStream();
|
||||
using var blobs = new MemoryStream();
|
||||
var strings = new StringPool(ReadOnlySpan<byte>.Empty);
|
||||
using var stream = new MemoryStream();
|
||||
using var blobs = new MemoryStream();
|
||||
var strings = new StringPool(ReadOnlySpan<byte>.Empty);
|
||||
using (var w = new BinaryWriter(stream))
|
||||
{
|
||||
w.Write(ShPkMagic);
|
||||
w.Write(Version);
|
||||
w.Write(DirectXVersion switch
|
||||
{
|
||||
DXVersion.DirectX9 => DX9Magic,
|
||||
DXVersion.DirectX11 => DX11Magic,
|
||||
DxVersion.DirectX9 => Dx9Magic,
|
||||
DxVersion.DirectX11 => Dx11Magic,
|
||||
_ => throw new NotImplementedException(),
|
||||
});
|
||||
var offsetsPosition = stream.Position;
|
||||
|
|
@ -35,7 +33,7 @@ public partial class ShpkFile
|
|||
w.Write((uint)MaterialParams.Length);
|
||||
w.Write((uint)Constants.Length);
|
||||
w.Write((uint)Samplers.Length);
|
||||
w.Write((uint)UAVs.Length);
|
||||
w.Write((uint)Uavs.Length);
|
||||
w.Write((uint)SystemKeys.Length);
|
||||
w.Write((uint)SceneKeys.Length);
|
||||
w.Write((uint)MaterialKeys.Length);
|
||||
|
|
@ -43,7 +41,7 @@ public partial class ShpkFile
|
|||
w.Write((uint)Items.Length);
|
||||
|
||||
WriteShaderArray(w, VertexShaders, blobs, strings);
|
||||
WriteShaderArray(w, PixelShaders, blobs, strings);
|
||||
WriteShaderArray(w, PixelShaders, blobs, strings);
|
||||
|
||||
foreach (var materialParam in MaterialParams)
|
||||
{
|
||||
|
|
@ -53,54 +51,50 @@ public partial class ShpkFile
|
|||
}
|
||||
|
||||
WriteResourceArray(w, Constants, strings);
|
||||
WriteResourceArray(w, Samplers, strings);
|
||||
WriteResourceArray(w, UAVs, strings);
|
||||
WriteResourceArray(w, Samplers, strings);
|
||||
WriteResourceArray(w, Uavs, strings);
|
||||
|
||||
foreach (var key in SystemKeys)
|
||||
{
|
||||
w.Write(key.Id);
|
||||
w.Write(key.DefaultValue);
|
||||
}
|
||||
|
||||
foreach (var key in SceneKeys)
|
||||
{
|
||||
w.Write(key.Id);
|
||||
w.Write(key.DefaultValue);
|
||||
}
|
||||
|
||||
foreach (var key in MaterialKeys)
|
||||
{
|
||||
w.Write(key.Id);
|
||||
w.Write(key.DefaultValue);
|
||||
}
|
||||
|
||||
foreach (var key in SubViewKeys)
|
||||
{
|
||||
w.Write(key.DefaultValue);
|
||||
}
|
||||
|
||||
foreach (var node in Nodes)
|
||||
{
|
||||
if (node.PassIndices.Length != 16 || node.SystemKeys.Length != SystemKeys.Length || node.SceneKeys.Length != SceneKeys.Length || node.MaterialKeys.Length != MaterialKeys.Length || node.SubViewKeys.Length != SubViewKeys.Length)
|
||||
{
|
||||
if (node.PassIndices.Length != 16
|
||||
|| node.SystemKeys.Length != SystemKeys.Length
|
||||
|| node.SceneKeys.Length != SceneKeys.Length
|
||||
|| node.MaterialKeys.Length != MaterialKeys.Length
|
||||
|| node.SubViewKeys.Length != SubViewKeys.Length)
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
w.Write(node.Id);
|
||||
w.Write(node.Passes.Length);
|
||||
w.Write(node.PassIndices);
|
||||
foreach (var key in node.SystemKeys)
|
||||
{
|
||||
w.Write(key);
|
||||
}
|
||||
foreach (var key in node.SceneKeys)
|
||||
{
|
||||
w.Write(key);
|
||||
}
|
||||
foreach (var key in node.MaterialKeys)
|
||||
{
|
||||
w.Write(key);
|
||||
}
|
||||
foreach (var key in node.SubViewKeys)
|
||||
{
|
||||
w.Write(key);
|
||||
}
|
||||
foreach (var pass in node.Passes)
|
||||
{
|
||||
w.Write(pass.Id);
|
||||
|
|
@ -160,21 +154,12 @@ public partial class ShpkFile
|
|||
w.Write(blobSize);
|
||||
w.Write((ushort)shader.Constants.Length);
|
||||
w.Write((ushort)shader.Samplers.Length);
|
||||
w.Write((ushort)shader.UAVs.Length);
|
||||
w.Write((ushort)shader.Uavs.Length);
|
||||
w.Write((ushort)0);
|
||||
|
||||
WriteResourceArray(w, shader.Constants, strings);
|
||||
WriteResourceArray(w, shader.Samplers, strings);
|
||||
WriteResourceArray(w, shader.UAVs, strings);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteUInt32PairArray(BinaryWriter w, (uint, uint)[] array)
|
||||
{
|
||||
foreach (var (first, second) in array)
|
||||
{
|
||||
w.Write(first);
|
||||
w.Write(second);
|
||||
WriteResourceArray(w, shader.Samplers, strings);
|
||||
WriteResourceArray(w, shader.Uavs, strings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue