scenerygraphics / scenery

Flexible VR Visualisation for Volumetric and Geometric Data on the Java VM, powered by Kotlin and Vulkan.
https://scenery.graphics
GNU Lesser General Public License v3.0
128 stars 31 forks source link

Vulkan bug with validation layer endCommandBuffer? #169

Closed kephale closed 6 years ago

kephale commented 6 years ago

Note that this issue also arises in SciView: http://forum.imagej.net/t/3d-viewer-doesnt-work-with-java8/8078/9?u=kephale

I get this with a Quadro P5000 running Ubuntu 16.04 and explicitly specify VulkanRenderer (fallback to OpenGLRenderer works). This happens on texturedcube:

this is scenery.
Standard library imported.

Try scene.addChild(a = new Box(new GLVector(4.0, 4.0, 4.0)))
------------------------------------------------------------

[main] INFO VulkanRenderer - Recreating Swapchain at frame 0
[main] INFO VulkanRenderer - Creating render framebuffer GeometryBuffer for pass Scene
[main] INFO VulkanRenderer -  + attachment NormalsMaterial, RGBA_Float16
[main] INFO VulkanRenderer -  + attachment DiffuseAlbedo, RGBA_UInt8
[main] INFO VulkanRenderer -  + attachment ZBuffer, Depth32
[main] INFO VulkanRenderer - Creating render framebuffer DSSDOTemp1 for pass DSSDO
[main] INFO VulkanRenderer -  + attachment Occlusion, RGBA_UInt8
[main] INFO VulkanRenderer - Creating render framebuffer DSSDOTemp2 for pass DSSDOBlurV
[main] INFO VulkanRenderer -  + attachment Occlusion, RGBA_UInt8
[main] INFO VulkanRenderer - Creating render framebuffer DSSDOBuffer for pass DSSDOBlurH
[main] INFO VulkanRenderer -  + attachment Occlusion, RGBA_UInt8
[main] INFO VulkanRenderer - Creating render framebuffer ForwardBuffer for pass DeferredLighting
[main] INFO VulkanRenderer -  + attachment Color, RGBA_Float32
[main] INFO VulkanRenderer - Creating render framebuffer HDRBuffer for pass ForwardShading
[main] INFO VulkanRenderer -  + attachment Color, RGBA_Float32
[main] INFO VulkanRenderer -  + attachment Depth, Depth32
[main] INFO VulkanRenderer - Creating render framebuffer FXAABuffer for pass HDR
[main] INFO VulkanRenderer -  + attachment Color, RGBA_UInt8
[main] WARN VulkanShaderModule - Shader path shaders/DSSDO.frag.spv not found within given classes, falling back to default.
[main] INFO VulkanShaderModule - Compiling shaders/DSSDO.frag to SPIR-V...
[main] WARN VulkanShaderModule - Shader path shaders/DeferredLighting.frag.spv not found within given classes, falling back to default.
[main] INFO VulkanShaderModule - Compiling shaders/DeferredLighting.frag to SPIR-V...
[main] INFO VulkanRenderer - Scene initialization started.
[main] INFO VulkanShaderModule - Compiling shaders/DeferredLighting.frag to SPIR-V...
[main] INFO VulkanShaderModule - Compiling shaders/DeferredLighting.frag to SPIR-V...
[main] INFO VulkanRenderer - Scene initialization complete.
[main @coroutine#25020] ERROR VulkanRenderer - Call to endCommandBuffer failed: The logical or physical device has been lost.

java.lang.RuntimeException: Call to endCommandBuffer failed: The logical or physical device has been lost.

    at graphics.scenery.backends.vulkan.VUKt.submit(VU.kt:642)
    at graphics.scenery.backends.vulkan.VUKt.submit$default(VU.kt:64)
    at graphics.scenery.backends.vulkan.VUKt.endCommandBuffer(VU.kt:56)
    at graphics.scenery.backends.vulkan.VUKt.endCommandBuffer$default(VU.kt:46)
    at graphics.scenery.backends.vulkan.VulkanRenderer.createVertexBuffers(VulkanRenderer.kt:2002)
    at graphics.scenery.backends.vulkan.VulkanRenderer.initializeNode(VulkanRenderer.kt:668)
    at graphics.scenery.backends.vulkan.VulkanRenderer$recordSceneRenderCommands$1.doResume(VulkanRenderer.kt:2198)
    at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
    at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
    at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25)
    at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:147)
    at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:233)
    at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Builders.kt:174)
    at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Builders.kt:167)
    at graphics.scenery.backends.vulkan.VulkanRenderer.recordSceneRenderCommands(VulkanRenderer.kt:2173)
    at graphics.scenery.backends.vulkan.VulkanRenderer.render(VulkanRenderer.kt:1756)
    at graphics.scenery.SceneryBase.main(SceneryBase.kt:203)
    at graphics.scenery.tests.examples.basic.PointCloudExample.main(PointCloudExample.kt:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
skalarproduktraum commented 6 years ago

Hey @kephale,

I'm trying to investigate this at the moment, and it seems to be quite weird. Device lost errors should actually not occur, and usually point to a severe mistake before the error. I've so far only been able to reproduce this with the 396 Nvidia driver, which one are you using?

skalarproduktraum commented 6 years ago

Further investigation has led me to believe that the issue is not caused by scenery, but by Nvidia's new shader compiler, introduced with the 396.xx+ series of drivers. The new shader compiler can be disabled by setting the environment variable __GL_NextGenCompiler=0, which should at least work around the problem for the moment.

Source for this: http://www.nvidia.com/download/driverResults.aspx/133859/en-us

Further issues with these driver versions are reported also by the dxvk project (https://github.com/doitsujin/dxvk/issues/267), and Nvidia reports issues with the Vulkan-only game Wolfenstein II.

skalarproduktraum commented 6 years ago

93a3463 contains some new code for device-specific workarounds, the only thing it can do about this issue though is emitting a warning to set abovementioned environment variable.

skalarproduktraum commented 6 years ago

This issues is successfully worked around by using a newer shader compiler version introduced with spirvcrossj 0.4.1, in commit 45cec6c3af9d74d84d3cc499d50c666b58f1fca7. Closing the issue therefore.