This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
HRESULT D3DCompileFromFile( [in] LPCWSTR pFileName, [in, optional] const D3D_SHADER_MACRO *pDefines, [in, optional] ID3DInclude *pInclude, [in] LPCSTR pEntrypoint, [in] LPCSTR pTarget, [in] UINT Flags1, [in] UINT Flags2, [out] ID3DBlob **ppCode, [out, optional] ID3DBlob **ppErrorMsgs);[in] pFileName
A pointer to a constant null-terminated string that contains the name of the file that contains the shader code.
[in, optional] pDefines
An optional array ofD3D_SHADER_MACRO structures that define shader macros. Each macro definition contains a name and a null-terminated definition. If not used, set toNULL. The last structure in the array serves as a terminator and must have all members set toNULL.
[in, optional] pInclude
An optional pointer to anID3DInclude interface that the compiler uses to handle include files. If you set this parameter toNULL and the shader contains a #include, a compile error occurs. You can pass theD3D_COMPILE_STANDARD_FILE_INCLUDE macro, which is a pointer to a default include handler. This default include handler includes files that are relative to the current directory.
#define D3D_COMPILE_STANDARD_FILE_INCLUDE ((ID3DInclude*)(UINT_PTR)1)[in] pEntrypoint
A pointer to a constant null-terminated string that contains the name of the shader entry point function where shader execution begins. When you compile an effect,D3DCompileFromFile ignorespEntrypoint; we recommend that you setpEntrypoint toNULL because it is good programming practice to set a pointer parameter toNULL if the called function will not use it.
[in] pTarget
A pointer to a constant null-terminated string that specifies the shader target or set of shader features to compile against. The shader target can be a shader model (for example, shader model 2, shader model 3, shader model 4, or shader model 5 and later). The target can also be an effect type (for example, fx_4_1). For info about the targets that various profiles support, seeSpecifying Compiler Targets.
[in] Flags1
A combination of shadercompile options that are combined by using a bitwiseOR operation. The resulting value specifies how the compiler compiles the HLSL code.
[in] Flags2
A combination of effectcompile options that are combined by using a bitwiseOR operation. The resulting value specifies how the compiler compiles the effect. When you compile a shader and not an effect file,D3DCompileFromFile ignoresFlags2; we recommend that you setFlags2 to zero because it is good programming practice to set a nonpointer parameter to zero if the called function will not use it.
[out] ppCode
A pointer to a variable that receives a pointer to theID3DBlob interface that you can use to access the compiled code.
[out, optional] ppErrorMsgs
An optional pointer to a variable that receives a pointer to theID3DBlob interface that you can use to access compiler error messages, orNULL if there are no errors.
Returns one of theDirect3D 11 return codes.
| Requirement | Value |
|---|---|
| Target Platform | Windows |
| Header | d3dcompiler.h |
| Library | D3DCompiler.lib |
| DLL | D3DCompiler_47.dll |
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?