D3DX10CompileFromFile function


Instead of using this legacy function, we recommend that you compile offline by using the Fxc.exe command-line compiler or use the D3DCompile API.


Compile a shader or an effect from a file.


HRESULT D3DX10CompileFromFile(
  _In_        LPCTSTR            pSrcFile,
  _In_  const D3D_SHADER_MACRO *pDefines,
  _In_        LPD3D10INCLUDE     pInclude,
  _In_        LPCSTR             pFunctionName,
  _In_        LPCSTR             pProfile,
  _In_        UINT               Flags1,
  _In_        UINT               Flags2,
  _In_        ID3DX10ThreadPump  *pPump,
  _Out_       ID3D10Blob         **ppShader,
  _Out_       ID3D10Blob         **ppErrorMsgs,
  _Out_       HRESULT            *pHResult


pSrcFile [in]


The name of the file that contains the shader code. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the data type resolves to LPCSTR.

pDefines [in]

Type: const D3D_SHADER_MACRO*

Optional. Pointer to an array of macro definitions (see D3D_SHADER_MACRO). The last structure in the array serves as a terminator and must have all members set to 0. If not used, set pDefines to NULL.

pInclude [in]


Optional. Pointer to an ID3D10Include Interface interface for handling include files. Setting this to NULL will cause a compile error if a shader contains a #include.

pFunctionName [in]


Name of the shader-entry point function where shader execution begins. When you compile an effect, D3DX10CompileFromFile ignores pFunctionName; we recommend that you set pFunctionName to NULL because it is good programming practice to set a pointer parameter to NULL if the called function will not use it.

pProfile [in]


A string that specifies the shader model; can be any profile in shader model 2, shader model 3, or shader model 4.

Flags1 [in]

Type: UINT

Shader compile flags.

Flags2 [in]

Type: UINT

Effect compile flags. When you compile a shader and not an effect file, D3DX10CompileFromFile ignores Flags2; we recommend that you set Flags2 to zero because it is good programming practice to set a nonpointer parameter to zero if the called function will not use it.

pPump [in]

Type: ID3DX10ThreadPump*

A pointer to a thread pump interface (see ID3DX10ThreadPump Interface). Use NULL to specify that this function should not return until it is completed.

ppShader [out]

Type: ID3D10Blob**

A pointer to an ID3D10Blob Interface which contains the compiled shader, as well as any embedded debug and symbol-table information.

ppErrorMsgs [out]

Type: ID3D10Blob**

A pointer to an ID3D10Blob Interface which contains a listing of errors and warnings that occurred during compilation. These errors and warnings are identical to the debug output from a debugger.

pHResult [out]


A pointer to the return value. May be NULL. If pPump is not NULL, then pHResult must be a valid memory location until the asynchronous execution completes.

Return value


The return value is one of the values listed in Direct3D 10 Return Codes.



Requirement Value

See also

General Purpose Functions