[SharpDX] Load precompiled shaders into Windows Store App

Started by
2 comments, last by dmtuan 9 years ago

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? :/

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.



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);


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.

This topic is closed to new replies.

Advertisement