Why Unity Editor always crashes when using a ray tracing shader?

I’m writing my own SRP and try to do some ray tracing features.

But once I call cmd.DispatchRays(), unity editor crashes. And I have to press alt+F4 to shut down the editor, or I can’t even close it. Did anyone ever encounter this problem?

The ray tracing shader itself doesn’t have any error. It’s very simple:

#pragma max_recursion_depth 1
RWTexture2D<float4> RenderTarget;
[shader("raygeneration")]
void BackgroundRayGenShader()
{
	uint2 dispatchIdx = DispatchRaysIndex().xy;
	uint2 dispatchDim = DispatchRaysDimensions().xy;
	RenderTarget[dispatchIdx] = float4((float)dispatchIdx.x / dispatchDim.x, (float)dispatchIdx.y/dispatchDim.y , 0.2f, 1.0f);
}

Even if I make the function body empty, Unity still crashes.

The crash is not immediately happened when the first frame is rendered. It usually happens after controlling the Scene Camera for a few seconds.

I’ve tried both Unity6000.0.0f1c1 and Unity6000.0.17f1c1. I’ve tried to upgrade my NVIDIA driver to newest version. The problem still exists.

My graphics card is RTX3060 Laptop. There’s no error when I try to write a C++ DXR demo, which proves that it’s ok for my hardware to run DXR.

Actually, my Unity Editor also crashes when I just start a HDRP project.

Here’s the crash log.
Editor.txt (475.4 KB)

Then I tried the Unity2022.3.43f1c1(LTS), it still crashes but log d3d12: Profiler is enabled, but stable power state is not. GPU timing errors are expected