Search code examples
c++visual-studio-2015windows-7-x64directx-11build-error

Compiling DirectX11 Shader Files


I am currently following the DirectX 11 tutorial from www.rastertek.com in the 2nd series of tutorials. I'm currently using VS2015 on a Windows7 x64. Following this tutorial has me using the Windows 10 kit.

I've successfully completed the first 3 tutorials and was able to render a colored window using DirectX 11. I've just completed tutorial 4 to render a colored triangle using the HLSL with a vertex & pixel shaders. I'm following this tutorial where both the vertex and pixel shaders are in separate files the only difference in my code is the file extension that I'm using. His website uses *.vs and *.ps respectively where I'm using *.vsh and *.psh since this gives me code highlighting. All of my class files compile correctly but when I begin to build out my solution I am getting this error.

1>------ Build started: Project: DirectX 11 Engine, Configuration: Debug x64 ------
1>FXC : error X3501: 'main': entrypoint not found
1>
1>  compilation failed; no code produced
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The creator of this website does not have any contact information or community based forums. I do not know if this is an error within the website's tutorial or not. Now I know that this code has worked before using older versions of VS such as 2010, 2012 and 2013 on both Windows Vista and Windows 7 using both Windows 7 & Windows 8 kits from his first series of DirectX 10 & DirectX 11 tutorials. I wasn't able to find any help from www.msdn.com since some of their tutorials are written with the requirement of Windows 8 for DirectX 11 using VS2013. Their documentation is quite poor too.

One of the things that I have noticed that is different within DirectX 11 from the Windows Kit versus the deprecated June 2010 Direct X SDK release when Compiling a Shader file is as follows:

June 2010 Direct X SDK - Uses:

HRESULT result;

result = D3DX11CompileFromFile( "shaderFilename", NULL, NULL, "ShaderName", "*s_5_0" or "*s_5_1", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pShaderBuffer, &pErrorMessage, NULL );

Versus...

This tutorial (Windows 10 kit from VS2015) - Uses:

HRESULT result;
result = D3DCompileFromFile( "shaderFilename", NULL, NULL, "ShaderName", "*s_5_0" or "*s_5_1", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pShaderBuffer, &pErrorMessage );

Where the shader filename, shader name, feature level, and the shader buffer is either a Vertex or Pixel Shader Type. And the feature level being used in both these cases is "5_0" and not "5_1" even though I have specified both feature levels.

I'm not sure what has changed between the different compilers for DirectX's HLSL, and I don't understand where or why this error is being generated from. I do not know if the Shader Source code from the website's tutorial is missing something, or if there is some kind of property or setting in VS2015 not set right that I'm unaware of. I am open for any and all suggestions to help resolve this issue.


Solution

  • After I have submitted this question; I happened to stumble onto this question FXC : error X3501: 'main': entrypoint not found and from some of the comments and answers there. I simply ended up right clicking on the "color.psh" and "color.vsh" files and under their properties:

    • Configuration Properties -> General -> Excluded From Build section I set the flag to "Yes"
      • HLSL Compiler -> General -> Shader Type section I set the Shader Type respectively for Pixel & Vertex Shader For Each File.
      • HLSL Compiler -> General -> Shader Model section I set to Shader Model 5.0(/5_0) for both files.

    Now every thing builds successfully and I am rendering a Green Triangle on a Black Windowed Background as expected.