• Advertisement
Sign in to follow this  

DX11 D3DCompileFromFile

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

Hello!

 

I am stuck on tutorial 4 on this website: http://www.braynzarsoft.net/index.php?p=D3D11BD#still

 

Theese two lines are messing everything up for me:

hResult = D3DCompileFromFile(L"C:\\Users\\Dawood\\Documents\\Visual Studio 2013\\Projects\\Direct3D\\Direct3D\\Effects.fx", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, NULL, "vs_5_0", 0, 0, &VS_Buffer, NULL);

hResult = D3DCompileFromFile(L"C:\\Users\\Dawood\\Documents\\Visual Studio 2013\\Projects\\Direct3D\\Direct3D\\Effects.fx", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, NULL, "ps_5_0", 0, 0, &PS_Buffer, NULL);

I am not using the exact same code as he is using so please notice that. I have included my Effects.fx file in the project and also placed it where my .cpp and .h files are located for the project. I have also changed the properties->HLSL Compiler->General and there I changed the "shader type" to Effect (/fx) and the "shader model" to Shader Model 5 (/5_0)

 

I can't understand why this isn't working. The issue is that our VS_Buffer and PS_Buffer is still pointing to NULL after this line of code is done and the result of hResult is some weird numbers like "0x8876086c" and not "S_OK"

 

He has written the following lines just to save you some time in your search but I am not using that stuff since msdn doesn't recommend it anymore.

hr = D3DX11CompileFromFile(L"Effects.fx", 0, 0, "VS", "vs_4_0", 0, 0, 0, &VS_Buffer, 0, 0);
hr = D3DX11CompileFromFile(L"Effects.fx", 0, 0, "PS", "ps_4_0", 0, 0, 0, &PS_Buffer, 0, 0);

I have already tried changing the vs_5_0 to vs_4_0 but that is not the issue here.

 

Regards!

 
Edited by dawoodr

Share this post


Link to post
Share on other sites
Advertisement

the result of hResult is some weird numbers like "0x8876086c"

 

That's called an error code. 0x8876086c is the informative error "Invalid Call."

 

So.. you need to check each parameter for validity.

 

Do you have debug output enabled? You should be able to get more informative info from that. Or, add the error msgs blob parameter and get the error description from that.

 

- Is the file path correct?

- If you have "#include some-file" in your shader file, can they be found?

- Are VS_ and PS_BUFFER ID3DBlob* objects? I know, if they aren't, it shouldn't compile.

- Have you tried specifying the entry points explicitly?

- Try setting the shader flags to D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG.

 


I changed ... the "shader model" to Shader Model 5 (/5_0)

 

Is that supported? Do you have code in the fx file that needs 5_0? [shrug]

Edited by Buckeye

Share this post


Link to post
Share on other sites

http://msdn.microsoft.com/en-us/library/windows/desktop/hh446872%28v=vs.85%29.aspx

 

The last parameter is an ID3DBlob that will receive error messages that occur during the compilation.  Instead of setting it to NULL, I recommend that you actually use it; you can then use it's GetBufferPointer member to access those error messages and find out what went wrong.  Cast it to the appropriate char * or string type and print them, or whatever; e.g:

 

if (pErrorBlob) {OutputDebugString ((LPCTSTR) pErrorBlob->GetBufferPointer ()); pErrorBlob->Release ();}

Share this post


Link to post
Share on other sites

Ok, I created on ID3DBlob* pErrorBlob, I assume that was what you wanted me to do and just placed it instead of NULL.
The pErrorBlob showed the following message: + 0x01485510 <Information not available, no symbols loaded for D3DCompiler_47.dll> ID3D10Blob *

 

Also what do you mean by this "- Have you tried specifying the entry points explicitly?" I am a beginner so I don't know what you mean really

Share this post


Link to post
Share on other sites

I don't know how much this will help but perhaps It will so I am just pasting this

'Direct3D.exe' (Win32): Loaded 'C:\Users\Dawood\Documents\Visual Studio 2013\Projects\Direct3D\Debug\Direct3D.exe'. Symbols loaded.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Program Files (x86)\Norton Internet Security\NortonData\21.0.0.100\Definitions\BASHDefs\20140912.003\UMEngx86.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\D3DCompiler_47.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptsp.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvinit.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\advapi32.dll'
'Direct3D.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\nvinit.dll'
The thread 0xf3c has exited with code 0 (0x0).
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igd10iumd32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ncrypt.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntasn1.dll'. Cannot find or open the PDB file.
'Direct3D.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file.

Share this post


Link to post
Share on other sites

Perhaps this can help
 

- &VS_Buffer 0x00e2bee0 {0x00000000 <NULL>} ID3D10Blob * *
    - 0x00000000 <NULL> ID3D10Blob *
        - IUnknown <struct at NULL> IUnknown
            __vfptr <Unable to read memory> void * *
 
 

Share this post


Link to post
Share on other sites

First: It appears the code you're working with is for Direct3D 11, and you're using ID3D10Blob. If so, use ID3DBlob.

 

You should have something like:

// ID3DBlob VS_BUFFER; // NO! VS_BUFFER must be a pointer to a blob.
ID3DBlob *VS_BUFFER = NULL;
ID3DBlob *errMsg = NULL;
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG;

