ID3DXEffectCompiler::CompileShader method

Compiles a shader from an effect that contains one or more functions.

Syntax

HRESULT CompileShader(
  [in]          D3DXHANDLE          hFunction,
  [in]          LPCSTR              pTarget,
  [in]          DWORD               Flags,
  [out, retval] LPD3DXBUFFER        *ppShader,
  [out, retval] LPD3DXBUFFER        *ppErrorMsgs,
  [out]         LPD3DXCONSTANTTABLE *ppConstantTable
);

Parameters

hFunction [in]

Type: D3DXHANDLE

Unique identifier to the function to be compiled. This value must not be NULL. See Handles (Direct3D 9).

pTarget [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, retval]

Type: LPD3DXBUFFER*

Buffer containing the compiled shader. The compiler shader is an array of DWORDs. For more information about accessing the buffer, see ID3DXBuffer.

ppErrorMsgs [out, retval]

Type: LPD3DXBUFFER*

Buffer containing at least the first compile error message that occurred. This includes effect compiler errors and high-level language compile errors. For more information about accessing the buffer, see ID3DXBuffer.

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 method succeeds, the return value is S_OK.

If the arguments are invalid, the method will return D3DERR_INVALIDCALL.

If the method fails, the return value will be E_FAIL.

Remarks

Targets can be specified for vertex shaders, pixel shaders, and texture fill functions.

Targets Functions
Vertex shader targets vs_1_1, vs_2_0, vs_2_sw, vs_3_0
Pixel shader targets ps_1_1, ps_1_2, ps_1_3, ps_1_4, ps_2_0, ps_2_sw, ps_3_0
Texture fill targets tx_0, tx_1

 

This method compiles a shader from a function that is written in a C-like language. For more information, see HLSL.

Requirements

Requirement Value
Header
D3DX9Effect.h
Library
D3dx9.lib

See also

ID3DXEffectCompiler

D3DXGetShaderConstantTable