Export (0) Print
Expand All

D3DX11CompileFromFile function

Note  The D3DX (D3DX 9, D3DX 10, and D3DX 11) utility library is deprecated for Windows 8 and is not supported for Windows Store apps.

Note  Instead of using this function, we recommend that you compile offline by using the Fxc.exe command-line compiler or use one of the HLSL compile APIs, like the D3DCompileFromFile API.

Compile a shader or an effect from a file.

Syntax


HRESULT D3DX11CompileFromFile(
  _In_   LPCTSTR pSrcFile,
  _In_   const D3D10_SHADER_MACRO *pDefines,
  _In_   LPD3D10INCLUDE pInclude,
  _In_   LPCSTR pFunctionName,
  _In_   LPCSTR pProfile,
  _In_   UINT Flags1,
  _In_   UINT Flags2,
  _In_   ID3DX11ThreadPump *pPump,
  _Out_  ID3D10Blob **ppShader,
  _Out_  ID3D10Blob **ppErrorMsgs,
  _Out_  HRESULT *pHResult
);

Parameters

pSrcFile [in]

Type: LPCTSTR

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 D3D10_SHADER_MACRO*

Optional. Pointer to an array of macro definitions (see D3D10_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]

Type: LPD3D10INCLUDE

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

pFunctionName [in]

Type: LPCSTR

Name of the shader-entry point function where shader execution begins. When you compile an effect, D3DX11CompileFromFile 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]

Type: LPCSTR

A string that specifies the shader model; can be any profile in shader model 2, shader model 3, shader model 4, or shader model 5. The profile can also be for effect type (for example, fx_4_1).

Flags1 [in]

Type: UINT

Shader compile flags.

Flags2 [in]

Type: UINT

Effect compile flags. When you compile a shader and not an effect file, D3DX11CompileFromFile 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: ID3DX11ThreadPump*

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

ppShader [out]

Type: ID3D10Blob**

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

ppErrorMsgs [out]

Type: ID3D10Blob**

A pointer to memory 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]

Type: HRESULT*

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

Type: HRESULT

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

D3DX11CompileFromFile returns E_INVALIDARG if you supply a non-NULL value to the pHResult parameter when you supply NULL to the pPump parameter. For more information about this situation, see Remarks.

Remarks

For more information about D3DX11CompileFromFile, see D3DCompile.

You must supply NULL to the pHResult parameter if you also supply NULL to the pPump parameter. Otherwise, you cannot create a shader by using the compiled shader code that D3DX11CompileFromFile returns in the memory that the ppShader parameter points to. To create a shader from complied shader code, you call one of the following ID3D11Device interface methods:

In addition, if you supply a non-NULL value to pHResult when you supply NULL to pPump, D3DX11CompileFromFile returns the E_INVALIDARG error code.

Requirements

Header

D3DX11async.h

Library

D3DX11.lib

See also

D3DX Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft