@@ -2377,6 +2377,13 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari
2377
2377
}
2378
2378
}
2379
2379
2380
+ void RendererStorageRD::MaterialData::free_parameters_uniform_set(RID p_uniform_set) {
2381
+ if (p_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(p_uniform_set)) {
2382
+ RD::get_singleton()->uniform_set_set_invalidation_callback(p_uniform_set, nullptr, nullptr);
2383
+ RD::get_singleton()->free(p_uniform_set);
2384
+ }
2385
+ }
2386
+
2380
2387
bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompilerRD::GeneratedCode::Texture> &p_texture_uniforms, const Map<StringName, RID> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier) {
2381
2388
if ((uint32_t)ubo_data.size() != p_ubo_size) {
2382
2389
p_uniform_dirty = true;
@@ -2393,6 +2400,7 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
2393
2400
2394
2401
//clear previous uniform set
2395
2402
if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
2403
+ RD::get_singleton()->uniform_set_set_invalidation_callback(uniform_set, nullptr, nullptr);
2396
2404
RD::get_singleton()->free(uniform_set);
2397
2405
uniform_set = RID();
2398
2406
}
@@ -2412,6 +2420,7 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
2412
2420
2413
2421
//clear previous uniform set
2414
2422
if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
2423
+ RD::get_singleton()->uniform_set_set_invalidation_callback(uniform_set, nullptr, nullptr);
2415
2424
RD::get_singleton()->free(uniform_set);
2416
2425
uniform_set = RID();
2417
2426
}
@@ -2454,9 +2463,19 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
2454
2463
2455
2464
uniform_set = RD::get_singleton()->uniform_set_create(uniforms, p_shader, p_shader_uniform_set);
2456
2465
2466
+ RD::get_singleton()->uniform_set_set_invalidation_callback(uniform_set, _material_uniform_set_erased, &self);
2467
+
2457
2468
return true;
2458
2469
}
2459
2470
2471
+ void RendererStorageRD::_material_uniform_set_erased(const RID &p_set, void *p_material) {
2472
+ RID rid = *(RID *)p_material;
2473
+ Material *material = base_singleton->material_owner.getornull(rid);
2474
+ if (material) {
2475
+ material->dependency.changed_notify(DEPENDENCY_CHANGED_MATERIAL);
2476
+ }
2477
+ }
2478
+
2460
2479
void RendererStorageRD::material_force_update_textures(RID p_material, ShaderType p_shader_type) {
2461
2480
Material *material = material_owner.getornull(p_material);
2462
2481
if (material->shader_type != p_shader_type) {
@@ -5367,9 +5386,7 @@ bool RendererStorageRD::ParticlesMaterialData::update_parameters(const Map<Strin
5367
5386
}
5368
5387
5369
5388
RendererStorageRD::ParticlesMaterialData::~ParticlesMaterialData() {
5370
- if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
5371
- RD::get_singleton()->free(uniform_set);
5372
- }
5389
+ free_parameters_uniform_set(uniform_set);
5373
5390
}
5374
5391
5375
5392
RendererStorageRD::MaterialData *RendererStorageRD::_create_particles_material_func(ParticlesShaderData *p_shader) {
0 commit comments