1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 22:13:07 +01:00

Profiler update (#16463)

* Add more functions to be profiled

* Add isEnabled method to Profiler scripting interface

* Bump up scripting version

* Apply review suggestions
This commit is contained in:
ζeh Matt
2022-01-29 05:29:08 -08:00
committed by GitHub
parent f43a4344ce
commit 269673e3aa
28 changed files with 192 additions and 1 deletions

View File

@@ -2705,6 +2705,7 @@ declare global {
start(): void;
stop(): void;
reset(): void;
readonly enabled: boolean;
}
interface ProfiledFunction {

View File

@@ -976,6 +976,8 @@ namespace OpenRCT2
*/
void RunGameLoop()
{
PROFILED_FUNCTION();
log_verbose("begin openrct2 loop");
_finished = false;
@@ -998,6 +1000,8 @@ namespace OpenRCT2
void RunFrame()
{
PROFILED_FUNCTION();
const auto deltaTime = _timer.GetElapsedTimeAndRestart().count();
// Make sure we catch the state change and reset it.
@@ -1042,6 +1046,8 @@ namespace OpenRCT2
void RunFixedFrame(float deltaTime)
{
PROFILED_FUNCTION();
_uiContext->ProcessMessages();
if (_ticksAccumulator < GAME_UPDATE_TIME_MS)
@@ -1069,6 +1075,8 @@ namespace OpenRCT2
void RunVariableFrame(float deltaTime)
{
PROFILED_FUNCTION();
const bool shouldDraw = ShouldDraw();
auto& tweener = EntityTweener::Get();

View File

@@ -14,6 +14,7 @@
#include "../core/DataSerialiser.h"
#include "../network/network.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../scenario/Scenario.h"
#include "../util/Util.h"
#include "EntityRegistry.h"
@@ -110,6 +111,8 @@ void Balloon::Serialise(DataSerialiser& stream)
void Balloon::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = 22651 + (frame & 7);
if (popped != 0)
{

View File

@@ -13,6 +13,7 @@
#include "../core/DataSerialiser.h"
#include "../localisation/Date.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../scenario/Scenario.h"
#include "../sprites.h"
#include "../world/Surface.h"
@@ -366,6 +367,8 @@ void Duck::Serialise(DataSerialiser& stream)
void Duck::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
rct_drawpixelinfo& dpi = session.DPI;
if (dpi.zoom_level > ZoomLevel{ 1 })
return;

View File

@@ -12,6 +12,7 @@
#include "../Game.h"
#include "../core/DataSerialiser.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../scenario/Scenario.h"
#include "../world/Footpath.h"
#include "../world/Map.h"
@@ -396,6 +397,8 @@ void JumpingFountain::Serialise(DataSerialiser& stream)
void JumpingFountain::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Move into sprites.h
constexpr uint32_t JumpingFountainSnowBaseImage = 23037;
constexpr uint32_t JumpingFountainWaterBaseImage = 22973;

View File

@@ -5,6 +5,7 @@
#include "../core/DataSerialiser.h"
#include "../localisation/StringIds.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../sprites.h"
#include "../world/Map.h"
#include "EntityList.h"
@@ -171,6 +172,8 @@ static constexpr const LitterSprite _litterSprites[] = {
void Litter::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
rct_drawpixelinfo& dpi = session.DPI;
if (dpi.zoom_level > ZoomLevel{ 0 })
return; // If zoomed at all no litter drawn

View File

@@ -16,6 +16,7 @@
#include "../localisation/Localisation.h"
#include "../network/network.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../world/Map.h"
#include "EntityRegistry.h"
@@ -168,6 +169,8 @@ void MoneyEffect::Serialise(DataSerialiser& stream)
void MoneyEffect::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
rct_drawpixelinfo& dpi = session.DPI;
if (dpi.zoom_level > ZoomLevel{ 0 })
{

View File

@@ -11,6 +11,7 @@
#include "../audio/audio.h"
#include "../core/DataSerialiser.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../scenario/Scenario.h"
#include "EntityRegistry.h"
@@ -151,6 +152,8 @@ void VehicleCrashParticle::Serialise(DataSerialiser& stream)
void VehicleCrashParticle::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
rct_drawpixelinfo& dpi = session.DPI;
if (dpi.zoom_level > ZoomLevel{ 0 })
{
@@ -201,6 +204,8 @@ void CrashSplashParticle::Serialise(DataSerialiser& stream)
void CrashSplashParticle::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Create constant in sprites.h
uint32_t imageId = 22927 + (frame / 256);
PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 1, 1, 0 });
@@ -258,6 +263,8 @@ void SteamParticle::Serialise(DataSerialiser& stream)
void SteamParticle::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Create constant in sprites.h
uint32_t imageId = 22637 + (frame / 256);
PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 1, 1, 0 });
@@ -302,6 +309,8 @@ void ExplosionCloud::Serialise(DataSerialiser& stream)
void ExplosionCloud::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = 22878 + (frame / 256);
PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 1, 1, 0 });
}
@@ -345,6 +354,8 @@ void ExplosionFlare::Serialise(DataSerialiser& stream)
void ExplosionFlare::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Create constant in sprites.h
uint32_t imageId = 22896 + (frame / 256);
PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 1, 1, 0 });

View File

@@ -251,6 +251,8 @@ void peep_update_all()
*/
static void peep_128_tick_update(Peep* peep, int32_t index)
{
PROFILED_FUNCTION();
auto* guest = peep->As<Guest>();
if (guest != nullptr)
{
@@ -272,6 +274,8 @@ static void peep_128_tick_update(Peep* peep, int32_t index)
*/
bool Peep::CheckForPath()
{
PROFILED_FUNCTION();
PathCheckOptimisation++;
if ((PathCheckOptimisation & 0xF) != (sprite_index & 0xF))
{
@@ -397,6 +401,8 @@ std::optional<CoordsXY> Peep::UpdateAction()
*/
std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
{
PROFILED_FUNCTION();
_unk_F1AEF0 = ActionSpriteImageOffset;
if (Action == PeepActionType::Idle)
{
@@ -2686,6 +2692,8 @@ void Peep::Serialise(DataSerialiser& stream)
void Peep::Paint(paint_session& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
#ifdef __ENABLE_LIGHTFX__
if (lightfx_is_available())
{

View File

@@ -900,6 +900,8 @@ static void record_session(
static void viewport_fill_column(
paint_session& session, std::vector<RecordedPaintSession>* recorded_sessions, size_t record_index)
{
PROFILED_FUNCTION();
PaintSessionGenerate(session);
if (recorded_sessions != nullptr)
{
@@ -910,6 +912,8 @@ static void viewport_fill_column(
static void viewport_paint_column(paint_session& session)
{
PROFILED_FUNCTION();
if (session.ViewFlags
& (VIEWPORT_FLAG_HIDE_VERTICAL | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_UNDERGROUND_INSIDE
| VIEWPORT_FLAG_CLIP_VIEW)
@@ -1365,6 +1369,8 @@ static bool PSSpriteTypeIsInFilter(paint_struct* ps, uint16_t filter)
static bool is_pixel_present_bmp(
uint32_t imageType, const rct_g1_element* g1, const uint8_t* index, const PaletteMap& paletteMap)
{
PROFILED_FUNCTION();
// Probably used to check for corruption
if (!(g1->flags & G1_FLAG_BMP))
{
@@ -1389,6 +1395,8 @@ static bool is_pixel_present_bmp(
*/
static bool is_pixel_present_rle(const uint8_t* esi, int32_t x_start_point, int32_t y_start_point, int32_t round)
{
PROFILED_FUNCTION();
uint32_t start_offset = esi[y_start_point * 2] | (esi[y_start_point * 2 + 1] << 8);
const uint8_t* ebx = esi + start_offset;
@@ -1482,6 +1490,8 @@ static bool is_pixel_present_rle(const uint8_t* esi, int32_t x_start_point, int3
static bool is_sprite_interacted_with_palette_set(
rct_drawpixelinfo* dpi, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap)
{
PROFILED_FUNCTION();
const rct_g1_element* g1 = gfx_get_g1_element(imageId);
if (g1 == nullptr)
{
@@ -1626,6 +1636,8 @@ static bool is_sprite_interacted_with_palette_set(
static bool is_sprite_interacted_with(rct_drawpixelinfo* dpi, ImageId imageId, const ScreenCoordsXY& coords)
{
PROFILED_FUNCTION();
auto paletteMap = PaletteMap::GetDefault();
if (imageId.HasPrimary() || imageId.IsRemap())
{
@@ -1657,6 +1669,8 @@ static bool is_sprite_interacted_with(rct_drawpixelinfo* dpi, ImageId imageId, c
*/
InteractionInfo set_interaction_info_from_paint_session(paint_session* session, uint16_t filter)
{
PROFILED_FUNCTION();
paint_struct* ps = &session->PaintHead;
rct_drawpixelinfo* dpi = &session->DPI;
InteractionInfo info{};
@@ -1755,6 +1769,8 @@ InteractionInfo get_map_coordinates_from_pos_window(rct_window* window, const Sc
*/
void viewport_invalidate(const rct_viewport* viewport, const ScreenRect& screenRect)
{
PROFILED_FUNCTION();
// if unknown viewport visibility, use the containing window to discover the status
if (viewport->visibility == VisibilityCache::Unknown)
{

View File

@@ -14,6 +14,7 @@
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../profiling/Profiling.h"
#include "../ride/Ride.h"
#include "../ride/RideData.h"
#include "../scenario/Scenario.h"
@@ -602,6 +603,8 @@ void award_reset()
*/
void award_update_all()
{
PROFILED_FUNCTION();
// Only add new awards if park is open
if (gParkFlags & PARK_FLAGS_PARK_OPEN)
{

View File

@@ -17,6 +17,7 @@
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
#include "../profiling/Profiling.h"
#include "../ride/Ride.h"
#include "../scenario/Scenario.h"
#include "../util/Util.h"
@@ -105,6 +106,8 @@ void finance_payment(money32 amount, ExpenditureType type)
*/
void finance_pay_wages()
{
PROFILED_FUNCTION();
if (gParkFlags & PARK_FLAGS_NO_MONEY)
{
return;
@@ -157,6 +160,8 @@ void finance_pay_interest()
*/
void finance_pay_ride_upkeep()
{
PROFILED_FUNCTION();
for (auto& ride : GetRideManager())
{
if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED))
@@ -233,6 +238,8 @@ void finance_init()
*/
void finance_update_daily_profit()
{
PROFILED_FUNCTION();
gCurrentProfit = 7 * gCurrentExpenditure;
gCurrentExpenditure = 0; // Reset daily expenditure

View File

@@ -16,6 +16,7 @@
#include "../interface/Window.h"
#include "../localisation/Formatter.h"
#include "../localisation/Localisation.h"
#include "../profiling/Profiling.h"
#include "../ride/Ride.h"
#include "../ride/RideData.h"
#include "../ride/ShopItem.h"
@@ -97,6 +98,8 @@ static void marketing_raise_finished_notification(const MarketingCampaign& campa
*/
void marketing_update()
{
PROFILED_FUNCTION();
if (gCheatsNeverendingMarketing)
return;

View File

@@ -20,6 +20,7 @@
#include "../entity/Particle.h"
#include "../entity/Staff.h"
#include "../interface/Viewport.h"
#include "../profiling/Profiling.h"
#include "../ride/RideData.h"
#include "../ride/TrackDesign.h"
#include "../ride/Vehicle.h"
@@ -35,6 +36,8 @@
*/
void EntityPaintSetup(paint_session& session, const CoordsXY& pos)
{
PROFILED_FUNCTION();
if (!map_is_location_valid(pos))
{
return;

View File

@@ -529,6 +529,8 @@ static void PaintDrawStruct(paint_session& session, paint_struct* ps)
*/
void PaintDrawStructs(paint_session& session)
{
PROFILED_FUNCTION();
paint_struct* ps = &session.PaintHead;
for (ps = ps->next_quadrant_ps; ps != nullptr;)

View File

@@ -22,6 +22,7 @@
#include "../localisation/Formatting.h"
#include "../localisation/Language.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../title/TitleScreen.h"
#include "../ui/UiContext.h"
@@ -37,6 +38,8 @@ Painter::Painter(const std::shared_ptr<IUiContext>& uiContext)
void Painter::Paint(IDrawingEngine& de)
{
PROFILED_FUNCTION();
auto dpi = de.GetDrawingPixelInfo();
if (gIntroState != IntroState::None)
{
@@ -130,6 +133,8 @@ void Painter::MeasureFPS()
paint_session* Painter::CreateSession(rct_drawpixelinfo* dpi, uint32_t viewFlags)
{
PROFILED_FUNCTION();
paint_session* session = nullptr;
if (_freePaintSessions.empty() == false)
@@ -167,6 +172,8 @@ paint_session* Painter::CreateSession(rct_drawpixelinfo* dpi, uint32_t viewFlags
void Painter::ReleaseSession(paint_session* session)
{
PROFILED_FUNCTION();
session->PaintEntryChain.Clear();
_freePaintSessions.push_back(session);
}

View File

@@ -13,6 +13,7 @@
#include "../Input.h"
#include "../config/Config.h"
#include "../interface/Viewport.h"
#include "../profiling/Profiling.h"
#include "../sprites.h"
#include "../util/Util.h"
#include "../world/Location.hpp"
@@ -98,6 +99,8 @@ void virtual_floor_disable()
void virtual_floor_invalidate()
{
PROFILED_FUNCTION();
// First, let's figure out how big our selection is.
CoordsXY min_position = { std::numeric_limits<int32_t>::max(), std::numeric_limits<int32_t>::max() };
CoordsXY max_position = { std::numeric_limits<int32_t>::lowest(), std::numeric_limits<int32_t>::lowest() };
@@ -291,6 +294,8 @@ static void virtual_floor_get_tile_properties(
void virtual_floor_paint(paint_session& session)
{
PROFILED_FUNCTION();
static constexpr const CoordsXY scenery_half_tile_offsets[4] = {
{ -COORDS_XY_STEP, 0 },
{ 0, COORDS_XY_STEP },

View File

@@ -14,6 +14,7 @@
#include "../../interface/Viewport.h"
#include "../../localisation/Formatter.h"
#include "../../localisation/Localisation.h"
#include "../../profiling/Profiling.h"
#include "../../ride/TrackDesign.h"
#include "../../sprites.h"
#include "../../world/Banner.h"
@@ -34,6 +35,8 @@ static void PaintBannerScrollingText(
paint_session& session, const BannerSceneryEntry& bannerEntry, Banner& banner, const BannerElement& bannerElement,
Direction direction, int32_t height, const CoordsXYZ& bbOffset)
{
PROFILED_FUNCTION();
// If text on hidden direction or ghost
direction = direction_reverse(direction) - 1;
if (direction >= 2 || (bannerElement.IsGhost()))
@@ -66,6 +69,8 @@ static void PaintBannerScrollingText(
void PaintBanner(paint_session& session, uint8_t direction, int32_t height, const BannerElement& bannerElement)
{
PROFILED_FUNCTION();
if (session.DPI.zoom_level > ZoomLevel{ 1 } || gTrackDesignSaveMode
|| (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
return;

View File

@@ -20,6 +20,7 @@
#include "../../object/EntranceObject.h"
#include "../../object/ObjectManager.h"
#include "../../object/StationObject.h"
#include "../../profiling/Profiling.h"
#include "../../ride/RideData.h"
#include "../../ride/TrackDesign.h"
#include "../../world/Banner.h"
@@ -36,6 +37,8 @@ static void PaintRideEntranceExitScrollingText(
paint_session& session, const EntranceElement& entranceEl, const StationObject& stationObj, Direction direction,
int32_t height)
{
PROFILED_FUNCTION();
if (stationObj.ScrollingMode == SCROLLING_MODE_NONE)
return;
@@ -77,6 +80,8 @@ static void PaintRideEntranceExitScrollingText(
static void PaintRideEntranceExitLightEffects(paint_session& session, int32_t height, const EntranceElement& entranceEl)
{
#ifdef __ENABLE_LIGHTFX__
PROFILED_FUNCTION();
if (lightfx_is_available())
{
if (entranceEl.GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
@@ -105,6 +110,8 @@ static void PaintRideEntranceExitLightEffects(paint_session& session, int32_t he
static void PaintRideEntranceExit(paint_session& session, uint8_t direction, int32_t height, const EntranceElement& entranceEl)
{
PROFILED_FUNCTION();
auto rideIndex = entranceEl.GetRideIndex();
if ((gTrackDesignSaveMode || (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
&& (rideIndex != gTrackDesignSaveRideIndex))
@@ -203,6 +210,8 @@ static void PaintRideEntranceExit(paint_session& session, uint8_t direction, int
static void PaintParkEntranceScrollingText(
paint_session& session, const EntranceObject& entrance, Direction direction, int32_t height)
{
PROFILED_FUNCTION();
if ((direction + 1) & (1 << 1))
return;
@@ -245,6 +254,8 @@ static void PaintParkEntranceScrollingText(
static void PaintParkEntranceLightEffects(paint_session& session)
{
#ifdef __ENABLE_LIGHTFX__
PROFILED_FUNCTION();
if (lightfx_is_available())
{
lightfx_add_3d_light_magic_from_drawing_tile(session.MapPosition, 0, 0, 155, LightType::Lantern3);
@@ -254,6 +265,8 @@ static void PaintParkEntranceLightEffects(paint_session& session)
static void PaintParkEntrance(paint_session& session, uint8_t direction, int32_t height, const EntranceElement& entranceEl)
{
PROFILED_FUNCTION();
if (gTrackDesignSaveMode || (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
return;
@@ -325,6 +338,8 @@ static void PaintParkEntrance(paint_session& session, uint8_t direction, int32_t
static void PaintHeightMarkers(paint_session& session, const EntranceElement& entranceEl, int32_t height)
{
PROFILED_FUNCTION();
if (PaintShouldShowHeightMarkers(session, VIEWPORT_FLAG_PATH_HEIGHTS))
{
if (entranceEl.GetDirections() & 0xF)
@@ -342,6 +357,8 @@ static void PaintHeightMarkers(paint_session& session, const EntranceElement& en
void PaintEntrance(paint_session& session, uint8_t direction, int32_t height, const EntranceElement& entranceElement)
{
PROFILED_FUNCTION();
session.InteractionType = ViewportInteractionItem::Label;
PaintHeightMarkers(session, entranceElement, height);

View File

@@ -17,6 +17,7 @@
#include "../../localisation/Formatter.h"
#include "../../localisation/Localisation.h"
#include "../../object/LargeSceneryObject.h"
#include "../../profiling/Profiling.h"
#include "../../ride/Ride.h"
#include "../../ride/TrackDesign.h"
#include "../../util/Util.h"
@@ -60,6 +61,8 @@ static void PaintLargeScenerySupports(
paint_session& session, uint8_t direction, uint16_t height, const LargeSceneryElement& tileElement, ImageId imageTemplate,
const rct_large_scenery_tile& tile)
{
PROFILED_FUNCTION();
if (tile.flags & LARGE_SCENERY_TILE_FLAG_NO_SUPPORTS)
return;
@@ -110,6 +113,8 @@ static void PaintLargeScenery3DTextLine(
paint_session& session, const LargeSceneryEntry& sceneryEntry, const LargeSceneryText& text, std::string_view line,
ImageId imageTemplate, Direction direction, int32_t offsetY)
{
PROFILED_FUNCTION();
line = LargeSceneryCalculateDisplayText(text, line, false);
auto width = text.MeasureWidth(line);
auto offsetX = text.offset[(direction & 1)].x;
@@ -184,6 +189,8 @@ static void PaintLargeScenery3DText(
paint_session& session, const LargeSceneryEntry& sceneryEntry, const rct_large_scenery_tile& tile,
const LargeSceneryElement& tileElement, uint8_t direction, uint16_t height, bool isGhost)
{
PROFILED_FUNCTION();
if (sceneryEntry.tiles[1].x_offset != -1)
{
auto sequenceDirection = (tileElement.GetSequenceIndex() - 1) & 3;
@@ -296,6 +303,8 @@ static void PaintLargeSceneryScrollingText(
paint_session& session, const LargeSceneryEntry& sceneryEntry, const LargeSceneryElement& tileElement, uint8_t direction,
uint16_t height, const CoordsXYZ& bbOffset, bool isGhost)
{
PROFILED_FUNCTION();
auto textColour = isGhost ? static_cast<colour_t>(COLOUR_GREY) : tileElement.GetSecondaryColour();
auto textPaletteIndex = direction == 0 ? ColourMapA[textColour].mid_dark : ColourMapA[textColour].light;
@@ -325,6 +334,8 @@ static void PaintLargeSceneryScrollingText(
void PaintLargeScenery(paint_session& session, uint8_t direction, uint16_t height, const LargeSceneryElement& tileElement)
{
PROFILED_FUNCTION();
if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
return;

View File

@@ -25,6 +25,7 @@
#include "../../object/FootpathSurfaceObject.h"
#include "../../object/ObjectList.h"
#include "../../object/ObjectManager.h"
#include "../../profiling/Profiling.h"
#include "../../ride/Ride.h"
#include "../../ride/Track.h"
#include "../../ride/TrackDesign.h"
@@ -290,6 +291,8 @@ static void sub_6A4101(
paint_session& session, const PathElement& pathElement, uint16_t height, uint32_t connectedEdges, bool hasSupports,
const FootpathPaintInfo& pathPaintInfo, ImageId imageTemplate)
{
PROFILED_FUNCTION();
auto imageId = imageTemplate.WithIndex(pathPaintInfo.RailingsImageId);
if (pathElement.IsQueue())
{
@@ -719,6 +722,7 @@ static void sub_6A3F61(
// esp: [ esi, ???, 000]
// Probably drawing benches etc.
PROFILED_FUNCTION();
rct_drawpixelinfo* dpi = &session.DPI;
@@ -936,6 +940,8 @@ static void PaintPatrolAreas(paint_session& session, const PathElement& pathEl)
static void PaintHeightMarkers(paint_session& session, const PathElement& pathEl)
{
PROFILED_FUNCTION();
if (PaintShouldShowHeightMarkers(session, VIEWPORT_FLAG_PATH_HEIGHTS))
{
uint16_t heightMarkerBaseZ = pathEl.GetBaseZ() + 3;
@@ -956,6 +962,8 @@ static void PaintHeightMarkers(paint_session& session, const PathElement& pathEl
static void PaintLampLightEffects(paint_session& session, const PathElement& pathEl, uint16_t height)
{
#ifdef __ENABLE_LIGHTFX__
PROFILED_FUNCTION();
if (lightfx_is_available())
{
if (pathEl.HasAddition() && !(pathEl.IsBroken()))
@@ -990,6 +998,8 @@ static void PaintLampLightEffects(paint_session& session, const PathElement& pat
*/
void PaintPath(paint_session& session, uint16_t height, const PathElement& tileElement)
{
PROFILED_FUNCTION();
session.InteractionType = ViewportInteractionItem::Footpath;
ImageId imageTemplate, sceneryImageTemplate;
@@ -1061,6 +1071,8 @@ void path_paint_box_support(
paint_session& session, const PathElement& pathElement, int32_t height, const FootpathPaintInfo& pathPaintInfo,
bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate)
{
PROFILED_FUNCTION();
// Rol edges around rotation
uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF)
| (((pathElement.GetEdges()) << session.CurrentRotation) >> 4);
@@ -1196,6 +1208,8 @@ void path_paint_pole_support(
paint_session& session, const PathElement& pathElement, int16_t height, const FootpathPaintInfo& pathPaintInfo,
bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate)
{
PROFILED_FUNCTION();
// Rol edges around rotation
uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF)
| (((pathElement.GetEdges()) << session.CurrentRotation) >> 4);

View File

@@ -13,6 +13,7 @@
#include "../../config/Config.h"
#include "../../interface/Viewport.h"
#include "../../localisation/Date.h"
#include "../../profiling/Profiling.h"
#include "../../ride/TrackDesign.h"
#include "../../util/Util.h"
#include "../../world/Map.h"
@@ -33,6 +34,8 @@ static void PaintSmallScenerySupports(
paint_session& session, const SmallSceneryEntry& sceneryEntry, const SmallSceneryElement& sceneryElement,
Direction direction, int32_t height, ImageId imageTemplate)
{
PROFILED_FUNCTION();
if (!sceneryElement.NeedsSupports())
return;
@@ -106,6 +109,8 @@ static void SetSupportHeights(
*/
void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement)
{
PROFILED_FUNCTION();
if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
{
return;

View File

@@ -25,6 +25,7 @@
#include "../../object/TerrainEdgeObject.h"
#include "../../object/TerrainSurfaceObject.h"
#include "../../paint/Paint.h"
#include "../../profiling/Profiling.h"
#include "../../ride/TrackDesign.h"
#include "../../sprites.h"
#include "../../world/Surface.h"
@@ -303,6 +304,8 @@ static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = {
static const TerrainSurfaceObject* get_surface_object(size_t index)
{
PROFILED_FUNCTION();
TerrainSurfaceObject* result{};
auto& objMgr = OpenRCT2::GetContext()->GetObjectManager();
auto obj = objMgr.GetLoadedObject(ObjectType::TerrainSurface, index);
@@ -317,6 +320,8 @@ static ImageId get_surface_image(
const paint_session& session, ObjectEntryIndex index, int32_t offset, uint8_t rotation, int32_t grassLength, bool grid,
bool underground)
{
PROFILED_FUNCTION();
ImageId image;
auto obj = get_surface_object(index);
if (obj != nullptr)
@@ -333,6 +338,8 @@ static ImageId get_surface_image(
static ImageId get_surface_pattern(uint8_t index, int32_t offset)
{
PROFILED_FUNCTION();
ImageId image;
auto obj = get_surface_object(index);
if (obj != nullptr)
@@ -348,6 +355,8 @@ static ImageId get_surface_pattern(uint8_t index, int32_t offset)
static bool surface_should_smooth_self(uint8_t index)
{
PROFILED_FUNCTION();
auto obj = get_surface_object(index);
if (obj != nullptr)
{
@@ -358,6 +367,8 @@ static bool surface_should_smooth_self(uint8_t index)
static bool surface_should_smooth(uint8_t index)
{
PROFILED_FUNCTION();
auto obj = get_surface_object(index);
if (obj != nullptr)
{
@@ -398,6 +409,8 @@ static ImageId get_edge_image(uint8_t index, uint8_t type)
static ImageId get_tunnel_image(ObjectEntryIndex index, uint8_t type, edge_t edge)
{
PROFILED_FUNCTION();
static constexpr uint32_t offsets[TUNNEL_TYPE_COUNT] = { 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80,
36, 48, 60, 72, 76, 80, 84, 88, 92, 96, 100 };
@@ -436,6 +449,8 @@ static uint8_t viewport_surface_paint_setup_get_relative_slope(const SurfaceElem
static void viewport_surface_smoothen_edge(
paint_session& session, enum edge_t edge, struct tile_descriptor self, struct tile_descriptor neighbour)
{
PROFILED_FUNCTION();
if (neighbour.tile_element == nullptr)
return;
@@ -555,6 +570,8 @@ static void viewport_surface_draw_tile_side_bottom(
paint_session& session, enum edge_t edge, uint16_t height, uint8_t edgeStyle, struct tile_descriptor self,
struct tile_descriptor neighbour, bool isWater)
{
PROFILED_FUNCTION();
// From big Z to tiny Z
height /= COORDS_Z_PER_TINY_Z;
int16_t cornerHeight1, neighbourCornerHeight1, cornerHeight2, neighbourCornerHeight2;
@@ -769,6 +786,8 @@ static void viewport_surface_draw_tile_side_top(
paint_session& session, enum edge_t edge, uint16_t height, uint8_t terrain, struct tile_descriptor self,
struct tile_descriptor neighbour, bool isWater)
{
PROFILED_FUNCTION();
// From big Z to tiny Z
height /= COORDS_Z_PER_TINY_Z;
@@ -955,6 +974,8 @@ static std::pair<int32_t, int32_t> surface_get_height_above_water(
*/
void PaintSurface(paint_session& session, uint8_t direction, uint16_t height, const SurfaceElement& tileElement)
{
PROFILED_FUNCTION();
rct_drawpixelinfo* dpi = &session.DPI;
session.InteractionType = ViewportInteractionItem::Terrain;
session.DidPassSurface = true;

View File

@@ -16,6 +16,7 @@
#include "../../drawing/Drawing.h"
#include "../../interface/Viewport.h"
#include "../../localisation/Localisation.h"
#include "../../profiling/Profiling.h"
#include "../../ride/RideData.h"
#include "../../ride/TrackData.h"
#include "../../ride/TrackPaint.h"
@@ -49,6 +50,8 @@ const int32_t SEGMENTS_ALL = SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 |
*/
void tile_element_paint_setup(paint_session& session, const CoordsXY& mapCoords, bool isTrackPiecePreview)
{
PROFILED_FUNCTION();
if (!map_is_edge(mapCoords))
{
paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
@@ -116,6 +119,8 @@ bool gShowSupportSegmentHeights = false;
*/
static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoords)
{
PROFILED_FUNCTION();
CoordsXY coords = origCoords;
rct_drawpixelinfo* dpi = &session.DPI;

View File

@@ -16,6 +16,7 @@
#include "../../interface/Colour.h"
#include "../../interface/Viewport.h"
#include "../../localisation/Localisation.h"
#include "../../profiling/Profiling.h"
#include "../../ride/Track.h"
#include "../../ride/TrackDesign.h"
#include "../../world/Banner.h"
@@ -48,6 +49,8 @@ static void PaintWallDoor(
paint_session& session, const WallSceneryEntry& wallEntry, ImageId imageId, CoordsXYZ offset, CoordsXYZ bbLengthR1,
CoordsXYZ bbOffsetR1, CoordsXYZ bbLengthR2, CoordsXYZ bbOffsetR2, CoordsXYZ bbLengthL, CoordsXYZ bbOffsetL)
{
PROFILED_FUNCTION();
auto newImageId0 = imageId;
auto newImageId1 = imageId.WithIndexOffset(1);
if (wallEntry.flags & WALL_SCENERY_IS_DOUBLE_SIDED)
@@ -66,6 +69,8 @@ static void PaintWallDoor(
paint_session& session, const WallSceneryEntry& wallEntry, const WallElement& wallElement, ImageId imageTemplate,
Direction direction, int32_t height)
{
PROFILED_FUNCTION();
auto bbHeight = wallEntry.height * 8 - 2;
auto animationFrame = wallElement.GetAnimationFrame();
@@ -151,6 +156,8 @@ static void PaintWallWall(
paint_session& session, const WallSceneryEntry& wallEntry, ImageId imageTemplate, uint32_t imageOffset, CoordsXYZ offset,
CoordsXYZ bounds, CoordsXYZ boundsOffset, bool isGhost)
{
PROFILED_FUNCTION();
auto frameNum = (wallEntry.flags2 & WALL_SCENERY_2_ANIMATED) ? (gCurrentTicks & 7) * 2 : 0;
auto imageIndex = wallEntry.image + imageOffset + frameNum;
PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), offset, bounds, boundsOffset);
@@ -165,6 +172,8 @@ static void PaintWallScrollingText(
paint_session& session, const WallSceneryEntry& wallEntry, const WallElement& wallElement, Direction direction,
int32_t height, const CoordsXYZ& boundsOffset, bool isGhost)
{
PROFILED_FUNCTION();
if (direction != 0 && direction != 3)
return;
@@ -205,6 +214,8 @@ static void PaintWallWall(
paint_session& session, const WallSceneryEntry& wallEntry, const WallElement& wallElement, ImageId imageTemplate,
Direction direction, int32_t height, bool isGhost)
{
PROFILED_FUNCTION();
uint8_t bbHeight = wallEntry.height * 8 - 2;
ImageIndex imageOffset = 0;
CoordsXYZ offset, bounds, boundsOffset;
@@ -313,6 +324,8 @@ static void PaintWallWall(
void PaintWall(paint_session& session, uint8_t direction, int32_t height, const WallElement& wallElement)
{
PROFILED_FUNCTION();
auto* wallEntry = wallElement.GetEntry();
if (wallEntry == nullptr)
{

View File

@@ -12,6 +12,7 @@
#include "../core/Guard.hpp"
#include "../entity/Guest.h"
#include "../entity/Staff.h"
#include "../profiling/Profiling.h"
#include "../ride/RideData.h"
#include "../ride/Station.h"
#include "../ride/Track.h"
@@ -528,6 +529,8 @@ static uint8_t peep_pathfind_get_max_number_junctions(Peep* peep)
*/
static bool path_is_thin_junction(PathElement* path, const TileCoordsXYZ& loc)
{
PROFILED_FUNCTION();
uint8_t edges = path->GetEdges();
int32_t test_edge = bitscanforward(edges);
@@ -1261,6 +1264,8 @@ static void peep_pathfind_heuristic_search(
*/
Direction peep_pathfind_choose_direction(const TileCoordsXYZ& loc, Peep* peep)
{
PROFILED_FUNCTION();
// The max number of thin junctions searched - a per-search-path limit.
_peepPathFindMaxJunctions = peep_pathfind_get_max_number_junctions(peep);

View File

@@ -46,7 +46,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 42;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 43;
// Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;

View File

@@ -84,6 +84,11 @@ namespace OpenRCT2::Scripting
OpenRCT2::Profiling::ResetData();
}
bool enabled_get() const
{
return OpenRCT2::Profiling::IsEnabled();
}
public:
static void Register(duk_context* ctx)
{
@@ -91,6 +96,7 @@ namespace OpenRCT2::Scripting
dukglue_register_method(ctx, &ScProfiler::start, "start");
dukglue_register_method(ctx, &ScProfiler::stop, "stop");
dukglue_register_method(ctx, &ScProfiler::reset, "reset");
dukglue_register_property(ctx, &ScProfiler::enabled_get, nullptr, "enabled");
}
};
} // namespace OpenRCT2::Scripting