| Previous | Next |
| D2DERR_TOO_MANY_SHADER_ELEMENTS | D2DERR_MAX_TEXTURE_SIZE_EXCEEDED |
D2DERR_SHADER_COMPILE_FAILED
D2DERR_SHADER_COMPILE_FAILED belongs to Direct2D custom-effect shader construction. The HLSL or supplied custom-effect shader could not be compiled or loaded as valid Direct2D shader code. The diagnostic goal for D2DERR_SHADER_COMPILE_FAILED is to identify the first rejecting object and transition, not merely the final high-level symptom.
Read the HRESULT in context
For D2DERR_SHADER_COMPILE_FAILED, custom effects combine registration XML, property bindings, transform nodes, compiled HLSL, resource declarations, and device capabilities. When D2DERR_SHADER_COMPILE_FAILED is returned, shader compilation failure and excessive shader elements occur at different checkpoints: valid source can still produce a graph or bytecode payload beyond accepted limits.
For D2DERR_SHADER_COMPILE_FAILED, inspect the following boundary: source or bytecode compilation, entry point, profile, bindings, and Direct2D effect requirements.
A minimal test sequence
Start with a pass-through shader and one transform node in the D2DERR_SHADER_COMPILE_FAILED path. For D2DERR_SHADER_COMPILE_FAILED, add constants, textures, samplers, instructions, and graph operations incrementally while retaining compiler diagnostics and the exact bytecode loaded by Direct2D.
- For D2DERR_SHADER_COMPILE_FAILED, compile offline with warnings treated as errors.
- When D2DERR_SHADER_COMPILE_FAILED is returned, start from the Direct2D pass-through sample.
- Verify bytecode matches the requested shader stage in the D2DERR_SHADER_COMPILE_FAILED path.
- For D2DERR_SHADER_COMPILE_FAILED, load the exact bytecode in a minimal custom effect.
Capture before changing state
| Record | Why it matters here |
|---|---|
| Compiler diagnostics and source hash | In D2DERR_SHADER_COMPILE_FAILED diagnostics, recording compiler diagnostics and source hash ties the HRESULT to the Direct2D custom-effect shader construction boundary rather than to the final visible failure. |
| Entry point, shader profile, flags, and SDK compiler version | Comparing entry point, shader profile, flags, and SDK compiler version shows whether D2DERR_SHADER_COMPILE_FAILED follows input, object state, or environment. |
| Resource/register bindings expected by Direct2D | Preserving resource/register bindings expected by Direct2D provides the evidence needed to test this distinction: tOO_MANY_SHADER_ELEMENTS is a complexity limit; COMPILE_FAILED covers syntax, profile, entry-point, or bytecode validity. |
| Effect registration and load sequence | For D2DERR_SHADER_COMPILE_FAILED, recording effect registration and load sequence separates the Direct2D custom-effect shader construction boundary from a later wrapper symptom. |
Three diagnostic branches
| Test | Interpretation | Hold constant |
|---|---|---|
| Same environment, reduced input | If D2DERR_SHADER_COMPILE_FAILED disappears with a smaller faithful case, complexity within Direct2D custom-effect shader construction is implicated. | For D2DERR_SHADER_COMPILE_FAILED, keep compiler diagnostics and source hash fixed while simplifying resource/register bindings expected by Direct2D. |
| Same input, fresh object generation | If D2DERR_SHADER_COMPILE_FAILED changes after rebuilding state, examine ownership across the caller’s object graph, custom effect or renderer, Direct2D validation layer, backing device, and deferred draw boundary. | For D2DERR_SHADER_COMPILE_FAILED, place entry point, shader profile, flags, and SDK compiler version on the timeline of the last successful transition. |
| Same operation on a controlled second path | If D2DERR_SHADER_COMPILE_FAILED follows one environment, the failure is not explained by source data alone. | For D2DERR_SHADER_COMPILE_FAILED, compare adapter and feature level, factory and device generations, target identity, debug-layer output, and thread ownership while preserving effect registration and load sequence. |
Common wrong turns
TOO_MANY_SHADER_ELEMENTS is a complexity limit; COMPILE_FAILED covers syntax, profile, entry-point, or bytecode validity. For D2DERR_SHADER_COMPILE_FAILED, do not respond with a universal render-target recreation loop unless the returned status specifically documents device-loss recovery; graph, property, numeric, lifetime, and print-state errors require correcting their contract.
Regression verification
A correction for D2DERR_SHADER_COMPILE_FAILED should let the operation at the Direct2D custom-effect shader construction boundary complete repeatedly under the original supported conditions. Repeat the control that begins with “Compile offline with warnings treated as errors” and confirm that the following lifecycle step also succeeds. For D2DERR_SHADER_COMPILE_FAILED, keep the original failing sample and one deliberate negative case so fallback cannot be mistaken for repair.
Technical references
When D2DERR_SHADER_COMPILE_FAILED is returned, these references define the public API family, object model, or error list used to interpret this status.
- Microsoft: Direct2D error codes.
- Microsoft: Direct2D custom effects.
- Microsoft: ID2D1TransformGraph.
- Microsoft: Direct2D devices and device contexts.
Looking for a different code? Search another status or error code.