mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-30 10:52:55 +08:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
|
using SharpDX.D3DCompiler;
|
|||
|
using System;
|
|||
|
|
|||
|
namespace CodeWalker.GameFiles
|
|||
|
{
|
|||
|
|
|||
|
public static class FxcParser
|
|||
|
{
|
|||
|
|
|||
|
public static bool ParseShader(FxcShader shader)
|
|||
|
{
|
|||
|
ShaderBytecode ByteCodeObj;
|
|||
|
ShaderProfile ShaderProfile;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
ByteCodeObj = new ShaderBytecode(shader.ByteCode);
|
|||
|
|
|||
|
ShaderProfile = ByteCodeObj.GetVersion();
|
|||
|
|
|||
|
|
|||
|
switch (ShaderProfile.Version)
|
|||
|
{
|
|||
|
case ShaderVersion.VertexShader:
|
|||
|
case ShaderVersion.PixelShader:
|
|||
|
case ShaderVersion.GeometryShader:
|
|||
|
//VersionMajor = br.ReadByte();//4,5 //appears to be shader model version
|
|||
|
//VersionMinor = br.ReadByte(); //perhaps shader minor version
|
|||
|
break;
|
|||
|
default:
|
|||
|
shader.VersionMajor = (byte)ShaderProfile.Major;
|
|||
|
shader.VersionMinor = (byte)ShaderProfile.Minor;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
shader.Disassembly = ByteCodeObj.Disassemble();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
shader.LastError += ex.ToString() + "\r\n";
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|