@@ -9,20 +9,20 @@ params:
99 status : Under Review
1010---
1111
12-
12+
1313* Issue(s): https://github.com/microsoft/hlsl-specs/issues/33
1414
1515## Introduction
1616
1717This proposal specifies two new HLSL debugging intrinsics:
1818
19- 1 . ** ` DebugBreak() ` ** : Triggers a breakpoint when a debugger is attached,
19+ 1 . ** ` DebugBreak() ` ** : Triggers a breakpoint when debugging is enabled
2020 allowing developers to pause execution and inspect shader state.
21- 2 . ** ` dx::IsDebuggerPresent () ` ** : Returns whether a graphics debugger is currently
22- attached to the process , enabling conditional debug-only code paths.
21+ 2 . ** ` dx::IsDebuggingEnabled () ` ** : Returns whether debugging is enabled for the
22+ currently executing thread , enabling conditional debug-only code paths.
2323
2424` DebugBreak() ` will lower to new DXIL operations for DirectX and to appropriate
25- SPIR-V instructions for Vulkan targets. ` dx::IsDebuggerPresent () ` is a DirectX
25+ SPIR-V instructions for Vulkan targets. ` dx::IsDebuggingEnabled () ` is a DirectX
2626extension and has no Vulkan/SPIR-V equivalent.
2727
2828## Motivation
@@ -36,8 +36,8 @@ Conditional breakpoints can be a powerful tool for shader authors to narrow down
3636and identify these complex rare-occurring problems.
3737
3838Additionally, shader authors need a way to conditionally enable expensive debug
39- checks only when a debugger is attached , avoiding runtime overhead in production
40- scenarios.
39+ checks only when debugging is enabled in the runtime , avoiding runtime overhead
40+ in production scenarios.
4141
4242This proposal introduces two intrinsics that together provide a debugging
4343toolkit for shader development.
@@ -49,8 +49,8 @@ This proposal introduces two new HLSL intrinsics for debugging shader code.
4949### Intrinsics
5050
5151``` hlsl
52- void DebugBreak(); // Trigger a breakpoint if debugger attached
53- bool dx::IsDebuggerPresent (); // Query if a debugger is attached (DirectX only)
52+ void DebugBreak(); // Trigger a breakpoint if debugging is enabled.
53+ bool dx::IsDebuggingEnabled (); // Query if debugging is enabled (DirectX only).
5454```
5555
5656### Example Usage
@@ -59,11 +59,11 @@ bool dx::IsDebuggerPresent(); // Query if a debugger is attached (DirectX only)
5959[numthreads(8,1,1)]
6060void main(uint GI : SV_GroupIndex) {
6161 // Conditional expensive debug checks
62- if (dx::IsDebuggerPresent ()) {
62+ if (dx::IsDebuggingEnabled ()) {
6363 // Expensive validation only when debugging
6464 ValidateComplexInvariants();
6565 }
66-
66+
6767 // Manual breakpoint for debugging specific conditions
6868 if (someRareCondition) {
6969 DebugBreak();
@@ -85,22 +85,22 @@ Two new intrinsic functions are added:
8585void DebugBreak();
8686```
8787
88- Triggers a breakpoint if a graphics debugger is attached . If no debugger is
89- attached or the runtime does not support this operation, it is treated as a
88+ Triggers a breakpoint if debugging is enabled in the runtime . If debugging is
89+ not enabled or the runtime does not support this operation, it is treated as a
9090no-op. Execution continues after the breakpoint.
9191
92- #### ` dx::IsDebuggerPresent () `
92+ #### ` dx::IsDebuggingEnabled () `
9393
9494``` hlsl
95- bool dx::IsDebuggerPresent ();
95+ bool dx::IsDebuggingEnabled ();
9696```
9797
98- Returns ` true ` if a graphics debugger is currently attached to the process,
99- ` false ` otherwise. This allows shader authors to conditionally execute expensive
100- debug validation code only when a debugger is present :
98+ Returns ` true ` if debugging is enabled on the current thread, ` false ` otherwise.
99+ This allows shader authors to conditionally execute expensive debug validation
100+ code only when debugging is enabled :
101101
102102``` hlsl
103- if (dx::IsDebuggerPresent ()) {
103+ if (dx::IsDebuggingEnabled ()) {
104104 // Expensive bounds checking, validation, etc.
105105 for (uint i = 0; i < arraySize; ++i) {
106106 if (data[i] < 0.0f || data[i] > 1.0f) {
@@ -126,19 +126,19 @@ declare void @dx.op.debugBreak(
126126```
127127
128128Triggers a debugger breakpoint. Must be treated as ` convergent ` to prevent code
129- motion. Should not be marked ` readonly ` or ` readnone ` . If no debugger is
130- attached , this is a no-op.
129+ motion. Should not be marked ` readonly ` or ` readnone ` . If debugging is not
130+ enabled , this is a no-op.
131131
132- #### ` dx.op.isDebuggerPresent `
132+ #### ` dx.op.IsDebuggingEnabled `
133133
134134``` llvm
135- declare i1 @dx.op.isDebuggerPresent (
135+ declare i1 @dx.op.IsDebuggingEnabled (
136136 immarg i32 ; opcode
137137) readonly
138138```
139139
140- Returns ` true ` (1) if a debugger is attached , ` false ` (0) otherwise. Marked
141- ` readonly ` as it only queries state.
140+ Returns ` true ` (1) if debugging is enabled , ` false ` (0) otherwise. Marked
141+ ` readonly ` as it only queries state.
142142
143143### Convergence Requirements
144144
@@ -162,10 +162,10 @@ per-pipeline basis.
162162
163163Behavioral changes may include:
164164
165- - Breaking regardless of a debugger being attached
165+ - Breaking regardless of a debugging enabled
166166- Disabling debug break instructions entirely
167167
168- It is expected that the driver compiler will alter behavior during lowering
168+ It is expected that the driver compiler will alter behavior during lowering
169169based on information provided by the runtime at pipeline creation.
170170
171171### SPIR-V Lowering
@@ -182,7 +182,7 @@ Uses the existing `NonSemantic.DebugBreak` instruction:
182182While this instruction is not widely supported by Vulkan debuggers, it is
183183supported by NVIDIA's NSight and can be safely ignored by Vulkan runtimes.
184184
185- No SPIR-V lowering is defined for ` dx::IsDebuggerPresent () ` .
185+ No SPIR-V lowering is defined for ` dx::IsDebuggingEnabled () ` .
186186
187187## Testing
188188
@@ -199,13 +199,13 @@ No SPIR-V lowering is defined for `dx::IsDebuggerPresent()`.
199199
200200### Execution Testing
201201
202- - Test ` DebugBreak() ` triggers breakpoint when debugger attached
203- - Test ` DebugBreak() ` is no-op when no debugger present
204- - Test ` dx::IsDebuggerPresent () ` returns correct value based on debugger state
202+ - Test ` DebugBreak() ` triggers breakpoint when debugging is enabled
203+ - Test ` DebugBreak() ` is no-op when debugging is not enabled
204+ - Test ` dx::IsDebuggingEnabled () ` returns correct value based on runtime state
205205
206206## Open Questions
207207
208208* Consider introducing the ` convergent ` attribute to DXIL.
209209 * This should be "cheap" and would potentially address pre-existing bugs.
210210 * This would preserve the requirement that these operations not be moved
211- during optimization in the final DXIL.
211+ during optimization in the final DXIL.
0 commit comments