Jump to content
  • Advertisement
Sign in to follow this  
brekehan

D3DX10CreateEffectFromFile - Get Error Msg

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

How do I get the error message from D3DX10CreateEffectFromFile? I tired using the blob. It has an address after I call D3D10CreateBlob, but comes back NULL after the call to D3DX10CreateEffectFromFile. Yet, the creation fails.
   LPD3D10BLOB blob = NULL;
   D3D10CreateBlob(512, &blob);

   if( FAILED(D3DX10CreateEffectFromFile(filePath.c_str(),
                                         NULL,
                                         NULL,
                                         "fx_4_0",
                                         effectFlags,
                                         D3D10_EFFECT_COMPILE_CHILD_EFFECT,
                                         &m_device,
                                         &effectPool,
                                         NULL,
                                         &m_effect,
                                         &blob,
                                         NULL)) )
   {
      char * compileErrors = static_cast<char *>(blob->GetBufferPointer());
      
      std::stringstream msg;
      msg << "Could not compile effect file: " << filePath << " ";
      msg << compileErrors;

      exception.m_msg  = msg.str();
      
      blob->Release();
      throw exception;
   }

Share this post


Link to post
Share on other sites
Advertisement
My guess is the file isn't being found. You can use DXGetErrorString() and DXGetErrorDescription to figure out what's going on. You just feed them your HRESULT and they return the error code and a description:
HRESULT hr = D3DX10CreateEffectFromFile(...);
...
const WCHAR* errorString = DXGetErrorString(hr);

Share this post


Link to post
Share on other sites
Quote:
Original post by Ariste
My guess is the file isn't being found. You can use DXGetErrorString() and DXGetErrorDescription to figure out what's going on. You just feed them your HRESULT and they return the error code and a description:
HRESULT hr = D3DX10CreateEffectFromFile(...);
...
const WCHAR* errorString = DXGetErrorString(hr);



DXGetErrorString is returning "E_FAIL"
DxGetErrorDescription is returning "An undefined error has occured"
Not a very descriptive error message!


Path is correct. It succeeded until I added some stuff to the file. It also compiles offline which is strange. I debug and check the full path and it is correct and hasn't changed since it was working...

Share this post


Link to post
Share on other sites
I know what code I changed in the effect files. Maybe someone can tell me if what I did was illegal. It's very strange that it still compiles in offline mode though.

I tried to add default states to the effect pool.

Here is my effect pool file:


//--------------------------------------------------------------------------------------
// File: EffectPool.fx
//
// Contains shared effect variables and functions that remain the same every frame
// for all effects.
//--------------------------------------------------------------------------------------

shared cbuffer Matrices
{
matrix view : View;
matrix projection : Projection;
};

shared cbuffer Lights
{
struct AmbientLight
{
float intensity;
float4 color;
};

struct DirectionalLight
{
bool enabled;
float3 direction;
float4 color;
};

AmbientLight ambientLight;
DirectionalLight directionalLights[8];
};

BlendState DefaultBlending
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = FALSE;
BlendEnable[1] = FALSE;
BlendEnable[2] = FALSE;
BlendEnable[3] = FALSE;
BlendEnable[4] = FALSE;
BlendEnable[5] = FALSE;
BlendEnable[6] = FALSE;
BlendEnable[7] = FALSE;
SrcBlend = One;
DestBlend = One;
BlendOp = Add;
SrcBlendAlpha = One;
DestBlendAlpha = Zero;
BlendOpAlpha = Add;
RenderTargetWriteMask[0] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[1] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[2] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[3] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[4] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[5] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[6] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[7] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
};

DepthStencilState DefaultDepthStencil
{
DepthEnable = TRUE;
DepthWriteMask = All;
DepthFunc = Less;
StencilEnable = FALSE;
StencilReadMask = 0xFF; // DEFAULT_STENCIL_READ_MASK
StencilWriteMask = 0xFF; // DEFAULT_STENCIL_WRITE_MASK
FrontFaceStencilFail = Keep;
FrontFaceStencilDepthFail = Keep;
FrontFaceStencilPass = Keep;
FrontFaceStencilFunc = Always;
BackFaceStencilFail = Keep;
BackFaceStencilDepthFail = Keep;
BackFaceStencilPass = Keep;
BackFaceStencilFunc = Always;
};



The states at the bottom are what I added. Before I added them the application worked. After I added them, effects that are a child of this pool will not compile in the application, but do compile offline.

Share this post


Link to post
Share on other sites
I added "shared" to the default states in the effect pool and it works fine now. Still would be good to know how to use the Blob interface to get error messages. It exists after all.

Share this post


Link to post
Share on other sites
Not sure why yours doesn't work, but here's what I use:

ID3D10Blob* compErrors = NULL;
HRESULT hr;

hr = D3D10CreateEffectFromFile(...); // use &compErrors

if (FAILED(hr))
{
if (compErrors)
{
MessageBoxA(0, (char*)compErrors->GetBufferPointer(), 0, 0);
}
}

Share this post


Link to post
Share on other sites
Quote:
Original post by Ariste
Not sure why yours doesn't work, but here's what I use:

ID3D10Blob* compErrors = NULL;
HRESULT hr;

hr = D3D10CreateEffectFromFile(...); // use &compErrors

if (FAILED(hr))
{
if (compErrors)
{
MessageBoxA(0, (char*)compErrors->GetBufferPointer(), 0, 0);
}
}


I got it now. Copied your code in.

It would seem the error of declaring states in an effect pool without the shared keyword is something DirectX doens't know how to report. I tried again while making a more obvious error and the blob came back with contents. I just have to check for a NULL blob and report "unknown error" for that case I guess.

Thanks!

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!