mellinoe / veldrid-raytracer

A C# ray tracer, capable of running on both the CPU and GPU.
198 stars 29 forks source link

Unable to run with high NumSamples in RayTracingApplication.cs #2

Open TekuSP opened 6 years ago

TekuSP commented 6 years ago

Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'C:\Users\TekuSP\Desktop\veldrid-raytracer-master\bin\Debug\raytracer\netcoreapp2.0\Shaders\RayTraceCompute-compute.hlsl.bytes'. at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.IO.File.InternalReadAllBytes(String path) at System.IO.File.ReadAllBytes(String path) at RayTracer.RayTracingApplication.LoadShaderBytes(String name) in C:\Users\TekuSP\Desktop\veldrid-raytracer-master\src\raytracer\RayTracingApplication.cs:line 526 at RayTracer.RayTracingApplication.CreateDeviceResources() in C:\Users\TekuSP\Desktop\veldrid-raytracer-master\src\raytracer\RayTracingApplication.cs:line 497 at RayTracer.RayTracingApplication.Run() in C:\Users\TekuSP\Desktop\veldrid-raytracer-master\src\raytracer\RayTracingApplication.cs:line 66 at RayTracer.Program.Main(String[] args) in C:\Users\TekuSP\Desktop\veldrid-raytracer-master\src\raytracer\Program.cs:line 7 Press any key to continue . . .

Happens for example at 80. 8 works fine.

TekuSP commented 6 years ago

Windows 10 17672.1000. .NET 4.7.2 .NET Core 2.1.200 NVIDIA 1060 and having all these Windows 10 SDKs https://i.imgur.com/4CohZGF.png

mellinoe commented 6 years ago

Hrm, I don't see what that message would have to do with the sample count. Are you sure that is related?

TekuSP commented 6 years ago

Lowering NumSamples removes this issue. Adding more makes this issue.

This is only error I get.

mellinoe commented 6 years ago

The error is about missing shader bytecode, which could be the same as #1 . I'm not sure how changing NumSamples could affect the loading of shader code, though. I have seen that the compute shader can time out (crash the app), if NumSamples is too high, though.

TekuSP commented 6 years ago

Too high? You mean like 30? I can replicate this bug by changing NumSamples.

I am running it on NVIDIA 1060 with latest driver. https://pastebin.com/5iz7PYdH

mellinoe commented 6 years ago

@TekuSP I see what the problem is now. Sorry for doubting you before -- this was a very unusual issue 😅 .

It turns out that if the sample count is too high, the HLSL compiler starts to hit the timeout value that I have in place (2 seconds). It seems that cranking up the outer loop limit causes the compilation to take significantly longer. At 64 samples, it takes about 10 seconds (!) to compile the HLSL compute shader. I've made the FXC timeout much longer to allow for this. On my GTX 770, I'm able to get to about 80 samples before the compute shader starts timing out.