Merge pull request #51723 from Chaosus/fix_shader_compile_error

Makes a clear error message if shader compilation failed
This commit is contained in:
Rémi Verschelde 2021-08-16 12:31:39 +02:00 committed by GitHub
commit 87226cef21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 14 deletions

View File

@ -131,9 +131,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {
SceneShaderForwardClustered *shader_singleton = (SceneShaderForwardClustered *)SceneShaderForwardClustered::singleton; SceneShaderForwardClustered *shader_singleton = (SceneShaderForwardClustered *)SceneShaderForwardClustered::singleton;
Error err = shader_singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code); Error err = shader_singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
if (err != OK) { ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
return;
}
if (version.is_null()) { if (version.is_null()) {
version = shader_singleton->shader.version_create(); version = shader_singleton->shader.version_create();

View File

@ -135,8 +135,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {
SceneShaderForwardMobile *shader_singleton = (SceneShaderForwardMobile *)SceneShaderForwardMobile::singleton; SceneShaderForwardMobile *shader_singleton = (SceneShaderForwardMobile *)SceneShaderForwardMobile::singleton;
Error err = shader_singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code); Error err = shader_singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
ERR_FAIL_COND(err != OK);
if (version.is_null()) { if (version.is_null()) {
version = shader_singleton->shader.version_create(); version = shader_singleton->shader.version_create();

View File

@ -1970,8 +1970,7 @@ void RendererCanvasRenderRD::ShaderData::set_code(const String &p_code) {
RendererCanvasRenderRD *canvas_singleton = (RendererCanvasRenderRD *)RendererCanvasRender::singleton; RendererCanvasRenderRD *canvas_singleton = (RendererCanvasRenderRD *)RendererCanvasRender::singleton;
Error err = canvas_singleton->shader.compiler.compile(RS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code); Error err = canvas_singleton->shader.compiler.compile(RS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
ERR_FAIL_COND(err != OK);
if (version.is_null()) { if (version.is_null()) {
version = canvas_singleton->shader.canvas_shader.version_create(); version = canvas_singleton->shader.canvas_shader.version_create();

View File

@ -92,8 +92,7 @@ void RendererSceneSkyRD::SkyShaderData::set_code(const String &p_code) {
RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton;
Error err = scene_singleton->sky.sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code); Error err = scene_singleton->sky.sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
ERR_FAIL_COND(err != OK);
if (version.is_null()) { if (version.is_null()) {
version = scene_singleton->sky.sky_shader.shader.version_create(); version = scene_singleton->sky.sky_shader.shader.version_create();

View File

@ -5268,8 +5268,7 @@ void RendererStorageRD::ParticlesShaderData::set_code(const String &p_code) {
actions.uniforms = &uniforms; actions.uniforms = &uniforms;
Error err = base_singleton->particles_shader.compiler.compile(RS::SHADER_PARTICLES, code, &actions, path, gen_code); Error err = base_singleton->particles_shader.compiler.compile(RS::SHADER_PARTICLES, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
ERR_FAIL_COND(err != OK);
if (version.is_null()) { if (version.is_null()) {
version = base_singleton->particles_shader.shader.version_create(); version = base_singleton->particles_shader.shader.version_create();

View File

@ -142,9 +142,7 @@ public:
ERR_FAIL_COND_V(!variants_enabled[p_variant], RID()); ERR_FAIL_COND_V(!variants_enabled[p_variant], RID());
Version *version = version_owner.getornull(p_version); Version *version = version_owner.getornull(p_version);
if (!version) { ERR_FAIL_COND_V(!version, RID());
return RID();
}
if (version->dirty) { if (version->dirty) {
_compile_version(version); _compile_version(version);