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
|
|
@ -35,6 +35,7 @@
|
|||
#include "servers/rendering/renderer_rd/storage_rd/mesh_storage.h"
|
||||
#include "servers/rendering/renderer_rd/storage_rd/particles_storage.h"
|
||||
#include "servers/rendering/renderer_rd/storage_rd/texture_storage.h"
|
||||
#include "servers/rendering/renderer_rd/uniform_set_cache_rd.h"
|
||||
#include "servers/rendering/rendering_device.h"
|
||||
#include "servers/rendering/rendering_server_default.h"
|
||||
|
||||
|
|
@ -208,9 +209,6 @@ RID RenderForwardMobile::RenderBufferDataForwardMobile::get_color_fbs(Framebuffe
|
|||
RD::FramebufferPass pass;
|
||||
pass.color_attachments.push_back(0);
|
||||
pass.depth_attachment = 1;
|
||||
if (vrs_texture.is_valid()) {
|
||||
pass.vrs_attachment = 2;
|
||||
}
|
||||
|
||||
if (use_msaa) {
|
||||
// Add resolve
|
||||
|
|
@ -231,9 +229,6 @@ RID RenderForwardMobile::RenderBufferDataForwardMobile::get_color_fbs(Framebuffe
|
|||
RD::FramebufferPass pass;
|
||||
pass.color_attachments.push_back(0);
|
||||
pass.depth_attachment = 1;
|
||||
if (vrs_texture.is_valid()) {
|
||||
pass.vrs_attachment = 2;
|
||||
}
|
||||
|
||||
if (use_msaa) {
|
||||
// add resolve
|
||||
|
|
@ -404,7 +399,8 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
// default render buffer and scene state uniform set
|
||||
// loaded into set 1
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
thread_local LocalVector<RD::Uniform> uniforms;
|
||||
uniforms.clear();
|
||||
|
||||
{
|
||||
RD::Uniform u;
|
||||
|
|
@ -481,9 +477,8 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
|
||||
/* we have limited ability to keep textures like this so we're moving this to a set we change before drawing geometry and just pushing the needed texture in */
|
||||
{
|
||||
RD::Uniform u;
|
||||
u.binding = 6;
|
||||
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++) {
|
||||
|
|
@ -503,14 +498,14 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
|
||||
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, 6, textures);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
||||
|
|
@ -630,15 +625,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
|
||||
p_samplers.append_uniforms(uniforms, 13);
|
||||
|
||||
if (p_index >= (int)render_pass_uniform_sets.size()) {
|
||||
render_pass_uniform_sets.resize(p_index + 1);
|
||||
}
|
||||
|
||||
if (render_pass_uniform_sets[p_index].is_valid() && RD::get_singleton()->uniform_set_is_valid(render_pass_uniform_sets[p_index])) {
|
||||
RD::get_singleton()->free(render_pass_uniform_sets[p_index]);
|
||||
}
|
||||
render_pass_uniform_sets[p_index] = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, RENDER_PASS_UNIFORM_SET, true);
|
||||
return render_pass_uniform_sets[p_index];
|
||||
return UniformSetCacheRD::get_singleton()->get_cache_vec(scene_shader.default_shader_rd, RENDER_PASS_UNIFORM_SET, uniforms);
|
||||
}
|
||||
|
||||
void RenderForwardMobile::_setup_lightmaps(const RenderDataRD *p_render_data, const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform) {
|
||||
|
|
@ -1187,14 +1174,22 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
|
|||
_process_compositor_effects(RS::COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT, 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_screen_texture || global_surface_data.screen_texture_used) {
|
||||
_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) {
|
||||
// Copy depth texture to backbuffer so we can read from it
|
||||
_render_buffers_copy_depth_texture(p_render_data);
|
||||
if (scene_state.used_depth_texture || global_surface_data.depth_texture_used) {
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
if (render_list[RENDER_LIST_ALPHA].element_info.size() > 0) {
|
||||
|
|
@ -1426,6 +1421,7 @@ void RenderForwardMobile::_render_shadow_begin() {
|
|||
_update_render_base_uniform_set();
|
||||
|
||||
render_list[RENDER_LIST_SECONDARY].clear();
|
||||
scene_state.instance_data[RENDER_LIST_SECONDARY].clear();
|
||||
}
|
||||
|
||||
void RenderForwardMobile::_render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end, RenderingMethod::RenderInfo *p_render_info, const Transform3D &p_main_cam_transform) {
|
||||
|
|
@ -1471,7 +1467,7 @@ void RenderForwardMobile::_render_shadow_append(RID p_framebuffer, const PagedAr
|
|||
_fill_render_list(RENDER_LIST_SECONDARY, &render_data, pass_mode, true);
|
||||
uint32_t render_list_size = render_list[RENDER_LIST_SECONDARY].elements.size() - render_list_from;
|
||||
render_list[RENDER_LIST_SECONDARY].sort_by_key_range(render_list_from, render_list_size);
|
||||
_fill_instance_data(RENDER_LIST_SECONDARY, render_list_from, render_list_size);
|
||||
_fill_instance_data(RENDER_LIST_SECONDARY, render_list_from, render_list_size, false);
|
||||
|
||||
{
|
||||
//regular forward for now
|
||||
|
|
@ -1498,6 +1494,7 @@ void RenderForwardMobile::_render_shadow_append(RID p_framebuffer, const PagedAr
|
|||
}
|
||||
|
||||
void RenderForwardMobile::_render_shadow_process() {
|
||||
_update_instance_data_buffer(RENDER_LIST_SECONDARY);
|
||||
//render shadows one after the other, so this can be done un-barriered and the driver can optimize (as well as allow us to run compute at the same time)
|
||||
|
||||
for (uint32_t i = 0; i < scene_state.shadow_passes.size(); i++) {
|
||||
|
|
@ -1702,16 +1699,15 @@ void RenderForwardMobile::base_uniforms_changed() {
|
|||
void RenderForwardMobile::_update_render_base_uniform_set() {
|
||||
RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
|
||||
|
||||
// We must always recreate the uniform set every frame if we're using linear pools (since we requested it on creation).
|
||||
// This pays off as long as we often get inside the if() block (i.e. the settings end up changing often).
|
||||
if (RD::get_singleton()->uniform_sets_have_linear_pools() || render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
|
||||
RD::get_singleton()->free(render_base_uniform_set);
|
||||
}
|
||||
|
||||
lightmap_texture_array_version = light_storage->lightmap_array_get_version();
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
thread_local LocalVector<RD::Uniform> uniforms;
|
||||
uniforms.clear();
|
||||
|
||||
{
|
||||
RD::Uniform u;
|
||||
|
|
@ -1805,7 +1801,7 @@ void RenderForwardMobile::_update_render_base_uniform_set() {
|
|||
uniforms.push_back(u);
|
||||
}
|
||||
|
||||
render_base_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, SCENE_UNIFORM_SET, true);
|
||||
render_base_uniform_set = UniformSetCacheRD::get_singleton()->get_cache_vec(scene_shader.default_shader_rd, SCENE_UNIFORM_SET, uniforms);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1862,10 +1858,7 @@ void RenderForwardMobile::_fill_instance_data(RenderListType p_render_list, uint
|
|||
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);
|
||||
|
|
@ -1878,23 +1871,13 @@ void RenderForwardMobile::_fill_instance_data(RenderListType p_render_list, uint
|
|||
|
||||
fill_push_constant_instance_indices(&instance_data, inst);
|
||||
|
||||
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);
|
||||
|
||||
RenderElementInfo &element_info = rl->element_info[p_offset + i];
|
||||
|
||||
element_info.lod_index = surface->lod_index;
|
||||
element_info.uses_lightmap = surface->sort.uses_lightmap;
|
||||
// Sets lod_index and uses_lightmap at once.
|
||||
element_info.value = uint32_t(surface->sort.sort_key1 & 0x1FF);
|
||||
}
|
||||
|
||||
if (p_update_buffer) {
|
||||
|
|
@ -1904,7 +1887,7 @@ void RenderForwardMobile::_fill_instance_data(RenderListType p_render_list, uint
|
|||
|
||||
_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];
|
||||
}
|
||||
|
||||
|
|
@ -1912,9 +1895,7 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
|
|||
RendererRD::MeshStorage *mesh_storage = RendererRD::MeshStorage::get_singleton();
|
||||
|
||||
if (p_render_list == RENDER_LIST_OPAQUE) {
|
||||
scene_state.used_sss = false;
|
||||
scene_state.used_screen_texture = false;
|
||||
scene_state.used_normal_texture = false;
|
||||
scene_state.used_depth_texture = false;
|
||||
scene_state.used_lightmap = false;
|
||||
}
|
||||
|
|
@ -2026,7 +2007,7 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
|
|||
|
||||
if (p_render_data->scene_data->screen_mesh_lod_threshold > 0.0 && mesh_storage->mesh_surface_has_lod(surf->surface)) {
|
||||
uint32_t indices = 0;
|
||||
surf->lod_index = mesh_storage->mesh_surface_get_lod(surf->surface, inst->lod_model_scale * inst->lod_bias, lod_distance * p_render_data->scene_data->lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, indices);
|
||||
surf->sort.lod_index = mesh_storage->mesh_surface_get_lod(surf->surface, inst->lod_model_scale * inst->lod_bias, lod_distance * p_render_data->scene_data->lod_distance_multiplier, p_render_data->scene_data->screen_mesh_lod_threshold, indices);
|
||||
if (p_render_data->render_info) {
|
||||
indices = _indices_to_primitives(surf->primitive, indices);
|
||||
if (p_render_list == RENDER_LIST_OPAQUE) { //opaque
|
||||
|
|
@ -2036,7 +2017,7 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
|
|||
}
|
||||
}
|
||||
} else {
|
||||
surf->lod_index = 0;
|
||||
surf->sort.lod_index = 0;
|
||||
if (p_render_data->render_info) {
|
||||
uint32_t to_draw = mesh_storage->mesh_surface_get_vertices_drawn_count(surf->surface);
|
||||
to_draw = _indices_to_primitives(surf->primitive, to_draw);
|
||||
|
|
@ -2068,15 +2049,9 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
|
|||
scene_state.used_lightmap = true;
|
||||
}
|
||||
|
||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_SUBSURFACE_SCATTERING) {
|
||||
scene_state.used_sss = true;
|
||||
}
|
||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_SCREEN_TEXTURE) {
|
||||
scene_state.used_screen_texture = true;
|
||||
}
|
||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_NORMAL_TEXTURE) {
|
||||
scene_state.used_normal_texture = true;
|
||||
}
|
||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_DEPTH_TEXTURE) {
|
||||
scene_state.used_depth_texture = true;
|
||||
}
|
||||
|
|
@ -2312,7 +2287,6 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr
|
|||
mesh_storage->mesh_surface_get_vertex_arrays_and_format(mesh_surface, input_mask, false, vertex_array_rd, vertex_format);
|
||||
}
|
||||
|
||||
index_array_rd = mesh_storage->mesh_surface_get_index_array(mesh_surface, element_info.lod_index);
|
||||
pipeline_key.vertex_format_id = vertex_format;
|
||||
|
||||
if (pipeline_key.ubershader) {
|
||||
|
|
@ -2562,10 +2536,12 @@ void RenderForwardMobile::_geometry_instance_add_surface_with_material(GeometryI
|
|||
|
||||
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) {
|
||||
|
|
@ -2640,11 +2616,9 @@ void RenderForwardMobile::_geometry_instance_add_surface_with_material(GeometryI
|
|||
sdcache->sort.sort_key2 = 0;
|
||||
|
||||
sdcache->sort.surface_index = p_surface;
|
||||
sdcache->sort.material_id_low = p_material_id & 0x0000FFFF;
|
||||
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();
|
||||
// sdcache->sort.uses_forward_gi = ginstance->can_sdfgi;
|
||||
sdcache->sort.priority = p_material->priority;
|
||||
|
||||
uint64_t format = RendererRD::MeshStorage::get_singleton()->mesh_surface_get_format(sdcache->surface);
|
||||
|
|
@ -2904,6 +2878,7 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
|
|||
attachments.push_back(attachment);
|
||||
|
||||
if (p_vrs) {
|
||||
// VRS attachment.
|
||||
attachment.samples = RD::TEXTURE_SAMPLES_1;
|
||||
attachment.format = RenderSceneBuffersRD::get_vrs_format();
|
||||
attachment.usage_flags = RenderSceneBuffersRD::get_vrs_usage_bits();
|
||||
|
|
@ -2925,10 +2900,6 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
|
|||
pass.color_attachments.push_back(0);
|
||||
pass.depth_attachment = 1;
|
||||
|
||||
if (p_vrs) {
|
||||
pass.vrs_attachment = 2;
|
||||
}
|
||||
|
||||
if (multisampling) {
|
||||
pass.resolve_attachments.push_back(attachments.size() - 1);
|
||||
}
|
||||
|
|
@ -2954,7 +2925,8 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
|
|||
passes.push_back(blit_pass);
|
||||
}
|
||||
|
||||
return RD::get_singleton()->framebuffer_format_create_multipass(attachments, passes, p_view_count);
|
||||
int32_t vrs_attachment = p_vrs ? 2 : -1;
|
||||
return RD::get_singleton()->framebuffer_format_create_multipass(attachments, passes, p_view_count, vrs_attachment);
|
||||
}
|
||||
|
||||
static RD::FramebufferFormatID _get_reflection_probe_color_framebuffer_format_for_pipeline() {
|
||||
|
|
@ -3270,13 +3242,6 @@ RenderForwardMobile::RenderForwardMobile() {
|
|||
RenderForwardMobile::~RenderForwardMobile() {
|
||||
RSG::light_storage->directional_shadow_atlas_set_size(0);
|
||||
|
||||
//clear base uniform set if still valid
|
||||
for (uint32_t i = 0; i < render_pass_uniform_sets.size(); i++) {
|
||||
if (render_pass_uniform_sets[i].is_valid() && RD::get_singleton()->uniform_set_is_valid(render_pass_uniform_sets[i])) {
|
||||
RD::get_singleton()->free(render_pass_uniform_sets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (const RID &rid : scene_state.uniform_buffers) {
|
||||
RD::get_singleton()->free(rid);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_FORWARD_MOBILE_H
|
||||
#define RENDER_FORWARD_MOBILE_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/paged_allocator.h"
|
||||
#include "servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h"
|
||||
|
|
@ -174,7 +173,6 @@ private:
|
|||
void _setup_lightmaps(const RenderDataRD *p_render_data, const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform);
|
||||
|
||||
RID render_base_uniform_set;
|
||||
LocalVector<RID> render_pass_uniform_sets;
|
||||
|
||||
/* Light map */
|
||||
|
||||
|
|
@ -211,7 +209,7 @@ private:
|
|||
uint32_t flags;
|
||||
uint32_t instance_uniforms_ofs; // Base offset in global buffer for instance variables.
|
||||
uint32_t gi_offset; // GI information when using lightmapping (VCT or lightmap index).
|
||||
uint32_t layer_mask = 1;
|
||||
uint32_t layer_mask;
|
||||
float lightmap_uv_scale[4]; // Doubles as uv_offset when needed.
|
||||
uint32_t reflection_probes[2]; // Packed reflection probes.
|
||||
uint32_t omni_lights[2]; // Packed omni lights.
|
||||
|
|
@ -220,8 +218,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>);
|
||||
|
||||
RID instance_buffer[RENDER_LIST_MAX];
|
||||
uint32_t instance_buffer_size[RENDER_LIST_MAX] = { 0, 0, 0 };
|
||||
LocalVector<InstanceData> instance_data[RENDER_LIST_MAX];
|
||||
|
|
@ -239,9 +282,7 @@ private:
|
|||
RID lightmap_capture_buffer;
|
||||
|
||||
bool used_screen_texture = false;
|
||||
bool used_normal_texture = false;
|
||||
bool used_depth_texture = false;
|
||||
bool used_sss = false;
|
||||
bool used_lightmap = false;
|
||||
|
||||
struct ShadowPass {
|
||||
|
|
@ -322,11 +363,19 @@ private:
|
|||
};
|
||||
|
||||
struct RenderElementInfo {
|
||||
uint32_t uses_lightmap : 1;
|
||||
uint32_t lod_index : 8;
|
||||
uint32_t reserved : 23;
|
||||
union {
|
||||
struct {
|
||||
uint32_t lod_index : 8;
|
||||
uint32_t uses_lightmap : 1;
|
||||
uint32_t reserved : 23;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible_v<RenderElementInfo>);
|
||||
static_assert(std::is_trivially_constructible_v<RenderElementInfo>);
|
||||
|
||||
template <PassMode p_pass_mode>
|
||||
_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);
|
||||
|
|
@ -402,27 +451,22 @@ protected:
|
|||
uint64_t sort_key2;
|
||||
};
|
||||
struct {
|
||||
// !BAS! CHECK BITS!!!
|
||||
|
||||
uint64_t surface_index : 10;
|
||||
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_lightmap : 4; // sort by lightmap id here, not whether its yes/no (is 4 bits enough?)
|
||||
uint64_t lod_index : 8;
|
||||
uint64_t uses_lightmap : 1;
|
||||
uint64_t pad : 3;
|
||||
uint64_t depth_layer : 4;
|
||||
uint64_t surface_index : 8;
|
||||
uint64_t priority : 8;
|
||||
uint64_t geometry_id : 32;
|
||||
|
||||
// uint64_t lod_index : 8; // no need to sort on LOD
|
||||
// uint64_t uses_forward_gi : 1; // no GI here, remove
|
||||
uint64_t material_id : 32;
|
||||
uint64_t shader_id : 32;
|
||||
};
|
||||
} sort;
|
||||
|
||||
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;
|
||||
uint32_t flags = 0;
|
||||
uint32_t surface_index = 0;
|
||||
uint32_t lod_index = 0;
|
||||
|
||||
void *surface = nullptr;
|
||||
RID material_uniform_set;
|
||||
|
|
@ -613,6 +657,12 @@ public:
|
|||
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 depth_texture_used = false;
|
||||
} global_surface_data;
|
||||
|
||||
virtual RenderGeometryInstance *geometry_instance_create(RID p_base) override;
|
||||
virtual void geometry_instance_free(RenderGeometryInstance *p_geometry_instance) override;
|
||||
|
||||
|
|
@ -637,5 +687,3 @@ public:
|
|||
~RenderForwardMobile();
|
||||
};
|
||||
} // namespace RendererSceneRenderImplementation
|
||||
|
||||
#endif // RENDER_FORWARD_MOBILE_H
|
||||
|
|
|
|||
|
|
@ -552,9 +552,9 @@ void SceneShaderForwardMobile::init(const String p_defines) {
|
|||
|
||||
actions.renames["TIME"] = "scene_data_block.data.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_MOBILE_H
|
||||
#define SCENE_SHADER_FORWARD_MOBILE_H
|
||||
#pragma once
|
||||
|
||||
#include "../storage_rd/material_storage.h"
|
||||
#include "servers/rendering/renderer_rd/pipeline_hash_map_rd.h"
|
||||
|
|
@ -337,5 +336,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererSceneRenderImplementation
|
||||
|
||||
#endif // SCENE_SHADER_FORWARD_MOBILE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue