icculus / mojoshader

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

MOJOSHADER_parse not support XNA Format ByteCode #57

Closed sunwanxin213 closed 2 years ago

sunwanxin213 commented 2 years ago

like MOJOSHADER_compileEffect , support XNA Effect ByteCode.

flibitijibibo commented 2 years ago

Already done - if you decompress the XNB and pass what's left it is expected to work, as it does in FNA:

https://github.com/FNA-XNA/FNA/tree/master/src/Graphics/Effect

https://github.com/FNA-XNA/FNA3D

sunwanxin213 commented 2 years ago

I see that FNA3D uses MOJOSHADER_compileEffect to process effect code data. But don't see the procedure calling MOJOSHADER_parse . So I want to know if the MOJOSHADER_parse function can support processing XNA bytecode. thanks~

flibitijibibo commented 2 years ago

There is MOJOSHADER_parseEffect which should do what you want - it's the effects equivalent of parse() for standalone shaders.

sunwanxin213 commented 2 years ago

I noticed that MOJOSHADER_parseEffect has been renamed to MOJOSHADER_compileEffect, but it still leaves a comment indicating that it used to be MOJOSHADER_parseEffect. By communicating with you, I already know the problem, thank you very much for your reply!

sunwanxin213 commented 2 years ago

After I tried it, I found that it didn't work well in WebAssembly, and I can use MOJOSHADER_parseEffect after going back to the version 2 years ago. The screenshot is as follows, I hope to consider restoring this usage in the future. Picture

flibitijibibo commented 2 years ago

Right, forgot I redid that export... like the log says, it's been a couple years 😅

You can cheat by using an effectShaderContext that doesn't do any compilation work, and instead just reads and parses what you need - though this looks very XNA-like, so I wonder if FNA's experimental wasm target could be of interest?

sunwanxin213 commented 2 years ago

I will try FNA to wasm.(>^ω^<)

flibitijibibo commented 2 years ago

Current guide (I think): https://gist.github.com/TheSpydog/e94c8c23c01615a5a3b2cc1a0857415c