Renderer: Eliminates String allocations for all labels in the renderer

Uses `Span<char>` to avoid additional allocations in the graph.
This commit is contained in:
Stuart Carnie
2025-05-23 06:52:10 +10:00
parent 6c9765d87e
commit 7d93119353
10 changed files with 30 additions and 19 deletions

View File

@@ -38,13 +38,11 @@
namespace RendererRD {
class FSR : public SpatialUpscaler {
String name = "FSR 1.0 Upscale";
public:
FSR();
~FSR();
virtual String get_label() const final { return name; }
virtual const Span<char> get_label() const final { return "FSR 1.0 Upscale"; }
virtual void ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) final {}
virtual void process(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_source_rd_texture, RID p_destination_texture) final;

View File

@@ -76,10 +76,9 @@ class MFXSpatialEffect : public SpatialUpscaler {
PagedAllocator<CallbackArgs, true, 16> args_allocator;
static void callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata);
String name = "MetalFX Spatial Upscale";
public:
virtual String get_label() const final { return name; }
virtual const Span<char> get_label() const final { return "MetalFX Spatial Upscale"; }
virtual void ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) final;
virtual void process(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_src, RID p_dst) final;

View File

@@ -36,7 +36,7 @@ class RenderSceneBuffersRD;
class SpatialUpscaler {
public:
virtual String get_label() const = 0;
virtual const Span<char> get_label() const = 0;
virtual void ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) = 0;
virtual void process(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_source_rd_texture, RID p_destination_texture) = 0;

View File

@@ -985,7 +985,7 @@ void SSEffects::gather_ssao(RD::ComputeListID p_compute_list, const RID *p_ao_sl
continue;
}
RD::Uniform u_ao_slice(RD::UNIFORM_TYPE_IMAGE, 0, Vector<RID>({ p_ao_slices[i] }));
RD::Uniform u_ao_slice(RD::UNIFORM_TYPE_IMAGE, 0, p_ao_slices[i]);
ssao.gather_push_constant.pass_coord_offset[0] = i % 2;
ssao.gather_push_constant.pass_coord_offset[1] = i / 2;
@@ -1419,7 +1419,11 @@ void SSEffects::screen_space_reflection(Ref<RenderSceneBuffersRD> p_render_buffe
blur_radius[1] = p_render_buffers->get_texture_slice(RB_SCOPE_SSR, RB_BLUR_RADIUS, 1, 0);
}
RD::get_singleton()->draw_command_begin_label(String("SSR View ") + itos(v));
{
char label[16];
int len = snprintf(label, sizeof(label), "SSR View %d", v);
RD::get_singleton()->draw_command_begin_label(Span<char>(label, len));
}
{ //scale color and depth to half
RD::get_singleton()->draw_command_begin_label("SSR Scale");