D3D10CompileShader function
Compile an HLSL shader.
Syntax
HRESULT D3D10CompileShader(
_In_ LPCSTR pSrcData,
_In_ SIZE_T SrcDataLen,
_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
- pSrcData [in]
-
Type: LPCSTR
Pointer to a string containing the shader source code.
- SrcDataLen [in]
-
Type: SIZE_T
Size of pSrcData, in bytes.
- pFileName [in]
-
Type: LPCSTR
The name of the file that contains the shader code.
- 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 ID3D10Include Interface 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.
- pProfile [in]
-
Type: LPCSTR
A string that specifies the shader profile or shader model.
- Flags [in]
-
Type: UINT
Shader compile options.
- ppShader [out]
-
Type: ID3D10Blob**
A pointer to an ID3D10Blob Interface that contains the compiled shader, as well as any embedded debug and symbol-table information.
- ppErrorMsgs [out]
-
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
|
Header |
|
|---|---|
|
Library |
|
|
DLL |
|
See also