# [SlimDX/C#] Effect.FromMemory fails with FXO files

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

## Recommended Posts

Hello all, I am working in C# and DirectX 9 via SlimDX. I have the following:
            string[] effectPath = EffectPaths;
for (int i = 0; i < effectPath.Length; i++)
{
if (System.IO.File.Exists(effectPath))
{
string errorList;
MyEffects = Effect.FromMemory(D3DDev, effectdata, null, null, null, ShaderFlags.None, MyEffectPool, out errorList);
numEffects++;
}
}

My effects are .FXO files compiled with fxc.exe under VS and PS 2.0. Effect.FromMemory fails with D3DXERR_INVALIDDATA: Invalid data (-2005529767) ...this has been puzzling me and I haven't been able to find anything on it. Is it obvious what I'm doing wrong? Much obliged, Steve.

##### Share on other sites
Are you compiling SlimDX from source, or using the March release? Also, what compile options are you using for fxc?

##### Share on other sites

I am using a SlimDX DLL you built me. Remember? In Pierce at lunch, sometime in mid/late-April (I think it was the day before our second differential equations test). So I'm newer than March 2009. I feel superior to all other SlimDX users because of this, but my enlarged ego does not help Effect.FromMemory work as I require it to.

As for fxc, here are the lines I use to compile each half of my effect (vertex and pixel shader):

fxc /E vs_main /T vs_2_0 /Fo fixedfunc_vs.fxo fixedfunc.fxfxc /E ps_main /T ps_2_0 /Fo fixedfunc_ps.fxo fixedfunc.fx

Thanks again for any help.

##### Share on other sites
Apologies for the double-post, but I found something from a while ago that might be interesting to us:

http://www.gamedev.net/community/forums/topic.asp?topic_id=519022

While my first error is (I believe) related to Effect.FromMemory, that topic's first post describes another SlimDX issue I am having.

Here's a complete list of errors I'm getting:

1. FromMemory/no effect pool/.FXO compiled shader:
- D3DXERR_INVALIDDATA

2. FromFile/no effect pool/.FXO compiled shader:
- D3DXERR_INVALIDDATA

3. Either of the two cases above, WITH effect pool:
- D3DXERR_INVALIDDATA

4. FromFile/effect pool/.FX text (uncompiled)
- E_FAIL (the problem described in the link above)

5. FromFile/no effect pool/.FX text (uncompiled)
- works. But it's slow (takes ~5 seconds for the effect to compile on my 2.66GHz Core 2 Duo...that's annoying).

So the findings would indicate:

1. There's a problem with my .FXO files, maybe? What should my compile options be if those are no good?

2. There's a problem with the effect pool, possibly a problem in SlimDX, as I'm having the exact problem the first poster is having in the link I gave above. I use
EffectPool myEffectPool = new EffectPool()
before I call the function. There's not really much else I could be doing wrong, I think.

##### Share on other sites
Just a word on my "progress":

I fixed the EffectPool errors I was getting: I was declaring EffectPool like so:
EffectPool myEffectPool = new EffectPool();

when actually you shouldn't do that--i.e., it needs to be left as:
EffectPool myEffectPool;

Of course then you get an annoying warning that it will always have its default value of null, so what I do is
 EffectPool myEffectPool = new EffectPool(); ...myEffectPool.Dispose();myEffectPool = null;myEffect = Effect.FromFile(D3DDev, Path, null, null, null, ShaderFlags.None, myEffectPool);

So it has to be null going into .FromFile() (contrary to what I saw on another thread)--I actually stumbled on fact that by mistake. But I don't like the warning so I mess with it. At least I know it's not a problem with SlimDX.

With respect to the other half of this effects bonanza, I still think I must be .FXO'ing my stuff wrong. I still get D3DXERR_INVALIDDATA when I try to create an effect from a precompiled FXO file.

Since I'm doubting myself all over now, what exactly is the way one compiles a shader offline as an FXO using fxc? More specifically:

-- Can I put the vertex and pixel shaders in one file with a .FXO using fxc.exe? How?
-- What switches am I supposed to be setting in fxc to get a created effect identical to the one that I get from the JIT effect compiler I use when I give .FromFile a .fx file (I'm using vertex and pixel shader 2.0)?

##### Share on other sites
Well, figured it out thanks to help from big Mike.Popoloski.

I should be using fx_2_0 and not compiling the vertex/pixel shaders separately. Hope this helps someone in the future.

-- Steve.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632654
• Total Posts
3007669
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!