Files
@ r13257:4c5b8120be59
Branch filter:
Location: cpp/openttd-patchpack/source/src/company_base.h - annotation
r13257:4c5b8120be59
3.3 KiB
text/x-c
(svn r17776) -Codechange: [SDL] make "update the video card"-process asynchronious. Profiling with gprof etc. hasn't shown us that DrawSurfaceToScreen takes a significant amount of CPU; only using TIC/TOC it became apparant that it was a heavy CPU-cycle user or that it was waiting for something.
The benefit of making this function asynchronious ranges from 2%-25% (real time) during fast forward on dual core/hyperthreading-enabled CPUs; 8bpp improvements are, in my test cases, significantly smaller than 32bpp improvements.
On single core non-hyperthreading-enabled CPUs the extra locking/scheduling costs up to 1% extra realtime in fast forward. You can use -v sdl:no_threads to disable threading and undo this loss.
During normal non-fast-forwarded games the benefit/costs are negligable except when the gameloop takes more than about 90% of the time of a tick.
Note that allegro's performance does not improve with this system, likely due to their way of getting data to the video card. It is not implemented for the OS X/Windows video backends, unless (ofcourse) SDL is used there.
Funny is that the performance of the 32bpp(-anim) blitter is, at least in some test cases, significantly faster (more than 10%) than the 8bpp(-optimized) blitter when looking at real time in fast forward on a dual core CPU; it was slower.
The idea comes from a paper/report by Idar Borlaug and Knut Imar Hagen.
The benefit of making this function asynchronious ranges from 2%-25% (real time) during fast forward on dual core/hyperthreading-enabled CPUs; 8bpp improvements are, in my test cases, significantly smaller than 32bpp improvements.
On single core non-hyperthreading-enabled CPUs the extra locking/scheduling costs up to 1% extra realtime in fast forward. You can use -v sdl:no_threads to disable threading and undo this loss.
During normal non-fast-forwarded games the benefit/costs are negligable except when the gameloop takes more than about 90% of the time of a tick.
Note that allegro's performance does not improve with this system, likely due to their way of getting data to the video card. It is not implemented for the OS X/Windows video backends, unless (ofcourse) SDL is used there.
Funny is that the performance of the 32bpp(-anim) blitter is, at least in some test cases, significantly faster (more than 10%) than the 8bpp(-optimized) blitter when looking at real time in fast forward on a dual core CPU; it was slower.
The idea comes from a paper/report by Idar Borlaug and Knut Imar Hagen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11969:3526c3cc75dc r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11908:0875f47fab11 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11967:df0600d2c7e7 r11967:df0600d2c7e7 r10208:ef8fcc3dc4ca r11967:df0600d2c7e7 r11967:df0600d2c7e7 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10555:6bae964dabbf r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r12843:3cf702197a97 r10479:08b722b708ec r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r12605:09984b3bf0a4 r10208:ef8fcc3dc4ca r11908:0875f47fab11 r10208:ef8fcc3dc4ca r12138:e93d2e409e78 r12138:e93d2e409e78 r12138:e93d2e409e78 r12210:fd25f54f9ba0 r12138:e93d2e409e78 r12138:e93d2e409e78 r12138:e93d2e409e78 r12138:e93d2e409e78 r12138:e93d2e409e78 r12210:fd25f54f9ba0 r12138:e93d2e409e78 r12138:e93d2e409e78 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12969:5e7f0342aa53 r12969:5e7f0342aa53 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11966:921bea0ca112 r11966:921bea0ca112 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11230:fd38dc6041aa r11230:fd38dc6041aa r11230:fd38dc6041aa r10208:ef8fcc3dc4ca | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
#ifndef COMPANY_BASE_H
#define COMPANY_BASE_H
#include "company_type.h"
#include "core/pool_type.hpp"
#include "road_type.h"
#include "rail_type.h"
#include "date_type.h"
#include "engine_type.h"
#include "livery.h"
#include "autoreplace_type.h"
#include "economy_type.h"
#include "tile_type.h"
#include "settings_type.h"
struct CompanyEconomyEntry {
Money income;
Money expenses;
int32 delivered_cargo;
int32 performance_history; ///< company score (scale 0-1000)
Money company_value;
};
typedef Pool<Company, CompanyByte, 1, MAX_COMPANIES> CompanyPool;
extern CompanyPool _company_pool;
struct Company : CompanyPool::PoolItem<&_company_pool> {
Company(uint16 name_1 = 0, bool is_ai = false);
~Company();
uint32 name_2;
uint16 name_1;
char *name;
uint16 president_name_1;
uint32 president_name_2;
char *president_name;
CompanyManagerFace face;
Money money;
byte money_fraction;
Money current_loan;
byte colour;
Livery livery[LS_END];
RailTypes avail_railtypes;
RoadTypes avail_roadtypes;
byte block_preview;
uint32 cargo_types; ///< which cargo types were transported the last year
TileIndex location_of_HQ; ///< northern tile of HQ ; INVALID_TILE when there is none
TileIndex last_build_coordinate;
OwnerByte share_owners[4];
Year inaugurated_year;
byte num_valid_stat_ent;
byte quarters_of_bankruptcy;
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
int16 bankrupt_timeout;
Money bankrupt_value;
bool is_ai;
class AIInstance *ai_instance;
class AIInfo *ai_info;
Money yearly_expenses[3][EXPENSES_END];
CompanyEconomyEntry cur_economy;
CompanyEconomyEntry old_economy[MAX_HISTORY_MONTHS];
EngineRenewList engine_renew_list; ///< Defined later
CompanySettings settings; ///< settings specific for each company
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
static FORCEINLINE bool IsValidAiID(size_t index)
{
const Company *c = Company::GetIfValid(index);
return c != NULL && c->is_ai;
}
static FORCEINLINE bool IsValidHumanID(size_t index)
{
const Company *c = Company::GetIfValid(index);
return c != NULL && !c->is_ai;
}
static FORCEINLINE bool IsHumanID(size_t index)
{
return !Company::Get(index)->is_ai;
}
static void PostDestructor(size_t index);
};
#define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
#define FOR_ALL_COMPANIES(var) FOR_ALL_COMPANIES_FROM(var, 0)
Money CalculateCompanyValue(const Company *c);
extern uint _next_competitor_start;
extern uint _cur_company_tick_index;
#endif /* COMPANY_BASE_H */
|