1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add shader baker to project exporter.

Metal Support contributed by Migeran (https://migeran.com) and Stuart Carnie.

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
Co-authored-by: Gergely Kis <gergely.kis@migeran.com>
This commit is contained in:
Dario
2025-01-13 16:13:39 -03:00
parent 99f5a3d665
commit 5a30a7e7cd
112 changed files with 5786 additions and 4203 deletions

View File

@@ -30,14 +30,14 @@
#include "rendering_device_binds.h"
#include "modules/modules_enabled.gen.h" // For glslang.
#ifdef MODULE_GLSLANG_ENABLED
#include "modules/glslang/shader_compile.h"
#endif
#include "shader_include_db.h"
Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
ERR_FAIL_NULL_V_MSG(
RenderingDevice::get_singleton(),
ERR_UNAVAILABLE,
"Cannot import custom .glsl shaders when running without a RenderingDevice. This can happen if you are using the headless more or the Compatibility renderer.");
Vector<String> lines = p_text.split("\n");
bool reading_versions = false;
@@ -192,8 +192,12 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
}
code = code.replace("VERSION_DEFINES", E.value);
String error;
Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false);
#ifdef MODULE_GLSLANG_ENABLED
Vector<uint8_t> spirv = compile_glslang_shader(RD::ShaderStage(i), ShaderIncludeDB::parse_include_files(code), RD::SHADER_LANGUAGE_VULKAN_VERSION_1_1, RD::SHADER_SPIRV_VERSION_1_3, &error);
bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv);
#else
error = "Shader compilation is not supported because glslang was not enabled.";
#endif
if (!error.is_empty()) {
error += String() + "\n\nStage '" + stage_str[i] + "' source code: \n\n";
Vector<String> sclines = code.split("\n");