From b92a75db2aab1adffe08ae0103cafb080f9795e2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 14 Feb 2023 16:21:07 -0500 Subject: Preliminary debugBreak support (#2647) * #include an absolute path didn't work - because paths were taken to always be relative. * Preliminary support for debug break. * Add C++ debug break support. Add details about usage. * Improve debug break test details. * Make HLSL output a comment about no support. * Handle specialize for target assert, without a body if it has spv_instruction/target intrinsic --- tests/hlsl-intrinsic/debug-break.slang | 23 +++++++++++++++++++++++ tests/hlsl-intrinsic/debug-break.slang.expected | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/hlsl-intrinsic/debug-break.slang create mode 100644 tests/hlsl-intrinsic/debug-break.slang.expected (limited to 'tests') diff --git a/tests/hlsl-intrinsic/debug-break.slang b/tests/hlsl-intrinsic/debug-break.slang new file mode 100644 index 000000000..e46c42004 --- /dev/null +++ b/tests/hlsl-intrinsic/debug-break.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE:-stage compute -entry computeMain -target glsl -line-directive-mode none +// We can't enable because output source includes path to prelude. +//DISABLE_TEST:SIMPLE:-stage compute -entry computeMain -target cpp -line-directive-mode none +//DISABLE_TEST:SIMPLE:-stage compute -entry computeMain -target cuda -line-directive-mode none +// Not currently supported on HLSL +//DISABLE_TEST:SIMPLE:-stage compute -entry computeMain -target hlsl -line-directive-mode none +// With `slang-llvm` this will crash, but the call stack isn't really usable. +// With downstream host compilers this should break into the debugger. It's not enabled as that isn't testable. +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -Xslang... -O0 -g -X. + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer + +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + const int idx = int(dispatchThreadID.x); + + debugBreak(); + + outputBuffer[idx] = idx; +} \ No newline at end of file diff --git a/tests/hlsl-intrinsic/debug-break.slang.expected b/tests/hlsl-intrinsic/debug-break.slang.expected new file mode 100644 index 000000000..fbd1faa9b --- /dev/null +++ b/tests/hlsl-intrinsic/debug-break.slang.expected @@ -0,0 +1,24 @@ +result code = 0 +standard error = { +} +standard output = { +#version 450 +#extension GL_EXT_spirv_intrinsics : require +layout(row_major) uniform; +layout(row_major) buffer; +spirv_instruction(id = 1, set = "NonSemantic.DebugBreak") +void debugBreak_0(); + +layout(std430, binding = 0) buffer _S1 { + int _data[]; +} outputBuffer_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + int idx_0 = int(gl_GlobalInvocationID.x); + debugBreak_0(); + ((outputBuffer_0)._data[(uint(idx_0))]) = idx_0; + return; +} + +} -- cgit v1.2.3