D3DXCompileShader function

Compile a shader file.

Note

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.

 

Syntax

HRESULT D3DXCompileShader(
  _In_        LPCSTR              pSrcData,
  _In_        UINT                srcDataLen,
  _In_  const D3DXMACRO           *pDefines,
  _In_        LPD3DXINCLUDE       pInclude,
  _In_        LPCSTR              pFunctionName,
  _In_        LPCSTR              pProfile,
  _In_        DWORD               Flags,
  _Out_       LPD3DXBUFFER        *ppShader,
  _Out_       LPD3DXBUFFER        *ppErrorMsgs,
  _Out_       LPD3DXCONSTANTTABLE *ppConstantTable
);

Parameters

pSrcData [in]

Type: LPCSTR

Pointer to a string that contains the shader.

srcDataLen [in]

Type: UINT

Length of the data in bytes.

pDefines [in]

Type: const D3DXMACRO*

An optional NULL terminated array of D3DXMACRO structures. This value may be NULL.

pInclude [in]

Type: LPD3DXINCLUDE

Optional interface pointer, ID3DXInclude, to use for handling #include directives. If this value is NULL, #includes will either be honored when compiling from a file or will cause an error when compiled from a resource or memory.

pFunctionName [in]

Type: LPCSTR

Pointer to a string that contains the name of the shader entry point function where execution begins.

pProfile [in]

Type: LPCSTR

Pointer to a shader profile which determines the shader instruction set. See D3DXGetVertexShaderProfile or D3DXGetPixelShaderProfile for a list of the profiles available.

Flags [in]

Type: DWORD

Compile options identified by various flags. The Direct3D 10 HLSL compiler is now the default. See D3DXSHADER Flags for details.

ppShader [out]

Type: LPD3DXBUFFER*

Returns a buffer containing the created shader. This buffer contains the compiled shader code, as well as any embedded debug and symbol table information.

ppErrorMsgs [out]

Type: LPD3DXBUFFER*

Returns a buffer containing a listing of errors and warnings that were encountered during the compile. These are the same messages the debugger displays when running in debug mode. This value may be NULL.

ppConstantTable [out]

Type: LPD3DXCONSTANTTABLE*

Returns an ID3DXConstantTable interface, which can be used to access shader constants. This value can be NULL. If you compile your application as large address aware (that is, you use the /LARGEADDRESSAWARE linker option to handle addresses larger than 2 GB), you cannot use this parameter and must set it to NULL. Instead, you must use the D3DXGetShaderConstantTableEx function to retrieve the shader-constant table that is embedded inside the shader. In this D3DXGetShaderConstantTableEx call, you must pass the D3DXCONSTTABLE_LARGEADDRESSAWARE flag to the Flags parameter to specify to access up to 4 GB of virtual address space.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Requirements

Requirement Value
Header
D3DX9Shader.h
Library
D3dx9.lib

See also

Shader Functions

D3DXCompileShaderFromFile

D3DXCompileShaderFromResource