Merge pull request #54489 from briansemrau/texture-delete-update
This commit is contained in:
commit
8b8e858778
|
@ -8372,11 +8372,11 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
|
|||
} else if (uniform_set_owner.owns(p_id)) {
|
||||
UniformSet *uniform_set = uniform_set_owner.get_or_null(p_id);
|
||||
frames[frame].uniform_sets_to_dispose_of.push_back(*uniform_set);
|
||||
if (uniform_set->invalidated_callback != nullptr) {
|
||||
uniform_set->invalidated_callback(p_id, uniform_set->invalidated_callback_userdata);
|
||||
}
|
||||
|
||||
uniform_set_owner.free(p_id);
|
||||
|
||||
if (uniform_set->invalidated_callback != nullptr) {
|
||||
uniform_set->invalidated_callback(uniform_set->invalidated_callback_userdata);
|
||||
}
|
||||
} else if (render_pipeline_owner.owns(p_id)) {
|
||||
RenderPipeline *pipeline = render_pipeline_owner.get_or_null(p_id);
|
||||
frames[frame].render_pipelines_to_dispose_of.push_back(*pipeline);
|
||||
|
|
|
@ -463,7 +463,6 @@ SceneShaderForwardClustered::MaterialData::~MaterialData() {
|
|||
RendererStorageRD::MaterialData *SceneShaderForwardClustered::_create_material_func(ShaderData *p_shader) {
|
||||
MaterialData *material_data = memnew(MaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,6 @@ public:
|
|||
}
|
||||
|
||||
struct MaterialData : public RendererStorageRD::MaterialData {
|
||||
uint64_t last_frame;
|
||||
ShaderData *shader_data;
|
||||
RID uniform_set;
|
||||
uint64_t last_pass = 0;
|
||||
|
|
|
@ -452,7 +452,6 @@ SceneShaderForwardMobile::MaterialData::~MaterialData() {
|
|||
RendererStorageRD::MaterialData *SceneShaderForwardMobile::_create_material_func(ShaderData *p_shader) {
|
||||
MaterialData *material_data = memnew(MaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,6 @@ public:
|
|||
}
|
||||
|
||||
struct MaterialData : public RendererStorageRD::MaterialData {
|
||||
uint64_t last_frame;
|
||||
ShaderData *shader_data;
|
||||
RID uniform_set;
|
||||
uint64_t last_pass = 0;
|
||||
|
|
|
@ -1377,14 +1377,6 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
|
|||
if (md->shader_data->uses_time) {
|
||||
time_used = true;
|
||||
}
|
||||
if (md->last_frame != RendererCompositorRD::singleton->get_frame_number()) {
|
||||
md->last_frame = RendererCompositorRD::singleton->get_frame_number();
|
||||
if (!RD::get_singleton()->uniform_set_is_valid(md->uniform_set)) {
|
||||
// uniform set may be gone because a dependency was erased. In this case, it will happen
|
||||
// if a texture is deleted, so just re-create it.
|
||||
storage->material_force_update_textures(material, RendererStorageRD::SHADER_TYPE_2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2240,7 +2232,6 @@ RendererCanvasRenderRD::MaterialData::~MaterialData() {
|
|||
RendererStorageRD::MaterialData *RendererCanvasRenderRD::_create_material_func(ShaderData *p_shader) {
|
||||
MaterialData *material_data = memnew(MaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -200,7 +200,6 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
}
|
||||
|
||||
struct MaterialData : public RendererStorageRD::MaterialData {
|
||||
uint64_t last_frame;
|
||||
ShaderData *shader_data;
|
||||
RID uniform_set;
|
||||
|
||||
|
|
|
@ -3993,7 +3993,6 @@ RendererStorageRD::ShaderData *RendererSceneRenderRD::_create_fog_shader_funcs()
|
|||
RendererStorageRD::MaterialData *RendererSceneRenderRD::_create_fog_material_func(FogShaderData *p_shader) {
|
||||
FogMaterialData *material_data = memnew(FogMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -942,7 +942,6 @@ private:
|
|||
};
|
||||
|
||||
struct FogMaterialData : public RendererStorageRD::MaterialData {
|
||||
uint64_t last_frame;
|
||||
FogShaderData *shader_data;
|
||||
RID uniform_set;
|
||||
bool uniform_set_updated;
|
||||
|
|
|
@ -750,7 +750,6 @@ RendererStorageRD::ShaderData *RendererSceneSkyRD::_create_sky_shader_funcs() {
|
|||
RendererStorageRD::MaterialData *RendererSceneSkyRD::_create_sky_material_func(SkyShaderData *p_shader) {
|
||||
SkyMaterialData *material_data = memnew(SkyMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,6 @@ public:
|
|||
} sky_shader;
|
||||
|
||||
struct SkyMaterialData : public RendererStorageRD::MaterialData {
|
||||
uint64_t last_frame;
|
||||
SkyShaderData *shader_data;
|
||||
RID uniform_set;
|
||||
bool uniform_set_updated;
|
||||
|
|
|
@ -2962,24 +2962,19 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
|
|||
return true;
|
||||
}
|
||||
|
||||
void RendererStorageRD::_material_uniform_set_erased(const RID &p_set, void *p_material) {
|
||||
void RendererStorageRD::_material_uniform_set_erased(void *p_material) {
|
||||
RID rid = *(RID *)p_material;
|
||||
Material *material = base_singleton->material_owner.get_or_null(rid);
|
||||
if (material) {
|
||||
if (material->data) {
|
||||
// Uniform set may be gone because a dependency was erased. This happens
|
||||
// if a texture is deleted, so re-create it.
|
||||
base_singleton->_material_queue_update(material, false, true);
|
||||
}
|
||||
material->dependency.changed_notify(DEPENDENCY_CHANGED_MATERIAL);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererStorageRD::material_force_update_textures(RID p_material, ShaderType p_shader_type) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
if (material->shader_type != p_shader_type) {
|
||||
return;
|
||||
}
|
||||
if (material->data) {
|
||||
material->data->update_parameters(material->params, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererStorageRD::_update_queued_materials() {
|
||||
while (material_update_list.first()) {
|
||||
Material *material = material_update_list.first()->self();
|
||||
|
@ -5882,8 +5877,6 @@ RendererStorageRD::ShaderData *RendererStorageRD::_create_particles_shader_func(
|
|||
}
|
||||
|
||||
bool RendererStorageRD::ParticlesMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
|
||||
uniform_set_updated = true;
|
||||
|
||||
return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, base_singleton->particles_shader.shader.version_get_shader(shader_data->version, 0), 3);
|
||||
}
|
||||
|
||||
|
@ -5894,7 +5887,6 @@ RendererStorageRD::ParticlesMaterialData::~ParticlesMaterialData() {
|
|||
RendererStorageRD::MaterialData *RendererStorageRD::_create_particles_material_func(ParticlesShaderData *p_shader) {
|
||||
ParticlesMaterialData *material_data = memnew(ParticlesMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
material_data->last_frame = false;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
Vector<RID> texture_cache;
|
||||
};
|
||||
typedef MaterialData *(*MaterialDataRequestFunction)(ShaderData *);
|
||||
static void _material_uniform_set_erased(const RID &p_set, void *p_material);
|
||||
static void _material_uniform_set_erased(void *p_material);
|
||||
|
||||
enum DefaultRDTexture {
|
||||
DEFAULT_RD_TEXTURE_WHITE,
|
||||
|
@ -910,10 +910,8 @@ private:
|
|||
}
|
||||
|
||||
struct ParticlesMaterialData : public MaterialData {
|
||||
uint64_t last_frame = 0;
|
||||
ParticlesShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
bool uniform_set_updated = false;
|
||||
|
||||
virtual void set_render_priority(int p_priority) {}
|
||||
virtual void set_next_pass(RID p_pass) {}
|
||||
|
@ -1448,7 +1446,6 @@ public:
|
|||
void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters);
|
||||
|
||||
void material_update_dependency(RID p_material, DependencyTracker *p_instance);
|
||||
void material_force_update_textures(RID p_material, ShaderType p_shader_type);
|
||||
|
||||
void material_set_data_request_function(ShaderType p_shader_type, MaterialDataRequestFunction p_function);
|
||||
|
||||
|
|
|
@ -742,7 +742,7 @@ public:
|
|||
|
||||
virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) = 0;
|
||||
virtual bool uniform_set_is_valid(RID p_uniform_set) = 0;
|
||||
typedef void (*UniformSetInvalidatedCallback)(const RID &, void *);
|
||||
typedef void (*UniformSetInvalidatedCallback)(void *);
|
||||
virtual void uniform_set_set_invalidation_callback(RID p_uniform_set, UniformSetInvalidatedCallback p_callback, void *p_userdata) = 0;
|
||||
|
||||
virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
|
||||
|
|
Loading…
Reference in New Issue