Jump to content
  • Advertisement
Sign in to follow this  
Diltsman

D3DX10CompileFromMemory Usage

This topic is 3635 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

I'm trying to compile a vertex shader that I have in memory as a std::string. My code to compile the shader is:
if(FAILED(hr = D3DX10CompileFromMemory(
        Point::sm_vertexShader.c_str(), Point::sm_vertexShader.size(),
        NULL, NULL, NULL, "VS", "vs_4_0", NULL, NULL, NULL, &shader, NULL, NULL)))
{
    ...
}
When I run this I get E_FAIL as a result. I would use D3DX10CompileShaderFromMemory, but it is marked as deprecated. I'm pretty certain I'm not passing everything in to the shader correctly, but I'm not certain what I'm missing. I would really appreciate it if someone could help me figure out what I'm doing wrong here.

Share this post


Link to post
Share on other sites
Advertisement
According to the docs, the third parameter is not optional:
Quote:
pFileName
[in] The name of the file that contains the shader code.


Also, you can try turning on the debug runtimes, which you tell you exactly why the function failed.

Share this post


Link to post
Share on other sites
Since the third parameter is a file name, and the shader is just a C++ string, what should I put there? Can it be a garbage value?

Share this post


Link to post
Share on other sites
Probably. I'm not actually sure what it's supposed to do - perhaps DX10 needs it internally for something (#include's, maybe). In any case, a garbage value would probably do just fine.

Share this post


Link to post
Share on other sites
So, I feel kind of silly. Turns out that there is a D3D10CompileShader function that isn't deprecated. I used that, did a bit of fixing on my shader (not completely certain what the issue was, but there was one), and now it compiles correctly.

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.

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!