Jump to content
  • Advertisement
Sign in to follow this  
dmtuan

[SharpDX] Load precompiled shaders into Windows Store App

This topic is 1163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, could someone please help me with this little problem..

 

I used fxc.exe to precompile my vertex shader and pixel shader. I now have VS.fxo and PS.fxo files, that I need to load into my Windows Store Application. 

 

Normaly, if we were in Desktop App, we would use

ShaderBytecode s = ShaderBytecode.FromFile("VS.fxo");

But since we are in Windows Store App, we do not have ShaderBytecode.FromFile() method available. We can only use Shaderbytecode.FromStream(System.IO.Stream stream). But that's a problem, because we cannot use FileStream object in Windows Store App. How do I load the precompiled shaders into my app then? :/

Share this post


Link to post
Share on other sites
Advertisement

Do you have any sort of file system?  I am still using the effect framework, and it has a nice constructor for Effect (Device, byteCode[]) that works if you can manually load it from storage somehow.  I'm not familiar with windows store restrictions.

 

In my stuff on PC I compile from file, then take the compilation result and save it out to a file myself.  Then later load that up and pass it into effect.

Share this post


Link to post
Share on other sites


Hi, could someone please help me with this little problem..

 

I used fxc.exe to precompile my vertex shader and pixel shader. I now have VS.fxo and PS.fxo files, that I need to load into my Windows Store Application. 

 

Normaly, if we were in Desktop App, we would use

ShaderBytecode s = ShaderBytecode.FromFile("VS.fxo");

But since we are in Windows Store App, we do not have ShaderBytecode.FromFile() method available. We can only use Shaderbytecode.FromStream(System.IO.Stream stream). But that's a problem, because we cannot use FileStream object in Windows Store App. How do I load the precompiled shaders into my app then? :/

Surely there must be some way to get a file read from the disk into a stream of bytes, right?

 

If you can get the URI of the file, this might work:

Uri uri = new Uri("IDon'tKnowWhatever");
var stream = System.Windows.Application.GetResourceStream(uri).Stream;
var shaderByteCode = ShaderBytecode.FromStream(stream);
Utilities.Dispose(ref stream);

Share this post


Link to post
Share on other sites


If you can get the URI of the file, this might work:
Uri uri = new Uri("IDon'tKnowWhatever");
var stream = System.Windows.Application.GetResourceStream(uri).Stream;
var shaderByteCode = ShaderBytecode.FromStream(stream);
Utilities.Dispose(ref stream);

 

Thank you, I will try this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!