예제 #1
0
파일: fxdis.cpp 프로젝트: RobinWuDev/Qt
int main(int argc, char** argv)
{
    if(argc < 2)
    {
        usage();
        return 1;
    }

    std::vector<char> data;
    std::ifstream in(argv[1]);
    char c;
    in >> std::noskipws;
    while(in >> c)
        data.push_back(c);
    in.close();

    dxbc_container* dxbc = dxbc_parse(&data[0], data.size());
    if(dxbc)
    {
        std::cout << *dxbc;
        dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(&data[0], data.size());
        if(sm4_chunk)
        {
            sm4_program* sm4 = sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size));
            if(sm4)
            {
                std::cout << *sm4;
                delete sm4;
            }
        }
        delete dxbc;
    }
}
예제 #2
0
int main(int argc, char** argv)
{
    if(argc < 2)
    {
        usage();
        return EXIT_FAILURE;
    }

    std::vector<char> data;
    FILE *pFile = NULL;
#ifdef _MSC_VER
    fopen_s(&pFile, argv[1], "rb" );
#else
    pFile = fopen(argv[1], "rb" );
#endif
    if ( !pFile )
    {
       printf("Could not open file: %s\n", pFile );
       return EXIT_FAILURE;
    }

    fseek(pFile, 0, SEEK_END);
    uint32_t nFileSize = ftell(pFile);
    fseek(pFile, 0, SEEK_SET);

    if (nFileSize < sizeof(dxbc_container_header))
    {
      printf("File is too small!\n");
      return EXIT_FAILURE;
    }

    data.resize(nFileSize);
    if (fread(&data[0], 1, nFileSize, pFile) != nFileSize)
    {
       printf("Failed reading file!\n");
       return EXIT_FAILURE;
    }
    fclose(pFile);

    dxbc_container* dxbc = dxbc_parse(&data[0], data.size());
    if(dxbc)
    {
        std::cout << *dxbc;
        dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(&data[0], data.size());
        if(sm4_chunk)
        {
            sm4_program* sm4 = sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size));
            if(sm4)
            {
                std::cout << *sm4;
                delete sm4;
            }
        }
        delete dxbc;
    }

    return EXIT_SUCCESS;
}