| Previous | Next |
| D2DERR_RECREATE_TARGET | D2DERR_SHADER_COMPILE_FAILED |
D2DERR_TOO_MANY_SHADER_ELEMENTS
D2DERR_TOO_MANY_SHADER_ELEMENTS belongs to Direct2D custom-effect shader construction. Custom shader construction exceeds the complexity or element limits accepted by Direct2D. The diagnostic goal for it is to identify the first rejecting object and transition, not merely the final high-level symptom.
Where the failure occurs
Custom effects combine registration XML, property bindings, transform nodes, compiled HLSL, resource declarations, and device capabilities., shader compilation failure and excessive shader elements occur at different checkpoints: valid source can still produce a graph or bytecode payload beyond accepted limits.
Inspect the following boundary: custom effect shader, resource declarations, constants, and generated shader graph.
Smallest faithful reproducer
Start with a pass-through shader and one transform node. Add constants, textures, samplers, instructions, and graph operations incrementally while retaining compiler diagnostics and the exact bytecode loaded by Direct2D.
- compile a minimal pass-through shader.
- When it is returned, add shader features incrementally.
- Split independent operations into multiple effects.
- verify the target device and shader model.
Telemetry with explanatory value
| Record | Why it matters here |
|---|---|
| Shader model and compiled bytecode size | In this result diagnostics, recording shader model and compiled bytecode size ties the HRESULT to the Direct2D custom-effect shader construction boundary rather than to the final visible failure. |
| Samplers, constant buffers, textures, and instructions | Comparing samplers, constant buffers, textures, and instructions shows whether this result follows input, object state, or environment. |
| Effect transform graph and combined operations | Preserving effect transform graph and combined operations provides the evidence needed to test this distinction: sHADER_COMPILE_FAILED means compilation itself failed; TOO_MANY_SHADER_ELEMENTS means complexity remained beyond an accepted limit. |
| Compiler warnings and Direct2D debug output | Recording compiler warnings and Direct2D debug output separates the Direct2D custom-effect shader construction boundary from a later wrapper symptom. |
Separate object, input, and environment
| Test | Interpretation | Hold constant |
|---|---|---|
| Same environment, reduced input | If this result disappears with a smaller faithful case, complexity within Direct2D custom-effect shader construction is implicated. | Keep shader model and compiled bytecode size fixed while simplifying effect transform graph and combined operations. |
| Same input, fresh object generation | If this result 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. | Place samplers, constant buffers, textures, and instructions on the timeline of the last successful transition. |
| Same operation on a controlled second path | If this result follows one environment, the failure is not explained by source data alone. | Compare adapter and feature level, factory and device generations, target identity, debug-layer output, and thread ownership while preserving compiler warnings and Direct2D debug output. |
Avoid broad resets
SHADER_COMPILE_FAILED means compilation itself failed; TOO_MANY_SHADER_ELEMENTS means complexity remained beyond an accepted limit. 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.
Completion test
A correction for it 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 a minimal pass-through shader” and confirm that the following lifecycle step also succeeds. Keep the original failing sample and one deliberate negative case so fallback cannot be mistaken for repair.
Technical references
When it 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.
