D3D10CompileShader function

Compile an HLSL shader.

Note  Use D3DX10CompileFromMemory instead of this function.
 

Syntax

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

Parameters

pSrcData

Type: LPCSTR

Pointer to a string containing the shader source code.

SrcDataSize

Type: SIZE_T

Size of pSrcData, in bytes.

pFileName

Type: LPCSTR

The name of the file that contains the shader code.

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.

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.

pFunctionName

Type: LPCSTR

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

pProfile

Type: LPCSTR

A string that specifies the shader profile or shader model.

Flags

Type: UINT

Shader compile options.

ppShader

Type: ID3D10Blob**

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

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

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

See Also

Shader Functions