DirectX Utilities
This section provides reference information for DirectX utility functions, which offer helper routines for common graphics programming tasks.
General Utility Functions
-
HRESULT D3DCreateBlob(SIZE_t Size, ID3DBlob** ppBlob);
Creates a buffer of the specified size for use with DirectX APIs.
Parameters:- Size: The size of the buffer to create.
- ppBlob: Address of a pointer to the ID3DBlob interface.
Return Value: Returns an HRESULT code such as S_OK on success or E_OUTOFMEMORY if the buffer could not be allocated. -
HRESULT D3DDisassemble(
const void* pShader,
SIZE_t Size,
UINT Flags1,
D3D_DISASM_FLAGS Flags2,
ID3DBlob** ppDisassembly
);Disassembles compiled shader code.
Parameters:- pShader: Pointer to the compiled shader code.
- Size: The size of the compiled shader code.
- Flags1: Flags for disassembly.
- Flags2: Additional flags for disassembly.
- ppDisassembly: Address of a pointer to an ID3DBlob interface that receives the disassembled code.
Return Value: Returns S_OK if successful, or one of the Direct3D 11/12 error codes. -
HRESULT D3DCompileFromFile(
LPCWSTR pFileName,
const D3D_SHADER_MACRO* pDefines,
ID3DInclude* pInclude,
LPCSTR pEntrypoint,
LPCSTR pTarget,
UINT Flags1,
UINT Flags2,
ID3DBlob** ppCode,
ID3DBlob** ppErrorMsgs
);Compiles a shader from a file.
Parameters:- pFileName: Name of the shader file.
- pDefines: Optional array of shader macros.
- pInclude: Pointer to an include interface.
- pEntrypoint: Name of the shader-compilation target in the effect file.
- pTarget: The shader model to compile.
- Flags1: Compilation flags.
- Flags2: Effect compilation flags.
- ppCode: Address of a pointer to an ID3DBlob interface that contains the compiled shader code.
- ppErrorMsgs: Address of a pointer to an ID3DBlob interface that contains compiler error messages.
Return Value: Returns S_OK if successful, or one of the Direct3D 11/12 error codes.
Shader Reflection
Tools and interfaces for inspecting compiled shader code.
-
HRESULT D3DReflect(
const void* pShaderBytecode,
SIZE_t BytecodeLength,
REFIID InterfaceID,
void** ppReflector
);Retrieves a shader reflection interface from compiled shader code.
Parameters:- pShaderBytecode: Pointer to the compiled shader code.
- BytecodeLength: Length of the shader bytecode.
- InterfaceID: The GUID of the reflection interface to retrieve.
- ppReflector: Address of a pointer to the reflection interface.
Return Value: Returns S_OK if successful, or one of the Direct3D 11/12 error codes.
Debugging and Diagnostics
Utility functions for debugging graphics applications.
-
HRESULT DXGIReportAdapterConfiguration();
Reports the configuration of the graphics adapter to the debug output.
Return Value: Returns S_OK on success, or DXGI_ERROR_NOT_FOUND if no adapter is found.