D3D10CompileShader function (d3d10shader.h)

Compile an HLSL shader.

Note  Use D3DX10CompileFromMemory instead of this function.
 

Syntax

HRESULT D3D10CompileShader(
  [in]  LPCSTR                   pSrcData,
  [in]  SIZE_T                   SrcDataSize,
  [in]  LPCSTR                   pFileName,
  [in]  const D3D10_SHADER_MACRO *pDefines,
  [in]  LPD3D10INCLUDE           pInclude,
  [in]  LPCSTR                   pFunctionName,
  [in]  LPCSTR                   pProfile,
  [in]  UINT                     Flags,
  [out] ID3D10Blob               **ppShader,
  [out] ID3D10Blob               **ppErrorMsgs
);

Parameters

[in] pSrcData

Type: LPCSTR

Pointer to a string containing the shader source code.

[in] SrcDataSize

Type: SIZE_T

Size of pSrcData, in bytes.

[in] pFileName

Type: LPCSTR

The name of the file that contains the shader code.

[in] pDefines

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.

[in] pInclude

Type: LPD3D10INCLUDE*

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.

[in] pFunctionName

Type: LPCSTR

Name of the shader-entry point function where shader execution begins.

[in] pProfile

Type: LPCSTR

A string that specifies the shader profile or shader model.

[in] Flags

Type: UINT

Shader compile options.

[out] ppShader

Type: ID3D10Blob**

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

[out] ppErrorMsgs

Type: ID3D10Blob**

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

Return value

Type: HRESULT

Returns one of the following Direct3D 10 Return Codes.

Remarks

This function uses the version of the HLSL compiler released in the November 2006 DirectX SDK.

This function implements two ways to supply the input shader information. Either use pSrcData and SrcDataLen to specify a string that contains the shader HLSL code (and set pFileName to NULL) or use pFileName to specify the name of a shader or effect file (and set pSrcData to NULL).

To setup a programmable-pipeline stage, compile a shader and then bind the shader to the appropriate pipeline stage. For instance, here is an example compiling a geometry shader (see Compile a Geometry Shader).

This function, D3D10CompileShader, calls the version of the shader compiler that is shipped each time the operating system releases. A more up-to-date version of the shader compiler ships when the DirectX SDK ships, which can be accessed from D3DX by calling a version of the shader compiler entry-point function such as D3DX10CompileFromFile. It is preferable to use the D3DX entry-point functions to ensure the latest version of the shader compiler will be used if you will be redistributing the DirectX redistributable libraries.

Requirements

Requirement Value
Target Platform Windows
Header d3d10shader.h
Library D3D10.lib
DLL D3D10.dll

See also

Shader Functions