mirror of
https://github.com/godotengine/godot.git
synced 2024-12-27 11:24:59 +08:00
Avoid error spam when shaders fail to compile by freeing shader_data version when compilation fails
This commit is contained in:
parent
aa8d9b83f6
commit
fce34f22a2
@ -4642,7 +4642,7 @@ void RenderForwardClustered::mesh_generate_pipelines(RID p_mesh, bool p_backgrou
|
||||
void *mesh_surface = mesh_storage->mesh_get_surface(p_mesh, i);
|
||||
void *mesh_surface_shadow = mesh_surface;
|
||||
SceneShaderForwardClustered::MaterialData *material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(materials[i], RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (material == nullptr) {
|
||||
if (material == nullptr || !material->shader_data->is_valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,14 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {
|
||||
|
||||
MutexLock lock(SceneShaderForwardClustered::singleton_mutex);
|
||||
Error err = SceneShaderForwardClustered::singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
|
||||
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
|
||||
|
||||
if (err != OK) {
|
||||
if (version.is_valid()) {
|
||||
SceneShaderForwardClustered::singleton->shader.version_free(version);
|
||||
version = RID();
|
||||
}
|
||||
ERR_FAIL_MSG("Shader compilation failed.");
|
||||
}
|
||||
|
||||
if (version.is_null()) {
|
||||
version = SceneShaderForwardClustered::singleton->shader.version_create();
|
||||
|
@ -294,7 +294,7 @@ void RenderForwardMobile::mesh_generate_pipelines(RID p_mesh, bool p_background_
|
||||
void *mesh_surface = mesh_storage->mesh_get_surface(p_mesh, i);
|
||||
void *mesh_surface_shadow = mesh_surface;
|
||||
SceneShaderForwardMobile::MaterialData *material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(materials[i], RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (material == nullptr) {
|
||||
if (material == nullptr || !material->shader_data->is_valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,14 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {
|
||||
|
||||
MutexLock lock(SceneShaderForwardMobile::singleton_mutex);
|
||||
Error err = SceneShaderForwardMobile::singleton->compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
|
||||
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
|
||||
|
||||
if (err != OK) {
|
||||
if (version.is_valid()) {
|
||||
SceneShaderForwardMobile::singleton->shader.version_free(version);
|
||||
version = RID();
|
||||
}
|
||||
ERR_FAIL_MSG("Shader compilation failed.");
|
||||
}
|
||||
|
||||
if (version.is_null()) {
|
||||
version = SceneShaderForwardMobile::singleton->shader.version_create();
|
||||
|
@ -1517,7 +1517,13 @@ void RendererCanvasRenderRD::CanvasShaderData::set_code(const String &p_code) {
|
||||
MutexLock lock(canvas_singleton->shader.mutex);
|
||||
|
||||
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.");
|
||||
if (err != OK) {
|
||||
if (version.is_valid()) {
|
||||
canvas_singleton->shader.canvas_shader.version_free(version);
|
||||
version = RID();
|
||||
}
|
||||
ERR_FAIL_MSG("Shader compilation failed.");
|
||||
}
|
||||
|
||||
uses_screen_texture_mipmaps = gen_code.uses_screen_texture_mipmaps;
|
||||
uses_screen_texture = gen_code.uses_screen_texture;
|
||||
@ -1593,9 +1599,13 @@ uint64_t RendererCanvasRenderRD::CanvasShaderData::get_vertex_input_mask(ShaderV
|
||||
}
|
||||
|
||||
bool RendererCanvasRenderRD::CanvasShaderData::is_valid() const {
|
||||
RendererCanvasRenderRD *canvas_singleton = static_cast<RendererCanvasRenderRD *>(RendererCanvasRender::singleton);
|
||||
MutexLock lock(canvas_singleton->shader.mutex);
|
||||
return canvas_singleton->shader.canvas_shader.version_is_valid(version);
|
||||
if (version.is_valid()) {
|
||||
RendererCanvasRenderRD *canvas_singleton = static_cast<RendererCanvasRenderRD *>(RendererCanvasRender::singleton);
|
||||
MutexLock lock(canvas_singleton->shader.mutex);
|
||||
return canvas_singleton->shader.canvas_shader.version_is_valid(version);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RendererCanvasRenderRD::CanvasShaderData::CanvasShaderData() {
|
||||
|
Loading…
Reference in New Issue
Block a user