コード例 #1
0
        public ShaderHeader(IGalMemory Memory, long Position)
        {
            uint CommonWord0 = (uint)Memory.ReadInt32(Position + 0);
            uint CommonWord1 = (uint)Memory.ReadInt32(Position + 4);
            uint CommonWord2 = (uint)Memory.ReadInt32(Position + 8);
            uint CommonWord3 = (uint)Memory.ReadInt32(Position + 12);
            uint CommonWord4 = (uint)Memory.ReadInt32(Position + 16);

            SphType         = ReadBits(CommonWord0, 0, 5);
            Version         = ReadBits(CommonWord0, 5, 5);
            ShaderType      = ReadBits(CommonWord0, 10, 4);
            MrtEnable       = ReadBits(CommonWord0, 14, 1) != 0;
            KillsPixels     = ReadBits(CommonWord0, 15, 1) != 0;
            DoesGlobalStore = ReadBits(CommonWord0, 16, 1) != 0;
            SassVersion     = ReadBits(CommonWord0, 17, 4);
            DoesLoadOrStore = ReadBits(CommonWord0, 26, 1) != 0;
            DoesFp64        = ReadBits(CommonWord0, 27, 1) != 0;
            StreamOutMask   = ReadBits(CommonWord0, 28, 4);

            ShaderLocalMemoryLowSize = ReadBits(CommonWord1, 0, 24);
            PerPatchAttributeCount   = ReadBits(CommonWord1, 24, 8);

            ShaderLocalMemoryHighSize = ReadBits(CommonWord2, 0, 24);
            ThreadsPerInputPrimitive  = ReadBits(CommonWord2, 24, 8);

            ShaderLocalMemoryCrsSize = ReadBits(CommonWord3, 0, 24);
            OutputTopology           = ReadBits(CommonWord3, 24, 4);

            MaxOutputVertexCount = ReadBits(CommonWord4, 0, 12);
            StoreReqStart        = ReadBits(CommonWord4, 12, 8);
            StoreReqEnd          = ReadBits(CommonWord4, 24, 8);

            //Type 2 (fragment?) reading
            uint Type2OmapTarget = (uint)Memory.ReadInt32(Position + 72);
            uint Type2Omap       = (uint)Memory.ReadInt32(Position + 76);

            OmapTargets = new OmapTarget[8];

            for (int i = 0; i < OmapTargets.Length; i++)
            {
                int Offset = i * 4;

                OmapTargets[i] = new OmapTarget
                {
                    Red   = ReadBits(Type2OmapTarget, Offset + 0, 1) != 0,
                    Green = ReadBits(Type2OmapTarget, Offset + 1, 1) != 0,
                    Blue  = ReadBits(Type2OmapTarget, Offset + 2, 1) != 0,
                    Alpha = ReadBits(Type2OmapTarget, Offset + 3, 1) != 0
                };
            }

            OmapSampleMask = ReadBits(Type2Omap, 0, 1) != 0;
            OmapDepth      = ReadBits(Type2Omap, 1, 1) != 0;
        }
コード例 #2
0
ファイル: GlslDecompiler.cs プロジェクト: pinguicodes/Ryujinx
        private void PrintMain()
        {
            SB.AppendLine("void main() {");

            foreach (KeyValuePair <int, ShaderDeclInfo> KV in Decl.InAttributes)
            {
                if (!Decl.Attributes.TryGetValue(KV.Key, out ShaderDeclInfo Attr))
                {
                    continue;
                }

                ShaderDeclInfo DeclInfo = KV.Value;

                if (Decl.ShaderType == GalShaderType.Geometry)
                {
                    for (int Vertex = 0; Vertex < MaxVertexInput; Vertex++)
                    {
                        string Dst = Attr.Name + "[" + Vertex + "]";

                        string Src = "block_in[" + Vertex + "]." + DeclInfo.Name;

                        SB.AppendLine(IdentationStr + Dst + " = " + Src + ";");
                    }
                }
                else
                {
                    SB.AppendLine(IdentationStr + Attr.Name + " = " + DeclInfo.Name + ";");
                }
            }

            SB.AppendLine(IdentationStr + "uint pc;");

            if (BlocksB != null)
            {
                PrintProgram(Blocks, GlslDecl.BasicBlockAName);
                PrintProgram(BlocksB, GlslDecl.BasicBlockBName);
            }
            else
            {
                PrintProgram(Blocks, GlslDecl.BasicBlockName);
            }

            if (Decl.ShaderType != GalShaderType.Geometry)
            {
                PrintAttrToOutput();
            }

            if (Decl.ShaderType == GalShaderType.Fragment)
            {
                if (Header.OmapDepth)
                {
                    SB.AppendLine(IdentationStr + "gl_FragDepth = " + GlslDecl.GetGprName(Header.DepthRegister) + ";");
                }

                int GprIndex = 0;

                for (int Attachment = 0; Attachment < 8; Attachment++)
                {
                    string Output = GlslDecl.FragmentOutputName + Attachment;

                    OmapTarget Target = Header.OmapTargets[Attachment];

                    for (int Component = 0; Component < 4; Component++)
                    {
                        if (Target.ComponentEnabled(Component))
                        {
                            SB.AppendLine(IdentationStr + Output + "[" + Component + "] = " + GlslDecl.GetGprName(GprIndex) + ";");

                            GprIndex++;
                        }
                    }
                }
            }

            SB.AppendLine("}");
        }