private static DrawEventVertexData[] MapVertexShaderData(
            IEnumerable <Number4> data,
            InputOutputSignatureChunk signature)
        {
            return(data.Select((datum, i) =>
            {
                var parameter = signature.Parameters[i];

                var value = string.Empty;
                if (parameter.Mask.HasFlag(ComponentMask.X))
                {
                    value += "x=" + datum.X + ", ";
                }
                if (parameter.Mask.HasFlag(ComponentMask.Y))
                {
                    value += "y=" + datum.Y + ", ";
                }
                if (parameter.Mask.HasFlag(ComponentMask.Z))
                {
                    value += "z=" + datum.Z + ", ";
                }
                if (parameter.Mask.HasFlag(ComponentMask.W))
                {
                    value += "w=" + datum.W + ", ";
                }
                value = value.TrimEnd(' ', ',');
                return new DrawEventVertexData
                {
                    Semantic = parameter.SemanticName,
                    Value = value
                };
            }).ToArray());
        }
        public static BytecodeChunk ParseChunk(BytecodeReader chunkReader, BytecodeContainer container)
        {
            // Type of chunk this is.
            uint fourCc = chunkReader.ReadUInt32();

            // Total length of the chunk in bytes.
            uint chunkSize = chunkReader.ReadUInt32();

            ChunkType chunkType;

            if (KnownChunkTypes.ContainsKey(fourCc))
            {
                chunkType = KnownChunkTypes[fourCc];
            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Chunk type '" + fourCc.ToFourCcString() + "' is not yet supported.");
                System.Diagnostics.Debug.WriteLine("Chunk type '" + fourCc.ToFourCcString() + "' is not yet supported.");
                return(null);
            }

            var           chunkContentReader = chunkReader.CopyAtCurrentPosition((int)chunkSize);
            BytecodeChunk chunk;

            switch (chunkType)
            {
            case ChunkType.Ifce:
                chunk = InterfacesChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Isgn:
            case ChunkType.Osgn:
            case ChunkType.Osg5:
            case ChunkType.Pcsg:
            case ChunkType.Isg1:
            case ChunkType.Osg1:
                chunk = InputOutputSignatureChunk.Parse(chunkContentReader, chunkType,
                                                        container.Version.ProgramType);
                break;

            case ChunkType.Rdef:
                chunk = ResourceDefinitionChunk.Parse(chunkContentReader);
                break;

            case ChunkType.Sdbg:
            case ChunkType.Spdb:
                chunk = DebuggingChunk.Parse(chunkContentReader, chunkType, chunkSize);
                break;

            case ChunkType.Sfi0:
                chunk = Sfi0Chunk.Parse(chunkContentReader, container.Version, chunkSize);
                break;

            case ChunkType.Shdr:
            case ChunkType.Shex:
                chunk = ShaderProgramChunk.Parse(chunkContentReader);
                break;

            case ChunkType.Stat:
                chunk = StatisticsChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Xnas:
            case ChunkType.Xnap:
            case ChunkType.Aon9:
                chunk = Level9ShaderChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Priv:
                chunk = PrivateChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Rts0:
                chunk = RootSignatureChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Libf:
                chunk = LibfChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Libh:
                chunk = LibHeaderChunk.Parse(chunkContentReader, chunkSize);
                break;

            case ChunkType.Lfs0:
                chunk = LibraryParameterSignatureChunk.Parse(chunkContentReader, chunkSize);
                break;

            default:
                throw new ParseException("Invalid chunk type: " + chunkType);
            }

            chunk.Container = container;
            chunk.FourCc    = fourCc;
            chunk.ChunkSize = chunkSize;
            chunk.ChunkType = chunkType;

            return(chunk);
        }
Exemple #3
0
 public IrSignature(InputOutputSignatureChunk chunk, string name, IrSignatureType signatureType)
 {
     Name          = name;
     Chunk         = chunk;
     SignatureType = signatureType;
 }