Ealrann / VSand

Rewrite of the "Falling Sand" game with Vulkan.
GNU General Public License v3.0
30 stars 3 forks source link

Do not require VK_EXT_debug_report on Vulkan #20

Closed kvark closed 4 years ago

kvark commented 4 years ago

Is there a way to make this instance extension optional instead of required?

Ealrann commented 4 years ago

This instance extension should only be required in debug mode, which means DebugUtil.DEBUG_ENABLED == true or DebugUtil.DEBUG_VERBOSE_ENABLED == true.

It's disabled by default, but enabled if:

  1. There is a Java property '-Ddebug=true'
  2. or, more recently, if there is an application parameter (in void main(String[] args)) equals to 'debug'.

(If you use an old version on the code, there was also a debug parameter somewhere in the model file : https://github.com/Ealrann/VSand/blob/master/org.sheepy.vsand/src/main/resources/Application.vsand).

If you need to play with instances/check what is enabled, the entry point is there: https://github.com/Ealrann/Lily-Vulkan/blob/5a58144bba85dbdba6917167df8a5819bffada41/org.sheepy.lily.vulkan.core/src/main/java/org/sheepy/lily/vulkan/core/instance/VulkanInstance.java#L64

Ealrann commented 4 years ago

Note, I updated the Readme with some useful information to clone or update the repository (since it's specific), and the required jdk version (14): https://github.com/Ealrann/VSand/blob/master/README.md#contribution

Don't hesitate if you need more information, I'm glad to help !

kvark commented 4 years ago

Thank you for the quick and detailed response! Perhaps this is a real niche case, but I want to run VSand in debug mode where VK_EXT_debug_report isn't available.

Edit: also, nowhere did I intentionally selected debug. I just followed the steps to check this out and run.

kvark commented 4 years ago

Actually, maybe the whole problem is different. I saw the following error/stack:

> Task :org.sheepy.vsand:run FAILED
Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.window.Window.getRequiredInstanceExtensions(Window.java:197)
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.engine.extension.EngineExtensionRequirement.getRequiredInstanceExtensions(EngineExtensionRequirement.java:33)
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.instance.VulkanInstance.allocate(VulkanInstance.java:64)
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.engine.VulkanEngineAdapter.createInstance(VulkanEngineAdapter.java:279)
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.engine.VulkanEngineAdapter.load(VulkanEngineAdapter.java:128)
        at org.sheepy.lily.vulkan.core/org.sheepy.lily.vulkan.core.engine.VulkanEngineAdapter.start(VulkanEngineAdapter.java:120)
        at org.sheepy.lily.core.impl/org.sheepy.lily.core.cadence.common.Cadencer.load(Cadencer.java:96)
        at org.sheepy.lily.core.impl/org.sheepy.lily.core.application.ApplicationAdapter.launch(ApplicationAdapter.java:34)
        at org.sheepy.lily.core.api/org.sheepy.lily.core.api.LilyLauncher.launch(LilyLauncher.java:15)
        at org.sheepy.vsand/org.sheepy.vsand.VSandApplicationLauncher.main(VSandApplicationLauncher.java:23)
Caused by: java.lang.NullPointerException: A required function is missing: _glfw_vulkan_library
        at org.lwjgl/org.lwjgl.system.APIUtil.requiredFunctionMissing(APIUtil.java:141)
        at org.lwjgl/org.lwjgl.system.APIUtil.apiGetFunctionAddress(APIUtil.java:134)
        at org.lwjgl.glfw/org.lwjgl.glfw.GLFWVulkan.<clinit>(GLFWVulkan.java:54)
        ... 10 more

I checked the code, saw the extension, and assumed the lack of it is the problem (it's indeed not supported yet on my driver). But in fact maybe this is just some kind of a crash calling a GLFW function because it didn't link to GLFW correctly?

Ealrann commented 4 years ago

Indeed, it looks like something is not linked correctly between GLFW and Vulkan. I transferred the error to the LWJGL developer, maybe I'll know more soon.

I believe you are working on macOs ? If so, here some information about that:

EDIT: I just received a message from the LWJGL developper: looks like it's related to this issue: https://github.com/LWJGL/lwjgl3/issues/502 So let's try the last LWJGL snapshot. I'll come back soon with a dedicated branch.

Ealrann commented 4 years ago

Ok, no need for a new branch, the code looks already compatible. You just have to modify two files:

  1. Lily-vulkan/gradle.properties : Replace lwjglVersion = 3.2.3 to lwjglVersion = 3.2.4-SNAPSHOT
  2. VSand/VSand/build.gradle => Add a maven url in the afterEvaluate block:
    afterEvaluate {
    repositories {
        jcenter()
        maven {
            maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
            [...same as before...]
        }
    }
    }
kvark commented 4 years ago

Yes, I'm on macOS. With these changes I'm getting

> Configure project :
Found module name 'org.sheepy.vsand'

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':org.sheepy.vsand:run'.
> Could not resolve all task dependencies for configuration ':org.sheepy.vsand:runtimeClasspath'.
   > Could not find emf.standalone:org.eclipse.emf.common:2.21.0.
     Searched in the following locations:
       - https://jcenter.bintray.com/emf/standalone/org.eclipse.emf.common/2.21.0/org.eclipse.emf.common-2.21.0.pom
       - https://oss.sonatype.org/content/repositories/snapshots/emf/standalone/org.eclipse.emf.common/2.21.0/org.eclipse.emf.common-2.21.0.pom
     Required by:
         project :org.sheepy.vsand > project :Lily-vulkan:org.sheepy.lily.vulkan.api > project :Lily-vulkan:org.sheepy.lily.game.api > project :Lily-core:org.sheepy.lily.core.api
   > Could not find emf.standalone:org.eclipse.emf.ecore:2.21.0.
     Searched in the following locations:
       - https://jcenter.bintray.com/emf/standalone/org.eclipse.emf.ecore/2.21.0/org.eclipse.emf.ecore-2.21.0.pom
       - https://oss.sonatype.org/content/repositories/snapshots/emf/standalone/org.eclipse.emf.ecore/2.21.0/org.eclipse.emf.ecore-2.21.0.pom
     Required by:
         project :org.sheepy.vsand > project :Lily-vulkan:org.sheepy.lily.vulkan.api > project :Lily-vulkan:org.sheepy.lily.game.api > project :Lily-core:org.sheepy.lily.core.api
   > Could not find emf.standalone:org.eclipse.emf.ecore.xmi:2.21.0.
     Searched in the following locations:
       - https://jcenter.bintray.com/emf/standalone/org.eclipse.emf.ecore.xmi/2.21.0/org.eclipse.emf.ecore.xmi-2.21.0.pom
       - https://oss.sonatype.org/content/repositories/snapshots/emf/standalone/org.eclipse.emf.ecore.xmi/2.21.0/org.eclipse.emf.ecore.xmi-2.21.0.pom
     Required by:
         project :org.sheepy.vsand > project :Lily-vulkan:org.sheepy.lily.vulkan.api > project :Lily-vulkan:org.sheepy.lily.game.api > project :Lily-core:org.sheepy.lily.core.api

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Ealrann commented 4 years ago

Mhh, could be an error with the afterEvaluate, the full block should be now:

afterEvaluate {
    repositories {
        jcenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven {
            url "https://maven.pkg.github.com/ealrann/emf-standalone"
            credentials {
                username = findProperty("github.username")
                password = findProperty("github.token")
            }
        }
    }
}
kvark commented 4 years ago

Oh great, I think that gets me there. Now crashing in MoltenVK:

Using Graphic Device: Intel(R) Iris(TM) Graphics 550 (10040)
[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
Compilation failed: 

program_source:62:15: error: zero-length arrays are not permitted in C++
    uint4 _m0[_1509];
              ^~~~~
.
[mvk-error] VK_ERROR_INVALID_SHADER_NV: Compute shader function could not be compiled into pipeline. See previous logged error.

I have this extra line added to "org.sheepy.vsand/build.gradle":

applicationDefaultJvmArgs = ["-Dorg.lwjgl.util.DebugLoader=true", "-Dorg.lwjgl.glfw.checkThread0=false", "-Dorg.lwjgl.librarypath=/Users/dmalyshau/Code/vulkansdk/macOS/lib/", "-XstartOnFirstThread"]

I also have the VK_ICD_FILENAMES pointing to gfx-portability, so I'm surprised we see MVK used. Does VSand use the Vulkan loader interface, or is it trying to load MoltenVK manually?

Ealrann commented 4 years ago

I totally rely on LWJGL for this part. Maybe this post from Spasi could help: http://forum.lwjgl.org/index.php?topic=6875.msg36239#msg36239

kvark commented 4 years ago

Thanks, that explains it! Please feel free to close this issue, unless you want to keep it open for lwjgl update.