icculus / mojoshader

Use Direct3D shaders with other 3D rendering APIs.
https://icculus.org/mojoshader/
zlib License
122 stars 36 forks source link

ps_3_0 shader parsing failed #54

Open Joschuka opened 2 years ago

Joschuka commented 2 years ago

Samples : Samples.zip

Code to reproduce the error :

        std::ifstream shaderInFile("TestFpo2.shd", std::ios::in);
    if (!shaderInFile.is_open())
    {
        std::cout << "Couldn't open shader file" << std::endl;
        system("pause");
        return 0;
    }

    shaderInFile.seekg(0, std::ios::end);
    size_t fileSize = shaderInFile.tellg();
    std::vector<char> data;
    data.resize(fileSize);
    shaderInFile.seekg(0, std::ios::beg);
    shaderInFile.read(&data[0], fileSize);

    const MOJOSHADER_parseData *test = MOJOSHADER_parse(MOJOSHADER_PROFILE_HLSL, "ShaderMain", (uint8_t*)data.data(), fileSize, nullptr, 0, nullptr, 0, 0, 0, 0);
    std::ofstream outFile("out.txt", std::ios::out);
    outFile.write(test->output, test->output_len);

    return 0;

TestFpo.shd gives the following errors : TestFpo

TestFpo2.sh gives these : TestFpo2 shd

The first file can be parsed with both the cmdDecompiler from 3DMigoto and SlimDX while the second can only be parsed by SlimDX. The expected disasm can be found for both of them in the enclosed folder.

icculus commented 2 years ago

These files both parse fine, at least on Linux, using both the HLSL and d3d profiles.

I sync'd to a random commit in 2019, too, and they worked then as well, so it doesn't appear to be something that was fixed since this was reported.

Unless building with Visual Studio breaks this in some way, I think we can close this.