You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Merge pull request #98701 from DarioSamo/rd-graph-improvements
Add dependency detection improvements to the render graph.
This commit is contained in:
@@ -1002,15 +1002,19 @@ void CopyEffects::copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dst_framebuf
|
||||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
ERR_FAIL_NULL(material_storage);
|
||||
|
||||
Rect2i screen_rect;
|
||||
float atlas_width = p_dst_size.width / p_rect.size.width;
|
||||
float atlas_height = p_dst_size.height / p_rect.size.height;
|
||||
screen_rect.position.x = (int32_t)(Math::round(p_rect.position.x * atlas_width));
|
||||
screen_rect.position.y = (int32_t)(Math::round(p_rect.position.y * atlas_height));
|
||||
screen_rect.size.width = (int32_t)(Math::round(p_dst_size.width));
|
||||
screen_rect.size.height = (int32_t)(Math::round(p_dst_size.height));
|
||||
|
||||
CopyToDPPushConstant push_constant;
|
||||
push_constant.screen_rect[0] = p_rect.position.x;
|
||||
push_constant.screen_rect[1] = p_rect.position.y;
|
||||
push_constant.screen_rect[2] = p_rect.size.width;
|
||||
push_constant.screen_rect[3] = p_rect.size.height;
|
||||
push_constant.z_far = p_z_far;
|
||||
push_constant.z_near = p_z_near;
|
||||
push_constant.texel_size[0] = 1.0f / p_dst_size.x;
|
||||
push_constant.texel_size[1] = 1.0f / p_dst_size.y;
|
||||
push_constant.texel_size[0] = 1.0f / p_dst_size.width;
|
||||
push_constant.texel_size[1] = 1.0f / p_dst_size.height;
|
||||
push_constant.texel_size[0] *= p_dp_flip ? -1.0f : 1.0f; // Encode dp flip as x size sign
|
||||
|
||||
// setup our uniforms
|
||||
@@ -1021,7 +1025,7 @@ void CopyEffects::copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dst_framebuf
|
||||
RID shader = cube_to_dp.shader.version_get_shader(cube_to_dp.shader_version, 0);
|
||||
ERR_FAIL_COND(shader.is_null());
|
||||
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dst_framebuffer, RD::INITIAL_ACTION_DISCARD, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_LOAD, RD::FINAL_ACTION_STORE);
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dst_framebuffer, RD::INITIAL_ACTION_DISCARD, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_LOAD, RD::FINAL_ACTION_STORE, Vector<Color>(), 1.0f, 0, screen_rect);
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, cube_to_dp.pipeline.get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dst_framebuffer)));
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, uniform_set_cache->get_cache(shader, 0, u_source_rd_texture), 0);
|
||||
RD::get_singleton()->draw_list_bind_index_array(draw_list, material_storage->get_quad_index_array());
|
||||
|
||||
@@ -217,7 +217,6 @@ private:
|
||||
float z_far;
|
||||
float z_near;
|
||||
float texel_size[2];
|
||||
float screen_rect[4];
|
||||
};
|
||||
|
||||
struct CopyToDP {
|
||||
|
||||
@@ -8,7 +8,6 @@ layout(push_constant, std430) uniform Params {
|
||||
float z_far;
|
||||
float z_near;
|
||||
vec2 texel_size;
|
||||
vec4 screen_rect;
|
||||
}
|
||||
params;
|
||||
|
||||
@@ -17,8 +16,7 @@ layout(location = 0) out vec2 uv_interp;
|
||||
void main() {
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
vec2 screen_pos = uv_interp * params.screen_rect.zw + params.screen_rect.xy;
|
||||
gl_Position = vec4(screen_pos * 2.0 - 1.0, 0.0, 1.0);
|
||||
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
#[fragment]
|
||||
@@ -35,7 +33,6 @@ layout(push_constant, std430) uniform Params {
|
||||
float z_far;
|
||||
float z_near;
|
||||
vec2 texel_size;
|
||||
vec4 screen_rect;
|
||||
}
|
||||
params;
|
||||
|
||||
|
||||
@@ -306,9 +306,14 @@ void ParticlesStorage::_particles_free_data(Particles *particles) {
|
||||
particles->emission_storage_buffer = RID();
|
||||
}
|
||||
|
||||
if (particles->unused_storage_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(particles->unused_storage_buffer);
|
||||
particles->unused_storage_buffer = RID();
|
||||
if (particles->unused_emission_storage_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(particles->unused_emission_storage_buffer);
|
||||
particles->unused_emission_storage_buffer = RID();
|
||||
}
|
||||
|
||||
if (particles->unused_trail_storage_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(particles->unused_trail_storage_buffer);
|
||||
particles->unused_trail_storage_buffer = RID();
|
||||
}
|
||||
|
||||
if (RD::get_singleton()->uniform_set_is_valid(particles->particles_material_uniform_set)) {
|
||||
@@ -534,9 +539,15 @@ void ParticlesStorage::_particles_allocate_emission_buffer(Particles *particles)
|
||||
}
|
||||
}
|
||||
|
||||
void ParticlesStorage::_particles_ensure_unused_buffer(Particles *particles) {
|
||||
if (particles->unused_storage_buffer.is_null()) {
|
||||
particles->unused_storage_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 4);
|
||||
void ParticlesStorage::_particles_ensure_unused_emission_buffer(Particles *particles) {
|
||||
if (particles->unused_emission_storage_buffer.is_null()) {
|
||||
particles->unused_emission_storage_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 4);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticlesStorage::_particles_ensure_unused_trail_buffer(Particles *particles) {
|
||||
if (particles->unused_trail_storage_buffer.is_null()) {
|
||||
particles->unused_trail_storage_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,8 +774,8 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
||||
if (p_particles->emission_storage_buffer.is_valid()) {
|
||||
u.append_id(p_particles->emission_storage_buffer);
|
||||
} else {
|
||||
_particles_ensure_unused_buffer(p_particles);
|
||||
u.append_id(p_particles->unused_storage_buffer);
|
||||
_particles_ensure_unused_emission_buffer(p_particles);
|
||||
u.append_id(p_particles->unused_emission_storage_buffer);
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
@@ -779,8 +790,8 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
||||
}
|
||||
u.append_id(sub_emitter->emission_storage_buffer);
|
||||
} else {
|
||||
_particles_ensure_unused_buffer(p_particles);
|
||||
u.append_id(p_particles->unused_storage_buffer);
|
||||
_particles_ensure_unused_emission_buffer(p_particles);
|
||||
u.append_id(p_particles->unused_emission_storage_buffer);
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
@@ -1481,8 +1492,8 @@ void ParticlesStorage::update_particles() {
|
||||
if (particles->trail_bind_pose_buffer.is_valid()) {
|
||||
u.append_id(particles->trail_bind_pose_buffer);
|
||||
} else {
|
||||
_particles_ensure_unused_buffer(particles);
|
||||
u.append_id(particles->unused_storage_buffer);
|
||||
_particles_ensure_unused_trail_buffer(particles);
|
||||
u.append_id(particles->unused_trail_storage_buffer);
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,8 @@ private:
|
||||
ParticleEmissionBuffer *emission_buffer = nullptr;
|
||||
RID emission_storage_buffer;
|
||||
|
||||
RID unused_storage_buffer;
|
||||
RID unused_emission_storage_buffer;
|
||||
RID unused_trail_storage_buffer;
|
||||
|
||||
HashSet<RID> collisions;
|
||||
|
||||
@@ -265,7 +266,8 @@ private:
|
||||
|
||||
void _particles_process(Particles *p_particles, double p_delta);
|
||||
void _particles_allocate_emission_buffer(Particles *particles);
|
||||
void _particles_ensure_unused_buffer(Particles *particles);
|
||||
void _particles_ensure_unused_emission_buffer(Particles *particles);
|
||||
void _particles_ensure_unused_trail_buffer(Particles *particles);
|
||||
void _particles_free_data(Particles *particles);
|
||||
void _particles_update_buffers(Particles *particles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user