jmorton06 / Lumos

Cross-Platform C++ 2D/3D game engine
MIT License
1.29k stars 140 forks source link

Could not launch Sandbox on MacOS Catalina due to Vulkan problem #44

Closed zettdaymond closed 4 years ago

zettdaymond commented 4 years ago
~/Lumos (dev) $ ./bin/Debug/Sandbox
[02:38:25] LUMOS: Lumos Engine - Version 0.2.2
[02:38:25] LUMOS: Initialised JobSystem with [8 cores] [8 threads]
[02:38:25] LUMOS: Initializing System
[02:38:25] LUMOS: Creating window - Title : Sandbox, Width : 1280, Height : 800
[02:38:26] LUMOS: Initialised GLFW version : 3.3.0 Cocoa NSGL EGL OSMesa
[02:38:26] LUMOS: Battery Info - Percentage : 94 , Time Left 9540s , State : On Battery
[02:38:26] LUMOS: Vulkan : 1.0.108
[02:38:26] LUMOS: GPU : AMD Radeon R9 M370X
[02:38:26] LUMOS: Vendor ID : 4098
[02:38:26] LUMOS: Device Type : DISCRETE GPU
[02:38:26] LUMOS: Driver Version : 0.2.1843
[mvk-error] VK_ERROR_FEATURE_NOT_PRESENT: vkCreateDevice(): Requested feature is not available on this device.
[02:38:26] LUMOS: [VULKAN] VKDevice::Instance()->GetDevice() vkCreateDevice() failed!
Segmentation fault: 11

But all tests passed:

~/Lumos (dev) $ ./bin/Debug/Tests
[02:39:11] LUMOS: Lumos Engine - Version 0.2.2
[02:39:11] LUMOS: Initialised JobSystem with [8 cores] [8 threads]
[02:39:11] LUMOS: Initializing System
[02:39:11] APP: Vector2 Test Passed
[02:39:11] APP: Vector3 Test Passed
[02:39:11] APP: Vector4 Test Passed
[02:39:11] APP: Reference Test Passed
===============================================================================
All tests passed (259 assertions in 5 test cases)

Reproduced on master and dev branch

jmorton06 commented 4 years ago

Think it's to do with the Vulkan version. Works for me and I'm using 1.0.85. Got this last time I tried to update it. I'll try again to a more update to a more recent version.

jmorton06 commented 4 years ago

Seems like on newer Vulkan/Moltenvk versions commenting out //deviceFeatures.shaderCullDistance = VK_TRUE; Before vkCreateDevice fixes the issue.

zettdaymond commented 4 years ago

After update to the latest dev branch, I got those errors:

[20:30:56] LUMOS: Lumos Engine - Version 0.2.2
[20:30:56] LUMOS: Initialised JobSystem with [8 cores] [8 threads]
[20:30:56] LUMOS: Initializing System
[20:30:56] LUMOS: Creating window - Title : Sandbox, Width : 1280, Height : 800
[20:30:56] LUMOS: Initialised GLFW version : 3.3.0 Cocoa NSGL EGL OSMesa
[20:30:57] LUMOS: Battery Info - Percentage : 19 , Time Left 2280s , State : On Battery
[20:30:57] LUMOS: Vulkan : 1.0.108
[20:30:57] LUMOS: GPU : AMD Radeon R9 M370X
[20:30:57] LUMOS: Vendor ID : 4098
[20:30:57] LUMOS: Device Type : DISCRETE GPU
[20:30:57] LUMOS: Driver Version : 0.2.1843
[20:30:57] LUMOS: Profiler Enabled
[20:30:57] LUMOS: Creating SoundSystem!
[20:30:57] LUMOS: Found the following devices: Built-in Output
[20:30:57] LUMOS: SoundSystem created with device: Built-in Output
[20:30:57] APP: [SceneManager] - Enqueued scene : SceneModelViewer
[20:30:57] APP: [SceneManager] - Enqueued scene : 2D Test
[20:30:57] APP: [SceneManager] - Enqueued scene : Physics Scene
[20:30:57] APP: [SceneManager] - Enqueued scene : Terrain Test
[20:30:57] APP: [SceneManager] - Enqueued scene : Material Test
[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
Compilation failed: 

program_source:190:158: error: expected ')'
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                             ^
program_source:190:16: note: to match this '('
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
               ^
program_source:232:36: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float3 Lh = normalize(Li + material.View);
                                   ^~~~~~~~
                                   Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:233:42: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float cosLi = fast::max(0.0, dot(material.Normal, Li));
                                         ^~~~~~~~
                                         Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:234:42: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float cosLh = fast::max(0.0, dot(material.Normal, Lh));
                                         ^~~~~~~~
                                         Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:236:48: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float param_1 = fast::max(0.0, dot(Lh, material.View));
                                               ^~~~~~~~
                                               Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:239:25: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float param_3 = material.Roughness;
                        ^~~~~~~~
                        Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:242:25: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float param_5 = material.NDotV;
                        ^~~~~~~~
                        Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:243:25: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float param_6 = material.Roughness;
                        ^~~~~~~~
                        Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:245:48: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float3 kd = (float3(1.0) - F) * (1.0 - material.Specular.x);
                                               ^~~~~~~~
                                               Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:246:35: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float3 diffuseBRDF = kd * material.Albedo.xyz;
                                  ^~~~~~~~
                                  Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
program_source:247:119: error: use of undeclared identifier 'material'; did you mean 'Material'?
        float3 specularBRDF = ((F * D) * G) / float3(fast::max(9.9999997473787516355514526367188e-06, (4.0 * cosLi) * material.NDotV));
                                                                                                                      ^~~~~~~~
                                                                                                                      Material
program_source:190:149: note: 'Material' declared here
float3 Lighting(thread const float3& F0, thread const float& shadow, thread const float3& wsPos, constant UniformBufferLight& ubo, thread Material& Material material)
                                                                                                                                                    ^
.
[mvk-error] VK_ERROR_INVALID_SHADER_NV: Fragment shader function could not be compiled into pipeline. See previous logged error.
[20:30:58] LUMOS: [SceneManager] - Scene switched to : Physics Scene
Segmentation fault: 11

Looks like it is my hardware/MoltenVK problem. Anyway, thank you for answers.

jmorton06 commented 4 years ago

Hmm strange the shader not compiling on a different moltenvk version. I've submitted a potential fix.

zettdaymond commented 4 years ago

Fix helped! Thank you.