Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [Core] fix issue with parsing Texture2D [GI]
Browse files Browse the repository at this point in the history
  • Loading branch information
Razmoth committed Sep 19, 2023
1 parent 8b49dd5 commit d594f90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion AssetStudio/Classes/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public class SerializedSubProgram
public UAVParameter[] m_UAVParams;
public SamplerParameter[] m_Samplers;

public static bool HasGlobalLocalKeywordIndices(SerializedType type) => type.Match("E99740711222CD922E9A6F92FF1EB07A") || type.Match("450A058C218DAF000647948F2F59DA6D");
public static bool HasGlobalLocalKeywordIndices(SerializedType type) => type.Match("E99740711222CD922E9A6F92FF1EB07A", "450A058C218DAF000647948F2F59DA6D");
public static bool HasInstancedStructuredBuffers(SerializedType type) => type.Match("E99740711222CD922E9A6F92FF1EB07A");

public SerializedSubProgram(ObjectReader reader)
Expand Down
9 changes: 5 additions & 4 deletions AssetStudio/Classes/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public sealed class Texture2D : Texture
public ResourceReader image_data;
public StreamingInfo m_StreamData;

private static bool HasGNFTexture(ObjectReader reader) => reader.serializedType.Match("1D52BB98AA5F54C67C22C39E8B2E400F");
private static bool HasGNFTexture(SerializedType type) => type.Match("1D52BB98AA5F54C67C22C39E8B2E400F");
private static bool HasExternalMipRelativeOffset(SerializedType type) => type.Match("1D52BB98AA5F54C67C22C39E8B2E400F", "5390A985F58D5524F95DB240E8789704");
public Texture2D(ObjectReader reader) : base(reader)
{
m_Width = reader.ReadInt32();
Expand All @@ -85,7 +86,7 @@ public Texture2D(ObjectReader reader) : base(reader)
if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up
{
var m_IsReadable = reader.ReadBoolean();
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
if (reader.Game.Type.IsGI() && HasGNFTexture(reader.serializedType))
{
var m_IsGNFTexture = reader.ReadBoolean();
}
Expand All @@ -110,7 +111,7 @@ public Texture2D(ObjectReader reader) : base(reader)
var m_StreamingMipmaps = reader.ReadBoolean();
}
reader.AlignStream();
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
if (reader.Game.Type.IsGI() && HasGNFTexture(reader.serializedType))
{
var m_TextureGroup = reader.ReadInt32();
}
Expand All @@ -137,7 +138,7 @@ public Texture2D(ObjectReader reader) : base(reader)
var image_data_size = reader.ReadInt32();
if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up
{
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
if (reader.Game.Type.IsGI() && HasExternalMipRelativeOffset(reader.serializedType))
{
var m_externalMipRelativeOffset = reader.ReadUInt32();
}
Expand Down
2 changes: 1 addition & 1 deletion AssetStudio/SerializedType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SerializedType
public string m_NameSpace;
public string m_AsmName;

public bool Match(string hash) => Convert.ToHexString(m_OldTypeHash) == hash;
public bool Match(params string[] hashes) => hashes.Any(x => x == Convert.ToHexString(m_OldTypeHash));
public override string ToString()
{
var sb = new StringBuilder();
Expand Down

0 comments on commit d594f90

Please sign in to comment.