internal void UpdateVersion(DebugShaderVersion version)
        {
            if (Reader == null)
            {
                return;
            }
            Reader.ReadUInt32("Unknown");
            switch (version.ProgramType)
            {
            case ProgramType.VertexShader:
                Info = DebugVSInfo.Parse(Reader);
                break;

            case ProgramType.HullShader:
                Info = DebugHSInfo.Parse(Reader);
                break;

            case ProgramType.DomainShader:
                Info = DebugDSInfo.Parse(Reader);
                break;

            case ProgramType.GeometryShader:
                Info = DebugGSInfo.Parse(Reader);
                break;

            case ProgramType.PixelShader:
                Info = DebugPSInfo.Parse(Reader);
                break;

            default:
                Reader.ReadBytes("Unknown", 32);
                break;
            }
            if (Info != null && Info.StructSize < DebugValidationInfo.UnionSize)
            {
                Reader.ReadBytes("Padding", DebugValidationInfo.UnionSize - Info.StructSize);
            }
            MinimumExpectedWaveLaneCount = Reader.ReadUInt32("MinimumExpectedWaveLaneCount");
            MaximumExpectedWaveLaneCount = Reader.ReadUInt32("MaximumExpectedWaveLaneCount");
            if (ChunkSize > 20)
            {
                Reader.ReadEnum8 <PSVShaderKind>("ShaderStage");
                UsesViewID                  = Reader.ReadByte("UsesViewID");
                GSMaxVertexCount            = Reader.ReadByte("MaxVertexCount");
                SigInputElements            = Reader.ReadByte("SigInputElements");
                SigOutputElements           = Reader.ReadByte("SigOutputElements");
                SigPatchConstOrPrimElements = Reader.ReadByte("SigPatchConstOrPrimElements");
                SigInputVectors             = Reader.ReadByte("SigInputVectors");
                SigOutputVectors            = Reader.ReadBytes("SigOutputVectors", 4);
            }
            Reader = null;
        }
        public static DebugConstantBufferMapping Parse(DebugBytecodeReader reader)
        {
            var result = new DebugConstantBufferMapping();

            result.Buffer    = reader.ReadUInt16("Buffer");
            result.StartReg  = reader.ReadUInt16("StartReg");
            result.RegCount  = reader.ReadUInt16("RegCount");
            result.TargetReg = reader.ReadUInt16("TargetReg");
            for (int i = 0; i < 4; i++)
            {
                var type = reader.ReadEnum8 <DataConversionType>("DataConversionType");
                result.DataConversion[i] = type;
            }
            return(result);
        }
Esempio n. 3
0
        public static DebugSignatureParameterDescription Parse(DebugBytecodeReader reader, DebugBytecodeReader parameterReader,
                                                               ChunkType chunkType, SignatureElementSize size, ProgramType programType)
        {
            uint stream = 0;

            if (size == SignatureElementSize._7 || size == SignatureElementSize._8)
            {
                stream = parameterReader.ReadUInt32("Stream");
            }
            uint nameOffset = parameterReader.ReadUInt32("NameOffset");
            var  nameReader = reader.CopyAtOffset("NameReader", parameterReader, (int)nameOffset);

            var result = new DebugSignatureParameterDescription
            {
                SemanticName    = nameReader.ReadString("SemanticName"),
                SemanticIndex   = parameterReader.ReadUInt32("SemanticIndex"),
                SystemValueType = parameterReader.ReadEnum32 <Name>("SystemValueType"),
                ComponentType   = parameterReader.ReadEnum32 <RegisterComponentType>("ComponentType"),
                Register        = parameterReader.ReadUInt32("Register"),
                Stream          = stream,
            };

            result.Mask          = parameterReader.ReadEnum8 <ComponentMask>("Mask");
            result.ReadWriteMask = parameterReader.ReadEnum8 <ComponentMask>("ReadWriteMask");
            parameterReader.ReadUInt16("MaskPadding");

            if (size == SignatureElementSize._8)
            {
                MinPrecision minPrecision = parameterReader.ReadEnum32 <MinPrecision>("MinPrecision");
                result.MinPrecision = minPrecision;
            }

            // This is my guesswork, but it works so far...
            if (chunkType == ChunkType.Osg5 ||
                chunkType == ChunkType.Osgn ||
                chunkType == ChunkType.Osg1 ||
                (chunkType == ChunkType.Pcsg && programType == ProgramType.HullShader))
            {
                result.ReadWriteMask = (ComponentMask)(ComponentMask.All - result.ReadWriteMask);
            }

            // Vertex and pixel shaders need special handling for SystemValueType in the output signature.
            if ((programType == ProgramType.PixelShader || programType == ProgramType.VertexShader) &&
                (chunkType == ChunkType.Osg5 || chunkType == ChunkType.Osgn || chunkType == ChunkType.Osg1))
            {
                if (result.Register == 0xffffffff)
                {
                    switch (result.SemanticName.ToUpper())
                    {
                    case "SV_DEPTH":
                        result.SystemValueType = Name.Depth;
                        break;

                    case "SV_COVERAGE":
                        result.SystemValueType = Name.Coverage;
                        break;

                    case "SV_DEPTHGREATEREQUAL":
                        result.SystemValueType = Name.DepthGreaterEqual;
                        break;

                    case "SV_DEPTHLESSEQUAL":
                        result.SystemValueType = Name.DepthLessEqual;
                        break;

                    case "SV_STENCILREF":
                        result.SystemValueType = Name.StencilRef;
                        break;
                    }
                }
                else if (programType == ProgramType.PixelShader)
                {
                    result.SystemValueType = Name.Target;
                }
            }

            return(result);
        }