scope_exit: Make constexpr

Allows the use of the macro in constexpr-contexts.
Also avoids some potential problems when nesting braces inside it.
This commit is contained in:
FearlessTobi
2024-02-19 16:00:46 +01:00
parent 665fce871f
commit 310c1f50be
58 changed files with 421 additions and 226 deletions

View File

@ -291,7 +291,9 @@ u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
}
void Maxwell3D::ConsumeSinkImpl() {
SCOPE_EXIT({ method_sink.clear(); });
SCOPE_EXIT {
method_sink.clear();
};
const auto control = shadow_state.shadow_ram_control;
if (control == Regs::ShadowRamControl::Track ||
control == Regs::ShadowRamControl::TrackWithFilter) {

View File

@ -197,7 +197,9 @@ private:
MicroProfileOnThreadCreate(name.c_str());
// Cleanup
SCOPE_EXIT({ MicroProfileOnThreadExit(); });
SCOPE_EXIT {
MicroProfileOnThreadExit();
};
Common::SetCurrentThreadName(name.c_str());
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);

View File

@ -22,7 +22,9 @@ static void RunThread(std::stop_token stop_token, Core::System& system,
Tegra::Control::Scheduler& scheduler, SynchState& state) {
std::string name = "GPU";
MicroProfileOnThreadCreate(name.c_str());
SCOPE_EXIT({ MicroProfileOnThreadExit(); });
SCOPE_EXIT {
MicroProfileOnThreadExit();
};
Common::SetCurrentThreadName(name.c_str());
Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);

View File

@ -273,10 +273,10 @@ DeinterlaceFilter::DeinterlaceFilter(const Frame& frame) {
const AVFilter* buffer_sink = avfilter_get_by_name("buffersink");
AVFilterInOut* inputs = avfilter_inout_alloc();
AVFilterInOut* outputs = avfilter_inout_alloc();
SCOPE_EXIT({
SCOPE_EXIT {
avfilter_inout_free(&inputs);
avfilter_inout_free(&outputs);
});
};
// Don't know how to get the accurate time_base but it doesn't matter for yadif filter
// so just use 1/1 to make buffer filter happy

View File

@ -92,12 +92,12 @@ public:
private:
void Fallback(const std::vector<u32>& parameters) {
SCOPE_EXIT({
SCOPE_EXIT {
if (extended) {
maxwell3d.engine_state = Maxwell3D::EngineHint::None;
maxwell3d.replace_table.clear();
}
});
};
maxwell3d.RefreshParameters();
const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]);
@ -281,12 +281,12 @@ public:
private:
void Fallback(const std::vector<u32>& parameters) {
SCOPE_EXIT({
SCOPE_EXIT {
// Clean everything.
maxwell3d.regs.vertex_id_base = 0x0;
maxwell3d.engine_state = Maxwell3D::EngineHint::None;
maxwell3d.replace_table.clear();
});
};
maxwell3d.RefreshParameters();
const u32 start_indirect = parameters[0];
const u32 end_indirect = parameters[1];

View File

@ -230,7 +230,9 @@ template <typename Func>
void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) {
MICROPROFILE_SCOPE(OpenGL_Drawing);
SCOPE_EXIT({ gpu.TickWork(); });
SCOPE_EXIT {
gpu.TickWork();
};
gpu_memory->FlushCaching();
GraphicsPipeline* const pipeline{shader_cache.CurrentGraphicsPipeline()};
@ -355,7 +357,9 @@ void RasterizerOpenGL::DrawIndirect() {
void RasterizerOpenGL::DrawTexture() {
MICROPROFILE_SCOPE(OpenGL_Drawing);
SCOPE_EXIT({ gpu.TickWork(); });
SCOPE_EXIT {
gpu.TickWork();
};
texture_cache.SynchronizeGraphicsDescriptors();
texture_cache.UpdateRenderTargets(false);

View File

@ -82,7 +82,9 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
// Finish any pending renderpass
scheduler.RequestOutsideRenderPassOperationContext();
scheduler.Wait(resource_ticks[image_index]);
SCOPE_EXIT({ resource_ticks[image_index] = scheduler.CurrentTick(); });
SCOPE_EXIT {
resource_ticks[image_index] = scheduler.CurrentTick();
};
if (!use_accelerated) {
UpdateRawImage(framebuffer, image_index);

View File

@ -144,7 +144,9 @@ void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebu
return;
}
SCOPE_EXIT({ render_window.OnFrameDisplayed(); });
SCOPE_EXIT {
render_window.OnFrameDisplayed();
};
RenderAppletCaptureLayer(framebuffers);

View File

@ -196,7 +196,9 @@ template <typename Func>
void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
MICROPROFILE_SCOPE(Vulkan_Drawing);
SCOPE_EXIT({ gpu.TickWork(); });
SCOPE_EXIT {
gpu.TickWork();
};
FlushWork();
gpu_memory->FlushCaching();
@ -288,7 +290,9 @@ void RasterizerVulkan::DrawIndirect() {
void RasterizerVulkan::DrawTexture() {
MICROPROFILE_SCOPE(Vulkan_Drawing);
SCOPE_EXIT({ gpu.TickWork(); });
SCOPE_EXIT {
gpu.TickWork();
};
FlushWork();
query_cache.NotifySegment(true);

View File

@ -116,7 +116,9 @@ void NsightAftermathTracker::OnGpuCrashDumpCallback(const void* gpu_crash_dump,
LOG_ERROR(Render_Vulkan, "Failed to create decoder");
return;
}
SCOPE_EXIT({ GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder); });
SCOPE_EXIT {
GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder);
};
u32 json_size = 0;
if (!GFSDK_Aftermath_SUCCEED(GFSDK_Aftermath_GpuCrashDump_GenerateJSON(