feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -167,7 +167,6 @@ RID RenderForwardClustered::RenderBufferDataForwardClustered::get_color_only_fb(
|
|||
|
||||
if (render_buffers->has_texture(RB_SCOPE_VRS, RB_TEXTURE)) {
|
||||
RID vrs_texture = render_buffers->get_texture(RB_SCOPE_VRS, RB_TEXTURE);
|
||||
|
||||
return FramebufferCacheRD::get_singleton()->get_cache_multiview(render_buffers->get_view_count(), color, depth, vrs_texture);
|
||||
} else {
|
||||
return FramebufferCacheRD::get_singleton()->get_cache_multiview(render_buffers->get_view_count(), color, depth);
|
||||
|
|
@ -197,7 +196,6 @@ RID RenderForwardClustered::RenderBufferDataForwardClustered::get_color_pass_fb(
|
|||
|
||||
if (render_buffers->has_texture(RB_SCOPE_VRS, RB_TEXTURE)) {
|
||||
RID vrs_texture = render_buffers->get_texture(RB_SCOPE_VRS, RB_TEXTURE);
|
||||
|
||||
return FramebufferCacheRD::get_singleton()->get_cache_multiview(v_count, color, specular, velocity_buffer, depth, vrs_texture);
|
||||
} else {
|
||||
return FramebufferCacheRD::get_singleton()->get_cache_multiview(v_count, color, specular, velocity_buffer, depth);
|
||||
|
|
@ -786,7 +784,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
if (p_render_info) {
|
||||
p_render_info[RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] += element_total;
|
||||
}
|
||||
uint64_t frame = RSG::rasterizer->get_frame_number();
|
||||
|
||||
uint32_t repeats = 0;
|
||||
GeometryInstanceSurfaceDataCache *prev_surface = nullptr;
|
||||
for (uint32_t i = 0; i < element_total; i++) {
|
||||
|
|
@ -795,12 +793,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
|
||||
SceneState::InstanceData &instance_data = scene_state.instance_data[p_render_list][i + p_offset];
|
||||
|
||||
if (inst->prev_transform_dirty && frame > inst->prev_transform_change_frame + 1 && inst->prev_transform_change_frame) {
|
||||
inst->prev_transform = inst->transform;
|
||||
inst->prev_transform_dirty = false;
|
||||
}
|
||||
|
||||
if (inst->store_transform_cache) {
|
||||
if (likely(inst->store_transform_cache)) {
|
||||
RendererRD::MaterialStorage::store_transform(inst->transform, instance_data.transform);
|
||||
RendererRD::MaterialStorage::store_transform(inst->prev_transform, instance_data.prev_transform);
|
||||
|
||||
|
|
@ -820,10 +813,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
instance_data.gi_offset = inst->gi_offset_cache;
|
||||
instance_data.layer_mask = inst->layer_mask;
|
||||
instance_data.instance_uniforms_ofs = uint32_t(inst->shader_uniforms_offset);
|
||||
instance_data.lightmap_uv_scale[0] = inst->lightmap_uv_scale.position.x;
|
||||
instance_data.lightmap_uv_scale[1] = inst->lightmap_uv_scale.position.y;
|
||||
instance_data.lightmap_uv_scale[2] = inst->lightmap_uv_scale.size.x;
|
||||
instance_data.lightmap_uv_scale[3] = inst->lightmap_uv_scale.size.y;
|
||||
instance_data.set_lightmap_uv_scale(inst->lightmap_uv_scale);
|
||||
|
||||
AABB surface_aabb = AABB(Vector3(0.0, 0.0, 0.0), Vector3(1.0, 1.0, 1.0));
|
||||
uint64_t format = RendererRD::MeshStorage::get_singleton()->mesh_surface_get_format(surface->surface);
|
||||
|
|
@ -834,18 +824,8 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
uv_scale = RendererRD::MeshStorage::get_singleton()->mesh_surface_get_uv_scale(surface->surface);
|
||||
}
|
||||
|
||||
instance_data.compressed_aabb_position[0] = surface_aabb.position.x;
|
||||
instance_data.compressed_aabb_position[1] = surface_aabb.position.y;
|
||||
instance_data.compressed_aabb_position[2] = surface_aabb.position.z;
|
||||
|
||||
instance_data.compressed_aabb_size[0] = surface_aabb.size.x;
|
||||
instance_data.compressed_aabb_size[1] = surface_aabb.size.y;
|
||||
instance_data.compressed_aabb_size[2] = surface_aabb.size.z;
|
||||
|
||||
instance_data.uv_scale[0] = uv_scale.x;
|
||||
instance_data.uv_scale[1] = uv_scale.y;
|
||||
instance_data.uv_scale[2] = uv_scale.z;
|
||||
instance_data.uv_scale[3] = uv_scale.w;
|
||||
instance_data.set_compressed_aabb(surface_aabb);
|
||||
instance_data.set_uv_scale(uv_scale);
|
||||
|
||||
bool cant_repeat = instance_data.flags & INSTANCE_DATA_FLAG_MULTIMESH || inst->mesh_instance.is_valid();
|
||||
|
||||
|
|
@ -866,11 +846,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
|
||||
RenderElementInfo &element_info = rl->element_info[p_offset + i];
|
||||
|
||||
element_info.lod_index = surface->sort.lod_index;
|
||||
element_info.uses_forward_gi = surface->sort.uses_forward_gi;
|
||||
element_info.uses_lightmap = surface->sort.uses_lightmap;
|
||||
element_info.uses_softshadow = surface->sort.uses_softshadow;
|
||||
element_info.uses_projector = surface->sort.uses_projector;
|
||||
element_info.value = uint32_t(surface->sort.sort_key1 & 0xFFF);
|
||||
|
||||
if (cant_repeat) {
|
||||
prev_surface = nullptr;
|
||||
|
|
@ -892,7 +868,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||
|
||||
_FORCE_INLINE_ static uint32_t _indices_to_primitives(RS::PrimitiveType p_primitive, uint32_t p_indices) {
|
||||
static const uint32_t divisor[RS::PRIMITIVE_MAX] = { 1, 2, 1, 3, 1 };
|
||||
static const uint32_t subtractor[RS::PRIMITIVE_MAX] = { 0, 0, 1, 0, 1 };
|
||||
static const uint32_t subtractor[RS::PRIMITIVE_MAX] = { 0, 0, 1, 0, 2 };
|
||||
return (p_indices - subtractor[p_primitive]) / divisor[p_primitive];
|
||||
}
|
||||
void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, bool p_using_sdfgi, bool p_using_opaque_gi, bool p_using_motion_pass, bool p_append) {
|
||||
|
|
@ -1068,6 +1044,11 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
|
|||
lod_distance = surface_distance.length();
|
||||
}
|
||||
|
||||
if (unlikely(inst->prev_transform_dirty && frame > inst->prev_transform_change_frame + 1 && inst->prev_transform_change_frame)) {
|
||||
inst->prev_transform = inst->transform;
|
||||
inst->prev_transform_dirty = false;
|
||||
}
|
||||
|
||||
while (surf) {
|
||||
surf->sort.uses_forward_gi = 0;
|
||||
surf->sort.uses_lightmap = 0;
|
||||
|
|
@ -1921,16 +1902,25 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
color_framebuffer = rb_data->get_color_pass_fb(color_pass_flags);
|
||||
}
|
||||
|
||||
if (using_sss || using_separate_specular || scene_state.used_lightmap || using_voxelgi) {
|
||||
// Ensure this is allocated so we don't get a stutter the first time an object with SSS appears on screen.
|
||||
if (global_surface_data.sss_used) {
|
||||
rb_data->ensure_specular();
|
||||
}
|
||||
|
||||
if (global_surface_data.normal_texture_used) {
|
||||
rb_data->ensure_normal_roughness_texture();
|
||||
}
|
||||
|
||||
if (using_sss || using_separate_specular || scene_state.used_lightmap || using_voxelgi || global_surface_data.sss_used) {
|
||||
scene_shader.enable_advanced_shader_group(p_render_data->scene_data->view_count > 1);
|
||||
}
|
||||
|
||||
// Update the global pipeline requirements with all the features found to be in use in this scene.
|
||||
if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS) {
|
||||
if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS || global_surface_data.normal_texture_used) {
|
||||
global_pipeline_data_required.use_normal_and_roughness = true;
|
||||
}
|
||||
|
||||
if (scene_state.used_lightmap) {
|
||||
if (scene_state.used_lightmap || scene_state.lightmaps_used > 0) {
|
||||
global_pipeline_data_required.use_lightmaps = true;
|
||||
}
|
||||
|
||||
|
|
@ -1938,7 +1928,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
global_pipeline_data_required.use_voxelgi = true;
|
||||
}
|
||||
|
||||
if (using_separate_specular) {
|
||||
if (using_separate_specular || global_surface_data.sss_used) {
|
||||
global_pipeline_data_required.use_separate_specular = true;
|
||||
}
|
||||
|
||||
|
|
@ -2309,18 +2299,26 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
rb->ensure_upscaled();
|
||||
}
|
||||
|
||||
if (scene_state.used_screen_texture) {
|
||||
if (scene_state.used_screen_texture || global_surface_data.screen_texture_used) {
|
||||
RENDER_TIMESTAMP("Copy Screen Texture");
|
||||
|
||||
// Copy screen texture to backbuffer so we can read from it
|
||||
_render_buffers_copy_screen_texture(p_render_data);
|
||||
_render_buffers_ensure_screen_texture(p_render_data);
|
||||
|
||||
if (scene_state.used_screen_texture) {
|
||||
// Copy screen texture to backbuffer so we can read from it
|
||||
_render_buffers_copy_screen_texture(p_render_data);
|
||||
}
|
||||
}
|
||||
|
||||
if (scene_state.used_depth_texture) {
|
||||
if (scene_state.used_depth_texture || global_surface_data.depth_texture_used) {
|
||||
RENDER_TIMESTAMP("Copy Depth Texture");
|
||||
|
||||
// Copy depth texture to backbuffer so we can read from it
|
||||
_render_buffers_copy_depth_texture(p_render_data);
|
||||
_render_buffers_ensure_depth_texture(p_render_data);
|
||||
|
||||
if (scene_state.used_depth_texture) {
|
||||
// Copy depth texture to backbuffer so we can read from it
|
||||
_render_buffers_copy_depth_texture(p_render_data);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -3310,9 +3308,8 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
uniforms.push_back(u);
|
||||
}
|
||||
{
|
||||
RD::Uniform u;
|
||||
u.binding = 7;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
Vector<RID> textures;
|
||||
textures.resize(scene_state.max_lightmaps * 2);
|
||||
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
for (uint32_t i = 0; i < scene_state.max_lightmaps * 2; i++) {
|
||||
|
|
@ -3332,14 +3329,14 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
|
||||
if (texture.is_valid()) {
|
||||
RID rd_texture = texture_storage->texture_get_rd_texture(texture);
|
||||
u.append_id(rd_texture);
|
||||
textures.write[i] = rd_texture;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
u.append_id(default_tex);
|
||||
textures.write[i] = default_tex;
|
||||
}
|
||||
|
||||
RD::Uniform u(RD::UNIFORM_TYPE_TEXTURE, 7, textures);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
{
|
||||
|
|
@ -3955,18 +3952,22 @@ void RenderForwardClustered::_geometry_instance_add_surface_with_material(Geomet
|
|||
|
||||
if (p_material->shader_data->uses_sss) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SUBSURFACE_SCATTERING;
|
||||
global_surface_data.sss_used = true;
|
||||
}
|
||||
|
||||
if (p_material->shader_data->uses_screen_texture) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SCREEN_TEXTURE;
|
||||
global_surface_data.screen_texture_used = true;
|
||||
}
|
||||
|
||||
if (p_material->shader_data->uses_depth_texture) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_DEPTH_TEXTURE;
|
||||
global_surface_data.depth_texture_used = true;
|
||||
}
|
||||
|
||||
if (p_material->shader_data->uses_normal_texture) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_NORMAL_TEXTURE;
|
||||
global_surface_data.normal_texture_used = true;
|
||||
}
|
||||
|
||||
if (ginstance->data->cast_double_sided_shadows) {
|
||||
|
|
@ -4039,8 +4040,7 @@ void RenderForwardClustered::_geometry_instance_add_surface_with_material(Geomet
|
|||
sdcache->sort.sort_key2 = 0;
|
||||
|
||||
sdcache->sort.surface_index = p_surface;
|
||||
sdcache->sort.material_id_low = p_material_id & 0xFFFF;
|
||||
sdcache->sort.material_id_hi = p_material_id >> 16;
|
||||
sdcache->sort.material_id = p_material_id;
|
||||
sdcache->sort.shader_id = p_shader_id;
|
||||
sdcache->sort.geometry_id = p_mesh.get_local_index(); //only meshes can repeat anyway
|
||||
sdcache->sort.uses_forward_gi = ginstance->can_sdfgi;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_FORWARD_CLUSTERED_H
|
||||
#define RENDER_FORWARD_CLUSTERED_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/paged_allocator.h"
|
||||
#include "servers/rendering/renderer_rd/cluster_builder_rd.h"
|
||||
|
|
@ -326,8 +325,53 @@ private:
|
|||
float compressed_aabb_position[4];
|
||||
float compressed_aabb_size[4];
|
||||
float uv_scale[4];
|
||||
|
||||
// These setters allow us to copy the data over with operation when using floats.
|
||||
inline void set_lightmap_uv_scale(const Rect2 &p_rect) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
lightmap_uv_scale[0] = p_rect.position.x;
|
||||
lightmap_uv_scale[1] = p_rect.position.y;
|
||||
lightmap_uv_scale[2] = p_rect.size.x;
|
||||
lightmap_uv_scale[3] = p_rect.size.y;
|
||||
#else
|
||||
Rect2 *rect = reinterpret_cast<Rect2 *>(lightmap_uv_scale);
|
||||
*rect = p_rect;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void set_compressed_aabb(const AABB &p_aabb) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
compressed_aabb_position[0] = p_aabb.position.x;
|
||||
compressed_aabb_position[1] = p_aabb.position.y;
|
||||
compressed_aabb_position[2] = p_aabb.position.z;
|
||||
|
||||
compressed_aabb_size[0] = p_aabb.size.x;
|
||||
compressed_aabb_size[1] = p_aabb.size.y;
|
||||
compressed_aabb_size[2] = p_aabb.size.z;
|
||||
#else
|
||||
Vector3 *compressed_aabb_position_vec3 = reinterpret_cast<Vector3 *>(compressed_aabb_position);
|
||||
Vector3 *compressed_aabb_size_vec3 = reinterpret_cast<Vector3 *>(compressed_aabb_size);
|
||||
*compressed_aabb_position_vec3 = p_aabb.position;
|
||||
*compressed_aabb_size_vec3 = p_aabb.size;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void set_uv_scale(const Vector4 &p_uv_scale) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
uv_scale[0] = p_uv_scale.x;
|
||||
uv_scale[1] = p_uv_scale.y;
|
||||
uv_scale[2] = p_uv_scale.z;
|
||||
uv_scale[3] = p_uv_scale.w;
|
||||
#else
|
||||
Vector4 *uv_scale_vec4 = reinterpret_cast<Vector4 *>(uv_scale);
|
||||
*uv_scale_vec4 = p_uv_scale;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible_v<InstanceData>);
|
||||
static_assert(std::is_trivially_constructible_v<InstanceData>);
|
||||
|
||||
UBO ubo;
|
||||
|
||||
LocalVector<RID> uniform_buffers;
|
||||
|
|
@ -384,14 +428,22 @@ private:
|
|||
|
||||
struct RenderElementInfo {
|
||||
enum { MAX_REPEATS = (1 << 20) - 1 };
|
||||
uint32_t repeat : 20;
|
||||
uint32_t uses_projector : 1;
|
||||
uint32_t uses_softshadow : 1;
|
||||
uint32_t uses_lightmap : 1;
|
||||
uint32_t uses_forward_gi : 1;
|
||||
uint32_t lod_index : 8;
|
||||
union {
|
||||
struct {
|
||||
uint32_t lod_index : 8;
|
||||
uint32_t uses_softshadow : 1;
|
||||
uint32_t uses_projector : 1;
|
||||
uint32_t uses_forward_gi : 1;
|
||||
uint32_t uses_lightmap : 1;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
uint32_t repeat;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible_v<RenderElementInfo>);
|
||||
static_assert(std::is_trivially_constructible_v<RenderElementInfo>);
|
||||
|
||||
template <PassMode p_pass_mode, uint32_t p_color_pass_flags = 0>
|
||||
_FORCE_INLINE_ void _render_list_template(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element);
|
||||
void _render_list(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element);
|
||||
|
|
@ -434,18 +486,17 @@ private:
|
|||
};
|
||||
struct {
|
||||
uint64_t lod_index : 8;
|
||||
uint64_t surface_index : 8;
|
||||
uint64_t geometry_id : 32;
|
||||
uint64_t material_id_low : 16;
|
||||
|
||||
uint64_t material_id_hi : 16;
|
||||
uint64_t shader_id : 32;
|
||||
uint64_t uses_softshadow : 1;
|
||||
uint64_t uses_projector : 1;
|
||||
uint64_t uses_forward_gi : 1;
|
||||
uint64_t uses_lightmap : 1;
|
||||
uint64_t depth_layer : 4;
|
||||
uint64_t surface_index : 8;
|
||||
uint64_t priority : 8;
|
||||
uint64_t geometry_id : 32;
|
||||
|
||||
uint64_t material_id : 32;
|
||||
uint64_t shader_id : 32;
|
||||
};
|
||||
} sort;
|
||||
|
||||
|
|
@ -578,6 +629,14 @@ private:
|
|||
void _update_dirty_geometry_instances();
|
||||
void _update_dirty_geometry_pipelines();
|
||||
|
||||
// Global data about the scene that can be used to pre-allocate resources without relying on culling.
|
||||
struct GlobalSurfaceData {
|
||||
bool screen_texture_used = false;
|
||||
bool normal_texture_used = false;
|
||||
bool depth_texture_used = false;
|
||||
bool sss_used = false;
|
||||
} global_surface_data;
|
||||
|
||||
/* Render List */
|
||||
|
||||
struct RenderList {
|
||||
|
|
@ -748,5 +807,3 @@ public:
|
|||
~RenderForwardClustered();
|
||||
};
|
||||
} // namespace RendererSceneRenderImplementation
|
||||
|
||||
#endif // RENDER_FORWARD_CLUSTERED_H
|
||||
|
|
|
|||
|
|
@ -618,9 +618,9 @@ void SceneShaderForwardClustered::init(const String p_defines) {
|
|||
|
||||
actions.renames["TIME"] = "global_time";
|
||||
actions.renames["EXPOSURE"] = "(1.0 / scene_data_block.data.emissive_exposure_normalization)";
|
||||
actions.renames["PI"] = _MKSTR(Math_PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions.renames["E"] = _MKSTR(Math_E);
|
||||
actions.renames["PI"] = String::num(Math::PI);
|
||||
actions.renames["TAU"] = String::num(Math::TAU);
|
||||
actions.renames["E"] = String::num(Math::E);
|
||||
actions.renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
|
||||
actions.renames["CLIP_SPACE_FAR"] = "SHADER_SPACE_FAR";
|
||||
actions.renames["VIEWPORT_SIZE"] = "read_viewport_size";
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SCENE_SHADER_FORWARD_CLUSTERED_H
|
||||
#define SCENE_SHADER_FORWARD_CLUSTERED_H
|
||||
#pragma once
|
||||
|
||||
#include "../storage_rd/material_storage.h"
|
||||
#include "servers/rendering/renderer_rd/pipeline_hash_map_rd.h"
|
||||
|
|
@ -356,5 +355,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererSceneRenderImplementation
|
||||
|
||||
#endif // SCENE_SHADER_FORWARD_CLUSTERED_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue