godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.48k stars 21.26k forks source link

Compute Shader res compiled by PC editor cannot be exported to Android for use #77200

Open scgm0 opened 1 year ago

scgm0 commented 1 year ago

Godot version

4.0.2

System information

PC: MANJARO-6.1.26 GTX1650 PE: HarmonyOS-3.0 Huawei Kirin980

Issue description

When exporting Compute Shader project to Android, I found that glsl failed to load, but importing the project to Android editor works fine, I found the gap lies in . /godot/imported, after replacing the Compute Shader res file in apk with the res file generated by Android editor, the app can be used normally.

PC: image PE: Screenshot_20230518194644 There is a significant size difference in the res file, and I don't know if this is related to the problem.

Steps to reproduce

  1. Import the computational shader project into the pc and pe editors respectively.
  2. Export Android apk in pc editor and install it, Compute Shader fails
  3. Replace the res file inside the apk with the res file generated by the Android editor and install it, Compute Shader works normally

Minimal reproduction project

https://github.com/godotengine/godot-demo-projects/tree/master/misc/compute_shader_heightmap

Calinou commented 1 year ago

Note that mobile GPUs have poor support for compute shaders across the board, so using compute shaders on mobile is not recommended.

scgm0 commented 1 year ago

Note that mobile GPUs have poor support for compute shaders across the board, so using compute shaders on mobile is not recommended.请注意,移动 GPU 对计算着色器的全面支持很差,因此不建议在移动设备上使用计算着色器。

Compute Shader works on my phone, just not with .godot for pc.Could this be a problem caused by different vulkan versions?

AThousandShips commented 1 year ago

Does it work for these features though? Supporting it isn't a question of all or nothing

scgm0 commented 1 year ago

Does it work for these features though? Supporting it isn't a question of all or nothing它对这些功能有效吗?支持它不是全有或全无的问题

My English is poor, can you speak more clearly?

AThousandShips commented 1 year ago

Maybe there are features that are used that android does not support, but other compute shaders do not use

scgm0 commented 1 year ago

Maybe there are features that are used that android does not support, but other compute shaders do not use可能有使用android不支持的功能,但其他计算着色器不使用

Ah, Compute Shader is fully available on my phone, including the official demo (https://github.com/godotengine/godot-demo-projects/tree/master/misc/compute_shader_heightmap) and my own noise map generation , the actual problem is that the res files compiled by glsl do not have cross-platform functions (maybe it is a vk version problem?), and the res files generated by pc cannot be used on Android, and only the res files generated by the Android editor can be used.

AThousandShips commented 1 year ago

Are you using Forward+ or Mobile when exporting from PC?

scgm0 commented 1 year ago

Are you using Forward+ or Mobile when exporting from PC?从 PC 导出时,您使用的是 Forward+ 还是 Mobile

I have tried it all, and it seems to have no effect on the res file. The res files generated by the pc editor and the pe editor are inconsistent even under the same rendering backend (you can see a slight size difference in the screenshot)

AThousandShips commented 1 year ago

Also the file size only differs by 8 bytes, which could be just two to eight unicode letters

scgm0 commented 1 year ago

Also the file size only differs by 8 bytes, which could be just two to eight unicode letters此外,文件大小仅相差 8 个字节,可能只是两到八个 unicode 字母

The project and files used by pc editor and pe editor are the same, only the platform, absolute path and vulkan version are inconsistent.

blubbers122 commented 9 months ago

Note that mobile GPUs have poor support for compute shaders across the board, so using compute shaders on mobile is not recommended.

Is this something that can be worked around on the project or engine level, or is it an unavoidable limitation depending on the phone's GPU?

Calinou commented 9 months ago

Is this something that can be worked around on the project or engine level, or is it an unavoidable limitation depending on the phone's GPU?

It's due to the graphics driver, which you have no control over as an application developer. It's possible for users to sideload graphics drivers for some GPUs on Android, but this is not allowed when shipping apps on Google Play.