コード例 #1
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Property = loader.ReadUInt32();
            uint Size = loader.ReadUInt32();

            BufferOffset = loader.ReadUInt64();
            Reserved     = loader.ReadBytes(16);
        }
コード例 #2
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            uint size = loader.ReadUInt32();

            DecompressedSize = loader.ReadUInt32();
            ulong codePointer = loader.ReadUInt64();

            loader.Seek((int)codePointer, System.IO.SeekOrigin.Begin);
            CompressedData = loader.ReadBytes((int)size);
        }
コード例 #3
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            loader.Seek(8); //always empty
            ulong[] codeOffsets = loader.ReadUInt64s(2);
            uint[]  codeSizes   = loader.ReadUInt32s(2);
            loader.Seek(32); //padding

            BinaryData = new List <byte[]>();
            for (int i = 0; i < 2; i++) //Fixed with 2 binaries
            {
                loader.Seek((long)codeOffsets[i], System.IO.SeekOrigin.Begin);
                if (i == 0)
                {
                    BinaryData.Add(loader.ReadBytes((int)codeSizes[1]));
                }
                else
                {
                    BinaryData.Add(loader.ReadBytes((int)codeSizes[0]));
                }
            }
        }
コード例 #4
0
        void IResData.Load(BfshaFileLoader loader)
        {
            ShaderInfoData = loader.LoadSection <ShaderInfoData>();
            uint memorySize = loader.ReadUInt32();

            loader.ReadUInt32(); //padding
            //Stores a bunch of 0s
            MemoryData = loader.LoadCustom(() => loader.ReadBytes((int)memorySize));
            loader.ReadUInt64(); //offset to parent shader variation
            ShaderReflection = loader.Load <ShaderReflection>();
            loader.Seek(32);     //reserved
        }
コード例 #5
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            ushort codeLength = loader.ReadUInt16();

            loader.Seek(6);
            uint[]  codeSizes   = loader.LoadCustom(() => loader.ReadUInt32s(codeLength));
            ulong[] codeOffsets = loader.LoadCustom(() => loader.ReadUInt64s(codeLength));
            loader.Seek(8); //reserved

            SourceData = new List <byte[]>();
            for (int i = 0; i < codeLength; i++)
            {
                loader.Seek((long)codeOffsets[i], System.IO.SeekOrigin.Begin);
                SourceData.Add(loader.ReadBytes((int)codeSizes[i]));
            }
        }
コード例 #6
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            uint dataPointer = loader.ReadUInt32();
            uint size        = loader.ReadUInt32();
            uint handle      = loader.ReadUInt32();

            Stride = loader.ReadUInt16();
            ushort numBuffering   = loader.ReadUInt16();
            uint   contextPointer = loader.ReadUInt32();

            Data = loader.LoadCustom(() =>
            {
                byte[][] data = new byte[numBuffering][];
                for (int i = 0; i < numBuffering; i++)
                {
                    data[i] = loader.ReadBytes((int)size);
                }
                return(data);
            });
        }
コード例 #7
0
        void IResData.Load(BfshaFileLoader loader)
        {
            Name = loader.LoadString();
            long staticOptionArrayOffset = loader.ReadOffset();

            StaticOptionDict = loader.LoadDict();
            long dynamicOptionArrayOffset = loader.ReadOffset();

            DynamiOptionDict = loader.LoadDict();
            long attribArrayOffset = loader.ReadOffset();

            AttributeDict = loader.LoadDict();
            long samplerArrayOffset = loader.ReadOffset();

            SamplersDict = loader.LoadDict();

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                loader.ReadInt64();
                loader.ReadInt64();
            }

            long uniformBlockArrayOffset = loader.ReadOffset();

            UniformBlockDict = loader.LoadDict();
            long uniformArrayOffset = loader.ReadOffset();

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                loader.ReadInt64();
                loader.ReadInt64();
                loader.ReadInt64();
            }

            long shaderProgramArrayOffset = loader.ReadOffset();
            long tableOffset         = loader.ReadOffset();
            long shaderArchiveOffset = loader.ReadOffset();
            long shaderInfoOffset    = loader.ReadOffset();
            long shaderFileOffset    = loader.ReadOffset();

            loader.ReadUInt64();

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                //padding
                loader.ReadInt64();
                loader.ReadInt64();
            }

            loader.ReadUInt64();
            loader.ReadUInt64();

            uint uniformCount = loader.ReadUInt32();

            if (loader.BfshaFile.VersionMinor <= 7)
            {
                loader.ReadUInt32();
            }
            int    defaultProgramIndex = loader.ReadInt32();
            ushort staticOptionCount   = loader.ReadUInt16();
            ushort dynamicOptionCount  = loader.ReadUInt16();
            ushort shaderProgramCount  = loader.ReadUInt16();
            byte   staticKeyLength     = loader.ReadByte();
            byte   dynamicKeyLength    = loader.ReadByte();
            byte   attribCount         = loader.ReadByte();
            byte   samplerCount        = loader.ReadByte();

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                byte imageCount = loader.ReadByte();
            }

            byte uniformBlockCount = loader.ReadByte();

            loader.ReadBytes(5);

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                loader.ReadBytes(6);
            }

            System.Console.WriteLine($"shaderFileOffset " + shaderFileOffset);
            System.Console.WriteLine($"Sampler " + samplerCount);
            System.Console.WriteLine($"attribCount " + attribCount);
            System.Console.WriteLine($"dynamicOptionCount " + dynamicOptionCount);
            System.Console.WriteLine($"staticOptionArrayOffset " + staticOptionArrayOffset);
            System.Console.WriteLine($"staticOptionCount " + staticOptionCount);

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                loader.ReadBytes(7);
            }
            if (loader.BfshaFile.VersionMinor < 7)
            {
                loader.ReadBytes(4);
            }

            System.Console.WriteLine($"end pos " + loader.Position);

            int BnshSize = 0;

            if (shaderFileOffset != 0)
            {
                //Go into the bnsh file and get the file size
                using (loader.TemporarySeek(shaderFileOffset + 0x1C, System.IO.SeekOrigin.Begin))
                {
                    BnshSize = (int)loader.ReadUInt32();
                }
            }

            byte[] BinaryShaderData = loader.LoadCustom(() => loader.ReadBytes(BnshSize), shaderFileOffset);
            BnshFile = new BnshFile(new System.IO.MemoryStream(BinaryShaderData));

            StaticOptions = loader.LoadList <ShaderOption>(staticOptionCount, staticOptionArrayOffset);
            DynamiOptions = loader.LoadList <ShaderOption>(dynamicOptionCount, dynamicOptionArrayOffset);
            Attributes    = loader.LoadList <Attribute>(attribCount, attribArrayOffset);
            Samplers      = loader.LoadList <Sampler>(samplerCount, samplerArrayOffset);
            UniformBlocks = loader.LoadList <UniformBlock>(uniformBlockCount, uniformBlockArrayOffset);
            UniformVars   = loader.LoadList <UniformVar>((int)uniformCount, uniformArrayOffset);
        }