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

Prevent shaders from generating code before the constructor finishes. [3.x] #52475

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scene/2d/canvas_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void CanvasItemMaterial::flush_changes() {
void CanvasItemMaterial::_queue_shader_change() {
material_mutex.lock();

if (!element.in_list()) {
if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}

Expand Down Expand Up @@ -313,6 +313,7 @@ CanvasItemMaterial::CanvasItemMaterial() :

current_key.key = 0;
current_key.invalid_key = 1;
is_initialized = true;
_queue_shader_change();
}

Expand Down
1 change: 1 addition & 0 deletions scene/2d/canvas_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CanvasItemMaterial : public Material {
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;

bool is_initialized = false;
BlendMode blend_mode;
LightMode light_mode;
bool particles_animation;
Expand Down
3 changes: 2 additions & 1 deletion scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ void SpatialMaterial::flush_changes() {
void SpatialMaterial::_queue_shader_change() {
material_mutex.lock();

if (!element.in_list()) {
if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}

Expand Down Expand Up @@ -2317,6 +2317,7 @@ SpatialMaterial::SpatialMaterial() :

current_key.key = 0;
current_key.invalid_key = 1;
is_initialized = true;
_queue_shader_change();
}

Expand Down
1 change: 1 addition & 0 deletions scene/resources/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ class SpatialMaterial : public Material {
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;

bool is_initialized = false;
Color albedo;
float specular;
float metallic;
Expand Down
3 changes: 2 additions & 1 deletion scene/resources/particles_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void ParticlesMaterial::flush_changes() {
void ParticlesMaterial::_queue_shader_change() {
material_mutex.lock();

if (!element.in_list()) {
if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}

Expand Down Expand Up @@ -1367,6 +1367,7 @@ ParticlesMaterial::ParticlesMaterial() :
current_key.key = 0;
current_key.invalid_key = 1;

is_initialized = true;
_queue_shader_change();
}

Expand Down
1 change: 1 addition & 0 deletions scene/resources/particles_material.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class ParticlesMaterial : public Material {
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;

bool is_initialized = false;
Vector3 direction;
float spread;
float flatness;
Expand Down