hr = D3DCompileFromFile( filename, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "your-entry-point", "vs_4_0", dwShaderFlags, NULL, &VS_BUFFER, &errMsg );
if( FAILED(hr) )
{
   if( NULL != errMsg )
   {
      OutputErrorMessage( (char*)errMsg->GetBufferPointer() );
      errMsg->Release();
      return some-error;
   }
   // .. output the error condition for the user
   ReportErrorCondition(hr);
}
if( NULL != errMsg ) errMsg->Release(); // ensure cleanup 
Edited by Buckeye

Share this post


Link to post
Share on other sites

That parameter is the entry point for the vertex shader in your shader file.

 

If, for instance, your shader file has:

PS_INPUT MyVertexShader( VS_INPUT input )
{
   ...

then that parameter would be "MyVertexShader" - i.e., D3DCompileFromFile(..., "MyVertexShader", "vs_4_0", ...)

Share this post


Link to post
Share on other sites

Hmm, I think that was it, now it is atleast working, however nothing is being drawn :(

Thanks alot for the help!

Share this post


Link to post
Share on other sites

its the function that the HLSL shader will use to set as the function to execute when you call this shader. Its the same as the main function in a C/C++ application and you need to provide this so that the HLSL compiler and runtime know where to start from.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Fleshbits
      Back around 2006 I spent a good year or two reading books, articles on this site, and gobbling up everything game dev related I could. I started an engine in DX10 and got through basics. I eventually gave up, because I couldn't do the harder things.
      Now, my C++ is 12 years stronger, my mind is trained better, and I am thinking of giving it another go.
      Alot has changed. There is no more SDK, there is evidently a DX Toolkit, XNA died, all the sweet sites I used to go to are 404, and google searches all point to Unity and Unreal.
      I plainly don't like Unity or Unreal, but might learn them for reference.
      So, what is the current path? Does everyone pretty much use the DX Toolkit? Should I start there? I also read that DX12 is just expert level DX11, so I guess I am going DX 11.
      Is there a current and up to date list of learning resources anywhere?  I am about tired of 404s..
       
       
    • By Stewie.G
      Hi,
       
      I've been trying to implement a basic gaussian blur using the gaussian formula, and here is what it looks like so far:
      float gaussian(float x, float sigma)
      {
          float pi = 3.14159;
          float sigma_square = sigma * sigma;
          float a = 1 / sqrt(2 * pi*sigma_square);
          float b = exp(-((x*x) / (2 * sigma_square)));
          return a * b;
      }
      My problem is that I don't quite know what sigma should be.
      It seems that if I provide a random value for sigma, weights in my kernel won't add up to 1.
      So I ended up calling my gaussian function with sigma == 1, which gives me weights adding up to 1, but also a very subtle blur.
      Here is what my kernel looks like with sigma == 1
              [0]    0.0033238872995488885    
              [1]    0.023804742479357766    
              [2]    0.09713820127276819    
              [3]    0.22585307043511713    
              [4]    0.29920669915475656    
              [5]    0.22585307043511713    
              [6]    0.09713820127276819    
              [7]    0.023804742479357766    
              [8]    0.0033238872995488885    
       
      I would have liked it to be more "rounded" at the top, or a better spread instead of wasting [0], [1], [2] with values bellow 0.1.
      Based on my experiments, the key to this is to provide a different sigma, but if I do, my kernel values no longer adds up to 1, which results to a darker blur.
      I've found this post 
      ... which helped me a bit, but I am really confused with this the part where he divide sigma by 3.
      Can someone please explain how sigma works? How is it related to my kernel size, how can I balance my weights with different sigmas, ect...
       
      Thanks :-)
    • By mc_wiggly_fingers
      Is it possible to asynchronously create a Texture2D using DirectX11?
      I have a native Unity plugin that downloads 8K textures from a server and displays them to the user for a VR application. This works well, but there's a large frame drop when calling CreateTexture2D. To remedy this, I've tried creating a separate thread that creates the texture, but the frame drop is still present.
      Is there anything else that I could do to prevent that frame drop from occuring?
    • By cambalinho
      i'm trying draw a circule using math:
      class coordenates { public: coordenates(float x=0, float y=0) { X = x; Y = y; } float X; float Y; }; coordenates RotationPoints(coordenates ActualPosition, double angle) { coordenates NewPosition; NewPosition.X = ActualPosition.X*sin(angle) - ActualPosition.Y*sin(angle); NewPosition.Y = ActualPosition.Y*cos(angle) + ActualPosition.X*cos(angle); return NewPosition; } but now i know that these have 1 problem, because i don't use the orign.
      even so i'm getting problems on how i can rotate the point.
      these coordinates works between -1 and 1 floating points.
      can anyone advice more for i create the circule?
    • By isu diss
      I managed convert opengl code on http://john-chapman-graphics.blogspot.co.uk/2013/02/pseudo-lens-flare.html to hlsl, but unfortunately I don't know how to add it to my atmospheric scattering code (Sky - first image). Can anyone help me?
      I tried to bind the sky texture as SRV and implement lens flare code in pixel shader, I don't know how to separate them (second image)


  • Advertisement