Jump to content
  • Advertisement

Compiling HLSL to ASM? And inserting ASM into HLSL?

Recommended Posts

Hi, I'm just a self-taught amateur exploring HLSL (among other things).  I'm using MikuMikuDance to render my models and effects.  It's closed source but free, based on DX9 (so shader model 3.0).

One of my problems with this renderer is that effects are always compiled at run time.  This is handy for debugging, of course.  But when I get something finished, load times can be irritating.  I very much appreciate the intelligence of the compiler in terms of optimization, but loading times are the price to be paid for that.  Since I usually attach shaders to models that I make for public use (public domain to the extent made possible by any other sources I might use), shader load times can limit my audience.

I believe that if I could insert assembly into my .fx files, that I could bypass most of the compiler's thought processes.  In order to do that, I'd need to know how to output my HLSL to ASM (I can't write ASM and have a lot of other priorities) and how to replace my HLSL with the outputted ASM.

Maybe that's bad thinking?  Like I said, I'm just a beginner, trying to work within the limits of my knowledge and my environment.  Always happy to hear if I'm pursuing something unwise.

But otherwise, this strikes me as something that is probably possible, and that would probably help load times quite a bit.  Any help or advice?  Wasn't able to refine my Googling enough to get anything useful.


Share this post

Link to post
Share on other sites

Thanks, that might be a start.  I'll try to figure out what I can get out of fxc.


Just to be clear about my limits, my "development environment" is Notepad++ and I don't have any access to C code from the renderer.  I believe that the renderer will only load uncompiled HLSL files (typically with the .fx extension) rather than compiled shaders.

Share this post

Link to post
Share on other sites

You can't insert inline assembly into HLSL. The only way to avoid compiling at runtime is to pre-compile offline (or cache compiler outputs at runtime), and create your shaders from the pre-compiled binary data. If you can't modify the code that loads the shaders, then your only options are to somehow patch the executable or DLL, or create a shim DLL that intercepts the call to compile the shader and does something else.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!