Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godot freezes when transforming the the LIGHT vector from a view space to a world space #67256

Closed
rumbogs opened this issue Oct 11, 2022 · 4 comments · Fixed by #76290
Closed

Comments

@rumbogs
Copy link

rumbogs commented Oct 11, 2022

Godot version

Godot Engine v4.0.beta.custom_build.56563ef09 - https://godotengine.org
Vulkan API 1.1.211 - Using Vulkan Device #0: AMD - AMD Radeon Pro 560X

System information

MacOS, Radeon Pro 560X

Issue description

Pretty simple scenario. Follow the steps to reproduce it.

Note: This also happens on Windows, it's just that Godot never freezes and the shader material is ignored altogether.

Using the CLI, I get a bunch of errors, but I think it boils down to:

ERROR: Error compiling Fragment shader, variant #11 (
#define USE_LIGHTMAP
).
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:276)
ERROR: Failed parse:
WARNING: 0:74: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
         "precision mediump int; precision highp float;" 
ERROR: 0:793: 'scene_data' : undeclared identifier 
ERROR: 0:793: 'inv_view_matrix' : vector swizzle too long 
ERROR: 0:793: 'inv_view_matrix' : unknown swizzle selection 
ERROR: 0:793: 'inv_view_matrix' : unknown swizzle selection 
ERROR: 0:793: 'inv_view_matrix' : unknown swizzle selection 
ERROR: 0:793: 'inv_view_matrix' : unknown swizzle selection 
ERROR: 0:793: '' : compilation terminated 
ERROR: 7 compilation errors.  No code generated.

The same error happens in other fragment shaders, like :

ERROR: Error compiling Fragment shader, variant #13 (
#define USE_MULTIVIEW
).

I can post them all if needed.

Steps to reproduce

  1. Create a clean 3d scene.
  2. Create a mesh instance.
  3. Assign a shader material to it.
  4. Create a light shader for it and add vec4 light_world = INV_VIEW_MATRIX + vec4(LIGHT, 1.0); to it. (I think just using INV_VIEW_MATRIX in the light shader breaks)
  5. Godot freezes.

Minimal reproduction project

No response

@clayjohn
Copy link
Member

Could you please update your post to say what version of Godot you are using and what (if any) error messages are printed when Godot freezes (you may have to run Godot from the command line to get the error messages)?

@tessarakkt
Copy link

tessarakkt commented Nov 26, 2022

I get similar symptoms with beta6 on Arch Linux as well.

It seems to occur after adding a reference to any of the built in matrices, not just INV_VIEW_MATRIX. It appears to be isolated to light().

Normally there is no freeze, but it does throw errors and ignore the material as described for Windows. However if I try to look at the debuggers error tab after it has thrown its 49 errors (it is consistently 49 logged there) for more than a few seconds, it will freeze the editor. It is shown to be fixed at 25-26% CPU usage at this point (dual core Intel i3 + hyper threading).

There does not appear to be a message thrown either to output or CLI when the editor freezes when viewing the already thrown shader compilation errors.

These errors are thrown to the output after referencing any built in matrix from light():

  servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:178 - Condition "!shader_singleton->shader.version_is_valid(version)" is true.
  drivers/vulkan/rendering_device_vulkan.cpp:5834 - Condition "!shader" is true. Returning: RID()
  drivers/vulkan/rendering_device_vulkan.cpp:6319 - Condition "!us" is true.

When trying to run the shader in game, I get the same errors:

   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:281)
ERROR: Error compiling Fragment shader, variant #23 (
#define USE_LIGHTMAP

#define USE_MULTIVIEW

#define MOTION_VECTORS
).
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:277)
ERROR: Failed parse:
WARNING: 0:84: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
         "precision mediump int; precision highp float;" 
ERROR: 0:814: 'scene_data' : undeclared identifier 
ERROR: 0:814: 'view_matrix' : vector swizzle too long 
ERROR: 0:814: 'view_matrix' : unknown swizzle selection 
ERROR: 0:814: 'view_matrix' : unknown swizzle selection 
ERROR: 0:814: 'view_matrix' : unknown swizzle selection 
ERROR: 0:814: 'view_matrix' : vector swizzle selection out of range 
ERROR: 0:814: '' : compilation terminated 
ERROR: 7 compilation errors.  No code generated.

I will also add this in case the missing functionality from Haswell Vulkan support is at play here, but where it matches symptoms from other symptoms I would think not.

Godot Engine v4.0.beta6.official.7f8ecffa5 - https://godotengine.org
MESA-INTEL: warning: Haswell Vulkan support is incomplete
Vulkan API 1.2.0 - Using Vulkan Device #0: Intel - Intel(R) HD Graphics 4400 (HSW GT2)

@clayjohn
Copy link
Member

@tessarakkt thanks for the additional information! It looks there are 2 bugs here:

  1. The INV_VIEW_MATRIX isn't properly exposed in light() shaders leading to a compile error (this is an easy fix)
  2. The engine freezes whenever there is an internal Godot shader compile error (this will be much for difficult to fix and is a known issue)

@JohanAR
Copy link
Contributor

JohanAR commented Apr 20, 2023

Doesn't seem like the engine is freezing now, however the editor doesn't give any feedback indicating that the shader compilation failed. If I removed the missing matrix built-in then it resumed normal operation.

@akien-mga akien-mga modified the milestones: 4.x, 4.1 Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants