Merge pull request #70132 from clayjohn/RT-update
Implement render_target_was_used API so that Viewports can properly check if they have been used.
This commit is contained in:
commit
676f60b0cc
16 changed files with 85 additions and 6 deletions
|
|
@ -1319,6 +1319,10 @@ void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Va
|
|||
roughness_detect_texture = tex;
|
||||
roughness_channel = RS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R);
|
||||
}
|
||||
if (tex->render_target) {
|
||||
tex->render_target->was_used = true;
|
||||
render_target_cache.push_back(tex->render_target);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (rd_texture.is_null()) {
|
||||
|
|
@ -1405,6 +1409,7 @@ bool MaterialStorage::MaterialData::update_parameters_uniform_set(const HashMap<
|
|||
|
||||
if ((uint32_t)texture_cache.size() != tex_uniform_count || p_textures_dirty) {
|
||||
texture_cache.resize(tex_uniform_count);
|
||||
render_target_cache.clear();
|
||||
p_textures_dirty = true;
|
||||
|
||||
//clear previous uniform set
|
||||
|
|
@ -1465,6 +1470,12 @@ bool MaterialStorage::MaterialData::update_parameters_uniform_set(const HashMap<
|
|||
return true;
|
||||
}
|
||||
|
||||
void MaterialStorage::MaterialData::set_as_used() {
|
||||
for (int i = 0; i < render_target_cache.size(); i++) {
|
||||
render_target_cache[i]->was_used = true;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// MaterialStorage
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#ifndef MATERIAL_STORAGE_RD_H
|
||||
#define MATERIAL_STORAGE_RD_H
|
||||
|
||||
#include "texture_storage.h"
|
||||
|
||||
#include "core/math/projection.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -74,8 +76,10 @@ public:
|
|||
};
|
||||
|
||||
struct MaterialData {
|
||||
Vector<RendererRD::TextureStorage::RenderTarget *> render_target_cache;
|
||||
void update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color);
|
||||
void update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color);
|
||||
void set_as_used();
|
||||
|
||||
virtual void set_render_priority(int p_priority) = 0;
|
||||
virtual void set_next_pass(RID p_pass) = 0;
|
||||
|
|
|
|||
|
|
@ -1116,6 +1116,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
|
||||
if (m->uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(m->uniform_set)) {
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, m->uniform_set, 3);
|
||||
m->set_as_used();
|
||||
}
|
||||
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(ParticlesShader::PushConstant));
|
||||
|
|
|
|||
|
|
@ -582,6 +582,9 @@ bool TextureStorage::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasIte
|
|||
}
|
||||
|
||||
ct = t->canvas_texture;
|
||||
if (t->render_target) {
|
||||
t->render_target->was_used = true;
|
||||
}
|
||||
} else {
|
||||
ct = canvas_texture_owner.get_or_null(p_texture);
|
||||
}
|
||||
|
|
@ -612,6 +615,9 @@ bool TextureStorage::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasIte
|
|||
} else {
|
||||
u.append_id(t->rd_texture);
|
||||
ct->size_cache = Size2i(t->width_2d, t->height_2d);
|
||||
if (t->render_target) {
|
||||
t->render_target->was_used = true;
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
|
@ -627,6 +633,9 @@ bool TextureStorage::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasIte
|
|||
} else {
|
||||
u.append_id(t->rd_texture);
|
||||
ct->use_normal_cache = true;
|
||||
if (t->render_target) {
|
||||
t->render_target->was_used = true;
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
|
@ -642,6 +651,9 @@ bool TextureStorage::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasIte
|
|||
} else {
|
||||
u.append_id(t->rd_texture);
|
||||
ct->use_specular_cache = true;
|
||||
if (t->render_target) {
|
||||
t->render_target->was_used = true;
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
|
@ -2399,6 +2411,10 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) {
|
|||
|
||||
rt->color = RID();
|
||||
rt->color_multisample = RID();
|
||||
if (rt->texture.is_valid()) {
|
||||
Texture *tex = get_texture(rt->texture);
|
||||
tex->render_target = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TextureStorage::_update_render_target(RenderTarget *rt) {
|
||||
|
|
@ -2479,6 +2495,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) {
|
|||
|
||||
tex->rd_texture = RID();
|
||||
tex->rd_texture_srgb = RID();
|
||||
tex->render_target = rt;
|
||||
|
||||
//create shared textures to the color buffer,
|
||||
//so transparent can be supported
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ private:
|
|||
|
||||
/* Texture API */
|
||||
|
||||
struct RenderTarget;
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
TextureType type;
|
||||
|
|
@ -141,6 +143,7 @@ private:
|
|||
Vector<BufferSlice3D> buffer_slices_3d;
|
||||
uint32_t buffer_size_3d = 0;
|
||||
|
||||
RenderTarget *render_target = nullptr;
|
||||
bool is_render_target;
|
||||
bool is_proxy;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue