CreateInputLayout crashes only outside VS

Started by
0 comments, last by LMedina 14 years, 2 months ago
Hello everyone, This problem is driving me nuts. I was porting a simple OBJ mesh loader from Direct3D 9 (no shaders) to Direct3D 10. When it runs inside the debugger, everything is fine, albeit taking more than it should to load. It also won't step into the call when I try figure out where it might go wrong... I assume this is expected? Is this particular call's source closed? What I did was basically copy and paste most of the SDK's tutorial about lighting, changing what was necessary, encapsulating what made sense with my classes, etc. Here's the fragment where it happens:

  /* Create the effect */
  DWORD shader_flags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
/* Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
   Setting this flag improves the shader debugging experience, but still allows 
   the shaders to be optimized and to run exactly the way they will run in 
   the release configuration of this program. */
  shader_flags |= D3D10_SHADER_DEBUG;
#endif
  hr = D3DX10CreateEffectFromFile ("Tutorial06.fx",
                                   NULL, NULL,
                                   "fx_4_0",
                                   shader_flags,
                                   0,
                                   d3ddev,
                                   NULL, NULL,
                                   &effect,
                                   NULL, NULL);
  if (FAILED (hr)) {
    printf ("Tutorial06.fx not found.\n");
    return hr;
    getchar ();
  }

  /* obtain the techniques */
  technique_render       = effect->GetTechniqueByName ("render");
  technique_render_light = effect->GetTechniqueByName ("render_light");

  /* obtain the variables */
  world_variable         = effect->GetVariableByName ("world_matrix")->AsMatrix();
  view_variable          = effect->GetVariableByName ("view_matrix")->AsMatrix();
  projection_variable    = effect->GetVariableByName ("projection_matrix")->AsMatrix();
  light_dir_variable     = effect->GetVariableByName ("light_dir")->AsVector();
  light_color_variable   = effect->GetVariableByName ("light_color")->AsVector();
  output_color_variable  = effect->GetVariableByName ("output_color")->AsVector();

  /* define the input layout */
  D3D10_INPUT_ELEMENT_DESC layout[] = {
    {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
    {"NORMAL",   0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
  };
  UINT num_elements = sizeof (layout) / sizeof (layout[0]);

  /* create the input layout */
  D3D10_PASS_DESC pass_desc;
  technique_render->GetPassByIndex (0)->GetDesc (&pass_desc);

  /* Using printf, I noticed it works up to here. This next call crashes. */

  hr = d3ddev->CreateInputLayout (layout,
                                  num_elements,
                                  pass_desc.pIAInputSignature,
                                  pass_desc.IAInputSignatureSize,
                                  &vertex_layout);
  if (FAILED (hr))
    return hr;

  /* Set the input layout */
  d3ddev->IASetInputLayout (vertex_layout);

  return init_graphics ();



Can anyone help me with some clues as to what might have gone wrong? :) [Edited by - LMedina on February 21, 2010 1:54:15 AM]
Advertisement
OOps, problem solved. Turns out I had a copy of the shader file with the variables under a different name in the Debug folder... it called the correct one in the project folder when I ran it through Visual Studio, but the wrong one from the command line.

Sorry for the bother :)

This topic is closed to new replies.

Advertisement