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
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CLUSTER_BUILDER_RD_H
|
||||
#define CLUSTER_BUILDER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/cluster_debug.glsl.gen.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/cluster_render.glsl.gen.h"
|
||||
|
|
@ -392,5 +391,3 @@ public:
|
|||
ClusterBuilderRD();
|
||||
~ClusterBuilderRD();
|
||||
};
|
||||
|
||||
#endif // CLUSTER_BUILDER_RD_H
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ thirdparty_dir = "#thirdparty/amd-fsr2/"
|
|||
thirdparty_sources = ["ffx_assert.cpp", "ffx_fsr2.cpp"]
|
||||
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
|
||||
|
||||
env_effects.Prepend(CPPPATH=[thirdparty_dir])
|
||||
env_effects.Prepend(CPPEXTPATH=[thirdparty_dir])
|
||||
|
||||
# This flag doesn't actually control anything GCC specific in FSR2. It determines
|
||||
# if symbols should be exported, which is not required for Godot.
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef BOKEH_DOF_RD_H
|
||||
#define BOKEH_DOF_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl.gen.h"
|
||||
|
|
@ -118,5 +117,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // BOKEH_DOF_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef COPY_EFFECTS_RD_H
|
||||
#define COPY_EFFECTS_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/blur_raster.glsl.gen.h"
|
||||
|
|
@ -358,5 +357,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // COPY_EFFECTS_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DEBUG_EFFECTS_RD_H
|
||||
#define DEBUG_EFFECTS_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/motion_vectors.glsl.gen.h"
|
||||
|
|
@ -94,5 +93,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // DEBUG_EFFECTS_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FSR_RD_H
|
||||
#define FSR_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "spatial_upscaler.h"
|
||||
|
||||
|
|
@ -71,5 +70,3 @@ private:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // FSR_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FSR2_RD_H
|
||||
#define FSR2_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/fsr2/fsr2_accumulate_pass.glsl.gen.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/fsr2/fsr2_autogen_reactive_pass.glsl.gen.h"
|
||||
|
|
@ -195,5 +194,3 @@ private:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // FSR2_RD_H
|
||||
|
|
|
|||
|
|
@ -102,9 +102,10 @@ void Luminance::LuminanceBuffers::configure(RenderSceneBuffersRD *p_render_buffe
|
|||
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
} else {
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
if (final) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
if (final) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
}
|
||||
|
||||
RID texture = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
|
@ -112,6 +113,7 @@ void Luminance::LuminanceBuffers::configure(RenderSceneBuffersRD *p_render_buffe
|
|||
|
||||
if (final) {
|
||||
current = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
RD::get_singleton()->texture_clear(current, Color(0.0, 0.0, 0.0), 0u, 1u, 0u, 1u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef LUMINANCE_RD_H
|
||||
#define LUMINANCE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/luminance_reduce.glsl.gen.h"
|
||||
|
|
@ -113,5 +112,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // LUMINANCE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef METAL_FX_RD_H
|
||||
#define METAL_FX_RD_H
|
||||
#pragma once
|
||||
|
||||
#ifdef METAL_ENABLED
|
||||
|
||||
|
|
@ -178,5 +177,3 @@ public:
|
|||
} //namespace RendererRD
|
||||
|
||||
#endif // METAL_ENABLED
|
||||
|
||||
#endif // METAL_FX_RD_H
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ MFXSpatialEffect::~MFXSpatialEffect() {
|
|||
}
|
||||
|
||||
void MFXSpatialEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
|
||||
|
||||
MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id);
|
||||
obj->end();
|
||||
|
|
@ -73,7 +72,7 @@ void MFXSpatialEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_bu
|
|||
|
||||
CallbackArgs::free(&p_userdata);
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
GODOT_CLANG_WARNING_POP
|
||||
}
|
||||
|
||||
void MFXSpatialEffect::ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) {
|
||||
|
|
@ -99,8 +98,7 @@ void MFXSpatialEffect::process(Ref<RenderSceneBuffersRD> p_render_buffers, RID p
|
|||
MFXSpatialContext *MFXSpatialEffect::create_context(CreateParams p_params) const {
|
||||
DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_SPATIAL));
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
|
||||
|
||||
RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver();
|
||||
PixelFormats &pf = rdd->get_pixel_formats();
|
||||
|
|
@ -120,7 +118,7 @@ MFXSpatialContext *MFXSpatialEffect::create_context(CreateParams p_params) const
|
|||
MFXSpatialContext *context = memnew(MFXSpatialContext);
|
||||
context->scaler = scaler;
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
GODOT_CLANG_WARNING_POP
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
@ -135,8 +133,7 @@ MFXTemporalEffect::~MFXTemporalEffect() {}
|
|||
MFXTemporalContext *MFXTemporalEffect::create_context(CreateParams p_params) const {
|
||||
DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_TEMPORAL));
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
|
||||
|
||||
RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver();
|
||||
PixelFormats &pf = rdd->get_pixel_formats();
|
||||
|
|
@ -164,7 +161,7 @@ MFXTemporalContext *MFXTemporalEffect::create_context(CreateParams p_params) con
|
|||
scaler.motionVectorScaleY = p_params.motion_vector_scale.y;
|
||||
scaler.depthReversed = true; // Godot uses reverse Z per https://github.com/godotengine/godot/pull/88328
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
GODOT_CLANG_WARNING_POP
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
@ -189,8 +186,7 @@ void MFXTemporalEffect::process(RendererRD::MFXTemporalContext *p_ctx, RendererR
|
|||
}
|
||||
|
||||
void MFXTemporalEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
|
||||
|
||||
MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id);
|
||||
obj->end();
|
||||
|
|
@ -221,5 +217,5 @@ void MFXTemporalEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_b
|
|||
|
||||
CallbackArgs::free(&p_userdata);
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
GODOT_CLANG_WARNING_POP
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MOTION_VECTORS_STORE_RD_H
|
||||
#define MOTION_VECTORS_STORE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/motion_vectors_store.glsl.gen.h"
|
||||
|
|
@ -58,5 +57,3 @@ public:
|
|||
const Projection &p_previous_projection, const Transform3D &p_previous_transform);
|
||||
};
|
||||
} //namespace RendererRD
|
||||
|
||||
#endif // MOTION_VECTORS_STORE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RESOLVE_RD_H
|
||||
#define RESOLVE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/resolve.glsl.gen.h"
|
||||
|
||||
|
|
@ -66,5 +65,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // RESOLVE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef ROUGHNESS_LIMITER_RD_H
|
||||
#define ROUGHNESS_LIMITER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/roughness_limiter.glsl.gen.h"
|
||||
|
||||
|
|
@ -59,5 +58,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // ROUGHNESS_LIMITER_RD_H
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SORT_EFFECTS_RD_H
|
||||
#define SORT_EFFECTS_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shader_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/sort.glsl.gen.h"
|
||||
|
||||
namespace RendererRD {
|
||||
|
|
@ -63,5 +63,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // SORT_EFFECTS_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SPATIAL_UPSCALER_RD_H
|
||||
#define SPATIAL_UPSCALER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
|
||||
|
|
@ -44,5 +43,3 @@ public:
|
|||
SpatialUpscaler() = default;
|
||||
virtual ~SpatialUpscaler() = default;
|
||||
};
|
||||
|
||||
#endif // SPATIAL_UPSCALER_RD_H
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ SSEffects::SSEffects() {
|
|||
int b = spmap[subPass];
|
||||
|
||||
float ca, sa;
|
||||
float angle0 = (float(a) + float(b) / float(sub_pass_count)) * Math_PI * 0.5f;
|
||||
float angle0 = (float(a) + float(b) / float(sub_pass_count)) * Math::PI * 0.5f;
|
||||
|
||||
ca = Math::cos(angle0);
|
||||
sa = Math::sin(angle0);
|
||||
|
|
@ -706,7 +706,7 @@ void SSEffects::screen_space_indirect_lighting(Ref<RenderSceneBuffersRD> p_rende
|
|||
}
|
||||
}
|
||||
radius_near_limit /= tan_half_fov_y;
|
||||
ssil.gather_push_constant.intensity = p_settings.intensity * Math_PI;
|
||||
ssil.gather_push_constant.intensity = p_settings.intensity * Math::PI;
|
||||
ssil.gather_push_constant.fade_out_mul = -1.0 / (ssil_fadeout_to - ssil_fadeout_from);
|
||||
ssil.gather_push_constant.fade_out_add = ssil_fadeout_from / (ssil_fadeout_to - ssil_fadeout_from) + 1.0;
|
||||
ssil.gather_push_constant.inv_radius_near_limit = 1.0f / radius_near_limit;
|
||||
|
|
@ -788,7 +788,7 @@ void SSEffects::screen_space_indirect_lighting(Ref<RenderSceneBuffersRD> p_rende
|
|||
RD::get_singleton()->draw_command_begin_label("Generate Importance Map");
|
||||
ssil.importance_map_push_constant.half_screen_pixel_size[0] = 1.0 / p_ssil_buffers.buffer_width;
|
||||
ssil.importance_map_push_constant.half_screen_pixel_size[1] = 1.0 / p_ssil_buffers.buffer_height;
|
||||
ssil.importance_map_push_constant.intensity = p_settings.intensity * Math_PI;
|
||||
ssil.importance_map_push_constant.intensity = p_settings.intensity * Math::PI;
|
||||
|
||||
//base pass
|
||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssil.pipelines[SSIL_GATHER_BASE]);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SS_EFFECTS_RD_H
|
||||
#define SS_EFFECTS_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl.gen.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection_filter.glsl.gen.h"
|
||||
|
|
@ -527,5 +526,3 @@ private:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // SS_EFFECTS_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TAA_RD_H
|
||||
#define TAA_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/taa_resolve.glsl.gen.h"
|
||||
#include "servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h"
|
||||
|
|
@ -59,5 +58,3 @@ private:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // TAA_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TONE_MAPPER_RD_H
|
||||
#define TONE_MAPPER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/tonemap.glsl.gen.h"
|
||||
|
|
@ -154,5 +153,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // TONE_MAPPER_RD_H
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@
|
|||
#include "../storage_rd/texture_storage.h"
|
||||
#include "../uniform_set_cache_rd.h"
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
#ifndef XR_DISABLED
|
||||
#include "servers/xr_server.h"
|
||||
#endif // _3D_DISABLED
|
||||
#endif // XR_DISABLED
|
||||
|
||||
using namespace RendererRD;
|
||||
|
||||
|
|
@ -44,6 +44,8 @@ VRS::VRS() {
|
|||
Vector<String> vrs_modes;
|
||||
vrs_modes.push_back("\n"); // VRS_DEFAULT
|
||||
vrs_modes.push_back("\n#define USE_MULTIVIEW\n"); // VRS_MULTIVIEW
|
||||
vrs_modes.push_back("\n#define SPLIT_RG\n"); // VRS_RG
|
||||
vrs_modes.push_back("\n#define SPLIT_RG\n#define USE_MULTIVIEW\n"); // VRS_RG_MULTIVIEW
|
||||
|
||||
vrs_shader.shader.initialize(vrs_modes);
|
||||
|
||||
|
|
@ -80,14 +82,16 @@ void VRS::copy_vrs(RID p_source_rd_texture, RID p_dest_framebuffer, bool p_multi
|
|||
|
||||
RD::Uniform u_source_rd_texture(RD::UNIFORM_TYPE_SAMPLER_WITH_TEXTURE, 0, Vector<RID>({ default_sampler, p_source_rd_texture }));
|
||||
|
||||
int mode = 0;
|
||||
VRSPushConstant push_constant = {};
|
||||
|
||||
int mode = p_multiview ? VRS_MULTIVIEW : VRS_DEFAULT;
|
||||
|
||||
// Set maximum texel factor based on maximum fragment size, some GPUs do not support 8x8 (fragment shading rate approach).
|
||||
if (MIN(RD::get_singleton()->limit_get(RD::LIMIT_VRS_MAX_FRAGMENT_WIDTH), RD::get_singleton()->limit_get(RD::LIMIT_VRS_MAX_FRAGMENT_HEIGHT)) > 4) {
|
||||
push_constant.max_texel_factor = 3.0;
|
||||
bool uses_rg_format = RD::get_singleton()->vrs_get_format() == RD::DATA_FORMAT_R8G8_UNORM;
|
||||
if (uses_rg_format) {
|
||||
mode = p_multiview ? VRS_RG_MULTIVIEW : VRS_RG;
|
||||
} else {
|
||||
mode = p_multiview ? VRS_MULTIVIEW : VRS_DEFAULT;
|
||||
|
||||
// Default to 4x4 as it's not possible to query the max fragment size from RenderingDevice. This can be improved to use the largest size
|
||||
// available if this code is moved over to RenderingDevice at some point.
|
||||
push_constant.max_texel_factor = 2.0;
|
||||
}
|
||||
|
||||
|
|
@ -103,18 +107,8 @@ void VRS::copy_vrs(RID p_source_rd_texture, RID p_dest_framebuffer, bool p_multi
|
|||
}
|
||||
|
||||
Size2i VRS::get_vrs_texture_size(const Size2i p_base_size) const {
|
||||
int32_t texel_width = RD::get_singleton()->limit_get(RD::LIMIT_VRS_TEXEL_WIDTH);
|
||||
int32_t texel_height = RD::get_singleton()->limit_get(RD::LIMIT_VRS_TEXEL_HEIGHT);
|
||||
|
||||
int width = p_base_size.x / texel_width;
|
||||
if (p_base_size.x % texel_width != 0) {
|
||||
width++;
|
||||
}
|
||||
int height = p_base_size.y / texel_height;
|
||||
if (p_base_size.y % texel_height != 0) {
|
||||
height++;
|
||||
}
|
||||
return Size2i(width, height);
|
||||
Size2i vrs_texel_size = RD::get_singleton()->vrs_get_texel_size();
|
||||
return Size2i((p_base_size.x + vrs_texel_size.x - 1) / vrs_texel_size.x, (p_base_size.y + vrs_texel_size.y - 1) / vrs_texel_size.y);
|
||||
}
|
||||
|
||||
void VRS::update_vrs_texture(RID p_vrs_fb, RID p_render_target) {
|
||||
|
|
@ -135,7 +129,7 @@ void VRS::update_vrs_texture(RID p_vrs_fb, RID p_render_target) {
|
|||
copy_vrs(rd_texture, p_vrs_fb, layers > 1);
|
||||
}
|
||||
}
|
||||
#ifndef _3D_DISABLED
|
||||
#ifndef XR_DISABLED
|
||||
} else if (vrs_mode == RS::VIEWPORT_VRS_XR) {
|
||||
Ref<XRInterface> interface = XRServer::get_singleton()->get_primary_interface();
|
||||
if (interface.is_valid()) {
|
||||
|
|
@ -150,7 +144,7 @@ void VRS::update_vrs_texture(RID p_vrs_fb, RID p_render_target) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // _3D_DISABLED
|
||||
#endif // XR_DISABLED
|
||||
}
|
||||
|
||||
if (vrs_update_mode == RS::VIEWPORT_VRS_UPDATE_ONCE) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef VRS_RD_H
|
||||
#define VRS_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
|
||||
#include "servers/rendering/renderer_rd/shaders/effects/vrs.glsl.gen.h"
|
||||
|
|
@ -41,6 +40,8 @@ private:
|
|||
enum VRSMode {
|
||||
VRS_DEFAULT,
|
||||
VRS_MULTIVIEW,
|
||||
VRS_RG,
|
||||
VRS_RG_MULTIVIEW,
|
||||
VRS_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -69,5 +70,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // VRS_RD_H
|
||||
|
|
|
|||
|
|
@ -205,9 +205,9 @@ void Fog::init_fog_shader(uint32_t p_max_directional_lights, int p_roughness_lay
|
|||
ShaderCompiler::DefaultIdentifierActions actions;
|
||||
|
||||
actions.renames["TIME"] = "scene_params.time";
|
||||
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["WORLD_POSITION"] = "world.xyz";
|
||||
actions.renames["OBJECT_POSITION"] = "params.position";
|
||||
actions.renames["UVW"] = "uvw";
|
||||
|
|
@ -437,8 +437,7 @@ void Fog::VolumetricFog::init(const Vector3i &fog_size, RID p_sky_shader) {
|
|||
|
||||
#if defined(MACOS_ENABLED) || defined(IOS_ENABLED)
|
||||
Vector<uint8_t> dm;
|
||||
dm.resize(fog_size.x * fog_size.y * fog_size.z * 4);
|
||||
dm.fill(0);
|
||||
dm.resize_zeroed(fog_size.x * fog_size.y * fog_size.z * 4);
|
||||
|
||||
density_map = RD::get_singleton()->storage_buffer_create(dm.size(), dm);
|
||||
RD::get_singleton()->set_resource_name(density_map, "Fog density map");
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FOG_RD_H
|
||||
#define FOG_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -355,5 +354,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // FOG_RD_H
|
||||
|
|
|
|||
|
|
@ -1214,7 +1214,7 @@ void GI::SDFGI::update(RID p_env, const Vector3 &p_world_position) {
|
|||
|
||||
if (cascade.dirty_regions[j] == 0) {
|
||||
continue; // not dirty
|
||||
} else if (uint32_t(ABS(cascade.dirty_regions[j])) >= cascade_size) {
|
||||
} else if (uint32_t(Math::abs(cascade.dirty_regions[j])) >= cascade_size) {
|
||||
//moved too much, just redraw everything (make all dirty)
|
||||
cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL;
|
||||
break;
|
||||
|
|
@ -1226,7 +1226,7 @@ void GI::SDFGI::update(RID p_env, const Vector3 &p_world_position) {
|
|||
uint32_t total_volume = cascade_size * cascade_size * cascade_size;
|
||||
uint32_t safe_volume = 1;
|
||||
for (int j = 0; j < 3; j++) {
|
||||
safe_volume *= cascade_size - ABS(cascade.dirty_regions[j]);
|
||||
safe_volume *= cascade_size - Math::abs(cascade.dirty_regions[j]);
|
||||
}
|
||||
uint32_t dirty_volume = total_volume - safe_volume;
|
||||
if (dirty_volume > (safe_volume / 2)) {
|
||||
|
|
@ -1674,7 +1674,7 @@ void GI::SDFGI::debug_probes(RID p_framebuffer, const uint32_t p_view_count, con
|
|||
push_constant.band_power = 4;
|
||||
push_constant.sections_in_band = ((band_points / 2) - 1);
|
||||
push_constant.band_mask = band_points - 2;
|
||||
push_constant.section_arc = Math_TAU / float(push_constant.sections_in_band);
|
||||
push_constant.section_arc = Math::TAU / float(push_constant.sections_in_band);
|
||||
push_constant.y_mult = y_mult;
|
||||
|
||||
uint32_t total_points = push_constant.sections_in_band * band_points;
|
||||
|
|
@ -1977,11 +1977,11 @@ void GI::SDFGI::pre_process_gi(const Transform3D &p_transform, RenderDataRD *p_r
|
|||
|
||||
// Convert from Luminous Power to Luminous Intensity
|
||||
if (lights[idx].type == RS::LIGHT_OMNI) {
|
||||
lights[idx].energy *= 1.0 / (Math_PI * 4.0);
|
||||
lights[idx].energy *= 1.0 / (Math::PI * 4.0);
|
||||
} else if (lights[idx].type == RS::LIGHT_SPOT) {
|
||||
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
|
||||
// We make this assumption to keep them easy to control.
|
||||
lights[idx].energy *= 1.0 / Math_PI;
|
||||
lights[idx].energy *= 1.0 / Math::PI;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2079,9 +2079,9 @@ void GI::SDFGI::render_region(Ref<RenderSceneBuffersRD> p_render_buffers, int p_
|
|||
|
||||
Vector3i dirty = cascades[cascade].dirty_regions;
|
||||
Vector3i groups;
|
||||
groups.x = cascade_size - ABS(dirty.x);
|
||||
groups.y = cascade_size - ABS(dirty.y);
|
||||
groups.z = cascade_size - ABS(dirty.z);
|
||||
groups.x = cascade_size - Math::abs(dirty.x);
|
||||
groups.y = cascade_size - Math::abs(dirty.y);
|
||||
groups.z = cascade_size - Math::abs(dirty.z);
|
||||
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant));
|
||||
RD::get_singleton()->compute_list_dispatch_threads(compute_list, groups.x, groups.y, groups.z);
|
||||
|
|
@ -2440,11 +2440,11 @@ void GI::SDFGI::render_static_lights(RenderDataRD *p_render_data, Ref<RenderScen
|
|||
|
||||
// Convert from Luminous Power to Luminous Intensity
|
||||
if (lights[idx].type == RS::LIGHT_OMNI) {
|
||||
lights[idx].energy *= 1.0 / (Math_PI * 4.0);
|
||||
lights[idx].energy *= 1.0 / (Math::PI * 4.0);
|
||||
} else if (lights[idx].type == RS::LIGHT_SPOT) {
|
||||
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
|
||||
// We make this assumption to keep them easy to control.
|
||||
lights[idx].energy *= 1.0 / Math_PI;
|
||||
lights[idx].energy *= 1.0 / Math::PI;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2676,13 +2676,13 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
|
|||
dtf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
|
||||
if (dynamic_maps.size() == 0) {
|
||||
if (dynamic_maps.is_empty()) {
|
||||
dtf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
dmap.texture = RD::get_singleton()->texture_create(dtf, RD::TextureView());
|
||||
RD::get_singleton()->set_resource_name(dmap.texture, "VoxelGI Instance DMap Texture");
|
||||
|
||||
if (dynamic_maps.size() == 0) {
|
||||
if (dynamic_maps.is_empty()) {
|
||||
// Render depth for first one.
|
||||
// Use 16-bit depth when supported to improve performance.
|
||||
dtf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D16_UNORM, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_D16_UNORM : RD::DATA_FORMAT_X8_D24_UNORM_PACK32;
|
||||
|
|
@ -2698,7 +2698,7 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
|
|||
dmap.depth = RD::get_singleton()->texture_create(dtf, RD::TextureView());
|
||||
RD::get_singleton()->set_resource_name(dmap.depth, "VoxelGI Instance DMap Depth");
|
||||
|
||||
if (dynamic_maps.size() == 0) {
|
||||
if (dynamic_maps.is_empty()) {
|
||||
dtf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
dmap.albedo = RD::get_singleton()->texture_create(dtf, RD::TextureView());
|
||||
|
|
@ -2906,11 +2906,11 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
|
|||
|
||||
// Convert from Luminous Power to Luminous Intensity
|
||||
if (l.type == RS::LIGHT_OMNI) {
|
||||
l.energy *= 1.0 / (Math_PI * 4.0);
|
||||
l.energy *= 1.0 / (Math::PI * 4.0);
|
||||
} else if (l.type == RS::LIGHT_SPOT) {
|
||||
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
|
||||
// We make this assumption to keep them easy to control.
|
||||
l.energy *= 1.0 / Math_PI;
|
||||
l.energy *= 1.0 / Math::PI;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3279,7 +3279,7 @@ void GI::VoxelGIInstance::free_resources() {
|
|||
void GI::VoxelGIInstance::debug(RD::DrawListID p_draw_list, RID p_framebuffer, const Projection &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
|
||||
RendererRD::MaterialStorage *material_storage = RendererRD::MaterialStorage::get_singleton();
|
||||
|
||||
if (mipmaps.size() == 0) {
|
||||
if (mipmaps.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GI_RD_H
|
||||
#define GI_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -829,5 +828,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // GI_RD_H
|
||||
|
|
|
|||
|
|
@ -722,6 +722,12 @@ SkyRD::SkyRD() {
|
|||
roughness_layers = GLOBAL_GET("rendering/reflections/sky_reflections/roughness_layers");
|
||||
sky_ggx_samples_quality = GLOBAL_GET("rendering/reflections/sky_reflections/ggx_samples");
|
||||
sky_use_cubemap_array = GLOBAL_GET("rendering/reflections/sky_reflections/texture_array_reflections");
|
||||
#if defined(MACOS_ENABLED) && defined(__x86_64__)
|
||||
if (OS::get_singleton()->get_current_rendering_driver_name() == "vulkan" && RenderingServer::get_singleton()->get_video_adapter_name().contains("Intel")) {
|
||||
// Disable texture array reflections on macOS on Intel GPUs due to driver bugs.
|
||||
sky_use_cubemap_array = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkyRD::init() {
|
||||
|
|
@ -777,9 +783,9 @@ void SkyRD::init() {
|
|||
actions.renames["SCREEN_UV"] = "uv";
|
||||
actions.renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions.renames["TIME"] = "params.time";
|
||||
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["HALF_RES_COLOR"] = "half_res_color";
|
||||
actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
|
||||
actions.renames["RADIANCE"] = "radiance";
|
||||
|
|
@ -1093,15 +1099,7 @@ void SkyRD::setup_sky(const RenderDataRD *p_render_data, const Size2i p_screen_s
|
|||
sky_light_data.enabled = true;
|
||||
|
||||
float angular_diameter = light_storage->light_get_param(base, RS::LIGHT_PARAM_SIZE);
|
||||
if (angular_diameter > 0.0) {
|
||||
// I know tan(0) is 0, but let's not risk it with numerical precision.
|
||||
// Technically this will keep expanding until reaching the sun, but all we care about
|
||||
// is expanding until we reach the radius of the near plane. There can't be more occluders than that.
|
||||
angular_diameter = Math::tan(Math::deg_to_rad(angular_diameter));
|
||||
} else {
|
||||
angular_diameter = 0.0;
|
||||
}
|
||||
sky_light_data.size = angular_diameter;
|
||||
sky_light_data.size = Math::deg_to_rad(angular_diameter);
|
||||
sky_scene_state.ubo.directional_light_count++;
|
||||
if (sky_scene_state.ubo.directional_light_count >= sky_scene_state.max_directional_lights) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKY_RD_H
|
||||
#define SKY_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/rid_owner.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
|
|
@ -319,5 +318,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // SKY_RD_H
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FRAMEBUFFER_CACHE_RD_H
|
||||
#define FRAMEBUFFER_CACHE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/paged_allocator.h"
|
||||
|
|
@ -59,7 +58,6 @@ class FramebufferCacheRD : public Object {
|
|||
|
||||
static _FORCE_INLINE_ uint32_t _hash_pass(const RD::FramebufferPass &p, uint32_t h) {
|
||||
h = hash_murmur3_one_32(p.depth_attachment, h);
|
||||
h = hash_murmur3_one_32(p.vrs_attachment, h);
|
||||
|
||||
h = hash_murmur3_one_32(p.color_attachments.size(), h);
|
||||
for (int i = 0; i < p.color_attachments.size(); i++) {
|
||||
|
|
@ -84,10 +82,6 @@ class FramebufferCacheRD : public Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (a.vrs_attachment != b.vrs_attachment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.color_attachments.size() != b.color_attachments.size()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -213,7 +207,7 @@ public:
|
|||
const Cache *c = hash_table[table_idx];
|
||||
|
||||
while (c) {
|
||||
if (c->hash == h && c->passes.size() == 0 && c->textures.size() == sizeof...(Args) && c->views == 1 && _compare_args(0, c->textures, args...)) {
|
||||
if (c->hash == h && c->passes.is_empty() && c->textures.size() == sizeof...(Args) && c->views == 1 && _compare_args(0, c->textures, args...)) {
|
||||
return c->cache;
|
||||
}
|
||||
c = c->next;
|
||||
|
|
@ -241,7 +235,7 @@ public:
|
|||
const Cache *c = hash_table[table_idx];
|
||||
|
||||
while (c) {
|
||||
if (c->hash == h && c->passes.size() == 0 && c->textures.size() == sizeof...(Args) && c->views == p_views && _compare_args(0, c->textures, args...)) {
|
||||
if (c->hash == h && c->passes.is_empty() && c->textures.size() == sizeof...(Args) && c->views == p_views && _compare_args(0, c->textures, args...)) {
|
||||
return c->cache;
|
||||
}
|
||||
c = c->next;
|
||||
|
|
@ -312,5 +306,3 @@ public:
|
|||
FramebufferCacheRD();
|
||||
~FramebufferCacheRD();
|
||||
};
|
||||
|
||||
#endif // FRAMEBUFFER_CACHE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PIPELINE_CACHE_RD_H
|
||||
#define PIPELINE_CACHE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/spin_lock.h"
|
||||
#include "servers/rendering/rendering_device.h"
|
||||
|
|
@ -98,5 +97,3 @@ public:
|
|||
PipelineCacheRD();
|
||||
~PipelineCacheRD();
|
||||
};
|
||||
|
||||
#endif // PIPELINE_CACHE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PIPELINE_HASH_MAP_RD_H
|
||||
#define PIPELINE_HASH_MAP_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/rendering_device.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
|
@ -78,9 +77,17 @@ private:
|
|||
}
|
||||
|
||||
void _wait_for_all_pipelines() {
|
||||
MutexLock local_lock(local_mutex);
|
||||
for (KeyValue<uint32_t, WorkerThreadPool::TaskID> key_value : compilation_tasks) {
|
||||
WorkerThreadPool::get_singleton()->wait_for_task_completion(key_value.value);
|
||||
thread_local LocalVector<WorkerThreadPool::TaskID> tasks_to_wait;
|
||||
tasks_to_wait.clear();
|
||||
{
|
||||
MutexLock local_lock(local_mutex);
|
||||
for (KeyValue<uint32_t, WorkerThreadPool::TaskID> key_value : compilation_tasks) {
|
||||
tasks_to_wait.push_back(key_value.value);
|
||||
}
|
||||
}
|
||||
|
||||
for (WorkerThreadPool::TaskID task_id : tasks_to_wait) {
|
||||
WorkerThreadPool::get_singleton()->wait_for_task_completion(task_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,17 +145,25 @@ public:
|
|||
}
|
||||
|
||||
void wait_for_pipeline(uint32_t p_key_hash) {
|
||||
MutexLock local_lock(local_mutex);
|
||||
if (!compilation_set.has(p_key_hash)) {
|
||||
// The pipeline was never submitted, we can't wait for it.
|
||||
return;
|
||||
WorkerThreadPool::TaskID task_id_to_wait = WorkerThreadPool::INVALID_TASK_ID;
|
||||
|
||||
{
|
||||
MutexLock local_lock(local_mutex);
|
||||
if (!compilation_set.has(p_key_hash)) {
|
||||
// The pipeline was never submitted, we can't wait for it.
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<uint32_t, WorkerThreadPool::TaskID>::Iterator task_it = compilation_tasks.find(p_key_hash);
|
||||
if (task_it != compilation_tasks.end()) {
|
||||
// Wait for and remove the compilation task if it exists.
|
||||
task_id_to_wait = task_it->value;
|
||||
compilation_tasks.remove(task_it);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<uint32_t, WorkerThreadPool::TaskID>::Iterator task_it = compilation_tasks.find(p_key_hash);
|
||||
if (task_it != compilation_tasks.end()) {
|
||||
// Wait for and remove the compilation task if it exists.
|
||||
WorkerThreadPool::get_singleton()->wait_for_task_completion(task_it->value);
|
||||
compilation_tasks.remove(task_it);
|
||||
if (task_id_to_wait != WorkerThreadPool::INVALID_TASK_ID) {
|
||||
WorkerThreadPool::get_singleton()->wait_for_task_completion(task_id_to_wait);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,5 +232,3 @@ public:
|
|||
clear_pipelines();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // PIPELINE_HASH_MAP_RD_H
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ static RD::RenderPrimitive _primitive_type_to_render_primitive(RS::PrimitiveType
|
|||
|
||||
_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];
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +379,8 @@ RID RendererCanvasRenderRD::_create_base_uniform_set(RID p_to_render_target, boo
|
|||
RendererRD::MaterialStorage *material_storage = RendererRD::MaterialStorage::get_singleton();
|
||||
|
||||
//re create canvas state
|
||||
Vector<RD::Uniform> uniforms;
|
||||
thread_local LocalVector<RD::Uniform> uniforms;
|
||||
uniforms.clear();
|
||||
|
||||
{
|
||||
RD::Uniform u;
|
||||
|
|
@ -1021,8 +1022,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
|
|||
|
||||
cl->shadow.z_far = p_far;
|
||||
cl->shadow.y_offset = float(p_shadow_index * 2 + 1) / float(state.max_lights_per_render * 2);
|
||||
Vector<Color> cc;
|
||||
cc.push_back(Color(p_far, p_far, p_far, 1.0));
|
||||
Color cc = Color(p_far, p_far, p_far, 1.0);
|
||||
|
||||
// First, do a culling pass and record what occluders need to be drawn for this light.
|
||||
static thread_local LocalVector<OccluderPolygon *> occluders;
|
||||
|
|
@ -1075,7 +1075,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
|
|||
}
|
||||
|
||||
Rect2i rect(0, p_shadow_index * 2, state.shadow_texture_size, 2);
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(state.shadow_fb, RD::DRAW_CLEAR_ALL, cc, 1.0f, 0, rect);
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(state.shadow_fb, RD::DRAW_CLEAR_ALL, VectorView(&cc, 1), 1.0f, 0, rect);
|
||||
|
||||
if (state.shadow_occluder_buffer.is_valid()) {
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, shadow_render.render_pipelines[SHADOW_RENDER_MODE_POSITIONAL_SHADOW]);
|
||||
|
|
@ -1129,7 +1129,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
|
|||
|
||||
Vector2 center = p_clip_rect.get_center();
|
||||
|
||||
float to_edge_distance = ABS(light_dir.dot(p_clip_rect.get_support(-light_dir)) - light_dir.dot(center));
|
||||
float to_edge_distance = Math::abs(light_dir.dot(p_clip_rect.get_support(-light_dir)) - light_dir.dot(center));
|
||||
|
||||
Vector2 from_pos = center - light_dir * (to_edge_distance + p_cull_distance);
|
||||
float distance = to_edge_distance * 2.0 + p_cull_distance;
|
||||
|
|
@ -1299,7 +1299,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
|
|||
}
|
||||
}
|
||||
|
||||
if ((oc->line_point_count != lines.size() || lines.size() == 0) && oc->vertex_array.is_valid()) {
|
||||
if ((oc->line_point_count != lines.size() || lines.is_empty()) && oc->vertex_array.is_valid()) {
|
||||
RD::get_singleton()->free(oc->vertex_array);
|
||||
RD::get_singleton()->free(oc->vertex_buffer);
|
||||
RD::get_singleton()->free(oc->index_array);
|
||||
|
|
@ -1404,7 +1404,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
|
|||
}
|
||||
}
|
||||
|
||||
if (((oc->sdf_index_count != sdf_indices.size() && oc->sdf_point_count != p_points.size()) || p_points.size() == 0) && oc->sdf_vertex_array.is_valid()) {
|
||||
if (((oc->sdf_index_count != sdf_indices.size() && oc->sdf_point_count != p_points.size()) || p_points.is_empty()) && oc->sdf_vertex_array.is_valid()) {
|
||||
RD::get_singleton()->free(oc->sdf_vertex_array);
|
||||
RD::get_singleton()->free(oc->sdf_vertex_buffer);
|
||||
RD::get_singleton()->free(oc->sdf_index_array);
|
||||
|
|
@ -1773,9 +1773,9 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
|
|||
actions.renames["CANVAS_MATRIX"] = "canvas_data.canvas_transform";
|
||||
actions.renames["SCREEN_MATRIX"] = "canvas_data.screen_transform";
|
||||
actions.renames["TIME"] = "canvas_data.time";
|
||||
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["AT_LIGHT_PASS"] = "false";
|
||||
actions.renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
|
||||
|
|
@ -1837,7 +1837,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
|
|||
actions.base_varying_index = 5;
|
||||
|
||||
actions.global_buffer_array_variable = "global_shader_uniforms.data";
|
||||
actions.instance_uniform_index_variable = "draw_data.instance_uniforms_ofs";
|
||||
actions.instance_uniform_index_variable = "instances.data[instance_index].instance_uniforms_ofs";
|
||||
|
||||
shader.compiler.initialize(actions);
|
||||
}
|
||||
|
|
@ -2219,7 +2219,7 @@ void RendererCanvasRenderRD::_render_batch_items(RenderTarget p_to_render_target
|
|||
RID framebuffer;
|
||||
RID fb_uniform_set;
|
||||
bool clear = false;
|
||||
Vector<Color> clear_colors;
|
||||
Color clear_color;
|
||||
|
||||
if (p_to_backbuffer) {
|
||||
framebuffer = texture_storage->render_target_get_rd_backbuffer_framebuffer(p_to_render_target.render_target);
|
||||
|
|
@ -2230,7 +2230,7 @@ void RendererCanvasRenderRD::_render_batch_items(RenderTarget p_to_render_target
|
|||
|
||||
if (texture_storage->render_target_is_clear_requested(p_to_render_target.render_target)) {
|
||||
clear = true;
|
||||
clear_colors.push_back(texture_storage->render_target_get_clear_request_color(p_to_render_target.render_target));
|
||||
clear_color = texture_storage->render_target_get_clear_request_color(p_to_render_target.render_target);
|
||||
texture_storage->render_target_disable_clear_request(p_to_render_target.render_target);
|
||||
}
|
||||
// TODO: Obtain from framebuffer format eventually when this is implemented.
|
||||
|
|
@ -2243,7 +2243,7 @@ void RendererCanvasRenderRD::_render_batch_items(RenderTarget p_to_render_target
|
|||
|
||||
RD::FramebufferFormatID fb_format = RD::get_singleton()->framebuffer_get_format(framebuffer);
|
||||
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, clear ? RD::DRAW_CLEAR_COLOR_0 : RD::DRAW_DEFAULT_ALL, clear_colors, 1.0f, 0, Rect2(), RDD::BreadcrumbMarker::UI_PASS);
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, clear ? RD::DRAW_CLEAR_COLOR_0 : RD::DRAW_DEFAULT_ALL, clear_color, 1.0f, 0, Rect2(), RDD::BreadcrumbMarker::UI_PASS);
|
||||
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, fb_uniform_set, BASE_UNIFORM_SET);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, state.default_transforms_uniform_set, TRANSFORMS_UNIFORM_SET);
|
||||
|
|
@ -3200,7 +3200,7 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, CanvasSha
|
|||
}
|
||||
|
||||
RendererCanvasRenderRD::Batch *RendererCanvasRenderRD::_new_batch(bool &r_batch_broken) {
|
||||
if (state.canvas_instance_batches.size() == 0) {
|
||||
if (state.canvas_instance_batches.is_empty()) {
|
||||
Batch new_batch;
|
||||
new_batch.instance_buffer_index = state.current_instance_buffer_index;
|
||||
state.canvas_instance_batches.push_back(new_batch);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDERER_CANVAS_RENDER_RD_H
|
||||
#define RENDERER_CANVAS_RENDER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/lru.h"
|
||||
#include "servers/rendering/renderer_canvas_render.h"
|
||||
|
|
@ -526,7 +525,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
uint32_t flags = 0;
|
||||
};
|
||||
|
||||
HashMap<TextureState, TextureInfo, HashableHasher<TextureState>> texture_info_map;
|
||||
HashMap<TextureState, TextureInfo, HashableHasher<TextureState>, HashMapComparatorDefault<TextureState>, PagedAllocator<HashMapElement<TextureState, TextureInfo>>> texture_info_map;
|
||||
|
||||
// per-frame buffers
|
||||
struct DataBuffer {
|
||||
|
|
@ -667,5 +666,3 @@ public:
|
|||
RendererCanvasRenderRD();
|
||||
~RendererCanvasRenderRD();
|
||||
};
|
||||
|
||||
#endif // RENDERER_CANVAS_RENDER_RD_H
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID
|
|||
RID rd_texture = texture_storage->render_target_get_rd_texture(p_render_targets[i].render_target);
|
||||
ERR_CONTINUE(rd_texture.is_null());
|
||||
|
||||
if (!render_target_descriptors.has(rd_texture) || !RD::get_singleton()->uniform_set_is_valid(render_target_descriptors[rd_texture])) {
|
||||
HashMap<RID, RID>::Iterator it = render_target_descriptors.find(rd_texture);
|
||||
if (it == render_target_descriptors.end() || !RD::get_singleton()->uniform_set_is_valid(it->value)) {
|
||||
Vector<RD::Uniform> uniforms;
|
||||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_SAMPLER_WITH_TEXTURE;
|
||||
|
|
@ -60,14 +61,14 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID
|
|||
uniforms.push_back(u);
|
||||
RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, blit.shader.version_get_shader(blit.shader_version, BLIT_MODE_NORMAL), 0);
|
||||
|
||||
render_target_descriptors[rd_texture] = uniform_set;
|
||||
it = render_target_descriptors.insert(rd_texture, uniform_set);
|
||||
}
|
||||
|
||||
Size2 screen_size(RD::get_singleton()->screen_get_width(p_screen), RD::get_singleton()->screen_get_height(p_screen));
|
||||
BlitMode mode = p_render_targets[i].lens_distortion.apply ? BLIT_MODE_LENS : (p_render_targets[i].multi_view.use_layer ? BLIT_MODE_USE_LAYER : BLIT_MODE_NORMAL);
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blit.pipelines[mode]);
|
||||
RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, it->value, 0);
|
||||
|
||||
// We need to invert the phone rotation.
|
||||
const int screen_rotation_degrees = -RD::get_singleton()->screen_get_pre_rotation_degrees(p_screen);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDERER_COMPOSITOR_RD_H
|
||||
#define RENDERER_COMPOSITOR_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/image.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
|
|
@ -125,6 +124,7 @@ public:
|
|||
void begin_frame(double frame_step);
|
||||
void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
|
||||
|
||||
bool is_opengl() { return false; }
|
||||
void gl_end_frame(bool p_swap_buffers) {}
|
||||
void end_frame(bool p_present);
|
||||
void finalize();
|
||||
|
|
@ -151,5 +151,3 @@ public:
|
|||
RendererCompositorRD();
|
||||
~RendererCompositorRD();
|
||||
};
|
||||
|
||||
#endif // RENDERER_COMPOSITOR_RD_H
|
||||
|
|
|
|||
|
|
@ -309,16 +309,38 @@ void RendererSceneRenderRD::_process_compositor_effects(RS::CompositorEffectCall
|
|||
Vector<RID> re_rids = comp_storage->compositor_get_compositor_effects(p_render_data->compositor, p_callback_type, true);
|
||||
|
||||
for (RID rid : re_rids) {
|
||||
Array arr;
|
||||
Callable callback = comp_storage->compositor_effect_get_callback(rid);
|
||||
|
||||
arr.push_back(p_callback_type);
|
||||
arr.push_back(p_render_data);
|
||||
|
||||
Array arr = { p_callback_type, p_render_data };
|
||||
callback.callv(arr);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererSceneRenderRD::_render_buffers_ensure_screen_texture(const RenderDataRD *p_render_data) {
|
||||
Ref<RenderSceneBuffersRD> rb = p_render_data->render_buffers;
|
||||
ERR_FAIL_COND(rb.is_null());
|
||||
|
||||
if (!rb->has_internal_texture()) {
|
||||
// We're likely rendering reflection probes where we can't use our backbuffers.
|
||||
return;
|
||||
}
|
||||
|
||||
bool can_use_storage = _render_buffers_can_be_storage();
|
||||
Size2i size = rb->get_internal_size();
|
||||
|
||||
// When upscaling, the blur texture needs to be at the target size for post-processing to work. We prefer to use a
|
||||
// dedicated backbuffer copy texture instead if the blur texture is not an option so shader effects work correctly.
|
||||
Size2i target_size = rb->get_target_size();
|
||||
bool internal_size_matches = (size.width == target_size.width) && (size.height == target_size.height);
|
||||
bool reuse_blur_texture = !rb->has_upscaled_texture() || internal_size_matches;
|
||||
if (reuse_blur_texture) {
|
||||
rb->allocate_blur_textures();
|
||||
} else {
|
||||
uint32_t usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
usage_bits |= can_use_storage ? RD::TEXTURE_USAGE_STORAGE_BIT : RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
rb->create_texture(RB_SCOPE_BUFFERS, RB_TEX_BACK_COLOR, rb->get_base_data_format(), usage_bits);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderDataRD *p_render_data) {
|
||||
Ref<RenderSceneBuffersRD> rb = p_render_data->render_buffers;
|
||||
ERR_FAIL_COND(rb.is_null());
|
||||
|
|
@ -340,12 +362,8 @@ void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderData
|
|||
bool internal_size_matches = (size.width == target_size.width) && (size.height == target_size.height);
|
||||
bool reuse_blur_texture = !rb->has_upscaled_texture() || internal_size_matches;
|
||||
if (reuse_blur_texture) {
|
||||
rb->allocate_blur_textures();
|
||||
texture_name = RB_TEX_BLUR_0;
|
||||
} else {
|
||||
uint32_t usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
usage_bits |= can_use_storage ? RD::TEXTURE_USAGE_STORAGE_BIT : RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
rb->create_texture(RB_SCOPE_BUFFERS, RB_TEX_BACK_COLOR, rb->get_base_data_format(), usage_bits);
|
||||
texture_name = RB_TEX_BACK_COLOR;
|
||||
}
|
||||
|
||||
|
|
@ -377,6 +395,23 @@ void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderData
|
|||
RD::get_singleton()->draw_command_end_label();
|
||||
}
|
||||
|
||||
void RendererSceneRenderRD::_render_buffers_ensure_depth_texture(const RenderDataRD *p_render_data) {
|
||||
Ref<RenderSceneBuffersRD> rb = p_render_data->render_buffers;
|
||||
ERR_FAIL_COND(rb.is_null());
|
||||
|
||||
if (!rb->has_depth_texture()) {
|
||||
// We're likely rendering reflection probes where we can't use our backbuffers.
|
||||
return;
|
||||
}
|
||||
|
||||
// Note, this only creates our back depth texture if we haven't already created it.
|
||||
uint32_t usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; // Set this as color attachment because we're copying data into it, it's not actually used as a depth buffer
|
||||
|
||||
rb->create_texture(RB_SCOPE_BUFFERS, RB_TEX_BACK_DEPTH, RD::DATA_FORMAT_R32_SFLOAT, usage_bits, RD::TEXTURE_SAMPLES_1);
|
||||
}
|
||||
|
||||
void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataRD *p_render_data) {
|
||||
Ref<RenderSceneBuffersRD> rb = p_render_data->render_buffers;
|
||||
ERR_FAIL_COND(rb.is_null());
|
||||
|
|
@ -388,13 +423,6 @@ void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataR
|
|||
|
||||
RD::get_singleton()->draw_command_begin_label("Copy depth texture");
|
||||
|
||||
// note, this only creates our back depth texture if we haven't already created it.
|
||||
uint32_t usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; // set this as color attachment because we're copying data into it, it's not actually used as a depth buffer
|
||||
|
||||
rb->create_texture(RB_SCOPE_BUFFERS, RB_TEX_BACK_DEPTH, RD::DATA_FORMAT_R32_SFLOAT, usage_bits, RD::TEXTURE_SAMPLES_1);
|
||||
|
||||
bool can_use_storage = _render_buffers_can_be_storage();
|
||||
Size2i size = rb->get_internal_size();
|
||||
for (uint32_t v = 0; v < p_render_data->scene_data->view_count; v++) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDERER_SCENE_RENDER_RD_H
|
||||
#define RENDERER_SCENE_RENDER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
#include "servers/rendering/renderer_rd/effects/bokeh_dof.h"
|
||||
|
|
@ -103,7 +102,9 @@ protected:
|
|||
bool _compositor_effects_has_flag(const RenderDataRD *p_render_data, RS::CompositorEffectFlags p_flag, RS::CompositorEffectCallbackType p_callback_type = RS::COMPOSITOR_EFFECT_CALLBACK_TYPE_ANY);
|
||||
bool _has_compositor_effect(RS::CompositorEffectCallbackType p_callback_type, const RenderDataRD *p_render_data);
|
||||
void _process_compositor_effects(RS::CompositorEffectCallbackType p_callback_type, const RenderDataRD *p_render_data);
|
||||
void _render_buffers_ensure_screen_texture(const RenderDataRD *p_render_data);
|
||||
void _render_buffers_copy_screen_texture(const RenderDataRD *p_render_data);
|
||||
void _render_buffers_ensure_depth_texture(const RenderDataRD *p_render_data);
|
||||
void _render_buffers_copy_depth_texture(const RenderDataRD *p_render_data);
|
||||
void _render_buffers_post_process_and_tonemap(const RenderDataRD *p_render_data);
|
||||
void _post_process_subpass(RID p_source_texture, RID p_framebuffer, const RenderDataRD *p_render_data);
|
||||
|
|
@ -342,5 +343,3 @@ public:
|
|||
RendererSceneRenderRD();
|
||||
~RendererSceneRenderRD();
|
||||
};
|
||||
|
||||
#endif // RENDERER_SCENE_RENDER_RD_H
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void ShaderRD::_add_stage(const char *p_code, StageType p_stage_type) {
|
|||
} else if (l.begins_with("#CODE")) {
|
||||
chunk.type = StageTemplate::Chunk::TYPE_CODE;
|
||||
push_chunk = true;
|
||||
chunk.code = l.replace_first("#CODE", String()).replace(":", "").strip_edges().to_upper();
|
||||
chunk.code = l.replace_first("#CODE", String()).remove_char(':').strip_edges().to_upper();
|
||||
} else if (l.begins_with("#include ")) {
|
||||
String include_file = l.replace("#include ", "").strip_edges();
|
||||
if (include_file[0] == '"') {
|
||||
|
|
@ -149,9 +149,9 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
|
|||
|
||||
StringBuilder tohash;
|
||||
tohash.append("[GodotVersionNumber]");
|
||||
tohash.append(VERSION_NUMBER);
|
||||
tohash.append(GODOT_VERSION_NUMBER);
|
||||
tohash.append("[GodotVersionHash]");
|
||||
tohash.append(VERSION_HASH);
|
||||
tohash.append(GODOT_VERSION_HASH);
|
||||
tohash.append("[SpirvCacheKey]");
|
||||
tohash.append(RenderingDevice::get_singleton()->shader_get_spirv_cache_key());
|
||||
tohash.append("[BinaryCacheKey]");
|
||||
|
|
@ -187,8 +187,7 @@ void ShaderRD::_initialize_version(Version *p_version) {
|
|||
|
||||
p_version->variants.resize_zeroed(variant_defines.size());
|
||||
p_version->variant_data.resize(variant_defines.size());
|
||||
p_version->group_compilation_tasks.resize(group_enabled.size());
|
||||
p_version->group_compilation_tasks.fill(0);
|
||||
p_version->group_compilation_tasks.resize_zeroed(group_enabled.size());
|
||||
}
|
||||
|
||||
void ShaderRD::_clear_version(Version *p_version) {
|
||||
|
|
@ -283,7 +282,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, CompileData p_data) {
|
|||
current_source = builder.as_string();
|
||||
RD::ShaderStageSPIRVData stage;
|
||||
stage.spirv = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_VERTEX, current_source, RD::SHADER_LANGUAGE_GLSL, &error);
|
||||
if (stage.spirv.size() == 0) {
|
||||
if (stage.spirv.is_empty()) {
|
||||
build_ok = false;
|
||||
} else {
|
||||
stage.shader_stage = RD::SHADER_STAGE_VERTEX;
|
||||
|
|
@ -301,7 +300,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, CompileData p_data) {
|
|||
current_source = builder.as_string();
|
||||
RD::ShaderStageSPIRVData stage;
|
||||
stage.spirv = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_FRAGMENT, current_source, RD::SHADER_LANGUAGE_GLSL, &error);
|
||||
if (stage.spirv.size() == 0) {
|
||||
if (stage.spirv.is_empty()) {
|
||||
build_ok = false;
|
||||
} else {
|
||||
stage.shader_stage = RD::SHADER_STAGE_FRAGMENT;
|
||||
|
|
@ -320,7 +319,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, CompileData p_data) {
|
|||
|
||||
RD::ShaderStageSPIRVData stage;
|
||||
stage.spirv = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_COMPUTE, current_source, RD::SHADER_LANGUAGE_GLSL, &error);
|
||||
if (stage.spirv.size() == 0) {
|
||||
if (stage.spirv.is_empty()) {
|
||||
build_ok = false;
|
||||
} else {
|
||||
stage.shader_stage = RD::SHADER_STAGE_COMPUTE;
|
||||
|
|
@ -555,7 +554,7 @@ void ShaderRD::_compile_version_start(Version *p_version, int p_group) {
|
|||
compile_data.version = p_version;
|
||||
compile_data.group = p_group;
|
||||
|
||||
WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &ShaderRD::_compile_variant, compile_data, group_to_variant_map[p_group].size(), -1, true, SNAME("ShaderCompilation"));
|
||||
WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_named_pool(SNAME("ShaderCompilationPool"))->add_template_group_task(this, &ShaderRD::_compile_variant, compile_data, group_to_variant_map[p_group].size(), -1, true, SNAME("ShaderCompilation"));
|
||||
p_version->group_compilation_tasks.write[p_group] = group_task;
|
||||
}
|
||||
|
||||
|
|
@ -563,9 +562,8 @@ void ShaderRD::_compile_version_end(Version *p_version, int p_group) {
|
|||
if (p_version->group_compilation_tasks.size() <= p_group || p_version->group_compilation_tasks[p_group] == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorkerThreadPool::GroupID group_task = p_version->group_compilation_tasks[p_group];
|
||||
WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task);
|
||||
WorkerThreadPool::get_named_pool(SNAME("ShaderCompilationPool"))->wait_for_group_task_completion(group_task);
|
||||
p_version->group_compilation_tasks.write[p_group] = 0;
|
||||
|
||||
bool all_valid = true;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SHADER_RD_H
|
||||
#define SHADER_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/string/string_builder.h"
|
||||
|
|
@ -216,5 +215,3 @@ public:
|
|||
|
||||
virtual ~ShaderRD();
|
||||
};
|
||||
|
||||
#endif // SHADER_RD_H
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ layout(location = 11) in vec4 weight_attrib;
|
|||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
#ifndef USE_ATTRIBUTES
|
||||
|
||||
layout(location = 4) out flat uint instance_index_interp;
|
||||
|
||||
#endif // !USE_ATTRIBUTES
|
||||
layout(location = 4) out flat uint instance_index;
|
||||
#else
|
||||
#define instance_index params.base_instance_index
|
||||
#endif // USE_ATTRIBUTES
|
||||
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
layout(location = 1) out vec4 color_interp;
|
||||
|
|
@ -65,11 +65,8 @@ void main() {
|
|||
vec4 custom1 = vec4(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
uint instance_index = params.base_instance_index;
|
||||
#else
|
||||
uint instance_index = gl_InstanceIndex + params.base_instance_index;
|
||||
instance_index_interp = instance_index;
|
||||
#ifndef USE_ATTRIBUTES
|
||||
instance_index = gl_InstanceIndex + params.base_instance_index;
|
||||
#endif // USE_ATTRIBUTES
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
|
||||
|
|
@ -241,6 +238,8 @@ void main() {
|
|||
|
||||
#ifndef USE_ATTRIBUTES
|
||||
layout(location = 4) in flat uint instance_index;
|
||||
#else
|
||||
#define instance_index params.base_instance_index
|
||||
#endif // USE_ATTRIBUTES
|
||||
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
|
|
@ -302,6 +301,7 @@ vec4 light_compute(
|
|||
vec2 screen_uv,
|
||||
vec2 uv,
|
||||
vec4 color, bool is_directional) {
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
vec4 light = vec4(0.0);
|
||||
vec3 light_direction = vec3(0.0);
|
||||
|
||||
|
|
@ -460,11 +460,7 @@ void main() {
|
|||
vec2 uv = uv_interp;
|
||||
vec2 vertex = vertex_interp;
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
const InstanceData draw_data = instances.data[params.base_instance_index];
|
||||
#else
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
#endif // USE_ATTRIBUTES
|
||||
|
||||
#if !defined(USE_ATTRIBUTES) && !defined(USE_PRIMITIVE)
|
||||
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@ void SSAO_tap_inner(const int p_quality_level, inout float r_obscurance_sum, ino
|
|||
float weight = 1.0;
|
||||
|
||||
if (p_quality_level >= SSAO_HALOING_REDUCTION_ENABLE_AT_QUALITY_PRESET) {
|
||||
float reduct = max(0, -hit_delta.z);
|
||||
reduct = clamp(reduct * params.neg_inv_radius + 2.0, 0.0, 1.0);
|
||||
weight = SSAO_HALOING_REDUCTION_AMOUNT * reduct + (1.0 - SSAO_HALOING_REDUCTION_AMOUNT);
|
||||
float reduce = max(0, -hit_delta.z);
|
||||
reduce = clamp(reduce * params.neg_inv_radius + 2.0, 0.0, 1.0);
|
||||
weight = SSAO_HALOING_REDUCTION_AMOUNT * reduce + (1.0 - SSAO_HALOING_REDUCTION_AMOUNT);
|
||||
}
|
||||
weight *= p_weight_mod;
|
||||
r_obscurance_sum += obscurance * weight;
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@ void SSIL_tap_inner(const int p_quality_level, inout vec3 r_color_sum, inout flo
|
|||
float weight = 1.0;
|
||||
|
||||
if (p_quality_level >= SSIL_HALOING_REDUCTION_ENABLE_AT_QUALITY_PRESET) {
|
||||
float reduct = max(0, -hit_delta.z);
|
||||
reduct = clamp(reduct * params.neg_inv_radius + 2.0, 0.0, 1.0);
|
||||
weight = SSIL_HALOING_REDUCTION_AMOUNT * reduct + (1.0 - SSIL_HALOING_REDUCTION_AMOUNT);
|
||||
float reduce = max(0, -hit_delta.z);
|
||||
reduce = clamp(reduce * params.neg_inv_radius + 2.0, 0.0, 1.0);
|
||||
weight = SSIL_HALOING_REDUCTION_AMOUNT * reduce + (1.0 - SSIL_HALOING_REDUCTION_AMOUNT);
|
||||
}
|
||||
|
||||
// Translate sampling_uv to last screen's coordinates
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@ layout(location = 0) in vec2 uv_interp;
|
|||
layout(set = 0, binding = 0) uniform sampler2D source_color;
|
||||
#endif /* USE_MULTIVIEW */
|
||||
|
||||
#ifdef SPLIT_RG
|
||||
layout(location = 0) out vec2 frag_color;
|
||||
#else
|
||||
layout(location = 0) out uint frag_color;
|
||||
#endif
|
||||
|
||||
layout(push_constant, std430) uniform Params {
|
||||
float max_texel_factor;
|
||||
|
|
@ -79,6 +83,10 @@ void main() {
|
|||
// Input is standardized. R for X, G for Y, 0.0 (0) = 1, 0.33 (85) = 2, 0.66 (170) = 3, 1.0 (255) = 8
|
||||
vec4 color = textureLod(source_color, uv, 0.0);
|
||||
|
||||
#ifdef SPLIT_RG
|
||||
// Density map for VRS according to VK_EXT_fragment_density_map, we can use as is.
|
||||
frag_color = max(vec2(1.0f) - color.rg, vec2(1.0f / 255.0f));
|
||||
#else
|
||||
// Output image shading rate image for VRS according to VK_KHR_fragment_shading_rate.
|
||||
color.r = clamp(floor(color.r * params.max_texel_factor + 0.1), 0.0, params.max_texel_factor);
|
||||
color.g = clamp(floor(color.g * params.max_texel_factor + 0.1), 0.0, params.max_texel_factor);
|
||||
|
|
@ -94,4 +102,5 @@ void main() {
|
|||
// Encode to frag_color;
|
||||
frag_color = int(color.r + 0.1) << 2;
|
||||
frag_color += int(color.g + 0.1);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FORWARD_ID_STORAGE_H
|
||||
#define FORWARD_ID_STORAGE_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -64,5 +63,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // FORWARD_ID_STORAGE_H
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
|
|||
if (RendererSceneRenderRD::get_singleton()->is_using_physical_light_units()) {
|
||||
light_data.energy *= light->param[RS::LIGHT_PARAM_INTENSITY];
|
||||
} else {
|
||||
light_data.energy *= Math_PI;
|
||||
light_data.energy *= Math::PI;
|
||||
}
|
||||
|
||||
if (p_render_data->camera_attributes.is_valid()) {
|
||||
|
|
@ -714,7 +714,9 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
|
|||
light_data.shadow_split_offsets[j] = split;
|
||||
float bias_scale = light_instance->shadow_transform[j].bias_scale * light_data.soft_shadow_scale;
|
||||
light_data.shadow_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_BIAS] / 100.0 * bias_scale;
|
||||
light_data.shadow_normal_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * light_instance->shadow_transform[j].shadow_texel_size;
|
||||
// Use lower shadow normal bias for distant splits, relative to the share taken by the split.
|
||||
// This helps reduce peter-panning at a distance.
|
||||
light_data.shadow_normal_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * light_instance->shadow_transform[j].shadow_texel_size * light_data.shadow_split_offsets[0] / split;
|
||||
light_data.shadow_transmittance_bias[j] = light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] / 100.0 * bias_scale;
|
||||
light_data.shadow_z_range[j] = light_instance->shadow_transform[j].farplane;
|
||||
light_data.shadow_range_begin[j] = light_instance->shadow_transform[j].range_begin;
|
||||
|
|
@ -864,14 +866,14 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
|
|||
|
||||
// Convert from Luminous Power to Luminous Intensity
|
||||
if (type == RS::LIGHT_OMNI) {
|
||||
energy *= 1.0 / (Math_PI * 4.0);
|
||||
energy *= 1.0 / (Math::PI * 4.0);
|
||||
} else {
|
||||
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
|
||||
// We make this assumption to keep them easy to control.
|
||||
energy *= 1.0 / Math_PI;
|
||||
energy *= 1.0 / Math::PI;
|
||||
}
|
||||
} else {
|
||||
energy *= Math_PI;
|
||||
energy *= Math::PI;
|
||||
}
|
||||
|
||||
if (p_render_data->camera_attributes.is_valid()) {
|
||||
|
|
@ -1998,7 +2000,7 @@ void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point,
|
|||
return; //nothing could be done
|
||||
}
|
||||
|
||||
node = ABS(node) - 1;
|
||||
node = Math::abs(node) - 1;
|
||||
|
||||
uint32_t *tetrahedron = (uint32_t *)&lm->tetrahedra[node * 4];
|
||||
Vector3 points[4] = { lm->points[tetrahedron[0]], lm->points[tetrahedron[1]], lm->points[tetrahedron[2]], lm->points[tetrahedron[3]] };
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef LIGHT_STORAGE_RD_H
|
||||
#define LIGHT_STORAGE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/paged_array.h"
|
||||
|
|
@ -1164,5 +1163,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // LIGHT_STORAGE_RD_H
|
||||
|
|
|
|||
|
|
@ -1137,7 +1137,7 @@ bool MaterialStorage::MaterialData::update_parameters_uniform_set(const HashMap<
|
|||
update_textures(p_parameters, p_default_texture_params, p_texture_uniforms, texture_cache.ptrw(), p_use_linear_color, p_3d_material);
|
||||
}
|
||||
|
||||
if (p_ubo_size == 0 && (p_texture_uniforms.size() == 0)) {
|
||||
if (p_ubo_size == 0 && (p_texture_uniforms.is_empty())) {
|
||||
// This material does not require an uniform set, so don't create it.
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1705,7 +1705,7 @@ void MaterialStorage::global_shader_parameters_load_settings(bool p_load_texture
|
|||
|
||||
for (const PropertyInfo &E : settings) {
|
||||
if (E.name.begins_with("shader_globals/")) {
|
||||
StringName name = E.name.get_slice("/", 1);
|
||||
StringName name = E.name.get_slicec('/', 1);
|
||||
Dictionary d = GLOBAL_GET(E.name);
|
||||
|
||||
ERR_CONTINUE(!d.has("type"));
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MATERIAL_STORAGE_RD_H
|
||||
#define MATERIAL_STORAGE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "texture_storage.h"
|
||||
|
||||
|
|
@ -469,5 +468,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // MATERIAL_STORAGE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MESH_STORAGE_RD_H
|
||||
#define MESH_STORAGE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "../../rendering_server_globals.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
|
|
@ -799,5 +798,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // MESH_STORAGE_RD_H
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ ParticlesStorage::ParticlesStorage() {
|
|||
}
|
||||
actions.renames["TRANSFORM"] = "PARTICLE.xform";
|
||||
actions.renames["TIME"] = "frame_history.data[0].time";
|
||||
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["LIFETIME"] = "params.lifetime";
|
||||
actions.renames["DELTA"] = "local_delta";
|
||||
actions.renames["NUMBER"] = "particle_number";
|
||||
|
|
@ -765,7 +765,8 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
|
||||
if (p_particles->particles_material_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(p_particles->particles_material_uniform_set)) {
|
||||
Vector<RD::Uniform> uniforms;
|
||||
thread_local LocalVector<RD::Uniform> uniforms;
|
||||
uniforms.clear();
|
||||
|
||||
{
|
||||
RD::Uniform u;
|
||||
|
|
@ -814,7 +815,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
p_particles->particles_material_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, particles_shader.default_shader_rd, 1);
|
||||
}
|
||||
|
||||
double new_phase = Math::fmod((double)p_particles->phase + (p_delta / p_particles->lifetime) * p_particles->speed_scale, 1.0);
|
||||
double new_phase = Math::fmod((double)p_particles->phase + (p_delta / p_particles->lifetime), 1.0);
|
||||
|
||||
//move back history (if there is any)
|
||||
for (uint32_t i = p_particles->frame_history.size() - 1; i > 0; i--) {
|
||||
|
|
@ -839,7 +840,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
p_particles->phase = new_phase;
|
||||
|
||||
frame_params.time = RendererCompositorRD::get_singleton()->get_total_time();
|
||||
frame_params.delta = p_delta * p_particles->speed_scale;
|
||||
frame_params.delta = p_delta;
|
||||
frame_params.random_seed = p_particles->random_seed;
|
||||
frame_params.explosiveness = p_particles->explosiveness;
|
||||
frame_params.randomness = p_particles->randomness;
|
||||
|
|
@ -1071,7 +1072,8 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
RD::get_singleton()->free(p_particles->collision_textures_uniform_set);
|
||||
}
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
thread_local LocalVector<RD::Uniform> uniforms;
|
||||
uniforms.clear();
|
||||
|
||||
{
|
||||
RD::Uniform u;
|
||||
|
|
@ -1158,6 +1160,10 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
//fill the trail params
|
||||
for (uint32_t i = 0; i < p_particles->trail_params.size(); i++) {
|
||||
uint32_t src_idx = i * p_particles->frame_history.size() / p_particles->trail_params.size();
|
||||
if (p_particles->speed_scale <= 0.0) {
|
||||
// Stop trails.
|
||||
src_idx = 0;
|
||||
}
|
||||
p_particles->trail_params[i] = p_particles->frame_history[src_idx];
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1529,7 +1535,6 @@ void ParticlesStorage::update_particles() {
|
|||
}
|
||||
}
|
||||
|
||||
bool zero_time_scale = Engine::get_singleton()->get_time_scale() <= 0.0;
|
||||
double todo = particles->request_process_time;
|
||||
if (particles->clear) {
|
||||
todo += particles->pre_process_time;
|
||||
|
|
@ -1554,37 +1559,26 @@ void ParticlesStorage::update_particles() {
|
|||
particles->speed_scale = tmp_scale;
|
||||
}
|
||||
|
||||
double time_scale = MAX(particles->speed_scale, 0.0);
|
||||
|
||||
if (fixed_fps > 0) {
|
||||
double frame_time;
|
||||
double decr;
|
||||
if (zero_time_scale) {
|
||||
frame_time = 0.0;
|
||||
decr = 1.0 / fixed_fps;
|
||||
} else {
|
||||
frame_time = 1.0 / fixed_fps;
|
||||
decr = frame_time;
|
||||
}
|
||||
double frame_time = 1.0 / fixed_fps;
|
||||
double delta = RendererCompositorRD::get_singleton()->get_frame_delta_time();
|
||||
if (delta > 0.1) { //avoid recursive stalls if fps goes below 10
|
||||
delta = 0.1;
|
||||
} else if (delta <= 0.0) { //unlikely but..
|
||||
delta = 0.001;
|
||||
}
|
||||
todo = particles->frame_remainder + delta;
|
||||
todo = particles->frame_remainder + delta * time_scale;
|
||||
|
||||
while (todo >= frame_time || particles->clear) {
|
||||
_particles_process(particles, frame_time);
|
||||
todo -= decr;
|
||||
todo -= frame_time;
|
||||
}
|
||||
|
||||
particles->frame_remainder = todo;
|
||||
|
||||
} else {
|
||||
if (zero_time_scale) {
|
||||
_particles_process(particles, 0.0);
|
||||
} else {
|
||||
_particles_process(particles, RendererCompositorRD::get_singleton()->get_frame_delta_time());
|
||||
}
|
||||
_particles_process(particles, RendererCompositorRD::get_singleton()->get_frame_delta_time() * time_scale);
|
||||
}
|
||||
|
||||
// Ensure that memory is initialized (the code above should ensure that _particles_process is always called at least once upon clearing).
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PARTICLES_STORAGE_RD_H
|
||||
#define PARTICLES_STORAGE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -597,5 +596,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // PARTICLES_STORAGE_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_BUFFER_CUSTOM_DATA_RD_H
|
||||
#define RENDER_BUFFER_CUSTOM_DATA_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
|
||||
|
|
@ -44,5 +43,3 @@ public:
|
|||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // RENDER_BUFFER_CUSTOM_DATA_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_DATA_RD_H
|
||||
#define RENDER_DATA_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h"
|
||||
#include "servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h"
|
||||
|
|
@ -96,5 +95,3 @@ public:
|
|||
|
||||
uint32_t voxel_gi_count = 0;
|
||||
};
|
||||
|
||||
#endif // RENDER_DATA_RD_H
|
||||
|
|
|
|||
|
|
@ -325,9 +325,7 @@ RID RenderSceneBuffersRD::create_texture_from_format(const StringName &p_context
|
|||
named_texture.is_unique = p_unique;
|
||||
named_texture.texture = RD::get_singleton()->texture_create(p_texture_format, p_view);
|
||||
|
||||
Array arr;
|
||||
arr.push_back(p_context);
|
||||
arr.push_back(p_texture_name);
|
||||
Array arr = { p_context, p_texture_name };
|
||||
RD::get_singleton()->set_resource_name(named_texture.texture, String("RenderBuffer {0}/{1}").format(arr));
|
||||
|
||||
update_sizes(named_texture);
|
||||
|
|
@ -366,9 +364,7 @@ RID RenderSceneBuffersRD::create_texture_view(const StringName &p_context, const
|
|||
|
||||
view_texture.texture = RD::get_singleton()->texture_create_shared(p_view, named_texture.texture);
|
||||
|
||||
Array arr;
|
||||
arr.push_back(p_context);
|
||||
arr.push_back(p_view_name);
|
||||
Array arr = { p_context, p_view_name };
|
||||
RD::get_singleton()->set_resource_name(view_texture.texture, String("RenderBuffer View {0}/{1}").format(arr));
|
||||
|
||||
update_sizes(named_texture);
|
||||
|
|
@ -446,18 +442,19 @@ RID RenderSceneBuffersRD::get_texture_slice_view(const StringName &p_context, co
|
|||
RID &slice = named_texture.slices[slice_key];
|
||||
slice = RD::get_singleton()->texture_create_shared_from_slice(p_view, named_texture.texture, p_layer, p_mipmap, p_mipmaps, p_layers > 1 ? RD::TEXTURE_SLICE_2D_ARRAY : RD::TEXTURE_SLICE_2D, p_layers);
|
||||
|
||||
Array arr;
|
||||
arr.push_back(p_context);
|
||||
arr.push_back(p_texture_name);
|
||||
arr.push_back(itos(p_layer));
|
||||
arr.push_back(itos(p_layers));
|
||||
arr.push_back(itos(p_mipmap));
|
||||
arr.push_back(itos(p_mipmaps));
|
||||
arr.push_back(itos(p_view.format_override));
|
||||
arr.push_back(itos(p_view.swizzle_r));
|
||||
arr.push_back(itos(p_view.swizzle_g));
|
||||
arr.push_back(itos(p_view.swizzle_b));
|
||||
arr.push_back(itos(p_view.swizzle_a));
|
||||
Array arr = {
|
||||
p_context,
|
||||
p_texture_name,
|
||||
itos(p_layer),
|
||||
itos(p_layers),
|
||||
itos(p_mipmap),
|
||||
itos(p_mipmaps),
|
||||
itos(p_view.format_override),
|
||||
itos(p_view.swizzle_r),
|
||||
itos(p_view.swizzle_g),
|
||||
itos(p_view.swizzle_b),
|
||||
itos(p_view.swizzle_a)
|
||||
};
|
||||
RD::get_singleton()->set_resource_name(slice, String("RenderBuffer {0}/{1}, layer {2}/{3}, mipmap {4}/{5}, view {6}/{7}/{8}/{9}/{10}").format(arr));
|
||||
|
||||
// and return our slice
|
||||
|
|
@ -756,9 +753,9 @@ uint32_t RenderSceneBuffersRD::get_velocity_usage_bits(bool p_resolve, bool p_ms
|
|||
}
|
||||
|
||||
RD::DataFormat RenderSceneBuffersRD::get_vrs_format() {
|
||||
return RD::DATA_FORMAT_R8_UINT;
|
||||
return RD::get_singleton()->vrs_get_format();
|
||||
}
|
||||
|
||||
uint32_t RenderSceneBuffersRD::get_vrs_usage_bits() {
|
||||
return RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
return RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_SCENE_BUFFERS_RD_H
|
||||
#define RENDER_SCENE_BUFFERS_RD_H
|
||||
#pragma once
|
||||
|
||||
#ifdef METAL_ENABLED
|
||||
#include "../effects/metal_fx.h"
|
||||
|
|
@ -451,5 +450,3 @@ public:
|
|||
// 2 full size, 2 half size
|
||||
WeightBuffers weight_buffers[4]; // Only used in raster
|
||||
};
|
||||
|
||||
#endif // RENDER_SCENE_BUFFERS_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDER_SCENE_DATA_RD_H
|
||||
#define RENDER_SCENE_DATA_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/rendering/renderer_scene_render.h"
|
||||
#include "servers/rendering/storage/render_scene_data.h"
|
||||
|
|
@ -174,5 +173,3 @@ private:
|
|||
UBO prev_ubo;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // RENDER_SCENE_DATA_RD_H
|
||||
|
|
|
|||
|
|
@ -482,17 +482,15 @@ TextureStorage::TextureStorage() {
|
|||
}
|
||||
}
|
||||
|
||||
{ //create default VRS
|
||||
|
||||
{
|
||||
// Create default VRS texture.
|
||||
bool vrs_supported = RD::get_singleton()->has_feature(RD::SUPPORTS_ATTACHMENT_VRS);
|
||||
RD::TextureFormat tformat;
|
||||
tformat.format = RD::DATA_FORMAT_R8_UINT;
|
||||
tformat.format = vrs_supported ? RD::get_singleton()->vrs_get_format() : RD::DATA_FORMAT_R8_UINT;
|
||||
tformat.width = 4;
|
||||
tformat.height = 4;
|
||||
tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT;
|
||||
tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | (vrs_supported ? RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT : 0);
|
||||
tformat.texture_type = RD::TEXTURE_TYPE_2D;
|
||||
if (!RD::get_singleton()->has_feature(RD::SUPPORTS_ATTACHMENT_VRS)) {
|
||||
tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT;
|
||||
}
|
||||
|
||||
Vector<uint8_t> pv;
|
||||
pv.resize(4 * 4);
|
||||
|
|
@ -1275,15 +1273,21 @@ RID TextureStorage::texture_create_from_native_handle(RS::TextureType p_type, Im
|
|||
break;
|
||||
|
||||
case Image::FORMAT_ASTC_4x4:
|
||||
case Image::FORMAT_ASTC_4x4_HDR:
|
||||
format = RD::DATA_FORMAT_ASTC_4x4_UNORM_BLOCK;
|
||||
break;
|
||||
|
||||
case Image::FORMAT_ASTC_4x4_HDR:
|
||||
format = RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK;
|
||||
break;
|
||||
|
||||
case Image::FORMAT_ASTC_8x8:
|
||||
case Image::FORMAT_ASTC_8x8_HDR:
|
||||
format = RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK;
|
||||
break;
|
||||
|
||||
case Image::FORMAT_ASTC_8x8_HDR:
|
||||
format = RD::DATA_FORMAT_ASTC_8x8_SFLOAT_BLOCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Arbitrary fallback.
|
||||
format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
|
|
@ -1639,8 +1643,8 @@ void TextureStorage::texture_debug_usage(List<RS::TextureInfo> *r_info) {
|
|||
List<RID> textures;
|
||||
texture_owner.get_owned_list(&textures);
|
||||
|
||||
for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
|
||||
Texture *t = texture_owner.get_or_null(E->get());
|
||||
for (const RID &rid : textures) {
|
||||
Texture *t = texture_owner.get_or_null(rid);
|
||||
if (!t) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2197,24 +2201,16 @@ Ref<Image> TextureStorage::_validate_texture_format(const Ref<Image> &p_image, T
|
|||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_ASTC_4x4:
|
||||
case Image::FORMAT_ASTC_4x4_HDR: {
|
||||
case Image::FORMAT_ASTC_4x4: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_4x4_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ASTC_4x4_UNORM_BLOCK;
|
||||
if (p_image->get_format() == Image::FORMAT_ASTC_4x4) {
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ASTC_4x4_SRGB_BLOCK;
|
||||
}
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ASTC_4x4_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
image->decompress();
|
||||
if (p_image->get_format() == Image::FORMAT_ASTC_4x4) {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
} else {
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
|
|
@ -2222,24 +2218,31 @@ Ref<Image> TextureStorage::_validate_texture_format(const Ref<Image> &p_image, T
|
|||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; // astc 4x4
|
||||
case Image::FORMAT_ASTC_8x8:
|
||||
case Image::FORMAT_ASTC_8x8_HDR: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK;
|
||||
if (p_image->get_format() == Image::FORMAT_ASTC_8x8) {
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ASTC_8x8_SRGB_BLOCK;
|
||||
}
|
||||
case Image::FORMAT_ASTC_4x4_HDR: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
image->decompress();
|
||||
if (p_image->get_format() == Image::FORMAT_ASTC_8x8) {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
} else {
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; // astc 4x4 HDR
|
||||
case Image::FORMAT_ASTC_8x8: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ASTC_8x8_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
image->decompress();
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
|
|
@ -2247,6 +2250,21 @@ Ref<Image> TextureStorage::_validate_texture_format(const Ref<Image> &p_image, T
|
|||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; // astc 8x8
|
||||
case Image::FORMAT_ASTC_8x8_HDR: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_8x8_SFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ASTC_8x8_SFLOAT_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
image->decompress();
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; // astc 8x8 HDR
|
||||
|
||||
default: {
|
||||
}
|
||||
|
|
@ -2589,7 +2607,7 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
|
|||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case RD::DATA_FORMAT_ASTC_4x4_SRGB_BLOCK: {
|
||||
r_format.image_format = Image::FORMAT_ASTC_4x4_HDR;
|
||||
r_format.image_format = Image::FORMAT_ASTC_4x4;
|
||||
r_format.rd_format = RD::DATA_FORMAT_ASTC_4x4_UNORM_BLOCK;
|
||||
r_format.rd_format_srgb = RD::DATA_FORMAT_ASTC_4x4_SRGB_BLOCK;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
|
|
@ -2597,6 +2615,14 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
|
|||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break;
|
||||
case RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK: {
|
||||
r_format.image_format = Image::FORMAT_ASTC_4x4_HDR;
|
||||
r_format.rd_format = RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break; // astc 4x4
|
||||
case RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK: {
|
||||
// Q: Do we do as we do below, just create the sRGB variant?
|
||||
|
|
@ -2608,14 +2634,21 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
|
|||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case RD::DATA_FORMAT_ASTC_8x8_SRGB_BLOCK: {
|
||||
r_format.image_format = Image::FORMAT_ASTC_8x8_HDR;
|
||||
r_format.image_format = Image::FORMAT_ASTC_8x8;
|
||||
r_format.rd_format = RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK;
|
||||
r_format.rd_format_srgb = RD::DATA_FORMAT_ASTC_8x8_SRGB_BLOCK;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break;
|
||||
case RD::DATA_FORMAT_ASTC_8x8_SFLOAT_BLOCK: {
|
||||
r_format.image_format = Image::FORMAT_ASTC_8x8_HDR;
|
||||
r_format.rd_format = RD::DATA_FORMAT_ASTC_8x8_SFLOAT_BLOCK;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break; // astc 8x8
|
||||
|
||||
default: {
|
||||
|
|
@ -3684,7 +3717,7 @@ RID TextureStorage::render_target_get_rd_texture_slice(RID p_render_target, uint
|
|||
return rt->color;
|
||||
} else {
|
||||
ERR_FAIL_UNSIGNED_INDEX_V(p_layer, rt->view_count, RID());
|
||||
if (rt->color_slices.size() == 0) {
|
||||
if (rt->color_slices.is_empty()) {
|
||||
for (uint32_t v = 0; v < rt->view_count; v++) {
|
||||
RID slice = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rt->color, v, 0);
|
||||
rt->color_slices.push_back(slice);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEXTURE_STORAGE_RD_H
|
||||
#define TEXTURE_STORAGE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/paged_array.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -820,5 +819,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // TEXTURE_STORAGE_RD_H
|
||||
|
|
|
|||
|
|
@ -286,6 +286,10 @@ bool Utilities::has_os_feature(const String &p_feature) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (p_feature == "astc_hdr" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef UTILITIES_RD_H
|
||||
#define UTILITIES_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/rid_owner.h"
|
||||
#include "servers/rendering/storage/utilities.h"
|
||||
|
|
@ -122,5 +121,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace RendererRD
|
||||
|
||||
#endif // UTILITIES_RD_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef UNIFORM_SET_CACHE_RD_H
|
||||
#define UNIFORM_SET_CACHE_RD_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/paged_allocator.h"
|
||||
|
|
@ -226,5 +225,3 @@ public:
|
|||
UniformSetCacheRD();
|
||||
~UniformSetCacheRD();
|
||||
};
|
||||
|
||||
#endif // UNIFORM_SET_CACHE_RD_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue