Skip to main content
GameDev.net gamedev.net
🔒 Locked

[SlimDX] Effect.FromFile() doesn't give compilation errors

Started by Gage64 Sep 23, 2009 at 10:10 AM 2 replies 1.9k views
Original Post
Gage64
Gage64
It seems that the overload of Effect.FromFile() that's supposed to give a string containing effect compilation errors never fills that string. This is how I call the function:

string errors;
effect = Effect.FromFile(device, "perPixel.fx", null, null, null,
                         ShaderFlags.Debug, null, out errors);

When I use a working effect file, it works fine. When I use an effect file that contains any kind of error (syntactic or semantic), it throws an exception saying "An undetermined error occurred". The 'errors' string is always "". I have tried this with several effect files, and with several types of errors, and it's always the same thing. I'm using the March 2009 version of SlimDX, and, in case it matters, the August 2008 version of the DirectX SDK. Any idea what might be causing this?
jpetrie
jpetrie
Quote:

When I use an effect file that contains any kind of error (syntactic or semantic), it throws an exception saying "An undetermined error occurred". The 'errors' string is always "".

Emphasis mine. Since you have it configured to throw on error (the default), the function never returns, and thus the out parameter is never filled. Examine the exception's Data field (which is a dictionary), one of the keys contains the error string. Alternatively, use the Configuration static class to disable exceptions of this type.
Gage64
Gage64
Thanks, that fixed it. I was sure I tried using the Configuration class to disable exceptions, but looks like I was wrong.

Quote:
Original post by jpetrie
Examine the exception's Data field (which is a dictionary), one of the keys contains the error string.


That works as well, but it seems a little unintuitive. Wouldn't it be better if the exception's message contained the error string instead of the cryptic "An undetermined error occurred"?
jpetrie
jpetrie
Our exception architecture and semantics cannot support that. Making the changes to allow it would render that option outmoded as we could then have a specific exception subclass for 'compile error' that included the errors as a first-class property. The Data dictionary is a standard (although admittedly little-known) means of piggybacking domain-specific information like this, even if it does suck from a usability perspective.

Improving the quality of the shader compilation error system is something that's on our radar for our next ("2.0"-ish) release.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.