Skip to content

Commit

Permalink
Merge pull request #10715 from ZehMatt/fix-10705
Browse files Browse the repository at this point in the history
Fix #10705: Apply multithreaded rendering to all viewports
  • Loading branch information
ZehMatt committed Feb 16, 2020
2 parents 1690361 + 0f50697 commit 6039191
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Expand Up @@ -20,6 +20,7 @@
- Fix: [#10489] Hosts last player action not being synchronized.
- Fix: [#10543] Secondary shop item prices are not imported correctly from RCT1 saves.
- Fix: [#10547] RCT1 parks have too many rides available.
- Fix: [#10705] Apply multithreaded rendering to all viewports.
- Removed: [#6898] LOADMM and LOADRCT1 title sequence commands (use LOADSC instead).

0.2.4 (2019-10-28)
Expand Down
15 changes: 7 additions & 8 deletions src/openrct2/interface/Viewport.cpp
@@ -1,4 +1,4 @@
/*****************************************************************************
/*****************************************************************************
* Copyright (c) 2014-2019 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
Expand Down Expand Up @@ -932,14 +932,12 @@ void viewport_paint(

// make sure, the compare operation is done in int16_t to avoid the loop becoming an infiniteloop.
// this as well as the [x += 32] in the loop causes signed integer overflow -> undefined behaviour.
int16_t rightBorder = dpi1.x + dpi1.width;
const int16_t rightBorder = dpi1.x + dpi1.width;
const int16_t alignedX = floor2(dpi1.x, 32);

std::vector<paint_session*> columns;

bool useMultithreading = gConfigGeneral.multithreading;
if (window_get_main() != nullptr && viewport != window_get_main()->viewport)
useMultithreading = false;

if (useMultithreading && _paintJobs == nullptr)
{
_paintJobs = std::make_unique<JobPool>();
Expand All @@ -953,12 +951,13 @@ void viewport_paint(
size_t index = 0;
if (recorded_sessions != nullptr)
{
const uint16_t column_count = (rightBorder - floor2(dpi1.x, 32)) / 32 + 1;
recorded_sessions->resize(column_count);
const uint16_t columnSize = rightBorder - alignedX;
const uint16_t columnCount = (columnSize / 32);
recorded_sessions->resize(columnCount);
}

// Splits the area into 32 pixel columns and renders them
for (x = floor2(dpi1.x, 32); x < rightBorder; x += 32, index++)
for (x = alignedX; x < rightBorder; x += 32, index++)
{
paint_session* session = paint_session_alloc(&dpi1, viewFlags);
columns.push_back(session);
Expand Down

0 comments on commit 6039191

Please sign in to comment.