hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
d2b9329600d820be12ae5c36395cf8872d6ddd45
622
cpp
C++
BeakJoon/c++/solved/1000/1764.cpp
heeboy007/PS-MyAnswers
e5e02972ab64279d96eb43e85941a46b82315fbd
[ "MIT" ]
null
null
null
BeakJoon/c++/solved/1000/1764.cpp
heeboy007/PS-MyAnswers
e5e02972ab64279d96eb43e85941a46b82315fbd
[ "MIT" ]
null
null
null
BeakJoon/c++/solved/1000/1764.cpp
heeboy007/PS-MyAnswers
e5e02972ab64279d96eb43e85941a46b82315fbd
[ "MIT" ]
null
null
null
#include<iostream> #include<set> #include<vector> #include<algorithm> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); set<string> s; vector<string> v; int n, m; cin >> n >> m; while(n--){ string input; cin >> input; s.insert(input); } while(m--){ string input; cin >> input; if(s.end() != s.find(input)){ v.push_back(input); } } sort(v.begin(), v.end()); cout << v.size() << '\n'; for(string output : v){ cout << output << '\n'; } return 0; }
16.810811
37
0.482315
heeboy007
d2b9aa173bf1cca601f0ac9b79473a26a0225895
29,356
cpp
C++
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
2
2020-03-03T12:40:29.000Z
2021-05-06T06:20:19.000Z
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
7
2020-01-14T20:38:04.000Z
2021-05-17T09:52:07.000Z
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
2
2019-11-09T09:14:48.000Z
2020-03-03T12:40:30.000Z
/* * The MIT License (MIT) * * Copyright (c) 2018 Sylko Olzscher * */ #include "sync_db.h" #include "../../shared/db/db_schemes.h" #include <smf/cluster/generator.h> #include <cyng/table/meta.hpp> #include <cyng/io/serializer.h> #include <cyng/tuple_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/uuid/nil_generator.hpp> namespace node { void create_cache(cyng::logging::log_ptr logger, cyng::store::db& db) { CYNG_LOG_TRACE(logger, "create cache tables"); if (!create_table(db, "TDevice")) { CYNG_LOG_FATAL(logger, "cannot create table TDevice"); } // // Has more columns than original TGateway definition // if (!db.create_table(cyng::table::make_meta_table<1, 16>("TGateway", { "pk" // primary key , "serverId" // (1) Server-ID (i.e. 0500153B02517E) , "manufacturer" // (2) manufacturer (i.e. EMH) , "made" // (4) production date , "factoryNr" // (6) fabrik nummer (i.e. 06441734) , "ifService" // (7) MAC of service interface , "ifData" // (8) MAC od data interface , "pwdDef" // (9) Default PW , "pwdRoot" // (10) root PW , "mbus" // (11) W-Mbus ID (i.e. A815408943050131) , "userName" // (12) , "userPwd" // (13) // since here columns specific for dash/s and not part of the original table scheme , "name" // IP-T/device name , "descr" // IP-T/device description , "model" // (3) Typbezeichnung (i.e. Variomuc ETHERNET) , "vFirmware" // (5) firmware version (i.e. 11600000) , "online" // (14) }, { cyng::TC_UUID // pk , cyng::TC_STRING // server id , cyng::TC_STRING // manufacturer , cyng::TC_TIME_POINT // production data , cyng::TC_STRING // Fabriknummer/serial number (i.e. 06441734) , cyng::TC_MAC48 // MAC of service interface , cyng::TC_MAC48 // MAC od data interface , cyng::TC_STRING // Default PW , cyng::TC_STRING // root PW , cyng::TC_STRING // W-Mbus ID (i.e. A815408943050131) , cyng::TC_STRING // operator , cyng::TC_STRING // operator // --- dynamic part: , cyng::TC_STRING // IP-T/device name , cyng::TC_STRING // model , cyng::TC_STRING // vFirmware , cyng::TC_INT32 // on/offline state }, { 36 // pk , 23 // server id , 64 // manufacturer , 0 // production date , 8 // serial , 18 // MAC , 18 // MAC , 32 // PW , 32 // PW , 16 // M-Bus , 32 // PW , 32 // PW , 128 // IP-T/device name , 64 // model , 64 // vFirmware , 0 // online/offline state }))) { CYNG_LOG_FATAL(logger, "cannot create table TGateway"); } // https://www.thethingsnetwork.org/docs/lorawan/address-space.html#devices // DevEUI - 64 bit end-device identifier, EUI-64 (unique) // DevAddr - 32 bit device address (non-unique) if (!create_table(db, "TLoRaDevice")) { CYNG_LOG_FATAL(logger, "cannot create table TLoRaDevice"); } if (!db.create_table(cyng::table::make_meta_table<1, 13>("TMeter", { "pk" , "ident" // ident nummer (i.e. 1EMH0006441734, 01-e61e-13090016-3c-07) , "meter" // meter number (i.e. 16000913) 4 bytes , "code" // metering code - changed at 2019-01-31 , "maker" // manufacturer , "tom" // time of manufacture , "vFirmware" // firmwareversion (i.e. 11600000) , "vParam" // parametrierversion (i.e. 16A098828.pse) , "factoryNr" // fabrik nummer (i.e. 06441734) , "item" // ArtikeltypBezeichnung = "NXT4-S20EW-6N00-4000-5020-E50/Q" , "mClass" // Metrological Class: A, B, C, Q3/Q1, ... , "gw" // optional gateway pk // -- additional columns , "serverId" // optional gateway server ID , "online" // gateway online state (1,2,3) }, { cyng::TC_UUID , cyng::TC_STRING // ident , cyng::TC_STRING // meter , cyng::TC_STRING // code , cyng::TC_STRING // maker , cyng::TC_TIME_POINT // tom , cyng::TC_STRING // vFirmware , cyng::TC_STRING // vParam , cyng::TC_STRING // factoryNr , cyng::TC_STRING // item , cyng::TC_STRING // mClass , cyng::TC_UUID // gw , cyng::TC_STRING // serverID , cyng::TC_INT32 // on/offline state }, { 36 , 24 // ident , 8 // meter , 33 // code - country[2], ident[11], number[22] , 64 // maker , 0 // tom , 64 // vFirmware , 64 // vParam , 32 // factoryNr , 128 // item , 8 // mClass , 36 // gw , 23 // serverId , 0 // on/offline state }))) { CYNG_LOG_FATAL(logger, "cannot create table TMeter"); } if (!create_table(db, "_Session")) { CYNG_LOG_FATAL(logger, "cannot create table _Session"); } if (!create_table(db, "_Target")) { CYNG_LOG_FATAL(logger, "cannot create table _Target"); } if (!create_table(db, "_Connection")) { CYNG_LOG_FATAL(logger, "cannot create table _Connection"); } if (!create_table(db, "_Cluster")) { CYNG_LOG_FATAL(logger, "cannot create table _Cluster"); } if (!create_table(db, "_Config")) { CYNG_LOG_FATAL(logger, "cannot create table _Config"); } else { // // set initial value // //db.insert("_Config", cyng::table::key_generator("cpu:load"), cyng::table::data_generator(0.0), 0, bus_->vm_.tag()); } if (!create_table(db, "_SysMsg")) { CYNG_LOG_FATAL(logger, "cannot create table _SysMsg"); } if (!create_table(db, "_TimeSeries")) { CYNG_LOG_FATAL(logger, "cannot create table _TimeSeries"); } if (!create_table(db, "_CSV")) { CYNG_LOG_FATAL(logger, "cannot create table _CSV"); } if (!create_table(db, "_LoRaUplink")) { CYNG_LOG_FATAL(logger, "cannot create table _LoRaUplink"); } // // all tables created // CYNG_LOG_INFO(logger, db.size() << " tables created"); } void clear_cache(cyng::store::db& db, boost::uuids::uuid tag) { db.clear("TDevice", tag); db.clear("TGateway", tag); db.clear("TMeter", tag); db.clear("_Session", tag); db.clear("_Target", tag); db.clear("_Connection", tag); db.clear("_Cluster", tag); db.clear("_Config", tag); db.insert("_Config", cyng::table::key_generator("cpu:load"), cyng::table::data_generator(0.0), 0, tag); //cache_.clear("_SysMsg", bus_->vm_.tag()); } void res_subscribe(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::table::data_type data // [2] record , std::uint64_t gen // [3] generation , boost::uuids::uuid origin // [4] origin session id , std::size_t tsk) { // // Boost gateway records with additional data from TDevice and _Session table // if (boost::algorithm::equals(table, "TGateway")) { // // Additional values for TGateway // db.access([&](const cyng::store::table* tbl_dev, const cyng::store::table* tbl_ses) { // // Gateway and Device table share the same table key // look for a session of this device // auto dev_rec = tbl_dev->lookup(key); auto ses_rec = tbl_ses->find_first(cyng::param_t("device", key.at(0))); // // set device name // set model // set firmware // set online state // if (!dev_rec.empty()) { data.push_back(dev_rec["name"]); data.push_back(dev_rec["descr"]); data.push_back(dev_rec["id"]); data.push_back(dev_rec["vFirmware"]); if (ses_rec.empty()) { data.push_back(cyng::make_object(0)); } else { const auto peer = cyng::value_cast(ses_rec["rtag"], boost::uuids::nil_uuid()); data.push_back(cyng::make_object(peer.is_nil() ? 1 : 2)); } } else { CYNG_LOG_WARNING(logger, "res.subscribe - gateway" << cyng::io::to_str(key) << " has no associated device"); } } , cyng::store::read_access("TDevice") , cyng::store::read_access("_Session")); } // // Boost meter records with additional data from TGateway // else if (boost::algorithm::equals(table, "TMeter")) { // // Additional values for TMeter // db.access([&](const cyng::store::table* tbl_gw) { // // TMeter contains an optional reference to TGateway table // auto key = cyng::table::key_generator(data.at(10)); auto dev_gw = tbl_gw->lookup(key); // // set serverId and online state // if (!dev_gw.empty()) { data.push_back(dev_gw["serverId"]); data.push_back(dev_gw["online"]); } else { data.push_back(cyng::make_object("05000000000000")); data.push_back(cyng::make_object(-1)); CYNG_LOG_WARNING(logger, "res.subscribe - meter" << cyng::io::to_str(key) << " has no associated gateway"); } }, cyng::store::read_access("TGateway")); } // // insert new record // if (!db.insert(table // table name , key // table key , data // table data , gen // generation , origin)) { CYNG_LOG_WARNING(logger, "res.subscribe failed " << table // table name << " - " << cyng::io::to_str(key)); } else { if (boost::algorithm::equals(table, "_Session")) { // // mark gateways as online // db.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set state: offline tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { // // If rtag is not nil then this session has an open connection // auto const rtag = cyng::value_cast(rec["rtag"], boost::uuids::nil_uuid()); auto const state = rtag.is_nil() ? 1 : 2; tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", state), origin); // // update TMeter // Lookup if TMeter has a gateway with this key // This method is inherently slow. // ToDo: optimize // std::map<cyng::table::key_type, int> result; auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is online/connected // result.emplace(rec.key(), state); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item.first, cyng::param_factory("online", item.second), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } } } db_sync::db_sync(cyng::logging::log_ptr logger, cyng::store::db& db) : logger_(logger) , db_(db) {} void db_sync::register_this(cyng::controller& vm) { vm.register_function("db.res.insert", 4, std::bind(&db_sync::db_res_insert, this, std::placeholders::_1)); vm.register_function("db.res.remove", 2, std::bind(&db_sync::db_res_remove, this, std::placeholders::_1)); vm.register_function("db.res.modify.by.attr", 3, std::bind(&db_sync::db_res_modify_by_attr, this, std::placeholders::_1)); vm.register_function("db.res.modify.by.param", 3, std::bind(&db_sync::db_res_modify_by_param, this, std::placeholders::_1)); vm.register_function("db.req.insert", 4, std::bind(&db_sync::db_req_insert, this, std::placeholders::_1)); vm.register_function("db.req.remove", 3, std::bind(&db_sync::db_req_remove, this, std::placeholders::_1)); vm.register_function("db.req.modify.by.param", 5, std::bind(&db_sync::db_req_modify_by_param, this, std::placeholders::_1)); } void db_sync::db_res_insert(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [TDevice,[32f1a373-83c9-4f24-8fac-b13103bc7466],[00000006,2018-03-11 18:35:33.61302590,true,,,comment #10,1010000,secret,device-10000],0] // // * table name // * record key // * record data // * generation // CYNG_LOG_TRACE(logger_, "db.res.insert - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::table::data_type, // [2] record std::uint64_t // [3] generation >(frame); // // assemble a record // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); std::reverse(std::get<2>(tpl).begin(), std::get<2>(tpl).end()); db_insert(ctx , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl) // [2] record , std::get<3>(tpl) // [3] generation , ctx.tag()); // [4] origin } void db_sync::db_req_insert(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // // * table name // * record key // * record data // * generation // CYNG_LOG_TRACE(logger_, "db.req.insert - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::table::data_type, // [2] record std::uint64_t, // [3] generation boost::uuids::uuid // [4] source >(frame); // // assemble a record // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); std::reverse(std::get<2>(tpl).begin(), std::get<2>(tpl).end()); db_insert(ctx , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl) // [2] record , std::get<3>(tpl) // [3] generation , std::get<4>(tpl)); // [4] origin } void db_sync::db_req_remove(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [*Session,[e72bc048-cb37-4a86-b156-d07f22608476]] // // * table name // * record key // * source // CYNG_LOG_TRACE(logger_, "db.req.remove - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key boost::uuids::uuid // [2] source >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_req_remove(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl)); // [2] source } void db_sync::db_res_remove(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [TDevice,[def8e1ef-4a67-49ff-84a9-fda31509dd8e]] // // * table name // * record key // CYNG_LOG_TRACE(logger_, "db.res.remove - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type // [1] table key >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_res_remove(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , ctx.tag()); // [2] source } void db_sync::db_res_modify_by_attr(cyng::context& ctx) { // [TDevice,[0950f361-7800-4d80-b3bc-c6689f159439],(1:secret)] // // * table name // * record key // * attr [column,value] // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.res.modify.by.attr - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::attr_t // [2] attribute >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_res_modify_by_attr(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] attribute , ctx.tag()); // [3] source } void db_sync::db_res_modify_by_param(cyng::context& ctx) { // // // * table name // * record key // * param [column,value] // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.res.modify.by.param - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::param_t // [2] parameter >(frame); node::db_res_modify_by_param(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] parameter , ctx.tag()); // [3] source } void db_sync::db_req_modify_by_param(cyng::context& ctx) { // // [*Session,[35d1d76d-56c3-4df7-b1ff-b7ad374d2e8f],("rx":33344),327,35d1d76d-56c3-4df7-b1ff-b7ad374d2e8f] // [*Cluster,[1e4527b3-6479-4b2c-854b-e4793f40d864],("ping":00:00:0.003736),4,1e4527b3-6479-4b2c-854b-e4793f40d864] // // * table name // * record key // * param [column,value] // * generation // * source // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.req.modify.by.param - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::param_t, // [2] parameter std::uint64_t, // [3] generation boost::uuids::uuid // [4] source >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_req_modify_by_param(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] parameter , std::get<3>(tpl) // [3] generation , std::get<4>(tpl)); // [4] source } void db_sync::db_insert(cyng::context& ctx , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::table::data_type data // [2] record , std::uint64_t gen , boost::uuids::uuid origin) { if (boost::algorithm::equals(table, "TGateway")) { db_.access([&](cyng::store::table* tbl_gw, const cyng::store::table* tbl_dev, const cyng::store::table* tbl_ses) { // // search session with this device/GW tag // auto dev_rec = tbl_dev->lookup(key); // // set device name // set model // set vFirmware // set online state // if (!dev_rec.empty()) { data.push_back(dev_rec["name"]); data.push_back(dev_rec["descr"]); data.push_back(dev_rec["id"]); data.push_back(dev_rec["vFirmware"]); // // get online state // auto ses_rec = tbl_ses->find_first(cyng::param_t("device", key.at(0))); if (ses_rec.empty()) { data.push_back(cyng::make_object(0)); } else { const auto rtag = cyng::value_cast(ses_rec["rtag"], boost::uuids::nil_uuid()); data.push_back(cyng::make_object(rtag.is_nil() ? 1 : 2)); } if (!tbl_gw->insert(key, data, gen, origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); } } else { std::stringstream ss; ss << "gateway " << cyng::io::to_str(key) << " has no associated device" ; CYNG_LOG_WARNING(logger_, ss.str()); ctx.queue(bus_insert_msg(cyng::logging::severity::LEVEL_WARNING, ss.str())); } } , cyng::store::write_access("TGateway") , cyng::store::read_access("TDevice") , cyng::store::read_access("_Session")); } else if (boost::algorithm::equals(table, "TMeter")) { // // Additional values for TMeter // db_.access([&](cyng::store::table* tbl_meter, cyng::store::table const* tbl_gw) { // // TMeter contains an optional reference to TGateway table // auto const key_gw = cyng::table::key_generator(data.at(10)); auto const dev_gw = tbl_gw->lookup(key_gw); // // set serverId // if (!dev_gw.empty()) { data.push_back(dev_gw["serverId"]); data.push_back(dev_gw["online"]); } else { data.push_back(cyng::make_object("00000000000000")); data.push_back(cyng::make_object(-1)); CYNG_LOG_WARNING(logger_, "res.subscribe - meter" << cyng::io::to_str(key) << " has no associated gateway"); } if (!tbl_meter->insert(key, data, gen, origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); } } , cyng::store::write_access("TMeter") , cyng::store::read_access("TGateway")); } else if (!db_.insert(table , key , data , gen , origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); // // dump record data // std::size_t idx{ 0 }; for (auto const& obj : data) { CYNG_LOG_TRACE(logger_, "data [" << idx++ << "] " << obj.get_class().type_name() << ": " << cyng::io::to_str(obj)) ; } } else { if (boost::algorithm::equals(table, "_Session")) { db_.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set online state tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { auto const rtag = cyng::value_cast(rec["rtag"], boost::uuids::nil_uuid()); auto const state = rtag.is_nil() ? 1 : 2; tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", state), origin); // // update TMeter // Lookup if TMeter has a gateway with this key // This method is inherently slow. // ToDo: optimize // std::map<cyng::table::key_type, int> result; auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is online/connected // result.emplace(rec.key(), state); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item.first, cyng::param_factory("online", item.second), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } } } void db_req_remove(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , boost::uuids::uuid origin) { // // we have to query session data before session will be removed // if (boost::algorithm::equals(table, "_Session")) { db.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (!rec.empty()) { // set online state auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_gw->modify(cyng::table::key_generator(gw_tag), cyng::param_factory("online", 0), origin); // // find meters of this gateway and set offline // std::set<cyng::table::key_type> result; tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is offline // result.emplace(rec.key()); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item, cyng::param_factory("online", 0), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } // // remove record // if (!db.erase(table, key, origin)) { CYNG_LOG_WARNING(logger, "db.req.remove failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_remove(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , boost::uuids::uuid origin) { if (!db.erase(table, key, origin)) { CYNG_LOG_WARNING(logger, "db.res.remove failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_modify_by_attr(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::attr_t attr // [2] attribute , boost::uuids::uuid origin) { // // distribute some changes to other tables too // if (boost::algorithm::equals(table, "TDevice")) { switch (attr.first) { case 0: // change name db.modify("TGateway", key, cyng::param_factory("name", attr.second), origin); break; case 3: // change description db.modify("TGateway", key, cyng::param_factory("descr", attr.second), origin); break; default: break; } } else if (boost::algorithm::equals(table, "TGateway")) { // // distribute changes from TGateway to TMeter // switch (attr.first) { case 0: // modified serverID db.access([&](cyng::store::table* tbl_meter) { auto const gw_tag = cyng::value_cast(key.at(0), boost::uuids::nil_uuid()); std::set<cyng::table::key_type> result; tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { result.insert(rec.key()); } return true; // continue }); for (auto const& item : result) { tbl_meter->modify(item, cyng::param_factory("serverId", attr.second), origin); } }, cyng::store::write_access("TMeter")); break; default: break; } } // // update cache // if (!db.modify(table, key, std::move(attr), origin)) { CYNG_LOG_WARNING(logger, "db.res.modify.by.attr failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_modify_by_param(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::param_t param // [2] parameter , boost::uuids::uuid origin) { if (!db.modify(table, key, param, origin)) { CYNG_LOG_WARNING(logger, "db.res.modify.by.param failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_req_modify_by_param(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::param_t param // [2] parameter , std::uint64_t gen // [3] generation , boost::uuids::uuid origin) { if (boost::algorithm::equals(table, "_Session")) { if (boost::algorithm::equals(param.first, "rtag")) { const auto rtag = cyng::value_cast(param.second, boost::uuids::nil_uuid()); // // mark gateways as online // db.access([&](cyng::store::table* tbl_gw, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set online state tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", rtag.is_nil() ? 1 : 2), origin); } } , cyng::store::write_access("TGateway") , cyng::store::read_access("_Session")); } } if (!db.modify(table, key, param, origin)) { CYNG_LOG_WARNING(logger, "db.req.modify.by.param failed " << table // table name << " - " << cyng::io::to_str(key)); } } }
28.226923
234
0.598617
solosTec
d2bd648559a621c4b9ee276afe119fd1ef0202ae
361
cpp
C++
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
#include "updatepetprofile.h" #include "ui_updatepetprofile.h" /** * @brief Constructor for the class * @param parent */ updatepetprofile::updatepetprofile(QWidget *parent) : QWidget(parent), ui(new Ui::updatepetprofile) { ui->setupUi(this); } /** * @brief Destructor for the class */ updatepetprofile::~updatepetprofile() { delete ui; }
16.409091
53
0.689751
alisultan14
d2c4a86d2544d252c415e7a8fed4b6dc477617c9
2,837
cpp
C++
RVAF-GUI/teechart/highlowseries.cpp
YangQun1/RVAF-GUI
f187e2325fc8fdbac84a63515b7dd67c09e2fc72
[ "BSD-2-Clause" ]
4
2018-03-31T10:45:19.000Z
2021-10-09T02:57:13.000Z
RVAF-GUI/teechart/highlowseries.cpp
P-Chao/RVAF-GUI
3bbeed7d2ffa400f754f095e7c08400f701813d4
[ "BSD-2-Clause" ]
1
2018-04-22T05:12:36.000Z
2018-04-22T05:12:36.000Z
RVAF-GUI/teechart/highlowseries.cpp
YangQun1/RVAF-GUI
f187e2325fc8fdbac84a63515b7dd67c09e2fc72
[ "BSD-2-Clause" ]
5
2018-01-13T15:57:14.000Z
2019-11-12T03:23:18.000Z
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. #include "stdafx.h" #include "highlowseries.h" // Dispatch interfaces referenced by this interface #include "valuelist.h" #include "brush.h" #include "pen.h" ///////////////////////////////////////////////////////////////////////////// // CHighLowSeries properties ///////////////////////////////////////////////////////////////////////////// // CHighLowSeries operations long CHighLowSeries::AddHighLow(double AX, double AHigh, double ALow, LPCTSTR AXLabel, unsigned long AColor) { long result; static BYTE parms[] = VTS_R8 VTS_R8 VTS_R8 VTS_BSTR VTS_I4; InvokeHelper(0xc9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, AX, AHigh, ALow, AXLabel, AColor); return result; } CValueList CHighLowSeries::GetHighValues() { LPDISPATCH pDispatch; InvokeHelper(0xca, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CValueList(pDispatch); } CValueList CHighLowSeries::GetLowValues() { LPDISPATCH pDispatch; InvokeHelper(0xcb, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CValueList(pDispatch); } double CHighLowSeries::MaxYValue() { double result; InvokeHelper(0xcc, DISPATCH_METHOD, VT_R8, (void*)&result, NULL); return result; } double CHighLowSeries::MinYValue() { double result; InvokeHelper(0xcd, DISPATCH_METHOD, VT_R8, (void*)&result, NULL); return result; } CBrush1 CHighLowSeries::GetHighBrush() { LPDISPATCH pDispatch; InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CBrush1(pDispatch); } CPen1 CHighLowSeries::GetHighPen() { LPDISPATCH pDispatch; InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } CBrush1 CHighLowSeries::GetLowBrush() { LPDISPATCH pDispatch; InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CBrush1(pDispatch); } CPen1 CHighLowSeries::GetLowPen() { LPDISPATCH pDispatch; InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } CPen1 CHighLowSeries::GetPen() { LPDISPATCH pDispatch; InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } long CHighLowSeries::GetTransparency() { long result; InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); return result; } void CHighLowSeries::SetTransparency(long nNewValue) { static BYTE parms[] = VTS_I4; InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, nNewValue); }
26.027523
109
0.694043
YangQun1
d2c64b2dd24a59bb3dd307e7ca8d91bb9df81260
8,336
hpp
C++
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include <initializer_list> // Including type: System.ValueType #include "System/ValueType.hpp" // Completed includes // Begin il2cpp-utils forward declares template<class T> struct Array; // Completed il2cpp-utils forward declares // Type namespace: UnityEngine namespace UnityEngine { // Size: 0x0 #pragma pack(push, 1) // WARNING Layout: Sequential may not be correctly taken into account! // Autogenerated type: UnityEngine.Mathf // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC struct Mathf/*, public System::ValueType*/ { public: // Creating value type constructor for type: Mathf constexpr Mathf() noexcept {} // Creating interface conversion operator: operator System::ValueType operator System::ValueType() noexcept { return *reinterpret_cast<System::ValueType*>(this); } // Get static field: static public readonly System.Single Epsilon static float _get_Epsilon(); // Set static field: static public readonly System.Single Epsilon static void _set_Epsilon(float value); // static public System.Int32 NextPowerOfTwo(System.Int32 value) // Offset: 0x1BF493C static int NextPowerOfTwo(int value); // static public System.Single GammaToLinearSpace(System.Single value) // Offset: 0x1BF497C static float GammaToLinearSpace(float value); // static public System.Single LinearToGammaSpace(System.Single value) // Offset: 0x1BF49C0 static float LinearToGammaSpace(float value); // static public System.Single PerlinNoise(System.Single x, System.Single y) // Offset: 0x1BF4A04 static float PerlinNoise(float x, float y); // static public System.Single Sin(System.Single f) // Offset: 0x1BF4A50 static float Sin(float f); // static public System.Single Cos(System.Single f) // Offset: 0x1BF4AC4 static float Cos(float f); // static public System.Single Tan(System.Single f) // Offset: 0x1BF4B38 static float Tan(float f); // static public System.Single Asin(System.Single f) // Offset: 0x1BF4BAC static float Asin(float f); // static public System.Single Acos(System.Single f) // Offset: 0x1BF4C20 static float Acos(float f); // static public System.Single Atan(System.Single f) // Offset: 0x1BF4C94 static float Atan(float f); // static public System.Single Atan2(System.Single y, System.Single x) // Offset: 0x1BF4D08 static float Atan2(float y, float x); // static public System.Single Sqrt(System.Single f) // Offset: 0x1BF4D84 static float Sqrt(float f); // static public System.Single Abs(System.Single f) // Offset: 0x1BF4E0C static float Abs(float f); // static public System.Int32 Abs(System.Int32 value) // Offset: 0x1BF4E78 static int Abs(int value); // static public System.Single Min(System.Single a, System.Single b) // Offset: 0x1BF4EE0 static float Min(float a, float b); // static public System.Int32 Min(System.Int32 a, System.Int32 b) // Offset: 0x1BF4EEC static int Min(int a, int b); // static public System.Single Max(System.Single a, System.Single b) // Offset: 0x1BF4EF8 static float Max(float a, float b); // static public System.Single Max(params System.Single[] values) // Offset: 0x1BF4F04 static float Max(::Array<float>* values); // Creating initializer_list -> params proxy for: System.Single Max(params System.Single[] values) static float Max(std::initializer_list<float> values); // Creating TArgs -> initializer_list proxy for: System.Single Max(params System.Single[] values) template<class ...TParams> static float Max(TParams&&... values) { return Max({values...}); } // static public System.Int32 Max(System.Int32 a, System.Int32 b) // Offset: 0x1BF4F58 static int Max(int a, int b); // static public System.Single Pow(System.Single f, System.Single p) // Offset: 0x1BF4F64 static float Pow(float f, float p); // static public System.Single Log(System.Single f, System.Single p) // Offset: 0x1BF4FE4 static float Log(float f, float p); // static public System.Single Log(System.Single f) // Offset: 0x1BF5064 static float Log(float f); // static public System.Single Ceil(System.Single f) // Offset: 0x1BF50D8 static float Ceil(float f); // static public System.Single Floor(System.Single f) // Offset: 0x1BF5144 static float Floor(float f); // static public System.Single Round(System.Single f) // Offset: 0x1BF51B0 static float Round(float f); // static public System.Int32 CeilToInt(System.Single f) // Offset: 0x1BF5288 static int CeilToInt(float f); // static public System.Int32 FloorToInt(System.Single f) // Offset: 0x1BF52F4 static int FloorToInt(float f); // static public System.Int32 RoundToInt(System.Single f) // Offset: 0x1BF5360 static int RoundToInt(float f); // static public System.Single Sign(System.Single f) // Offset: 0x1BF5438 static float Sign(float f); // static public System.Single Clamp(System.Single value, System.Single min, System.Single max) // Offset: 0x1BF544C static float Clamp(float value, float min, float max); // static public System.Int32 Clamp(System.Int32 value, System.Int32 min, System.Int32 max) // Offset: 0x1BF5468 static int Clamp(int value, int min, int max); // static public System.Single Clamp01(System.Single value) // Offset: 0x1BF5484 static float Clamp01(float value); // static public System.Single Lerp(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF54A0 static float Lerp(float a, float b, float t); // static public System.Single LerpUnclamped(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF5538 static float LerpUnclamped(float a, float b, float t); // static public System.Single LerpAngle(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF5548 static float LerpAngle(float a, float b, float t); // static public System.Single MoveTowards(System.Single current, System.Single target, System.Single maxDelta) // Offset: 0x1BF56B0 static float MoveTowards(float current, float target, float maxDelta); // static public System.Boolean Approximately(System.Single a, System.Single b) // Offset: 0x1BF576C static bool Approximately(float a, float b); // static public System.Single SmoothDamp(System.Single current, System.Single target, ref System.Single currentVelocity, System.Single smoothTime) // Offset: 0x1BF581C static float SmoothDamp(float current, float target, float& currentVelocity, float smoothTime); // static public System.Single SmoothDamp(System.Single current, System.Single target, ref System.Single currentVelocity, System.Single smoothTime, System.Single maxSpeed, System.Single deltaTime) // Offset: 0x1BF58C0 static float SmoothDamp(float current, float target, float& currentVelocity, float smoothTime, float maxSpeed, float deltaTime); // static public System.Single Repeat(System.Single t, System.Single length) // Offset: 0x1BF5620 static float Repeat(float t, float length); // static public System.Single InverseLerp(System.Single a, System.Single b, System.Single value) // Offset: 0x1BF5A14 static float InverseLerp(float a, float b, float value); // static public System.Single DeltaAngle(System.Single current, System.Single target) // Offset: 0x1BF5AB8 static float DeltaAngle(float current, float target); // static private System.Void .cctor() // Offset: 0x1BF5B50 static void _cctor(); }; // UnityEngine.Mathf #pragma pack(pop) } #include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(UnityEngine::Mathf, "UnityEngine", "Mathf");
47.096045
201
0.691819
darknight1050
d2c731a879f215d360cef570db551c42de6fdd96
4,216
cxx
C++
ParaViewCore/ServerManager/Rendering/vtkSMComparativeAnimationCueUndoElement.cxx
brown-ccv/paraview-scalable
64b221a540737d2ac94a120039bd8d1e661bdc8f
[ "Apache-2.0", "BSD-3-Clause" ]
2
2021-07-07T22:53:19.000Z
2021-07-31T19:29:35.000Z
ParaViewCore/ServerManager/Rendering/vtkSMComparativeAnimationCueUndoElement.cxx
sakjain92/paraview
f3af0cd9f6750e24ad038eac573b870c88d6b7dd
[ "Apache-2.0", "BSD-3-Clause" ]
2
2020-11-18T16:50:34.000Z
2022-01-21T13:31:47.000Z
ParaViewCore/ServerManager/Rendering/vtkSMComparativeAnimationCueUndoElement.cxx
sakjain92/paraview
f3af0cd9f6750e24ad038eac573b870c88d6b7dd
[ "Apache-2.0", "BSD-3-Clause" ]
5
2020-10-02T10:14:35.000Z
2022-03-10T07:50:22.000Z
/*========================================================================= Program: ParaView Module: vtkSMComparativeAnimationCueUndoElement.cxx Copyright (c) Kitware, Inc. All rights reserved. See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkSMComparativeAnimationCueUndoElement.h" #include "vtkCollection.h" #include "vtkCommand.h" #include "vtkObjectFactory.h" #include "vtkPVComparativeAnimationCue.h" #include "vtkPVXMLElement.h" #include "vtkSMComparativeAnimationCueProxy.h" #include "vtkSMProxyLocator.h" #include "vtkSMProxyManager.h" #include "vtkSMSession.h" #include "vtkSMSessionProxyManager.h" vtkStandardNewMacro(vtkSMComparativeAnimationCueUndoElement); //----------------------------------------------------------------------------- vtkSMComparativeAnimationCueUndoElement::vtkSMComparativeAnimationCueUndoElement() { this->ComparativeAnimationCueID = 0; } //----------------------------------------------------------------------------- vtkSMComparativeAnimationCueUndoElement::~vtkSMComparativeAnimationCueUndoElement() { } //----------------------------------------------------------------------------- void vtkSMComparativeAnimationCueUndoElement::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); } //---------------------------------------------------------------------------- int vtkSMComparativeAnimationCueUndoElement::Undo() { if (this->ComparativeAnimationCueID && this->Session->GetRemoteObject(this->ComparativeAnimationCueID) && this->BeforeState && this->BeforeState->GetNestedElement(0)) { vtkSMComparativeAnimationCueProxy* proxy = vtkSMComparativeAnimationCueProxy::SafeDownCast( this->Session->GetRemoteObject(this->ComparativeAnimationCueID)); proxy->GetComparativeAnimationCue()->LoadCommandInfo(this->BeforeState->GetNestedElement(0)); proxy->InvokeEvent(vtkCommand::ModifiedEvent); // Will update the UI } return 1; } //---------------------------------------------------------------------------- int vtkSMComparativeAnimationCueUndoElement::Redo() { if (this->ComparativeAnimationCueID && this->AfterState && this->AfterState->GetNestedElement(0)) { // Make sure the proxy exist. // In the current undostack vtkSMComparativeAnimationCueUndoElement will // always occurs before the actual proxy will get registered therefore // when we redo from nothing we have no other choice than recreating that // proxy HERE which should ONLY be done inside the ProxyManager at the // registration time. if (!this->Session->GetRemoteObject(this->ComparativeAnimationCueID)) { vtkSMProxy* proxy = this->Session->GetProxyLocator()->LocateProxy(this->ComparativeAnimationCueID); this->UndoSetWorkingContext->AddItem(proxy); proxy->LoadXMLState(this->AfterState->GetNestedElement(0), NULL); proxy->Delete(); } else { vtkSMComparativeAnimationCueProxy* proxy = vtkSMComparativeAnimationCueProxy::SafeDownCast( this->Session->GetRemoteObject(this->ComparativeAnimationCueID)); proxy->GetComparativeAnimationCue()->LoadCommandInfo(this->AfterState->GetNestedElement(0)); proxy->InvokeEvent(vtkCommand::ModifiedEvent); // Will update the UI } } return 1; } //---------------------------------------------------------------------------- void vtkSMComparativeAnimationCueUndoElement::SetXMLStates( vtkTypeUInt32 proxyID, vtkPVXMLElement* before, vtkPVXMLElement* after) { this->ComparativeAnimationCueID = proxyID; if (before) { this->BeforeState = vtkSmartPointer<vtkPVXMLElement>::New(); before->CopyTo(this->BeforeState); } else { this->BeforeState = NULL; } if (after) { this->AfterState = vtkSmartPointer<vtkPVXMLElement>::New(); after->CopyTo(this->AfterState); } else { this->AfterState = NULL; } }
36.66087
99
0.644213
brown-ccv
d2c7e9ab7e38e29a8a77911dce767c34047af947
11,563
cc
C++
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2021-04-21T06:39:42.000Z
2021-04-21T06:39:42.000Z
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2019-01-20T17:35:23.000Z
2019-01-22T21:41:38.000Z
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2021-09-29T16:06:57.000Z
2021-09-29T16:06:57.000Z
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyright (c) 1996 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Network Research * Group at Lawrence Berkeley National Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* 9/96 Pittsburgh Supercomputing Center * UpdateScoreBoard, CheckSndNxt, MarkRetran modified for fack */ #ifndef lint static const char rcsid[] = "@(#) $Header: /cvsroot/nsnam/ns-2/tcp/scoreboard-rh.cc,v 1.2 2000/08/12 21:45:39 sfloyd Exp $ (LBL)"; #endif /* A quick hack version of the scoreboard */ #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <math.h> #include "packet.h" #include "scoreboard-rh.h" #include "tcp.h" #define ASSERT(x) if (!(x)) {printf ("Assert SB failed\n"); exit(1);} #define ASSERT1(x) if (!(x)) {printf ("Assert1 SB (length)\n"); exit(1);} #define SBNI SBN[i%SBSIZE] // last_ack = TCP last ack int ScoreBoardRH::UpdateScoreBoard (int last_ack, hdr_tcp* tcph, int rh_id) { int i, sack_index, sack_left, sack_right; int sack_max = 0; int retran_decr = 0; /* Can't do this, because we need to process out the retran_decr */ #if 0 if (tcph->sa_length() == 0) { // There are no SACK blocks, so clear the scoreboard. this->ClearScoreBoard(); return(0); } #endif /* What we do need to do is not create a scoreboard if we don't need one. */ if ((tcph->sa_length() == 0) && (length_ == 0)) { return(0); } // If there is no scoreboard, create one. if (length_ == 0) { i = last_ack+1; SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; first_ = i%SBSIZE; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } // Advance the left edge of the block. if (SBN[first_].seq_no_ <= last_ack) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<=last_ack; i++) { // Advance the ACK if (SBNI.seq_no_ <= last_ack) { ASSERT(first_ == i%SBSIZE); first_ = (first_+1)%SBSIZE; length_--; ASSERT1(length_ >= 0); SBNI.ack_flag_ = 1; SBNI.sack_flag_ = 1; if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; retran_sacked_ = rh_id; } if (length_==0) break; } } } for (sack_index=0; sack_index < tcph->sa_length(); sack_index++) { sack_left = tcph->sa_left(sack_index); sack_right = tcph->sa_right(sack_index); /* Remember the highest segment SACKed by this packet */ if (sack_right > sack_max) { sack_max = sack_right; } // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_right; i++) { // Check to see if this segment is now covered by the sack block if (SBNI.seq_no_ >= sack_left && SBNI.seq_no_ < sack_right) { if (! SBNI.sack_flag_) { SBNI.sack_flag_ = 1; } if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; retran_sacked_ = rh_id; } } } } /* Now go through the whole scoreboard and update sack_cnt on holes which still exist. */ if (length_ != 0) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_max; i++) { // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.sack_cnt_++; } } } retran_decr += CheckSndNxt(sack_max); return (retran_decr); } int ScoreBoardRH::CheckSndNxt (int sack_max) { int i; int num_lost = 0; if (length_ != 0) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_max; i++) { // Check to see if this segment's snd_nxt_ is now covered by the sack block if (SBNI.retran_ && SBNI.snd_nxt_ < sack_max) { // the packet was lost again SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 1; num_lost++; } } } return (num_lost); } void ScoreBoardRH::ClearScoreBoard() { length_ = 0; } /* * GetNextRetran() returns "-1" if there is no packet that is * not acked and not sacked and not retransmitted. */ int ScoreBoardRH::GetNextRetran() // Returns sequence number of next pkt... { int i; if (length_) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && !SBNI.retran_ && (SBNI.sack_cnt_ >= *numdupacks_)) { return (i); } } } return (-1); } void ScoreBoardRH::MarkRetran (int retran_seqno, int snd_nxt, int rh_id) { SBN[retran_seqno%SBSIZE].retran_ = 1; SBN[retran_seqno%SBSIZE].snd_nxt_ = snd_nxt; SBN[retran_seqno%SBSIZE].rh_id_ = rh_id; retran_occured_ = rh_id; } int ScoreBoardRH::GetFack (int last_ack) { if (length_) { return(SBN[(first_)%SBSIZE].seq_no_+length_-1); } else { return(last_ack); } } int ScoreBoardRH::GetNewHoles () { int i, new_holes=0; for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { // Check to see if this segment is a new hole #if 1 if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && SBNI.sack_cnt_ == 1) { new_holes++; } #else if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && SBNI.sack_cnt_ == *numdupacks_) { new_holes++; } #endif } return (new_holes); } void ScoreBoardRH::TimeoutScoreBoard (int snd_nxt) { int i, sack_right; if (length_ == 0) { // No need to do anything! return; } sack_right = snd_nxt; // Use this to know how far to extend. // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } /* Now go through the whole scoreboard and update sack_cnt on holes; clear retran flag on everything. */ for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = *numdupacks_; // This forces all holes to be retransmitted. } } /* And, finally, check the first segment in case of a renege. */ i=SBN[(first_)%SBSIZE].seq_no_; if (!SBNI.ack_flag_ && SBNI.sack_flag_) { printf ("Renege!!! seqno = %d\n", SBNI.seq_no_); SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = *numdupacks_; // This forces it to be retransmitted. } } #if 0 /* This routine inserts a fake sack block of length num_dupacks, starting at last_ack+1. It is for use during NewReno recovery. */ int ScoreBoardRH::FakeSack (int last_ack, int num_dupacks) { int i, sack_left, sack_right; int retran_decr = 0; // If there is no scoreboard, create one. if (length_ == 0) { i = last_ack+1; SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; first_ = i%SBSIZE; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } // Advance the left edge of the scoreboard. if (SBN[first_].seq_no_ <= last_ack) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<=last_ack; i++) { // Advance the ACK if (SBNI.seq_no_ <= last_ack) { ASSERT(first_ == i%SBSIZE); first_ = (first_+1)%SBSIZE; length_--; ASSERT1(length_ >= 0); SBNI.ack_flag_ = 1; SBNI.sack_flag_ = 1; if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; } if (length_==0) break; } } /* Now create a new hole in the first position */ i=SBN[(first_)%SBSIZE].seq_no_; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.rh_id_ = 0; SBNI.sack_cnt_ = num_dupacks; } sack_left = last_ack + 1; sack_right = sack_left + num_dupacks - 1; // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_right; i++) { // Check to see if this segment is now covered by the sack block if (SBNI.seq_no_ >= sack_left && SBNI.seq_no_ < sack_right) { if (! SBNI.sack_flag_) { SBNI.sack_flag_ = 1; } if (SBNI.retran_) { SBNI.retran_ = 0; retran_decr++; } } } /* Now go through the whole scoreboard and update sack_cnt on holes which still exist. In this case the only possible case is the first hole. */ i=SBN[(first_)%SBSIZE].seq_no_; // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.sack_cnt_++; } return (retran_decr); } #endif int ScoreBoardRH::RetranSacked (int rh_id) { return (retran_sacked_ == rh_id); }
26.890698
106
0.653204
nitishk017
d2d4f3e19e863715bcb44468eb2a960df7b33953
3,534
cpp
C++
Assignments/Subject/3 - Assignment/main.cpp
sherali801/data_structures_and_algorithms
8f0351398c2519ff2eaee20fad5b815d06f0966e
[ "Apache-2.0" ]
null
null
null
Assignments/Subject/3 - Assignment/main.cpp
sherali801/data_structures_and_algorithms
8f0351398c2519ff2eaee20fad5b815d06f0966e
[ "Apache-2.0" ]
null
null
null
Assignments/Subject/3 - Assignment/main.cpp
sherali801/data_structures_and_algorithms
8f0351398c2519ff2eaee20fad5b815d06f0966e
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <string> #include <fstream> #include <map> #include <unordered_map> #include <conio.h> using namespace std; #include "class.BST.h" #include "class.BSTNode.h" int main() { unordered_map<string, int> searchQueries;//hold all queries without redundancy fstream * fileHandle = new fstream(); fileHandle->open("search-history.txt", ios::in); if (!fileHandle->is_open()) { cout << "Error while reading file.\nPress any key to continue...\n"; _getch(); return 0; } string query; while (getline(*fileHandle, query)) { if (searchQueries[query] == NULL) { searchQueries[query] = 1; } else { searchQueries[query]++; } } fileHandle->close(); multimap<int, string> sortedSearchQueries;//hold all queries in ascending order according to their occurrences for (unordered_map<string, int>::iterator it = searchQueries.begin(); it != searchQueries.end(); it++) { sortedSearchQueries.insert({it->second, it->first}); } searchQueries.clear(); multimap<int, string>::reverse_iterator r1, r2;//highest is in the end so using reverse iterator r1 = sortedSearchQueries.rbegin(); r2 = sortedSearchQueries.rend(); unordered_map<string, int> topKqueries, top9KRemainingQueries;//hold top 10000 queries based on occurrences int i = 0; for (i = 0; (r1 != r2) && (i < 1000); r1++, i++) { topKqueries[r1->second] = r1->first; } for (i = 0; (r1 != r2) && (i < 9000); r1++, i++) { top9KRemainingQueries[r1->second] = r1->first; } sortedSearchQueries.clear(); fileHandle->open("search-results.txt", ios::in); if (!fileHandle->is_open()) { cout << "Error while reading file.\nPress any key to continue...\n"; _getch(); return 0; } map<string, string> searchResults; string urls; while (!fileHandle->eof()) { getline(*fileHandle, query, ':'); getline(*fileHandle, urls); searchResults[query] = urls; } fileHandle->close(); BST tree; unordered_map<string, int>::iterator it = topKqueries.begin(); map<string, string>::iterator searchResult = searchResults.begin(); while (!topKqueries.empty()) {//storing urls for top 1000 and inserting in BST it = topKqueries.begin(); searchResult = searchResults.find(it->first); tree.insert(it->first, searchResult->second, NULL); topKqueries.erase(it); } topKqueries.clear(); cout << "Top 1000 are stored in BST\n"; while (!top9KRemainingQueries.empty()) {//storing remaining top 9000 without urls in BST it = top9KRemainingQueries.begin(); tree.insert(it->first, "", fileHandle); top9KRemainingQueries.erase(it); } top9KRemainingQueries.clear(); searchResults.clear(); cout << "Remaining Top 9000 are stored in BST\n"; string searchQuery = ""; do { cout << "Please enter search query: "; getline(cin, searchQuery); BSTNode * node = tree.find(searchQuery); if (node != nullptr) { if (node->urls == "") { (node->fileHandle)->open("search-results.txt", ios::in); while (!node->fileHandle->eof()) { getline(*(node->fileHandle), query, ':'); getline(*(node->fileHandle), urls); if (node->query == query) { cout << "Output:" << urls << "\nURLs Read From: Disk\n"; break; } } (node->fileHandle)->close(); } else { cout << "Output:" << node->urls << "\nURLs Read From: Memory\n"; } } else { cout << "Not found\n"; } } while (true); tree.clear(); return 0; }
32.422018
112
0.63073
sherali801
d2d4fb3e81870b5007f46b2a23d4511f5b85e1e2
489
hpp
C++
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
#pragma once #include "xfwin.hpp" namespace Hxsoft{ namespace XFrame { class XFRAME_API xfMdiFrame : public xfWin { public: xfMdiFrame(void); ~xfMdiFrame(void); public: virtual int OnXCommand(LPCTSTR pStrID, class xfControl * pControl); public: HWND m_hMdiClient; public: virtual int AddSheet(xfWin * pWin){return 1;} virtual int SelectSheet(int nIndex){return 1;} virtual int PreSelectSheet(int nIndex){return 1;} public: virtual HWND GetActiveSheet(); }; }}
19.56
69
0.728016
qianxj
d2d51e30449a024b8d8bfe29da811c37a009916a
765
cc
C++
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
1
2018-09-20T08:27:38.000Z
2018-09-20T08:27:38.000Z
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
null
null
null
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
null
null
null
#include <thread> #include <assert.h> #include <unistd.h> #include <wood/net/EventLoop.hh> int main() { assert(wood::EventLoop::getCurerntEventLoop() == nullptr); wood::EventLoop loop; assert(wood::EventLoop::getCurerntEventLoop() == &loop); std::thread ex([&loop](){ assert(wood::EventLoop::getCurerntEventLoop() == nullptr); sleep(2); for(int i= 0; i < 10; i++) { sleep(1); loop.wake(); } loop.runInLoop([&loop](){ loop.stop(); }); }); loop.loop(); if(ex.joinable()) { ex.join(); } }
21.857143
74
0.418301
LeoGale
d2e156fc854b87e3d940fcd13c28ad5a0385bcf8
1,118
hpp
C++
products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationTimerWindow.hpp
bitigchi/MuditaOS
425d23e454e09fd6ae274b00f8d19c57a577aa94
[ "BSL-1.0" ]
1
2022-01-09T18:03:54.000Z
2022-01-09T18:03:54.000Z
products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationTimerWindow.hpp
bitigchi/MuditaOS
425d23e454e09fd6ae274b00f8d19c57a577aa94
[ "BSL-1.0" ]
null
null
null
products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationTimerWindow.hpp
bitigchi/MuditaOS
425d23e454e09fd6ae274b00f8d19c57a577aa94
[ "BSL-1.0" ]
null
null
null
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include <apps-common/widgets/spinners/Spinners.hpp> #include <widgets/BellBaseLayout.hpp> #include <Application.hpp> #include <AppWindow.hpp> #include <InputEvent.hpp> #include "MeditationTimerPresenter.hpp" namespace gui { class MeditationTimerWindow : public AppWindow, public app::meditation::MeditationTimerContract::View { public: explicit MeditationTimerWindow( app::ApplicationCommon *app, std::unique_ptr<app::meditation::MeditationTimerContract::Presenter> &&windowPresenter); // virtual methods void buildInterface() override; bool onInput(const gui::InputEvent &inputEvent) override; void onValueChanged(const std::uint32_t currentValue); private: std::unique_ptr<app::meditation::MeditationTimerContract::Presenter> presenter; BellBaseLayout *body{}; UIntegerSpinner *spinner{}; Label *bottomDescription{}; }; } // namespace gui
30.216216
105
0.703936
bitigchi
d2e1c460f4706588be2c969a3492d31fbb82824f
1,572
cpp
C++
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
// A sample program to find the middle element of the single linked list. // one simple approach is to first find the length of the linked list then again traversal to find the middle element. // second algo is implemented below: #include<iostream> using namespace std; class Node { public: int data; Node * next; }; void pushData(Node ** head_ref, int data ) { Node * temp = new Node(); temp -> data = data; temp -> next = nullptr; Node * current = * head_ref; if(current == nullptr) { *head_ref = temp; } else { while(current -> next != nullptr) { current = current -> next; } current -> next = temp; } } void printList(Node ** head_ref) { Node * current = * head_ref; while (current != nullptr) { cout << current -> data << endl; current = current -> next; } } int findMiddle(Node ** head_ref) { Node * slow_ptr, * fast_ptr; slow_ptr = *head_ref; fast_ptr = *head_ref; while(fast_ptr -> next != nullptr) { slow_ptr = slow_ptr->next; if(fast_ptr -> next -> next != nullptr) { fast_ptr = fast_ptr -> next -> next; } else { fast_ptr = fast_ptr -> next; } } return slow_ptr -> data; } int main() { Node * head = nullptr; pushData(&head, 4); pushData(&head, 5); pushData(&head, 6); pushData(&head, 7); pushData(&head, 8); pushData(&head, 6); printList(&head); cout << "The middle node data is " << findMiddle(&head); return 0; }
20.96
118
0.566158
hkansal27
d2e394b875b885274550f9db4d4284526d7b8261
3,781
cc
C++
test/theta_sketch_dup_test.cc
googleinterns/cardinality-estimation-with-data-deletions
7371c757feda0ae75fc61990c29569b5aa2568f9
[ "Apache-2.0" ]
null
null
null
test/theta_sketch_dup_test.cc
googleinterns/cardinality-estimation-with-data-deletions
7371c757feda0ae75fc61990c29569b5aa2568f9
[ "Apache-2.0" ]
null
null
null
test/theta_sketch_dup_test.cc
googleinterns/cardinality-estimation-with-data-deletions
7371c757feda0ae75fc61990c29569b5aa2568f9
[ "Apache-2.0" ]
1
2020-05-14T18:58:54.000Z
2020-05-14T18:58:54.000Z
#include "theta_sketch_dup.h" #include <gtest/gtest.h> #include <random> #include <set> #include <string> #include "gen_string.h" namespace datasketches { TEST(ThetaSketchDup, TestSerializeDeterminedCaseWithoutEstimation) { // @a: theta sketch with storage set to be [2^5, 2^5*threshold) // @b: theta sketch deserialized from serialized a // this test data stream only has 20 distinct elements, so the result is exact // instead to estimated auto a = update_theta_sketch_dup::builder().set_lg_k(5).build(); for (int i = 0; i < 20; i++) a.update(i); // serialize using proto // a and b should be the same before/after the serialization datasketches_pb::ThetaSketchDup serialized_proto; a.serialize(&serialized_proto); auto b = update_theta_sketch_dup::deserialize(serialized_proto); EXPECT_EQ(a, b); // serialize using bytes // a and b should be the same before/after the serialization auto serialized_bytes = a.serialize(); b = update_theta_sketch_dup::deserialize(serialized_bytes.data(), serialized_bytes.size()); EXPECT_EQ(a, b); // remove 10 elements, the sketch has 10 remaining elements for (int i = 0; i < 10; i++) { b.remove(i); } EXPECT_EQ(b.get_estimate(), 10); } TEST(ThetaSketchDup, TestSerializeUnderterminedCaseUnderEstimation) { // @a: theta sketch with storage set to be [2^10, 2^10*threshold) // @b: theta sketch deserialized from serialized a // this test data stream has 10000 distinct elements, which exceeds the // storage size, so the cardinality is estimated instead of exact auto a = update_theta_sketch_dup::builder().set_lg_k(10).build(); for (int i = 0; i < 10000; i++) a.update(i); // serialize using proto // a and b should be the same before/after the serialization datasketches_pb::ThetaSketchDup serialized_proto; a.serialize(&serialized_proto); auto b = update_theta_sketch_dup::deserialize(serialized_proto); EXPECT_EQ(a, b); for (int i = 5000; i < 20000; i++) a.update(i); for (int i = 5000; i < 20000; i++) b.update(i); EXPECT_EQ(a, b); // serialize using bytes // a and b should be the same before/after the serialization auto serialized_bytes = a.serialize(); b = update_theta_sketch_dup::deserialize(serialized_bytes.data(), serialized_bytes.size()); EXPECT_EQ(a, b); } TEST(ThetaSketchDup, TestStringStream) { // @a: theta sketch with storage set to be [2^15 2^15*threshold) // @gen: random string generator // input data stream are random strings with random length auto a = update_theta_sketch_dup::builder().set_lg_k(15).build(); GenString gen; for (int i = 0; i < 1000000; i++) a.update(gen.next()); // expect the estimation near exact value with 2% accuarcy EXPECT_NEAR(a.get_estimate(), 1000000, 20000); } TEST(ThetaSketchDup, TestGaussianInput) { // @a: theta sketch with storage set to be [2^15, 2^15*threshold) // @stddev: standard deviation of the gaussian dist // @gen: random number generator // @d: normal distribution with standard deviation stddev // @current_distinct_elements: // input data stream are random strings with random length int stddev = 1000000; auto a = update_theta_sketch_dup::builder().set_lg_k(15).build(); std::random_device rd{}; std::mt19937 gen{rd()}; std::normal_distribution<> d{0, static_cast<double>(stddev)}; std::set<int> current_distinct_elements; while (current_distinct_elements.size() < 100000) { int x = std::round(d(gen)); a.update(x); current_distinct_elements.insert(x); } // expect the estimation near exact value with 2% accuarcy EXPECT_NEAR(a.get_estimate(), current_distinct_elements.size(), 2000); } } // namespace datasketches
37.81
80
0.700608
googleinterns
d2e3e7d318a6cb5b7b7f768f2c37986834e176c9
42,106
cc
C++
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
#include "input_handler.hh" #include "window.hh" #include "utf8.hh" #include "user_interface.hh" #include "buffer_manager.hh" #include "register_manager.hh" #include "normal.hh" #include "event_manager.hh" #include "client.hh" #include "color_registry.hh" #include "file.hh" #include "word_db.hh" #include <unordered_map> namespace Kakoune { class InputMode { public: InputMode(InputHandler& input_handler) : m_input_handler(input_handler) {} virtual ~InputMode() {} InputMode(const InputMode&) = delete; InputMode& operator=(const InputMode&) = delete; virtual void on_key(Key key) = 0; virtual void on_replaced() {} Context& context() const { return m_input_handler.context(); } virtual String description() const = 0; virtual KeymapMode keymap_mode() const = 0; using Insertion = InputHandler::Insertion; Insertion& last_insert() { return m_input_handler.m_last_insert; } protected: void reset_normal_mode(); private: InputHandler& m_input_handler; }; namespace InputModes { static constexpr std::chrono::milliseconds idle_timeout{100}; static constexpr std::chrono::milliseconds fs_check_timeout{500}; class Normal : public InputMode { public: Normal(InputHandler& input_handler) : InputMode(input_handler), m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { context().hooks().run_hook("NormalIdle", "", context()); }}, m_fs_check_timer{Clock::now() + fs_check_timeout, [this](Timer& timer) { if (not context().has_client()) return; context().client().check_buffer_fs_timestamp(); timer.set_next_date(Clock::now() + fs_check_timeout); }} { context().hooks().run_hook("NormalBegin", "", context()); } void on_replaced() override { context().hooks().run_hook("NormalEnd", "", context()); } void on_key(Key key) override { if (key.modifiers == Key::Modifiers::None and isdigit(key.key)) m_count = m_count * 10 + key.key - '0'; else { auto it = keymap.find(key); if (it != keymap.end()) it->second(context(), m_count); m_count = 0; } context().hooks().run_hook("NormalKey", key_to_str(key), context()); m_idle_timer.set_next_date(Clock::now() + idle_timeout); } String description() const override { return to_string(context().selections().size()) + (m_count != 0 ? " sel; param=" + to_string(m_count) : " sel"); } KeymapMode keymap_mode() const override { return KeymapMode::Normal; } private: int m_count = 0; Timer m_idle_timer; Timer m_fs_check_timer; }; class LineEditor { public: void handle_key(Key key) { if (key == Key::Left or key == ctrl('b')) { if (m_cursor_pos > 0) --m_cursor_pos; } else if (key == Key::Right or key == ctrl('f')) { if (m_cursor_pos < m_line.char_length()) ++m_cursor_pos; } else if (key == Key::Home) m_cursor_pos = 0; else if (key == Key::End) m_cursor_pos = m_line.char_length(); else if (key == Key::Backspace) { if (m_cursor_pos != 0) { m_line = m_line.substr(0, m_cursor_pos - 1) + m_line.substr(m_cursor_pos); --m_cursor_pos; } } else if (key == Key::Erase) { if (m_cursor_pos != m_line.char_length()) m_line = m_line.substr(0, m_cursor_pos) + m_line.substr(m_cursor_pos+1); } else { m_line = m_line.substr(0, m_cursor_pos) + codepoint_to_str(key.key) + m_line.substr(m_cursor_pos); ++m_cursor_pos; } } void insert(const String& str) { insert_from(m_cursor_pos, str); } void insert_from(CharCount start, const String& str) { kak_assert(start <= m_cursor_pos); m_line = m_line.substr(0, start) + str + m_line.substr(m_cursor_pos); m_cursor_pos = start + str.char_length(); } void reset(String line) { m_line = std::move(line); m_cursor_pos = m_line.char_length(); } const String& line() const { return m_line; } CharCount cursor_pos() const { return m_cursor_pos; } DisplayLine build_display_line() const { kak_assert(m_cursor_pos <= m_line.char_length()); if (m_cursor_pos == m_line.char_length()) return DisplayLine{{ {m_line, get_color("StatusLine")}, {" "_str, get_color("StatusCursor")} }}; else return DisplayLine({ { m_line.substr(0, m_cursor_pos), get_color("StatusLine") }, { m_line.substr(m_cursor_pos, 1), get_color("StatusCursor") }, { m_line.substr(m_cursor_pos+1), get_color("StatusLine") } }); } private: CharCount m_cursor_pos = 0; String m_line; }; class Menu : public InputMode { public: Menu(InputHandler& input_handler, memoryview<String> choices, MenuCallback callback) : InputMode(input_handler), m_callback(callback), m_choices(choices.begin(), choices.end()), m_selected(m_choices.begin()) { if (not context().has_ui()) return; DisplayCoord menu_pos{ context().ui().dimensions().line, 0_char }; context().ui().menu_show(choices, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Prompt); context().ui().menu_select(0); } void on_key(Key key) override { auto match_filter = [this](const String& str) { return boost::regex_match(str.begin(), str.end(), m_filter); }; if (key == ctrl('m')) { if (context().has_ui()) context().ui().menu_hide(); context().print_status(DisplayLine{}); reset_normal_mode(); int selected = m_selected - m_choices.begin(); m_callback(selected, MenuEvent::Validate, context()); return; } else if (key == Key::Escape or key == ctrl('c')) { if (m_edit_filter) { m_edit_filter = false; m_filter = boost::regex(".*"); m_filter_editor.reset(""); context().print_status(DisplayLine{}); } else { if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); int selected = m_selected - m_choices.begin(); m_callback(selected, MenuEvent::Abort, context()); } } else if (key == Key::Down or key == ctrl('i') or key == ctrl('n') or key == 'j') { auto it = std::find_if(m_selected+1, m_choices.end(), match_filter); if (it == m_choices.end()) it = std::find_if(m_choices.begin(), m_selected, match_filter); select(it); } else if (key == Key::Up or key == Key::BackTab or key == ctrl('p') or key == 'k') { ChoiceList::const_reverse_iterator selected(m_selected+1); auto it = std::find_if(selected+1, m_choices.rend(), match_filter); if (it == m_choices.rend()) it = std::find_if(m_choices.rbegin(), selected, match_filter); select(it.base()-1); } else if (key == '/' and not m_edit_filter) { m_edit_filter = true; } else if (m_edit_filter) { m_filter_editor.handle_key(key); auto search = ".*" + m_filter_editor.line() + ".*"; m_filter = boost::regex(search.begin(), search.end()); auto it = std::find_if(m_selected, m_choices.end(), match_filter); if (it == m_choices.end()) it = std::find_if(m_choices.begin(), m_selected, match_filter); select(it); } if (m_edit_filter) { auto display_line = m_filter_editor.build_display_line(); display_line.insert(display_line.begin(), { "filter:"_str, get_color("Prompt") }); context().print_status(display_line); } } String description() const override { return "menu"; } KeymapMode keymap_mode() const override { return KeymapMode::Menu; } private: MenuCallback m_callback; using ChoiceList = std::vector<String>; const ChoiceList m_choices; ChoiceList::const_iterator m_selected; void select(ChoiceList::const_iterator it) { m_selected = it; int selected = m_selected - m_choices.begin(); if (context().has_ui()) context().ui().menu_select(selected); m_callback(selected, MenuEvent::Select, context()); } boost::regex m_filter = boost::regex(".*"); bool m_edit_filter = false; LineEditor m_filter_editor; }; String common_prefix(memoryview<String> strings) { String res; if (strings.empty()) return res; res = strings[0]; for (auto& str : strings) { ByteCount len = std::min(res.length(), str.length()); ByteCount common_len = 0; while (common_len < len and str[common_len] == res[common_len]) ++common_len; if (common_len != res.length()) res = res.substr(0, common_len); } return res; } class Prompt : public InputMode { public: Prompt(InputHandler& input_handler, const String& prompt, ColorPair colors, Completer completer, PromptCallback callback) : InputMode(input_handler), m_prompt(prompt), m_prompt_colors(colors), m_completer(completer), m_callback(callback) { m_history_it = ms_history[m_prompt].end(); if (context().options()["autoshowcompl"].get<bool>()) refresh_completions(CompletionFlags::Fast); display(); } void on_key(Key key) override { std::vector<String>& history = ms_history[m_prompt]; const String& line = m_line_editor.line(); bool showcompl = false; if (m_mode == Mode::InsertReg) { String reg = RegisterManager::instance()[key.key].values(context())[0]; m_line_editor.insert(reg); m_mode = Mode::Default; } else if (key == ctrl('m')) // enter { if (not line.empty()) { std::vector<String>::iterator it; while ((it = find(history, line)) != history.end()) history.erase(it); history.push_back(line); } context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); // call callback after reset_normal_mode so that callback // may change the mode m_callback(line, PromptEvent::Validate, context()); return; } else if (key == Key::Escape or key == ctrl('c')) { context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); m_callback(line, PromptEvent::Abort, context()); return; } else if (key == ctrl('r')) { m_mode = Mode::InsertReg; } else if (key == Key::Up or key == ctrl('p')) { if (m_history_it != history.begin()) { if (m_history_it == history.end()) m_prefix = line; auto it = m_history_it; // search for the previous history entry matching typed prefix do { --it; if (prefix_match(*it, m_prefix)) { m_history_it = it; m_line_editor.reset(*it); break; } } while (it != history.begin()); clear_completions(); showcompl = true; } } else if (key == Key::Down or key == ctrl('n')) // next { if (m_history_it != history.end()) { // search for the next history entry matching typed prefix ++m_history_it; while (m_history_it != history.end() and prefix_match(*m_history_it, m_prefix)) ++m_history_it; if (m_history_it != history.end()) m_line_editor.reset(*m_history_it); else m_line_editor.reset(m_prefix); clear_completions(); showcompl = true; } } else if (key == ctrl('i') or key == Key::BackTab) // tab completion { const bool reverse = (key == Key::BackTab); CandidateList& candidates = m_completions.candidates; // first try, we need to ask our completer for completions if (candidates.empty()) { refresh_completions(CompletionFlags::None); if (candidates.empty()) return; } bool did_prefix = false; if (m_current_completion == -1 and context().options()["complete_prefix"].get<bool>()) { const String& line = m_line_editor.line(); CandidateList& candidates = m_completions.candidates; String prefix = common_prefix(candidates); if (m_completions.end - m_completions.start > prefix.length()) prefix = line.substr(m_completions.start, m_completions.end - m_completions.start); if (not prefix.empty()) { auto it = find(candidates, prefix); if (it == candidates.end()) { m_current_completion = candidates.size(); candidates.push_back(prefix); } else m_current_completion = it - candidates.begin(); CharCount start = line.char_count_to(m_completions.start); did_prefix = prefix != line.substr(start, m_line_editor.cursor_pos() - start); } } if (not did_prefix) { if (not reverse and ++m_current_completion >= candidates.size()) m_current_completion = 0; else if (reverse and --m_current_completion < 0) m_current_completion = candidates.size()-1; } const String& completion = candidates[m_current_completion]; if (context().has_ui()) context().ui().menu_select(m_current_completion); m_line_editor.insert_from(line.char_count_to(m_completions.start), completion); // when we have only one completion candidate, make next tab complete // from the new content. if (candidates.size() == 1) { m_current_completion = -1; candidates.clear(); showcompl = true; } } else { m_line_editor.handle_key(key); clear_completions(); showcompl = true; } if (showcompl and context().options()["autoshowcompl"].get<bool>()) refresh_completions(CompletionFlags::Fast); display(); m_callback(line, PromptEvent::Change, context()); } void set_prompt_colors(ColorPair colors) { if (colors != m_prompt_colors) { m_prompt_colors = colors; display(); } } String description() const override { return "prompt"; } KeymapMode keymap_mode() const override { return KeymapMode::Prompt; } private: void refresh_completions(CompletionFlags flags) { try { const String& line = m_line_editor.line(); m_completions = m_completer(context(), flags, line, line.byte_count_to(m_line_editor.cursor_pos())); CandidateList& candidates = m_completions.candidates; if (context().has_ui() and not candidates.empty()) { DisplayCoord menu_pos{ context().ui().dimensions().line, 0_char }; context().ui().menu_show(candidates, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Prompt); } } catch (runtime_error&) {} } void clear_completions() { m_current_completion = -1; if (context().has_ui()) context().ui().menu_hide(); } void display() const { auto display_line = m_line_editor.build_display_line(); display_line.insert(display_line.begin(), { m_prompt, m_prompt_colors }); context().print_status(display_line); } enum class Mode { Default, InsertReg }; PromptCallback m_callback; Completer m_completer; const String m_prompt; ColorPair m_prompt_colors; Completions m_completions; int m_current_completion = -1; String m_prefix; LineEditor m_line_editor; Mode m_mode = Mode::Default; static std::unordered_map<String, std::vector<String>> ms_history; std::vector<String>::iterator m_history_it; }; std::unordered_map<String, std::vector<String>> Prompt::ms_history; class NextKey : public InputMode { public: NextKey(InputHandler& input_handler, KeyCallback callback) : InputMode(input_handler), m_callback(callback) {} void on_key(Key key) override { reset_normal_mode(); m_callback(key, context()); } String description() const override { return "enter key"; } KeymapMode keymap_mode() const override { return KeymapMode::None; } private: KeyCallback m_callback; }; struct BufferCompletion { BufferCoord begin; BufferCoord end; CandidateList candidates; size_t timestamp; bool is_valid() const { return not candidates.empty(); } }; class BufferCompleter : public OptionManagerWatcher_AutoRegister { public: BufferCompleter(const Context& context) : OptionManagerWatcher_AutoRegister(context.options()), m_context(context) {} BufferCompleter(const BufferCompleter&) = delete; BufferCompleter& operator=(const BufferCompleter&) = delete; void select(int offset) { if (not setup_ifn()) return; auto& buffer = m_context.buffer(); m_current_candidate = (m_current_candidate + offset) % (int)m_matching_candidates.size(); if (m_current_candidate < 0) m_current_candidate += m_matching_candidates.size(); const String& candidate = m_matching_candidates[m_current_candidate]; const auto& cursor_pos = m_context.selections().main().cursor(); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); const auto suffix_len = std::max(0_byte, buffer.distance(cursor_pos, m_completions.end)); const auto buffer_len = buffer.byte_count(); auto ref = buffer.string(m_completions.begin, m_completions.end); for (auto& sel : m_context.selections()) { auto offset = buffer.offset(sel.cursor()); auto pos = buffer.iterator_at(sel.cursor()); if (offset >= prefix_len and offset + suffix_len < buffer_len and std::equal(ref.begin(), ref.end(), pos - prefix_len)) { pos = buffer.erase(pos - prefix_len, pos + suffix_len); buffer.insert(pos, candidate); } } m_completions.end = cursor_pos; m_completions.begin = buffer.advance(m_completions.end, -candidate.length()); m_completions.timestamp = m_context.buffer().timestamp(); if (m_context.has_ui()) m_context.ui().menu_select(m_current_candidate); // when we select a match, remove non displayed matches from the candidates // which are considered as invalid with the new completion timestamp m_completions.candidates.clear(); std::copy(m_matching_candidates.begin(), m_matching_candidates.end()-1, std::back_inserter(m_completions.candidates)); } void update() { if (m_completions.is_valid()) { ByteCount longest_completion = 0; for (auto& candidate : m_completions.candidates) longest_completion = std::max(longest_completion, candidate.length()); BufferCoord cursor = m_context.selections().main().cursor(); BufferCoord compl_beg = m_completions.begin; if (cursor.line == compl_beg.line and is_in_range(cursor.column - compl_beg.column, ByteCount{0}, longest_completion-1)) { String prefix = m_context.buffer().string(compl_beg, cursor); if (m_context.buffer().timestamp() == m_completions.timestamp) m_matching_candidates = m_completions.candidates; else { m_matching_candidates.clear(); for (auto& candidate : m_completions.candidates) { if (candidate.substr(0, prefix.length()) == prefix) m_matching_candidates.push_back(candidate); } } if (not m_matching_candidates.empty()) { m_current_candidate = m_matching_candidates.size(); m_completions.end = cursor; menu_show(); m_matching_candidates.push_back(prefix); return; } } } reset(); setup_ifn(); } void reset() { m_completions = BufferCompletion{}; if (m_context.has_ui()) m_context.ui().menu_hide(); } template<BufferCompletion (BufferCompleter::*complete_func)(const Buffer&, BufferCoord)> bool try_complete() { auto& buffer = m_context.buffer(); BufferCoord cursor_pos = m_context.selections().main().cursor(); m_completions = (this->*complete_func)(buffer, cursor_pos); if (not m_completions.is_valid()) return false; kak_assert(cursor_pos >= m_completions.begin); m_matching_candidates = m_completions.candidates; m_current_candidate = m_matching_candidates.size(); menu_show(); m_matching_candidates.push_back(buffer.string(m_completions.begin, m_completions.end)); return true; } using StringList = std::vector<String>; static WordDB& get_word_db(const Buffer& buffer) { static const ValueId word_db_id = ValueId::get_free_id(); Value& cache_val = buffer.values()[word_db_id]; if (not cache_val) cache_val = Value(WordDB{buffer}); return cache_val.as<WordDB>(); } template<bool other_buffers> BufferCompletion complete_word(const Buffer& buffer, BufferCoord cursor_pos) { auto pos = buffer.iterator_at(cursor_pos); if (pos == buffer.begin() or not is_word(*utf8::previous(pos))) return {}; auto end = buffer.iterator_at(cursor_pos); auto begin = end-1; while (begin != buffer.begin() and is_word(*begin)) --begin; if (not is_word(*begin)) ++begin; String prefix{begin, end}; std::unordered_set<String> matches; auto bufmatches = get_word_db(buffer).find_prefix(prefix); matches.insert(bufmatches.begin(), bufmatches.end()); if (other_buffers) { for (const auto& buf : BufferManager::instance()) { if (buf.get() == &buffer) continue; bufmatches = get_word_db(*buf).find_prefix(prefix); matches.insert(bufmatches.begin(), bufmatches.end()); } } matches.erase(prefix); CandidateList result; std::copy(make_move_iterator(matches.begin()), make_move_iterator(matches.end()), inserter(result, result.begin())); std::sort(result.begin(), result.end()); return { begin.coord(), end.coord(), std::move(result), buffer.timestamp() }; } BufferCompletion complete_filename(const Buffer& buffer, BufferCoord cursor_pos) { auto pos = buffer.iterator_at(cursor_pos); auto begin = pos; auto is_filename = [](char c) { return isalnum(c) or c == '/' or c == '.' or c == '_' or c == '-'; }; while (begin != buffer.begin() and is_filename(*(begin-1))) --begin; if (begin == pos) return {}; String prefix{begin, pos}; StringList res; if (prefix.front() == '/') res = Kakoune::complete_filename(prefix, Regex{}); else { for (auto dir : options()["path"].get<StringList>()) { if (not dir.empty() and dir.back() != '/') dir += '/'; for (auto& filename : Kakoune::complete_filename(dir + prefix, Regex{})) res.push_back(filename.substr(dir.length())); } } if (res.empty()) return {}; return { begin.coord(), pos.coord(), std::move(res), buffer.timestamp() }; } BufferCompletion complete_option(const Buffer& buffer, BufferCoord cursor_pos) { const StringList& opt = options()["completions"].get<StringList>(); if (opt.empty()) return {}; auto& desc = opt[0]; static const Regex re(R"((\d+)\.(\d+)(?:\+(\d+))?@(\d+))"); boost::smatch match; if (boost::regex_match(desc.begin(), desc.end(), match, re)) { BufferCoord coord{ str_to_int(match[1].str()) - 1, str_to_int(match[2].str()) - 1 }; if (not buffer.is_valid(coord)) return {}; auto end = coord; if (match[3].matched) { ByteCount len = str_to_int(match[3].str()); end = buffer.advance(coord, len); } size_t timestamp = (size_t)str_to_int(match[4].str()); ByteCount longest_completion = 0; for (auto it = opt.begin() + 1; it != opt.end(); ++it) longest_completion = std::max(longest_completion, it->length()); if (timestamp == buffer.timestamp() and cursor_pos.line == coord.line and cursor_pos.column >= coord.column and buffer.distance(coord, cursor_pos) < longest_completion) return { coord, end, { opt.begin() + 1, opt.end() }, timestamp }; } return {}; } BufferCompletion complete_line(const Buffer& buffer, BufferCoord cursor_pos) { String prefix = buffer[cursor_pos.line].substr(0_byte, cursor_pos.column); StringList res; for (LineCount l = 0_line; l < buffer.line_count(); ++l) { if (l == cursor_pos.line) continue; ByteCount len = buffer[l].length(); if (len > cursor_pos.column and std::equal(prefix.begin(), prefix.end(), buffer[l].begin())) res.push_back(buffer[l].substr(0_byte, len-1)); } if (res.empty()) return {}; std::sort(res.begin(), res.end()); res.erase(std::unique(res.begin(), res.end()), res.end()); return { cursor_pos.line, cursor_pos, std::move(res), buffer.timestamp() }; } private: void on_option_changed(const Option& opt) override { if (opt.name() == "completions") { reset(); setup_ifn(); } } void menu_show() { if (not m_context.has_ui()) return; DisplayCoord menu_pos = m_context.window().display_position(m_completions.begin); m_context.ui().menu_show(m_matching_candidates, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Inline); m_context.ui().menu_select(m_current_candidate); } bool setup_ifn() { if (not m_completions.is_valid()) { auto& completers = options()["completers"].get<StringList>(); if (contains(completers, "option") and try_complete<&BufferCompleter::complete_option>()) return true; if (contains(completers, "word=buffer") and try_complete<&BufferCompleter::complete_word<false>>()) return true; if (contains(completers, "word=all") and try_complete<&BufferCompleter::complete_word<true>>()) return true; if (contains(completers, "filename") and try_complete<&BufferCompleter::complete_filename>()) return true; return false; } return true; } const Context& m_context; BufferCompletion m_completions; CandidateList m_matching_candidates; int m_current_candidate = -1; }; class Insert : public InputMode { public: Insert(InputHandler& input_handler, InsertMode mode) : InputMode(input_handler), m_insert_mode(mode), m_edition(context()), m_completer(context()), m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { context().hooks().run_hook("InsertIdle", "", context()); m_completer.update(); }} { last_insert().first = mode; last_insert().second.clear(); context().hooks().run_hook("InsertBegin", "", context()); prepare(m_insert_mode); } void on_key(Key key) override { auto& buffer = context().buffer(); last_insert().second.push_back(key); if (m_mode == Mode::InsertReg) { if (key.modifiers == Key::Modifiers::None) insert(RegisterManager::instance()[key.key].values(context())); m_mode = Mode::Default; return; } if (m_mode == Mode::Complete) { if (key.key == 'f') m_completer.try_complete<&BufferCompleter::complete_filename>(); if (key.key == 'w') m_completer.try_complete<&BufferCompleter::complete_word<true>>(); if (key.key == 'o') m_completer.try_complete<&BufferCompleter::complete_option>(); if (key.key == 'l') m_completer.try_complete<&BufferCompleter::complete_line>(); m_mode = Mode::Default; return; } bool update_completions = true; bool moved = false; if (key == Key::Escape or key == ctrl('c')) { context().hooks().run_hook("InsertEnd", "", context()); m_completer.reset(); reset_normal_mode(); } else if (key == Key::Backspace) { for (auto& sel : context().selections()) { if (sel.cursor() == BufferCoord{0,0}) continue; auto pos = buffer.iterator_at(sel.cursor()); buffer.erase(utf8::previous(pos), pos); } } else if (key == Key::Erase) { for (auto& sel : context().selections()) { auto pos = buffer.iterator_at(sel.cursor()); buffer.erase(pos, utf8::next(pos)); } } else if (key == Key::Left) { move(-1_char); moved = true; } else if (key == Key::Right) { move(1_char); moved = true; } else if (key == Key::Up) { move(-1_line); moved = true; } else if (key == Key::Down) { move(1_line); moved = true; } else if (key.modifiers == Key::Modifiers::None) insert(key.key); else if (key == ctrl('r')) m_mode = Mode::InsertReg; else if ( key == ctrl('m')) insert('\n'); else if ( key == ctrl('i')) insert('\t'); else if ( key == ctrl('n')) { m_completer.select(1); update_completions = false; } else if ( key == ctrl('p')) { m_completer.select(-1); update_completions = false; } else if ( key == ctrl('x')) m_mode = Mode::Complete; else if ( key == ctrl('u')) context().buffer().commit_undo_group(); context().hooks().run_hook("InsertKey", key_to_str(key), context()); if (update_completions) m_idle_timer.set_next_date(Clock::now() + idle_timeout); if (moved) context().hooks().run_hook("InsertMove", key_to_str(key), context()); } String description() const override { return "insert"; } KeymapMode keymap_mode() const override { return KeymapMode::Insert; } private: template<typename Type> void move(Type offset) { auto& selections = context().selections(); for (auto& sel : selections) { auto cursor = context().has_window() ? context().window().offset_coord(sel.cursor(), offset) : context().buffer().offset_coord(sel.cursor(), offset); sel.anchor() = sel.cursor() = cursor; } selections.sort_and_merge_overlapping(); } void insert(memoryview<String> strings) { auto& buffer = context().buffer(); auto& selections = context().selections(); for (size_t i = 0; i < selections.size(); ++i) { size_t index = std::min(i, strings.size()-1); buffer.insert(buffer.iterator_at(selections[i].cursor()), strings[index]); } } void insert(Codepoint key) { auto str = codepoint_to_str(key); auto& buffer = context().buffer(); for (auto& sel : context().selections()) buffer.insert(buffer.iterator_at(sel.cursor()), str); context().hooks().run_hook("InsertChar", str, context()); } void prepare(InsertMode mode) { SelectionList& selections = context().selections(); Buffer& buffer = context().buffer(); for (auto& sel : selections) { BufferCoord anchor, cursor; switch (mode) { case InsertMode::Insert: anchor = sel.max(); cursor = sel.min(); break; case InsertMode::Replace: anchor = cursor = Kakoune::erase(buffer, sel).coord(); break; case InsertMode::Append: anchor = sel.min(); cursor = sel.max(); // special case for end of lines, append to current line instead if (cursor.column != buffer[cursor.line].length() - 1) cursor = buffer.char_next(cursor); break; case InsertMode::OpenLineBelow: case InsertMode::AppendAtLineEnd: anchor = cursor = BufferCoord{sel.max().line, buffer[sel.max().line].length() - 1}; break; case InsertMode::OpenLineAbove: case InsertMode::InsertAtLineBegin: anchor = sel.min().line; if (mode == InsertMode::OpenLineAbove) anchor = buffer.char_prev(anchor); else { auto anchor_non_blank = buffer.iterator_at(anchor); while (*anchor_non_blank == ' ' or *anchor_non_blank == '\t') ++anchor_non_blank; if (*anchor_non_blank != '\n') anchor = anchor_non_blank.coord(); } cursor = anchor; break; case InsertMode::InsertAtNextLineBegin: kak_assert(false); // not implemented break; } if (buffer.is_end(anchor)) anchor = buffer.char_prev(anchor); if (buffer.is_end(cursor)) cursor = buffer.char_prev(cursor); sel.anchor() = anchor; sel.cursor() = cursor; } if (mode == InsertMode::OpenLineBelow or mode == InsertMode::OpenLineAbove) { insert('\n'); if (mode == InsertMode::OpenLineAbove) { for (auto& sel : selections) { // special case, the --first line above did nothing, so we need to compensate now if (sel.anchor() == buffer.char_next({0,0})) sel.anchor() = sel.cursor() = BufferCoord{0,0}; } } } selections.sort_and_merge_overlapping(); selections.check_invariant(); buffer.check_invariant(); } void on_replaced() override { for (auto& sel : context().selections()) { if (m_insert_mode == InsertMode::Append and sel.cursor().column > 0) sel.cursor() = context().buffer().char_prev(sel.cursor()); avoid_eol(context().buffer(), sel); } } enum class Mode { Default, Complete, InsertReg }; Mode m_mode = Mode::Default; InsertMode m_insert_mode; ScopedEdition m_edition; BufferCompleter m_completer; Timer m_idle_timer; }; } void InputMode::reset_normal_mode() { m_input_handler.reset_normal_mode(); } InputHandler::InputHandler(Buffer& buffer, SelectionList selections, String name) : m_mode(new InputModes::Normal(*this)), m_context(*this, buffer, std::move(selections), std::move(name)) { } InputHandler::~InputHandler() {} void InputHandler::change_input_mode(InputMode* new_mode) { m_mode->on_replaced(); m_mode_trash.emplace_back(std::move(m_mode)); m_mode.reset(new_mode); } void InputHandler::insert(InsertMode mode) { change_input_mode(new InputModes::Insert(*this, mode)); } void InputHandler::repeat_last_insert() { if (m_last_insert.second.empty()) return; std::vector<Key> keys; swap(keys, m_last_insert.second); // context.last_insert will be refilled by the new Insert // this is very inefficient. change_input_mode(new InputModes::Insert(*this, m_last_insert.first)); for (auto& key : keys) m_mode->on_key(key); kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr); } void InputHandler::prompt(const String& prompt, ColorPair prompt_colors, Completer completer, PromptCallback callback) { change_input_mode(new InputModes::Prompt(*this, prompt, prompt_colors, completer, callback)); } void InputHandler::set_prompt_colors(ColorPair prompt_colors) { InputModes::Prompt* prompt = dynamic_cast<InputModes::Prompt*>(m_mode.get()); if (prompt) prompt->set_prompt_colors(prompt_colors); } void InputHandler::menu(memoryview<String> choices, MenuCallback callback) { change_input_mode(new InputModes::Menu(*this, choices, callback)); } void InputHandler::on_next_key(KeyCallback callback) { change_input_mode(new InputModes::NextKey(*this, callback)); } static bool is_valid(Key key) { return key != Key::Invalid and key.key <= 0x10FFFF; } void InputHandler::handle_key(Key key) { if (is_valid(key)) { const bool was_recording = is_recording(); auto keymap_mode = m_mode->keymap_mode(); KeymapManager& keymaps = m_context.keymaps(); if (keymaps.is_mapped(key, keymap_mode)) { for (auto& k : keymaps.get_mapping(key, keymap_mode)) m_mode->on_key(k); } else m_mode->on_key(key); // do not record the key that made us enter or leave recording mode. if (was_recording and is_recording()) m_recorded_keys += key_to_str(key); } } void InputHandler::start_recording(char reg) { kak_assert(m_recording_reg == 0); m_recorded_keys = ""; m_recording_reg = reg; } bool InputHandler::is_recording() const { return m_recording_reg != 0; } void InputHandler::stop_recording() { kak_assert(m_recording_reg != 0); RegisterManager::instance()[m_recording_reg] = memoryview<String>(m_recorded_keys); m_recording_reg = 0; } void InputHandler::reset_normal_mode() { change_input_mode(new InputModes::Normal(*this)); } String InputHandler::mode_string() const { return m_mode->description(); } void InputHandler::clear_mode_trash() { m_mode_trash.clear(); } }
32.895313
111
0.546074
nojhan
d2e3f3c448b905106cf36ebf622423c87f35ffef
1,044
hpp
C++
fold.hpp
wo3kie/cxxDojo
c63388eb37a62272bfb9ca5c0b207fc5387a29ad
[ "MIT" ]
2
2015-10-26T22:06:11.000Z
2015-11-25T14:35:00.000Z
fold.hpp
wo3kie/dojo
c63388eb37a62272bfb9ca5c0b207fc5387a29ad
[ "MIT" ]
null
null
null
fold.hpp
wo3kie/dojo
c63388eb37a62272bfb9ca5c0b207fc5387a29ad
[ "MIT" ]
null
null
null
/* * Website: * https://github.com/wo3kie/dojo * /* * Website: * https://github.com/wo3kie/dojo * * Author: * Lukasz Czerwinski */ #ifndef __CXX_DOJO_FOLD_HPP__ #define __CXX_DOJO_FOLD_HPP__ #include <functional> #include <iostream> /* * rfold(f, a, b, c, d) == f(a, f(b, f(c, d))) */ template<typename R, typename T> R rfold(std::function<R (T, T)> f, T t1, T t2){ return f(std::forward<T>(t1), std::forward<T>(t2)); } template<typename R, typename T, typename ... Ts> R rfold(std::function<R (T, T)> f, T t, Ts ... tail){ return f(std::forward<T>(t), rfold(f, std::forward<Ts>(tail)...)); } /* * lfold(f, a, b, c, d) == f( f( f(a, b), c), d) */ template<typename R, typename T> R lfold(std::function<R (T, T)> f, T t1, T t2){ return f(std::forward<T>(t1), std::forward<T>(t2)); } template<typename R, typename T, typename ... Ts> R lfold(std::function<R (T, T)> f, T t1, T t2, Ts ... tail){ return lfold(f, f(std::forward<T>(t1), std::forward<T>(t2)), std::forward<Ts>(tail)...); } #endif
21.75
92
0.585249
wo3kie
d2e4418179bc5c59c361a7ddae44a46f32e42af6
3,322
cpp
C++
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
#include "sly/win32/os/window.h" using namespace sly::os; Win32Window::Win32Window(Win32WindowSystem& parent) : _parent(parent), _initialized(false) { } sly::retval<void> Win32Window::release() { if(_initialized) { setVisible(false); DestroyWindow(_hWND); _hWND = nullptr; _parent.release(*this); _initialized = false; } return success(); } sly::retval<void> Win32Window::init(const WindowDesc& desc) { _width = desc.width; _height = desc.height; _title = desc.title; HINSTANCE hInstance= GetModuleHandle(NULL); // Initialize the window class. WNDCLASSEX windowClass = { 0 }; windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WindowProc; windowClass.hInstance = hInstance; windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); windowClass.lpszClassName = "Win32Window"; RegisterClassEx(&windowClass); ::RECT windowRect = { 0, 0, static_cast<LONG>(_width), static_cast<LONG>(_height) }; AdjustWindowRect(&windowRect, WS_OVERLAPPED, FALSE); /* _In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam); */ // Create the window and store a handle to it. this->setHwnd(CreateWindowEx( WS_EX_TRANSPARENT, windowClass.lpszClassName, getTitle().c_str(), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, nullptr, // We have no parent window. nullptr, // We aren't using menus. hInstance, this)); //ShowWindow(_hWND, SW_SHOWDEFAULT); _initialized = true; return success(); } bool_t Win32Window::processMessages() { MSG msg = {}; bool_t process = true; while (process) { process = false; // Process any messages in the queue. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); process = true; } } // Return this part of the WM_QUIT message to Windows. return static_cast<char>(msg.wParam); } // Main message handler for the sample. LRESULT CALLBACK Win32Window::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { Win32Window* pSample = reinterpret_cast<Win32Window*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch (message) { case WM_CREATE: { // Save the DXSample* passed in to CreateWindow. LPCREATESTRUCT pCreateStruct = reinterpret_cast<LPCREATESTRUCT>(lParam); SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pCreateStruct->lpCreateParams)); } return 0; case WM_PAINT: { ValidateRect(hWnd, NULL); } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } // Handle any messages the switch statement didn't. return DefWindowProc(hWnd, message, wParam, lParam); }
26.365079
109
0.643287
Gibbeon
5e4333c9a9bcd2c090290f1d14474bed5986266c
1,149
hpp
C++
example/generated-src/cwrapper/cw__textbox_listener.hpp
trafi/trafi-djinni
47cd2c849782e2ab4b38e5dc6a5a3104cc87f673
[ "Apache-2.0" ]
null
null
null
example/generated-src/cwrapper/cw__textbox_listener.hpp
trafi/trafi-djinni
47cd2c849782e2ab4b38e5dc6a5a3104cc87f673
[ "Apache-2.0" ]
null
null
null
example/generated-src/cwrapper/cw__textbox_listener.hpp
trafi/trafi-djinni
47cd2c849782e2ab4b38e5dc6a5a3104cc87f673
[ "Apache-2.0" ]
null
null
null
// AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni from example.djinni #pragma once #include <atomic> #include <experimental/optional> #include "textbox_listener.hpp" #ifdef __cplusplus extern "C" { #endif #include "cw__textbox_listener.h" #ifdef __cplusplus } #endif struct DjinniWrapperTextboxListener final { DjinniWrapperTextboxListener(std::shared_ptr<::textsort::TextboxListener>wo): wrapped_obj(wo) {}; static std::shared_ptr<::textsort::TextboxListener> get(djinni::Handle<DjinniWrapperTextboxListener> dw); static djinni::Handle<DjinniWrapperTextboxListener> wrap(std::shared_ptr<::textsort::TextboxListener> obj); const std::shared_ptr<::textsort::TextboxListener> wrapped_obj; std::atomic<size_t> ref_count {1}; }; class TextboxListenerPythonProxy final : public ::textsort::TextboxListener { public: explicit TextboxListenerPythonProxy(DjinniObjectHandle * c_ptr); ~TextboxListenerPythonProxy(); DjinniObjectHandle * get_m_py_obj_handle(); void update(const ::textsort::ItemList & items); private: DjinniObjectHandle * m_py_obj_handle; };
29.461538
111
0.749347
trafi
5e44a3b5dc5626758232f2c869ca651829479a98
2,339
hpp
C++
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
#include <fstream> #include <string.h> /********************************************************************* ** Program Filename: fileWrite ** Author: Mason Sidebottom ** Date: Feb. 2019 ** Description: Helper functionality for binary file IO *********************************************************************/ class fileWriter { private: std::ofstream file; public: /********************************************************************* ** Function: Constructor ** Description: Sets up writer class ** Parameters: String -> File name ** Pre-Conditions: N/A ** Post-Conditions: osfstream is initialized to be used in output mode, ** with binary output. *********************************************************************/ fileWriter (const char * filename) : file(filename, std::ofstream::out | std::ofstream::binary){} /********************************************************************* ** Function: Destructor ** Description: Closes file ** Pre-Conditions: File is open ** Post-Conditions: File will be closed *********************************************************************/ ~fileWriter () { this->file.close(); } /********************************************************************* ** Function: Write ** Description: Writes a file using binary data, instead of string ** representation. ** Pre-Conditions: File is open *********************************************************************/ template <typename T> void write(const T val){ // Create byte array of with as many bytes in type unsigned char * str = new unsigned char [sizeof(T)]; // Copy contents of memory memcpy(str, &val, sizeof(T)); // Write individual bytes so that all zeros are written for(int i = 0; i < sizeof(T); i++) this->file << str[i]; // Free byte array delete [] str; } /********************************************************************* ** Function: Overloaded stream operator ** Description: Calls write, see above ** Returns: fileWrite &, allows for fW << a < b << c << ... *********************************************************************/ template <typename T> friend fileWriter& operator<<(fileWriter & writer, const T val){ writer.write(val); return writer; } };
33.898551
99
0.446345
franzmk
5e45349a9480f07bc6f22d8abf2101dcea77be4a
2,492
cpp
C++
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
37
2020-01-20T06:21:24.000Z
2022-03-21T17:44:50.000Z
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
null
null
null
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
9
2019-03-22T00:33:07.000Z
2022-03-01T01:35:59.000Z
#include <eepp/audio/soundfilereadermp3.hpp> #define DR_MP3_IMPLEMENTATION #include <algorithm> #include <cctype> #include <dr_libs/dr_mp3.h> #include <eepp/audio/mp3info.hpp> #include <eepp/core/core.hpp> #include <eepp/system/iostreammemory.hpp> static size_t drmp3_func_read( void* data, void* ptr, size_t size ) { IOStream* stream = static_cast<IOStream*>( data ); return static_cast<std::size_t>( stream->read( (char*)ptr, size ) ); } static drmp3_bool32 drmp3_func_seek( void* data, int offset, drmp3_seek_origin whence ) { IOStream* stream = static_cast<IOStream*>( data ); switch ( whence ) { case drmp3_seek_origin_start: break; case drmp3_seek_origin_current: offset += stream->tell(); break; } stream->seek( offset ); return 1; } namespace EE { namespace Audio { namespace Private { bool SoundFileReaderMp3::check( IOStream& stream ) { return Mp3Info( stream ).isValidMp3(); } SoundFileReaderMp3::SoundFileReaderMp3() : mChannelCount( 0 ), mMp3( NULL ) {} SoundFileReaderMp3::~SoundFileReaderMp3() { close(); } bool SoundFileReaderMp3::open( IOStream& stream, Info& info ) { mMp3 = (drmp3*)eeMalloc( sizeof( drmp3 ) ); // This could be solved with drmp3_get_mp3_frame_count, but our implementation is faster. Mp3Info::Info mp3info = Mp3Info( stream ).getInfo(); stream.seek( 0 ); if ( drmp3_init( mMp3, drmp3_func_read, drmp3_func_seek, &stream, NULL ) ) { info.channelCount = mChannelCount = mMp3->channels; info.sampleRate = mMp3->sampleRate; info.sampleCount = mp3info.frames * DRMP3_MAX_SAMPLES_PER_FRAME; return true; } eeSAFE_FREE( mMp3 ); return false; } void SoundFileReaderMp3::seek( Uint64 sampleOffset ) { if ( mMp3 ) { drmp3_seek_to_pcm_frame( mMp3, sampleOffset / mChannelCount ); } } Uint64 SoundFileReaderMp3::read( Int16* samples, Uint64 maxCount ) { eeASSERT( mMp3 ); Uint64 count = 0; while ( count < maxCount ) { const int samplesToRead = static_cast<int>( maxCount - count ); int frames = samplesToRead / mChannelCount; long framesRead = drmp3_read_pcm_frames_s16( mMp3, frames, samples ); if ( framesRead > 0 ) { long samplesRead = framesRead * mChannelCount; count += samplesRead; samples += samplesRead; if ( framesRead != frames ) break; } else { // error or end of file break; } } return count; } void SoundFileReaderMp3::close() { if ( mMp3 ) { drmp3_uninit( mMp3 ); eeSAFE_FREE( mMp3 ); mChannelCount = 0; } } }}} // namespace EE::Audio::Private
25.171717
90
0.708668
jayrulez
5e493106bfcc6ba8979dc00ba487f5ef7f8fb672
8,009
cpp
C++
src/rl_connection.cpp
ShenDezhou/sogou-qdb-redis
bef543811765dda132552a3fa65cfe31c871a17f
[ "MIT" ]
null
null
null
src/rl_connection.cpp
ShenDezhou/sogou-qdb-redis
bef543811765dda132552a3fa65cfe31c871a17f
[ "MIT" ]
null
null
null
src/rl_connection.cpp
ShenDezhou/sogou-qdb-redis
bef543811765dda132552a3fa65cfe31c871a17f
[ "MIT" ]
null
null
null
/*-*- c++ -*- * * rl_connection.cpp * author : KDr2 * */ #include <algorithm> #include <stdio.h> #include <string.h> #include <errno.h> #include <assert.h> #include <unistd.h> #include <sys/socket.h> #include "rl_util.h" #include "rl_server.h" #include "rl_connection.h" #include "rl_request.h" #define CHECK_BUFFER(N) do{ \ if(next_idx+(N)>(read_buffer+buffered_data)){ \ next_idx=old_ni; \ memmove(read_buffer,next_idx,buffered_data-(next_idx-read_buffer)); \ buffered_data-=(next_idx-read_buffer);next_idx=read_buffer; \ read_buffer[buffered_data]=0; \ return 0;}}while(0) #define START_WRITER() do{if(!writer_started){writer_started=true;ev_io_start(server->loop, &write_watcher);}}while(0) RLConnection::RLConnection(RLServer *s, int fd): db_index(0), fd(fd), server(s), buffered_data(0),writer_started(false) { next_idx = read_buffer; ev_init(&read_watcher, RLConnection::on_readable); read_watcher.data = this; ev_init(&write_watcher, RLConnection::on_writable); write_watcher.data = this; timeout_watcher.data = this; set_nonblock(fd); open=true; current_request=NULL; transaction=NULL; server->clients_num++; //memcpy(sockaddr, &addr, addr_len); //ip = inet_ntoa(sockaddr.sin_addr); } RLConnection::~RLConnection() { if(open){ ev_io_stop(server->loop, &read_watcher); if(writer_started){ ev_io_stop(server->loop, &write_watcher); } close(fd); } server->clients_num--; } void RLConnection::start() { ev_io_set(&write_watcher, fd, EV_WRITE); ev_io_set(&read_watcher, fd, EV_READ); ev_io_start(server->loop, &read_watcher); } size_t RLConnection::get_int() { char *b = next_idx; size_t val = 0; while(*b != '\r') { val *= 10; val += (*b++ - '0'); } if(b<=(read_buffer+buffered_data-1)){ b += 2; next_idx = b; return val; } return -1; } void RLConnection::do_request(){ if(current_request && current_request->completed()){ current_request->run(); if(current_request){ delete current_request; current_request=NULL; } } } int RLConnection::do_read(){ char *old_ni=next_idx; while(next_idx<(read_buffer+buffered_data)){ old_ni=next_idx; if(!current_request)current_request=new RLRequest(this); // 1. read the arg count: if(current_request->arg_count<0){ CHECK_BUFFER(4); if(*next_idx++ != '*') return -1; current_request->arg_count=get_int(); current_request->arg_count--; old_ni=next_idx; } // 2. read the request name if(current_request->arg_count>=0 && current_request->name.empty()){ CHECK_BUFFER(4); if(*next_idx++ != '$') return -1; int len=get_int(); CHECK_BUFFER(len+2); current_request->name=std::string(next_idx,len); std::transform(current_request->name.begin(), current_request->name.end(), current_request->name.begin(), ::tolower); next_idx+=len+2; old_ni=next_idx; } // 3. read a arg if(current_request->arg_count>=0 && current_request->arg_count - current_request->args.size()>0){ CHECK_BUFFER(4); if(*next_idx++ != '$') return -1; int len=get_int(); CHECK_BUFFER(len+2); current_request->append_arg(std::string(next_idx,len)); next_idx+=len+2; old_ni=next_idx; } // 4. do the request if(current_request->arg_count>=0 && current_request->arg_count - current_request->args.size()==0){ do_request(); if(next_idx>=(read_buffer+buffered_data)){ buffered_data=0; next_idx=read_buffer; old_ni=next_idx; return 1; } } } old_ni=next_idx; CHECK_BUFFER(1); // 5. done return 1; } void RLConnection::on_readable(struct ev_loop *loop, ev_io *watcher, int revents) { RLConnection *connection = static_cast<RLConnection*>(watcher->data); size_t offset = connection->buffered_data; int left = READ_BUFFER - offset; char* recv_buffer = connection->read_buffer + offset; ssize_t recved; //assert(ev_is_active(&connection->timeout_watcher)); assert(watcher == &connection->read_watcher); // No more buffer space. if(left == 0) return; if(EV_ERROR & revents) { puts("on_readable() got error event, closing connection."); return; } recved = recv(connection->fd, recv_buffer, left, 0); if(recved == 0) { delete connection; return; } if(recved <= 0) return; recv_buffer[recved] = 0; connection->buffered_data += recved; int ret = connection->do_read(); switch(ret) { case -1: puts("bad protocol error"); // fallthrough break; case 1: connection->buffered_data = 0; break; case 0: // more data needed, leave the buffer. //TODO break; default: puts("unknown return error"); break; } /* rl_connection_reset_timeout(connection); */ return; /* error: */ /* rl_connection_schedule_close(connection); */ } int RLConnection::do_write(){ size_t nleft=write_buffer.size(); ssize_t nwritten=0; const char *ptr=write_buffer.c_str(); if ((nwritten = write(fd, ptr, nleft)) < 0) { if (nwritten < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)){ return 0; }else{ perror("Write Error Msg"); writer_started=false; ev_io_stop(server->loop, &write_watcher); return -1; } } write_buffer.erase(0,nwritten); if(write_buffer.size()<=0){ writer_started=false; ev_io_stop(server->loop, &write_watcher); } return 1; } void RLConnection::on_writable(struct ev_loop *loop, ev_io *watcher, int revents) { RLConnection *connection = static_cast<RLConnection*>(watcher->data); int ret = connection->do_write(); switch(ret) { case -1: puts("write error"); break; case 0: //unwritable break; case 1: //done break; default: puts("unknown return error"); break; } } void RLConnection::write_nil(){ write_buffer+="$-1\r\n"; START_WRITER(); } void RLConnection::write_error(const char* msg){ write_buffer+="-"; write_buffer+=std::string(msg,strlen(msg)); write_buffer+="\r\n"; START_WRITER(); } void RLConnection::write_status(const char* msg){ write_buffer+="+"; write_buffer+=std::string(msg,strlen(msg)); write_buffer+="\r\n"; START_WRITER(); } void RLConnection::write_integer(const char *out, size_t out_size){ write_buffer+=":"; write_buffer+=std::string(out,out_size); write_buffer+="\r\n"; START_WRITER(); } void RLConnection::write_bulk(const char *out, size_t out_size){ char buf[32]; int count = sprintf(buf, "%ld", out_size); write_buffer+="$"; write_buffer+=std::string(buf,count); write_buffer+="\r\n"; write_buffer+=std::string(out,out_size); write_buffer+="\r\n"; START_WRITER(); } void RLConnection::write_bulk(const std::string &out){ write_bulk(out.c_str(), out.size()); START_WRITER(); } void RLConnection::write_mbulk_header(int n){ char buf[32]; int count = sprintf(buf, "%d", n); write_buffer+="*"; write_buffer+=std::string(buf,count); write_buffer+="\r\n"; START_WRITER(); }
26.003247
118
0.578849
ShenDezhou
5e4a7ef09ef2e4b1883a4db634bd13bfd4e42291
312
cpp
C++
aql/benchmark/lib_76/class_5.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_76/class_5.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_76/class_5.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
#include "class_5.h" #include "class_6.h" #include "class_7.h" #include "class_0.h" #include "class_9.h" #include "class_3.h" #include <lib_37/class_5.h> #include <lib_15/class_3.h> #include <lib_28/class_4.h> #include <lib_46/class_6.h> #include <lib_70/class_9.h> class_5::class_5() {} class_5::~class_5() {}
20.8
27
0.714744
menify
5e4a914be837958d0a775f4615d9dc20868c646d
753
cpp
C++
Backbone/UserManager/XMLManager/XMLManager.cpp
ed-quiroga-2103/OdisseyC
cf7ec95c574bfd4b2581f9af092dae50803dcebb
[ "Apache-2.0" ]
null
null
null
Backbone/UserManager/XMLManager/XMLManager.cpp
ed-quiroga-2103/OdisseyC
cf7ec95c574bfd4b2581f9af092dae50803dcebb
[ "Apache-2.0" ]
null
null
null
Backbone/UserManager/XMLManager/XMLManager.cpp
ed-quiroga-2103/OdisseyC
cf7ec95c574bfd4b2581f9af092dae50803dcebb
[ "Apache-2.0" ]
null
null
null
// // Created by eduardo on 28/04/18. // #include <iostream> #include "XMLManager.h" XMLDoc* XMLManager::newXMLDoc(int opnum, string CDATA) { XMLDoc* doc = new XMLDoc(0); doc->newChild(opnum, CDATA); return doc; } void XMLManager::saveXML(XMLDoc doc, string name) { doc.saveXML(name); return; } string XMLManager::getCDATA(string str) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_string(str.c_str()); return doc.child("oddata").child("data").child("CData").text().get(); } int XMLManager::getOpNum(string str) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_string(str.c_str()); return std::stoi(doc.child("oddata").child("data").child("opnum").text().get()); }
24.290323
84
0.671979
ed-quiroga-2103
5e4be236582911556188763659fd9ab7a5b5e7fd
534
cpp
C++
Upsolving/URI/2172.cpp
rodrigoAMF7/Notebook---Maratonas
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
4
2019-01-25T21:22:55.000Z
2019-03-20T18:04:01.000Z
Upsolving/URI/2172.cpp
rodrigoAMF/competitive-programming-notebook
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
null
null
null
Upsolving/URI/2172.cpp
rodrigoAMF/competitive-programming-notebook
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define INF 0x3F3F3F3F #define LINF 0x3F3F3F3F3F3F3F3FLL #define DINF (double)1e+30 #define forn(i, n) for ( int i = 0; i < (n); ++i ) #define forxn(i, x, n) for ( int i = (x); i < (n); ++i ) #define forr(i, a, b) for ( int i = (a); i <= (b); ++i ) #define ford(i, a, b) for ( int i = (a); i >= (b); −−i ) using namespace std; int main(){ long long int x, m, resultado; while(true){ cin >> x >> m; if(x == m && x == 0) break; resultado = x*m; cout << resultado << endl; } return 0; }
19.071429
56
0.537453
rodrigoAMF7
5e4e19d16e3b7897c4b21b9fbdd2b56344315f87
20,639
cpp
C++
Engine/Source/Runtime/Core/Private/Apple/ApplePlatformSymbolication.cpp
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Runtime/Core/Private/Apple/ApplePlatformSymbolication.cpp
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Runtime/Core/Private/Apple/ApplePlatformSymbolication.cpp
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. /*============================================================================= ApplePlatformSymbolication.cpp: Apple platform implementation of symbolication =============================================================================*/ #include "ApplePlatformSymbolication.h" #include "HAL/FileManager.h" #include "HAL/PlatformProcess.h" #include "Misc/AssertionMacros.h" #include "Misc/CoreStats.h" #include "Containers/Map.h" #include "CoreGlobals.h" #include <CoreFoundation/CoreFoundation.h> #include <mach/mach.h> extern "C" { struct CSRange { uint64 Location; uint64 Length; }; typedef FApplePlatformSymbolCache CSTypeRef; typedef CSTypeRef CSSymbolicatorRef; typedef CSTypeRef CSSourceInfoRef; typedef CSTypeRef CSSymbolRef; typedef CSTypeRef CSSymbolOwnerRef; typedef int (^CSSymbolIterator)(CSSymbolRef Symbol); typedef int (^CSSourceInfoIterator)(CSSourceInfoRef SourceInfo); #define kCSNow 0x80000000u typedef Boolean (*CSEqualPtr)(CSTypeRef Cs1, CSTypeRef Cs2); typedef Boolean (*CSIsNullPtr)(CSTypeRef CS); typedef void (*CSReleasePtr)(CSTypeRef CS); typedef void (*CSRetainPtr)(CSTypeRef CS); typedef CSSymbolicatorRef (*CSSymbolicatorCreateWithPidPtr)(pid_t pid); typedef CSSymbolicatorRef (*CSSymbolicatorCreateWithPathAndArchitecturePtr)(const char* path, cpu_type_t type); typedef CSSymbolRef (*CSSymbolicatorGetSymbolWithAddressAtTimePtr)(CSSymbolicatorRef Symbolicator, vm_address_t Address, uint64_t Time); typedef CSSourceInfoRef (*CSSymbolicatorGetSourceInfoWithAddressAtTimePtr)(CSSymbolicatorRef Symbolicator, vm_address_t Address, uint64_t Time); typedef CSSymbolOwnerRef (*CSSymbolicatorGetSymbolOwnerWithUUIDAtTimePtr)(CSSymbolicatorRef Symbolicator, CFUUIDRef UUID, uint64_t Time); typedef CSSymbolOwnerRef (*CSSymbolicatorGetSymbolOwnerPtr)(CSSymbolicatorRef cs); typedef int (*CSSymbolicatorForeachSymbolAtTimePtr)(CSSymbolicatorRef Symbolicator, uint64_t Time, CSSymbolIterator It); typedef const char* (*CSSymbolGetNamePtr)(CSSymbolRef Symbol); typedef CSRange (*CSSymbolGetRangePtr)(CSSymbolRef Symbol); typedef CSSymbolOwnerRef (*CSSourceInfoGetSymbolOwnerPtr)(CSSourceInfoRef Info); typedef CSSymbolOwnerRef (*CSSymbolGetSymbolOwnerPtr)(CSSymbolRef Sym); typedef int (*CSSymbolForeachSourceInfoPtr)(CSSymbolRef Sym, CSSourceInfoIterator It); typedef const char* (*CSSymbolOwnerGetNamePtr)(CSSymbolOwnerRef Owner); typedef CFUUIDRef (*CSSymbolOwnerGetUUIDPtr)(CSSymbolOwnerRef Owner); typedef vm_address_t (*CSSymbolOwnerGetBaseAddressPtr)(CSSymbolOwnerRef Owner); typedef int (*CSSourceInfoGetLineNumberPtr)(CSSourceInfoRef Info); typedef const char* (*CSSourceInfoGetPathPtr)(CSSourceInfoRef Info); typedef CSRange (*CSSourceInfoGetRangePtr)(CSSourceInfoRef Info); typedef CSSymbolRef (*CSSourceInfoGetSymbolPtr)(CSSourceInfoRef Info); } static bool GAllowApplePlatformSymbolication = false; static void* GCoreSymbolicationHandle = nullptr; static CSEqualPtr CSEqual = nullptr; static CSIsNullPtr CSIsNull = nullptr; static CSReleasePtr CSRelease = nullptr; static CSRetainPtr CSRetain = nullptr; static CSSymbolicatorCreateWithPidPtr CSSymbolicatorCreateWithPid = nullptr; static CSSymbolicatorCreateWithPathAndArchitecturePtr CSSymbolicatorCreateWithPathAndArchitecture = nullptr; static CSSymbolicatorGetSymbolWithAddressAtTimePtr CSSymbolicatorGetSymbolWithAddressAtTime = nullptr; static CSSymbolicatorGetSourceInfoWithAddressAtTimePtr CSSymbolicatorGetSourceInfoWithAddressAtTime = nullptr; static CSSymbolicatorGetSymbolOwnerWithUUIDAtTimePtr CSSymbolicatorGetSymbolOwnerWithUUIDAtTime = nullptr; static CSSymbolicatorGetSymbolOwnerPtr CSSymbolicatorGetSymbolOwner = nullptr; static CSSymbolicatorForeachSymbolAtTimePtr CSSymbolicatorForeachSymbolAtTime = nullptr; static CSSymbolGetNamePtr CSSymbolGetName = nullptr; static CSSymbolGetRangePtr CSSymbolGetRange = nullptr; static CSSourceInfoGetSymbolOwnerPtr CSSourceInfoGetSymbolOwner = nullptr; static CSSymbolGetSymbolOwnerPtr CSSymbolGetSymbolOwner = nullptr; static CSSymbolForeachSourceInfoPtr CSSymbolForeachSourceInfo = nullptr; static CSSymbolOwnerGetNamePtr CSSymbolOwnerGetName = nullptr; static CSSymbolOwnerGetUUIDPtr CSSymbolOwnerGetUUID = nullptr; static CSSymbolOwnerGetBaseAddressPtr CSSymbolOwnerGetBaseAddress = nullptr; static CSSourceInfoGetLineNumberPtr CSSourceInfoGetLineNumber = nullptr; static CSSourceInfoGetPathPtr CSSourceInfoGetPath = nullptr; static CSSourceInfoGetRangePtr CSSourceInfoGetRange = nullptr; static CSSourceInfoGetSymbolPtr CSSourceInfoGetSymbol = nullptr; FApplePlatformSymbolDatabase::FApplePlatformSymbolDatabase() { GenericDB = MakeShareable( new FGenericPlatformSymbolDatabase() ); AppleDB.Buffer0 = nullptr; AppleDB.Buffer1 = nullptr; } FApplePlatformSymbolDatabase::FApplePlatformSymbolDatabase(FApplePlatformSymbolDatabase const& Other) { operator=(Other); } FApplePlatformSymbolDatabase::~FApplePlatformSymbolDatabase() { if(GCoreSymbolicationHandle && !CSIsNull(AppleDB)) { CSRelease(AppleDB); } AppleDB.Buffer0 = nullptr; AppleDB.Buffer1 = nullptr; GenericDB = nullptr; } FApplePlatformSymbolDatabase& FApplePlatformSymbolDatabase::operator=(FApplePlatformSymbolDatabase const& Other) { if(this != &Other) { GenericDB = Other.GenericDB; AppleDB = Other.AppleDB; if (AppleDB.Buffer0 != nullptr && AppleDB.Buffer1 != nullptr) { CSRetain(AppleDB); } } return *this; } void FApplePlatformSymbolication::EnableCoreSymbolication(bool const bEnable) { GAllowApplePlatformSymbolication = bEnable; if(bEnable && !GCoreSymbolicationHandle) { GCoreSymbolicationHandle = FPlatformProcess::GetDllHandle(TEXT("/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/Current/CoreSymbolication")); if(GCoreSymbolicationHandle) { CSEqual = (CSEqualPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSEqual")); GAllowApplePlatformSymbolication &= (CSEqual != nullptr); CSIsNull = (CSIsNullPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSIsNull")); GAllowApplePlatformSymbolication &= (CSIsNull != nullptr); CSRelease = (CSReleasePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSRelease")); GAllowApplePlatformSymbolication &= (CSRelease != nullptr); CSRetain = (CSRetainPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSRetain")); GAllowApplePlatformSymbolication &= (CSRetain != nullptr); CSSymbolicatorCreateWithPid = (CSSymbolicatorCreateWithPidPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorCreateWithPid")); GAllowApplePlatformSymbolication &= (CSSymbolicatorCreateWithPid != nullptr); CSSymbolicatorCreateWithPathAndArchitecture = (CSSymbolicatorCreateWithPathAndArchitecturePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorCreateWithPathAndArchitecture")); GAllowApplePlatformSymbolication &= (CSSymbolicatorCreateWithPathAndArchitecture != nullptr); CSSymbolicatorGetSymbolWithAddressAtTime = (CSSymbolicatorGetSymbolWithAddressAtTimePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorGetSymbolWithAddressAtTime")); GAllowApplePlatformSymbolication &= (CSSymbolicatorGetSymbolWithAddressAtTime != nullptr); CSSymbolicatorGetSourceInfoWithAddressAtTime = (CSSymbolicatorGetSourceInfoWithAddressAtTimePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorGetSourceInfoWithAddressAtTime")); GAllowApplePlatformSymbolication &= (CSSymbolicatorGetSourceInfoWithAddressAtTime != nullptr); CSSymbolicatorGetSymbolOwnerWithUUIDAtTime = (CSSymbolicatorGetSymbolOwnerWithUUIDAtTimePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorGetSymbolOwnerWithUUIDAtTime")); GAllowApplePlatformSymbolication &= (CSSymbolicatorGetSymbolOwnerWithUUIDAtTime != nullptr); CSSymbolicatorGetSymbolOwner = (CSSymbolicatorGetSymbolOwnerPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorGetSymbolOwner")); GAllowApplePlatformSymbolication &= (CSSymbolicatorGetSymbolOwner != nullptr); CSSymbolicatorForeachSymbolAtTime = (CSSymbolicatorForeachSymbolAtTimePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolicatorForeachSymbolAtTime")); GAllowApplePlatformSymbolication &= (CSSymbolicatorForeachSymbolAtTime != nullptr); CSSymbolGetName = (CSSymbolGetNamePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolGetName")); GAllowApplePlatformSymbolication &= (CSSymbolGetName != nullptr); CSSymbolGetRange = (CSSymbolGetRangePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolGetRange")); GAllowApplePlatformSymbolication &= (CSSymbolGetRange != nullptr); CSSourceInfoGetSymbolOwner = (CSSourceInfoGetSymbolOwnerPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSourceInfoGetSymbolOwner")); GAllowApplePlatformSymbolication &= (CSSourceInfoGetSymbolOwner != nullptr); CSSymbolGetSymbolOwner = (CSSymbolGetSymbolOwnerPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolGetSymbolOwner")); GAllowApplePlatformSymbolication &= (CSSymbolGetSymbolOwner != nullptr); CSSymbolOwnerGetBaseAddress = (CSSymbolOwnerGetBaseAddressPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolOwnerGetBaseAddress")); GAllowApplePlatformSymbolication &= (CSSymbolOwnerGetBaseAddress != nullptr); CSSymbolForeachSourceInfo = (CSSymbolForeachSourceInfoPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolForeachSourceInfo")); GAllowApplePlatformSymbolication &= (CSSymbolForeachSourceInfo != nullptr); CSSymbolOwnerGetName = (CSSymbolOwnerGetNamePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolOwnerGetName")); GAllowApplePlatformSymbolication &= (CSSymbolOwnerGetName != nullptr); CSSymbolOwnerGetUUID = (CSSymbolOwnerGetUUIDPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSymbolOwnerGetUUID")); GAllowApplePlatformSymbolication &= (CSSymbolOwnerGetUUID != nullptr); CSSourceInfoGetLineNumber = (CSSourceInfoGetLineNumberPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSourceInfoGetLineNumber")); GAllowApplePlatformSymbolication &= (CSSourceInfoGetLineNumber != nullptr); CSSourceInfoGetPath = (CSSourceInfoGetPathPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSourceInfoGetPath")); GAllowApplePlatformSymbolication &= (CSSourceInfoGetPath != nullptr); CSSourceInfoGetRange = (CSSourceInfoGetRangePtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSourceInfoGetRange")); GAllowApplePlatformSymbolication &= (CSSourceInfoGetRange != nullptr); CSSourceInfoGetSymbol = (CSSourceInfoGetSymbolPtr)FPlatformProcess::GetDllExport(GCoreSymbolicationHandle, TEXT("CSSourceInfoGetSymbol")); GAllowApplePlatformSymbolication &= (CSSourceInfoGetSymbol != nullptr); } else { GAllowApplePlatformSymbolication = false; } } else if(!bEnable && GCoreSymbolicationHandle) { CSIsNull = nullptr; CSRelease = nullptr; CSRetain = nullptr; CSSymbolicatorCreateWithPid = nullptr; CSSymbolicatorCreateWithPathAndArchitecture = nullptr; CSSymbolicatorGetSymbolWithAddressAtTime = nullptr; CSSymbolicatorGetSourceInfoWithAddressAtTime = nullptr; CSSymbolicatorGetSymbolOwnerWithUUIDAtTime = nullptr; CSSymbolicatorGetSymbolOwner = nullptr; CSSymbolicatorForeachSymbolAtTime = nullptr; CSSymbolGetName = nullptr; CSSymbolGetRange = nullptr; CSSourceInfoGetSymbolOwner = nullptr; CSSymbolGetSymbolOwner = nullptr; CSSymbolForeachSourceInfo = nullptr; CSSymbolOwnerGetName = nullptr; CSSymbolOwnerGetUUID = nullptr; CSSymbolOwnerGetBaseAddress = nullptr; CSSourceInfoGetLineNumber = nullptr; CSSourceInfoGetPath = nullptr; CSSourceInfoGetRange = nullptr; CSSourceInfoGetSymbol = nullptr; FPlatformProcess::FreeDllHandle(GCoreSymbolicationHandle); GCoreSymbolicationHandle = nullptr; } } bool FApplePlatformSymbolication::LoadSymbolDatabaseForBinary(FString SourceFolder, FString BinaryPath, FString BinarySignature, FApplePlatformSymbolDatabase& OutDatabase) { bool bOK = FGenericPlatformSymbolication::LoadSymbolDatabaseForBinary(SourceFolder, BinaryPath, BinarySignature, *OutDatabase.GenericDB); if(!bOK && GAllowApplePlatformSymbolication && (IFileManager::Get().FileSize(*BinaryPath) > 0)) { CSSymbolicatorRef Symbolicator = OutDatabase.AppleDB; if( CSIsNull(Symbolicator) ) { Symbolicator = CSSymbolicatorCreateWithPathAndArchitecture(TCHAR_TO_UTF8(*BinaryPath), CPU_TYPE_X86_64); } if (CSIsNull(Symbolicator)) { Symbolicator = CSSymbolicatorCreateWithPathAndArchitecture(TCHAR_TO_UTF8(*BinaryPath), CPU_TYPE_ARM64); } if( !CSIsNull(Symbolicator) ) { if(BinarySignature.Len()) { CFUUIDRef UUID = CFUUIDCreateFromString(kCFAllocatorDefault, (CFStringRef)BinarySignature.GetNSString()); check(UUID); CSSymbolOwnerRef SymbolOwner = CSSymbolicatorGetSymbolOwnerWithUUIDAtTime(Symbolicator, UUID, kCSNow); bOK = (!CSIsNull(SymbolOwner)); OutDatabase.GenericDB->Signature = BinarySignature; } else { CSSymbolOwnerRef SymbolOwner = CSSymbolicatorGetSymbolOwner(Symbolicator); if(!CSIsNull(SymbolOwner)) { CFUUIDRef OwnerUUID = CSSymbolOwnerGetUUID(SymbolOwner); CFStringRef String = CFUUIDCreateString(kCFAllocatorDefault, OwnerUUID); check(String); OutDatabase.GenericDB->Signature = FString((NSString*)String); CFRelease(String); bOK = true; } } if(bOK) { OutDatabase.AppleDB = Symbolicator; } } } return bOK; } bool FApplePlatformSymbolication::SaveSymbolDatabaseForBinary(FString TargetFolder, FString InName, FString BinarySignature, FApplePlatformSymbolDatabase& Database) { __block bool bOK = true; if(GAllowApplePlatformSymbolication) { CSSymbolicatorRef Symbolicator = Database.AppleDB; if( !CSIsNull(Symbolicator) ) { __block TMap<FString, int32> StringLookup; CSSymbolOwnerRef SymbolOwner = CSSymbolicatorGetSymbolOwner(Symbolicator); CFUUIDRef OwnerUUID = CSSymbolOwnerGetUUID(SymbolOwner); const char* OwnerName = CSSymbolOwnerGetName(SymbolOwner); vm_address_t BaseAddress = CSSymbolOwnerGetBaseAddress(SymbolOwner); Database.GenericDB->Name = OwnerName; Database.GenericDB->StringTable.Reset(); Database.GenericDB->Symbols.Reset(); if(BinarySignature.Len()) { CFUUIDRef UUID = CFUUIDCreateFromString(kCFAllocatorDefault, (CFStringRef)BinarySignature.GetNSString()); check(UUID); Database.GenericDB->Signature = BinarySignature; } else { CFStringRef String = CFUUIDCreateString(kCFAllocatorDefault, OwnerUUID); check(String); Database.GenericDB->Signature = FString((NSString*)String); CFRelease(String); } CSSymbolicatorForeachSymbolAtTime(Symbolicator, kCSNow, ^(CSSymbolRef Symbol){ CSSymbolOwnerRef Owner = CSSymbolGetSymbolOwner(Symbol); if (CSEqual(SymbolOwner, Owner)) { __block FGenericPlatformSymbolData SymbolData; CSRange Range = CSSymbolGetRange(Symbol); const char* Name = CSSymbolGetName(Symbol); SymbolData.Start = Range.Location - BaseAddress; SymbolData.Length = Range.Length; int32* NameIndex = StringLookup.Find(Name); if(NameIndex) { SymbolData.NameIdx = *NameIndex; } else { SymbolData.NameIdx = Database.GenericDB->StringTable.Num(); StringLookup.Add(Name, SymbolData.NameIdx); Database.GenericDB->StringTable.Push(Name); } CSSymbolForeachSourceInfo(Symbol, ^(CSSourceInfoRef SourceInfo){ int Line = CSSourceInfoGetLineNumber(SourceInfo); const char* Path = CSSourceInfoGetPath(SourceInfo); CSRange InfoRange = CSSourceInfoGetRange(SourceInfo); FGenericPlatformSymbolInfo Info; Info.Line = Line; Info.Start = InfoRange.Location - BaseAddress; Info.Length = InfoRange.Length; int32* PathIndex = StringLookup.Find(Path); if(PathIndex) { Info.PathIdx = *PathIndex; } else { Info.PathIdx = Database.GenericDB->StringTable.Num(); StringLookup.Add(Path, Info.PathIdx); Database.GenericDB->StringTable.Push(Path); } SymbolData.SymbolInfo.Add(Info); return 0; }); Database.GenericDB->Symbols.Add(SymbolData); } else { UE_LOG(LogInit, Warning, TEXT("FApplePlatformSymbolication::SaveSymbolDatabaseForBinary doesn't handle Mach-O binaries/.dSYMs with multiple symbol owners!")); bOK = false; return 1; } return 0; }); bOK &= (Database.GenericDB->Symbols.Num() >= 1); } } if(bOK) { bOK = FGenericPlatformSymbolication::SaveSymbolDatabaseForBinary(TargetFolder, InName, *Database.GenericDB); } return bOK; } bool FApplePlatformSymbolication::SymbolInfoForStrippedSymbol(FApplePlatformSymbolDatabase const& Database, uint64 ProgramCounter, uint64 ModuleOffset, FString ModuleSignature, FProgramCounterSymbolInfo& Info) { bool bOK = FGenericPlatformSymbolication::SymbolInfoForStrippedSymbol(*Database.GenericDB, ProgramCounter, ModuleOffset, ModuleSignature, Info); if(!bOK && GAllowApplePlatformSymbolication && !CSIsNull(Database.AppleDB) && (ModuleSignature.Len())) { CSSymbolicatorRef Symbolicator = Database.AppleDB; CFUUIDRef UUID = CFUUIDCreateFromString(kCFAllocatorDefault, (CFStringRef)ModuleSignature.GetNSString()); check(UUID); CSSymbolOwnerRef SymbolOwner = CSSymbolicatorGetSymbolOwnerWithUUIDAtTime(Symbolicator, UUID, kCSNow); if(!CSIsNull(SymbolOwner)) { ANSICHAR const* DylibName = CSSymbolOwnerGetName(SymbolOwner); FCStringAnsi::Strcpy(Info.ModuleName, DylibName); uint64 Address = ProgramCounter >= ModuleOffset ? (ProgramCounter - ModuleOffset) : ProgramCounter; vm_address_t BaseAddress = CSSymbolOwnerGetBaseAddress(SymbolOwner); CSSymbolRef Symbol = CSSymbolicatorGetSymbolWithAddressAtTime(Symbolicator, ((vm_address_t)Address) + BaseAddress, kCSNow); if(!CSIsNull(Symbol)) { ANSICHAR const* FunctionName = CSSymbolGetName(Symbol); if(FunctionName) { FCStringAnsi::Sprintf(Info.FunctionName, FunctionName); } CSRange Range = CSSymbolGetRange(Symbol); Info.SymbolDisplacement = (ProgramCounter - Range.Location); Info.OffsetInModule = Range.Location; Info.ProgramCounter = ProgramCounter; CSSourceInfoRef SymbolInfo = CSSymbolicatorGetSourceInfoWithAddressAtTime(Symbolicator, ((vm_address_t)Address) + BaseAddress, kCSNow); if(!CSIsNull(SymbolInfo)) { Info.LineNumber = CSSourceInfoGetLineNumber(SymbolInfo); ANSICHAR const* FileName = CSSourceInfoGetPath(SymbolInfo); if(FileName) { FCStringAnsi::Sprintf(Info.Filename, FileName); } } bOK = true; } } } return bOK; } bool FApplePlatformSymbolication::SymbolInfoForAddress(uint64 ProgramCounter, FProgramCounterSymbolInfo& out_SymbolInfo) { bool bOK = false; if (GAllowApplePlatformSymbolication) { CSSymbolicatorRef Symbolicator = CSSymbolicatorCreateWithPid(FPlatformProcess::GetCurrentProcessId()); if(!CSIsNull(Symbolicator)) { CSSourceInfoRef Symbol = CSSymbolicatorGetSourceInfoWithAddressAtTime(Symbolicator, (vm_address_t)ProgramCounter, kCSNow); if(!CSIsNull(Symbol)) { out_SymbolInfo.LineNumber = CSSourceInfoGetLineNumber(Symbol); FCStringAnsi::Sprintf(out_SymbolInfo.Filename, CSSourceInfoGetPath(Symbol)); FCStringAnsi::Sprintf(out_SymbolInfo.FunctionName, CSSymbolGetName(CSSourceInfoGetSymbol(Symbol))); CSRange CodeRange = CSSourceInfoGetRange(Symbol); out_SymbolInfo.SymbolDisplacement = (ProgramCounter - CodeRange.Location); CSSymbolOwnerRef Owner = CSSourceInfoGetSymbolOwner(Symbol); if(!CSIsNull(Owner)) { ANSICHAR const* DylibName = CSSymbolOwnerGetName(Owner); FCStringAnsi::Strcpy(out_SymbolInfo.ModuleName, DylibName); bOK = out_SymbolInfo.LineNumber != 0; } } CSRelease(Symbolicator); } } return bOK; }
43.177824
210
0.778526
windystrife
5e5114dd4ac3c8542e7978a2c8e2b1ceb95aab06
765
cc
C++
test/abc136/test_gathering_children.cc
nryotaro/at_c
8d7d3aecb4e3c768aefdf0ceaeefb269ca9ab34c
[ "MIT" ]
null
null
null
test/abc136/test_gathering_children.cc
nryotaro/at_c
8d7d3aecb4e3c768aefdf0ceaeefb269ca9ab34c
[ "MIT" ]
null
null
null
test/abc136/test_gathering_children.cc
nryotaro/at_c
8d7d3aecb4e3c768aefdf0ceaeefb269ca9ab34c
[ "MIT" ]
null
null
null
#include <vector> #include "gtest/gtest.h" #include "abc136/gathering_children.h" using namespace std; TEST(TestGatheringChildren, First) { vector<char> input = {'R', 'R', 'L', 'R', 'L'}; vector<int> ans = {0, 1, 2, 1, 1}; EXPECT_EQ(ans, gathering_children(input)); } TEST(TestGatheringChildren, Second) { vector<char> input = {'R', 'R', 'L', 'L', 'L', 'L', 'R', 'L', 'R', 'R', 'L', 'L'}; vector<int> ans = {0, 3, 3, 0, 0, 0, 1, 1, 0, 2, 2, 0}; EXPECT_EQ(ans, gathering_children(input)); } TEST(TestGatheringChildren, Third) { vector<char> input = {'R', 'R', 'R', 'L', 'L', 'R', 'L', 'L', 'R', 'R', 'R', 'L', 'L', 'L', 'L', 'L'}; vector<int> ans = {0, 0, 3, 2, 0, 2, 1, 0, 0, 0, 4, 4, 0, 0, 0, 0}; EXPECT_EQ(ans, gathering_children(input)); }
31.875
104
0.552941
nryotaro
5e516da768c2054897032efed128b7565b103cd1
401
cpp
C++
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
3
2018-04-05T04:04:17.000Z
2021-02-01T17:50:01.000Z
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
null
null
null
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
1
2021-02-01T17:50:03.000Z
2021-02-01T17:50:03.000Z
#include "RE/GameSettingCollection.h" #include "RE/Offsets.h" #include "REL/Relocation.h" namespace RE { GameSettingCollection* GameSettingCollection::GetSingleton() { REL::Offset<GameSettingCollection**> singleton(Offset::GameSettingCollection::Singleton); return *singleton; } Setting* GameSettingCollection::GetSetting(const char* a_name) { return settings.find(a_name).first; } }
19.095238
91
0.763092
qis
5e52823b75293ea1aaa1aa4fc7f759592ab0df80
7,217
cpp
C++
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
2,113
2015-01-01T11:23:01.000Z
2022-03-28T04:51:46.000Z
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
948
2015-01-02T01:50:00.000Z
2022-02-27T05:56:40.000Z
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
944
2015-01-01T09:33:53.000Z
2022-03-15T22:23:03.000Z
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames // Copyright (C) 2015 Faust Logic, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// #include "afx/arcaneFX.h" #include "math/mathUtils.h" #include "afx/afxEffectWrapper.h" #include "afx/afxChoreographer.h" #include "afx/xm/afxXfmMod.h" //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// class afxXM_AimData : public afxXM_WeightedBaseData { typedef afxXM_WeightedBaseData Parent; public: bool aim_z_only; public: /*C*/ afxXM_AimData(); /*C*/ afxXM_AimData(const afxXM_AimData&, bool = false); void packData(BitStream* stream); void unpackData(BitStream* stream); virtual bool allowSubstitutions() const { return true; } static void initPersistFields(); afxXM_Base* create(afxEffectWrapper* fx, bool on_server); DECLARE_CONOBJECT(afxXM_AimData); DECLARE_CATEGORY("AFX"); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxConstraint; class afxXM_Aim_weighted : public afxXM_WeightedBase { typedef afxXM_WeightedBase Parent; public: /*C*/ afxXM_Aim_weighted(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_weighted_z : public afxXM_WeightedBase { typedef afxXM_WeightedBase Parent; public: /*C*/ afxXM_Aim_weighted_z(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_fixed : public afxXM_Base { typedef afxXM_Base Parent; public: /*C*/ afxXM_Aim_fixed(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_fixed_z : public afxXM_Base { typedef afxXM_Base Parent; public: /*C*/ afxXM_Aim_fixed_z(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// IMPLEMENT_CO_DATABLOCK_V1(afxXM_AimData); ConsoleDocClass( afxXM_AimData, "@brief An xmod datablock.\n\n" "@ingroup afxXMods\n" "@ingroup AFX\n" "@ingroup Datablocks\n" ); afxXM_AimData::afxXM_AimData() { aim_z_only = false; } afxXM_AimData::afxXM_AimData(const afxXM_AimData& other, bool temp_clone) : afxXM_WeightedBaseData(other, temp_clone) { aim_z_only = other.aim_z_only; } void afxXM_AimData::initPersistFields() { addField("aimZOnly", TypeBool, Offset(aim_z_only, afxXM_AimData), "..."); Parent::initPersistFields(); } void afxXM_AimData::packData(BitStream* stream) { Parent::packData(stream); stream->writeFlag(aim_z_only); } void afxXM_AimData::unpackData(BitStream* stream) { Parent::unpackData(stream); aim_z_only = stream->readFlag(); } afxXM_Base* afxXM_AimData::create(afxEffectWrapper* fx, bool on_server) { afxXM_AimData* datablock = this; if (getSubstitutionCount() > 0) { datablock = new afxXM_AimData(*this, true); this->performSubstitutions(datablock, fx->getChoreographer(), fx->getGroupIndex()); } if (datablock->aim_z_only) { if (datablock->hasFixedWeight()) return new afxXM_Aim_fixed_z(datablock, fx); else return new afxXM_Aim_weighted_z(datablock, fx); } else { if (datablock->hasFixedWeight()) return new afxXM_Aim_fixed(datablock, fx); else return new afxXM_Aim_weighted(datablock, fx); } } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_weighted::afxXM_Aim_weighted(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_WeightedBase(db, fxw) { } void afxXM_Aim_weighted::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { VectorF line_of_sight = params.pos2 - params.pos; line_of_sight.normalize(); F32 wt_factor = calc_weight_factor(elapsed); QuatF qt_ori_incoming(params.ori); MatrixF ori_outgoing = MathUtils::createOrientFromDir(line_of_sight); QuatF qt_ori_outgoing(ori_outgoing); QuatF qt_ori = qt_ori_incoming.slerp(qt_ori_outgoing, wt_factor); qt_ori.setMatrix(&params.ori); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_weighted_z::afxXM_Aim_weighted_z(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_WeightedBase(db, fxw) { } void afxXM_Aim_weighted_z::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { Point3F aim_at_pos = params.pos2; aim_at_pos.z = params.pos.z; VectorF line_of_sight = aim_at_pos - params.pos; line_of_sight.normalize(); F32 wt_factor = calc_weight_factor(elapsed); QuatF qt_ori_incoming(params.ori); MatrixF ori_outgoing = MathUtils::createOrientFromDir(line_of_sight); QuatF qt_ori_outgoing( ori_outgoing ); QuatF qt_ori = qt_ori_incoming.slerp(qt_ori_outgoing, wt_factor); qt_ori.setMatrix(&params.ori); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_fixed::afxXM_Aim_fixed(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_Base(db, fxw) { } void afxXM_Aim_fixed::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { VectorF line_of_sight = params.pos2 - params.pos; line_of_sight.normalize(); params.ori = MathUtils::createOrientFromDir(line_of_sight); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_fixed_z::afxXM_Aim_fixed_z(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_Base(db, fxw) { } void afxXM_Aim_fixed_z::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { Point3F aim_at_pos = params.pos2; aim_at_pos.z = params.pos.z; VectorF line_of_sight = aim_at_pos - params.pos; line_of_sight.normalize(); params.ori = MathUtils::createOrientFromDir(line_of_sight); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
27.651341
117
0.65221
vbillet
5e536b2583624ff446f0da1baa8400a0d00529de
1,431
cpp
C++
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
/* ID: scwswx2 LANG: C++ PROG: crypt1 */ /*#include <iostream> #include <fstream> #include <string> #include <cstring> #include <map> #include <cstdio> #include <algorithm> using namespace std; int table[10]; int check ( int x ) { while (x) { if (!table[x%10]){ return 1; } x = x/10; } return 0; } int main() { int sum=0,n,t; freopen("crypt1.in","r",stdin); freopen("crypt1.out","w",stdout); scanf("%d",&n); for ( int i = 0;i < n;i++ ) { scanf("%d",&t); table[t] = 1; } for ( int i = 100;i < 1000;i++ ) { if ( check(i)) continue; for ( int j = 10;j < 100;j++ ) { int m = i*j; if ( m>9999 ) break; if ( check(j)||check(m)) continue; int fm = (j%10)*i; if ( fm<100||fm>=1000 ) continue; int sm = (j/10)*i; if ( sm<100||sm>=1000 ) continue; if ( check(sm)||check(fm) ) continue; sum++; } } cout<<sum<<endl; return 0; } */
21.681818
48
0.331936
versionwen
5e550339af045cd98886f1befda646e1558b2523
6,359
cpp
C++
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
52
2015-01-13T05:17:23.000Z
2021-05-09T14:09:39.000Z
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
7
2015-01-12T10:25:14.000Z
2018-09-18T12:34:15.000Z
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
31
2015-01-12T06:39:15.000Z
2020-04-06T07:05:08.000Z
// // ramGlobal.cpp - RAMDanceToolkit // // Copyright 2012-2013 YCAM InterLab, Yoshito Onishi, Satoru Higa, Motoi Shimizu, and Kyle McDonald // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "ramGlobal.h" #include "ramSimpleShadow.h" #include "ramPhysics.h" #include "ramControlPanel.h" #include "ramSceneManager.h" static ramSimpleShadow ram_simple_shadow; ramActorManager& ramGlobalShortcut::getActorManager() { return ramActorManager::instance(); } const ramActorManager& ramGlobalShortcut::getActorManager() const { return ramActorManager::instance(); } ramCommunicationManager& ramGlobalShortcut::getCommunicationManager() { return ramCommunicationManager::instance(); } const ramCommunicationManager& ramGlobalShortcut::getCommunicationManager() const { return ramCommunicationManager::instance(); } ramOscManager& ramGlobalShortcut::getOscManager() {return ramOscManager::instance(); } const ramOscManager& ramGlobalShortcut::getOscManager() const {return ramOscManager::instance(); } const vector<string>& ramGlobalShortcut::getNodeArrayNames() const { return ramActorManager::instance().getNodeArrayNames(); } bool ramGlobalShortcut::hasNodeArray(const string &key) const { return ramActorManager::instance().hasNodeArray(key); } ramNodeArray& ramGlobalShortcut::getNodeArray(const string &name) { return ramActorManager::instance().getNodeArray(name); } const ramNodeArray& ramGlobalShortcut::getNodeArray(const string &name) const { return ramActorManager::instance().getNodeArray(name); } size_t ramGlobalShortcut::getNumNodeArray() const { return ramActorManager::instance().getNumNodeArray(); } ramNodeArray& ramGlobalShortcut::getNodeArray(int index) { return ramActorManager::instance().getNodeArray(index); } const ramNodeArray& ramGlobalShortcut::getNodeArray(int index) const { return ramActorManager::instance().getNodeArray(index); } vector<ramNodeArray> ramGlobalShortcut::getAllNodeArrays() const { return ramActorManager::instance().getAllNodeArrays(); } ramCameraManager& ramGlobalShortcut::getCameraManager() { return ramCameraManager::instance(); } ofCamera& ramGlobalShortcut::getActiveCamera() { return ramCameraManager::instance().getActiveCamera(); } //ramSceneManager& ramGlobalShortcut::getSceneManager() { return ramSceneManager::instance(); } #pragma mark - core void ramInitialize(int oscPort, bool usePresetScenes) { static bool inited = false; if (inited) return; inited = true; ram_simple_shadow.setup(); ramOscManager::instance().setup(oscPort); ramActorManager::instance().setup(); ramActorManager::instance().setupOscReceiver(&ramOscManager::instance()); ramSceneManager::instance().setup(); ramPhysics::instance(); ramGetGUI().setup(usePresetScenes); ramCommunicationManager::instance().setup(&ramOscManager::instance()); } string ramToResourcePath(const string& path) { string base_path = "resources"; bool dirExists = false; const int maxDepth = 5; for (int i=0; i<maxDepth; i++) { ofDirectory dir(base_path); if (dir.exists()) { dirExists = true; break; } string tmpPath = ofToDataPath(base_path); ofDirectory dirFromDataPath(tmpPath); if (dirFromDataPath.exists()) { base_path = tmpPath; dirExists = true; break; } base_path = "../" + base_path; } if (!dirExists) { ofLogError() << "resources folder dosen't found"; } return ofFilePath::join(base_path, path); } #pragma mark - actors void ramEnableShowActors(bool v) { ramSceneManager::instance().setShowAllActors(v); } bool ramShowActorsEnabled() { return ramSceneManager::instance().getShowAllActors(); } ramNode _evilNode; const ramNode& ramGetNode(unsigned int actorId, unsigned int jointId){ const int numNA = ramActorManager::instance().getNumNodeArray(); // if the actor does not exist... if (!(0 < numNA) || (numNA-1 <= actorId)) { ofLogError("getRamNode()") << "the actor id " << actorId << " is not found. retruned evil node."; return _evilNode; } ramNodeArray &NA = ramActorManager::instance().getNodeArray(actorId); // if the joint does not exist... if (NA.getNumNode() >= jointId) { ofLogError("getRamNode()") << "the joint id " << jointId << " is greater than " << NA.getName() << "'s number of joints. retruned evil node."; return _evilNode; } return NA.getNode(jointId); } #pragma mark - camera static ofRectangle _viewport; void ramSetViewPort(ofRectangle viewport) { _viewport = viewport; } ofRectangle ramGetViewPort() { return _viewport; } void ramBeginCamera(ofRectangle viewport) { ofRectangle v = viewport; if (v.isEmpty()) v = ofGetCurrentViewport(); ramCameraManager::instance().getActiveCamera().begin(v); } void ramEndCamera() { ramCameraManager::instance().getActiveCamera().end(); } void ramEnableInteractiveCamera(bool v) { ramCameraManager::instance().setEnableInteractiveCamera(v); } #pragma mark - shadows void ramEnableShadow(bool v) { ram_simple_shadow.setEnable(v); } void ramDisableShadow() { ram_simple_shadow.setEnable(false); } bool ramShadowEnabled() { return ram_simple_shadow.getEnable(); } void ramBeginShadow() { ram_simple_shadow.begin(); } void ramEndShadow() { ram_simple_shadow.end(); } void ramSetShadowAlpha(float alpha) { ram_simple_shadow.setShadowAlpha(alpha); } #pragma mark - physics static bool ram_enable_physics_primitive = true; void ramEnablePhysicsPrimitive(bool v) { ram_enable_physics_primitive = v; } void ramDisablePhysicsPrimitive() { ram_enable_physics_primitive = false; } bool ramGetEnablePhysicsPrimitive() { return ram_enable_physics_primitive; } #pragma mark - error void ramNotImplementedError() { ofLogWarning("RAM Dance Toolkit") << "not implemented yet"; }
26.831224
144
0.736122
YCAMInterlab
5e577f7f085c0266f90064f9f4c9d7376fcfdfd6
1,654
cpp
C++
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
/************************************************** Copyright 2015 Ola Enberg ***************************************************/ #include "SSTerrainFollow.h" #include <gfx/GraphicsEngine.h> #include "../../datadriven/DenseComponentCollection.h" #include "../../component/PlacementComponent.h" #include "../../component/TerrainFollowComponent.h" #include "../../datadriven/EntityManager.h" SSTerrainFollow& SSTerrainFollow::GetInstance() { static SSTerrainFollow instance; return instance; } void SSTerrainFollow::Startup() { Subsystem::Startup(); } void SSTerrainFollow::UpdateUserLayer( const float deltaTime ) { EntityMask placementFlag = DenseComponentCollection<PlacementComponent>::GetInstance().GetComponentTypeFlag(); EntityMask terrainFollowFlag = DenseComponentCollection<TerrainFollowComponent>::GetInstance().GetComponentTypeFlag(); EntityMask combinedFlag = placementFlag | terrainFollowFlag; int entityID = 0; for ( auto& entityMask : EntityManager::GetInstance().GetEntityMasks() ) { // Check if entity has a placement component if ( ( entityMask & combinedFlag ) == combinedFlag ) { PlacementComponent* placementComponent = GetDenseComponent<PlacementComponent>( entityID ); TerrainFollowComponent* terrainFollowComponent = GetDenseComponent<TerrainFollowComponent>( entityID ); float addedHeight = terrainFollowComponent->Offset * placementComponent->Scale.y; placementComponent->Position.y = gfx::g_GFXTerrain.GetHeightAtWorldCoord(placementComponent->Position.x, placementComponent->Position.z) + addedHeight + 0.2f; } entityID++; } } void SSTerrainFollow::Shutdown() { Subsystem::Shutdown(); }
34.458333
161
0.729746
Robograde
5e58d9b177591bf633607aa836258e0d2e4d6e4b
1,053
hpp
C++
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
#pragma once #include "../detail/detail.hpp" #include "../random_generator.hpp" #include <vector> namespace ga { namespace operators { template <class GenotypeModel> class crossover { public: using genotype = typename GenotypeModel::representation; using gene_value_type = typename GenotypeModel::value_type; public: virtual std::pair<genotype, genotype> apply(const genotype &a, const genotype &b) = 0; ~crossover() {} }; template <class GenotypeModel> class one_point_crossover : public crossover<GenotypeModel> { public: using genotype = typename GenotypeModel::representation; using gene_value_type = typename GenotypeModel::value_type; public: std::pair<genotype, genotype> apply(const genotype &a, const genotype &b) override { const std::size_t point_index = rg.generate(std::uniform_int_distribution<unsigned long>(1, a.size() - 2)); return detail::one_point_crossover(a, b, point_index); } private: random_generator rg; }; } //namespace operators } //namespace ga
21.489796
90
0.717949
AndrSar
5e58dc866b936d77cffbf8f319d51d0d453bf584
13,351
cpp
C++
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
30
2020-09-16T17:39:36.000Z
2022-02-17T08:32:53.000Z
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
7
2020-11-23T14:37:15.000Z
2022-01-17T11:35:32.000Z
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
5
2020-09-17T00:39:14.000Z
2021-08-30T16:14:07.000Z
// IDDN FR.001.250001.004.S.X.2019.000.00000 // ULIS is subject to copyright laws and is the legal and intellectual property of Praxinos,Inc /* * ULIS *__________________ * @file DockingManager.cpp * @author Clement Berthaud * @brief pyULIS_Interactive application for testing pyULIS. * @copyright Copyright 2018-2021 Praxinos, Inc. All Rights Reserved. * @license Please refer to LICENSE.md */ #include "DockingManager.h" #include "Tab.h" #include "TabArea.h" #include "GeometryUtils.h" #include "WinExtras.h" #include <QApplication> #include <QShortcut> #include <QEvent> #include <QMouseEvent> #include <assert.h> //////////////////////////////////////////////////////////////////////////////////////// //// STATIC TOOLS //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------- Static functions & tools for sorting struct FZOrderingPair { int zOrder; FTabArea* area; }; // Struct for ordering and selecting area while dragging struct FElligibleArea { FTabArea* mArea; QRegion mRegion; }; static bool SortZ( const FZOrderingPair& iA, const FZOrderingPair& iB ) { return iA.zOrder < iB.zOrder; } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE CONSTRUCTION //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //----------------------------------------------------------- Construction / Destruction FDockingManager::~FDockingManager() { } FDockingManager::FDockingManager() : mCurrentDraggingTab( NULL ), mCurrentTargetArea( NULL ), mLastLiftedFrom( NULL ) { } //////////////////////////////////////////////////////////////////////////////////////// //// PUBLIC SINGLETON API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------------------------- Singleton Accessor // static FDockingManager* FDockingManager::DockingManager() { static FDockingManager* sgDockingManager = 0; if( !sgDockingManager ) sgDockingManager = new FDockingManager(); return sgDockingManager; } //////////////////////////////////////////////////////////////////////////////////////// //// INFO API //// //////////////////////////////////////////////////////////////////////////////////////// FTab* FDockingManager::CurrentDraggingTab() const { return mCurrentDraggingTab; } FTabArea* FDockingManager::CurrentTargetArea() const { return mCurrentTargetArea; } void FDockingManager::SetLastLiftedFrom( FTabArea* iValue ) { mLastLiftedFrom = iValue; } FTabArea* FDockingManager::GetLastLiftedFrom() const { return mLastLiftedFrom; } //////////////////////////////////////////////////////////////////////////////////////// //// REGISTER API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //---------------------------------------------- Public Register API for Tabs & TabAreas void FDockingManager::RegisterTabArea( FTabArea* iTabArea ) { mTabAreaList.append( iTabArea ); } void FDockingManager::UnregisterTabArea( FTabArea* iTabArea ) { mTabAreaList.removeAll( iTabArea ); } void FDockingManager::RegisterTab( FTab* iTab ) { InitConnectionsForTab( iTab ); } void FDockingManager::UnregisterTab( FTab* iTab ) { DestroyConnectionsForTab( iTab ); } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE SIGNAL SLOTS API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //-------------------------------------------------------------- Docking Interface Slots void FDockingManager::TabLifted( FTab* iTab ) { // Processing directly after the signal was emitted // Hook the dragging tab mCurrentDraggingTab = iTab; mCurrentDraggingTab->installEventFilter( this ); // Make it Indie iTab->setParent(0); iTab->setWindowFlags( Qt::FramelessWindowHint | Qt::SubWindow ); iTab->show(); iTab->raise(); } void FDockingManager::TabDropped( FTab* iTab ) { assert( iTab == mCurrentDraggingTab ); mCurrentDraggingTab->removeEventFilter( this ); if( !mCurrentTargetArea ) { //emit TabDroppedOutisde( mCurrentDraggingTab ); auto fctptr = mCurrentDraggingTab->GetOnTabDroppedOutCB(); if( fctptr ) fctptr( mCurrentDraggingTab, mLastLiftedFrom ); } //mCurrentTargetArea = NULL; //mCurrentDraggingTab = NULL; } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------------------------ Qt Events overrides bool FDockingManager::eventFilter( QObject* obj, QEvent* event ) { // We process only mouse events of the current dragging tab. { FTab* tab = dynamic_cast< FTab* >( obj ); if( !tab ) // return false means process the event normally instead return false; assert( tab->Dragging() ); assert( tab == mCurrentDraggingTab ); } // This part allows us to cancel the dragging in case an unexpected event occured { auto eType = event->type(); if( eType == QEvent::FocusOut || eType == QEvent::Leave || eType == QEvent::HoverLeave || eType == QEvent::ContextMenu || eType == QEvent::Drop || eType == QEvent::NonClientAreaMouseButtonRelease ) { mCurrentDraggingTab->FinishDrag(); // cancel drag will emit the necessary signals to remove the event filter. event->ignore(); // explicit ignore, not sure about the effect of this. return true; // return true cancels any further event propagation & computation. } } // Actual eventFilter behaviour starts here // We process only mouse events ( most likely move events ) QMouseEvent* mouseEvent = dynamic_cast< QMouseEvent* >( event ); if( !mouseEvent ) return false; // return false means process the event normally instead // Positionning // Position of the mouse at the time of event, see also QCursor::pos() QPoint cpos = mouseEvent->globalPos(); QRect tabRec = mCurrentDraggingTab->geometry(); // Mouse Snapping when close to the Area that has been targeted. if( mCurrentTargetArea ) { QPoint globalSnap = mCurrentTargetArea->mapToGlobal(QPoint(0,0)); int h2 = mCurrentTargetArea->height() / 2; int threshold = 10; if( abs( globalSnap.y() + h2 - mouseEvent->globalPos().y() ) < threshold ) mCurrentDraggingTab->move( cpos.x() - mCurrentDraggingTab->DragShift().x(), globalSnap.y()); else mCurrentDraggingTab->move( cpos - mCurrentDraggingTab->DragShift()); } else { mCurrentDraggingTab->move( cpos - mCurrentDraggingTab->DragShift()); } // Selecting target area FTabArea* resultArea = NULL; QVector< FElligibleArea > elligibleVector; for( FTabArea* area : mTabAreaList ) { // Reset tabAreas hooks before processing the new one // This is safe to do even if there is none mCurrentDraggingTab->removeEventFilter( area ); QObject::disconnect( mCurrentDraggingTab, SIGNAL( Dropped( FTab* ) ), area, SLOT( ForeignTabDropped( FTab* ) ) ); // Computing global Region for ech tabArea /* QRegion region = area->visibleRegion().translated( area->mapToGlobal( QPoint( 0, 0 ) ) ); QRect debug = region.boundingRect(); QRect debug2 = area->geometry(); */ QRect region = MapRectToGlobal( area->parentWidget(), area->geometry() ); // If there is no intersection that means the area is not elligible // It can mean the area lost track of the tab so we proceed to a reorder if( !region.intersects( tabRec ) ) { continue; } // If we arrive here, the tabArea is elligible so we push it for further processing elligibleVector.push_back( FElligibleArea( { area, region } ) ); } switch( elligibleVector.count() ) { case 0: { resultArea = NULL; break; } case 1: { resultArea = elligibleVector[0].mArea; break; } default: { // The current dragging tab is overlapping more than one area QVector< FElligibleArea > overlappingCursorSelection; bool therAreOverlaping = false; for( FElligibleArea m : elligibleVector ) { // We chose the ones that contains the mouse cursor position if( m.mRegion.contains( cpos ) ) { overlappingCursorSelection.append( m ); therAreOverlaping = true; } } if( therAreOverlaping ) { // If there is at least one region that contains the cursor position, we select the topmost in overlappingCursorSelection QVector< FZOrderingPair > orderingVector; for( FElligibleArea m : overlappingCursorSelection ) orderingVector.append( FZOrderingPair{ GetZOrder( (HWND)m.mArea->topLevelWidget()->winId() ), m.mArea } ); qSort( orderingVector.begin(), orderingVector.end(), SortZ ); resultArea = orderingVector[0].area; } else { // Otherwise: overlapping more than one area but cursor is not in any of them, we select the topmost in elligible QVector< FZOrderingPair > orderingVector; for( FElligibleArea m : elligibleVector ) orderingVector.append( FZOrderingPair{ GetZOrder( (HWND)m.mArea->topLevelWidget()->winId() ), m.mArea } ); qSort( orderingVector.begin(), orderingVector.end(), SortZ ); resultArea = orderingVector[0].area; } } // !default } // !switch // Reject if not tag if( resultArea && resultArea->GetTag() != mCurrentDraggingTab->GetTag() ) return false; // Reorder leaving target area if( resultArea != mCurrentTargetArea && mCurrentTargetArea != NULL ) mCurrentTargetArea->Recompose(); // Can be set to NULL mCurrentTargetArea = resultArea; if( resultArea ) { mCurrentDraggingTab->installEventFilter( resultArea ); QObject::connect( mCurrentDraggingTab, SIGNAL( Dropped( FTab* ) ), resultArea, SLOT( ForeignTabDropped( FTab* ) ) ); resultArea->SetCandidateTab( mCurrentDraggingTab ); } for( FTabArea* area : mTabAreaList ) if( area != resultArea ) area->SetCandidateTab( NULL ); return false; } //-------------------------------------------------------------------------------------- //--------------------------------------------------------- Private Connection Interface void FDockingManager::InitConnectionsForTab( FTab* iTab ) { QObject::connect( iTab, SIGNAL( Lifted( FTab* ) ), this, SLOT( TabLifted( FTab* ) ) ); QObject::connect( iTab, SIGNAL( Dropped( FTab* ) ), this, SLOT( TabDropped( FTab* ) ) ); } void FDockingManager::DestroyConnectionsForTab( FTab* iTab ) { QObject::disconnect( iTab, SIGNAL( Lifted( FTab* ) ), this, SLOT( TabLifted( FTab* ) ) ); QObject::disconnect( iTab, SIGNAL( Dropped( FTab* ) ), this, SLOT( TabDropped( FTab* ) ) ); } //-------------------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////// //// PUBLIC SINGLETON API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //---------------------------------------------- External Conveniency Singleton Accessor FDockingManager* DockingManager() { return FDockingManager::DockingManager(); }
32.965432
205
0.485507
Fabrice-Praxinos
5e5b7ac48008a29b994edb31e3a52d6226016709
1,545
cc
C++
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
/** ** Checking string comparisons desugaring. */ #include <ostream> #include <string> #include <ast/all.hh> #include <ast/libast.hh> #include <desugar/desugar-visitor.hh> #include <misc/file-library.hh> #include <parse/libparse.hh> #include <type/type-checker.hh> #include <type/types.hh> using namespace ast; using namespace desugar; const char* program_name = "test-string-cmp-desugar"; static void test_string_desugaring(const std::string& oper) { Exp* tree = parse::parse("let primitive streq(s1 : string, s2 : string) : int\n" " primitive strcmp(s1 : string, s2 : string) : int\n" "in\n" " (\"foo\" " + oper + " \"bar\")\n" "end\n"); type::TypeChecker type; type(tree); std::cout << "/* === Original tree... */\n" << *tree << '\n'; DesugarVisitor desugar(false, true); tree->accept(desugar); delete tree; tree = nullptr; std::cout << "/* === Desugared tree... */\n" << *desugar.result_get() << '\n'; delete desugar.result_get(); } int main() { // Desugaring `"foo" = "bar"' as `streq("foo", "bar")'. std::cout << "First test...\n"; test_string_desugaring("="); std::cout << std::endl; // Desugaring `"foo" <> "bar"' as `streq("foo", "bar") = 0'. std::cout << "Second test...\n"; test_string_desugaring("<>"); std::cout << std::endl; // Desugaring `"foo" >= "bar"' as `strcmp("foo", "bar") >= 0'. std::cout << "Third test...\n"; test_string_desugaring(">="); }
25.327869
72
0.565696
MrMaDGaME
5e5bc5c88129877bb07eef053149da72fc08a862
600
hpp
C++
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
#pragma once #include <D3D12/D3D12_Define.hpp> #include <memory> namespace Ladybug3D { class Editor { public: static constexpr UINT EDITOR_DESCRIPTOR_SIZE = 64; void Initialize(void* hwnd, ID3D12Device* device, unsigned int frameCount); void NewFrame(); void Render(ID3D12GraphicsCommandList* cmdList); void DrawSampleWindow(); void DrawSceneGraph(); void ShutDownImGui(); ID3D12DescriptorHeap* GetDescriptorHeap(); private: std::unique_ptr<Ladybug3D::D3D12::DescriptorHeapAllocator> m_DescriptorHeap; }; }
25
84
0.68
wlsvy
5e65feb904a960179bc1f92364f826e0e7365e2f
1,091
cc
C++
chrome/browser/extensions/wasm_app_browsertest.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chrome/browser/extensions/wasm_app_browsertest.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
chrome/browser/extensions/wasm_app_browsertest.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_browsertest.h" #include "content/public/test/browser_test.h" using extensions::Extension; // Test ensures that Wasm can run in Chrome Apps. namespace { using WasmAppTest = extensions::ExtensionBrowserTest; IN_PROC_BROWSER_TEST_F(WasmAppTest, InstantiateWasmFromFetch) { const Extension* extension = LoadExtension(test_data_dir_.AppendASCII("wasm_app")); ASSERT_TRUE(extension); EXPECT_EQ("success", ExecuteScriptInBackgroundPage(extension->id(), "instantiateFetch()")); } IN_PROC_BROWSER_TEST_F(WasmAppTest, InstantiateWasmFromArrayBuffer) { const Extension* extension = LoadExtension(test_data_dir_.AppendASCII("wasm_app")); ASSERT_TRUE(extension); EXPECT_EQ("success", ExecuteScriptInBackgroundPage( extension->id(), "instantiateArrayBuffer()")); } } // namespace
32.088235
76
0.721357
zealoussnow
5e6802193d69edc37ae030323b4f7c1d5fe5c2c9
22,188
cc
C++
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
6
2016-02-03T12:48:36.000Z
2020-09-16T15:07:51.000Z
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
4
2016-02-13T01:30:43.000Z
2020-03-30T16:59:32.000Z
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
null
null
null
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #define VTK_WRAPPING_CXX #define VTK_STREAMS_FWD_ONLY #include <nan.h> #include "vtkHyperTreeCursorWrap.h" #include "vtkHyperTreeGridCursorWrap.h" #include "vtkObjectBaseWrap.h" #include "vtkHyperTreeGridWrap.h" #include "vtkHyperTreeWrap.h" #include "vtkIdListWrap.h" #include "../../plus/plus.h" using namespace v8; extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap; Nan::Persistent<v8::FunctionTemplate> VtkHyperTreeGridCursorWrap::ptpl; VtkHyperTreeGridCursorWrap::VtkHyperTreeGridCursorWrap() { } VtkHyperTreeGridCursorWrap::VtkHyperTreeGridCursorWrap(vtkSmartPointer<vtkHyperTreeGridCursor> _native) { native = _native; } VtkHyperTreeGridCursorWrap::~VtkHyperTreeGridCursorWrap() { } void VtkHyperTreeGridCursorWrap::Init(v8::Local<v8::Object> exports) { Nan::SetAccessor(exports, Nan::New("vtkHyperTreeGridCursor").ToLocalChecked(), ConstructorGetter); Nan::SetAccessor(exports, Nan::New("HyperTreeGridCursor").ToLocalChecked(), ConstructorGetter); } void VtkHyperTreeGridCursorWrap::ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) { InitPtpl(); info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction()); } void VtkHyperTreeGridCursorWrap::InitPtpl() { if (!ptpl.IsEmpty()) return; v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New); VtkHyperTreeCursorWrap::InitPtpl( ); tpl->Inherit(Nan::New<FunctionTemplate>(VtkHyperTreeCursorWrap::ptpl)); tpl->SetClassName(Nan::New("VtkHyperTreeGridCursorWrap").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); Nan::SetPrototypeMethod(tpl, "Clone", Clone); Nan::SetPrototypeMethod(tpl, "clone", Clone); Nan::SetPrototypeMethod(tpl, "GetBounds", GetBounds); Nan::SetPrototypeMethod(tpl, "getBounds", GetBounds); Nan::SetPrototypeMethod(tpl, "GetChildIndex", GetChildIndex); Nan::SetPrototypeMethod(tpl, "getChildIndex", GetChildIndex); Nan::SetPrototypeMethod(tpl, "GetCornerCursors", GetCornerCursors); Nan::SetPrototypeMethod(tpl, "getCornerCursors", GetCornerCursors); Nan::SetPrototypeMethod(tpl, "GetCursor", GetCursor); Nan::SetPrototypeMethod(tpl, "getCursor", GetCursor); Nan::SetPrototypeMethod(tpl, "GetDimension", GetDimension); Nan::SetPrototypeMethod(tpl, "getDimension", GetDimension); Nan::SetPrototypeMethod(tpl, "GetGrid", GetGrid); Nan::SetPrototypeMethod(tpl, "getGrid", GetGrid); Nan::SetPrototypeMethod(tpl, "GetLevel", GetLevel); Nan::SetPrototypeMethod(tpl, "getLevel", GetLevel); Nan::SetPrototypeMethod(tpl, "GetNumberOfChildren", GetNumberOfChildren); Nan::SetPrototypeMethod(tpl, "getNumberOfChildren", GetNumberOfChildren); Nan::SetPrototypeMethod(tpl, "GetNumberOfCursors", GetNumberOfCursors); Nan::SetPrototypeMethod(tpl, "getNumberOfCursors", GetNumberOfCursors); Nan::SetPrototypeMethod(tpl, "GetPoint", GetPoint); Nan::SetPrototypeMethod(tpl, "getPoint", GetPoint); Nan::SetPrototypeMethod(tpl, "GetTree", GetTree); Nan::SetPrototypeMethod(tpl, "getTree", GetTree); Nan::SetPrototypeMethod(tpl, "IsEqual", IsEqual); Nan::SetPrototypeMethod(tpl, "isEqual", IsEqual); Nan::SetPrototypeMethod(tpl, "IsLeaf", IsLeaf); Nan::SetPrototypeMethod(tpl, "isLeaf", IsLeaf); Nan::SetPrototypeMethod(tpl, "IsRoot", IsRoot); Nan::SetPrototypeMethod(tpl, "isRoot", IsRoot); Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "SameTree", SameTree); Nan::SetPrototypeMethod(tpl, "sameTree", SameTree); Nan::SetPrototypeMethod(tpl, "SetGrid", SetGrid); Nan::SetPrototypeMethod(tpl, "setGrid", SetGrid); Nan::SetPrototypeMethod(tpl, "SetTree", SetTree); Nan::SetPrototypeMethod(tpl, "setTree", SetTree); Nan::SetPrototypeMethod(tpl, "ToChild", ToChild); Nan::SetPrototypeMethod(tpl, "toChild", ToChild); Nan::SetPrototypeMethod(tpl, "ToParent", ToParent); Nan::SetPrototypeMethod(tpl, "toParent", ToParent); Nan::SetPrototypeMethod(tpl, "ToRoot", ToRoot); Nan::SetPrototypeMethod(tpl, "toRoot", ToRoot); Nan::SetPrototypeMethod(tpl, "ToSameVertex", ToSameVertex); Nan::SetPrototypeMethod(tpl, "toSameVertex", ToSameVertex); #ifdef VTK_NODE_PLUS_VTKHYPERTREEGRIDCURSORWRAP_INITPTPL VTK_NODE_PLUS_VTKHYPERTREEGRIDCURSORWRAP_INITPTPL #endif ptpl.Reset( tpl ); } void VtkHyperTreeGridCursorWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) { if(!info.IsConstructCall()) { Nan::ThrowError("Constructor not called in a construct call."); return; } if(info.Length() == 0) { vtkSmartPointer<vtkHyperTreeGridCursor> native = vtkSmartPointer<vtkHyperTreeGridCursor>::New(); VtkHyperTreeGridCursorWrap* obj = new VtkHyperTreeGridCursorWrap(native); obj->Wrap(info.This()); } else { if(info[0]->ToObject() != vtkNodeJsNoWrap ) { Nan::ThrowError("Parameter Error"); return; } } info.GetReturnValue().Set(info.This()); } void VtkHyperTreeGridCursorWrap::Clone(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGridCursor * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->Clone(); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::GetBounds(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); size_t i; if(info.Length() > 0 && info[0]->IsFloat64Array()) { v8::Local<v8::Float64Array>a0(v8::Local<v8::Float64Array>::Cast(info[0]->ToObject())); if( a0->Length() < 6 ) { Nan::ThrowError("Array too short."); return; } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetBounds( (double *)(a0->Buffer()->GetContents().Data()) ); return; } else if(info.Length() > 0 && info[0]->IsArray()) { v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject())); double b0[6]; if( a0->Length() < 6 ) { Nan::ThrowError("Array too short."); return; } for( i = 0; i < 6; i++ ) { if( !a0->Get(i)->IsNumber() ) { Nan::ThrowError("Array contents invalid."); return; } b0[i] = a0->Get(i)->NumberValue(); } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetBounds( b0 ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetChildIndex(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetChildIndex(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetCornerCursors(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsUint32()) { if(info.Length() > 1 && info[1]->IsUint32()) { if(info.Length() > 2 && info[2]->IsObject() && (Nan::New(VtkIdListWrap::ptpl))->HasInstance(info[2])) { VtkIdListWrap *a2 = ObjectWrap::Unwrap<VtkIdListWrap>(info[2]->ToObject()); bool r; if(info.Length() != 3) { Nan::ThrowError("Too many parameters."); return; } r = native->GetCornerCursors( info[0]->Uint32Value(), info[1]->Uint32Value(), (vtkIdList *) a2->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } } } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetCursor(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsUint32()) { vtkHyperTreeGridCursor * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->GetCursor( info[0]->Uint32Value() ); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetDimension(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetDimension(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetGrid(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGrid * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetGrid(); VtkHyperTreeGridWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridWrap *w = new VtkHyperTreeGridWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::GetLevel(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); unsigned int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetLevel(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetNumberOfChildren(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetNumberOfChildren(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetNumberOfCursors(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); unsigned int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetNumberOfCursors(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetPoint(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); size_t i; if(info.Length() > 0 && info[0]->IsFloat64Array()) { v8::Local<v8::Float64Array>a0(v8::Local<v8::Float64Array>::Cast(info[0]->ToObject())); if( a0->Length() < 3 ) { Nan::ThrowError("Array too short."); return; } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetPoint( (double *)(a0->Buffer()->GetContents().Data()) ); return; } else if(info.Length() > 0 && info[0]->IsArray()) { v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject())); double b0[3]; if( a0->Length() < 3 ) { Nan::ThrowError("Array too short."); return; } for( i = 0; i < 3; i++ ) { if( !a0->Get(i)->IsNumber() ) { Nan::ThrowError("Array contents invalid."); return; } b0[i] = a0->Get(i)->NumberValue(); } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetPoint( b0 ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTree * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetTree(); VtkHyperTreeWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeWrap *w = new VtkHyperTreeWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::IsEqual(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); bool r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->IsEqual( (vtkHyperTreeCursor *) a0->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::IsLeaf(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); bool r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->IsLeaf(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::IsRoot(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); bool r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->IsRoot(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGridCursor * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->NewInstance(); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0])) { VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject()); vtkHyperTreeGridCursor * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SafeDownCast( (vtkObjectBase *) a0->native.GetPointer() ); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SameTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); int r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SameTree( (vtkHyperTreeCursor *) a0->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SetGrid(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeGridWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeGridWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeGridWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetGrid( (vtkHyperTreeGrid *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SetTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetTree( (vtkHyperTree *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::ToChild(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->ToChild( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::ToParent(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->ToParent(); } void VtkHyperTreeGridCursorWrap::ToRoot(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->ToRoot(); } void VtkHyperTreeGridCursorWrap::ToSameVertex(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->ToSameVertex( (vtkHyperTreeCursor *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); }
31.833572
111
0.720119
axkibe
5e68fb61f2d11b469386d6daaba624edc2026233
2,146
cpp
C++
src/ml/neural_net/compute_context.cpp
Bpowers4/turicreate
73dad213cc1c4f74337b905baea2b3a1e5a0266c
[ "BSD-3-Clause" ]
1
2020-05-25T22:17:48.000Z
2020-05-25T22:17:48.000Z
src/ml/neural_net/compute_context.cpp
Bpowers4/turicreate
73dad213cc1c4f74337b905baea2b3a1e5a0266c
[ "BSD-3-Clause" ]
3
2022-02-15T04:42:24.000Z
2022-03-12T01:05:15.000Z
src/ml/neural_net/compute_context.cpp
Bpowers4/turicreate
73dad213cc1c4f74337b905baea2b3a1e5a0266c
[ "BSD-3-Clause" ]
null
null
null
/* Copyright © 2018 Apple Inc. All rights reserved. * * Use of this source code is governed by a BSD-3-clause license that can * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause */ #include <ml/neural_net/compute_context.hpp> #include <algorithm> #include <map> namespace turi { namespace neural_net { namespace { std::multimap<int, compute_context::registration*> &get_registry() { static auto *registry = new std::multimap<int, compute_context::registration*>; return *registry; } } // namespace compute_context::registration::registration(int priority, factory factory_fn, factory tf_factory_fn) : priority_(priority), factory_fn_(std::move(factory_fn)), tf_factory_fn_(std::move(tf_factory_fn)) { // No mutex is required if this is only used at static init time... get_registry().emplace(priority, this); } compute_context::registration::~registration() { // No mutex is required if this is only used at static init time... std::pair<const int, compute_context::registration *> needle(priority_, this); auto it = std::find(get_registry().begin(), get_registry().end(), needle); if (it != get_registry().end()) { get_registry().erase(it); } } // static std::unique_ptr<compute_context> compute_context::create_tf() { // Return the tensorflow compute context only. std::unique_ptr<compute_context> result; auto it = get_registry().begin(); while (result == nullptr && it != get_registry().end()) { result = it->second->create_tensorflow_context(); ++it; } return result; } // static std::unique_ptr<compute_context> compute_context::create() { // Return the first compute context created by any factory function, in // ascending order by priority. std::unique_ptr<compute_context> result; auto it = get_registry().begin(); while (result == nullptr && it != get_registry().end()) { result = it->second->create_context(); ++it; } return result; } compute_context::~compute_context() = default; } // namespace neural_net } // namespace turi
29.39726
86
0.682665
Bpowers4
5e6945471a919e1b986c4a664041b61b200f2a45
482
hpp
C++
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
#pragma once #include "header_ressources.hpp" #include "cl_CustomObject.hpp" class CustomCube : public CustomObject { protected: float fRot; public: CustomCube(CustomForme* _Forme); CustomCube(CustomForme* _Forme, D3DXVECTOR3& _TranVector); CustomCube(CustomForme* _Forme, D3DXVECTOR3& _TranVector, D3DXVECTOR3& _LocalRotVector, D3DXVECTOR3& _GlobalRotVector); ~CustomCube(); virtual void GeoActions(); virtual void SpecialActions(); virtual void ObjectRendering(); };
21.909091
120
0.786307
RSF-Deus
5e6a0b26f6059777554956dff53f4f18f709f3b3
476
hpp
C++
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
6
2019-03-06T23:54:01.000Z
2020-08-24T09:18:33.000Z
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
6
2019-03-07T00:31:48.000Z
2021-01-10T13:28:41.000Z
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
8
2019-03-07T00:08:43.000Z
2021-05-13T12:14:08.000Z
#ifndef ALGORITHM_DTOCS_HPP_GF3U3S3CO1 #define ALGORITHM_DTOCS_HPP_GF3U3S3CO1 #include "algorithm_distance_map.hpp" namespace prhlt { class Algorithm_DTOCS: public Algorithm_Distance_Map{ public: Algorithm_DTOCS(cv::Mat &ex_image); protected: virtual float calculate_neighbour_value(int r1,int c1, int r2, int c2); int calculate_grey_gradient(int r1,int c1, int r2, int c2); }; } #endif /* end of include guard*/
28
83
0.701681
jkloe
5e6a3bc05fe12d35beda603fa15212b5f1a4f4b1
8,231
hh
C++
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
3
2019-07-03T14:03:31.000Z
2021-12-19T10:18:49.000Z
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
6
2020-02-17T12:01:31.000Z
2021-12-09T22:02:36.000Z
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
2
2020-12-03T04:41:18.000Z
2021-01-11T21:44:42.000Z
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the library KASKADE 7 */ /* see http://www.zib.de/projects/kaskade7-finite-element-toolbox */ /* */ /* Copyright (C) 2013-2015 Zuse Institute Berlin */ /* */ /* KASKADE 7 is distributed under the terms of the ZIB Academic License. */ /* see $KASKADE/academic.txt */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef ERROREST_HH #define ERROREST_HH #include <vector> #include <boost/fusion/include/for_each.hpp> #include <boost/utility.hpp> #include <boost/multi_array.hpp> namespace Kaskade { /** * \ingroup refcrit * \brief Base class for refinement criteria. */ class RefinementCriterion { public: /** * \brief Computes the thresholds for refinement. * \param normalizedErrors a twodimensional array containing the normalized error contribution for each cell and * each variable, i.e. normalizedErrors[i][j] contains the error contribution of cell i * to the error in variable j, divided by the tolerance, such that the sum over i * should not exceed one (for acceptance) * \returns an array containing a threshold value such that any cell i for which normalizedErrors[i][j] > return[j] * for any j is to be refined, or an empty array in case all variables are accurate enough */ std::vector<double> threshold(boost::multi_array<double,2> const& normalizedErrors) const; private: virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const = 0; }; /** * \ingroup refcrit * \brief Refines the grid according to the normalized errors and the given thresholds. */ template <class GridManager, class GridView> void markAndRefine(GridManager& gridManager, GridView const& gridView, boost::multi_array<double,2> const& normalizedErrors, std::vector<double> const& threshold) { auto end = gridView.template end<0>(); for (auto ci=gridView.template begin<0>(); ci!=end; ++ci) { auto idx = gridView.indexSet().index(*ci); for (int j=0; j<threshold.size(); ++j) if (normalizedErrors[idx][j] >= threshold[j]) { gridManager.mark(1,*ci); break; } } gridManager.adaptAtOnce(); } /** * \ingroup refcrit * \brief Fixed fraction refinement criterion. * Determines the refinement thresholds such that at least the specified fraction of the cells are * marked for refinement. This ensures that not too few cells are marked, which could lead to very many * refinement iterations, but may lead to erratic refinement if there are indeed only very local refinements * necessary. * * In very rare circumstances (namely when there are many cells with exactly the same local error estimate), * much more cells than the required fraction can be marked for refinement. */ class FixedFractionCriterion: public RefinementCriterion { public: FixedFractionCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Bulk refinement criterion. * Determines the refinement thresholds such that approximately the specified fraction of the total error * is removed by the refinement (under the unrealistically optimistic assumption that refinement eliminates * the error completely in that cell - in reality, it's only reduced by a certain factor, so the total * error is reduced somewhat less). */ class BulkCriterion: public RefinementCriterion { public: BulkCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Max value refinement criterion. * Determines the refinement thresholds such that all cells with an error contribution exceeding a certain * fraction of the maximum error contribution are refined. */ class MaxValueCriterion: public RefinementCriterion { public: MaxValueCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Babuska-Rheinboldt refinement criterion. * Determines the refinement thresholds such that all cells with an error contribution exceeding the * expected error contribution of the worst cell \em after refinement will be marked. This tends to * equilibrate the error contributions quite fast. * * Note that the local convergence order should be estimated (important in the vicinity of singularities) * but is here assumed to be the fixed specified order. */ class BabuskaRheinboldtCriterion: public MaxValueCriterion { public: BabuskaRheinboldtCriterion(std::vector<int> const& order); private: std::vector<int> order; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; //--------------------------------------------------------------------------------------------- namespace ErrorestDetail { template <class GroupByCell> struct GroupedSummationCollector { GroupedSummationCollector(GroupByCell const& group_): group(group_) {} template <class Cell> int integrationOrder(Cell const& , int shapeFunctionOrder) const { return shapeFunctionOrder; } // need to define this because boost::multi_array does not perform assignment if the arrays have // different shape. GroupedSummationCollector<GroupByCell>& operator=(GroupedSummationCollector<GroupByCell> const& c) { auto shape = c.sums.shape(); sums.resize(boost::extents[shape[0]][shape[1]]); sums = c.sums; group = c.group; return *this; } template <class CellPointer, class Index, class Sequence> void operator()(CellPointer const& ci, Index idx, double weight, Sequence const& x) { if (sums.num_elements()==0) sums.resize(boost::extents[group.nGroups][boost::fusion::size(x)]); int i = 0; // for_each needs constant functor... boost::fusion::for_each(x,Add(sums,group[idx],i,weight)); } void join(GroupedSummationCollector<GroupByCell> const& c) { auto shape = c.sums.shape(); auto myshape = sums.shape(); if(c.sums.num_elements()==0) return; if (sums.num_elements()==0 || myshape[0]!=shape[0] || myshape[1]!=shape[1]) // not yet initialized { sums.resize(boost::extents[shape[0]][shape[1]]); sums = c.sums; // -> do a simple copy } else for (size_t i=0; i<shape[0]; ++i) // otherwise add up for (size_t j=0; j<shape[1]; ++j) sums[i][j] += c.sums[i][j]; } boost::multi_array<double,2> sums; private: GroupByCell group; struct Add { Add(boost::multi_array<double,2>& sums_, int idx_, int& i_, double w_): sums(sums_), idx(idx_), i(i_) , w(w_) {} template <class T> void operator()(T const& t) const { sums[idx][i++] += w*t; } private: boost::multi_array<double,2>& sums; int idx; int& i; double w; }; }; } } #endif
36.582222
127
0.598226
chenzongxiong
5e6a9a59f2c3f9c63495574ae5fed6034f7a0a04
59
cpp
C++
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
1
2018-12-17T09:33:54.000Z
2018-12-17T09:33:54.000Z
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
null
null
null
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
null
null
null
#include "sceneGraph.h" namespace sceneGraphSys { };
5.363636
23
0.677966
LeeCIT
5e6e59d85c62b87c3d5845a779a46568124c8e0a
1,610
cpp
C++
main.cpp
jrandiny/Sudoku-Dagozilla
2de1023947f5de1e5bfcf891dc17f8e223e0041b
[ "MIT" ]
1
2018-12-19T15:50:00.000Z
2018-12-19T15:50:00.000Z
main.cpp
jrandiny/Sudoku-Dagozilla
2de1023947f5de1e5bfcf891dc17f8e223e0041b
[ "MIT" ]
null
null
null
main.cpp
jrandiny/Sudoku-Dagozilla
2de1023947f5de1e5bfcf891dc17f8e223e0041b
[ "MIT" ]
null
null
null
#include "Node.h" #include "Board.h" #include "Reader.h" #include "Solver.h" #include <iostream> using namespace std; int main(){ string jenis_input; Reader read; Board papan; cout<<"Program Menyelesaikan Hyper Sudoku"<<endl<<"----------------------------------"<<endl<<endl; while(true){ cout<<"Pilih cara input(Manual/File)?"<<endl; cout<<"Pilihan Anda : "; cin>>jenis_input; //ubah ke lowercase for(int i = 0;i<jenis_input.length();i++){ jenis_input[i]=tolower(jenis_input[i]); } //Algoritma input manual dan cek per baris kalo kelebihan input ngulang input baris tersebut if(jenis_input=="manual"){ cout<<"Silahkan ketikan masukan anda di bawah ini (1 baris 9 angka tanpa spasi) :"<<endl; //Board papan(read.baca()); papan.setBoard(read.baca()); break; }else if(jenis_input=="file"){ cout<<"Nama File : "; string namaFile; cin>>namaFile; papan.setBoard(read.bacaFile(namaFile)); break; } else{ cout<<"Pilihannya hanya Manual dan File"<<endl; cout<<endl; } } cout<<endl<<"Ini masukkan Anda"<<endl; papan.print(); cout<<"Mencoba menyelesaikan"<<endl; Solver solverr(papan); if(solverr.solve()){ cout<<"SELESAI"<<endl; }else{ cout<<"GAGAL"<<endl; } solverr.getBoard().print(); while(true){ cout<<"Ingin simpan hasil ke file ?(y/n)"<<endl; char input; cin>>input; if(tolower(input)=='y'){ string namaFile; cout<<"Nama file : "; cin>>namaFile; solverr.getBoard().printSave(namaFile); break; }else if(tolower(input)=='n'){ break; } cout<<"Input tidak valid"<<endl; } return 0; }
18.941176
100
0.632919
jrandiny
5e6ebaa91f7041a28b381a7f3c0a778d68693894
4,242
cpp
C++
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
17
2018-07-04T14:06:31.000Z
2021-11-11T20:43:38.000Z
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
null
null
null
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
1
2019-12-26T12:59:00.000Z
2019-12-26T12:59:00.000Z
#include "MeasurementProvider.h" #define SHT21_TRIGGER_TEMP_MEASURE_NOHOLD 0xF3 #define SHT21_TRIGGER_HUMD_MEASURE_NOHOLD 0xF5 #define SHT21_TRIGGER_TEMP_MEASURE_HOLD 0xE3 #define SHT21_TRIGGER_HUMD_MEASURE_HOLD 0xE5 MeasurementProvider::MeasurementProvider( uint8_t tempSensAddr, uint8_t lightSensAddr, float analogVCCToRealCoeficient ): tempSensAddress(tempSensAddr), lightSensor(lightSensAddr), analogVCCToRealCoeficient(analogVCCToRealCoeficient) { } bool MeasurementProvider::begin() { bool lsStatus = lightSensor.begin(BH1750::ONE_TIME_HIGH_RES_MODE); //goes to sleep after measurement #ifdef USE_BMP280 bool bmpStatus = bmp.begin(0x76); return lsStatus && bmpStatus; #else return lsStatus; #endif } const MeasurementsData& MeasurementProvider::getCurrentMeasurements(){ return data; } bool MeasurementProvider::doMeasurements() { //measure battery voltage data.voltageRaw = analogRead(A0); data.voltage = analogToVoltage(data.voltageRaw); #ifdef USE_SHT30 //SHT-30 measure temp and humidity byte tempMeasureRes; int retryMeasurement = 3; do { retryMeasurement--; tempMeasureRes = measureTempSTH30(); if (tempMeasureRes != 0) { Serial.println(F("Unable to measure temperature")); Serial.println(tempMeasureRes); delay(100); } } while (tempMeasureRes != 0 && retryMeasurement > 0); if (tempMeasureRes != 0) { return false; } #endif #ifdef USE_SHT21 //SHT21 data.temperature = 0; data.humidity = 0; measureTempSTH21(); #endif #ifdef USE_BMP280 // measur pressure data.bmpTemp = bmp.readTemperature(); data.pressure = bmp.readPressure(); #else data.bmpTemp = 0; data.pressure = 0; #endif // measure lipht data.lightLevel = lightSensor.readLightLevel(); return true; } #ifdef USE_SHT30 byte MeasurementProvider::measureTempSTH30() { unsigned int data[6]; Wire.beginTransmission(tempSensAddress); // measurement command -> one shot measurement, clock stretching, high repeatability Wire.write(0x2C); Wire.write(0x06); uint8_t wireResult = Wire.endTransmission(); if (wireResult != 0) { return wireResult; } delay(500); // Request 6 bytes of data Wire.requestFrom(tempSensAddress, 6); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc for (int i=0;i<6;i++) { data[i]=Wire.read(); }; delay(50); if (Wire.available() != 0) { return 20; } // Convert the data this->data.temperature = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45; this->data.humidity = ((((data[3] * 256.0) + data[4]) * 100) / 65535.0); return 0; } #endif #ifdef USE_SHT21 uint8_t MeasurementProvider::measureTempSTH21() { // Convert the data this->data.humidity = (-6.0 + 125.0 / 65536.0 * readFloatSHT21(SHT21_TRIGGER_HUMD_MEASURE_HOLD)); this->data.temperature = (-46.85 + 175.72 / 65536.0 * readFloatSHT21(SHT21_TRIGGER_TEMP_MEASURE_HOLD)); return 0; } float MeasurementProvider::readFloatSHT21(uint8_t command) { uint16_t result; Wire.beginTransmission(tempSensAddress); Wire.write(command); Wire.endTransmission(); delay(100); Wire.requestFrom(tempSensAddress, 3); while(Wire.available() < 3) { delay(10); } // return result result = ((Wire.read()) << 8); result += Wire.read(); result &= ~0x0003; // clear two low bits (status bits) return (float)result; } #endif float MeasurementProvider::analogToVoltage(int analog) { return analog * analogVCCToRealCoeficient; } void MeasurementsData::printToSerial() const { Serial.print(F("temp: ")); Serial.print(temperature); Serial.print(F(" (")); Serial.print(bmpTemp); Serial.print(F(") ")); Serial.print(F(", hum: ")); Serial.print(humidity); Serial.print(F(", press: ")); Serial.print(pressure); Serial.print(F(", vcc: ")); Serial.print(voltage); Serial.print(F(", vcc raw: ")); Serial.print(voltageRaw); Serial.print(F(", light: ")); Serial.print(lightLevel); }
26.679245
107
0.657944
josefadamcik
5e6f3082b05ef40505cc3d1ddc8961c2d4d021e3
10,707
hpp
C++
multidrone_kml_parser/include/multidrone_kml_parser/geographic_to_cartesian.hpp
grvcTeam/multidrone_planning
421a7d81a3417cdc6bcb690d3d88bb4e9d6b6638
[ "MIT" ]
12
2020-07-02T07:00:35.000Z
2021-12-08T07:59:41.000Z
multidrone_kml_parser/include/multidrone_kml_parser/geographic_to_cartesian.hpp
grvcTeam/multidrone_planning
421a7d81a3417cdc6bcb690d3d88bb4e9d6b6638
[ "MIT" ]
null
null
null
multidrone_kml_parser/include/multidrone_kml_parser/geographic_to_cartesian.hpp
grvcTeam/multidrone_planning
421a7d81a3417cdc6bcb690d3d88bb4e9d6b6638
[ "MIT" ]
2
2021-01-01T06:35:22.000Z
2021-04-24T09:54:21.000Z
/** * MULTIDRONE Project: * * Geographic to Cartesian coordinate conversion and vice versa, with an intermediate conversion to UTM. * * This library suppose that the path of the robot cannot cross more than 2 different UTM zones. * */ #ifndef GEOGRAPHIC_TO_CARTESIAN #define GEOGRAPHIC_TO_CARTESIAN #include <math.h> #include <algorithm> #include <stdlib.h> #include <geometry_msgs/Point32.h> #include <geographic_msgs/GeoPoint.h> #include <geodesy/utm.h> // IMPORTANT TO INSTALL GEODESY: sudo apt-get install ros-kinetic-geographic-info // #define USING_IN_PYTHON // #ifdef USING_IN_PYTHON // #include <boost/python.hpp> // #endif namespace multidrone { inline geometry_msgs::Point32 geographic_to_cartesian (const geographic_msgs::GeoPoint& _actual_coordinate_geo, const geographic_msgs::GeoPoint& _origin_geo) { geodesy::UTMPoint actual_coordinate_UTM(_actual_coordinate_geo); // Conversion from geographic coordinates to UTM. geodesy::UTMPoint origin_UTM(_origin_geo); // Conversion from geographic coordinates to UTM. geometry_msgs::Point32 actual_coordinate_cartesian; // Cartesian coordinate that this function will return. // The problem with UTM is that if there are coordinates in more than one zone, it's difficult to merge the coordinates of the different zones. // This is because each zone has 6 degrees of longitude, and the width in meters of the zone is variable from equator to the poles. // Something similar when the coordinates are in different hemispheres, separated by the equator. Each hemisphere has a different origin for the y axis. // These are the reasons why the x and y assignation for the Cartesian conversion isn't a simple UTM substraction. // Assignating "actual_coordinate_cartesian.x" is tricky when the actual coordinate and the origin of the Cartesian coordinates are on different zones. if ( int(actual_coordinate_UTM.zone)==60 && origin_UTM.zone==1 ) { // Coordinate and origin separated by the +-180º longitude geographic_msgs::GeoPoint geo_180_w; geographic_msgs::GeoPoint geo_180_e; geo_180_w.longitude = 179.9999999; geo_180_w.latitude = _actual_coordinate_geo.latitude; geo_180_w.altitude = _actual_coordinate_geo.altitude; geo_180_e.longitude = -179.9999999; geo_180_e.latitude = _actual_coordinate_geo.latitude; geo_180_e.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_180_w(geo_180_w); geodesy::UTMPoint utm_180_e(geo_180_e); actual_coordinate_cartesian.x = actual_coordinate_UTM.easting - utm_180_w.easting + utm_180_e.easting - origin_UTM.easting; // Transformation of the x coordinate taking into account the different zones. " - utm_180_w.easting + utm_180_e.easting " computes the x step in both sides of the border longitude. } else if ( origin_UTM.zone==60 && int(actual_coordinate_UTM.zone)==1 ) { // Coordinate and origin separated by the +-180º longitude geographic_msgs::GeoPoint geo_180_w; geographic_msgs::GeoPoint geo_180_e; geo_180_w.longitude = 179.9999999; geo_180_w.latitude = _actual_coordinate_geo.latitude; geo_180_w.altitude = _actual_coordinate_geo.altitude; geo_180_e.longitude = -179.9999999; geo_180_e.latitude = _actual_coordinate_geo.latitude; geo_180_e.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_180_w(geo_180_w); geodesy::UTMPoint utm_180_e(geo_180_e); actual_coordinate_cartesian.x = actual_coordinate_UTM.easting - utm_180_e.easting + utm_180_w.easting - origin_UTM.easting; // Transformation of the x coordinate taking into account the different zones. " - utm_180_w.easting + utm_180_e.easting " computes the x step in both sides of the border longitude. } else if ( int(actual_coordinate_UTM.zone) < origin_UTM.zone ) { int quotient_from_int_division = (int) ( std::max(std::abs(_actual_coordinate_geo.longitude),std::abs(_origin_geo.longitude))/6 ); // int division of the max longitude (absolute, without sign) double border_longitude = quotient_from_int_division * 6.0 *pow(-1,std::signbit(std::max(_actual_coordinate_geo.longitude,_origin_geo.longitude))); // border_longitude = quotient_from_int_division * 6 *(-1)^(1 if negative longitude, 0 if positive) geographic_msgs::GeoPoint geo_w; geographic_msgs::GeoPoint geo_e; geo_w.longitude = border_longitude - 0.0000001; geo_w.latitude = _actual_coordinate_geo.latitude; geo_w.altitude = _actual_coordinate_geo.altitude; geo_e.longitude = border_longitude + 0.0000001; geo_e.latitude = _actual_coordinate_geo.latitude; geo_e.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_w(geo_w); geodesy::UTMPoint utm_e(geo_e); actual_coordinate_cartesian.x = actual_coordinate_UTM.easting - utm_w.easting + utm_e.easting - origin_UTM.easting; // Transformation of the x coordinate taking into account the different zones. " - utm_w.easting + utm_e.easting " computes the x step in both sides of the border longitude. } else if ( origin_UTM.zone < int(actual_coordinate_UTM.zone) ) { int quotient_from_int_division = (int) ( std::max(std::abs(_actual_coordinate_geo.longitude),std::abs(_origin_geo.longitude))/6 ); // int division of the max longitude (absolute, without sign) double border_longitude = quotient_from_int_division * 6.0 *pow(-1,std::signbit(std::max(_actual_coordinate_geo.longitude,_origin_geo.longitude))); // border_longitude = quotient_from_int_division * 6 *(-1)^(1 if negative longitude, 0 if positive) geographic_msgs::GeoPoint geo_w; geographic_msgs::GeoPoint geo_e; geo_w.longitude = border_longitude - 0.0000001; geo_w.latitude = _actual_coordinate_geo.latitude; geo_w.altitude = _actual_coordinate_geo.altitude; geo_e.longitude = border_longitude + 0.0000001; geo_e.latitude = _actual_coordinate_geo.latitude; geo_e.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_w(geo_w); geodesy::UTMPoint utm_e(geo_e); actual_coordinate_cartesian.x = actual_coordinate_UTM.easting - utm_e.easting + utm_w.easting - origin_UTM.easting; // Transformation of the x coordinate taking into account the different zones. " - utm_w.easting + utm_e.easting " computes the x step in both sides of the border longitude. } else { // The actual coordinate is in the same zone that the origin (the first station). This is the normal situation, the assigntation of the x axis value is trivial (simple subtraction). actual_coordinate_cartesian.x = actual_coordinate_UTM.easting -origin_UTM.easting; } // Assignating "actual_coordinate_cartesian.y" is also tricky when the actual coordinate and the origin of the Cartesian coordinates are on different hemispheres: if ( origin_UTM.band=='N' && actual_coordinate_UTM.band=='M' ) { // Coordinate and origin separated by the 0º latitude geographic_msgs::GeoPoint geo_0_n; geographic_msgs::GeoPoint geo_0_s; geo_0_n.longitude = _actual_coordinate_geo.longitude; geo_0_n.latitude = 0.0000001; geo_0_n.altitude = _actual_coordinate_geo.altitude; geo_0_s.longitude = _actual_coordinate_geo.longitude; geo_0_s.latitude = -0.0000001; geo_0_s.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_0_n(geo_0_n); geodesy::UTMPoint utm_0_s(geo_0_s); actual_coordinate_cartesian.y = actual_coordinate_UTM.northing - utm_0_s.northing + utm_0_n.northing - origin_UTM.northing; // Transformation of the y coordinate taking into account the different hemispheres. " - utm_0_s.northing + utm_0_n.northing " computes the y step in both sides of the equator. } else if ( actual_coordinate_UTM.band=='N' && origin_UTM.band=='M' ) { // Coordinate and origin separated by the 0º latitude geographic_msgs::GeoPoint geo_0_n; geographic_msgs::GeoPoint geo_0_s; geo_0_n.longitude = _actual_coordinate_geo.longitude; geo_0_n.latitude = 0.0000001; geo_0_n.altitude = _actual_coordinate_geo.altitude; geo_0_s.longitude = _actual_coordinate_geo.longitude; geo_0_s.latitude = -0.0000001; geo_0_s.altitude = _actual_coordinate_geo.altitude; geodesy::UTMPoint utm_0_n(geo_0_n); geodesy::UTMPoint utm_0_s(geo_0_s); actual_coordinate_cartesian.y = actual_coordinate_UTM.northing - utm_0_n.northing + utm_0_s.northing - origin_UTM.northing; // Transformation of the y coordinate taking into account the different hemispheres. " - utm_0_n.northing + utm_0_s.northing " computes the y step in both sides of the equator. } else { // The actual coordinate is in the same hemisphere that the origin (the first station). This is the normal situation, the assigntation of the y axis value is trivial (simple subtraction). actual_coordinate_cartesian.y = actual_coordinate_UTM.northing-origin_UTM.northing; } // Assignating "actual_coordinate_cartesian.z" is trivial always, simple subtraction. actual_coordinate_cartesian.z = actual_coordinate_UTM.altitude-origin_UTM.altitude; return actual_coordinate_cartesian; } // end geographic_to_cartesian inline geographic_msgs::GeoPoint cartesian_to_geographic (const geometry_msgs::Point32& _actual_coordinate_cartesian, const geographic_msgs::GeoPoint& _origin_geo) { geodesy::UTMPoint actual_coordinate_aux(_origin_geo); // Conversion from geographic coordinates to UTM. actual_coordinate_aux.easting += _actual_coordinate_cartesian.x; actual_coordinate_aux.northing += _actual_coordinate_cartesian.y; actual_coordinate_aux.altitude += _actual_coordinate_cartesian.z; // Convert to geographic coordinates and return the coordinate. This conversion is easier as it doesn't matter if the points are in different zones or hemispheres, but in that case the error increases if the points are very far from each other. return geodesy::toMsg (actual_coordinate_aux); } // end cartesian_to_geographic // #ifdef USING_IN_PYTHON // BOOST_PYTHON_MODULE(geographic_to_cartesian_and_vice_verse) { // using namespace boost::python; // def("geographic_to_cartesian", geographic_to_cartesian); // def("cartesian_to_geographic", cartesian_to_geographic); // } // #endif } // end namespace multidrone #endif // GEOGRAPHIC_TO_CARTESIAN
66.503106
313
0.74045
grvcTeam
5e70cdde2f80b822ff82028972a0a5be883e1d68
9,483
hpp
C++
algos.hpp
sg0/neve
d68f2b4740f30a1cab5412bf32c33db515844955
[ "BSD-3-Clause" ]
1
2021-06-20T19:16:04.000Z
2021-06-20T19:16:04.000Z
algos.hpp
sg0/neve
d68f2b4740f30a1cab5412bf32c33db515844955
[ "BSD-3-Clause" ]
null
null
null
algos.hpp
sg0/neve
d68f2b4740f30a1cab5412bf32c33db515844955
[ "BSD-3-Clause" ]
2
2021-06-28T17:05:18.000Z
2022-03-20T23:39:13.000Z
// *********************************************************************** // // NEVE // // *********************************************************************** // // Copyright (2019) Battelle Memorial Institute // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // ************************************************************************ #pragma once #ifndef ALGOS_HPP #define ALGOS_HPP #include <iostream> #include <algorithm> #include <vector> #include <string> #include <fstream> #include <sstream> #include <climits> #include <array> #include <unordered_map> #include "utils.hpp" // This file will contain algorithm implementations to be run on // shared-memory or serial, using a compact CSR defined in // graph.hpp (which is essentially a subset of the Graph class) // maximal edge graph matching // https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8820975 class MaxEdgeMatching { public: MaxEdgeMatching(CSR* g): g_(g), edge_active_(0), mate_(0), D_(0), M_(0) { nv_ = g_->get_nv(); ne_ = g_->get_ne(); edge_active_.resize(ne_, '1'); mate_.resize(nv_, -1); } ~MaxEdgeMatching() { edge_active_.clear(); D_.clear(); M_.clear(); mate_.clear(); } MaxEdgeMatching(const MaxEdgeMatching &other) = delete; MaxEdgeMatching& operator=(const MaxEdgeMatching& d) = delete; char const& get_active_edge(GraphElem const index) const { return edge_active_[index]; } char& get_active_edge(GraphElem const index) { return edge_active_[index]; } // #edges in matched set GraphElem get_mcount() const { GraphElem count = 0; for (GraphElem i = 0; i < M_.size(); i++) if ((M_[i].ij_[0] != -1) && (M_[i].ij_[1] != -1)) count++; return count; } void print_M() const { std::cout << "Matched vertices: " << std::endl; for (GraphElem i = 0; i < M_.size(); i++) { if ((M_[i].ij_[0] != -1) && (M_[i].ij_[1] != -1)) { std::cout << M_[i].ij_[0] << " ---- " << M_[i].ij_[1] << std::endl; } } } void flatten_M(std::vector<GraphElem>& matv) const { for (GraphElem i = 0; i < M_.size(); i++) { if ((M_[i].ij_[0] != -1) && (M_[i].ij_[1] != -1)) { matv.push_back(M_[i].ij_[0]); matv.push_back(M_[i].ij_[1]); } } } // if mate[mate[v]] == v then // we're good void check_results() { bool success = true; for (GraphElem i = 0; i < M_.size(); i++) { if ((M_[i].ij_[0] != -1) && (M_[i].ij_[1] != -1)) { if ((mate_[mate_[M_[i].ij_[0]]] != M_[i].ij_[0]) || (mate_[mate_[M_[i].ij_[1]]] != M_[i].ij_[1])) { std::cout << "\033[1;31mValidation FAILED.\033[0m" << std::endl; std::cout << "mate_[mate_[" << M_[i].ij_[0] << "]] != " << M_[i].ij_[0] << std::endl; std::cout << "mate_[mate_[" << M_[i].ij_[1] << "]] != " << M_[i].ij_[1] << std::endl; success = false; break; } } } if (success) std::cout << "\033[1;32mValidation SUCCESS.\033[0m" << std::endl; } inline void heaviest_edge_unmatched(GraphElem v, Edge& max_edge, GraphElem x = -1) { GraphElem e0, e1; g_->edge_range(v, e0, e1); for (GraphElem e = e0; e < e1; e++) { Edge const& edge = g_->get_edge(e); char const& active = get_active_edge(e); if (active == '1') { if (edge.tail_ == x) continue; if ((mate_[edge.tail_] == -1) || (mate_[mate_[edge.tail_]] != edge.tail_)) { if (edge.weight_ > max_edge.weight_) max_edge = edge; // break tie using vertex index if (edge.weight_ == max_edge.weight_) { if (edge.tail_ > max_edge.tail_) max_edge = edge; } } } } } // check if mate[x] = v and mate[v] != x // if yes, compute mate[x] inline void update_mate(GraphElem v) { GraphElem e0, e1; g_->edge_range(v, e0, e1); for (GraphElem e = e0; e < e1; e++) { Edge const& edge = g_->get_edge(e); GraphElem const& x = edge.tail_; // check if vertex is already matched auto result = std::find_if(M_.begin(), M_.end(), [&](EdgeTuple const& et) { return (((et.ij_[0] == v) || (et.ij_[1] == v)) && ((et.ij_[0] == x) || (et.ij_[1] == x))); }); // mate[x] == v and (v,x) not in M if ((mate_[x] == v) && (result == std::end(M_))) { Edge x_max_edge; heaviest_edge_unmatched(x, x_max_edge, v); GraphElem y = mate_[x] = x_max_edge.tail_; if (y == -1) // if x has no neighbor other than v continue; if (mate_[y] == x) // matched { D_.push_back(x); D_.push_back(y); M_.emplace_back(x, y, x_max_edge.weight_); deactivate_edge(x, y); } } } } // deactivate edge x -- y inline void deactivate_edge(GraphElem x, GraphElem y) { GraphElem e0, e1; g_->edge_range(x, e0, e1); for (GraphElem e = e0; e < e1; e++) { Edge const& edge = g_->get_edge(e); char& active = get_active_edge(e); if (edge.tail_ == y) { active = '0'; break; } } } // maximal edge matching void match() { // phase #1: compute max edge for every vertex for (GraphElem v = 0; v < nv_; v++) { Edge max_edge; heaviest_edge_unmatched(v, max_edge); GraphElem u = mate_[v] = max_edge.tail_; // v's mate if (u != -1) { // is mate[u] == v? if (mate_[u] == v) // matched { D_.push_back(u); D_.push_back(v); M_.emplace_back(u, v, max_edge.weight_); deactivate_edge(v, u); deactivate_edge(u, v); } } } // phase 2: update matching and match remaining vertices while(1) { if (D_.size() == 0) break; GraphElem v = D_.back(); D_.pop_back(); update_mate(v); } } private: CSR* g_; GraphElem nv_, ne_; std::vector<char> edge_active_; std::vector<GraphElem> mate_, D_; std::vector<EdgeTuple> M_; }; #endif
33.273684
103
0.452599
sg0
5e763ed5f586408e8ff628f829660ee724f3b6f9
4,076
cpp
C++
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
1
2022-01-28T04:54:52.000Z
2022-01-28T04:54:52.000Z
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
null
null
null
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
1
2022-01-28T04:54:57.000Z
2022-01-28T04:54:57.000Z
#include "find.hpp" #include <algorithm> #include <iostream> #include <vector> #include <cstdio> #include <chrono> #include <numeric> #include <benchmark/benchmark.h> static std::vector<int> build_ordered_vector(size_t n) { std::vector<int> values(n); std::iota(values.begin(), values.end(), 1); return values; } #define input_size \ Arg(1 << 2) \ ->Arg(1 << 4) \ ->Arg(1 << 8) \ ->Arg(1 << 9) \ ->Arg(1 << 10) \ ->Arg(1 << 11) \ ->Arg(1 << 12) \ ->Arg(1 << 13) \ ->Arg(1 << 14) \ ->Arg(1 << 15) \ ->Arg(1 << 16) \ ->Arg(1 << 17) \ ->Arg(1 << 18) \ ->Arg(1 << 19) \ ->Arg(1 << 20) \ ->Arg(1 << 21) \ ->Arg(1 << 22) \ ->Arg(1 << 23) \ ->Arg(1 << 24) \ #define declare_benchmark(impl) \ static void benchmark_ ## impl(benchmark::State& state) \ { \ const size_t n = state.range(0); \ const std::vector<int> values = build_ordered_vector(n); \ \ for (auto _ : state) \ benchmark::DoNotOptimize \ (find_int_ ## impl(values.back(), values.data(), n)); \ } \ \ BENCHMARK(benchmark_ ## impl)->input_size declare_benchmark(c); declare_benchmark(c_unrolled_8); declare_benchmark(cpp); declare_benchmark(sse2); static std::chrono::milliseconds now() { return std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::steady_clock::now().time_since_epoch()); } static int measure(int n) { std::vector<int> values(n); std::iota(values.begin(), values.end(), 1); const std::chrono::milliseconds start = now(); const size_t p_c = find_int_c(values.back(), values.data(), n); const std::chrono::milliseconds end_c = now(); const size_t p_c_unrolled = find_int_c_unrolled_8(values.back(), values.data(), n); const std::chrono::milliseconds end_c_unrolled = now(); const size_t p_cpp = find_int_cpp(values.back(), values.data(), n); const std::chrono::milliseconds end_cpp = now(); const size_t p_sse2 = find_int_sse2(values.back(), values.data(), n) ; const std::chrono::milliseconds end_sse2 = now(); std::cout << "C: " << (end_c - start).count() << " ms., " << "C unrolled: " << (end_c_unrolled - end_c).count() << " ms., " << "C++: " << (end_cpp - end_c_unrolled).count() << " ms., " << "SSE2: " << (end_sse2 - end_cpp).count() << " ms.\n"; if (p_c_unrolled != p_sse2) { std::cerr << "Mismatch: c unrolled -> " << p_c_unrolled << ", sse2 -> " << p_sse2 << '\n'; return 1; } if (p_cpp != p_sse2) { std::cerr << "Mismatch: c++ -> " << p_cpp << ", sse2 -> " << p_sse2 << '\n'; return 1; } if (p_c != p_sse2) { std::cerr << "Mismatch: c -> " << p_c << ", sse2 -> " << p_sse2 << '\n'; return 1; } return 0; } int main(int argc, char** argv) { if (argc == 2) { const int n = atoi(argv[1]); if (n > 0) return measure(n); } benchmark::Initialize(&argc, argv); benchmark::RunSpecifiedBenchmarks(); benchmark::Shutdown(); return 0; }
31.114504
77
0.418302
j-jorge
5e765b2cb378fd461aec047ec77d0e03dfdc43c1
3,256
cpp
C++
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
/*======================================================================= Copyright (c) 2018 Marcelo Kallmann. This software is distributed under the Apache License, Version 2.0. All copies must contain the full copyright notice licence.txt located at the base folder of the distribution. =======================================================================*/ # include <stdlib.h> # include <sig/gs_string.h> # include <sigogl/ws_run.h> # include <sigogl/ws_window.h> # include <sigogl/ws_osinterface.h> //===================================== xx ================================================= struct SwTimerData { double interval; double lasttime; WsWindow* window; void (*callback) (void*); union { void* udata; int evid; }; }; static GsArray<SwTimerData> Timers; static int NumTimers=0; static double Time0=0; static double TimeCur=0; void ws_check_timers () { TimeCur = gs_time()-Time0; for ( int i=0; i<NumTimers; i++ ) { if ( TimeCur-Timers[i].lasttime > Timers[i].interval ) { if ( Timers[i].callback ) { Timers[i].callback ( Timers[i].udata ); } else { WsWindow* win = Timers[i].window; if ( !win->minimized() ) win->timer ( Timers[i].evid ); } Timers[i].lasttime = TimeCur; } } } static void add_timer ( double interval, WsWindow* win, void(*cb)(void*) ) { if ( Time0==0 ) Time0 = gs_time(); SwTimerData& t = Timers.push(); t.interval = interval; t.lasttime = TimeCur; t.window = win; t.callback = cb; NumTimers++; } void ws_add_timer ( double interval, void(*cb)(void*), void* udata ) { add_timer ( interval, 0, cb ); Timers.top().udata = udata; } void ws_add_timer ( double interval, WsWindow* win, int ev ) { add_timer ( interval, win, 0 ); Timers.top().evid = ev; } void ws_remove_timer ( void(*cb)(void*) ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].callback == cb ) { Timers[i] = Timers.pop(); NumTimers--; return; } } } void ws_remove_timer ( WsWindow* win, int ev ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].window==win && Timers[i].evid==ev ) { Timers[i] = Timers.pop(); NumTimers--; return; } } } void ws_remove_timers ( WsWindow* win ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].window==win ) { Timers[i] = Timers.pop(); NumTimers--; i--; } } } void ws_run ( int sleepms ) { if ( sleepms>0 ) { while ( wsi_check() ) { gs_sleep ( sleepms ); if ( NumTimers ) ws_check_timers (); } } else if ( sleepms<0 ) { int n=sleepms; while ( wsi_check() ) { if ( NumTimers ) ws_check_timers (); if ( ++n==0 ) { gs_sleep(1); n=sleepms; } } } else { while ( wsi_check() ) { if ( NumTimers ) ws_check_timers (); } } } void ws_check ( int sleepms ) { static int counter=0; if ( sleepms>0 ) gs_sleep ( sleepms ); else if ( sleepms<0 && ++counter%-sleepms==0 ) gs_sleep(1); if ( NumTimers ) ws_check_timers (); if ( wsi_check()==0 ) exit(0); } int ws_fast_check () { if ( NumTimers ) ws_check_timers (); return wsi_check (); } void ws_exit ( int c ) { exit ( c ); } void ws_screen_resolution ( int& w, int& h ) { wsi_screen_resolution ( w, h ); } //================================ End of File =================================================
21.281046
96
0.561732
harsha336
5e77840110b226f16cf6e0d89ebbc9b186558d67
21,028
cpp
C++
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
#include "tile/tileManager.h" #include "data/tileSource.h" #include "map.h" #include "platform.h" #include "tile/tile.h" #include "tile/tileCache.h" #include "util/mapProjection.h" #include "view/view.h" #include "glm/gtx/norm.hpp" #include <algorithm> #define DBG(...) // LOGD(__VA_ARGS__) namespace Tangram { enum class TileManager::ProxyID : uint8_t { no_proxies = 0, child1 = 1 << 0, child2 = 1 << 1, child3 = 1 << 2, child4 = 1 << 3, parent = 1 << 4, parent2 = 1 << 5, }; struct TileManager::TileEntry { TileEntry(std::shared_ptr<Tile>& _tile) : tile(_tile), m_proxyCounter(0), m_proxies(0), m_visible(false) {} ~TileEntry() { clearTask(); } std::shared_ptr<Tile> tile; std::shared_ptr<TileTask> task; /* A Counter for number of tiles this tile acts a proxy for */ int32_t m_proxyCounter; /* The set of proxy tiles referenced by this tile */ uint8_t m_proxies; bool m_visible; bool isReady() { return bool(tile); } bool isInProgress() { return bool(task) && !task->isCanceled(); } bool isCanceled() { return bool(task) && task->isCanceled(); } bool needsLoading() { if (bool(tile)) { return false; } if (!task) { return true; } if (task->isCanceled()) { return false; } if (task->needsLoading()) { return true; } for (auto& subtask : task->subTasks()) { if (subtask->needsLoading()) { return true; } } return false; } // Complete task only when // - task still exists // - task has a tile ready // - tile has all rasters set bool completeTileTask() { if (bool(task) && task->isReady()) { for (auto& rTask : task->subTasks()) { if (!rTask->isReady()) { return false; } } task->complete(); tile = task->getTile(); task.reset(); return true; } return false; } void clearTask() { if (task) { for (auto& raster : task->subTasks()) { raster->cancel(); } task->subTasks().clear(); task->cancel(); task.reset(); } } /* Methods to set and get proxy counter */ int getProxyCounter() { return m_proxyCounter; } void incProxyCounter() { m_proxyCounter++; } void decProxyCounter() { m_proxyCounter = m_proxyCounter > 0 ? m_proxyCounter - 1 : 0; } void resetProxyCounter() { m_proxyCounter = 0; } bool setProxy(ProxyID id) { if ((m_proxies & static_cast<uint8_t>(id)) == 0) { m_proxies |= static_cast<uint8_t>(id); return true; } return false; } bool unsetProxy(ProxyID id) { if ((m_proxies & static_cast<uint8_t>(id)) != 0) { m_proxies &= ~static_cast<uint8_t>(id); return true; } return false; } /* Method to check whther this tile is in the current set of visible tiles * determined by view::updateTiles(). */ bool isVisible() const { return m_visible; } void setVisible(bool _visible) { m_visible = _visible; } }; TileManager::TileSet::TileSet(std::shared_ptr<TileSource> _source, bool _clientSource) : source(_source), clientTileSource(_clientSource) {} TileManager::TileSet::~TileSet() {} TileManager::TileManager(std::shared_ptr<Platform> platform, TileTaskQueue& _tileWorker) : m_workers(_tileWorker) { m_tileCache = std::unique_ptr<TileCache>(new TileCache(DEFAULT_CACHE_SIZE)); // Callback to pass task from Download-Thread to Worker-Queue m_dataCallback = TileTaskCb{[this, platform](std::shared_ptr<TileTask> task) { if (task->isReady()) { platform->requestRender(); } else if (task->hasData()) { m_workers.enqueue(task); } else { task->cancel(); } }}; } TileManager::~TileManager() { m_tileSets.clear(); } void TileManager::setTileSources(const std::vector<std::shared_ptr<TileSource>>& _sources) { m_tileCache->clear(); // Remove all (non-client datasources) sources and respective tileSets not present in the // new scene auto it = std::remove_if( m_tileSets.begin(), m_tileSets.end(), [&](auto& tileSet) { if (!tileSet.clientTileSource) { LOGN("Remove source %s", tileSet.source->name().c_str()); return true; } // Clear cache tileSet.tiles.clear(); return false; }); m_tileSets.erase(it, m_tileSets.end()); // add new sources for (const auto& source : _sources) { if (!source->generateGeometry()) { continue; } if (std::find_if(m_tileSets.begin(), m_tileSets.end(), [&](const TileSet& a) { return a.source->name() == source->name(); }) == m_tileSets.end()) { LOGN("add source %s", source->name().c_str()); m_tileSets.push_back({ source, false }); } else { LOGW("Duplicate named datasource (not added): %s", source->name().c_str()); } } } std::shared_ptr<TileSource> TileManager::getClientTileSource(int32_t sourceID) { for (const auto& tileSet : m_tileSets) { if (tileSet.clientTileSource && tileSet.source->id() == sourceID) { return tileSet.source; } } return nullptr; } void TileManager::addClientTileSource(std::shared_ptr<TileSource> _tileSource) { m_tileSets.push_back({ _tileSource, true }); } bool TileManager::removeClientTileSource(TileSource& _tileSource) { bool removed = false; for (auto it = m_tileSets.begin(); it != m_tileSets.end();) { if (it->source.get() == &_tileSource) { // Remove the textures for this tile source it->source->clearRasters(); // Remove the tile set associated with this tile source it = m_tileSets.erase(it); removed = true; } else { ++it; } } return removed; } void TileManager::clearTileSets(bool clearSourceCaches) { for (auto& tileSet : m_tileSets) { tileSet.tiles.clear(); if (clearSourceCaches) { tileSet.source->clearData(); } } m_tileCache->clear(); } void TileManager::clearTileSet(int32_t _sourceId) { for (auto& tileSet : m_tileSets) { if (tileSet.source->id() != _sourceId) { continue; } tileSet.tiles.clear(); } m_tileCache->clear(); m_tileSetChanged = true; } void TileManager::updateTileSets(const View& _view) { m_tiles.clear(); m_tilesInProgress = 0; m_tileSetChanged = false; if (!getDebugFlag(DebugFlags::freeze_tiles)) { for (auto& tileSet : m_tileSets) { tileSet.visibleTiles.clear(); } auto tileCb = [&, zoom = _view.getZoom()](TileID _tileID){ for (auto& tileSet : m_tileSets) { auto zoomBias = tileSet.source->zoomBias(); auto maxZoom = tileSet.source->maxZoom(); // Insert scaled and maxZoom mapped tileID in the visible set tileSet.visibleTiles.insert(_tileID.zoomBiasAdjusted(zoomBias).withMaxSourceZoom(maxZoom)); } }; _view.getVisibleTiles(tileCb); } for (auto& tileSet : m_tileSets) { // check if tile set is active for zoom (zoom might be below min_zoom) if (tileSet.source->isActiveForZoom(_view.getZoom())) { updateTileSet(tileSet, _view.state()); } } loadTiles(); // Make m_tiles an unique list of tiles for rendering sorted from // high to low zoom-levels. std::sort(m_tiles.begin(), m_tiles.end(), [](auto& a, auto& b) { return a->sourceID() == b->sourceID() ? a->getID() < b->getID() : a->sourceID() < b->sourceID(); } ); // Remove duplicates: Proxy tiles could have been added more than once m_tiles.erase(std::unique(m_tiles.begin(), m_tiles.end()), m_tiles.end()); } void TileManager::updateTileSet(TileSet& _tileSet, const ViewState& _view) { bool newTiles = false; if (_tileSet.sourceGeneration != _tileSet.source->generation()) { _tileSet.sourceGeneration = _tileSet.source->generation(); } // Tile load request above this zoom-level will be canceled in order to // not wait for tiles that are too small to contribute significantly to // the current view. int maxZoom = _view.zoom + 2; std::vector<TileID> removeTiles; auto& tiles = _tileSet.tiles; // Check for ready tasks, move Tile to active TileSet and unset Proxies. for (auto& it : tiles) { auto& entry = it.second; if (entry.completeTileTask()) { clearProxyTiles(_tileSet, it.first, entry, removeTiles); newTiles = true; m_tileSetChanged = true; } } const auto& visibleTiles = _tileSet.visibleTiles; // Loop over visibleTiles and add any needed tiles to tileSet auto curTilesIt = tiles.begin(); auto visTilesIt = visibleTiles.begin(); auto generation = _tileSet.source->generation(); while (visTilesIt != visibleTiles.end() || curTilesIt != tiles.end()) { auto& visTileId = visTilesIt == visibleTiles.end() ? NOT_A_TILE : *visTilesIt; auto& curTileId = curTilesIt == tiles.end() ? NOT_A_TILE : curTilesIt->first; if (visTileId == curTileId) { // tiles in both sets match assert(visTilesIt != visibleTiles.end() && curTilesIt != tiles.end()); auto& entry = curTilesIt->second; entry.setVisible(true); auto sourceGeneration = (entry.isReady()) ? entry.tile->sourceGeneration() : entry.task->sourceGeneration(); if (entry.isReady()) { m_tiles.push_back(entry.tile); if (!entry.isInProgress() && (sourceGeneration < generation)) { // Tile needs update - enqueue for loading entry.task = _tileSet.source->createTask(visTileId); enqueueTask(_tileSet, visTileId, _view); } } else if (entry.needsLoading()) { // Not yet available - enqueue for loading enqueueTask(_tileSet, visTileId, _view); } else if (entry.isCanceled() && (sourceGeneration < generation)) { // Tile needs update - enqueue for loading entry.task = _tileSet.source->createTask(visTileId); enqueueTask(_tileSet, visTileId, _view); } if (entry.isInProgress()) { m_tilesInProgress++; } if (newTiles && entry.isInProgress()) { // check again for proxies updateProxyTiles(_tileSet, visTileId, entry); } ++curTilesIt; ++visTilesIt; } else if (curTileId > visTileId) { // tileSet is missing an element present in visibleTiles // NB: if (curTileId == NOT_A_TILE) it is always > visTileId // and if curTileId > visTileId, then visTileId cannot be // NOT_A_TILE. (for the current implementation of > operator) assert(visTilesIt != visibleTiles.end()); if (!addTile(_tileSet, visTileId)) { // Not in cache - enqueue for loading enqueueTask(_tileSet, visTileId, _view); m_tilesInProgress++; } ++visTilesIt; } else { // tileSet has a tile not present in visibleTiles assert(curTilesIt != tiles.end()); auto& entry = curTilesIt->second; if (entry.getProxyCounter() > 0) { if (entry.isReady()) { m_tiles.push_back(entry.tile); } else if (curTileId.z < maxZoom) { // Cancel loading removeTiles.push_back(curTileId); } } else { removeTiles.push_back(curTileId); } entry.setVisible(false); ++curTilesIt; } } while (!removeTiles.empty()) { auto it = tiles.find(removeTiles.back()); removeTiles.pop_back(); if ((it != tiles.end()) && (!it->second.isVisible()) && (it->second.getProxyCounter() <= 0 || it->first.z >= maxZoom)) { clearProxyTiles(_tileSet, it->first, it->second, removeTiles); removeTile(_tileSet, it); } } for (auto& it : tiles) { auto& entry = it.second; #if LOG_LEVEL >= 3 size_t rasterLoading = 0; size_t rasterDone = 0; if (entry.task) { for (auto &raster : entry.task->subTasks()) { if (raster->isReady()) { rasterDone++; } else { rasterLoading++; } } } DBG("> %s - ready:%d proxy:%d/%d loading:%d rDone:%d rLoading:%d rPending:%d canceled:%d", it.first.toString().c_str(), entry.isReady(), entry.getProxyCounter(), entry.m_proxies, entry.task && !entry.task->isReady(), rasterDone, rasterLoading, entry.rastersPending(), entry.task && entry.task->isCanceled()); #endif if (entry.isInProgress()) { auto& id = it.first; auto& task = entry.task; // Update tile distance to map center for load priority. auto tileCenter = _view.mapProjection->TileCenter(id); double scaleDiv = exp2(id.z - _view.zoom); if (scaleDiv < 1) { scaleDiv = 0.1/scaleDiv; } // prefer parent tiles task->setPriority(glm::length2(tileCenter - _view.center) * scaleDiv); task->setProxyState(entry.getProxyCounter() > 0); } if (entry.isReady()) { // Mark as proxy entry.tile->setProxyState(entry.getProxyCounter() > 0); } } } void TileManager::enqueueTask(TileSet& _tileSet, const TileID& _tileID, const ViewState& _view) { // Keep the items sorted by distance auto tileCenter = _view.mapProjection->TileCenter(_tileID); double distance = glm::length2(tileCenter - _view.center); auto it = std::upper_bound(m_loadTasks.begin(), m_loadTasks.end(), distance, [](auto& distance, auto& other){ return distance < std::get<0>(other); }); m_loadTasks.insert(it, std::make_tuple(distance, &_tileSet, _tileID)); } void TileManager::loadTiles() { if (m_loadTasks.empty()) { return; } for (auto& loadTask : m_loadTasks) { auto tileId = std::get<2>(loadTask); auto& tileSet = *std::get<1>(loadTask); auto tileIt = tileSet.tiles.find(tileId); auto& entry = tileIt->second; tileSet.source->loadTileData(entry.task, m_dataCallback); } DBG("loading:%d pending:%d cache: %fMB", m_loadTasks.size(), m_loadPending, (double(m_tileCache->getMemoryUsage()) / (1024 * 1024))); m_loadTasks.clear(); } bool TileManager::addTile(TileSet& _tileSet, const TileID& _tileID) { auto tile = m_tileCache->get(_tileSet.source->id(), _tileID); if (tile) { if (tile->sourceGeneration() == _tileSet.source->generation()) { m_tiles.push_back(tile); // Reset tile on potential internal dynamic data set tile->resetState(); } else { // Clear stale tile data tile.reset(); } } // Add TileEntry to TileSet auto entry = _tileSet.tiles.emplace(_tileID, tile); if (!tile) { // Add Proxy if corresponding proxy MapTile ready updateProxyTiles(_tileSet, _tileID, entry.first->second); entry.first->second.task = _tileSet.source->createTask(_tileID); } entry.first->second.setVisible(true); return bool(tile); } void TileManager::removeTile(TileSet& _tileSet, std::map<TileID, TileEntry>::iterator& _tileIt) { auto& id = _tileIt->first; auto& entry = _tileIt->second; if (entry.isInProgress()) { entry.clearTask(); // 1. Remove from Datasource. Make sure to cancel // the network request associated with this tile. _tileSet.source->cancelLoadingTile(id); } else if (entry.isReady()) { // Add to cache auto poppedTiles = m_tileCache->put(_tileSet.source->id(), entry.tile); for (auto& tileID : poppedTiles) { _tileSet.source->clearRaster(tileID); } } // Remove rasters from this TileSource _tileSet.source->clearRaster(id); // Remove tile from set _tileIt = _tileSet.tiles.erase(_tileIt); } bool TileManager::updateProxyTile(TileSet& _tileSet, TileEntry& _tile, const TileID& _proxyTileId, const ProxyID _proxyId) { if (!_proxyTileId.isValid()) { return false; } auto& tiles = _tileSet.tiles; // check if the proxy exists in the visible tile set { const auto& it = tiles.find(_proxyTileId); if (it != tiles.end()) { auto& entry = it->second; if (!entry.isCanceled() && _tile.setProxy(_proxyId)) { entry.incProxyCounter(); if (entry.isReady()) { m_tiles.push_back(entry.tile); } // Note: No need to check the cache: When the tile is in // tileSet it would have already been fetched from cache return true; } } } // check if the proxy exists in the cache { auto proxyTile = m_tileCache->get(_tileSet.source->id(), _proxyTileId); if (proxyTile && _tile.setProxy(_proxyId)) { auto result = tiles.emplace(_proxyTileId, proxyTile); auto& entry = result.first->second; entry.incProxyCounter(); m_tiles.push_back(proxyTile); return true; } } return false; } void TileManager::updateProxyTiles(TileSet& _tileSet, const TileID& _tileID, TileEntry& _tile) { // TODO: this should be improved to use the nearest proxy tile available. // Currently it would use parent or grand*parent as proxies even if the // child proxies would be more appropriate // Try parent proxy auto zoomBias = _tileSet.source->zoomBias(); auto maxZoom = _tileSet.source->maxZoom(); auto parentID = _tileID.getParent(zoomBias); auto minZoom = _tileSet.source->minDisplayZoom(); if (minZoom <= parentID.z && updateProxyTile(_tileSet, _tile, parentID, ProxyID::parent)) { return; } // Try grandparent auto grandparentID = parentID.getParent(zoomBias); if (minZoom <= grandparentID.z && updateProxyTile(_tileSet, _tile, grandparentID, ProxyID::parent2)) { return; } // Try children if (maxZoom > _tileID.z) { for (int i = 0; i < 4; i++) { auto childID = _tileID.getChild(i, maxZoom); updateProxyTile(_tileSet, _tile, childID, static_cast<ProxyID>(1 << i)); } } } void TileManager::clearProxyTiles(TileSet& _tileSet, const TileID& _tileID, TileEntry& _tile, std::vector<TileID>& _removes) { auto& tiles = _tileSet.tiles; auto zoomBias = _tileSet.source->zoomBias(); auto maxZoom = _tileSet.source->maxZoom(); auto removeProxy = [&tiles,&_removes](TileID id) { auto it = tiles.find(id); if (it != tiles.end()) { auto& entry = it->second; entry.decProxyCounter(); if (entry.getProxyCounter() <= 0 && !entry.isVisible()) { _removes.push_back(id); } } }; // Check if grand parent proxy is present if (_tile.unsetProxy(ProxyID::parent2)) { TileID gparentID(_tileID.getParent(zoomBias).getParent(zoomBias)); removeProxy(gparentID); } // Check if parent proxy is present if (_tile.unsetProxy(ProxyID::parent)) { TileID parentID(_tileID.getParent(zoomBias)); removeProxy(parentID); } // Check if child proxies are present for (int i = 0; i < 4; i++) { if (_tile.unsetProxy(static_cast<ProxyID>(1 << i))) { TileID childID(_tileID.getChild(i, maxZoom)); removeProxy(childID); } } } void TileManager::setCacheSize(size_t _cacheSize) { m_tileCache->limitCacheSize(_cacheSize); } }
30.475362
107
0.568242
JungWonHyung
5e7a884153484f9c7b33720e401823626aaff820
7,954
cpp
C++
GRTlib/GRT/CoreModules/MLBase.cpp
vladnis/grt-android-lib
291401bfcc163677cb21f58fc28cab94fd97553b
[ "MIT" ]
1
2015-07-12T09:32:02.000Z
2015-07-12T09:32:02.000Z
GRTlib/src/CoreModules/MLBase.cpp
vladnis/GRT-Benchmark
5cbce6919f596fea3677660d89d8d41060bacbb6
[ "Apache-2.0" ]
null
null
null
GRTlib/src/CoreModules/MLBase.cpp
vladnis/GRT-Benchmark
5cbce6919f596fea3677660d89d8d41060bacbb6
[ "Apache-2.0" ]
null
null
null
/** GRT MIT License Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "MLBase.h" namespace GRT{ MLBase::MLBase(void){ trained = false; useScaling = false; baseType = BASE_TYPE_NOT_SET; numInputDimensions = 0; numOutputDimensions = 0; } MLBase::~MLBase(void){ clear(); } bool MLBase::copyMLBaseVariables(const MLBase *mlBase){ if( mlBase == NULL ){ errorLog << "copyMLBaseVariables(MLBase *mlBase) - mlBase pointer is NULL!" << endl; return false; } if( !copyGRTBaseVariables( mlBase ) ){ errorLog << "copyMLBaseVariables(MLBase *mlBase) - Failed to copy GRT Base variables!" << endl; return false; } this->trained = mlBase->trained; this->useScaling = mlBase->useScaling; this->baseType = mlBase->baseType; this->numInputDimensions = mlBase->numInputDimensions; this->numOutputDimensions = mlBase->numOutputDimensions; this->numTrainingIterationsToConverge = mlBase->numTrainingIterationsToConverge; this->trainingResults = mlBase->trainingResults; this->trainingResultsObserverManager = mlBase->trainingResultsObserverManager; this->testResultsObserverManager = mlBase->testResultsObserverManager; return true; } bool MLBase::train(LabelledClassificationData trainingData){ return trainInplace( trainingData ); } bool MLBase::trainInplace(LabelledClassificationData &trainingData){ return false; } bool MLBase::train(LabelledTimeSeriesClassificationData trainingData){ return trainInPlace( trainingData ); } bool MLBase::trainInPlace(LabelledTimeSeriesClassificationData &trainingData){ return false; } bool MLBase::train(UnlabelledClassificationData trainingData){ return false; } bool MLBase::trainInplace(UnlabelledClassificationData &trainingData){ return false; } bool MLBase::train(MatrixDouble data){ return trainInplace( data ); } bool MLBase::trainInplace(MatrixDouble &data){ return false; } bool MLBase::predict(VectorDouble inputVector){ return false; } bool MLBase::predict(MatrixDouble inputMatrix){ return false; } bool MLBase::MLBase::map(VectorDouble inputVector){ return false; } bool MLBase::mapInplace(VectorDouble &inputVector){ return false; } bool MLBase::reset(){ return true; } bool MLBase::clear(){ trained = false; numInputDimensions = 0; numOutputDimensions = 0; numTrainingIterationsToConverge = 0; trainingResults.clear(); return true; } bool MLBase::print() const { return true; } bool MLBase::saveModelToFile(string filename) const { return false; } bool MLBase::saveModelToFile(fstream &file) const { return false; } bool MLBase::loadModelFromFile(string filename){ return false; } bool MLBase::loadModelFromFile(fstream &file){ return false; } UINT MLBase::getBaseType() const{ return baseType; } UINT MLBase::getNumInputFeatures() const{ return getNumInputDimensions(); } UINT MLBase::getNumInputDimensions() const{ return numInputDimensions; } UINT MLBase::getNumOutputDimensions() const{ return numOutputDimensions; } UINT MLBase::getNumTrainingIterationsToConverge() const{ if( trained ){ return numTrainingIterationsToConverge; } return 0; } bool MLBase::getTrained() const{ return trained; } bool MLBase::getModelTrained() const{ return getTrained(); } bool MLBase::getScalingEnabled() const{ return useScaling; } bool MLBase::getIsBaseTypeClassifier() const{ return baseType==CLASSIFIER; } bool MLBase::getIsBaseTypeRegressifier() const{ return baseType==REGRESSIFIER; } bool MLBase::enableScaling(bool useScaling){ this->useScaling = useScaling; return true; } bool MLBase::registerTrainingResultsObserver( Observer< TrainingResult > &observer ){ return trainingResultsObserverManager.registerObserver( observer ); } bool MLBase::registerTestResultsObserver( Observer< TestInstanceResult > &observer ){ return testResultsObserverManager.registerObserver( observer ); } bool MLBase::removeTrainingResultsObserver( const Observer< TrainingResult > &observer ){ return trainingResultsObserverManager.removeObserver( observer ); } bool MLBase::removeTestResultsObserver( const Observer< TestInstanceResult > &observer ){ return testResultsObserverManager.removeObserver( observer ); } bool MLBase::removeAllTrainingObservers(){ return trainingResultsObserverManager.removeAllObservers(); } bool MLBase::removeAllTestObservers(){ return testResultsObserverManager.removeAllObservers(); } bool MLBase::notifyTrainingResultsObservers( const TrainingResult &data ){ return trainingResultsObserverManager.notifyObservers( data ); } bool MLBase::notifyTestResultsObservers( const TestInstanceResult &data ){ return testResultsObserverManager.notifyObservers( data ); } vector< TrainingResult > MLBase::getTrainingResults() const{ return trainingResults; } bool MLBase::saveBaseSettingsToFile(fstream &file) const{ if( !file.is_open() ){ errorLog << "saveBaseSettingsToFile(fstream &file) - The file is not open!" << endl; return false; } file << "Trained: " << trained << endl; file << "UseScaling: " << useScaling << endl; file << "NumInputDimensions: " << numInputDimensions << endl; file << "NumOutputDimensions: " << numOutputDimensions << endl; return true; } bool MLBase::loadBaseSettingsFromFile(fstream &file){ //Clear any previous setup clear(); if( !file.is_open() ){ errorLog << "loadBaseSettingsFromFile(fstream &file) - The file is not open!" << endl; return false; } string word; //Load the trained state file >> word; if( word != "Trained:" ){ errorLog << "loadBaseSettingsFromFile(fstream &file) - Failed to read Trained header!" << endl; return false; } file >> trained; //Load the scaling state file >> word; if( word != "UseScaling:" ){ errorLog << "loadBaseSettingsFromFile(fstream &file) - Failed to read UseScaling header!" << endl; return false; } file >> useScaling; //Load the NumInputDimensions file >> word; if( word != "NumInputDimensions:" ){ errorLog << "loadBaseSettingsFromFile(fstream &file) - Failed to read NumInputDimensions header!" << endl; return false; } file >> numInputDimensions; //Load the NumOutputDimensions file >> word; if( word != "NumOutputDimensions:" ){ errorLog << "loadBaseSettingsFromFile(fstream &file) - Failed to read NumOutputDimensions header!" << endl; return false; } file >> numOutputDimensions; return true; } } //End of namespace GRT
34.137339
116
0.707066
vladnis
5e7b56c302b1d9d2ab81b4ad7588750539a35857
2,324
cpp
C++
tests/ClusterManagerTest.cpp
cybergarage/round-common
cfbf66cd7afa5eee9fadb37e51f1a16b3f3c1189
[ "BSD-3-Clause" ]
5
2015-06-14T13:12:41.000Z
2017-01-09T13:34:14.000Z
tests/ClusterManagerTest.cpp
cybergarage/round-common
cfbf66cd7afa5eee9fadb37e51f1a16b3f3c1189
[ "BSD-3-Clause" ]
2
2015-06-08T05:41:05.000Z
2015-06-13T08:16:12.000Z
tests/ClusterManagerTest.cpp
cybergarage/round-common
cfbf66cd7afa5eee9fadb37e51f1a16b3f3c1189
[ "BSD-3-Clause" ]
1
2016-07-01T03:11:27.000Z
2016-07-01T03:11:27.000Z
/****************************************************************** * * Round for C * * Copyright (C) Satoshi Konno 2015 * * This is licensed under BSD-style license, see file COPYING. * ******************************************************************/ #include <boost/test/unit_test.hpp> #include "RoundTest.h" #include <round/cluster_internal.h> const char* TEST_CLUSTER_NAME = "testCluster"; BOOST_AUTO_TEST_SUITE(cluster) BOOST_AUTO_TEST_CASE(ClusterManager) { RoundClusterManager* mgr = round_cluster_manager_new(); BOOST_CHECK(mgr); BOOST_CHECK_EQUAL(0, round_cluster_manager_size(mgr)); char clusterName[32]; RoundCluster* cluster[ROUND_TEST_MAP_SIZE]; for (int n = 0; n < ROUND_TEST_MAP_SIZE; n++) { cluster[n] = round_cluster_new(); snprintf(clusterName, sizeof(clusterName), "%d", n); BOOST_CHECK(round_cluster_setname(cluster[n], clusterName)); BOOST_CHECK(round_cluster_manager_addcluster(mgr, cluster[n])); BOOST_CHECK_EQUAL((n + 1), round_cluster_manager_size(mgr)); BOOST_CHECK(round_cluster_manager_hascluster(mgr, clusterName)); } BOOST_CHECK_EQUAL(ROUND_TEST_MAP_SIZE, round_cluster_manager_size(mgr)); BOOST_CHECK(round_cluster_manager_delete(mgr)); } BOOST_AUTO_TEST_CASE(ClusterMgrAddNode) { RoundClusterManager* mgr = round_cluster_manager_new(); BOOST_CHECK(mgr); RoundNode* node = round_node_local_new(); BOOST_CHECK(round_node_setclustername(node, TEST_CLUSTER_NAME)); BOOST_CHECK(round_cluster_manager_addnode(mgr, node)); BOOST_CHECK(round_cluster_manager_delete(mgr)); } BOOST_AUTO_TEST_CASE(ClusterMgrAddSameHostNodes) { RoundClusterManager* mgr = round_cluster_manager_new(); BOOST_CHECK(mgr); for (int n = 0; n < ROUND_TEST_MAP_SIZE; n++) { RoundNode* node = round_node_new(); BOOST_CHECK(round_node_setaddress(node, "127.0.0.1")); BOOST_CHECK(round_node_setport(node, (n + 1))); BOOST_CHECK(round_cluster_manager_addnode(mgr, node)); const char* clusterName; BOOST_CHECK(round_node_getclustername(node, &clusterName)); RoundCluster* cluster = round_cluster_manager_getclusterbyname(mgr, clusterName); BOOST_CHECK(cluster); BOOST_CHECK_EQUAL(round_cluster_size(cluster), (n + 1)); } BOOST_CHECK(round_cluster_manager_delete(mgr)); } BOOST_AUTO_TEST_SUITE_END()
28.341463
85
0.715577
cybergarage
5e803e956a5759d1df385d6b1a8438ab092d0876
986
cpp
C++
src/data/Accuracy.cpp
mr-c/pbcopper
6226c0adf041db717360cf0066bc91e8f556bf48
[ "BSD-3-Clause-Clear" ]
null
null
null
src/data/Accuracy.cpp
mr-c/pbcopper
6226c0adf041db717360cf0066bc91e8f556bf48
[ "BSD-3-Clause-Clear" ]
null
null
null
src/data/Accuracy.cpp
mr-c/pbcopper
6226c0adf041db717360cf0066bc91e8f556bf48
[ "BSD-3-Clause-Clear" ]
null
null
null
// Author: Derek Barnett #include <pbcopper/data/Accuracy.h> #include <cassert> #include <type_traits> #include <boost/algorithm/clamp.hpp> namespace PacBio { namespace Data { const float Accuracy::MIN = 0.0f; const float Accuracy::MAX = 1.0f; static_assert(std::is_copy_constructible<Accuracy>::value, "Accuracy(const Accuracy&) is not = default"); static_assert(std::is_copy_assignable<Accuracy>::value, "Accuracy& operator=(const Accuracy&) is not = default"); static_assert(std::is_nothrow_move_constructible<Accuracy>::value, "Accuracy(Accuracy&&) is not = noexcept"); static_assert(std::is_nothrow_move_assignable<Accuracy>::value, "Accuracy& operator=(Accuracy&&) is not = noexcept"); Accuracy::Accuracy(float accuracy) : accuracy_{boost::algorithm::clamp(accuracy, Accuracy::MIN, Accuracy::MAX)} { } Accuracy::operator float() const noexcept { return accuracy_; } } // namespace Data } // namespace PacBio
28.171429
80
0.706897
mr-c
5e82b61df977500f5067014125164e44bfffa340
83,122
cpp
C++
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
5
2019-02-26T18:46:52.000Z
2022-01-27T23:48:26.000Z
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
1
2020-06-07T23:44:29.000Z
2021-04-03T18:49:54.000Z
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
null
null
null
#include "erm/extensions/VkExtensions.h" #include <assert.h> /* loaders */ /* /////////////////////////////////// */ #if VK_EXT_debug_marker static PFN_vkDebugMarkerSetObjectTagEXT pfn_vkDebugMarkerSetObjectTagEXT = 0; static PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT = 0; static PFN_vkCmdDebugMarkerBeginEXT pfn_vkCmdDebugMarkerBeginEXT = 0; static PFN_vkCmdDebugMarkerEndEXT pfn_vkCmdDebugMarkerEndEXT = 0; static PFN_vkCmdDebugMarkerInsertEXT pfn_vkCmdDebugMarkerInsertEXT = 0; # if defined(ERM_OSX) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wall" # pragma clang diagnostic ignored "-pedantic-errors" # pragma clang diagnostic ignored "-pedantic" # pragma clang diagnostic ignored "-Wextra" # endif VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { assert(pfn_vkDebugMarkerSetObjectTagEXT); return pfn_vkDebugMarkerSetObjectTagEXT(device, pTagInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo) { assert(pfn_vkDebugMarkerSetObjectNameEXT); return pfn_vkDebugMarkerSetObjectNameEXT(device, pNameInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT( VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { assert(pfn_vkCmdDebugMarkerBeginEXT); pfn_vkCmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT( VkCommandBuffer commandBuffer) { assert(pfn_vkCmdDebugMarkerEndEXT); pfn_vkCmdDebugMarkerEndEXT(commandBuffer); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { assert(pfn_vkCmdDebugMarkerInsertEXT); pfn_vkCmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo); } int has_VK_EXT_debug_marker = 0; int load_VK_EXT_debug_marker(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkDebugMarkerSetObjectTagEXT = (PFN_vkDebugMarkerSetObjectTagEXT)getDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT"); pfn_vkDebugMarkerSetObjectNameEXT = (PFN_vkDebugMarkerSetObjectNameEXT)getDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT"); pfn_vkCmdDebugMarkerBeginEXT = (PFN_vkCmdDebugMarkerBeginEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT"); pfn_vkCmdDebugMarkerEndEXT = (PFN_vkCmdDebugMarkerEndEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT"); pfn_vkCmdDebugMarkerInsertEXT = (PFN_vkCmdDebugMarkerInsertEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT"); int success = 1; success = success && (pfn_vkDebugMarkerSetObjectTagEXT != 0); success = success && (pfn_vkDebugMarkerSetObjectNameEXT != 0); success = success && (pfn_vkCmdDebugMarkerBeginEXT != 0); success = success && (pfn_vkCmdDebugMarkerEndEXT != 0); success = success && (pfn_vkCmdDebugMarkerInsertEXT != 0); has_VK_EXT_debug_marker = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkGetMemoryWin32HandleKHR pfn_vkGetMemoryWin32HandleKHR = 0; static PFN_vkGetMemoryWin32HandlePropertiesKHR pfn_vkGetMemoryWin32HandlePropertiesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR( VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetMemoryWin32HandleKHR); return pfn_vkGetMemoryWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties) { assert(pfn_vkGetMemoryWin32HandlePropertiesKHR); return pfn_vkGetMemoryWin32HandlePropertiesKHR(device, handleType, handle, pMemoryWin32HandleProperties); } int has_VK_KHR_external_memory_win32 = 0; int load_VK_KHR_external_memory_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)getDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR"); pfn_vkGetMemoryWin32HandlePropertiesKHR = (PFN_vkGetMemoryWin32HandlePropertiesKHR)getDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR"); int success = 1; success = success && (pfn_vkGetMemoryWin32HandleKHR != 0); success = success && (pfn_vkGetMemoryWin32HandlePropertiesKHR != 0); has_VK_KHR_external_memory_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_memory_fd static PFN_vkGetMemoryFdKHR pfn_vkGetMemoryFdKHR = 0; static PFN_vkGetMemoryFdPropertiesKHR pfn_vkGetMemoryFdPropertiesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR( VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd) { assert(pfn_vkGetMemoryFdKHR); return pfn_vkGetMemoryFdKHR(device, pGetFdInfo, pFd); } VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR( VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR* pMemoryFdProperties) { assert(pfn_vkGetMemoryFdPropertiesKHR); return pfn_vkGetMemoryFdPropertiesKHR(device, handleType, fd, pMemoryFdProperties); } int has_VK_KHR_external_memory_fd = 0; int load_VK_KHR_external_memory_fd(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetMemoryFdKHR = (PFN_vkGetMemoryFdKHR)getDeviceProcAddr(device, "vkGetMemoryFdKHR"); pfn_vkGetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)getDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR"); int success = 1; success = success && (pfn_vkGetMemoryFdKHR != 0); success = success && (pfn_vkGetMemoryFdPropertiesKHR != 0); has_VK_KHR_external_memory_fd = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkImportSemaphoreWin32HandleKHR pfn_vkImportSemaphoreWin32HandleKHR = 0; static PFN_vkGetSemaphoreWin32HandleKHR pfn_vkGetSemaphoreWin32HandleKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR( VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo) { assert(pfn_vkImportSemaphoreWin32HandleKHR); return pfn_vkImportSemaphoreWin32HandleKHR(device, pImportSemaphoreWin32HandleInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetSemaphoreWin32HandleKHR); return pfn_vkGetSemaphoreWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } int has_VK_KHR_external_semaphore_win32 = 0; int load_VK_KHR_external_semaphore_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportSemaphoreWin32HandleKHR = (PFN_vkImportSemaphoreWin32HandleKHR)getDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR"); pfn_vkGetSemaphoreWin32HandleKHR = (PFN_vkGetSemaphoreWin32HandleKHR)getDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR"); int success = 1; success = success && (pfn_vkImportSemaphoreWin32HandleKHR != 0); success = success && (pfn_vkGetSemaphoreWin32HandleKHR != 0); has_VK_KHR_external_semaphore_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_semaphore_fd static PFN_vkImportSemaphoreFdKHR pfn_vkImportSemaphoreFdKHR = 0; static PFN_vkGetSemaphoreFdKHR pfn_vkGetSemaphoreFdKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR( VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo) { assert(pfn_vkImportSemaphoreFdKHR); return pfn_vkImportSemaphoreFdKHR(device, pImportSemaphoreFdInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR( VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd) { assert(pfn_vkGetSemaphoreFdKHR); return pfn_vkGetSemaphoreFdKHR(device, pGetFdInfo, pFd); } int has_VK_KHR_external_semaphore_fd = 0; int load_VK_KHR_external_semaphore_fd(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportSemaphoreFdKHR = (PFN_vkImportSemaphoreFdKHR)getDeviceProcAddr(device, "vkImportSemaphoreFdKHR"); pfn_vkGetSemaphoreFdKHR = (PFN_vkGetSemaphoreFdKHR)getDeviceProcAddr(device, "vkGetSemaphoreFdKHR"); int success = 1; success = success && (pfn_vkImportSemaphoreFdKHR != 0); success = success && (pfn_vkGetSemaphoreFdKHR != 0); has_VK_KHR_external_semaphore_fd = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_push_descriptor static PFN_vkCmdPushDescriptorSetKHR pfn_vkCmdPushDescriptorSetKHR = 0; static PFN_vkCmdPushDescriptorSetWithTemplateKHR pfn_vkCmdPushDescriptorSetWithTemplateKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites) { assert(pfn_vkCmdPushDescriptorSetKHR); pfn_vkCmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites); } VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplate descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData) { assert(pfn_vkCmdPushDescriptorSetWithTemplateKHR); pfn_vkCmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set, pData); } int has_VK_KHR_push_descriptor = 0; int load_VK_KHR_push_descriptor(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdPushDescriptorSetKHR = (PFN_vkCmdPushDescriptorSetKHR)getDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR"); pfn_vkCmdPushDescriptorSetWithTemplateKHR = (PFN_vkCmdPushDescriptorSetWithTemplateKHR)getDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR"); int success = 1; success = success && (pfn_vkCmdPushDescriptorSetKHR != 0); success = success && (pfn_vkCmdPushDescriptorSetWithTemplateKHR != 0); has_VK_KHR_push_descriptor = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_create_renderpass2 static PFN_vkCreateRenderPass2KHR pfn_vkCreateRenderPass2KHR = 0; static PFN_vkCmdBeginRenderPass2KHR pfn_vkCmdBeginRenderPass2KHR = 0; static PFN_vkCmdNextSubpass2KHR pfn_vkCmdNextSubpass2KHR = 0; static PFN_vkCmdEndRenderPass2KHR pfn_vkCmdEndRenderPass2KHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2KHR( VkDevice device, const VkRenderPassCreateInfo2KHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) { assert(pfn_vkCreateRenderPass2KHR); return pfn_vkCreateRenderPass2KHR(device, pCreateInfo, pAllocator, pRenderPass); } VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2KHR( VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfoKHR* pSubpassBeginInfo) { assert(pfn_vkCmdBeginRenderPass2KHR); pfn_vkCmdBeginRenderPass2KHR(commandBuffer, pRenderPassBegin, pSubpassBeginInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2KHR( VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR* pSubpassBeginInfo, const VkSubpassEndInfoKHR* pSubpassEndInfo) { assert(pfn_vkCmdNextSubpass2KHR); pfn_vkCmdNextSubpass2KHR(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR( VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassEndInfo) { assert(pfn_vkCmdEndRenderPass2KHR); pfn_vkCmdEndRenderPass2KHR(commandBuffer, pSubpassEndInfo); } int has_VK_KHR_create_renderpass2 = 0; int load_VK_KHR_create_renderpass2(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)getDeviceProcAddr(device, "vkCreateRenderPass2KHR"); pfn_vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)getDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR"); pfn_vkCmdNextSubpass2KHR = (PFN_vkCmdNextSubpass2KHR)getDeviceProcAddr(device, "vkCmdNextSubpass2KHR"); pfn_vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)getDeviceProcAddr(device, "vkCmdEndRenderPass2KHR"); int success = 1; success = success && (pfn_vkCreateRenderPass2KHR != 0); success = success && (pfn_vkCmdBeginRenderPass2KHR != 0); success = success && (pfn_vkCmdNextSubpass2KHR != 0); success = success && (pfn_vkCmdEndRenderPass2KHR != 0); has_VK_KHR_create_renderpass2 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkImportFenceWin32HandleKHR pfn_vkImportFenceWin32HandleKHR = 0; static PFN_vkGetFenceWin32HandleKHR pfn_vkGetFenceWin32HandleKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR( VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo) { assert(pfn_vkImportFenceWin32HandleKHR); return pfn_vkImportFenceWin32HandleKHR(device, pImportFenceWin32HandleInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetFenceWin32HandleKHR); return pfn_vkGetFenceWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } int has_VK_KHR_external_fence_win32 = 0; int load_VK_KHR_external_fence_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportFenceWin32HandleKHR = (PFN_vkImportFenceWin32HandleKHR)getDeviceProcAddr(device, "vkImportFenceWin32HandleKHR"); pfn_vkGetFenceWin32HandleKHR = (PFN_vkGetFenceWin32HandleKHR)getDeviceProcAddr(device, "vkGetFenceWin32HandleKHR"); int success = 1; success = success && (pfn_vkImportFenceWin32HandleKHR != 0); success = success && (pfn_vkGetFenceWin32HandleKHR != 0); has_VK_KHR_external_fence_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_debug_utils static PFN_vkSetDebugUtilsObjectNameEXT pfn_vkSetDebugUtilsObjectNameEXT = 0; static PFN_vkSetDebugUtilsObjectTagEXT pfn_vkSetDebugUtilsObjectTagEXT = 0; static PFN_vkQueueBeginDebugUtilsLabelEXT pfn_vkQueueBeginDebugUtilsLabelEXT = 0; static PFN_vkQueueEndDebugUtilsLabelEXT pfn_vkQueueEndDebugUtilsLabelEXT = 0; static PFN_vkQueueInsertDebugUtilsLabelEXT pfn_vkQueueInsertDebugUtilsLabelEXT = 0; static PFN_vkCmdBeginDebugUtilsLabelEXT pfn_vkCmdBeginDebugUtilsLabelEXT = 0; static PFN_vkCmdEndDebugUtilsLabelEXT pfn_vkCmdEndDebugUtilsLabelEXT = 0; static PFN_vkCmdInsertDebugUtilsLabelEXT pfn_vkCmdInsertDebugUtilsLabelEXT = 0; static PFN_vkCreateDebugUtilsMessengerEXT pfn_vkCreateDebugUtilsMessengerEXT = 0; static PFN_vkDestroyDebugUtilsMessengerEXT pfn_vkDestroyDebugUtilsMessengerEXT = 0; static PFN_vkSubmitDebugUtilsMessageEXT pfn_vkSubmitDebugUtilsMessageEXT = 0; VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT( VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo) { assert(pfn_vkSetDebugUtilsObjectNameEXT); return pfn_vkSetDebugUtilsObjectNameEXT(device, pNameInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectTagEXT( VkDevice device, const VkDebugUtilsObjectTagInfoEXT* pTagInfo) { assert(pfn_vkSetDebugUtilsObjectTagEXT); return pfn_vkSetDebugUtilsObjectTagEXT(device, pTagInfo); } VKAPI_ATTR void VKAPI_CALL vkQueueBeginDebugUtilsLabelEXT( VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkQueueBeginDebugUtilsLabelEXT); pfn_vkQueueBeginDebugUtilsLabelEXT(queue, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkQueueEndDebugUtilsLabelEXT( VkQueue queue) { assert(pfn_vkQueueEndDebugUtilsLabelEXT); pfn_vkQueueEndDebugUtilsLabelEXT(queue); } VKAPI_ATTR void VKAPI_CALL vkQueueInsertDebugUtilsLabelEXT( VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkQueueInsertDebugUtilsLabelEXT); pfn_vkQueueInsertDebugUtilsLabelEXT(queue, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT( VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkCmdBeginDebugUtilsLabelEXT); pfn_vkCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT( VkCommandBuffer commandBuffer) { assert(pfn_vkCmdEndDebugUtilsLabelEXT); pfn_vkCmdEndDebugUtilsLabelEXT(commandBuffer); } VKAPI_ATTR void VKAPI_CALL vkCmdInsertDebugUtilsLabelEXT( VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkCmdInsertDebugUtilsLabelEXT); pfn_vkCmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT( VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { assert(pfn_vkCreateDebugUtilsMessengerEXT); return pfn_vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); } VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT( VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyDebugUtilsMessengerEXT); pfn_vkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT( VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData) { assert(pfn_vkSubmitDebugUtilsMessageEXT); pfn_vkSubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData); } int has_VK_EXT_debug_utils = 0; int load_VK_EXT_debug_utils(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkSetDebugUtilsObjectNameEXT = (PFN_vkSetDebugUtilsObjectNameEXT)getDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT"); pfn_vkSetDebugUtilsObjectTagEXT = (PFN_vkSetDebugUtilsObjectTagEXT)getDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT"); pfn_vkQueueBeginDebugUtilsLabelEXT = (PFN_vkQueueBeginDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT"); pfn_vkQueueEndDebugUtilsLabelEXT = (PFN_vkQueueEndDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT"); pfn_vkQueueInsertDebugUtilsLabelEXT = (PFN_vkQueueInsertDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT"); pfn_vkCmdBeginDebugUtilsLabelEXT = (PFN_vkCmdBeginDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT"); pfn_vkCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT"); pfn_vkCmdInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT"); pfn_vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)getInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"); pfn_vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT)getInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"); pfn_vkSubmitDebugUtilsMessageEXT = (PFN_vkSubmitDebugUtilsMessageEXT)getInstanceProcAddr(instance, "vkSubmitDebugUtilsMessageEXT"); int success = 1; success = success && (pfn_vkSetDebugUtilsObjectNameEXT != 0); success = success && (pfn_vkSetDebugUtilsObjectTagEXT != 0); success = success && (pfn_vkQueueBeginDebugUtilsLabelEXT != 0); success = success && (pfn_vkQueueEndDebugUtilsLabelEXT != 0); success = success && (pfn_vkQueueInsertDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdBeginDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdEndDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdInsertDebugUtilsLabelEXT != 0); success = success && (pfn_vkCreateDebugUtilsMessengerEXT != 0); success = success && (pfn_vkDestroyDebugUtilsMessengerEXT != 0); success = success && (pfn_vkSubmitDebugUtilsMessageEXT != 0); has_VK_EXT_debug_utils = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_sample_locations static PFN_vkCmdSetSampleLocationsEXT pfn_vkCmdSetSampleLocationsEXT = 0; static PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = 0; VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEXT( VkCommandBuffer commandBuffer, const VkSampleLocationsInfoEXT* pSampleLocationsInfo) { assert(pfn_vkCmdSetSampleLocationsEXT); pfn_vkCmdSetSampleLocationsEXT(commandBuffer, pSampleLocationsInfo); } VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT( VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples, VkMultisamplePropertiesEXT* pMultisampleProperties) { assert(pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT); pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT(physicalDevice, samples, pMultisampleProperties); } int has_VK_EXT_sample_locations = 0; int load_VK_EXT_sample_locations(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdSetSampleLocationsEXT = (PFN_vkCmdSetSampleLocationsEXT)getDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT"); pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)getDeviceProcAddr(device, "vkGetPhysicalDeviceMultisamplePropertiesEXT"); int success = 1; success = success && (pfn_vkCmdSetSampleLocationsEXT != 0); success = success && (pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT != 0); has_VK_EXT_sample_locations = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_acceleration_structure static PFN_vkCreateAccelerationStructureKHR pfn_vkCreateAccelerationStructureKHR = 0; static PFN_vkDestroyAccelerationStructureKHR pfn_vkDestroyAccelerationStructureKHR = 0; static PFN_vkCmdBuildAccelerationStructuresKHR pfn_vkCmdBuildAccelerationStructuresKHR = 0; static PFN_vkCmdBuildAccelerationStructuresIndirectKHR pfn_vkCmdBuildAccelerationStructuresIndirectKHR = 0; static PFN_vkBuildAccelerationStructuresKHR pfn_vkBuildAccelerationStructuresKHR = 0; static PFN_vkCopyAccelerationStructureKHR pfn_vkCopyAccelerationStructureKHR = 0; static PFN_vkCopyAccelerationStructureToMemoryKHR pfn_vkCopyAccelerationStructureToMemoryKHR = 0; static PFN_vkCopyMemoryToAccelerationStructureKHR pfn_vkCopyMemoryToAccelerationStructureKHR = 0; static PFN_vkWriteAccelerationStructuresPropertiesKHR pfn_vkWriteAccelerationStructuresPropertiesKHR = 0; static PFN_vkCmdCopyAccelerationStructureKHR pfn_vkCmdCopyAccelerationStructureKHR = 0; static PFN_vkCmdCopyAccelerationStructureToMemoryKHR pfn_vkCmdCopyAccelerationStructureToMemoryKHR = 0; static PFN_vkCmdCopyMemoryToAccelerationStructureKHR pfn_vkCmdCopyMemoryToAccelerationStructureKHR = 0; static PFN_vkGetAccelerationStructureDeviceAddressKHR pfn_vkGetAccelerationStructureDeviceAddressKHR = 0; static PFN_vkCmdWriteAccelerationStructuresPropertiesKHR pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = 0; static PFN_vkGetDeviceAccelerationStructureCompatibilityKHR pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = 0; static PFN_vkGetAccelerationStructureBuildSizesKHR pfn_vkGetAccelerationStructureBuildSizesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureKHR( VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureKHR* pAccelerationStructure) { assert(pfn_vkCreateAccelerationStructureKHR); return pfn_vkCreateAccelerationStructureKHR(device, pCreateInfo, pAllocator, pAccelerationStructure); } VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureKHR( VkDevice device, VkAccelerationStructureKHR accelerationStructure, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyAccelerationStructureKHR); pfn_vkDestroyAccelerationStructureKHR(device, accelerationStructure, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresKHR( VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos) { assert(pfn_vkCmdBuildAccelerationStructuresKHR); pfn_vkCmdBuildAccelerationStructuresKHR(commandBuffer, infoCount, pInfos, ppBuildRangeInfos); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresIndirectKHR( VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkDeviceAddress* pIndirectDeviceAddresses, const uint32_t* pIndirectStrides, const uint32_t* const* ppMaxPrimitiveCounts) { assert(pfn_vkCmdBuildAccelerationStructuresIndirectKHR); pfn_vkCmdBuildAccelerationStructuresIndirectKHR(commandBuffer, infoCount, pInfos, pIndirectDeviceAddresses, pIndirectStrides, ppMaxPrimitiveCounts); } VKAPI_ATTR VkResult VKAPI_CALL vkBuildAccelerationStructuresKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos) { assert(pfn_vkBuildAccelerationStructuresKHR); return pfn_vkBuildAccelerationStructuresKHR(device, deferredOperation, infoCount, pInfos, ppBuildRangeInfos); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCopyAccelerationStructureKHR); return pfn_vkCopyAccelerationStructureKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureToMemoryKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo) { assert(pfn_vkCopyAccelerationStructureToMemoryKHR); return pfn_vkCopyAccelerationStructureToMemoryKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToAccelerationStructureKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCopyMemoryToAccelerationStructureKHR); return pfn_vkCopyMemoryToAccelerationStructureKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkWriteAccelerationStructuresPropertiesKHR( VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, size_t dataSize, void* pData, size_t stride) { assert(pfn_vkWriteAccelerationStructuresPropertiesKHR); return pfn_vkWriteAccelerationStructuresPropertiesKHR(device, accelerationStructureCount, pAccelerationStructures, queryType, dataSize, pData, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureKHR( VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCmdCopyAccelerationStructureKHR); pfn_vkCmdCopyAccelerationStructureKHR(commandBuffer, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureToMemoryKHR( VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo) { assert(pfn_vkCmdCopyAccelerationStructureToMemoryKHR); pfn_vkCmdCopyAccelerationStructureToMemoryKHR(commandBuffer, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToAccelerationStructureKHR( VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCmdCopyMemoryToAccelerationStructureKHR); pfn_vkCmdCopyMemoryToAccelerationStructureKHR(commandBuffer, pInfo); } VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetAccelerationStructureDeviceAddressKHR( VkDevice device, const VkAccelerationStructureDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetAccelerationStructureDeviceAddressKHR); return pfn_vkGetAccelerationStructureDeviceAddressKHR(device, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesKHR( VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) { assert(pfn_vkCmdWriteAccelerationStructuresPropertiesKHR); pfn_vkCmdWriteAccelerationStructuresPropertiesKHR(commandBuffer, accelerationStructureCount, pAccelerationStructures, queryType, queryPool, firstQuery); } VKAPI_ATTR void VKAPI_CALL vkGetDeviceAccelerationStructureCompatibilityKHR( VkDevice device, const VkAccelerationStructureVersionInfoKHR* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility) { assert(pfn_vkGetDeviceAccelerationStructureCompatibilityKHR); pfn_vkGetDeviceAccelerationStructureCompatibilityKHR(device, pVersionInfo, pCompatibility); } VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureBuildSizesKHR( VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR* pBuildInfo, const uint32_t* pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo) { assert(pfn_vkGetAccelerationStructureBuildSizesKHR); pfn_vkGetAccelerationStructureBuildSizesKHR(device, buildType, pBuildInfo, pMaxPrimitiveCounts, pSizeInfo); } int has_VK_KHR_acceleration_structure = 0; int load_VK_KHR_acceleration_structure(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateAccelerationStructureKHR = (PFN_vkCreateAccelerationStructureKHR)getDeviceProcAddr(device, "vkCreateAccelerationStructureKHR"); pfn_vkDestroyAccelerationStructureKHR = (PFN_vkDestroyAccelerationStructureKHR)getDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR"); pfn_vkCmdBuildAccelerationStructuresKHR = (PFN_vkCmdBuildAccelerationStructuresKHR)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"); pfn_vkCmdBuildAccelerationStructuresIndirectKHR = (PFN_vkCmdBuildAccelerationStructuresIndirectKHR)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR"); pfn_vkBuildAccelerationStructuresKHR = (PFN_vkBuildAccelerationStructuresKHR)getDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR"); pfn_vkCopyAccelerationStructureKHR = (PFN_vkCopyAccelerationStructureKHR)getDeviceProcAddr(device, "vkCopyAccelerationStructureKHR"); pfn_vkCopyAccelerationStructureToMemoryKHR = (PFN_vkCopyAccelerationStructureToMemoryKHR)getDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR"); pfn_vkCopyMemoryToAccelerationStructureKHR = (PFN_vkCopyMemoryToAccelerationStructureKHR)getDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR"); pfn_vkWriteAccelerationStructuresPropertiesKHR = (PFN_vkWriteAccelerationStructuresPropertiesKHR)getDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR"); pfn_vkCmdCopyAccelerationStructureKHR = (PFN_vkCmdCopyAccelerationStructureKHR)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR"); pfn_vkCmdCopyAccelerationStructureToMemoryKHR = (PFN_vkCmdCopyAccelerationStructureToMemoryKHR)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR"); pfn_vkCmdCopyMemoryToAccelerationStructureKHR = (PFN_vkCmdCopyMemoryToAccelerationStructureKHR)getDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR"); pfn_vkGetAccelerationStructureDeviceAddressKHR = (PFN_vkGetAccelerationStructureDeviceAddressKHR)getDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR"); pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = (PFN_vkCmdWriteAccelerationStructuresPropertiesKHR)getDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR"); pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = (PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)getDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR"); pfn_vkGetAccelerationStructureBuildSizesKHR = (PFN_vkGetAccelerationStructureBuildSizesKHR)getDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR"); int success = 1; success = success && (pfn_vkCreateAccelerationStructureKHR != 0); success = success && (pfn_vkDestroyAccelerationStructureKHR != 0); success = success && (pfn_vkCmdBuildAccelerationStructuresKHR != 0); success = success && (pfn_vkCmdBuildAccelerationStructuresIndirectKHR != 0); success = success && (pfn_vkBuildAccelerationStructuresKHR != 0); success = success && (pfn_vkCopyAccelerationStructureKHR != 0); success = success && (pfn_vkCopyAccelerationStructureToMemoryKHR != 0); success = success && (pfn_vkCopyMemoryToAccelerationStructureKHR != 0); success = success && (pfn_vkWriteAccelerationStructuresPropertiesKHR != 0); success = success && (pfn_vkCmdCopyAccelerationStructureKHR != 0); success = success && (pfn_vkCmdCopyAccelerationStructureToMemoryKHR != 0); success = success && (pfn_vkCmdCopyMemoryToAccelerationStructureKHR != 0); success = success && (pfn_vkGetAccelerationStructureDeviceAddressKHR != 0); success = success && (pfn_vkCmdWriteAccelerationStructuresPropertiesKHR != 0); success = success && (pfn_vkGetDeviceAccelerationStructureCompatibilityKHR != 0); success = success && (pfn_vkGetAccelerationStructureBuildSizesKHR != 0); has_VK_KHR_acceleration_structure = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_ray_tracing_pipeline static PFN_vkCmdTraceRaysKHR pfn_vkCmdTraceRaysKHR = 0; static PFN_vkCreateRayTracingPipelinesKHR pfn_vkCreateRayTracingPipelinesKHR = 0; static PFN_vkGetRayTracingShaderGroupHandlesKHR pfn_vkGetRayTracingShaderGroupHandlesKHR = 0; static PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = 0; static PFN_vkCmdTraceRaysIndirectKHR pfn_vkCmdTraceRaysIndirectKHR = 0; static PFN_vkGetRayTracingShaderGroupStackSizeKHR pfn_vkGetRayTracingShaderGroupStackSizeKHR = 0; static PFN_vkCmdSetRayTracingPipelineStackSizeKHR pfn_vkCmdSetRayTracingPipelineStackSizeKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysKHR( VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width, uint32_t height, uint32_t depth) { assert(pfn_vkCmdTraceRaysKHR); pfn_vkCmdTraceRaysKHR(commandBuffer, pRaygenShaderBindingTable, pMissShaderBindingTable, pHitShaderBindingTable, pCallableShaderBindingTable, width, height, depth); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) { assert(pfn_vkCreateRayTracingPipelinesKHR); return pfn_vkCreateRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesKHR( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingShaderGroupHandlesKHR); return pfn_vkGetRayTracingShaderGroupHandlesKHR(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingCaptureReplayShaderGroupHandlesKHR( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR); return pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirectKHR( VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) { assert(pfn_vkCmdTraceRaysIndirectKHR); pfn_vkCmdTraceRaysIndirectKHR(commandBuffer, pRaygenShaderBindingTable, pMissShaderBindingTable, pHitShaderBindingTable, pCallableShaderBindingTable, indirectDeviceAddress); } VKAPI_ATTR VkDeviceSize VKAPI_CALL vkGetRayTracingShaderGroupStackSizeKHR( VkDevice device, VkPipeline pipeline, uint32_t group, VkShaderGroupShaderKHR groupShader) { assert(pfn_vkGetRayTracingShaderGroupStackSizeKHR); return pfn_vkGetRayTracingShaderGroupStackSizeKHR(device, pipeline, group, groupShader); } VKAPI_ATTR void VKAPI_CALL vkCmdSetRayTracingPipelineStackSizeKHR( VkCommandBuffer commandBuffer, uint32_t pipelineStackSize) { assert(pfn_vkCmdSetRayTracingPipelineStackSizeKHR); pfn_vkCmdSetRayTracingPipelineStackSizeKHR(commandBuffer, pipelineStackSize); } int has_VK_KHR_ray_tracing_pipeline = 0; int load_VK_KHR_ray_tracing_pipeline(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdTraceRaysKHR = (PFN_vkCmdTraceRaysKHR)getDeviceProcAddr(device, "vkCmdTraceRaysKHR"); pfn_vkCreateRayTracingPipelinesKHR = (PFN_vkCreateRayTracingPipelinesKHR)getDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR"); pfn_vkGetRayTracingShaderGroupHandlesKHR = (PFN_vkGetRayTracingShaderGroupHandlesKHR)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR"); pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = (PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)getDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR"); pfn_vkCmdTraceRaysIndirectKHR = (PFN_vkCmdTraceRaysIndirectKHR)getDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR"); pfn_vkGetRayTracingShaderGroupStackSizeKHR = (PFN_vkGetRayTracingShaderGroupStackSizeKHR)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR"); pfn_vkCmdSetRayTracingPipelineStackSizeKHR = (PFN_vkCmdSetRayTracingPipelineStackSizeKHR)getDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR"); int success = 1; success = success && (pfn_vkCmdTraceRaysKHR != 0); success = success && (pfn_vkCreateRayTracingPipelinesKHR != 0); success = success && (pfn_vkGetRayTracingShaderGroupHandlesKHR != 0); success = success && (pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR != 0); success = success && (pfn_vkCmdTraceRaysIndirectKHR != 0); success = success && (pfn_vkGetRayTracingShaderGroupStackSizeKHR != 0); success = success && (pfn_vkCmdSetRayTracingPipelineStackSizeKHR != 0); has_VK_KHR_ray_tracing_pipeline = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_shading_rate_image static PFN_vkCmdBindShadingRateImageNV pfn_vkCmdBindShadingRateImageNV = 0; static PFN_vkCmdSetViewportShadingRatePaletteNV pfn_vkCmdSetViewportShadingRatePaletteNV = 0; static PFN_vkCmdSetCoarseSampleOrderNV pfn_vkCmdSetCoarseSampleOrderNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdBindShadingRateImageNV( VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout) { assert(pfn_vkCmdBindShadingRateImageNV); pfn_vkCmdBindShadingRateImageNV(commandBuffer, imageView, imageLayout); } VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportShadingRatePaletteNV( VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkShadingRatePaletteNV* pShadingRatePalettes) { assert(pfn_vkCmdSetViewportShadingRatePaletteNV); pfn_vkCmdSetViewportShadingRatePaletteNV(commandBuffer, firstViewport, viewportCount, pShadingRatePalettes); } VKAPI_ATTR void VKAPI_CALL vkCmdSetCoarseSampleOrderNV( VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, const VkCoarseSampleOrderCustomNV* pCustomSampleOrders) { assert(pfn_vkCmdSetCoarseSampleOrderNV); pfn_vkCmdSetCoarseSampleOrderNV(commandBuffer, sampleOrderType, customSampleOrderCount, pCustomSampleOrders); } int has_VK_NV_shading_rate_image = 0; int load_VK_NV_shading_rate_image(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdBindShadingRateImageNV = (PFN_vkCmdBindShadingRateImageNV)getDeviceProcAddr(device, "vkCmdBindShadingRateImageNV"); pfn_vkCmdSetViewportShadingRatePaletteNV = (PFN_vkCmdSetViewportShadingRatePaletteNV)getDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV"); pfn_vkCmdSetCoarseSampleOrderNV = (PFN_vkCmdSetCoarseSampleOrderNV)getDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV"); int success = 1; success = success && (pfn_vkCmdBindShadingRateImageNV != 0); success = success && (pfn_vkCmdSetViewportShadingRatePaletteNV != 0); success = success && (pfn_vkCmdSetCoarseSampleOrderNV != 0); has_VK_NV_shading_rate_image = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_ray_tracing static PFN_vkCreateAccelerationStructureNV pfn_vkCreateAccelerationStructureNV = 0; static PFN_vkDestroyAccelerationStructureNV pfn_vkDestroyAccelerationStructureNV = 0; static PFN_vkGetAccelerationStructureMemoryRequirementsNV pfn_vkGetAccelerationStructureMemoryRequirementsNV = 0; static PFN_vkBindAccelerationStructureMemoryNV pfn_vkBindAccelerationStructureMemoryNV = 0; static PFN_vkCmdBuildAccelerationStructureNV pfn_vkCmdBuildAccelerationStructureNV = 0; static PFN_vkCmdCopyAccelerationStructureNV pfn_vkCmdCopyAccelerationStructureNV = 0; static PFN_vkCmdTraceRaysNV pfn_vkCmdTraceRaysNV = 0; static PFN_vkCreateRayTracingPipelinesNV pfn_vkCreateRayTracingPipelinesNV = 0; static PFN_vkGetRayTracingShaderGroupHandlesNV pfn_vkGetRayTracingShaderGroupHandlesNV = 0; static PFN_vkGetAccelerationStructureHandleNV pfn_vkGetAccelerationStructureHandleNV = 0; static PFN_vkCmdWriteAccelerationStructuresPropertiesNV pfn_vkCmdWriteAccelerationStructuresPropertiesNV = 0; static PFN_vkCompileDeferredNV pfn_vkCompileDeferredNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureNV( VkDevice device, const VkAccelerationStructureCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureNV* pAccelerationStructure) { assert(pfn_vkCreateAccelerationStructureNV); return pfn_vkCreateAccelerationStructureNV(device, pCreateInfo, pAllocator, pAccelerationStructure); } VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureNV( VkDevice device, VkAccelerationStructureNV accelerationStructure, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyAccelerationStructureNV); pfn_vkDestroyAccelerationStructureNV(device, accelerationStructure, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureMemoryRequirementsNV( VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements) { assert(pfn_vkGetAccelerationStructureMemoryRequirementsNV); pfn_vkGetAccelerationStructureMemoryRequirementsNV(device, pInfo, pMemoryRequirements); } VKAPI_ATTR VkResult VKAPI_CALL vkBindAccelerationStructureMemoryNV( VkDevice device, uint32_t bindInfoCount, const VkBindAccelerationStructureMemoryInfoNV* pBindInfos) { assert(pfn_vkBindAccelerationStructureMemoryNV); return pfn_vkBindAccelerationStructureMemoryNV(device, bindInfoCount, pBindInfos); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureNV( VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo, VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkBuffer scratch, VkDeviceSize scratchOffset) { assert(pfn_vkCmdBuildAccelerationStructureNV); pfn_vkCmdBuildAccelerationStructureNV(commandBuffer, pInfo, instanceData, instanceOffset, update, dst, src, scratch, scratchOffset); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureNV( VkCommandBuffer commandBuffer, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkCopyAccelerationStructureModeNV mode) { assert(pfn_vkCmdCopyAccelerationStructureNV); pfn_vkCmdCopyAccelerationStructureNV(commandBuffer, dst, src, mode); } VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysNV( VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, uint32_t width, uint32_t height, uint32_t depth) { assert(pfn_vkCmdTraceRaysNV); pfn_vkCmdTraceRaysNV(commandBuffer, raygenShaderBindingTableBuffer, raygenShaderBindingOffset, missShaderBindingTableBuffer, missShaderBindingOffset, missShaderBindingStride, hitShaderBindingTableBuffer, hitShaderBindingOffset, hitShaderBindingStride, callableShaderBindingTableBuffer, callableShaderBindingOffset, callableShaderBindingStride, width, height, depth); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesNV( VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoNV* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) { assert(pfn_vkCreateRayTracingPipelinesNV); return pfn_vkCreateRayTracingPipelinesNV(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesNV( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingShaderGroupHandlesNV); return pfn_vkGetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureHandleNV( VkDevice device, VkAccelerationStructureNV accelerationStructure, size_t dataSize, void* pData) { assert(pfn_vkGetAccelerationStructureHandleNV); return pfn_vkGetAccelerationStructureHandleNV(device, accelerationStructure, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesNV( VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) { assert(pfn_vkCmdWriteAccelerationStructuresPropertiesNV); pfn_vkCmdWriteAccelerationStructuresPropertiesNV(commandBuffer, accelerationStructureCount, pAccelerationStructures, queryType, queryPool, firstQuery); } VKAPI_ATTR VkResult VKAPI_CALL vkCompileDeferredNV( VkDevice device, VkPipeline pipeline, uint32_t shader) { assert(pfn_vkCompileDeferredNV); return pfn_vkCompileDeferredNV(device, pipeline, shader); } int has_VK_NV_ray_tracing = 0; int load_VK_NV_ray_tracing(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateAccelerationStructureNV = (PFN_vkCreateAccelerationStructureNV)getDeviceProcAddr(device, "vkCreateAccelerationStructureNV"); pfn_vkDestroyAccelerationStructureNV = (PFN_vkDestroyAccelerationStructureNV)getDeviceProcAddr(device, "vkDestroyAccelerationStructureNV"); pfn_vkGetAccelerationStructureMemoryRequirementsNV = (PFN_vkGetAccelerationStructureMemoryRequirementsNV)getDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV"); pfn_vkBindAccelerationStructureMemoryNV = (PFN_vkBindAccelerationStructureMemoryNV)getDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV"); pfn_vkCmdBuildAccelerationStructureNV = (PFN_vkCmdBuildAccelerationStructureNV)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV"); pfn_vkCmdCopyAccelerationStructureNV = (PFN_vkCmdCopyAccelerationStructureNV)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV"); pfn_vkCmdTraceRaysNV = (PFN_vkCmdTraceRaysNV)getDeviceProcAddr(device, "vkCmdTraceRaysNV"); pfn_vkCreateRayTracingPipelinesNV = (PFN_vkCreateRayTracingPipelinesNV)getDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV"); pfn_vkGetRayTracingShaderGroupHandlesNV = (PFN_vkGetRayTracingShaderGroupHandlesNV)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV"); pfn_vkGetAccelerationStructureHandleNV = (PFN_vkGetAccelerationStructureHandleNV)getDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV"); pfn_vkCmdWriteAccelerationStructuresPropertiesNV = (PFN_vkCmdWriteAccelerationStructuresPropertiesNV)getDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV"); pfn_vkCompileDeferredNV = (PFN_vkCompileDeferredNV)getDeviceProcAddr(device, "vkCompileDeferredNV"); int success = 1; success = success && (pfn_vkCreateAccelerationStructureNV != 0); success = success && (pfn_vkDestroyAccelerationStructureNV != 0); success = success && (pfn_vkGetAccelerationStructureMemoryRequirementsNV != 0); success = success && (pfn_vkBindAccelerationStructureMemoryNV != 0); success = success && (pfn_vkCmdBuildAccelerationStructureNV != 0); success = success && (pfn_vkCmdCopyAccelerationStructureNV != 0); success = success && (pfn_vkCmdTraceRaysNV != 0); success = success && (pfn_vkCreateRayTracingPipelinesNV != 0); success = success && (pfn_vkGetRayTracingShaderGroupHandlesNV != 0); success = success && (pfn_vkGetAccelerationStructureHandleNV != 0); success = success && (pfn_vkCmdWriteAccelerationStructuresPropertiesNV != 0); success = success && (pfn_vkCompileDeferredNV != 0); has_VK_NV_ray_tracing = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_draw_indirect_count static PFN_vkCmdDrawIndirectCountKHR pfn_vkCmdDrawIndirectCountKHR = 0; static PFN_vkCmdDrawIndexedIndirectCountKHR pfn_vkCmdDrawIndexedIndirectCountKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountKHR( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawIndirectCountKHR); pfn_vkCmdDrawIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawIndexedIndirectCountKHR); pfn_vkCmdDrawIndexedIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } int has_VK_KHR_draw_indirect_count = 0; int load_VK_KHR_draw_indirect_count(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdDrawIndirectCountKHR = (PFN_vkCmdDrawIndirectCountKHR)getDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR"); pfn_vkCmdDrawIndexedIndirectCountKHR = (PFN_vkCmdDrawIndexedIndirectCountKHR)getDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR"); int success = 1; success = success && (pfn_vkCmdDrawIndirectCountKHR != 0); success = success && (pfn_vkCmdDrawIndexedIndirectCountKHR != 0); has_VK_KHR_draw_indirect_count = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_calibrated_timestamps static PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = 0; static PFN_vkGetCalibratedTimestampsEXT pfn_vkGetCalibratedTimestampsEXT = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainEXT* pTimeDomains) { assert(pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT); return pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice, pTimeDomainCount, pTimeDomains); } VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT( VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation) { assert(pfn_vkGetCalibratedTimestampsEXT); return pfn_vkGetCalibratedTimestampsEXT(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation); } int has_VK_EXT_calibrated_timestamps = 0; int load_VK_EXT_calibrated_timestamps(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)getDeviceProcAddr(device, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT"); pfn_vkGetCalibratedTimestampsEXT = (PFN_vkGetCalibratedTimestampsEXT)getDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT != 0); success = success && (pfn_vkGetCalibratedTimestampsEXT != 0); has_VK_EXT_calibrated_timestamps = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_mesh_shader static PFN_vkCmdDrawMeshTasksNV pfn_vkCmdDrawMeshTasksNV = 0; static PFN_vkCmdDrawMeshTasksIndirectNV pfn_vkCmdDrawMeshTasksIndirectNV = 0; static PFN_vkCmdDrawMeshTasksIndirectCountNV pfn_vkCmdDrawMeshTasksIndirectCountNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksNV( VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) { assert(pfn_vkCmdDrawMeshTasksNV); pfn_vkCmdDrawMeshTasksNV(commandBuffer, taskCount, firstTask); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectNV( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { assert(pfn_vkCmdDrawMeshTasksIndirectNV); pfn_vkCmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawMeshTasksIndirectCountNV); pfn_vkCmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } int has_VK_NV_mesh_shader = 0; int load_VK_NV_mesh_shader(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdDrawMeshTasksNV = (PFN_vkCmdDrawMeshTasksNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksNV"); pfn_vkCmdDrawMeshTasksIndirectNV = (PFN_vkCmdDrawMeshTasksIndirectNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV"); pfn_vkCmdDrawMeshTasksIndirectCountNV = (PFN_vkCmdDrawMeshTasksIndirectCountNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV"); int success = 1; success = success && (pfn_vkCmdDrawMeshTasksNV != 0); success = success && (pfn_vkCmdDrawMeshTasksIndirectNV != 0); success = success && (pfn_vkCmdDrawMeshTasksIndirectCountNV != 0); has_VK_NV_mesh_shader = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_scissor_exclusive static PFN_vkCmdSetExclusiveScissorNV pfn_vkCmdSetExclusiveScissorNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors) { assert(pfn_vkCmdSetExclusiveScissorNV); pfn_vkCmdSetExclusiveScissorNV(commandBuffer, firstExclusiveScissor, exclusiveScissorCount, pExclusiveScissors); } int has_VK_NV_scissor_exclusive = 0; int load_VK_NV_scissor_exclusive(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdSetExclusiveScissorNV = (PFN_vkCmdSetExclusiveScissorNV)getDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV"); int success = 1; success = success && (pfn_vkCmdSetExclusiveScissorNV != 0); has_VK_NV_scissor_exclusive = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_buffer_device_address static PFN_vkGetBufferDeviceAddressEXT pfn_vkGetBufferDeviceAddressEXT = 0; VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressEXT( VkDevice device, const VkBufferDeviceAddressInfoEXT* pInfo) { assert(pfn_vkGetBufferDeviceAddressEXT); return pfn_vkGetBufferDeviceAddressEXT(device, pInfo); } int has_VK_EXT_buffer_device_address = 0; int load_VK_EXT_buffer_device_address(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetBufferDeviceAddressEXT = (PFN_vkGetBufferDeviceAddressEXT)getDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT"); int success = 1; success = success && (pfn_vkGetBufferDeviceAddressEXT != 0); has_VK_EXT_buffer_device_address = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_cooperative_matrix static PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesNV( VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesNV* pProperties) { assert(pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV); return pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice, pPropertyCount, pProperties); } int has_VK_NV_cooperative_matrix = 0; int load_VK_NV_cooperative_matrix(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)getDeviceProcAddr(device, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV != 0); has_VK_NV_cooperative_matrix = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_coverage_reduction_mode static PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV( VkPhysicalDevice physicalDevice, uint32_t* pCombinationCount, VkFramebufferMixedSamplesCombinationNV* pCombinations) { assert(pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV); return pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice, pCombinationCount, pCombinations); } int has_VK_NV_coverage_reduction_mode = 0; int load_VK_NV_coverage_reduction_mode(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = (PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)getDeviceProcAddr(device, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV != 0); has_VK_NV_coverage_reduction_mode = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_buffer_device_address static PFN_vkGetBufferDeviceAddressKHR pfn_vkGetBufferDeviceAddressKHR = 0; static PFN_vkGetBufferOpaqueCaptureAddressKHR pfn_vkGetBufferOpaqueCaptureAddressKHR = 0; static PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = 0; VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressKHR( VkDevice device, const VkBufferDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetBufferDeviceAddressKHR); return pfn_vkGetBufferDeviceAddressKHR(device, pInfo); } VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddressKHR( VkDevice device, const VkBufferDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetBufferOpaqueCaptureAddressKHR); return pfn_vkGetBufferOpaqueCaptureAddressKHR(device, pInfo); } VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddressKHR( VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfoKHR* pInfo) { assert(pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR); return pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR(device, pInfo); } int has_VK_KHR_buffer_device_address = 0; int load_VK_KHR_buffer_device_address(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)getDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"); pfn_vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)getDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR"); pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)getDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR"); int success = 1; success = success && (pfn_vkGetBufferDeviceAddressKHR != 0); success = success && (pfn_vkGetBufferOpaqueCaptureAddressKHR != 0); success = success && (pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR != 0); has_VK_KHR_buffer_device_address = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_host_query_reset static PFN_vkResetQueryPoolEXT pfn_vkResetQueryPoolEXT = 0; VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT( VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) { assert(pfn_vkResetQueryPoolEXT); pfn_vkResetQueryPoolEXT(device, queryPool, firstQuery, queryCount); } int has_VK_EXT_host_query_reset = 0; int load_VK_EXT_host_query_reset(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkResetQueryPoolEXT = (PFN_vkResetQueryPoolEXT)getDeviceProcAddr(device, "vkResetQueryPoolEXT"); int success = 1; success = success && (pfn_vkResetQueryPoolEXT != 0); has_VK_EXT_host_query_reset = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_pipeline_executable_properties static PFN_vkGetPipelineExecutablePropertiesKHR pfn_vkGetPipelineExecutablePropertiesKHR = 0; static PFN_vkGetPipelineExecutableStatisticsKHR pfn_vkGetPipelineExecutableStatisticsKHR = 0; static PFN_vkGetPipelineExecutableInternalRepresentationsKHR pfn_vkGetPipelineExecutableInternalRepresentationsKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutablePropertiesKHR( VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, uint32_t* pExecutableCount, VkPipelineExecutablePropertiesKHR* pProperties) { assert(pfn_vkGetPipelineExecutablePropertiesKHR); return pfn_vkGetPipelineExecutablePropertiesKHR(device, pPipelineInfo, pExecutableCount, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableStatisticsKHR( VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pStatisticCount, VkPipelineExecutableStatisticKHR* pStatistics) { assert(pfn_vkGetPipelineExecutableStatisticsKHR); return pfn_vkGetPipelineExecutableStatisticsKHR(device, pExecutableInfo, pStatisticCount, pStatistics); } VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR( VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pInternalRepresentationCount, VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations) { assert(pfn_vkGetPipelineExecutableInternalRepresentationsKHR); return pfn_vkGetPipelineExecutableInternalRepresentationsKHR(device, pExecutableInfo, pInternalRepresentationCount, pInternalRepresentations); } int has_VK_KHR_pipeline_executable_properties = 0; int load_VK_KHR_pipeline_executable_properties(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)getDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR"); pfn_vkGetPipelineExecutableStatisticsKHR = (PFN_vkGetPipelineExecutableStatisticsKHR)getDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR"); pfn_vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)getDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR"); int success = 1; success = success && (pfn_vkGetPipelineExecutablePropertiesKHR != 0); success = success && (pfn_vkGetPipelineExecutableStatisticsKHR != 0); success = success && (pfn_vkGetPipelineExecutableInternalRepresentationsKHR != 0); has_VK_KHR_pipeline_executable_properties = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_device_generated_commands static PFN_vkGetGeneratedCommandsMemoryRequirementsNV pfn_vkGetGeneratedCommandsMemoryRequirementsNV = 0; static PFN_vkCmdPreprocessGeneratedCommandsNV pfn_vkCmdPreprocessGeneratedCommandsNV = 0; static PFN_vkCmdExecuteGeneratedCommandsNV pfn_vkCmdExecuteGeneratedCommandsNV = 0; static PFN_vkCmdBindPipelineShaderGroupNV pfn_vkCmdBindPipelineShaderGroupNV = 0; static PFN_vkCreateIndirectCommandsLayoutNV pfn_vkCreateIndirectCommandsLayoutNV = 0; static PFN_vkDestroyIndirectCommandsLayoutNV pfn_vkDestroyIndirectCommandsLayoutNV = 0; VKAPI_ATTR void VKAPI_CALL vkGetGeneratedCommandsMemoryRequirementsNV( VkDevice device, const VkGeneratedCommandsMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2* pMemoryRequirements) { assert(pfn_vkGetGeneratedCommandsMemoryRequirementsNV); pfn_vkGetGeneratedCommandsMemoryRequirementsNV(device, pInfo, pMemoryRequirements); } VKAPI_ATTR void VKAPI_CALL vkCmdPreprocessGeneratedCommandsNV( VkCommandBuffer commandBuffer, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo) { assert(pfn_vkCmdPreprocessGeneratedCommandsNV); pfn_vkCmdPreprocessGeneratedCommandsNV(commandBuffer, pGeneratedCommandsInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdExecuteGeneratedCommandsNV( VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo) { assert(pfn_vkCmdExecuteGeneratedCommandsNV); pfn_vkCmdExecuteGeneratedCommandsNV(commandBuffer, isPreprocessed, pGeneratedCommandsInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdBindPipelineShaderGroupNV( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, uint32_t groupIndex) { assert(pfn_vkCmdBindPipelineShaderGroupNV); pfn_vkCmdBindPipelineShaderGroupNV(commandBuffer, pipelineBindPoint, pipeline, groupIndex); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNV( VkDevice device, const VkIndirectCommandsLayoutCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNV* pIndirectCommandsLayout) { assert(pfn_vkCreateIndirectCommandsLayoutNV); return pfn_vkCreateIndirectCommandsLayoutNV(device, pCreateInfo, pAllocator, pIndirectCommandsLayout); } VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNV( VkDevice device, VkIndirectCommandsLayoutNV indirectCommandsLayout, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyIndirectCommandsLayoutNV); pfn_vkDestroyIndirectCommandsLayoutNV(device, indirectCommandsLayout, pAllocator); } int has_VK_NV_device_generated_commands = 0; int load_VK_NV_device_generated_commands(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetGeneratedCommandsMemoryRequirementsNV = (PFN_vkGetGeneratedCommandsMemoryRequirementsNV)getDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV"); pfn_vkCmdPreprocessGeneratedCommandsNV = (PFN_vkCmdPreprocessGeneratedCommandsNV)getDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV"); pfn_vkCmdExecuteGeneratedCommandsNV = (PFN_vkCmdExecuteGeneratedCommandsNV)getDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV"); pfn_vkCmdBindPipelineShaderGroupNV = (PFN_vkCmdBindPipelineShaderGroupNV)getDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV"); pfn_vkCreateIndirectCommandsLayoutNV = (PFN_vkCreateIndirectCommandsLayoutNV)getDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV"); pfn_vkDestroyIndirectCommandsLayoutNV = (PFN_vkDestroyIndirectCommandsLayoutNV)getDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV"); int success = 1; success = success && (pfn_vkGetGeneratedCommandsMemoryRequirementsNV != 0); success = success && (pfn_vkCmdPreprocessGeneratedCommandsNV != 0); success = success && (pfn_vkCmdExecuteGeneratedCommandsNV != 0); success = success && (pfn_vkCmdBindPipelineShaderGroupNV != 0); success = success && (pfn_vkCreateIndirectCommandsLayoutNV != 0); success = success && (pfn_vkDestroyIndirectCommandsLayoutNV != 0); has_VK_NV_device_generated_commands = success; return success; } #endif /* super load/reset */ void load_VK_EXTENSION_SUBSET(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { #if VK_EXT_debug_marker load_VK_EXT_debug_marker(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_memory_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_memory_fd load_VK_KHR_external_memory_fd(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_semaphore_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_semaphore_fd load_VK_KHR_external_semaphore_fd(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_push_descriptor load_VK_KHR_push_descriptor(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_create_renderpass2 load_VK_KHR_create_renderpass2(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_fence_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_debug_utils load_VK_EXT_debug_utils(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_sample_locations load_VK_EXT_sample_locations(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_acceleration_structure load_VK_KHR_acceleration_structure(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_ray_tracing_pipeline load_VK_KHR_ray_tracing_pipeline(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_shading_rate_image load_VK_NV_shading_rate_image(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_ray_tracing load_VK_NV_ray_tracing(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_draw_indirect_count load_VK_KHR_draw_indirect_count(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_calibrated_timestamps load_VK_EXT_calibrated_timestamps(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_mesh_shader load_VK_NV_mesh_shader(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_scissor_exclusive load_VK_NV_scissor_exclusive(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_buffer_device_address load_VK_EXT_buffer_device_address(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_cooperative_matrix load_VK_NV_cooperative_matrix(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_coverage_reduction_mode load_VK_NV_coverage_reduction_mode(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_buffer_device_address load_VK_KHR_buffer_device_address(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_host_query_reset load_VK_EXT_host_query_reset(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_pipeline_executable_properties load_VK_KHR_pipeline_executable_properties(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_device_generated_commands load_VK_NV_device_generated_commands(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif } void reset_VK_EXTENSION_SUBSET() { #if VK_EXT_debug_marker has_VK_EXT_debug_marker = 0; PFN_vkDebugMarkerSetObjectTagEXT pfn_vkDebugMarkerSetObjectTagEXT = 0; PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT = 0; PFN_vkCmdDebugMarkerBeginEXT pfn_vkCmdDebugMarkerBeginEXT = 0; PFN_vkCmdDebugMarkerEndEXT pfn_vkCmdDebugMarkerEndEXT = 0; PFN_vkCmdDebugMarkerInsertEXT pfn_vkCmdDebugMarkerInsertEXT = 0; #endif #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_memory_win32 = 0; PFN_vkGetMemoryWin32HandleKHR pfn_vkGetMemoryWin32HandleKHR = 0; PFN_vkGetMemoryWin32HandlePropertiesKHR pfn_vkGetMemoryWin32HandlePropertiesKHR = 0; #endif #if VK_KHR_external_memory_fd has_VK_KHR_external_memory_fd = 0; PFN_vkGetMemoryFdKHR pfn_vkGetMemoryFdKHR = 0; PFN_vkGetMemoryFdPropertiesKHR pfn_vkGetMemoryFdPropertiesKHR = 0; #endif #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_semaphore_win32 = 0; PFN_vkImportSemaphoreWin32HandleKHR pfn_vkImportSemaphoreWin32HandleKHR = 0; PFN_vkGetSemaphoreWin32HandleKHR pfn_vkGetSemaphoreWin32HandleKHR = 0; #endif #if VK_KHR_external_semaphore_fd has_VK_KHR_external_semaphore_fd = 0; PFN_vkImportSemaphoreFdKHR pfn_vkImportSemaphoreFdKHR = 0; PFN_vkGetSemaphoreFdKHR pfn_vkGetSemaphoreFdKHR = 0; #endif #if VK_KHR_push_descriptor has_VK_KHR_push_descriptor = 0; PFN_vkCmdPushDescriptorSetKHR pfn_vkCmdPushDescriptorSetKHR = 0; PFN_vkCmdPushDescriptorSetWithTemplateKHR pfn_vkCmdPushDescriptorSetWithTemplateKHR = 0; #endif #if VK_KHR_create_renderpass2 has_VK_KHR_create_renderpass2 = 0; PFN_vkCreateRenderPass2KHR pfn_vkCreateRenderPass2KHR = 0; PFN_vkCmdBeginRenderPass2KHR pfn_vkCmdBeginRenderPass2KHR = 0; PFN_vkCmdNextSubpass2KHR pfn_vkCmdNextSubpass2KHR = 0; PFN_vkCmdEndRenderPass2KHR pfn_vkCmdEndRenderPass2KHR = 0; #endif #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_fence_win32 = 0; PFN_vkImportFenceWin32HandleKHR pfn_vkImportFenceWin32HandleKHR = 0; PFN_vkGetFenceWin32HandleKHR pfn_vkGetFenceWin32HandleKHR = 0; #endif #if VK_EXT_debug_utils has_VK_EXT_debug_utils = 0; PFN_vkSetDebugUtilsObjectNameEXT pfn_vkSetDebugUtilsObjectNameEXT = 0; PFN_vkSetDebugUtilsObjectTagEXT pfn_vkSetDebugUtilsObjectTagEXT = 0; PFN_vkQueueBeginDebugUtilsLabelEXT pfn_vkQueueBeginDebugUtilsLabelEXT = 0; PFN_vkQueueEndDebugUtilsLabelEXT pfn_vkQueueEndDebugUtilsLabelEXT = 0; PFN_vkQueueInsertDebugUtilsLabelEXT pfn_vkQueueInsertDebugUtilsLabelEXT = 0; PFN_vkCmdBeginDebugUtilsLabelEXT pfn_vkCmdBeginDebugUtilsLabelEXT = 0; PFN_vkCmdEndDebugUtilsLabelEXT pfn_vkCmdEndDebugUtilsLabelEXT = 0; PFN_vkCmdInsertDebugUtilsLabelEXT pfn_vkCmdInsertDebugUtilsLabelEXT = 0; PFN_vkCreateDebugUtilsMessengerEXT pfn_vkCreateDebugUtilsMessengerEXT = 0; PFN_vkDestroyDebugUtilsMessengerEXT pfn_vkDestroyDebugUtilsMessengerEXT = 0; PFN_vkSubmitDebugUtilsMessageEXT pfn_vkSubmitDebugUtilsMessageEXT = 0; #endif #if VK_EXT_sample_locations has_VK_EXT_sample_locations = 0; PFN_vkCmdSetSampleLocationsEXT pfn_vkCmdSetSampleLocationsEXT = 0; PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = 0; #endif #if VK_KHR_acceleration_structure has_VK_KHR_acceleration_structure = 0; PFN_vkCreateAccelerationStructureKHR pfn_vkCreateAccelerationStructureKHR = 0; PFN_vkDestroyAccelerationStructureKHR pfn_vkDestroyAccelerationStructureKHR = 0; PFN_vkCmdBuildAccelerationStructuresKHR pfn_vkCmdBuildAccelerationStructuresKHR = 0; PFN_vkCmdBuildAccelerationStructuresIndirectKHR pfn_vkCmdBuildAccelerationStructuresIndirectKHR = 0; PFN_vkBuildAccelerationStructuresKHR pfn_vkBuildAccelerationStructuresKHR = 0; PFN_vkCopyAccelerationStructureKHR pfn_vkCopyAccelerationStructureKHR = 0; PFN_vkCopyAccelerationStructureToMemoryKHR pfn_vkCopyAccelerationStructureToMemoryKHR = 0; PFN_vkCopyMemoryToAccelerationStructureKHR pfn_vkCopyMemoryToAccelerationStructureKHR = 0; PFN_vkWriteAccelerationStructuresPropertiesKHR pfn_vkWriteAccelerationStructuresPropertiesKHR = 0; PFN_vkCmdCopyAccelerationStructureKHR pfn_vkCmdCopyAccelerationStructureKHR = 0; PFN_vkCmdCopyAccelerationStructureToMemoryKHR pfn_vkCmdCopyAccelerationStructureToMemoryKHR = 0; PFN_vkCmdCopyMemoryToAccelerationStructureKHR pfn_vkCmdCopyMemoryToAccelerationStructureKHR = 0; PFN_vkGetAccelerationStructureDeviceAddressKHR pfn_vkGetAccelerationStructureDeviceAddressKHR = 0; PFN_vkCmdWriteAccelerationStructuresPropertiesKHR pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = 0; PFN_vkGetDeviceAccelerationStructureCompatibilityKHR pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = 0; PFN_vkGetAccelerationStructureBuildSizesKHR pfn_vkGetAccelerationStructureBuildSizesKHR = 0; #endif #if VK_KHR_ray_tracing_pipeline has_VK_KHR_ray_tracing_pipeline = 0; PFN_vkCmdTraceRaysKHR pfn_vkCmdTraceRaysKHR = 0; PFN_vkCreateRayTracingPipelinesKHR pfn_vkCreateRayTracingPipelinesKHR = 0; PFN_vkGetRayTracingShaderGroupHandlesKHR pfn_vkGetRayTracingShaderGroupHandlesKHR = 0; PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = 0; PFN_vkCmdTraceRaysIndirectKHR pfn_vkCmdTraceRaysIndirectKHR = 0; PFN_vkGetRayTracingShaderGroupStackSizeKHR pfn_vkGetRayTracingShaderGroupStackSizeKHR = 0; PFN_vkCmdSetRayTracingPipelineStackSizeKHR pfn_vkCmdSetRayTracingPipelineStackSizeKHR = 0; #endif #if VK_NV_shading_rate_image has_VK_NV_shading_rate_image = 0; PFN_vkCmdBindShadingRateImageNV pfn_vkCmdBindShadingRateImageNV = 0; PFN_vkCmdSetViewportShadingRatePaletteNV pfn_vkCmdSetViewportShadingRatePaletteNV = 0; PFN_vkCmdSetCoarseSampleOrderNV pfn_vkCmdSetCoarseSampleOrderNV = 0; #endif #if VK_NV_ray_tracing has_VK_NV_ray_tracing = 0; PFN_vkCreateAccelerationStructureNV pfn_vkCreateAccelerationStructureNV = 0; PFN_vkDestroyAccelerationStructureNV pfn_vkDestroyAccelerationStructureNV = 0; PFN_vkGetAccelerationStructureMemoryRequirementsNV pfn_vkGetAccelerationStructureMemoryRequirementsNV = 0; PFN_vkBindAccelerationStructureMemoryNV pfn_vkBindAccelerationStructureMemoryNV = 0; PFN_vkCmdBuildAccelerationStructureNV pfn_vkCmdBuildAccelerationStructureNV = 0; PFN_vkCmdCopyAccelerationStructureNV pfn_vkCmdCopyAccelerationStructureNV = 0; PFN_vkCmdTraceRaysNV pfn_vkCmdTraceRaysNV = 0; PFN_vkCreateRayTracingPipelinesNV pfn_vkCreateRayTracingPipelinesNV = 0; PFN_vkGetRayTracingShaderGroupHandlesNV pfn_vkGetRayTracingShaderGroupHandlesNV = 0; PFN_vkGetAccelerationStructureHandleNV pfn_vkGetAccelerationStructureHandleNV = 0; PFN_vkCmdWriteAccelerationStructuresPropertiesNV pfn_vkCmdWriteAccelerationStructuresPropertiesNV = 0; PFN_vkCompileDeferredNV pfn_vkCompileDeferredNV = 0; #endif #if VK_KHR_draw_indirect_count has_VK_KHR_draw_indirect_count = 0; PFN_vkCmdDrawIndirectCountKHR pfn_vkCmdDrawIndirectCountKHR = 0; PFN_vkCmdDrawIndexedIndirectCountKHR pfn_vkCmdDrawIndexedIndirectCountKHR = 0; #endif #if VK_EXT_calibrated_timestamps has_VK_EXT_calibrated_timestamps = 0; PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = 0; PFN_vkGetCalibratedTimestampsEXT pfn_vkGetCalibratedTimestampsEXT = 0; #endif #if VK_NV_mesh_shader has_VK_NV_mesh_shader = 0; PFN_vkCmdDrawMeshTasksNV pfn_vkCmdDrawMeshTasksNV = 0; PFN_vkCmdDrawMeshTasksIndirectNV pfn_vkCmdDrawMeshTasksIndirectNV = 0; PFN_vkCmdDrawMeshTasksIndirectCountNV pfn_vkCmdDrawMeshTasksIndirectCountNV = 0; #endif #if VK_NV_scissor_exclusive has_VK_NV_scissor_exclusive = 0; PFN_vkCmdSetExclusiveScissorNV pfn_vkCmdSetExclusiveScissorNV = 0; #endif #if VK_EXT_buffer_device_address has_VK_EXT_buffer_device_address = 0; PFN_vkGetBufferDeviceAddressEXT pfn_vkGetBufferDeviceAddressEXT = 0; #endif #if VK_NV_cooperative_matrix has_VK_NV_cooperative_matrix = 0; PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0; #endif #if VK_NV_coverage_reduction_mode has_VK_NV_coverage_reduction_mode = 0; PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = 0; #endif #if VK_KHR_buffer_device_address has_VK_KHR_buffer_device_address = 0; PFN_vkGetBufferDeviceAddressKHR pfn_vkGetBufferDeviceAddressKHR = 0; PFN_vkGetBufferOpaqueCaptureAddressKHR pfn_vkGetBufferOpaqueCaptureAddressKHR = 0; PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = 0; #endif #if VK_EXT_host_query_reset has_VK_EXT_host_query_reset = 0; PFN_vkResetQueryPoolEXT pfn_vkResetQueryPoolEXT = 0; #endif #if VK_KHR_pipeline_executable_properties has_VK_KHR_pipeline_executable_properties = 0; PFN_vkGetPipelineExecutablePropertiesKHR pfn_vkGetPipelineExecutablePropertiesKHR = 0; PFN_vkGetPipelineExecutableStatisticsKHR pfn_vkGetPipelineExecutableStatisticsKHR = 0; PFN_vkGetPipelineExecutableInternalRepresentationsKHR pfn_vkGetPipelineExecutableInternalRepresentationsKHR = 0; #endif #if VK_NV_device_generated_commands has_VK_NV_device_generated_commands = 0; PFN_vkGetGeneratedCommandsMemoryRequirementsNV pfn_vkGetGeneratedCommandsMemoryRequirementsNV = 0; PFN_vkCmdPreprocessGeneratedCommandsNV pfn_vkCmdPreprocessGeneratedCommandsNV = 0; PFN_vkCmdExecuteGeneratedCommandsNV pfn_vkCmdExecuteGeneratedCommandsNV = 0; PFN_vkCmdBindPipelineShaderGroupNV pfn_vkCmdBindPipelineShaderGroupNV = 0; PFN_vkCreateIndirectCommandsLayoutNV pfn_vkCreateIndirectCommandsLayoutNV = 0; PFN_vkDestroyIndirectCommandsLayoutNV pfn_vkDestroyIndirectCommandsLayoutNV = 0; #endif } #if defined(ERM_OSX) # pragma clang diagnostic pop #endif
47.634384
367
0.862479
JALB91
5e85639fac693539d79a0ea70f2d78fb56224e58
3,489
cpp
C++
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
// This file is part of QIpMsg. // // QIpMsg 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, either version 3 of the License, or // (at your option) any later version. // // QIpMsg 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 QIpMsg. If not, see <http://www.gnu.org/licenses/>. // #include "dir_dialog.h" #include "global.h" #include "preferences.h" #include "send_file_model.h" #include <QtGui> #include <QtCore> DirDialog::DirDialog(SendFileModel *sendFileModel, QWidget *parent) : QDialog(parent), m_sendFileModel(sendFileModel) { // Delete when close setAttribute(Qt::WA_DeleteOnClose, true); QStringList nameFilter; model = new QDirModel(nameFilter, QDir::Dirs | QDir::Readable | QDir::NoDotAndDotDot, QDir::Name); tree = new QTreeView; tree->setModel(model); tree->hideColumn(1); // Hide size column tree->hideColumn(2); // Hide type column tree->hideColumn(3); // Hide time column tree->header()->hide(); // Hide header selectionModel = new QItemSelectionModel(model); tree->setSelectionModel(selectionModel); // Expanded to the last send directory expandTree(); // Scroll to last dir path tree->verticalScrollBar() ->setValue(model->index(Global::preferences->lastSendDirPath).row()); // Set the default selected directory selectionModel->select(model->index(Global::preferences->lastSendDirPath), QItemSelectionModel::Select | QItemSelectionModel::Rows); QLabel *label = new QLabel(tr("Select folder to send")); createButtonLayout(); createConnections(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(label); mainLayout->addSpacing(10); mainLayout->addWidget(tree); mainLayout->addSpacing(10); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); setWindowTitle(tr("Browser Folders")); adjustSize(); } QSize DirDialog::sizeHint() const { return QSize(400, 480); } void DirDialog::selectDir() { QModelIndexList modelIndexList = selectionModel->selectedRows(0); foreach (QModelIndex ix, modelIndexList) { QFileInfo fi = model->fileInfo(ix); QString filePath = fi.absoluteFilePath(); m_sendFileModel->addFile(filePath); Global::preferences->lastSendDirPath = fi.absoluteFilePath(); } emit dirSelected(); close(); } void DirDialog::createConnections() { connect(okButton, SIGNAL(clicked()), this, SLOT(selectDir())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); } void DirDialog::createButtonLayout() { okButton = new QPushButton(tr("Ok")); cancelButton = new QPushButton(tr("Cancel")); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(okButton); buttonsLayout->addSpacing(20); buttonsLayout->addWidget(cancelButton); } void DirDialog::expandTree() { QDir dir(Global::preferences->lastSendDirPath); while (dir.cdUp()) { tree->expand(model->index(dir.absolutePath())); } }
28.137097
78
0.685583
cuibo10
5e8675ab6269e5b629c34db078715762012c3017
2,239
cpp
C++
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
#include <iostream> #include <string> #include <regex> void regex_match(std::string str) { // regex_match // ([a-z ]){0, 99999} \\w - for letters, \\s - space std::cmatch result; std::regex regular("([\\w-]+)" "(@)" "([\\w-]+)" "(\.)" "(\\w{2,5})"); // 2-5 symbols // Convert to c-string if (std::regex_match(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_search1(std::string str) { //regex_search std::cmatch result; std::regex regular( "([\\w-]+:\\s)" // word, ':'sign with space "([\\w-]+)" // can be letter, number and '-'sign "(@)" // '@'sign "([\\w-]+)" // can be letter, number and '-'sign "\." // '.'sign "(\\w{2,5})");// can be letter (2-5 length) if (std::regex_search(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_search2(std::string str) { std::cmatch result; std::regex regular( "(: )" "([.]*[^\.]+)" // any quantity of any symbols| before '.'sing "(\.)"); if (std::regex_search(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_replace(std::string str) { std::regex regular("(: )" "([.]*[^\.]+)" "(\.)"); std::string result = regex_replace(str.c_str(), regular, " ---lulz--- "); std::cout << result << std::endl; } int main() { std::cout << "REGEX_MATCH" << std::endl; std::string email = "grigorchukmaxon1@gmail.com"; regex_match(email); std::cout << "\nREGEX_SEARCH\nFirst Example" << std::endl; std::string strWithEmail = "MyEmail: email@host.ua LOL11!!!"; regex_search1(strWithEmail); std::cout << "\nREGEX_SEARCH\nSecond Example" << std::endl; std::string str2WithEmail = "MyEmail: email@host.ua LOL11!!!"; regex_search2(str2WithEmail); std::cout << "\nREGEX_REPLACE" << std::endl; std::string str3WithEmail = "MyEmail: email@cuteNinja.org LOL11!!!"; regex_replace(str3WithEmail); }
23.568421
75
0.528808
Foxitute
5e88d1d5aeebe02d7f7f4f1b97284aecf5c8a7d1
587
hpp
C++
algorithms/p634/634.hpp
baishuai/leetcode_go
440ff08cf15e03ee64b3aa18370af1f75e958d18
[ "Apache-2.0" ]
9
2017-06-05T15:10:35.000Z
2021-06-08T03:10:46.000Z
algorithms/p634/634.hpp
baishuai/leetcode
440ff08cf15e03ee64b3aa18370af1f75e958d18
[ "Apache-2.0" ]
3
2017-07-12T14:08:39.000Z
2017-10-11T03:08:15.000Z
algorithms/p634/634.hpp
baishuai/leetcode_go
440ff08cf15e03ee64b3aa18370af1f75e958d18
[ "Apache-2.0" ]
1
2017-07-21T03:51:51.000Z
2017-07-21T03:51:51.000Z
// // Created by bai on 17-7-2. // #ifndef LEETCODE_634_HPP #define LEETCODE_634_HPP #include <iostream> #include <queue> #include <algorithm> #include <vector> #include <unordered_map> #include <unordered_set> #include <numeric> using namespace std; class Solution { public: int findDerangement(int n) { long long int a = 0, b = 1; const long long int mod = 1000000000 + 7; for (int i = 2; i <= n; ++i) { auto c = i * (a + b) % mod; a = b; b = c; } return (int) a; } }; #endif //LEETCODE_634_HPP
17.264706
49
0.565588
baishuai
5e897dbaaf5357c6b8f92d02714b43f492512ad3
1,965
cpp
C++
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; class FSM { class State* current; public: FSM(); void setCurrent( State* s ) { current = s; } void suckUpMoney( int ); void carDrivesThrough(); }; class State { int total; protected: int getTotal() { return total; } public: State() { total = 0; } virtual void suckUpMoney( int in, FSM* fsm ) { total += in; cout << "total is " << total << '\n'; } virtual void carDrivesThrough( FSM* fsm ) = 0; }; class GreenLight : public State { public: GreenLight() { cout << "GREEN light\n"; } void suckUpMoney( int in, FSM* fsm ) { cout << " You're an idiot, "; State::suckUpMoney( in, fsm ); } void carDrivesThrough( FSM* fsm ); }; class RedLight : public State { public: RedLight() { cout << "RED light\n"; } void suckUpMoney( int in, FSM* fsm ) { cout << " "; State::suckUpMoney( in, fsm ); if (getTotal() >= 50) { fsm->setCurrent( new GreenLight ); delete this; } } void carDrivesThrough( FSM* fsm ) { cout << "Sirens!! Heat-seeking missile!! Confiscate net worth!!\n"; fsm->setCurrent( new RedLight ); delete this; } }; FSM::FSM() { current = new RedLight(); } void FSM::suckUpMoney( int in ) { current->suckUpMoney( in, this ); } void FSM::carDrivesThrough() { current->carDrivesThrough( this ); } void GreenLight::carDrivesThrough( FSM* fsm ) { cout << "Good-bye sucker!!\n"; fsm->setCurrent( new RedLight ); delete this; } int getCoin() { static int choices[3] = { 5, 10, 25 }; return choices[rand() % 3]; } int main( void ) { srand( time(0) ); FSM fsm; int ans; while (true) { cout << " Shell out (1), Drive thru (2), Exit (0): "; cin >> ans; if (ans == 1) fsm.suckUpMoney( getCoin() ); else if (ans == 2) fsm.carDrivesThrough(); else break; } return 0; }
22.329545
75
0.572519
enuguru
5e8af562f28b066ea443d9d8ff45d4ff33e59849
11,316
cpp
C++
src/OpenCL/CLScene.cpp
mikoro/raycer
281cbd42cae21c8612ed99d10eb4c113e6daa3d1
[ "MIT" ]
31
2016-04-10T16:40:38.000Z
2021-11-19T13:01:34.000Z
src/OpenCL/CLScene.cpp
mikoro/raycer
281cbd42cae21c8612ed99d10eb4c113e6daa3d1
[ "MIT" ]
null
null
null
src/OpenCL/CLScene.cpp
mikoro/raycer
281cbd42cae21c8612ed99d10eb4c113e6daa3d1
[ "MIT" ]
3
2017-10-01T22:33:57.000Z
2019-08-17T12:29:33.000Z
// Copyright © 2015 Mikko Ronkainen <firstname@mikkoronkainen.com> // License: MIT, see the LICENSE file. #include "stdafx.h" #include "OpenCL/CLScene.h" #include "Raytracing/Scene.h" #include "App.h" #include "Utils/Log.h" using namespace Raycer; namespace { void readVector2(cl_float2& destination, const Vector2& source) { destination.s[0] = cl_float(source.x); destination.s[1] = cl_float(source.y); } void readVector3(cl_float4& destination, const Vector3& source) { destination.s[0] = cl_float(source.x); destination.s[1] = cl_float(source.y); destination.s[2] = cl_float(source.z); destination.s[3] = 0.0f; } void readColor(cl_float4& destination, const Color& source) { destination.s[0] = cl_float(source.r); destination.s[1] = cl_float(source.g); destination.s[2] = cl_float(source.b); destination.s[3] = cl_float(source.a); } void readEulerAngle(cl_float4& destination, const EulerAngle& source) { destination.s[0] = cl_float(source.pitch); destination.s[1] = cl_float(source.yaw); destination.s[2] = cl_float(source.roll); destination.s[3] = 0.0f; } uint64_t findMaterialIndex(const std::vector<Material>& materials, uint64_t materialId) { auto result = std::find_if(materials.begin(), materials.end(), [materialId](const Material& material) { return material.id == materialId; }); if (result == materials.end()) throw std::runtime_error(tfm::format("Could not find OpenCL material index for material id (%d)", materialId)); return (result - materials.begin()); } cl_int findTextureIndex(const std::vector<ImageTexture>& textures, uint64_t textureId) { auto it = std::find_if(textures.begin(), textures.end(), [textureId](const ImageTexture& texture) { return texture.id == textureId; }); if (it == textures.end()) return -1; return cl_int((*it).getImagePoolIndex()); } } void CLScene::readSceneFull(const Scene& scene) { Log& log = App::getLog(); readColor(general.backgroundColor, scene.general.backgroundColor); readColor(general.offLensColor, scene.general.offLensColor); general.rayStartOffset = cl_float(scene.general.rayStartOffset); general.maxRayIterations = cl_int(scene.general.maxRayIterations); general.maxPathLength = cl_int(scene.general.maxPathLength); general.pathSampleCount = cl_int(scene.general.pathSampleCount); general.multiSampleCountSqrt = cl_int(scene.general.multiSampleCountSqrt); general.timeSampleCount = cl_int(scene.general.timeSampleCount); general.cameraSampleCountSqrt = cl_int(scene.general.cameraSampleCountSqrt); general.visualizeDepth = cl_int(scene.general.visualizeDepth); general.visualizeDepthMaxDistance = cl_float(scene.general.visualizeDepthMaxDistance); general.enableNormalMapping = cl_int(scene.general.enableNormalMapping); readSceneCamera(scene); toneMapper.type = cl_int(scene.toneMapper.type); toneMapper.applyGamma = cl_int(scene.toneMapper.applyGamma); toneMapper.shouldClamp = cl_int(scene.toneMapper.shouldClamp); toneMapper.gamma = cl_float(scene.toneMapper.gamma); toneMapper.exposure = cl_float(scene.toneMapper.exposure); toneMapper.key = cl_float(scene.toneMapper.key); toneMapper.enableAveraging = cl_int(scene.toneMapper.enableAveraging); toneMapper.averagingAlpha = cl_float(scene.toneMapper.averagingAlpha); readColor(simpleFog.color, scene.simpleFog.color); simpleFog.enabled = cl_int(scene.simpleFog.enabled); simpleFog.distance = cl_float(scene.simpleFog.distance); simpleFog.steepness = cl_float(scene.simpleFog.steepness); simpleFog.heightDispersion = cl_int(scene.simpleFog.heightDispersion); simpleFog.height = cl_float(scene.simpleFog.height); simpleFog.heightSteepness = cl_float(scene.simpleFog.heightSteepness); materials.clear(); for (const Material& material : scene.materials) { OpenCL::Material clMaterial; readColor(clMaterial.ambientReflectance, material.ambientReflectance); readColor(clMaterial.diffuseReflectance, material.diffuseReflectance); readColor(clMaterial.specularReflectance, material.specularReflectance); readColor(clMaterial.emittance, material.emittance); readColor(clMaterial.rayTransmissionAttenuationColor, material.rayTransmissionAttenuationColor); readVector2(clMaterial.texcoordScale, material.texcoordScale); clMaterial.skipLighting = cl_int(material.skipLighting); clMaterial.nonShadowing = cl_int(material.nonShadowing); clMaterial.normalInterpolation = cl_int(material.normalInterpolation); clMaterial.invertNormal = cl_int(material.invertNormal); clMaterial.isEmissive = cl_int(material.isEmissive); clMaterial.ambientMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.ambientMapTextureId); clMaterial.diffuseMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.diffuseMapTextureId); clMaterial.specularShininess = cl_float(material.specularShininess); clMaterial.specularMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.specularMapTextureId); clMaterial.emittanceMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.emittanceMapTextureId); clMaterial.fresnelReflection = cl_int(material.fresnelReflection); clMaterial.refractiveIndex = cl_float(material.refractiveIndex); clMaterial.rayReflectance = cl_float(material.rayReflectance); clMaterial.rayReflectanceMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.rayReflectanceMapTextureId); clMaterial.rayReflectanceGlossinessSampleCountSqrt = cl_int(material.rayReflectanceGlossinessSampleCountSqrt); clMaterial.rayReflectanceGlossiness = cl_float(material.rayReflectanceGlossiness); clMaterial.rayTransmittance = cl_float(material.rayTransmittance); clMaterial.rayTransmittanceMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.rayTransmittanceMapTextureId); clMaterial.rayTransmittanceGlossinessSampleCountSqrt = cl_int(material.rayTransmittanceGlossinessSampleCountSqrt); clMaterial.rayTransmittanceGlossiness = cl_float(material.rayTransmittanceGlossiness); clMaterial.enableRayTransmissionAttenuation = cl_int(material.enableRayTransmissionAttenuation); clMaterial.rayTransmissionAttenuationFactor = cl_float(material.rayTransmissionAttenuationFactor); clMaterial.normalMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.normalMapTextureId); clMaterial.maskMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.maskMapTextureId); clMaterial.heightMapTextureIndex = findTextureIndex(scene.textures.imageTextures, material.heightMapTextureId); materials.push_back(clMaterial); } readColor(ambientLight.color, scene.lights.ambientLight.color); ambientLight.intensity = cl_float(scene.lights.ambientLight.intensity); ambientLight.enableAmbientOcclusion = cl_int(scene.lights.ambientLight.enableAmbientOcclusion); ambientLight.ambientOcclusionSampleCountSqrt = cl_int(scene.lights.ambientLight.ambientOcclusionSampleCountSqrt); ambientLight.ambientOcclusionMaxSampleDistance = cl_float(scene.lights.ambientLight.ambientOcclusionMaxSampleDistance); ambientLight.ambientOcclusionSampleDistribution = cl_float(scene.lights.ambientLight.ambientOcclusionSampleDistribution); directionalLights.clear(); for (const DirectionalLight& light : scene.lights.directionalLights) { OpenCL::DirectionalLight clLight; readColor(clLight.color, light.color); readVector3(clLight.direction, light.direction); clLight.intensity = cl_float(light.intensity); directionalLights.push_back(clLight); } state.directionalLightCount = cl_int(directionalLights.size()); pointLights.clear(); for (const PointLight& light : scene.lights.pointLights) { OpenCL::PointLight clLight; readColor(clLight.color, light.color); readVector3(clLight.position, light.position); clLight.intensity = cl_float(light.intensity); clLight.maxDistance = cl_float(light.maxDistance); clLight.attenuation = cl_float(light.attenuation); clLight.enableAreaLight = cl_int(light.enableAreaLight); clLight.areaLightSampleCountSqrt = cl_int(light.areaLightSampleCountSqrt); clLight.areaLightRadius = cl_float(light.areaLightRadius); pointLights.push_back(clLight); } state.pointLightCount = cl_int(pointLights.size()); triangles.clear(); if (scene.rootBVH.bvh.orderedPrimitives.size() == 0) log.logWarning("Root BVH is empty so nothing will get rendered when using OpenCL"); for (Primitive* primitivePtr : scene.rootBVH.bvh.orderedPrimitives) { Triangle* triangle = dynamic_cast<Triangle*>(primitivePtr); if (triangle == nullptr) throw std::runtime_error("When using OpenCL, the root BVH must only contain triangles"); OpenCL::Triangle clTriangle; readVector3(clTriangle.vertices[0], triangle->vertices[0]); readVector3(clTriangle.vertices[1], triangle->vertices[1]); readVector3(clTriangle.vertices[2], triangle->vertices[2]); readVector3(clTriangle.normals[0], triangle->normals[0]); readVector3(clTriangle.normals[1], triangle->normals[1]); readVector3(clTriangle.normals[2], triangle->normals[2]); readVector2(clTriangle.texcoords[0], triangle->texcoords[0]); readVector2(clTriangle.texcoords[1], triangle->texcoords[1]); readVector2(clTriangle.texcoords[2], triangle->texcoords[2]); readVector3(clTriangle.normal, triangle->normal); readVector3(clTriangle.tangent, triangle->tangent); readVector3(clTriangle.bitangent, triangle->bitangent); clTriangle.materialIndex = cl_uint(findMaterialIndex(scene.materials, triangle->materialId)); triangles.push_back(clTriangle); } state.triangleCount = cl_int(triangles.size()); bvhNodes.clear(); for (const FlatBVHNode& node : scene.rootBVH.bvh.flatNodes) { OpenCL::BVHNode clNode; readVector3(clNode.aabb.min, node.aabb.getMin()); readVector3(clNode.aabb.max, node.aabb.getMax()); clNode.rightOffset = cl_int(node.rightOffset); clNode.startOffset = cl_int(node.startOffset); clNode.primitiveCount = cl_int(node.primitiveCount); bvhNodes.push_back(clNode); } state.bvhNodeCount = cl_int(bvhNodes.size()); } void CLScene::readSceneCamera(const Scene& scene) { readVector3(camera.position, scene.camera.cameraState.position); readVector3(camera.forward, scene.camera.cameraState.forward); readVector3(camera.right, scene.camera.cameraState.right); readVector3(camera.up, scene.camera.cameraState.up); readVector3(camera.imagePlaneCenter, scene.camera.cameraState.imagePlaneCenter); readVector3(camera.translateInTime, scene.camera.translateInTime); readEulerAngle(camera.rotateInTime, scene.camera.rotateInTime); camera.projectionType = cl_int(scene.camera.projectionType); camera.isTimeVariant = cl_int(scene.camera.isTimeVariant); camera.hasMoved = cl_int(scene.camera.cameraHasMoved); camera.fov = cl_float(scene.camera.fov); camera.orthoSize = cl_float(scene.camera.orthoSize); camera.fishEyeAngle = cl_float(scene.camera.fishEyeAngle); camera.apertureSize = cl_float(scene.camera.apertureSize); camera.focalDistance = cl_float(scene.camera.focalDistance); camera.aspectRatio = cl_float(scene.camera.aspectRatio); camera.imagePlaneDistance = cl_float(scene.camera.imagePlaneDistance); camera.imagePlaneWidth = cl_float(scene.camera.imagePlaneWidth); camera.imagePlaneHeight = cl_float(scene.camera.imagePlaneHeight); }
42.863636
133
0.799576
mikoro
5e8bf8891b6c97c6dbc71d06f39a318039a85d23
12,350
hxx
C++
Modules/Registration/Common/include/itkGradientDifferenceImageToImageMetric.hxx
HongdaZ/ITK
f5d004fa3607b8e11edc30f1ba299df35af8aff8
[ "Apache-2.0" ]
1
2021-01-10T14:19:08.000Z
2021-01-10T14:19:08.000Z
Modules/Registration/Common/include/itkGradientDifferenceImageToImageMetric.hxx
HongdaZ/ITK
f5d004fa3607b8e11edc30f1ba299df35af8aff8
[ "Apache-2.0" ]
1
2017-03-19T12:56:50.000Z
2018-10-24T10:40:21.000Z
Modules/Registration/Common/include/itkGradientDifferenceImageToImageMetric.hxx
HongdaZ/ITK
f5d004fa3607b8e11edc30f1ba299df35af8aff8
[ "Apache-2.0" ]
1
2020-07-24T22:58:19.000Z
2020-07-24T22:58:19.000Z
/*========================================================================= * * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkGradientDifferenceImageToImageMetric_hxx #define itkGradientDifferenceImageToImageMetric_hxx #include "itkGradientDifferenceImageToImageMetric.h" #include "itkImageRegionConstIteratorWithIndex.h" #include "itkNumericTraits.h" #include "itkMath.h" #include <iostream> #include <iomanip> #include <cstdio> #include "itkSimpleFilterWatcher.h" namespace itk { /** * Constructor */ template <typename TFixedImage, typename TMovingImage> GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::GradientDifferenceImageToImageMetric() { unsigned int iDimension; m_TransformMovingImageFilter = nullptr; for (iDimension = 0; iDimension < FixedImageDimension; iDimension++) { m_MinFixedGradient[iDimension] = 0; m_MaxFixedGradient[iDimension] = 0; m_Variance[iDimension] = 0; } for (iDimension = 0; iDimension < MovedImageDimension; iDimension++) { m_MinMovedGradient[iDimension] = 0; m_MaxMovedGradient[iDimension] = 0; } this->m_DerivativeDelta = 0.001; } /** * Initialize */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::Initialize() { unsigned int iFilter; // Index of Sobel filters for each dimension if (!this->GetComputeGradient()) { itkExceptionMacro(<< "Gradients must be calculated"); } // Initialise the base class Superclass::Initialize(); // Create the filter to resample the moving image m_TransformMovingImageFilter = TransformMovingImageFilterType::New(); m_TransformMovingImageFilter->SetTransform(this->m_Transform); m_TransformMovingImageFilter->SetInterpolator(this->m_Interpolator); m_TransformMovingImageFilter->SetInput(this->m_MovingImage); m_TransformMovingImageFilter->SetDefaultPixelValue(0); m_TransformMovingImageFilter->SetSize(this->m_FixedImage->GetLargestPossibleRegion().GetSize()); m_TransformMovingImageFilter->SetOutputOrigin(this->m_FixedImage->GetOrigin()); m_TransformMovingImageFilter->SetOutputSpacing(this->m_FixedImage->GetSpacing()); m_TransformMovingImageFilter->SetOutputDirection(this->m_FixedImage->GetDirection()); // Compute the image gradients // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Compute the gradient of the fixed image m_CastFixedImageFilter = CastFixedImageFilterType::New(); m_CastFixedImageFilter->SetInput(this->m_FixedImage); for (iFilter = 0; iFilter < FixedImageDimension; iFilter++) { m_FixedSobelOperators[iFilter].SetDirection(iFilter); m_FixedSobelOperators[iFilter].CreateDirectional(); m_FixedSobelFilters[iFilter] = FixedSobelFilter::New(); m_FixedSobelFilters[iFilter]->OverrideBoundaryCondition(&m_FixedBoundCond); m_FixedSobelFilters[iFilter]->SetOperator(m_FixedSobelOperators[iFilter]); m_FixedSobelFilters[iFilter]->SetInput(m_CastFixedImageFilter->GetOutput()); m_FixedSobelFilters[iFilter]->UpdateLargestPossibleRegion(); } ComputeVariance(); // Compute the gradient of the transformed moving image m_CastMovedImageFilter = CastMovedImageFilterType::New(); m_CastMovedImageFilter->SetInput(m_TransformMovingImageFilter->GetOutput()); for (iFilter = 0; iFilter < MovedImageDimension; iFilter++) { m_MovedSobelOperators[iFilter].SetDirection(iFilter); m_MovedSobelOperators[iFilter].CreateDirectional(); m_MovedSobelFilters[iFilter] = MovedSobelFilter::New(); m_MovedSobelFilters[iFilter]->OverrideBoundaryCondition(&m_MovedBoundCond); m_MovedSobelFilters[iFilter]->SetOperator(m_MovedSobelOperators[iFilter]); m_MovedSobelFilters[iFilter]->SetInput(m_CastMovedImageFilter->GetOutput()); m_MovedSobelFilters[iFilter]->UpdateLargestPossibleRegion(); } } /** * PrintSelf */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "DerivativeDelta: " << this->m_DerivativeDelta << std::endl; } /** * Compute the range of the moved image gradients */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::ComputeMovedGradientRange() const { unsigned int iDimension; MovedGradientPixelType gradient; for (iDimension = 0; iDimension < FixedImageDimension; iDimension++) { using IteratorType = itk::ImageRegionConstIteratorWithIndex<MovedGradientImageType>; IteratorType iterate(m_MovedSobelFilters[iDimension]->GetOutput(), this->GetFixedImageRegion()); gradient = iterate.Get(); m_MinMovedGradient[iDimension] = gradient; m_MaxMovedGradient[iDimension] = gradient; while (!iterate.IsAtEnd()) { gradient = iterate.Get(); if (gradient > m_MaxMovedGradient[iDimension]) { m_MaxMovedGradient[iDimension] = gradient; } if (gradient < m_MinMovedGradient[iDimension]) { m_MinMovedGradient[iDimension] = gradient; } ++iterate; } } } /** * Compute the gradient variances in each dimension. */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::ComputeVariance() const { unsigned int iDimension; SizeValueType nPixels; FixedGradientPixelType mean[FixedImageDimension]; FixedGradientPixelType gradient; for (iDimension = 0; iDimension < FixedImageDimension; iDimension++) { using IteratorType = itk::ImageRegionConstIteratorWithIndex<FixedGradientImageType>; IteratorType iterate(m_FixedSobelFilters[iDimension]->GetOutput(), this->GetFixedImageRegion()); // Calculate the mean gradients nPixels = 0; gradient = iterate.Get(); mean[iDimension] = 0; m_MinMovedGradient[iDimension] = gradient; m_MaxMovedGradient[iDimension] = gradient; while (!iterate.IsAtEnd()) { gradient = iterate.Get(); mean[iDimension] += gradient; if (gradient > m_MaxFixedGradient[iDimension]) { m_MaxFixedGradient[iDimension] = gradient; } if (gradient < m_MinFixedGradient[iDimension]) { m_MinFixedGradient[iDimension] = gradient; } nPixels++; ++iterate; } if (nPixels > 0) { mean[iDimension] /= nPixels; } // Calculate the variance iterate.GoToBegin(); m_Variance[iDimension] = 0; while (!iterate.IsAtEnd()) { gradient = iterate.Get(); gradient -= mean[iDimension]; m_Variance[iDimension] += gradient * gradient; ++iterate; } if (nPixels > 0) { m_Variance[iDimension] /= nPixels; } } } /** * Get the value of the similarity measure */ template <typename TFixedImage, typename TMovingImage> typename GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::MeasureType GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::ComputeMeasure( const TransformParametersType & parameters, const double * subtractionFactor) const { unsigned int iDimension; this->SetTransformParameters(parameters); m_TransformMovingImageFilter->UpdateLargestPossibleRegion(); MeasureType measure = NumericTraits<MeasureType>::ZeroValue(); for (iDimension = 0; iDimension < FixedImageDimension; iDimension++) { if (Math::AlmostEquals(m_Variance[iDimension], NumericTraits<MovedGradientPixelType>::ZeroValue())) { continue; } // Iterate over the fixed and moving gradient images // calculating the similarity measure MovedGradientPixelType movedGradient; FixedGradientPixelType fixedGradient; MovedGradientPixelType diff; using FixedIteratorType = itk::ImageRegionConstIteratorWithIndex<FixedGradientImageType>; FixedIteratorType fixedIterator(m_FixedSobelFilters[iDimension]->GetOutput(), this->GetFixedImageRegion()); using MovedIteratorType = itk::ImageRegionConstIteratorWithIndex<MovedGradientImageType>; MovedIteratorType movedIterator(m_MovedSobelFilters[iDimension]->GetOutput(), this->GetFixedImageRegion()); m_FixedSobelFilters[iDimension]->UpdateLargestPossibleRegion(); m_MovedSobelFilters[iDimension]->UpdateLargestPossibleRegion(); this->m_NumberOfPixelsCounted = 0; while (!fixedIterator.IsAtEnd()) { // Get the moving and fixed image gradients movedGradient = movedIterator.Get(); fixedGradient = fixedIterator.Get(); // And calculate the gradient difference diff = fixedGradient - subtractionFactor[iDimension] * movedGradient; measure += m_Variance[iDimension] / (m_Variance[iDimension] + diff * diff); ++fixedIterator; ++movedIterator; } } return measure; } /** * Get the value of the similarity measure */ template <typename TFixedImage, typename TMovingImage> typename GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::MeasureType GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::GetValue( const TransformParametersType & parameters) const { unsigned int iFilter; // Index of Sobel filters for // each dimension unsigned int iDimension; this->SetTransformParameters(parameters); m_TransformMovingImageFilter->UpdateLargestPossibleRegion(); // Update the gradient images for (iFilter = 0; iFilter < MovedImageDimension; iFilter++) { m_MovedSobelFilters[iFilter]->UpdateLargestPossibleRegion(); } // Compute the range of the moved image gradients // NB: Ideally this should be a filter as the computation is only // required if the moved gradient image has been updated. // However for the moment we'll assume that this is the case // whenever GetValue() is called. this->ComputeMovedGradientRange(); // Compute the similarity measure MovedGradientPixelType subtractionFactor[FixedImageDimension]; MeasureType currentMeasure; for (iDimension = 0; iDimension < FixedImageDimension; iDimension++) { subtractionFactor[iDimension] = 1.0; } // Compute the new value of the measure for this subtraction factor currentMeasure = this->ComputeMeasure(parameters, subtractionFactor); return currentMeasure; } /** * Get the Derivative Measure */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::GetDerivative( const TransformParametersType & parameters, DerivativeType & derivative) const { TransformParametersType testPoint; testPoint = parameters; const unsigned int numberOfParameters = this->GetNumberOfParameters(); derivative = DerivativeType(numberOfParameters); for (unsigned int i = 0; i < numberOfParameters; i++) { testPoint[i] -= this->m_DerivativeDelta; const MeasureType valuep0 = this->GetValue(testPoint); testPoint[i] += 2 * this->m_DerivativeDelta; const MeasureType valuep1 = this->GetValue(testPoint); derivative[i] = (valuep1 - valuep0) / (2 * this->m_DerivativeDelta); testPoint[i] = parameters[i]; } } /** * Get both the match Measure and theDerivative Measure */ template <typename TFixedImage, typename TMovingImage> void GradientDifferenceImageToImageMetric<TFixedImage, TMovingImage>::GetValueAndDerivative( const TransformParametersType & parameters, MeasureType & Value, DerivativeType & Derivative) const { Value = this->GetValue(parameters); this->GetDerivative(parameters, Derivative); } } // end namespace itk #endif
29.545455
114
0.727854
HongdaZ
5e8bfd44ce46f1d18d0f10c2ef3813a4abdfcfab
3,800
cpp
C++
Examples/HelloFluidSim/main.cpp
ADMTec/CubbyFlow
c71457fd04ccfaf3ef22772bab9bcec4a0a3b611
[ "MIT" ]
216
2017-01-25T04:34:30.000Z
2021-07-15T12:36:06.000Z
Examples/HelloFluidSim/main.cpp
ADMTec/CubbyFlow
c71457fd04ccfaf3ef22772bab9bcec4a0a3b611
[ "MIT" ]
323
2017-01-26T13:53:13.000Z
2021-07-14T16:03:38.000Z
Examples/HelloFluidSim/main.cpp
ADMTec/CubbyFlow
c71457fd04ccfaf3ef22772bab9bcec4a0a3b611
[ "MIT" ]
33
2017-01-25T05:05:49.000Z
2021-06-17T17:30:56.000Z
// This code is based on Jet framework. // Copyright (c) 2018 Doyub Kim // CubbyFlow is voxel-based fluid simulation engine for computer games. // Copyright (c) 2020 CubbyFlow Team // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo // AI Part: Dongheon Cho, Minseo Kim // We are making my contributions/submissions to this project solely in our // personal capacity and are not conveying any rights to any intellectual // property of any third parties. #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include <algorithm> #include <array> #include <chrono> #include <cmath> #include <cstdio> #include <string> #include <thread> const size_t BUFFER_SIZE = 80; const std::string GRAY_SCALE_TABLE = " .:-=+*#%@"; const size_t GRAY_SCALE_TABLE_SIZE = GRAY_SCALE_TABLE.length(); void UpdateWave(const double timeInterval, double* x, double* speed) { (*x) += timeInterval * (*speed); // Boundary reflection if ((*x) > 1.0) { (*speed) *= -1.0; (*x) = 1.0 + timeInterval * (*speed); } else if ((*x) < 0.0) { (*speed) *= -1.0; (*x) = timeInterval * (*speed); } } void AccumulateWaveToHeightField(const double x, const double waveLength, const double maxHeight, std::array<double, BUFFER_SIZE>* heightField) { const double quarterWaveLength = 0.25 * waveLength; const int start = static_cast<int>((x - quarterWaveLength) * BUFFER_SIZE); const int end = static_cast<int>((x + quarterWaveLength) * BUFFER_SIZE); for (int i = start; i < end; ++i) { int iNew = i; if (i < 0) { iNew = -i - 1; } else if (i >= static_cast<int>(BUFFER_SIZE)) { iNew = 2 * BUFFER_SIZE - i - 1; } const double distance = fabs((i + 0.5) / BUFFER_SIZE - x); const double height = maxHeight * 0.5 * (cos(std::min(distance * M_PI / quarterWaveLength, M_PI)) + 1.0); (*heightField)[iNew] += height; } } void Draw(const std::array<double, BUFFER_SIZE>& heightField) { std::string buffer(BUFFER_SIZE, ' '); // Convert height field to grayscale for (size_t i = 0; i < BUFFER_SIZE; ++i) { const double height = heightField[i]; const size_t tableIndex = std::min(static_cast<size_t>(floor(GRAY_SCALE_TABLE_SIZE * height)), GRAY_SCALE_TABLE_SIZE - 1); buffer[i] = GRAY_SCALE_TABLE[tableIndex]; } // Clear old prints for (size_t i = 0; i < BUFFER_SIZE; ++i) { printf("\b"); } // Draw new buffer printf("%s", buffer.c_str()); fflush(stdout); } int main() { const double waveLengthX = 0.8; const double waveLengthY = 1.2; const double maxHeightX = 0.5; const double maxHeightY = 0.4; double x = 0.0; double y = 1.0; double speedX = 1.0; double speedY = -0.5; const int fps = 100; const double timeInterval = 1.0 / fps; std::array<double, BUFFER_SIZE> heightField; for (int i = 0; i < 1000; ++i) { // March through time UpdateWave(timeInterval, &x, &speedX); UpdateWave(timeInterval, &y, &speedY); // Clear height field for (double& height : heightField) { height = 0.0; } // Accumulate waves for each center point AccumulateWaveToHeightField(x, waveLengthX, maxHeightX, &heightField); AccumulateWaveToHeightField(y, waveLengthY, maxHeightY, &heightField); // Draw height field Draw(heightField); // Wait std::this_thread::sleep_for(std::chrono::milliseconds(1000 / fps)); } printf("\n"); fflush(stdout); return 0; }
26.760563
80
0.592895
ADMTec
5e8f1f723a9de1c53eade71fb46968a8a6219c8c
1,502
cpp
C++
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
1
2020-09-18T22:33:37.000Z
2020-09-18T22:33:37.000Z
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
null
null
null
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
null
null
null
#include "rpn/utils.h" #include <cassert> #include <iostream> #include <cat.h> namespace rcnn{ namespace modeling{ torch::Tensor PermuteAndFlatten(torch::Tensor& layer, int64_t N, int64_t A, int64_t C, int64_t H, int64_t W){ layer = layer.view({N, -1, C, H, W}); layer = layer.permute({0, 3, 4, 1, 2}); layer = layer.reshape({N, -1, C}); return layer; } std::pair<torch::Tensor, torch::Tensor> ConcatBoxPredictionLayers(std::vector<torch::Tensor>& box_cls, std::vector<torch::Tensor>& box_regression){ std::vector<torch::Tensor> box_cls_flattened; box_cls_flattened.reserve(box_cls.size()); std::vector<torch::Tensor> box_regression_flattened; box_regression_flattened.reserve(box_cls.size()); int64_t C; assert(box_cls.size() == box_regression.size()); for(int i = 0; i < box_cls.size(); ++i){ int64_t N = box_cls[i].size(0), AxC = box_cls[i].size(1), H = box_cls[i].size(2), W = box_cls[i].size(3); int64_t Ax4 = box_regression[i].size(1); int64_t A = static_cast<int64_t> (Ax4 / 4); C = static_cast<int64_t> (AxC / A); //box_cls_per_level box_cls_flattened.push_back( std::move(PermuteAndFlatten(box_cls[i], N, A, C, H, W)) ); box_regression_flattened.push_back( std::move(PermuteAndFlatten(box_regression[i], N, A, 4, H, W)) ); } return std::make_pair(rcnn::layers::cat(box_cls_flattened, /*dim=*/1).reshape({-1, C}), rcnn::layers::cat(box_regression_flattened, /*dim=*/1).reshape({-1, 4})); } } }
31.957447
147
0.66245
conanhung
5e907214b76edb4ed4c8a811738b4be0da904e38
8,996
cpp
C++
3rdparty/kdl_parser/src/kdl_parser.cpp
rocos-sia/rocos-app
83aa8aa31dd303d77693cfc5ad48055d051fa4bc
[ "MIT" ]
3
2021-12-06T15:30:58.000Z
2022-03-29T13:21:40.000Z
3rdparty/kdl_parser/src/kdl_parser.cpp
thinkexist1989/rocos-app
7d6ab256c8212504b0a8bbe1ec1dea0c41ea3ff2
[ "MIT" ]
null
null
null
3rdparty/kdl_parser/src/kdl_parser.cpp
thinkexist1989/rocos-app
7d6ab256c8212504b0a8bbe1ec1dea0c41ea3ff2
[ "MIT" ]
null
null
null
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /* Author: Wim Meeussen */ #include "kdl_parser/kdl_parser.hpp" #include <string> #include <vector> #include <urdf_model/model.h> #include <urdf_parser/urdf_parser.h> #include <kdl/frames_io.hpp> #ifdef HAS_ROS #include <ros/console.h> #else // forward ROS warnings and errors to stderr #define ROS_DEBUG(...) fprintf(stdout, __VA_ARGS__); #define ROS_ERROR(...) fprintf(stderr, __VA_ARGS__); #define ROS_WARN(...) fprintf(stderr, __VA_ARGS__); #endif #ifdef HAS_URDF #include <urdf/model.h> #include <urdf/urdfdom_compatibility.h> #endif namespace kdl_parser { // construct vector KDL::Vector toKdl(urdf::Vector3 v) { return KDL::Vector(v.x, v.y, v.z); } // construct rotation KDL::Rotation toKdl(urdf::Rotation r) { return KDL::Rotation::Quaternion(r.x, r.y, r.z, r.w); } // construct pose KDL::Frame toKdl(urdf::Pose p) { return KDL::Frame(toKdl(p.rotation), toKdl(p.position)); } // construct joint KDL::Joint toKdl(urdf::JointSharedPtr jnt) { KDL::Frame F_parent_jnt = toKdl(jnt->parent_to_joint_origin_transform); switch (jnt->type) { case urdf::Joint::FIXED: { return KDL::Joint(jnt->name, KDL::Joint::None); } case urdf::Joint::REVOLUTE: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::RotAxis); } case urdf::Joint::CONTINUOUS: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::RotAxis); } case urdf::Joint::PRISMATIC: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::TransAxis); } default: { ROS_WARN("Converting unknown joint type of joint '%s' into a fixed joint", jnt->name.c_str()); return KDL::Joint(jnt->name, KDL::Joint::None); } } return KDL::Joint(); } // construct inertia KDL::RigidBodyInertia toKdl(urdf::InertialSharedPtr i) { KDL::Frame origin = toKdl(i->origin); // the mass is frame independent double kdl_mass = i->mass; // kdl and urdf both specify the com position in the reference frame of the link KDL::Vector kdl_com = origin.p; // kdl specifies the inertia matrix in the reference frame of the link, // while the urdf specifies the inertia matrix in the inertia reference frame KDL::RotationalInertia urdf_inertia = KDL::RotationalInertia(i->ixx, i->iyy, i->izz, i->ixy, i->ixz, i->iyz); // Rotation operators are not defined for rotational inertia, // so we use the RigidBodyInertia operators (with com = 0) as a workaround KDL::RigidBodyInertia kdl_inertia_wrt_com_workaround = origin.M * KDL::RigidBodyInertia(0, KDL::Vector::Zero(), urdf_inertia); // Note that the RigidBodyInertia constructor takes the 3d inertia wrt the com // while the getRotationalInertia method returns the 3d inertia wrt the frame origin // (but having com = Vector::Zero() in kdl_inertia_wrt_com_workaround they match) KDL::RotationalInertia kdl_inertia_wrt_com = kdl_inertia_wrt_com_workaround.getRotationalInertia(); return KDL::RigidBodyInertia(kdl_mass, kdl_com, kdl_inertia_wrt_com); } // recursive function to walk through tree bool addChildrenToTree(urdf::LinkConstSharedPtr root, KDL::Tree &tree) { std::vector<urdf::LinkSharedPtr> children = root->child_links; printf("Link %s had %zu children\n", root->name.c_str(), children.size()); // constructs the optional inertia KDL::RigidBodyInertia inert(0); if (root->inertial) { inert = toKdl(root->inertial); } // constructs the kdl joint KDL::Joint jnt = toKdl(root->parent_joint); // construct the kdl segment KDL::Segment sgm(root->name, jnt, toKdl(root->parent_joint->parent_to_joint_origin_transform), inert); // add segment to tree tree.addSegment(sgm, root->parent_joint->parent_link_name); // recurslively add all children for (size_t i = 0; i < children.size(); i++) { if (!addChildrenToTree(children[i], tree)) { return false; } } return true; } bool treeFromFile(const std::string &file, KDL::Tree &tree) { const urdf::ModelInterfaceSharedPtr robot_model = urdf::parseURDFFile(file); return kdl_parser::treeFromUrdfModel(*robot_model, tree); } bool treeFromParam(const std::string &param, KDL::Tree &tree) { #if defined(HAS_ROS) && defined(HAS_URDF) urdf::Model robot_model; if (!robot_model.initParam(param)) { ROS_ERROR("Could not generate robot model"); return false; } return treeFromUrdfModel(robot_model, tree); #else return false; #endif } bool treeFromString(const std::string &xml, KDL::Tree &tree) { const urdf::ModelInterfaceSharedPtr robot_model = urdf::parseURDF(xml); if (!robot_model) { ROS_ERROR("Could not generate robot model"); return false; } return kdl_parser::treeFromUrdfModel(*robot_model, tree); } bool treeFromXml(const tinyxml2::XMLDocument *xml_doc, KDL::Tree &tree) { if (!xml_doc) { ROS_ERROR("Could not parse the xml document"); return false; } tinyxml2::XMLPrinter printer; xml_doc->Print(&printer); return treeFromString(printer.CStr(), tree); } bool treeFromXml(TiXmlDocument *xml_doc, KDL::Tree &tree) { if (!xml_doc) { ROS_ERROR("Could not parse the xml document"); return false; } std::stringstream ss; ss << *xml_doc; return treeFromString(ss.str(), tree); } bool treeFromUrdfModel(const urdf::ModelInterface &robot_model, KDL::Tree &tree) { if (!robot_model.getRoot()) { return false; } tree = KDL::Tree(robot_model.getRoot()->name); // warn if root link has inertia. KDL does not support this if (robot_model.getRoot()->inertial) { ROS_WARN("The root link %s has an inertia specified in the URDF, but KDL does not " "support a root link with an inertia. As a workaround, you can add an extra " "dummy link to your URDF.", robot_model.getRoot()->name.c_str()); } // add all children for (size_t i = 0; i < robot_model.getRoot()->child_links.size(); i++) { if (!addChildrenToTree(robot_model.getRoot()->child_links[i], tree)) { return false; } } return true; } } // namespace kdl_parser
33.318519
110
0.618608
rocos-sia
5e907df894871fd4913ca0fc6a19937b83b2fc52
1,037
cpp
C++
leetcode/contest-246/1904. The Number of Full Rounds You Have Played.cpp
upupming/algorithm
44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1
[ "MIT" ]
107
2019-10-25T07:46:59.000Z
2022-03-29T11:10:56.000Z
leetcode/contest-246/1904. The Number of Full Rounds You Have Played.cpp
upupming/algorithm
44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1
[ "MIT" ]
1
2021-08-13T05:42:27.000Z
2021-08-13T05:42:27.000Z
leetcode/contest-246/1904. The Number of Full Rounds You Have Played.cpp
upupming/algorithm
44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1
[ "MIT" ]
18
2020-12-09T14:24:22.000Z
2022-03-30T06:56:01.000Z
#include <bits/stdc++.h> using namespace std; struct Time { int h, m; Time(int h, int m) : h(h), m(m) {} Time(string s) { h = (s[0] - '0') * 10 + s[1] - '0'; m = (s[3] - '0') * 10 + s[4] - '0'; } }; bool cmp(Time s, Time f) { if (s.h < f.h) return true; if (s.h > f.h) return false; if (s.m < f.m) return true; return false; } int cnt(Time s, Time f) { int ans = 0; for (int h = s.h; h <= f.h; h++) { for (int m = 0; m <= 45; m += 15) { Time tmp(h, m); if ( !cmp(tmp, s) && !cmp(f, tmp)) { // cout << h << " " << m << endl; ans++; } } } return max(ans - 1, 0); } class Solution { public: int numberOfRounds(string startTime, string finishTime) { Time s(startTime), f(finishTime); Time a(23, 59), b(0, 0); if (!cmp(f, s)) { return cnt(s, f); } else { f.h += 24; return cnt(s, f); } } };
23.568182
61
0.398264
upupming
5e94f2286108eb672682e36f876c6d7120ac124f
4,569
cp
C++
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
12
2015-04-21T16:10:43.000Z
2021-11-05T13:41:46.000Z
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
2
2015-11-02T13:32:11.000Z
2019-07-10T21:11:21.000Z
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
6
2015-01-12T08:49:12.000Z
2021-03-27T09:11:10.000Z
/* Copyright (c) 2007 Cyrus Daboo. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "JXMultiImageCheckbox.h" #include "CDrawUtils.h" #include "CIconLoader.h" #include <JXWindowPainter.h> #include <JXImage.h> #include <JXColormap.h> #include <jAssert.h> #include <jXPainterUtil.h> /****************************************************************************** Constructor ******************************************************************************/ JXMultiImageCheckbox::JXMultiImageCheckbox ( JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXCheckbox(enclosure, hSizing, vSizing, x,y, w,h), itsOffImageID(0), itsOffPushedImageID(0), itsOnImageID(0), itsOnPushedImageID(0) { // Our 3D buttons have 3-pixel border SetBorderWidth(3); } /****************************************************************************** Destructor ******************************************************************************/ JXMultiImageCheckbox::~JXMultiImageCheckbox() { } /****************************************************************************** SetImage ******************************************************************************/ void JXMultiImageCheckbox::SetImage(ResIDT offImageID) { itsOffImageID = offImageID; itsOffPushedImageID = offImageID; itsOnImageID = offImageID; itsOnPushedImageID = offImageID; Refresh(); } /****************************************************************************** SetImages ******************************************************************************/ void JXMultiImageCheckbox::SetImages(ResIDT offImageID, ResIDT offpushedImageID, ResIDT onImageID, ResIDT onpushedImageID) { itsOffImageID = offImageID; itsOnImageID = onImageID ? onImageID : offImageID; itsOffPushedImageID = offpushedImageID ? offpushedImageID : onImageID; itsOnPushedImageID = onpushedImageID ? onpushedImageID : offImageID; Refresh(); } /****************************************************************************** Draw (virtual protected) ******************************************************************************/ void JXMultiImageCheckbox::Draw ( JXWindowPainter& p, const JRect& rect ) { unsigned long bkgnd = 0x00FFFFFF; JColorIndex bkgnd_index = GetColormap()->Get3DShadeColor(); if (IsActive() && DrawChecked()) bkgnd_index = GetColormap()->Get3DShadeColor(); else bkgnd_index = GetColormap()->GetDefaultBackColor(); { JSize r, g, b; GetColormap()->GetRGB(bkgnd_index, &r, &g, &b); bkgnd = ((r & 0xFF00) << 8) | (g & 0xFF00) | ((b & 0xFF00) >> 8); } ResIDT iconID = 0; bool disabled = false; JXImage* draw_me = NULL; JRect actual_rect(GetBounds()); if (IsActive()) { if (IsChecked()) iconID = DrawChecked() ? itsOnImageID : itsOnPushedImageID; else iconID = !DrawChecked() ? itsOffImageID : itsOffPushedImageID; } else { iconID = itsOffImageID; disabled = true; } draw_me = CIconLoader::GetIcon(iconID, this, actual_rect.width() >= 32 ? 32 : 16, bkgnd, disabled ? CIconLoader::eDisabled : CIconLoader::eNormal); // Center icon in button area int hoffset = (GetBoundsWidth() - draw_me->GetBounds().width())/2; int voffset = (GetBoundsHeight() - draw_me->GetBounds().height())/2; p.JPainter::Image(*draw_me, draw_me->GetBounds(), actual_rect.left + hoffset, actual_rect.top + voffset); } void JXMultiImageCheckbox::DrawBackground(JXWindowPainter& p, const JRect& frame) { bool selected = DrawChecked(); bool enabled = IsActive(); bool use_frame = GetBorderWidth(); CDrawUtils::DrawBackground(p, frame, selected && use_frame, enabled); } void JXMultiImageCheckbox::DrawBorder(JXWindowPainter& p, const JRect& frame) { bool selected = DrawChecked(); bool enabled = IsActive(); bool use_frame = GetBorderWidth(); if (use_frame) CDrawUtils::Draw3DBorder(p, frame, selected, enabled); }
28.030675
148
0.591814
mulberry-mail
5e953edfa47bec9eeda3805f4d18b0067825c15b
6,781
cc
C++
views/controls/textfield/textfield.cc
zachlatta/chromium
c4625eefca763df86471d798ee5a4a054b4716ae
[ "BSD-3-Clause" ]
1
2021-09-24T22:49:10.000Z
2021-09-24T22:49:10.000Z
views/controls/textfield/textfield.cc
changbai1980/chromium
c4625eefca763df86471d798ee5a4a054b4716ae
[ "BSD-3-Clause" ]
null
null
null
views/controls/textfield/textfield.cc
changbai1980/chromium
c4625eefca763df86471d798ee5a4a054b4716ae
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "views/controls/textfield/textfield.h" #include "app/gfx/insets.h" #if defined(OS_WIN) #include "app/win_util.h" #endif #include "base/string_util.h" #include "views/controls/textfield/native_textfield_wrapper.h" #include "views/widget/widget.h" namespace views { // static const char Textfield::kViewClassName[] = "views/Textfield"; ///////////////////////////////////////////////////////////////////////////// // Textfield Textfield::Textfield() : native_wrapper_(NULL), controller_(NULL), style_(STYLE_DEFAULT), read_only_(false), default_width_in_chars_(0), draw_border_(true), background_color_(SK_ColorWHITE), use_default_background_color_(true), num_lines_(1), initialized_(false) { SetFocusable(true); } Textfield::Textfield(StyleFlags style) : native_wrapper_(NULL), controller_(NULL), style_(style), read_only_(false), default_width_in_chars_(0), draw_border_(true), background_color_(SK_ColorWHITE), use_default_background_color_(true), num_lines_(1), initialized_(false) { SetFocusable(true); } Textfield::~Textfield() { if (native_wrapper_) delete native_wrapper_; } void Textfield::SetController(Controller* controller) { controller_ = controller; } Textfield::Controller* Textfield::GetController() const { return controller_; } void Textfield::SetReadOnly(bool read_only) { read_only_ = read_only; if (native_wrapper_) { native_wrapper_->UpdateReadOnly(); native_wrapper_->UpdateBackgroundColor(); } } bool Textfield::IsPassword() const { return style_ & STYLE_PASSWORD; } bool Textfield::IsMultiLine() const { return !!(style_ & STYLE_MULTILINE); } void Textfield::SetText(const std::wstring& text) { text_ = text; if (native_wrapper_) native_wrapper_->UpdateText(); } void Textfield::AppendText(const std::wstring& text) { text_ += text; if (native_wrapper_) native_wrapper_->AppendText(text); } void Textfield::SelectAll() { if (native_wrapper_) native_wrapper_->SelectAll(); } void Textfield::ClearSelection() const { if (native_wrapper_) native_wrapper_->ClearSelection(); } void Textfield::SetBackgroundColor(SkColor color) { background_color_ = color; use_default_background_color_ = false; if (native_wrapper_) native_wrapper_->UpdateBackgroundColor(); } void Textfield::UseDefaultBackgroundColor() { use_default_background_color_ = true; if (native_wrapper_) native_wrapper_->UpdateBackgroundColor(); } void Textfield::SetFont(const gfx::Font& font) { font_ = font; if (native_wrapper_) native_wrapper_->UpdateFont(); } void Textfield::SetHorizontalMargins(int left, int right) { if (native_wrapper_) native_wrapper_->SetHorizontalMargins(left, right); } void Textfield::SetHeightInLines(int num_lines) { DCHECK(IsMultiLine()); num_lines_ = num_lines; } void Textfield::RemoveBorder() { if (!draw_border_) return; draw_border_ = false; if (native_wrapper_) native_wrapper_->UpdateBorder(); } void Textfield::CalculateInsets(gfx::Insets* insets) { DCHECK(insets); if (!draw_border_) return; // NOTE: One would think GetThemeMargins would return the insets we should // use, but it doesn't. The margins returned by GetThemeMargins are always // 0. // This appears to be the insets used by Windows. insets->Set(3, 3, 3, 3); } void Textfield::SyncText() { if (native_wrapper_) text_ = native_wrapper_->GetText(); } // static bool Textfield::IsKeystrokeEnter(const Keystroke& key) { #if defined(OS_WIN) return key.key == VK_RETURN; #else // TODO(port): figure out VK_constants NOTIMPLEMENTED(); return false; #endif } // static bool Textfield::IsKeystrokeEscape(const Keystroke& key) { #if defined(OS_WIN) return key.key == VK_ESCAPE; #else // TODO(port): figure out VK_constants NOTIMPLEMENTED(); return false; #endif } //////////////////////////////////////////////////////////////////////////////// // Textfield, View overrides: void Textfield::Layout() { if (native_wrapper_) { native_wrapper_->GetView()->SetBounds(GetLocalBounds(true)); native_wrapper_->GetView()->Layout(); } } gfx::Size Textfield::GetPreferredSize() { gfx::Insets insets; CalculateInsets(&insets); return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) + insets.width(), num_lines_ * font_.height() + insets.height()); } bool Textfield::IsFocusable() const { return IsEnabled() && !read_only_; } void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { SelectAll(); } bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { #if defined(OS_WIN) // TODO(hamaji): Figure out which keyboard combinations we need to add here, // similar to LocationBarView::SkipDefaultKeyEventProcessing. const int c = e.GetCharacter(); if (c == VK_BACK) return true; // We'll handle BackSpace ourselves. // We don't translate accelerators for ALT + NumPad digit, they are used for // entering special characters. We do translate alt-home. if (e.IsAltDown() && (c != VK_HOME) && win_util::IsNumPadDigit(c, e.IsExtendedKey())) return true; #endif return false; } void Textfield::SetEnabled(bool enabled) { View::SetEnabled(enabled); if (native_wrapper_) native_wrapper_->UpdateEnabled(); } void Textfield::Focus() { if (native_wrapper_) { // Forward the focus to the wrapper if it exists. native_wrapper_->SetFocus(); } else { // If there is no wrapper, cause the RootView to be focused so that we still // get keyboard messages. View::Focus(); } } void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if (is_add && !native_wrapper_ && GetWidget() && !initialized_) { initialized_ = true; native_wrapper_ = NativeTextfieldWrapper::CreateWrapper(this); //AddChildView(native_wrapper_->GetView()); // TODO(beng): Move this initialization to NativeTextfieldWin once it // subclasses NativeControlWin. native_wrapper_->UpdateText(); native_wrapper_->UpdateBackgroundColor(); native_wrapper_->UpdateReadOnly(); native_wrapper_->UpdateFont(); native_wrapper_->UpdateEnabled(); native_wrapper_->UpdateBorder(); // We need to call Layout here because any previous calls to Layout // will have short-circuited and we don't call AddChildView. Layout(); } } std::string Textfield::GetClassName() const { return kViewClassName; } } // namespace views
25.397004
80
0.692081
zachlatta
5e96838dc84f050a83b3cff06f613681a0ba0b70
2,482
cpp
C++
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
/************************************************** Copyright 2015 Daniel "MonzUn" Bengtsson ***************************************************/ #include "ReplayUtility.h" #include <messaging/GameMessages.h> using namespace SerializationUtility; ReplayFrame::ReplayFrame( ) {} ReplayFrame::~ReplayFrame( ) { for ( int i = 0; i < Messages.size( ); ++i ) tDelete( Messages[i] ); } ReplayFrame::ReplayFrame( const ReplayFrame& rhs ) { this->ID = rhs.ID; this->Hash = rhs.Hash; this->RandomCounter = rhs.RandomCounter; for ( int i = 0; i < rhs.Messages.size( ); ++i ) this->Messages.push_back( rhs.Messages[i]->Clone( ) ); } unsigned int ReplayFrame::GetSerializationSize( ) const { unsigned int size = static_cast<unsigned int>(sizeof(unsigned int)* 4); // ID, Hash, RandomCounter, and vector size for ( auto& message : Messages ) size += message->GetSerializationSize(); return size; } void ReplayFrame::Serialize( Byte*& buffer ) const { // Serialize ID and Hash CopyAndIncrementDestination( buffer, &ID, sizeof(unsigned int) ); CopyAndIncrementDestination( buffer, &Hash, sizeof(unsigned int) ); CopyAndIncrementDestination( buffer, &RandomCounter, sizeof(unsigned int) ); // Serialize all messages for the current frame unsigned int recordedMessagesCount = static_cast<unsigned int>(Messages.size( )); CopyAndIncrementDestination( buffer, &recordedMessagesCount, sizeof(unsigned int) ); for ( auto& message : Messages ) message->Serialize( buffer ); } void ReplayFrame::Deserialize( const Byte*& buffer ) { // Deserialize ID and Hash CopyAndIncrementSource( &ID, buffer, sizeof(unsigned int) ); CopyAndIncrementSource( &Hash, buffer, sizeof(unsigned int) ); CopyAndIncrementSource( &RandomCounter, buffer, sizeof(unsigned int) ); // Deserialize all messages for the current frame unsigned int recordedMessagesCount; CopyAndIncrementSource( &recordedMessagesCount, buffer, sizeof(unsigned int) ); Messages.reserve( recordedMessagesCount ); for ( unsigned int i = 0; i < recordedMessagesCount; ++i ) { MessageTypes::MessageType messageType; memcpy( &messageType, buffer, sizeof( MESSAGE_TYPE_ENUM_UNDELYING_TYPE ) ); // Deserialize the message type Message* message = Messages::GetDefaultMessage( messageType ); // Use the type to run the specific message types constructor message->Deserialize( buffer ); // Read the specific data for this message Messages.push_back( message ); // Add it to this frames recorded messages } }
35.457143
126
0.711523
Robograde
5e9c6e3170e48c33b13b076213827f8b46e04e3e
2,093
cpp
C++
src/ndnSIM/helper/ndn-face-container.cpp
NDNLink/NDN-Chord
cfabf8f56eea2c4ba47052ce145a939ebdc21e57
[ "MIT" ]
1
2021-09-07T04:12:15.000Z
2021-09-07T04:12:15.000Z
src/ndnSIM/helper/ndn-face-container.cpp
NDNLink/NDN-Chord
cfabf8f56eea2c4ba47052ce145a939ebdc21e57
[ "MIT" ]
null
null
null
src/ndnSIM/helper/ndn-face-container.cpp
NDNLink/NDN-Chord
cfabf8f56eea2c4ba47052ce145a939ebdc21e57
[ "MIT" ]
1
2020-07-15T06:21:03.000Z
2020-07-15T06:21:03.000Z
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** * Copyright (c) 2011-2015 Regents of the University of California. * * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and * contributors. * * ndnSIM 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, * either version 3 of the License, or (at your option) any later version. * * ndnSIM 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 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. **/ #include "ndn-face-container.hpp" #include <algorithm> namespace ns3 { namespace ndn { FaceContainer::FaceContainer() = default; FaceContainer::FaceContainer(const FaceContainer& other) { AddAll(other); } FaceContainer& FaceContainer::operator= (const FaceContainer &other) { m_faces.clear(); AddAll(other); return *this; } void FaceContainer::AddAll(Ptr<FaceContainer> other) { AddAll(*other); } void FaceContainer::AddAll(const FaceContainer& other) { if (this == &other) { // adding self to self, need to make a copy auto copyOfFaces = other.m_faces; m_faces.insert(m_faces.end(), copyOfFaces.begin(), copyOfFaces.end()); } else { m_faces.insert(m_faces.end(), other.m_faces.begin(), other.m_faces.end()); } } FaceContainer::Iterator FaceContainer::Begin(void) const { return m_faces.begin(); } FaceContainer::Iterator FaceContainer::End(void) const { return m_faces.end(); } uint32_t FaceContainer::GetN(void) const { return m_faces.size(); } void FaceContainer::Add(shared_ptr<Face> face) { m_faces.push_back(face); } shared_ptr<Face> FaceContainer::Get(size_t i) const { return m_faces.at(i); } } // namespace ndn } // namespace ns3
22.505376
86
0.71763
NDNLink
5e9c9565c604f811f449f55c1b7b13ebadb983c3
8,621
cc
C++
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
#include "config.h" #include "Graphics.h" #include <cstring> #include <chrono> #include "MeshResource.h" #include "GraphicsNode.h" #include "JointsStructure.h" #define PI 3.14159265 //#define true false using namespace Display; namespace Labb2 { Graphics::Graphics() { } Graphics::~Graphics() { } bool Graphics::Open() { App::Open(); this->window = new Display::Window; this->window->SetSize(600, 600); camera.setValues(0, 0, 4); origin.setValues(0, 0, 0); headUp.setValues(0, 1, 0); camFront.setValues(0.0f, 0.0f, 1.0f); yaw = -90.0f; // Yaw is initialized to -90.0 degrees since a yaw of 0.0 results in a direction vector pointing to the right (due to how Eular angles work) so we initially rotate a bit to the left. pitch = 0.0f; oldPosX = 300; oldPosY = 300; window->SetKeyPressFunction([this](int32 key, int32, int32, int32) { float camSpeed = 0.05f; if (GLFW_KEY_E == key) { if (mouseLocked == false) { glfwSetInputMode(this->window->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); mouseLocked = true; } } if (GLFW_KEY_R == key) { glfwSetInputMode(this->window->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); mouseLocked = false; } if (GLFW_KEY_1 == key) { this->clipIndex = 0; } if (GLFW_KEY_2 == key) { this->clipIndex = 1; } if (GLFW_KEY_3 == key) { this->clipIndex = 2; } if (GLFW_KEY_4 == key) { this->clipIndex = 3; } if (GLFW_KEY_5 == key) { this->clipIndex = 4; } if (GLFW_KEY_6 == key) { this->clipIndex = 5; } if (GLFW_KEY_7 == key) { this->clipIndex = 6; } if (GLFW_KEY_8 == key) { this->clipIndex = 7; } if (GLFW_KEY_ESCAPE == key) { this->window->Close(); } if (GLFW_KEY_COMMA == key) { this->skeleIndex++; } if (GLFW_KEY_PERIOD == key) { this->skeleIndex--; } if (GLFW_KEY_W == key) { if (!mouseLocked) { this->y += 0.1f; } else { camera[0] -= (camFront * camSpeed)[0]; camera[1] -= (camFront * camSpeed)[1]; camera[2] -= (camFront * camSpeed)[2]; } //this->y += 0.1f; //camera[1] += 0.1f; } if (GLFW_KEY_A == key) { if (!mouseLocked) { this->x += 0.1f; } else { camera[0] -= (camFront.cross(headUp).normalizeRe() * camSpeed)[0]; camera[1] -= (camFront.cross(headUp).normalizeRe() * camSpeed)[1]; camera[2] -= ((camFront.cross(headUp).normalizeRe()) * camSpeed)[2]; } //camera[0] -= 0.1f; } if (GLFW_KEY_S == key) { if (!mouseLocked) { this->y -= 0.1f; } else { camera[0] += (camFront * camSpeed)[0]; camera[1] += (camFront * camSpeed)[1]; camera[2] += (camFront * camSpeed)[2]; } //camera[1] -= 0.1f; } if (GLFW_KEY_D == key) { if (!mouseLocked) { this->x -= 0.1f; } else { camera[0] += (camFront.cross(headUp).normalizeRe() * camSpeed)[0]; camera[1] += (camFront.cross(headUp).normalizeRe() * camSpeed)[1]; camera[2] += ((camFront.cross(headUp).normalizeRe()) * camSpeed)[2]; } //camera[0] += 0.1f; } }); window->SetMousePressFunction([this](int32 key, int32 state , int32) { if (key == GLFW_MOUSE_BUTTON_LEFT && state == GLFW_PRESS) { mousePressedLeft = true; } if (key == GLFW_MOUSE_BUTTON_LEFT && state == GLFW_RELEASE) { mousePressedLeft = false; } if (key == GLFW_MOUSE_BUTTON_RIGHT && state == GLFW_PRESS) { mousePressed = true; if (vertexINT == 0) { v1.setXY(mX, mY); vertexINT++; } else if (vertexINT == 1) { v2.setXY(mX, mY); vertexINT++; } else if (vertexINT == 2) { v3.setXY(mX, mY); vertexINT++; } } if (key == GLFW_MOUSE_BUTTON_RIGHT && state == GLFW_RELEASE) { mousePressed = false; } }); window->SetMouseScrollFunction([this](float64 x, float64 y) { scrollX += 0.1f * y; }); window->SetMouseMoveFunction([this](float64 xpos, float64 ypos) { if (mousePressedLeft) { posX = (xpos - oldPosX); posY = (ypos - oldPosY); } if (mouseLocked == false || mousePressed != true ) { oldPosX = xpos; oldPosY = ypos; return; } if(firstM) { oldPosX = xpos; oldPosY = ypos; firstM = false; } GLfloat xoffset = xpos - oldPosX; GLfloat yoffset = oldPosY - ypos; oldPosX = xpos; oldPosY = ypos; float sensitivity = 0.05; xoffset *= sensitivity; yoffset *= sensitivity; yaw += xoffset; pitch -= yoffset; if(pitch > 89.0f) pitch = 89.0f; if(pitch < -89.0f) pitch = -89.0f; vector3D front; front[0] = (cos(rad(yaw)) * cos(rad(pitch))); front[1] = (sin(rad(pitch))); front[2] = -(sin(rad(yaw)) * cos(rad(pitch))); camFront = front.normalizeRe(); mX = xpos; mY = 300 - ypos; oldPosX = xpos; oldPosY = ypos; }); if (this->window->Open()) { glClearColor(0.1f, 0.1f, 0.1f, 1.0f); return true; } return false; } void Graphics::Run() { /* SoftRender s; s.lambdaPixels = [](SoftRender::Vertex v, unsigned char *image) { SoftRender::Color c; vector3D PL(50.0f, 2.0f, 1.0f); vector3D vec(v.nx, v.ny, v.nz); PL.normalize(); float intens = vec.dott(PL)-4; if (intens < 0) { intens = 0; } if (intens > 1) { intens = 1; } int teX = (v.U * 300); int teY = (v.V * 300); int index = (teY * 300 + teX) * 4; c.R = image[index] * intens; c.G = image[index + 1] * intens; c.B = image[index + 2] * intens; return c; }; TextureResource tex; s.loadTexture("frooog.jpg"); s.draw(300, 300); s.drawQuad(); GraphicsNode graph; texture = std::make_shared<TextureResource>(); texture->loadFromRaz(s); texture->bind(); graph.setTexture(texture); */ JointsStructure a; GraphicsNode graph; matrix4D mvp; matrix4D projection; matrix4D view; glEnable(GL_DEPTH_TEST); //a.createSkeleton(); projection = (projection.setPerspective(45.0f, (600.0f / 600.0f), 0.1f, 100.0f)); //view = view.LookAtRH(camera, origin, headUp); a.createInverseOriginal(); typedef std::chrono::system_clock Clock; auto start = Clock::now(); static int keyclip = 0; while (this->window->IsOpen()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); this->window->Update(); //Rotate camera: //float radius = 5.0f; //float camX = sin(glfwGetTime()) * radius; //float camZ = cos(glfwGetTime()) * radius; model = model.transform(x, y, 0) * model.rot_x(-posY ) * model.rot_y(-posX ); //model = model.transform(x * 100, y * 100, (scrollX + 5) * 100) * model.rot_x(posY / 10.0f) * model.rot_y(-posX / 10.0f); //camera[2] = (float)(scrollX - 2); view = view.LookAtRH(camera, camera+camFront, headUp); //Rotate camera: //camera.setValues(camX, 0.0, camZ); //view = view.LookAtRH(camera, origin, headUp); posY = 0.0f; posX = 0.0f; //matrix4D rotmaty = model.rot_x(-posY * 100 ) * model.rot_y(-posX *100 ) ;// rotmaty.rot_y(2); //matrix4D rotmatx = rotmaty.rot_z(5); static int r = 0; if (a.an->animClips[clipIndex].keyDuration <= (ushort)std::chrono::duration_cast<std::chrono::milliseconds> (Clock::now()-start).count()) { if ( r >= a.an->animClips[clipIndex].numKeys) { r = 0; } a.PlayAnimation(r++, clipIndex); start = Clock::now(); } //graph.draw(model); a.drawSkeleton(); //mvp = projection * view * model; matrix4D pv = projection * view; graph.drawAnim(model, pv, a.bones); this->window->SwapBuffers(); } } float Graphics::rad(float d) { float rad = (PI/180) * d; return rad; } } // namespace Example
21.825316
201
0.519545
miraz12
5ea1ba69aa45b824e72a50c7fd3bb59c7b96a9b8
3,445
cpp
C++
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
9
2016-05-27T01:00:39.000Z
2021-04-01T08:54:46.000Z
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
1
2016-03-03T22:54:08.000Z
2016-03-03T22:54:08.000Z
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
4
2016-05-27T01:00:43.000Z
2018-08-19T08:47:49.000Z
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1992 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)stak.c 1.5 (gritter) 6/15/05 */ /* from OpenSolaris "stak.c 1.10 05/06/08 SMI" */ /* * UNIX shell */ #include "defs.h" /* ======== storage allocation ======== */ unsigned char * getstak ( /* allocate requested stack */ intptr_t asize ) { register unsigned char *oldstak; register int size; size = round((intptr_t)asize, BYTESPERWORD); oldstak = stakbot; staktop = stakbot += size; if (staktop >= brkend) growstak(staktop); return(oldstak); } /* * set up stack for local use * should be followed by `endstak' */ unsigned char * locstak(void) { if (brkend - stakbot < BRKINCR) { if (setbrk(brkincr) == (unsigned char *)-1) error((const unsigned char*)nostack); if (brkincr < BRKMAX) brkincr += 256; } return(stakbot); } void growstak(unsigned char *newtop) { register uintptr_t incr; incr = (uintptr_t)round(newtop - brkend + 1, BYTESPERWORD); if (brkincr > incr) incr = brkincr; if (setbrk(incr) == (unsigned char *)-1) error((const unsigned char*)nospace); } unsigned char * savstak(void) { assert(staktop == stakbot); return(stakbot); } unsigned char * endstak ( /* tidy up after `locstak' */ register unsigned char *argp ) { register unsigned char *oldstak; if (argp >= brkend) growstak(argp); *argp++ = 0; oldstak = stakbot; stakbot = staktop = (unsigned char *)round(argp, BYTESPERWORD); if (staktop >= brkend) growstak(staktop); return(oldstak); } void tdystak ( /* try to bring stack back to x */ register unsigned char *x ) { while ((unsigned char *)stakbsy > x) { free(stakbsy); stakbsy = stakbsy->word; } staktop = stakbot = max(x, stakbas); rmtemp((struct ionod *)x); } void stakchk(void) { if ((brkend - stakbas) > BRKINCR + BRKINCR) setbrk(-BRKINCR); } unsigned char * cpystak(unsigned char *x) { return(endstak(movstrstak(x, locstak()))); } unsigned char * movstrstak(register const unsigned char *a, register unsigned char *b) { do { if (b >= brkend) growstak(b); } while (*b++ = *a++); return(--b); } /* * Copy s2 to s1, always copy n bytes. * Return s1 */ unsigned char * memcpystak(register unsigned char *s1, register const unsigned char *s2, register int n) { register unsigned char *os1 = s1; while (--n >= 0) { if (s1 >= brkend) growstak(s1); *s1++ = *s2++; } return (os1); }
20.264706
72
0.666183
mfaithfull
5ea331084ee6c9a229ac38ecefc976f5dec7e688
2,319
cpp
C++
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
#include <iostream> #include <vector> #include <set> int floodFill(std::vector<std::vector<int>>& grid, int i, int j, int mark) { if (grid[i][j] != 1) return 0; grid[i][j] = mark; int area = 1; if (i > 0) area += floodFill(grid, i - 1, j, mark); if (i < grid.size() - 1) area += floodFill(grid, i + 1, j, mark); if (j > 0) area += floodFill(grid, i, j - 1, mark); if (j < grid.size() - 1) area += floodFill(grid, i, j + 1, mark); return area; } std::set<int> get_neighbouring_islands(const std::vector<std::vector<int>>& grid, int i, int j) { std::set<int> neighbouring_islands; if (i > 0 && grid[i - 1][j]) neighbouring_islands.insert(grid[i - 1][j]); if (i < grid.size() - 1 && grid[i + 1][j]) neighbouring_islands.insert(grid[i + 1][j]); if (j > 0 && grid[i][j - 1]) neighbouring_islands.insert(grid[i][j - 1]); if (j < grid[0].size() - 1 && grid[i][j + 1]) neighbouring_islands.insert(grid[i][j + 1]); return neighbouring_islands; } int largestIsland(std::vector<std::vector<int>>& grid) { int max_area = 0; std::vector<int> islands_areas; int island_count = 0; for (int i = 0; i < grid.size(); ++i) for (int j = 0; j < grid[0].size(); ++j) if (grid[i][j] == 1) { int area = floodFill(grid, i, j, island_count + 2); islands_areas.push_back(area); max_area = std::max(max_area, area); ++island_count; } for (int i = 0; i < grid.size(); ++i) for (int j = 0; j < grid[0].size(); ++j) if (!grid[i][j]) { std::set<int> neighbouring_islands = get_neighbouring_islands(grid, i, j); int large_island_area = 1; for (auto& island_mark : neighbouring_islands) large_island_area += islands_areas[island_mark - 2]; max_area = std::max(max_area, large_island_area); } return max_area; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::vector<std::vector<int>> G; // Caso de prueba 1 // Entrada: // 1 0 // 0 1 // Salida: // 3 G = { { 1, 0 }, { 0, 1 } }; std::cout << largestIsland(G) << "\n"; // Caso de prueba 2 // Entrada: // 1 1 // 1 0 // Salida: // 4 G = { { 1, 1 }, { 0, 1 } }; std::cout << largestIsland(G) << "\n"; // Caso de prueba 3 // Entrada: // 1 1 // 1 1 // Salida: // 4 G = { { 1, 1 }, { 1, 1 } }; std::cout << largestIsland(G) << "\n"; return 0; }
22.960396
97
0.575679
MisaelVM
5ea37dd78a2b63f728f4d3a92db6b9d1b6ebca7d
98,088
hpp
C++
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
4
2018-04-11T13:31:10.000Z
2018-11-13T09:59:39.000Z
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
null
null
null
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
2
2018-04-11T02:09:08.000Z
2018-06-03T07:43:56.000Z
#pragma once #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> using namespace cv; using namespace std; #define ___MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3, out4, out5, out6, out7, __in0, __in1, __in2, __in3, __in4, __in5, __in6, __in7, __out0, __out1, __out2, __out3, __out4, __out5, __out6, __out7, __tmp0, __tmp1, __tmp2, __tmp3, __tmp4, __tmp5, __tmp6, __tmp7, __tmpp0, __tmpp1, __tmpp2, __tmpp3, __tmpp4, __tmpp5, __tmpp6, __tmpp7) \ do { \ __m256 __in0 = (in0), __in1 = (in1), __in2 = (in2), __in3 = (in3), __in4 = (in4), __in5 = (in5), __in6 = (in6), __in7 = (in7); \ __m256 __tmp0, __tmp1, __tmp2, __tmp3, __tmp4, __tmp5, __tmp6, __tmp7; \ __m256 __tmpp0, __tmpp1, __tmpp2, __tmpp3, __tmpp4, __tmpp5, __tmpp6, __tmpp7; \ __m256 __out0, __out1, __out2, __out3, __out4, __out5, __out6, __out7; \ __tmp0 = _mm256_unpacklo_ps(__in0, __in1); \ __tmp1 = _mm256_unpackhi_ps(__in0, __in1); \ __tmp2 = _mm256_unpacklo_ps(__in2, __in3); \ __tmp3 = _mm256_unpackhi_ps(__in2, __in3); \ __tmp4 = _mm256_unpacklo_ps(__in4, __in5); \ __tmp5 = _mm256_unpackhi_ps(__in4, __in5); \ __tmp6 = _mm256_unpacklo_ps(__in6, __in7); \ __tmp7 = _mm256_unpackhi_ps(__in6, __in7); \ __tmpp0 = _mm256_shuffle_ps(__tmp0, __tmp2, 0x44); \ __tmpp1 = _mm256_shuffle_ps(__tmp0, __tmp2, 0xEE); \ __tmpp2 = _mm256_shuffle_ps(__tmp1, __tmp3, 0x44); \ __tmpp3 = _mm256_shuffle_ps(__tmp1, __tmp3, 0xEE); \ __tmpp4 = _mm256_shuffle_ps(__tmp4, __tmp6, 0x44); \ __tmpp5 = _mm256_shuffle_ps(__tmp4, __tmp6, 0xEE); \ __tmpp6 = _mm256_shuffle_ps(__tmp5, __tmp7, 0x44); \ __tmpp7 = _mm256_shuffle_ps(__tmp5, __tmp7, 0xEE); \ __out0 = _mm256_permute2f128_ps(__tmpp0, __tmpp4, 0x20); \ __out1 = _mm256_permute2f128_ps(__tmpp1, __tmpp5, 0x20); \ __out2 = _mm256_permute2f128_ps(__tmpp2, __tmpp6, 0x20); \ __out3 = _mm256_permute2f128_ps(__tmpp3, __tmpp7, 0x20); \ __out4 = _mm256_permute2f128_ps(__tmpp0, __tmpp4, 0x31); \ __out5 = _mm256_permute2f128_ps(__tmpp1, __tmpp5, 0x31); \ __out6 = _mm256_permute2f128_ps(__tmpp2, __tmpp6, 0x31); \ __out7 = _mm256_permute2f128_ps(__tmpp3, __tmpp7, 0x31); \ (out0) = __out0, (out1) = __out1, (out2) = __out2, (out3) = __out3, (out4) = __out4, (out5) = __out5, (out6) = __out6, (out7) = __out7; \ } while (0) #define _MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7) \ ___MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, in5, in6, in7, \ __in0##__LINE__, __in1##__LINE__, __in2##__LINE__, __in3##__LINE__, __in4##__LINE__, __in5##__LINE__, __in6##__LINE__, __in7##__LINE__, \ __out0##__LINE__, __out1##__LINE__, __out2##__LINE__, __out3##__LINE__, __out4##__LINE__, __out5##__LINE__, __out6##__LINE__, __out7##__LINE__, \ __tmp0##__LINE__, __tmp1##__LINE__, __tmp2##__LINE__, __tmp3##__LINE__, __tmp4##__LINE__, __tmp5##__LINE__, __tmp6##__LINE__, __tmp7##__LINE__, \ __tmpp0##__LINE__, __tmpp1##__LINE__, __tmpp2##__LINE__, __tmpp3##__LINE__, __tmpp4##__LINE__, __tmpp5##__LINE__, __tmpp6##__LINE__, __tmpp7##__LINE__) #define ___MM256_TRANSPOSE4_PD(in0, in1, in2, in3, out0, out1, out2, out3, __in0, __in1, __in2, __in3, __out0, __out1, __out2, __out3, __tmp0, __tmp1, __tmp2, __tmp3) \ do { \ __m256d __in0 = (in0), __in1 = (in1), __in2 = (in2), __in3 = (in3); \ __m256d __tmp0, __tmp1, __tmp2, __tmp3; \ __m256d __out0, __out1, __out2, __out3; \ __tmp0 = _mm256_shuffle_pd(__in0, __in1, 0x0); \ __tmp1 = _mm256_shuffle_pd(__in0, __in1, 0xf); \ __tmp2 = _mm256_shuffle_pd(__in2, __in3, 0x0); \ __tmp3 = _mm256_shuffle_pd(__in2, __in3, 0xf); \ __out0 = _mm256_permute2f128_pd(__tmp0, __tmp2, 0x20); \ __out1 = _mm256_permute2f128_pd(__tmp1, __tmp3, 0x20); \ __out2 = _mm256_permute2f128_pd(__tmp0, __tmp2, 0x31); \ __out3 = _mm256_permute2f128_pd(__tmp1, __tmp3, 0x31); \ (out0) = __out0, (out1) = __out1, (out2) = __out2, (out3) = __out3; \ } while (0) #define _MM256_TRANSPOSE4_PD(in0, in1, in2, in3) \ ___MM256_TRANSPOSE4_PD(in0, in1, in2, in3, in0, in1, in2, in3, \ __in0##__LINE__, __in1##__LINE__, __in2##__LINE__, __in3##__LINE__, \ __out0##__LINE__, __out1##__LINE__, __out2##__LINE__, __out3##__LINE__, \ __tmp0##__LINE__, __tmp1##__LINE__, __tmp2##__LINE__, __tmp3##__LINE__) //spectral recursive Gaussian Filter //K. Sugimoto and S. Kamata: "Fast Gaussian filter with second-order shift property of DCT-5", Proc. IEEE Int. Conf. on Image Process. (ICIP2013), pp.514-518 (Sep. 2013). namespace spectral_recursive_filter { #define USE_BORDER_REPLICATE 1 //BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` //#define USE_BORDER_REFLECT 1 //BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` //#define USE_BORDER_REFLECT_101 1 //BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` //extrapolation functions //(atE() and atS() require variables w and h in their scope respectively) #ifdef USE_BORDER_REPLICATE #define atW(x) (std::max(x,0)) #define atN(y) (std::max(y,0)) #define atE(x) (std::min(x,w-1)) #define atS(y) (std::min(y,h-1)) #elif USE_BORDER_REFLECT #define atW(x) ( x < 0 ? std::abs(x+1) : std::abs(x)) #define atN(y) ( y < 0 ? std::abs(y+1) : std::abs(y)) #define atE(x) ( x < w ? w-1-std::abs(w-1-(x)) : w-std::abs(w-1-(x))) #define atS(y) ( y < h ? h-1-std::abs(h-1-(y)) : h-std::abs(h-1-(y))) //#define atE(x) ( x < w ? w-1-std::abs(w-1-(x)) : w-2-std::abs(w-1-(x))) //#define atS(y) ( y < h ? h-1-std::abs(h-1-(y)) : h-2-std::abs(h-1-(y))) #elif USE_BORDER_REFLECT_101 #define atW(x) (std::abs(x)) #define atN(y) (std::abs(y)) #define atE(x) (w-1-std::abs(w-1-(x))) #define atS(y) (h-1-std::abs(h-1-(y))) #endif class gauss { private: static const int K = 2; //order of approximation (do not change!) private: double sx, sy; //scale of Gaussian int rx, ry; //kernel radius std::vector<double> spectX, spectY; std::vector<double> tableX, tableY; //look-up tables public: gauss(double sx, double sy) :sx(sx), sy(sy) { if (sx < 0.0 || sy < 0.0) throw std::invalid_argument("\'sx\' and \'sy\' should be nonnegative!"); rx = estimate_radius(sx); ry = estimate_radius(sy); spectX = gen_spectrum(sx, rx); spectY = gen_spectrum(sy, ry); tableX = build_lookup_table(rx, spectX); tableY = build_lookup_table(ry, spectY); } ~gauss() {} private: static inline double phase(int r) { return 2.0*CV_PI / (r + 1 + r); //DCT/DST-5 } static inline int estimate_radius(double s) { //return (s<4.0) ? int(3.3333*s-0.3333+0.5) : int(3.4113*s-0.6452+0.5); //K==3 return (s < 4.0) ? int(3.0000*s - 0.2000 + 0.5) : int(3.0000*s + 0.5); //K==2 } static inline std::vector<double> gen_spectrum(double s, int r) { const double phi = phase(r); std::vector<double> spect(K); for (int k = 1; k <= K; k++) spect[k - 1] = 2.0*exp(-0.5*s*s*phi*phi*k*k); return spect; } static inline std::vector<double> build_lookup_table(int r, std::vector<double>& spect) { assert(spect.size() == K); const double phi = phase(r); std::vector<double> table(K*(1 + r)); for (int u = 0; u <= r; ++u) for (int k = 1; k <= K; ++k) table[K*u + k - 1] = cos(k*phi*u)*spect[k - 1]; return table; } template <typename T> inline void filter_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_sse_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_sse_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_h_OMP(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_v_OMP(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } public: template <typename T> void filter(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_v<T>(w, h, src, dst); else if (sy == 0.0) filter_h<T>(w, h, src, dst); else { filter_v<T>(w, h, src, dst); filter_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_sse(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_sse_v<T>(w, h, src, dst); else if (sy == 0.0) filter_sse_h<T>(w, h, src, dst); else { filter_sse_v<T>(w, h, src, dst); filter_sse_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_avx(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_avx_v<T>(w, h, src, dst); else if (sy == 0.0) filter_avx_h<T>(w, h, src, dst); else { filter_avx_v<T>(w, h, src, dst); filter_avx_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_avxOMP(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_avx_v_OMP<T>(w, h, src, dst); else if (sy == 0.0) filter_avx_h_OMP<T>(w, h, src, dst); else { filter_avx_v_OMP<T>(w, h, src, dst); filter_avx_h_OMP<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } void filter(const cv::Mat& src, cv::Mat& dst) { //checking the format of input/output images if (src.size() != dst.size()) throw std::invalid_argument("\'src\' and \'dst\' should have the same size!"); if (src.type() != dst.type()) throw std::invalid_argument("\'src\' and \'dst\' should have the same element type!"); if (src.channels() != 1 || dst.channels() != 1) throw std::invalid_argument("Multi-channel images are unsupported!"); if (src.isSubmatrix() || dst.isSubmatrix()) throw std::invalid_argument("Subimages are unsupported!"); switch (src.type()) { case CV_32FC1: filter_avx<float>(src.cols, src.rows, reinterpret_cast<float*>(src.data), reinterpret_cast<float*>(dst.data)); break; case CV_64FC1: filter_avx<double>(src.cols, src.rows, reinterpret_cast<double*>(src.data), reinterpret_cast<double*>(dst.data)); break; default: throw std::invalid_argument("Unsupported element type!"); break; } } }; //************************************************************************************************* template<> inline void gauss::filter_h<float>(int w, int h, float* src, float* dst) { const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; float sum, a1, a2, b1, b2; float dA, dB, delta; std::vector<float> buf(w); //to allow for src==dst for (int y = 0; y < h; ++y) { std::copy(&src[w*y], &src[w*y + w], buf.begin()); sum = buf[0]; a1 = buf[0] * table[0]; b1 = buf[1] * table[0]; a2 = buf[0] * table[1]; b2 = buf[1] * table[1]; for (int u = 1; u <= r; ++u) { const float sumA = buf[atW(0 - u)] + buf[0 + u]; const float sumB = buf[atW(1 - u)] + buf[1 + u]; sum += sumA; a1 += sumA*table[K*u + 0]; b1 += sumB*table[K*u + 0]; a2 += sumA*table[K*u + 1]; b2 += sumB*table[K*u + 1]; } //the first pixel (x=0) float* q = &dst[w*y]; q[0] = norm*(sum + a1 + a2); dA = buf[atE(0 + r + 1)] - buf[atW(0 - r)]; sum += dA; //the other pixels (0<x<w) int x = 1; while (true) //four-length ring buffers { q[x] = norm*(sum + b1 + b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 + cfR1*delta; a2 += -cf12*b2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - a1 - a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 + cfR1*delta; b2 += +cf12*a2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - b1 - b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 - cfR1*delta; a2 += -cf12*b2 - cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum + a1 + a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 - cfR1*delta; b2 += +cf12*a2 - cfR2*delta; x++; if (w <= x) break; } } } template<> inline void gauss::filter_v<float>(int w, int h, float* src, float* dst) { const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning std::vector<float> workspace((2 * K + 1)*w); //calculating the first and second terms for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; ws[0] = src[x]; ws[1] = src[x + w] * table[0]; ws[2] = src[x] * table[0]; ws[3] = src[x + w] * table[1]; ws[4] = src[x] * table[1]; } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w; ++x) { const float sum0 = src[x + w*atN(0 - v)] + src[x + w*(0 + v)]; const float sum1 = src[x + w*atN(1 - v)] + src[x + w*(1 + v)]; float* ws = &workspace[(2 * K + 1)*x]; ws[0] += sum0; ws[1] += sum1*table[K*v + 0]; ws[2] += sum0*table[K*v + 0]; ws[3] += sum1*table[K*v + 1]; ws[4] += sum0*table[K*v + 1]; } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; float *q, *p0N, *p0S, *p1N, *p1S; for (int y = 0; y < 1; ++y) //the first line (y=0) { q = &dst[w*y]; p1N = &src[w*atN(0 - r)]; p1S = &src[w*atS(0 + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); ws[0] += p1S[x] - p1N[x]; } } for (int y = 1; y < h; ++y) //remaining lines (with two-length ring buffers) { q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[1] + ws[3]); const float d0 = p0S[x] - p0N[x]; const float d1 = p1S[x] - p1N[x]; const float delta = d1 - d0; ws[0] += d1; ws[2] = cfR1*delta + cf11*ws[1] - ws[2]; ws[4] = cfR2*delta + cf12*ws[3] - ws[4]; } y++; if (h <= y) break; //to the next line q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); const float d0 = p0S[x] - p0N[x]; const float d1 = p1S[x] - p1N[x]; const float delta = d1 - d0; ws[0] += d1; ws[1] = cfR1*delta + cf11*ws[2] - ws[1]; ws[3] = cfR2*delta + cf12*ws[4] - ws[3]; } } } template<> inline void gauss::filter_sse_h<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m128) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<float> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m128 pv0 = _mm_set_ps(buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m128 pv1 = _mm_set_ps(buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m128 sum = pv0; __m128 a1 = _mm_mul_ps(_mm_set1_ps(table[0]), pv0); __m128 b1 = _mm_mul_ps(_mm_set1_ps(table[0]), pv1); __m128 a2 = _mm_mul_ps(_mm_set1_ps(table[1]), pv0); __m128 b2 = _mm_mul_ps(_mm_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m128 pv0M = _mm_set_ps(p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m128 pv1M = _mm_set_ps(p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m128 pv0P = _mm_set_ps(p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m128 pv1P = _mm_set_ps(p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m128 sumA = _mm_add_ps(pv0M, pv0P); __m128 sumB = _mm_add_ps(pv1M, pv1P); sum = _mm_add_ps(sum, sumA); a1 = _mm_add_ps(a1, _mm_mul_ps(_mm_set1_ps(table[K*u + 0]), sumA)); b1 = _mm_add_ps(b1, _mm_mul_ps(_mm_set1_ps(table[K*u + 0]), sumB)); a2 = _mm_add_ps(a2, _mm_mul_ps(_mm_set1_ps(table[K*u + 1]), sumA)); b2 = _mm_add_ps(b2, _mm_mul_ps(_mm_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m128 pvA, pvB; __m128 dvA, dvB, delta; __m128 qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); sum = _mm_add_ps(sum, dvA); //b1=_mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1),delta),_mm_mul_ps(_mm_set1_ps(cf11),a1)),b1); //b2=_mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2),delta),_mm_mul_ps(_mm_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE4_PS(qv[0], qv[1], qv[2], qv[3]); _mm_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm_storeu_ps(&dst[w*(y + 3)], qv[3]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE4_PS(qv[0], qv[1], qv[2], qv[3]); _mm_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm_storeu_ps(&dst[w*(y + 3) + x], qv[3]); } } } template<> inline void gauss::filter_sse_v<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m128) == 0); const int B = sizeof(__m128) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m128))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m128 p0 = _mm_load_ps(&src[x]); __m128 p1 = _mm_load_ps(&src[x + w]); _mm_store_ps(&ws[B * 0], p0); _mm_store_ps(&ws[B * 1], _mm_mul_ps(p1, _mm_set1_ps(table[0]))); _mm_store_ps(&ws[B * 2], _mm_mul_ps(p0, _mm_set1_ps(table[0]))); _mm_store_ps(&ws[B * 3], _mm_mul_ps(p1, _mm_set1_ps(table[1]))); _mm_store_ps(&ws[B * 4], _mm_mul_ps(p0, _mm_set1_ps(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m128 sum0 = _mm_add_ps(_mm_load_ps(&src[x + w*atN(0 - v)]), _mm_load_ps(&src[x + w*(0 + v)])); __m128 sum1 = _mm_add_ps(_mm_load_ps(&src[x + w*atN(1 - v)]), _mm_load_ps(&src[x + w*(1 + v)])); _mm_store_ps(&ws[B * 0], _mm_add_ps(_mm_load_ps(&ws[B * 0]), sum0)); _mm_store_ps(&ws[B * 1], _mm_add_ps(_mm_load_ps(&ws[B * 1]), _mm_mul_ps(sum1, _mm_set1_ps(table[K*v + 0])))); _mm_store_ps(&ws[B * 2], _mm_add_ps(_mm_load_ps(&ws[B * 2]), _mm_mul_ps(sum0, _mm_set1_ps(table[K*v + 0])))); _mm_store_ps(&ws[B * 3], _mm_add_ps(_mm_load_ps(&ws[B * 3]), _mm_mul_ps(sum1, _mm_set1_ps(table[K*v + 1])))); _mm_store_ps(&ws[B * 4], _mm_add_ps(_mm_load_ps(&ws[B * 4]), _mm_mul_ps(sum0, _mm_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m128 a0 = _mm_load_ps(&ws[B * 0]); const __m128 a2 = _mm_load_ps(&ws[B * 2]); const __m128 a4 = _mm_load_ps(&ws[B * 4]); _mm_store_ps(&q[x], _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(a0, _mm_add_ps(a2, a4)))); const __m128 d = _mm_sub_ps(_mm_load_ps(&p1S[x]), _mm_load_ps(&p1N[x])); _mm_store_ps(&ws[B * 0], _mm_add_ps(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m128 a0 = _mm_load_ps(&ws[B * 0]); const __m128 a1 = _mm_load_ps(&ws[B * 1]); const __m128 a3 = _mm_load_ps(&ws[B * 3]); _mm_store_ps(&q[x], _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(a0, _mm_add_ps(a1, a3)))); const __m128 d0 = _mm_sub_ps(_mm_load_ps(&p0S[x]), _mm_load_ps(&p0N[x])); const __m128 d1 = _mm_sub_ps(_mm_load_ps(&p1S[x]), _mm_load_ps(&p1N[x])); const __m128 delta = _mm_sub_ps(d1, d0); _mm_store_ps(&ws[B * 0], _mm_add_ps(a0, d1)); _mm_store_ps(&ws[B * 1], _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), _mm_load_ps(&ws[B * 2]))); _mm_store_ps(&ws[B * 2], a1); _mm_store_ps(&ws[B * 3], _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a3)), _mm_load_ps(&ws[B * 4]))); _mm_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_h_OMP<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m256) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; assert(h%B == 0); #pragma omp parallel for for (int y = 0; y < h / B*B; y += B) { //to allow for src==dst std::vector<float> buf(B*w); std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256 pv0 = _mm256_set_ps(buf[w * 7 + 0], buf[w * 6 + 0], buf[w * 5 + 0], buf[w * 4 + 0], buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256 pv1 = _mm256_set_ps(buf[w * 7 + 1], buf[w * 6 + 1], buf[w * 5 + 1], buf[w * 4 + 1], buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256 sum = pv0; __m256 a1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv0); __m256 b1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv1); __m256 a2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv0); __m256 b2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m256 pv0M = _mm256_set_ps(p0M[w * 7], p0M[w * 6], p0M[w * 5], p0M[w * 4], p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256 pv1M = _mm256_set_ps(p1M[w * 7], p1M[w * 6], p1M[w * 5], p1M[w * 4], p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256 pv0P = _mm256_set_ps(p0P[w * 7], p0P[w * 6], p0P[w * 5], p0P[w * 4], p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256 pv1P = _mm256_set_ps(p1P[w * 7], p1P[w * 6], p1P[w * 5], p1P[w * 4], p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256 sumA = _mm256_add_ps(pv0M, pv0P); __m256 sumB = _mm256_add_ps(pv1M, pv1P); sum = _mm256_add_ps(sum, sumA); a1 = _mm256_add_ps(a1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumA)); b1 = _mm256_add_ps(b1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumB)); a2 = _mm256_add_ps(a2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumA)); b2 = _mm256_add_ps(b2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m256 pvA, pvB; __m256 dvA, dvB, delta; __m256 qv[B]; //the first eight pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); sum = _mm256_add_ps(sum, dvA); //b1=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1),delta),_mm256_mul_ps(_mm256_set1_ps(cf11),a1)),b1); //b2=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2),delta),_mm256_mul_ps(_mm256_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3)], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4)], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5)], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6)], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7)], qv[7]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //eight-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3) + x], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4) + x], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5) + x], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6) + x], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7) + x], qv[7]); } } } template<> inline void gauss::filter_avx_h<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m256) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<float> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256 pv0 = _mm256_set_ps(buf[w * 7 + 0], buf[w * 6 + 0], buf[w * 5 + 0], buf[w * 4 + 0], buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256 pv1 = _mm256_set_ps(buf[w * 7 + 1], buf[w * 6 + 1], buf[w * 5 + 1], buf[w * 4 + 1], buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256 sum = pv0; __m256 a1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv0); __m256 b1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv1); __m256 a2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv0); __m256 b2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m256 pv0M = _mm256_set_ps(p0M[w * 7], p0M[w * 6], p0M[w * 5], p0M[w * 4], p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256 pv1M = _mm256_set_ps(p1M[w * 7], p1M[w * 6], p1M[w * 5], p1M[w * 4], p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256 pv0P = _mm256_set_ps(p0P[w * 7], p0P[w * 6], p0P[w * 5], p0P[w * 4], p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256 pv1P = _mm256_set_ps(p1P[w * 7], p1P[w * 6], p1P[w * 5], p1P[w * 4], p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256 sumA = _mm256_add_ps(pv0M, pv0P); __m256 sumB = _mm256_add_ps(pv1M, pv1P); sum = _mm256_add_ps(sum, sumA); a1 = _mm256_add_ps(a1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumA)); b1 = _mm256_add_ps(b1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumB)); a2 = _mm256_add_ps(a2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumA)); b2 = _mm256_add_ps(b2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m256 pvA, pvB; __m256 dvA, dvB, delta; __m256 qv[B]; //the first eight pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); sum = _mm256_add_ps(sum, dvA); //b1=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1),delta),_mm256_mul_ps(_mm256_set1_ps(cf11),a1)),b1); //b2=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2),delta),_mm256_mul_ps(_mm256_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3)], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4)], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5)], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6)], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7)], qv[7]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //eight-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3) + x], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4) + x], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5) + x], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6) + x], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7) + x], qv[7]); } } } template<> inline void gauss::filter_avx_v<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m256) == 0); const int B = sizeof(__m256) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m256))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 p0 = _mm256_load_ps(&src[x]); __m256 p1 = _mm256_load_ps(&src[x + w]); _mm256_store_ps(&ws[B * 0], p0); _mm256_store_ps(&ws[B * 1], _mm256_mul_ps(p1, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 2], _mm256_mul_ps(p0, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 3], _mm256_mul_ps(p1, _mm256_set1_ps(table[1]))); _mm256_store_ps(&ws[B * 4], _mm256_mul_ps(p0, _mm256_set1_ps(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 sum0 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(0 - v)]), _mm256_load_ps(&src[x + w*(0 + v)])); __m256 sum1 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(1 - v)]), _mm256_load_ps(&src[x + w*(1 + v)])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(_mm256_load_ps(&ws[B * 0]), sum0)); _mm256_store_ps(&ws[B * 1], _mm256_add_ps(_mm256_load_ps(&ws[B * 1]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 2], _mm256_add_ps(_mm256_load_ps(&ws[B * 2]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 3], _mm256_add_ps(_mm256_load_ps(&ws[B * 3]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 1])))); _mm256_store_ps(&ws[B * 4], _mm256_add_ps(_mm256_load_ps(&ws[B * 4]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a2 = _mm256_load_ps(&ws[B * 2]); const __m256 a4 = _mm256_load_ps(&ws[B * 4]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a2, a4)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d0)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a1 = _mm256_load_ps(&ws[B * 1]); const __m256 a3 = _mm256_load_ps(&ws[B * 3]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a1, a3)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p0S[x]), _mm256_load_ps(&p0N[x])); const __m256 d1 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); const __m256 delta1 = _mm256_sub_ps(d1, d0); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d1)); _mm256_store_ps(&ws[B * 1], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta1), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), _mm256_load_ps(&ws[B * 2]))); _mm256_store_ps(&ws[B * 2], a1); _mm256_store_ps(&ws[B * 3], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta1), _mm256_mul_ps(_mm256_set1_ps(cf12), a3)), _mm256_load_ps(&ws[B * 4]))); _mm256_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_v_OMP<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m256) == 0); const int B = sizeof(__m256) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m256))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 p0 = _mm256_load_ps(&src[x]); __m256 p1 = _mm256_load_ps(&src[x + w]); _mm256_store_ps(&ws[B * 0], p0); _mm256_store_ps(&ws[B * 1], _mm256_mul_ps(p1, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 2], _mm256_mul_ps(p0, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 3], _mm256_mul_ps(p1, _mm256_set1_ps(table[1]))); _mm256_store_ps(&ws[B * 4], _mm256_mul_ps(p0, _mm256_set1_ps(table[1]))); } //#pragma omp parallel for for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 sum0 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(0 - v)]), _mm256_load_ps(&src[x + w*(0 + v)])); __m256 sum1 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(1 - v)]), _mm256_load_ps(&src[x + w*(1 + v)])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(_mm256_load_ps(&ws[B * 0]), sum0)); _mm256_store_ps(&ws[B * 1], _mm256_add_ps(_mm256_load_ps(&ws[B * 1]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 2], _mm256_add_ps(_mm256_load_ps(&ws[B * 2]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 3], _mm256_add_ps(_mm256_load_ps(&ws[B * 3]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 1])))); _mm256_store_ps(&ws[B * 4], _mm256_add_ps(_mm256_load_ps(&ws[B * 4]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution //#pragma omp parallel for for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a2 = _mm256_load_ps(&ws[B * 2]); const __m256 a4 = _mm256_load_ps(&ws[B * 4]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a2, a4)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d0)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; //#pragma omp parallel for for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a1 = _mm256_load_ps(&ws[B * 1]); const __m256 a3 = _mm256_load_ps(&ws[B * 3]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a1, a3)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p0S[x]), _mm256_load_ps(&p0N[x])); const __m256 d1 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); const __m256 delta1 = _mm256_sub_ps(d1, d0); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d1)); _mm256_store_ps(&ws[B * 1], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta1), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), _mm256_load_ps(&ws[B * 2]))); _mm256_store_ps(&ws[B * 2], a1); _mm256_store_ps(&ws[B * 3], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta1), _mm256_mul_ps(_mm256_set1_ps(cf12), a3)), _mm256_load_ps(&ws[B * 4]))); _mm256_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_h<double>(int w, int h, double* src, double* dst) { const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; double sum, a1, a2, b1, b2; double dA, dB, delta; std::vector<double> buf(w); //to allow for src==dst for (int y = 0; y < h; ++y) { std::copy(&src[w*y], &src[w*y + w], buf.begin()); sum = buf[0]; a1 = buf[0] * table[0]; b1 = buf[1] * table[0]; a2 = buf[0] * table[1]; b2 = buf[1] * table[1]; for (int u = 1; u <= r; ++u) { const double sumA = buf[atW(0 - u)] + buf[0 + u]; const double sumB = buf[atW(1 - u)] + buf[1 + u]; sum += sumA; a1 += sumA*table[K*u + 0]; b1 += sumB*table[K*u + 0]; a2 += sumA*table[K*u + 1]; b2 += sumB*table[K*u + 1]; } //the first pixel (x=0) double* q = &dst[w*y]; q[0] = norm*(sum + a1 + a2); dA = buf[atE(0 + r + 1)] - buf[atW(0 - r)]; sum += dA; //the other pixels (0<x<w) int x = 1; while (true) //four-length ring buffers { q[x] = norm*(sum + b1 + b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 + cfR1*delta; a2 += -cf12*b2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - a1 - a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 + cfR1*delta; b2 += +cf12*a2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - b1 - b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 - cfR1*delta; a2 += -cf12*b2 - cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum + a1 + a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 - cfR1*delta; b2 += +cf12*a2 - cfR2*delta; x++; if (w <= x) break; } } } template<> inline void gauss::filter_v<double>(int w, int h, double* src, double* dst) { const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning std::vector<double> workspace((2 * K + 1)*w); //calculating the first and second terms for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; ws[0] = src[x]; ws[1] = src[x + w] * table[0]; ws[2] = src[x] * table[0]; ws[3] = src[x + w] * table[1]; ws[4] = src[x] * table[1]; } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w; ++x) { const double sum0 = src[x + w*atN(0 - v)] + src[x + w*(0 + v)]; const double sum1 = src[x + w*atN(1 - v)] + src[x + w*(1 + v)]; double* ws = &workspace[(2 * K + 1)*x]; ws[0] += sum0; ws[1] += sum1*table[K*v + 0]; ws[2] += sum0*table[K*v + 0]; ws[3] += sum1*table[K*v + 1]; ws[4] += sum0*table[K*v + 1]; } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; double *q, *p0N, *p0S, *p1N, *p1S; for (int y = 0; y < 1; ++y) //the first line (y=0) { q = &dst[w*y]; p1N = &src[w*atN(0 - r)]; p1S = &src[w*atS(0 + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); ws[0] += p1S[x] - p1N[x]; } } for (int y = 1; y < h; ++y) //remaining lines (with two-length ring buffers) { q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[1] + ws[3]); const double d0 = p0S[x] - p0N[x]; const double d1 = p1S[x] - p1N[x]; const double delta = d1 - d0; ws[0] += d1; ws[2] = cfR1*delta + cf11*ws[1] - ws[2]; ws[4] = cfR2*delta + cf12*ws[3] - ws[4]; } y++; if (h <= y) break; //to the next line q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); const double d0 = p0S[x] - p0N[x]; const double d1 = p1S[x] - p1N[x]; const double delta = d1 - d0; ws[0] += d1; ws[1] = cfR1*delta + cf11*ws[2] - ws[1]; ws[3] = cfR2*delta + cf12*ws[4] - ws[3]; } } } #define _MM_TRANSPOSE2_PD(row0, row1) { \ __m128d tmp1, tmp0; \ \ tmp0 = _mm_shuffle_pd(row0, row1, 0); \ tmp1 = _mm_shuffle_pd(row0, row1, 3); \ row0 = tmp0; \ row1 = tmp1; \ } template<> inline void gauss::filter_sse_h<double>(int w, int h, double* src, double* dst) { const int B = sizeof(__m128d) / sizeof(double); const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<double> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m128d pv0 = _mm_set_pd(buf[w * 1 + 0], buf[w * 0 + 0]); __m128d pv1 = _mm_set_pd(buf[w * 1 + 1], buf[w * 0 + 1]); __m128d sum = pv0; __m128d a1 = _mm_mul_pd(_mm_set1_pd(table[0]), pv0); __m128d b1 = _mm_mul_pd(_mm_set1_pd(table[0]), pv1); __m128d a2 = _mm_mul_pd(_mm_set1_pd(table[1]), pv0); __m128d b2 = _mm_mul_pd(_mm_set1_pd(table[1]), pv1); for (int u = 1; u <= r; ++u) { const double* p0M = &buf[atW(0 - u)]; const double* p1M = &buf[atW(1 - u)]; const double* p0P = &buf[(0 + u)]; const double* p1P = &buf[(1 + u)]; __m128d pv0M = _mm_set_pd(p0M[w * 1], p0M[w * 0]); __m128d pv1M = _mm_set_pd(p1M[w * 1], p1M[w * 0]); __m128d pv0P = _mm_set_pd(p0P[w * 1], p0P[w * 0]); __m128d pv1P = _mm_set_pd(p1P[w * 1], p1P[w * 0]); __m128d sumA = _mm_add_pd(pv0M, pv0P); __m128d sumB = _mm_add_pd(pv1M, pv1P); sum = _mm_add_pd(sum, sumA); a1 = _mm_add_pd(a1, _mm_mul_pd(_mm_set1_pd(table[K*u + 0]), sumA)); b1 = _mm_add_pd(b1, _mm_mul_pd(_mm_set1_pd(table[K*u + 0]), sumB)); a2 = _mm_add_pd(a2, _mm_mul_pd(_mm_set1_pd(table[K*u + 1]), sumA)); b2 = _mm_add_pd(b2, _mm_mul_pd(_mm_set1_pd(table[K*u + 1]), sumB)); } //sliding convolution double *pA, *pB; __m128d pvA, pvB; __m128d dvA, dvB, delta; __m128d qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvA = _mm_sub_pd(pvB, pvA); sum = _mm_add_pd(sum, dvA); //b1=_mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1),delta),_mm_mul_pd(_mm_set1_pd(cf11),a1)),b1); //b2=_mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2),delta),_mm_mul_pd(_mm_set1_pd(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvB = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvB, dvA); sum = _mm_add_pd(sum, dvB); a1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), b1)), a1); a2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE2_PD(qv[0], qv[1]); _mm_storeu_pd(&dst[w*(y + 0)], qv[0]); _mm_storeu_pd(&dst[w*(y + 1)], qv[1]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvA = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvA, dvB); sum = _mm_add_pd(sum, dvA); b1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), a1)), b1); b2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvB = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvB, dvA); sum = _mm_add_pd(sum, dvB); a1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), b1)), a1); a2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE2_PD(qv[0], qv[1]); _mm_storeu_pd(&dst[w*(y + 0) + x], qv[0]); _mm_storeu_pd(&dst[w*(y + 1) + x], qv[1]); } } } template<> inline void gauss::filter_sse_v<double>(int w, int h, double* src, double* dst) { assert(w % sizeof(__m128d) == 0); const int B = sizeof(__m128d) / sizeof(double); const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning double* workspace = reinterpret_cast<double*>(_mm_malloc(sizeof(double)*(2 * K + 1)*w, sizeof(__m128d))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m128d p0 = _mm_load_pd(&src[x]); __m128d p1 = _mm_load_pd(&src[x + w]); _mm_store_pd(&ws[B * 0], p0); _mm_store_pd(&ws[B * 1], _mm_mul_pd(p1, _mm_set1_pd(table[0]))); _mm_store_pd(&ws[B * 2], _mm_mul_pd(p0, _mm_set1_pd(table[0]))); _mm_store_pd(&ws[B * 3], _mm_mul_pd(p1, _mm_set1_pd(table[1]))); _mm_store_pd(&ws[B * 4], _mm_mul_pd(p0, _mm_set1_pd(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m128d sum0 = _mm_add_pd(_mm_load_pd(&src[x + w*atN(0 - v)]), _mm_load_pd(&src[x + w*(0 + v)])); __m128d sum1 = _mm_add_pd(_mm_load_pd(&src[x + w*atN(1 - v)]), _mm_load_pd(&src[x + w*(1 + v)])); _mm_store_pd(&ws[B * 0], _mm_add_pd(_mm_load_pd(&ws[B * 0]), sum0)); _mm_store_pd(&ws[B * 1], _mm_add_pd(_mm_load_pd(&ws[B * 1]), _mm_mul_pd(sum1, _mm_set1_pd(table[K*v + 0])))); _mm_store_pd(&ws[B * 2], _mm_add_pd(_mm_load_pd(&ws[B * 2]), _mm_mul_pd(sum0, _mm_set1_pd(table[K*v + 0])))); _mm_store_pd(&ws[B * 3], _mm_add_pd(_mm_load_pd(&ws[B * 3]), _mm_mul_pd(sum1, _mm_set1_pd(table[K*v + 1])))); _mm_store_pd(&ws[B * 4], _mm_add_pd(_mm_load_pd(&ws[B * 4]), _mm_mul_pd(sum0, _mm_set1_pd(table[K*v + 1])))); } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { double* q = &dst[w*y]; const double* p1N = &src[w*atN(y - r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m128d a0 = _mm_load_pd(&ws[B * 0]); const __m128d a2 = _mm_load_pd(&ws[B * 2]); const __m128d a4 = _mm_load_pd(&ws[B * 4]); _mm_store_pd(&q[x], _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(a0, _mm_add_pd(a2, a4)))); const __m128d d = _mm_sub_pd(_mm_load_pd(&p1S[x]), _mm_load_pd(&p1N[x])); _mm_store_pd(&ws[B * 0], _mm_add_pd(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { double* q = &dst[w*y]; const double* p0N = &src[w*atN(y - r - 1)]; const double* p1N = &src[w*atN(y - r)]; const double* p0S = &src[w*atS(y + r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m128d a0 = _mm_load_pd(&ws[B * 0]); const __m128d a1 = _mm_load_pd(&ws[B * 1]); const __m128d a3 = _mm_load_pd(&ws[B * 3]); _mm_store_pd(&q[x], _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(a0, _mm_add_pd(a1, a3)))); const __m128d d0 = _mm_sub_pd(_mm_load_pd(&p0S[x]), _mm_load_pd(&p0N[x])); const __m128d d1 = _mm_sub_pd(_mm_load_pd(&p1S[x]), _mm_load_pd(&p1N[x])); const __m128d delta = _mm_sub_pd(d1, d0); _mm_store_pd(&ws[B * 0], _mm_add_pd(a0, d1)); _mm_store_pd(&ws[B * 1], _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), a1)), _mm_load_pd(&ws[B * 2]))); _mm_store_pd(&ws[B * 2], a1); _mm_store_pd(&ws[B * 3], _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), a3)), _mm_load_pd(&ws[B * 4]))); _mm_store_pd(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_h<double>(int w, int h, double* src, double* dst) { const int B = sizeof(__m256d) / sizeof(double); const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<double> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256d pv0 = _mm256_set_pd(buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256d pv1 = _mm256_set_pd(buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256d sum = pv0; __m256d a1 = _mm256_mul_pd(_mm256_set1_pd(table[0]), pv0); __m256d b1 = _mm256_mul_pd(_mm256_set1_pd(table[0]), pv1); __m256d a2 = _mm256_mul_pd(_mm256_set1_pd(table[1]), pv0); __m256d b2 = _mm256_mul_pd(_mm256_set1_pd(table[1]), pv1); for (int u = 1; u <= r; ++u) { const double* p0M = &buf[atW(0 - u)]; const double* p1M = &buf[atW(1 - u)]; const double* p0P = &buf[(0 + u)]; const double* p1P = &buf[(1 + u)]; __m256d pv0M = _mm256_set_pd(p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256d pv1M = _mm256_set_pd(p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256d pv0P = _mm256_set_pd(p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256d pv1P = _mm256_set_pd(p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256d sumA = _mm256_add_pd(pv0M, pv0P); __m256d sumB = _mm256_add_pd(pv1M, pv1P); sum = _mm256_add_pd(sum, sumA); a1 = _mm256_add_pd(a1, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 0]), sumA)); b1 = _mm256_add_pd(b1, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 0]), sumB)); a2 = _mm256_add_pd(a2, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 1]), sumA)); b2 = _mm256_add_pd(b2, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 1]), sumB)); } //sliding convolution double *pA, *pB; __m256d pvA, pvB; __m256d dvA, dvB, delta; __m256d qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); sum = _mm256_add_pd(sum, dvA); //b1=_mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1),delta),_mm256_mul_pd(_mm256_set1_pd(cf11),a1)),b1); //b2=_mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2),delta),_mm256_mul_pd(_mm256_set1_pd(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE4_PD(qv[0], qv[1], qv[2], qv[3]); _mm256_storeu_pd(&dst[w*(y + 0)], qv[0]); _mm256_storeu_pd(&dst[w*(y + 1)], qv[1]); _mm256_storeu_pd(&dst[w*(y + 2)], qv[2]); _mm256_storeu_pd(&dst[w*(y + 3)], qv[3]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE4_PD(qv[0], qv[1], qv[2], qv[3]); _mm256_storeu_pd(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_pd(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_pd(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_pd(&dst[w*(y + 3) + x], qv[3]); } } } template<> inline void gauss::filter_avx_v<double>(int w, int h, double* src, double* dst) { assert(w % sizeof(__m256d) == 0); const int B = sizeof(__m256d) / sizeof(double); const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning double* workspace = reinterpret_cast<double*>(_mm_malloc(sizeof(double)*(2 * K + 1)*w, sizeof(__m256d))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m256d p0 = _mm256_load_pd(&src[x]); __m256d p1 = _mm256_load_pd(&src[x + w]); _mm256_store_pd(&ws[B * 0], p0); _mm256_store_pd(&ws[B * 1], _mm256_mul_pd(p1, _mm256_set1_pd(table[0]))); _mm256_store_pd(&ws[B * 2], _mm256_mul_pd(p0, _mm256_set1_pd(table[0]))); _mm256_store_pd(&ws[B * 3], _mm256_mul_pd(p1, _mm256_set1_pd(table[1]))); _mm256_store_pd(&ws[B * 4], _mm256_mul_pd(p0, _mm256_set1_pd(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m256d sum0 = _mm256_add_pd(_mm256_load_pd(&src[x + w*atN(0 - v)]), _mm256_load_pd(&src[x + w*(0 + v)])); __m256d sum1 = _mm256_add_pd(_mm256_load_pd(&src[x + w*atN(1 - v)]), _mm256_load_pd(&src[x + w*(1 + v)])); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(_mm256_load_pd(&ws[B * 0]), sum0)); _mm256_store_pd(&ws[B * 1], _mm256_add_pd(_mm256_load_pd(&ws[B * 1]), _mm256_mul_pd(sum1, _mm256_set1_pd(table[K*v + 0])))); _mm256_store_pd(&ws[B * 2], _mm256_add_pd(_mm256_load_pd(&ws[B * 2]), _mm256_mul_pd(sum0, _mm256_set1_pd(table[K*v + 0])))); _mm256_store_pd(&ws[B * 3], _mm256_add_pd(_mm256_load_pd(&ws[B * 3]), _mm256_mul_pd(sum1, _mm256_set1_pd(table[K*v + 1])))); _mm256_store_pd(&ws[B * 4], _mm256_add_pd(_mm256_load_pd(&ws[B * 4]), _mm256_mul_pd(sum0, _mm256_set1_pd(table[K*v + 1])))); } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { double* q = &dst[w*y]; const double* p1N = &src[w*atN(y - r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m256d a0 = _mm256_load_pd(&ws[B * 0]); const __m256d a2 = _mm256_load_pd(&ws[B * 2]); const __m256d a4 = _mm256_load_pd(&ws[B * 4]); _mm256_store_pd(&q[x], _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(a0, _mm256_add_pd(a2, a4)))); const __m256d d = _mm256_sub_pd(_mm256_load_pd(&p1S[x]), _mm256_load_pd(&p1N[x])); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { double* q = &dst[w*y]; const double* p0N = &src[w*atN(y - r - 1)]; const double* p1N = &src[w*atN(y - r)]; const double* p0S = &src[w*atS(y + r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m256d a0 = _mm256_load_pd(&ws[B * 0]); const __m256d a1 = _mm256_load_pd(&ws[B * 1]); const __m256d a3 = _mm256_load_pd(&ws[B * 3]); _mm256_store_pd(&q[x], _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(a0, _mm256_add_pd(a1, a3)))); const __m256d d0 = _mm256_sub_pd(_mm256_load_pd(&p0S[x]), _mm256_load_pd(&p0N[x])); const __m256d d1 = _mm256_sub_pd(_mm256_load_pd(&p1S[x]), _mm256_load_pd(&p1N[x])); const __m256d delta = _mm256_sub_pd(d1, d0); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(a0, d1)); _mm256_store_pd(&ws[B * 1], _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), _mm256_load_pd(&ws[B * 2]))); _mm256_store_pd(&ws[B * 2], a1); _mm256_store_pd(&ws[B * 3], _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a3)), _mm256_load_pd(&ws[B * 4]))); _mm256_store_pd(&ws[B * 4], a3); } } _mm_free(workspace); } } void GaussianBlurSR_cliped_32F(InputArray src_, OutputArray dest, float sigma) { Mat src = src_.getMat(); if (dest.empty())dest.create(src_.size(), src.type()); Mat dst = dest.getMat(); if (src.channels() == 1) { spectral_recursive_filter::gauss srf_gauss(sigma, sigma); if (src.data != dst.data) { srf_gauss.filter(src, dst); } else { Mat a(src.size(), src.type()); srf_gauss.filter(src, a); a.copyTo(dst); } } else if (src.channels() == 3) { vector<Mat> plane; split(src, plane); Mat temp(src.size(), CV_32F); spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(plane[0], temp); temp.copyTo(plane[0]); srf_gauss.filter(plane[1], temp); temp.copyTo(plane[1]); srf_gauss.filter(plane[2], temp); temp.copyTo(plane[2]); merge(plane, dest); } } void GaussianBlurSR_cliped_64F(InputArray src_, OutputArray dest, double sigma) { Mat src = src_.getMat(); Mat srcf2(src.size(), CV_64FC(src.channels())); if (src.channels() == 1) { spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(src, srcf2); } else if (src.channels() == 3) { vector<Mat> plane; split(src, plane); Mat temp(src.size(), CV_64F); spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(plane[0], temp); temp.copyTo(plane[0]); srf_gauss.filter(plane[1], temp); temp.copyTo(plane[1]); srf_gauss.filter(plane[2], temp); temp.copyTo(plane[2]); merge(plane, srcf2); } if (dest.empty()) srcf2.copyTo(dest); else if (dest.depth() != CV_64F) srcf2.convertTo(dest, CV_64F); else srcf2.copyTo(dest); } void GaussianBlurSR(InputArray src, OutputArray dest, const double sigma) { int SIMDSTEP = 4; if (src.depth() == CV_64F) SIMDSTEP = 2; int xpad = src.size().width%SIMDSTEP; int ypad = src.size().height%SIMDSTEP; xpad = (SIMDSTEP - xpad) % SIMDSTEP; ypad = (SIMDSTEP - ypad) % SIMDSTEP; if (xpad == 0 && ypad == 0) { if (src.depth() == CV_64F) { GaussianBlurSR_cliped_64F(src, dest, sigma); } else if (src.depth() == CV_32F) { GaussianBlurSR_cliped_32F(src, dest, (float)sigma); } else { Mat srcf, destf; src.getMat().convertTo(srcf, CV_32F); GaussianBlurSR_cliped_32F(srcf, destf, (float)sigma); destf.convertTo(dest, src.depth(), 1.0, 0.5); } } else { Mat s, d; copyMakeBorder(src, s, 0, ypad, 0, xpad, BORDER_REFLECT); if (src.depth() == CV_64F) { GaussianBlurSR_cliped_64F(s, d, sigma); } else if (src.depth() == CV_32F) { GaussianBlurSR_cliped_32F(s, d, (float)sigma); } else { Mat srcf, destf; s.convertTo(srcf, CV_32F); GaussianBlurSR_cliped_32F(srcf, destf, (float)sigma); destf.convertTo(d, src.depth(), 1.0, 0.5); } Mat(d(Rect(Point(0, 0), src.size()))).copyTo(dest); } }
43.750223
376
0.592692
norishigefukushima
5ea471441838daab58612181478ed8f625535a19
234
cpp
C++
torch/csrc/cuda/serialization.cpp
DavidKo3/mctorch
53ffe61763059677978b4592c8b2153b0c15428f
[ "BSD-3-Clause" ]
1
2019-07-21T02:13:22.000Z
2019-07-21T02:13:22.000Z
torch/csrc/cuda/serialization.cpp
DavidKo3/mctorch
53ffe61763059677978b4592c8b2153b0c15428f
[ "BSD-3-Clause" ]
null
null
null
torch/csrc/cuda/serialization.cpp
DavidKo3/mctorch
53ffe61763059677978b4592c8b2153b0c15428f
[ "BSD-3-Clause" ]
null
null
null
#include "torch/csrc/python_headers.h" #include "THCP.h" #include "override_macros.h" #include <system_error> #include <memory> #define THC_GENERIC_FILE "torch/csrc/generic/serialization.cpp" #include <THC/THCGenerateAllTypes.h>
18
63
0.777778
DavidKo3
5ea5c38a54bbddb0af567a118f6fd080996075ed
2,678
hpp
C++
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
null
null
null
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
1
2018-06-09T04:40:01.000Z
2018-06-09T04:40:01.000Z
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
null
null
null
# /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2003. # * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) # * * # ************************************************************************** */ # # /* See http://www.boost.org for most recent version. */ # # ifndef SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP # define SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP # #include <tnt/deps/simd/detail/preprocessor/config/config.hpp> # # if SIMDPP_PP_VARIADICS # #include <tnt/deps/simd/detail/preprocessor/facilities/is_empty_variadic.hpp> # # else # # if ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() && ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MWCC() #include <tnt/deps/simd/detail/preprocessor/tuple/elem.hpp> #include <tnt/deps/simd/detail/preprocessor/facilities/identity.hpp> # else #include <tnt/deps/simd/detail/preprocessor/cat.hpp> #include <tnt/deps/simd/detail/preprocessor/detail/split.hpp> # endif # # /* SIMDPP_PP_IS_EMPTY */ # # if ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() && ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MWCC() # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I(x SIMDPP_PP_IS_EMPTY_HELPER) # define SIMDPP_PP_IS_EMPTY_I(contents) SIMDPP_PP_TUPLE_ELEM(2, 1, (SIMDPP_PP_IS_EMPTY_DEF_ ## contents())) # define SIMDPP_PP_IS_EMPTY_DEF_SIMDPP_PP_IS_EMPTY_HELPER 1, SIMDPP_PP_IDENTITY(1) # define SIMDPP_PP_IS_EMPTY_HELPER() , 0 # else # if SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I(SIMDPP_PP_IS_EMPTY_HELPER x ()) # define SIMDPP_PP_IS_EMPTY_I(test) SIMDPP_PP_IS_EMPTY_II(SIMDPP_PP_SPLIT(0, SIMDPP_PP_CAT(SIMDPP_PP_IS_EMPTY_DEF_, test))) # define SIMDPP_PP_IS_EMPTY_II(id) id # else # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I((SIMDPP_PP_IS_EMPTY_HELPER x ())) # define SIMDPP_PP_IS_EMPTY_I(par) SIMDPP_PP_IS_EMPTY_II ## par # define SIMDPP_PP_IS_EMPTY_II(test) SIMDPP_PP_SPLIT(0, SIMDPP_PP_CAT(SIMDPP_PP_IS_EMPTY_DEF_, test)) # endif # define SIMDPP_PP_IS_EMPTY_HELPER() 1 # define SIMDPP_PP_IS_EMPTY_DEF_1 1, SIMDPP_PP_NIL # define SIMDPP_PP_IS_EMPTY_DEF_SIMDPP_PP_IS_EMPTY_HELPER 0, SIMDPP_PP_NIL # endif # # endif /* SIMDPP_PP_VARIADICS */ # # endif /* SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP */
46.982456
130
0.676998
JordanCheney
5eaaa8feb9f470edc8ae8aa3a1ae75043b27c7a6
2,996
cpp
C++
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
#include "j1EntityManager.h" #include "j1App.h" #include "p2Defs.h" #include "p2Log.h" #include "j1Player.h" #include "j1GroundedEnemy.h" #include "j1FlyingEnemy.h" j1EntityManager::j1EntityManager() : j1Module() { name = "entities"; } j1EntityManager::~j1EntityManager() { } bool j1EntityManager::Awake(pugi::xml_node& module_node) { this->module_node = module_node; bool ret = true; return ret; } bool j1EntityManager::Start() { bool ret = true; return ret; } bool j1EntityManager::PreUpdate() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->PreUpdate(); item = item->next; } return ret; } bool j1EntityManager::Update(float dt) { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && item->data != NULL && ret == true) { ret = item->data->Update(dt); item = item->next; } item = entities.start; while (item != NULL && ret == true) { ret = item->data->Draw(dt); item = item->next; } return ret; } bool j1EntityManager::PostUpdate() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->PostUpdate(); item = item->next; } return ret; } bool j1EntityManager::CleanUp() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL) { ret = item->data->CleanUp(); RELEASE(item->data); item = item->next; } entities.clear(); return ret; } void j1EntityManager::ResetEntities() { p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL) { item->data->Reset(); item = item->next; } } bool j1EntityManager::Load(pugi::xml_node& module_node) { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->Load(module_node); item = item->next; } return ret; } bool j1EntityManager::Save(pugi::xml_node& module_node) const { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->Save(module_node); item = item->next; } return ret; } j1Entity * j1EntityManager::CreateEntity(Type type) { j1Entity* ret = nullptr; switch (type) { case PLAYER: ret = new j1Player(); break; case GROUNDED_ENEMY: ret = new j1GroundedEnemy(); break; case FLYING_ENEMY: ret = new j1FlyingEnemy(); break; } ret->type = type; ret->Awake(module_node.child(ret->TypeToString().GetString())); ret->Start(); if (ret != nullptr) entities.add(ret); return ret; } bool j1EntityManager::DestroyEntity(j1Entity * entity) { bool ret = false; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == false) { if(item->data == entity) { ret = item->data->CleanUp(); RELEASE(item->data); entities.del(item); return ret; } item = item->next; } return ret; }
15.604167
64
0.648198
AlexisCosano
5eaee45bf8f9a844bccaf9f28099a4db7aa6b6fe
250
hpp
C++
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
#pragma once #if defined __MINGW32__ && !(defined _GLIBCXX_HAS_GTHREADS) #include <mingw.thread.h> #include <mingw.mutex.h> #include <mingw.condition_variable.h> #else #include <thread> #include <mutex> #include <condition_variable> #endif
22.727273
60
0.74
Helios-vmg
5eb7e84f957c3891ba0d0b57500ab7dc3b2431d7
10,096
cpp
C++
external/the-forge/Middleware_3/UI/imgui_user.cpp
learn-computer-graphics/the-forge-samples
36ee5310bf76271bf41186475c433cf050ab32af
[ "Apache-2.0" ]
18
2020-05-05T18:11:59.000Z
2021-12-16T07:07:46.000Z
external/the-forge/Middleware_3/UI/imgui_user.cpp
boberfly/the-forge-glfw
c3b4642f83bec165af481e8a7d6916330d4bd07b
[ "Apache-2.0" ]
null
null
null
external/the-forge/Middleware_3/UI/imgui_user.cpp
boberfly/the-forge-glfw
c3b4642f83bec165af481e8a7d6916330d4bd07b
[ "Apache-2.0" ]
6
2020-05-23T21:42:12.000Z
2021-08-09T13:44:02.000Z
/* * Copyright (c) 2018-2021 The Forge Interactive Inc. * * This file is part of The-Forge * (see https://github.com/ConfettiFX/The-Forge). * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include "imgui_user.h" #include "../../Common_3/ThirdParty/OpenSource/imgui/imgui_internal.h" #ifndef M_PI #define M_PI 3.14159f #endif namespace ImGui { int KnobFloat( const char* label, float* value_p, const float& step, const float& minv, const float& maxv, const char* format, const float& minimumHitRadius, bool doubleTapForText, bool spawnText) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return 0; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); float size = CalcItemWidth(); float2 extraPadding = style.ItemSpacing + style.ItemInnerSpacing; //extraPadding.y = 0.f; float line_height = ImGui::GetTextLineHeight(); //extraPadding *= 2.f; float2 label_size = CalcTextSize(label, NULL, true); label_size.y = fmaxf(label_size.y, 0.f) + line_height; ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + float2(size, size + label_size.y / 2.f) + extraPadding); float knobRadius = size * 0.5f; float2 startPos = window->DC.CursorPos; float2 center = total_bb.GetCenter(); const ImRect inner_bb(center - float2(knobRadius, knobRadius), center + float2(knobRadius, knobRadius)); //bool hovered, held; //Create Invisible button and check if its active/hovered float2 mousePos = ImGui::GetIO().MousePos; // Tabbing or CTRL-clicking on Drag turns it into an input box bool start_text_input = false; bool hovered = ItemHoverable(inner_bb, id); const bool tab_focus_requested = FocusableItemRegister(window, id); if (doubleTapForText && (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])) || g.NavActivateId == id || (g.NavInputId == id && g.ScalarAsInputTextId != id))) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0] || g.NavInputId == id) { start_text_input = true; g.ScalarAsInputTextId = 0; } } bool using_text_input = false; if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id)) { if (spawnText) { int retValue = (int)InputScalarAsWidgetReplacement(inner_bb, id, label, ImGuiDataType_Float, value_p, format); ImDrawList* draw_list = ImGui::GetWindowDrawList(); // Bottom Label (X, Y, Z, W) Goes Below Knob label_size = CalcTextSize(label, NULL, true); uint32_t col32text = ImGui::GetColorU32(ImGuiCol_Text); float2 textpos = center + float2(-label_size.x / 2.f, inner_bb.GetHeight() / 2.f + label_size.y / 2.f); draw_list->AddText(textpos, col32text, label); // if max and min are not equal only then we apply the limits // to the final value if (!(fabs(maxv - minv) <= ((fabs(maxv) < fabs(minv) ? fabs(minv) : fabs(maxv)) * 0.01f))) { value_p[0] = fmaxf(minv, fminf(value_p[0], maxv)); } return retValue; } else //Return value to indicate if text was requested using_text_input = true; } //Create Invisible button and check if its active/hovered ImGui::InvisibleButton(label, total_bb.GetSize()); bool isActive = ImGui::IsItemActive(); bool updatedKnob = false; float currentAngle = 0.f; // Mouse delta movement since last frame float2 mouseDelta = ImGui::GetIO().MouseDelta; // Previous Mouse position float2 mousePrevPos = mousePos - mouseDelta; // Vector from center of knob to previous mouse position float2 mousePrevToKnob = mousePrevPos - center; // Get the length float lengthPrev = sqrtf(mousePrevToKnob.x * mousePrevToKnob.x + mousePrevToKnob.y * mousePrevToKnob.y); // Get Vector from center of knob to current mouse position float2 mouseToKnob = mousePos - center; // Get the length float lengthCurr = sqrtf(mouseToKnob.x * mouseToKnob.x + mouseToKnob.y * mouseToKnob.y); if (lengthCurr > knobRadius && g.ActiveId != id) isActive = false; const float hitRadius = minimumHitRadius * knobRadius; if (isActive && g.ActiveIdPreviousFrame == id) { // sanity check in case user clicks on center of knob. // wait for 3 frames before activating the knob const float delay = ((1.f / g.IO.Framerate) * 3.f); if (lengthPrev > 0.001f && lengthCurr > hitRadius && g.ActiveIdTimer > delay) { //Normalize our vectors mousePrevToKnob /= lengthPrev; mouseToKnob /= lengthCurr; // Function returns true if we have modified a value, not just activated it. updatedKnob = true; // dot product between[x1, y1] and [x2, y2] float dot = mouseToKnob.x * mousePrevToKnob.x + mouseToKnob.y * mousePrevToKnob.y; // determinant float det = mouseToKnob.x * mousePrevToKnob.y - mouseToKnob.y * mousePrevToKnob.x; // Get the new angle to add. Needs to be in degrees float deltaAngle = atan2f(det, dot) * 180.f / M_PI; // Increment current value value_p[0] += deltaAngle * step / fmaxf(1.f, lengthCurr / knobRadius); // if max and min are not equal only then we apply the limits // to the final value if (!(fabs(maxv - minv) <= ((fabs(maxv) < fabs(minv) ? fabs(minv) : fabs(maxv)) * 0.01f))) { value_p[0] = fmaxf(minv, fminf(value_p[0], maxv)); } float lineAngle = atan2f(mouseToKnob.y, mouseToKnob.x) - M_PI / 2.0f; // TODO: Add magnitude to increase step. (Multiples of initial length) currentAngle = lineAngle; } } // Display current value (Final value after knob increments) char textval[32]; ImFormatString(textval, IM_ARRAYSIZE(textval), format, value_p[0]); uint32_t col32 = ImGui::GetColorU32(isActive ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); uint32_t col32line = ImGui::GetColorU32(ImGuiCol_SliderGrabActive); ImDrawList* draw_list = ImGui::GetWindowDrawList(); // Enable to draw debug rectangles to view the frames being used // [DEBUGGING] //draw_list->AddRect(total_bb.Min, total_bb.Max, ImColor(0.0f, 1.0f, 0.0f, 1.0f)); //draw_list->AddRect(inner_bb.Min, inner_bb.Max, ImColor(0.0f, 0.0f, 1.0f, 1.0f)); // Draw knob as Filled circle // We could add textures to it in the future. draw_list->AddCircleFilled(center, knobRadius, col32, 32); // Cover the part that can't be dragged // i.e: Create hole in center if (hitRadius > 0.f) draw_list->AddCircleFilled(center, hitRadius, ImGui::GetColorU32(ImGuiCol_WindowBg), 32); // Add line from center of knob to edge of circle along mouse direction float x2 = -sinf(currentAngle) * knobRadius + center.x; float y2 = cosf(currentAngle) * knobRadius + center.y; draw_list->AddLine(center, float2(x2, y2), col32line, 1); // Current Value of Widget (Above Knob) label_size = CalcTextSize(textval, NULL, true); float2 textpos = center - float2(label_size.x / 2.f, total_bb.GetHeight() / 2.f); RenderText(textpos, textval); // Bottom Label (X, Y, Z, W) Goes Below Knob label_size = CalcTextSize(label, NULL, true); textpos = center + float2(-label_size.x / 2.f, inner_bb.GetHeight() / 2.f); RenderText(textpos, label); if (using_text_input) return 2; return (int)updatedKnob; } int KnobFloatN( const char* label, float* value_p, const int& components, const float& step, const float& minv, const float& maxv, const char* format, const float& minimumHitRadius, float windowWidthRatio, bool doubleTapForText, bool spawnText, float framePaddingScale) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; int value_changed = 0; // Print label of widget TextUnformatted(label, FindRenderedTextEnd(label)); // Start group. if app calls IsItemActive, then this enables all the elements created to affect the state of widget. BeginGroup(); // Looks better with some padding before titles such as "Translation, Rotation, Scale" PushID(label); //Controls how much padding for start of knobs framePaddingScale = fmaxf(framePaddingScale, 1.0f); float extraFramePadding = GetStyle().FramePadding.x * framePaddingScale; float itemSpacing = GetStyle().ItemSpacing.x * 3; // Scale the content based on how much of the width we would like to fill float contentWidth = window->Size.x - GetStyle().FrameBorderSize - GetStyle().ScrollbarSize - itemSpacing - extraFramePadding; // Compute final size multipler > 0 to avoid undefined behavior windowWidthRatio = fmaxf(windowWidthRatio, 0.05f); PushMultiItemsWidths(components, contentWidth * windowWidthRatio); size_t type_size = sizeof(float); SetCursorPosX(extraFramePadding); // 4 Component names, this could probably be given as an extra paramater with some helper functions for defaults. const char* componentNames[4]{ "x", "y", "z", "w" }; for (int i = 0; i < components; i++) { PushID(i); int currValue = KnobFloat(componentNames[i % 4], value_p, step, minv, maxv, format, minimumHitRadius, doubleTapForText, spawnText); if (value_changed == 0) value_changed = currValue > 1 ? currValue + i : currValue; SameLine(0, itemSpacing); PopID(); PopItemWidth(); // update user provided float value value_p = (float*)((char*)value_p + type_size); } PopID(); EndGroup(); return value_changed; } } // namespace ImGui
37.117647
135
0.716918
learn-computer-graphics
5eb8ccc8ab15da553c58a923713aaf6571c993a1
537
cpp
C++
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
#include<iostream> #include<fstream> using namespace std; int n,a[50][50]; void citire() { int x,y; ifstream f("in.txt"); f>>n; while(f>>x>>y) a[x][y]=a[y][x]=1; } void afisare() { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) cout<<a[i][j]<<" "; cout<<endl; } cout<<endl; } void Roy_Warshall() { int i,j,k; for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) if(i!=j && a[i][j]==0 && a[i][k] && a[k][j]) a[i][j]=1; } int main() { citire(); afisare(); Roy_Warshall(); afisare(); return 0; }
11.933333
48
0.495345
seerj30
5ebceeee70a2cddf47ca71d83545a8048d9b7251
3,364
cc
C++
drivers/gpu/msd-intel-gen/tests/unit_tests/test_connection.cc
PowerOlive/garnet
16b5b38b765195699f41ccb6684cc58dd3512793
[ "BSD-3-Clause" ]
null
null
null
drivers/gpu/msd-intel-gen/tests/unit_tests/test_connection.cc
PowerOlive/garnet
16b5b38b765195699f41ccb6684cc58dd3512793
[ "BSD-3-Clause" ]
null
null
null
drivers/gpu/msd-intel-gen/tests/unit_tests/test_connection.cc
PowerOlive/garnet
16b5b38b765195699f41ccb6684cc58dd3512793
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "mock/mock_bus_mapper.h" #include "msd_intel_connection.h" #include "gtest/gtest.h" class TestMsdIntelConnection : public MsdIntelConnection::Owner { public: magma::Status SubmitCommandBuffer(std::unique_ptr<CommandBuffer> cmd_buf) override { return MAGMA_STATUS_UNIMPLEMENTED; } void DestroyContext(std::shared_ptr<ClientContext> client_context) override {} void ReleaseBuffer(std::shared_ptr<AddressSpace> address_space, std::shared_ptr<MsdIntelBuffer> buffer) override { } magma::PlatformBusMapper* GetBusMapper() override { return &mock_bus_mapper_; } void Notification() { auto connection = MsdIntelConnection::Create(this, 0); ASSERT_NE(connection, nullptr); connection->SetNotificationCallback(CallbackStatic, this); connection->SendNotification(test_buffer_ids_); } static void CallbackStatic(void* token, msd_notification_t* notification) { reinterpret_cast<TestMsdIntelConnection*>(token)->Callback(notification); } void Callback(msd_notification_t* notification) { EXPECT_EQ(MSD_CONNECTION_NOTIFICATION_CHANNEL_SEND, notification->type); switch (callback_count_++) { case 0: EXPECT_EQ(64u, notification->u.channel_send.size); EXPECT_EQ(test_buffer_ids_[0], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[0]); EXPECT_EQ(test_buffer_ids_[1], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[1]); EXPECT_EQ(test_buffer_ids_[2], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[2]); EXPECT_EQ(test_buffer_ids_[3], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[3]); EXPECT_EQ(test_buffer_ids_[4], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[4]); EXPECT_EQ(test_buffer_ids_[5], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[5]); EXPECT_EQ(test_buffer_ids_[6], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[6]); EXPECT_EQ(test_buffer_ids_[7], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[7]); break; case 1: EXPECT_EQ(16u, notification->u.channel_send.size); EXPECT_EQ(test_buffer_ids_[8], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[0]); EXPECT_EQ(test_buffer_ids_[9], reinterpret_cast<uint64_t*>(notification->u.channel_send.data)[1]); break; default: EXPECT_TRUE(false); } } private: MockBusMapper mock_bus_mapper_; std::vector<uint64_t> test_buffer_ids_{10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; uint32_t callback_count_ = 0; }; TEST(MsdIntelConnection, Notification) { TestMsdIntelConnection().Notification(); }
42.582278
93
0.631986
PowerOlive
5ebd77712f82833e915e3a6e1ee56d50318f20f9
2,188
cpp
C++
OIandACM/OJ/Nowcoder/5670F.cpp
ASC8384/-
8d8fb4c1d4c10aca1e10a0faf5ab2b687fd936d2
[ "CC0-1.0" ]
8
2019-08-09T14:28:13.000Z
2021-02-23T03:22:15.000Z
OIandACM/OJ/Nowcoder/5670F.cpp
ASC8384/Template
8d8fb4c1d4c10aca1e10a0faf5ab2b687fd936d2
[ "CC0-1.0" ]
null
null
null
OIandACM/OJ/Nowcoder/5670F.cpp
ASC8384/Template
8d8fb4c1d4c10aca1e10a0faf5ab2b687fd936d2
[ "CC0-1.0" ]
4
2019-08-16T12:00:41.000Z
2019-11-29T12:01:17.000Z
/* ** Author: ASC_8384 ** Website: www.ASC8384.top ** License: CC0 ** Time: 2020-07-25 12:08:43 */ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int size = 2e5 + 9; const ll mod = 1e9 + 7; int a[size]; int maxx = 0; void prt1(int x) { cout << '+'; // string s(x, '-'); // string s = ""; for(int i = 1; i <= x; i++) cout << "-"; // cout << s; cout << '+' << '\n'; } void prt2(int x) { cout << '|'; // string s(x, ' '); // string s = ""; for(int i = 1; i <= x; i++) cout << " "; // cout << s; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; maxx = max(maxx, a[i]); } if(maxx % 50 == 0) for(int i = 1; i <= n; i++) { prt1(a[i] * 50 / maxx); if(maxx == a[i]) { prt2(49); cout << '*' << '|' << a[i] << '\n'; } else { prt2(a[i] * 50 / maxx); cout << '|' << a[i] << '\n'; } prt1(a[i] * 50 / maxx); } else { for(int i = 1; i <= n; i++) { if(maxx % a[i] == 0) { prt1(a[i] * 50 / maxx); if(a[i] == maxx) { prt2(49); cout << '*' << '|' << a[i] << '\n'; } else { prt2(a[i] * 50 / maxx); cout << '|' << a[i] << '\n'; } prt1(a[i] * 50 / maxx); } else { prt1(a[i] * 50 / maxx + 1); prt2(a[i] * 50 / maxx + 1); cout << '|' << a[i] << '\n'; prt1(a[i] * 50 / maxx + 1); } } } return 0; } #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<cmath> using namespace std; long long P[110000],B[110000]; int C[110000]; long long gcd(long long a,long long b) { if(b==0)return a; else return gcd(b,a%b); } int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld",&P[i]); for(int i=1;i<=n;i++) if(!B[i]) { C[0]=1; C[1]=i; while(P[C[C[0]]]!=C[1]) C[++C[0]]=P[C[C[0]-1]]; int k=C[0]; while(C[0]) B[C[C[0]--]]=k; } long long ans=0; for(int i=1;i<=n;i++) if(B[i]!=1) { if(!ans)ans=B[i]; else ans=gcd(B[i],ans); } long long ans1=ans; if(ans==0) { ans=1; ans1=1; } for(int i=1;i<=n;i++) if(B[i]!=1) ans1=(ans1*(B[i]/ans)); cout<<ans1<<endl; }
16.575758
40
0.452011
ASC8384
5ebddd06b54e498a0d17c1fb3c4fecf080b7b8cf
1,266
cpp
C++
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
// TransformChar.cpp file, carrying function in separate file #include<cctype> #include<string> #include<iostream> // Function to transform characters to string std::string transformChar(const char inputChar){ std::string inputStrForm {""}; // Uppercase alphabetic characters if (std::isalpha(inputChar)) { inputStrForm += std::toupper(inputChar); return inputStrForm; } // Transliterate digits to English words switch (inputChar) { case '0': inputStrForm += "ZERO"; break; case '1': inputStrForm += "ONE"; break; case '2': inputStrForm += "TWO"; break; case '3': inputStrForm += "THREE"; break; case '4': inputStrForm += "FOUR"; break; case '5': inputStrForm += "FIVE"; break; case '6': inputStrForm += "SIX"; break; case '7': inputStrForm += "SEVEN"; break; case '8': inputStrForm += "EIGHT"; break; case '9': inputStrForm += "NINE"; break; } // If the character isn't alphabetic or numeric, DONT add it. // Our ciphers can only operate on alphabetic characters. return inputStrForm; }
23.018182
65
0.557662
MPAGS-CPP-2019
5ec09f659eca554b549963522452618e28e639ad
1,315
cc
C++
pw_software_update/manifest_accessor.cc
octml/pigweed
e273d46024ef7b5a7c7ec584e4aaada41c541fc4
[ "Apache-2.0" ]
86
2021-03-09T23:49:40.000Z
2022-03-30T08:14:51.000Z
pw_software_update/manifest_accessor.cc
octml/pigweed
e273d46024ef7b5a7c7ec584e4aaada41c541fc4
[ "Apache-2.0" ]
4
2021-07-27T20:32:03.000Z
2022-03-08T10:39:07.000Z
pw_software_update/manifest_accessor.cc
octml/pigweed
e273d46024ef7b5a7c7ec584e4aaada41c541fc4
[ "Apache-2.0" ]
22
2021-03-11T15:15:47.000Z
2022-02-09T06:16:36.000Z
// Copyright 2021 The Pigweed Authors // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy of // the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations under // the License. #include "pw_software_update/manifest_accessor.h" #include "pw_assert/check.h" #include "pw_software_update/update_bundle_accessor.h" namespace pw::software_update { ManifestAccessor::ManifestAccessor(UpdateBundleAccessor* update_bundle_accessor) : update_bundle_accessor_(update_bundle_accessor) { PW_CHECK_NOTNULL(update_bundle_accessor_); } Status ManifestAccessor::WriteManifest(stream::Writer& writer) { return update_bundle_accessor_->PersistManifest(writer); }; pw::stream::IntervalReader ManifestAccessor::GetUserManifest() { stream::IntervalReader user_manifest = update_bundle_accessor_->GetTargetPayload("user_manifest"); return user_manifest; }; } // namespace pw::software_update
35.540541
80
0.78327
octml
5ecbe055c8193a4eb162ff73366ebda544f09e10
6,010
cpp
C++
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
20
2016-02-15T23:22:06.000Z
2021-12-07T00:13:49.000Z
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
1
2017-09-04T00:28:19.000Z
2017-09-05T11:00:12.000Z
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
3
2016-08-10T02:44:08.000Z
2021-05-28T23:03:10.000Z
//============================================================================ // Name : Mouse3D.cpp // Author : Duarte Peixinho // Version : // Copyright : ;) // Description : Mouse 3D Class //============================================================================ #include <Pyros3D/Utils/Mouse3D/Mouse3D.h> #include <stdio.h> #include <string.h> namespace p3d { Mouse3D::Mouse3D() { } Mouse3D::~Mouse3D() { } const Vec3 &Mouse3D::GetDirection() const { return Direction; } const Vec3 &Mouse3D::GetOrigin() const { return Origin; } bool Mouse3D::GenerateRay(const f32 windowWidth, const f32 windowHeight, const f32 mouseX, const f32 mouseY, const Matrix &Model, const Matrix &View, const Matrix &Projection) { f32 glMouseY = windowHeight - mouseY; int32 viewPort[4]; f32 x1, y1, z1, x2, y2, z2; viewPort[0] = 0; viewPort[1] = 0; viewPort[2] = (int32)windowWidth; viewPort[3] = (int32)windowHeight; Vec3 v1, v2; if (UnProject(mouseX, glMouseY, 0.f, (View*Model), Projection, Vec4((f32)viewPort[0], (f32)viewPort[1], (f32)viewPort[2], (f32)viewPort[3]), &x1, &y1, &z1) == true && UnProject(mouseX, glMouseY, 1.f, (View*Model), Projection, Vec4((f32)viewPort[0], (f32)viewPort[1], (f32)viewPort[2], (f32)viewPort[3]), &x2, &y2, &z2) == true) { v1.x = x1; v1.y = y1; v1.z = z1; v2.x = x2; v2.y = y2; v2.z = z2; v2 = v2 - v1; v2.normalizeSelf(); Origin = v1; Direction = v2; return true; } return false; } bool Mouse3D::rayIntersectionTriangle(const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, Vec3 *IntersectionPoint32, f32 *t) const { Vec3 V1 = v1; Vec3 V2 = v2; Vec3 V3 = v3; Vec3 e1 = V2 - V1, e2 = V3 - V1; Vec3 pvec = Direction.cross(e2); f32 det = e1.dotProduct(pvec); if (det > -EPSILON && det < EPSILON) { return false; } f32 inv_det = 1.0f / det; Vec3 tvec = Origin - V1; f32 u = tvec.dotProduct(pvec) * inv_det; if (u < 0.0f || u > 1.0f) { return false; }; Vec3 qvec = tvec.cross(e1); f32 v = Direction.dotProduct(qvec) * inv_det; if (v < 0.0f || u + v > 1.0f) { return false; }; f32 _t = e2.dotProduct(qvec) * inv_det; if (!isnan((double)_t)) { *t = _t; } else return false; if (IntersectionPoint32) { *IntersectionPoint32 = Origin + (Direction * _t); } else return false; return true; } bool Mouse3D::rayIntersectionPlane(const Vec3 &Normal, const Vec3 &Position, Vec3 *IntersectionPoint32, f32* t) const { Vec3 intersectPoint; Vec3 u = Direction - Origin; Vec3 w = Origin - Position; f32 D = Normal.dotProduct(u); f32 N = -Normal.dotProduct(w); // if (fabs(D) < EPSILON) // segment is parallel to plane // { // if (N == 0) // segment lies in plane // return false; // else // return false; // no intersection // } float s = N / D; // if (s < 0 || s > 1) // return false; // no intersection intersectPoint = Origin + u*s; // compute segment intersect point // IntersectionPoint32->x = intersectPoint.x; // IntersectionPoint32->y = intersectPoint.y; // IntersectionPoint32->z = intersectPoint.z; f32 denom = Normal.dotProduct(Direction); Vec3 p0l0 = Position - Origin; f32 _t = p0l0.dotProduct(Normal) / denom; *IntersectionPoint32 = Origin + (Direction * _t); *t = _t; return true; } bool Mouse3D::rayIntersectionBox(Vec3 min, Vec3 max, f32* t) const { int32 tNear = INT_MIN; int32 tFar = INT_MAX; //check x if ((Direction.x == 0.f) && (Origin.x < min.x) && (Origin.x > max.x)) { //parallel return false; } else { float t1 = (min.x - Origin.x) / Direction.x; float t2 = (max.x - Origin.x) / Direction.x; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0)) return false; } //check y if ((Direction.y == 0) && (Origin.y < min.y) && (Origin.y > max.y)) { //parallel return false; } else { float t1 = (min.y - Origin.y) / Direction.y; float t2 = (max.y - Origin.y) / Direction.y; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0.f)) return false; } //check z if ((Direction.z == 0.f) && (Origin.z < min.z) && (Origin.z > max.z)) { //parallel return false; } else { float t1 = (min.z - Origin.z) / Direction.z; float t2 = (max.x - Origin.z) / Direction.z; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0)) return false; } *t = (f32)tNear; return true; } bool Mouse3D::rayIntersectionSphere(const Vec3 &position, const f32 radius, Vec3 *intersectionPoint32, f32 *t) const { Vec3 m = Origin - position; f32 b = m.dotProduct(Direction); f32 c = m.dotProduct(m) - radius * radius; if (c > 0.0f && b > 0.0f) return false; f32 discr = b*b - c; if (discr < 0.0f) return false; *t = -b - sqrtf(discr); if (*t < 0.0f) *t = 0.0f; *intersectionPoint32 = position + (Direction * *t); return true; } bool Mouse3D::UnProject(const f32 winX, const f32 winY, const f32 winZ, const Matrix &modelview, const Matrix &proj, const Vec4 view, f32 *objx, f32 *objy, f32 *objz) { Matrix finalMatrix; Vec4 in; Vec4 out; finalMatrix = (proj * modelview).Inverse(); in.x = winX; in.y = winY; in.z = winZ; in.w = 1.0; /* Map x and y from window coordinates */ in.x = (in.x - view.x) / view.z; in.y = (in.y - view.y) / view.w; /* Map to range -1 to 1 */ in.x = in.x * 2.f - 1.f; in.y = in.y * 2.f - 1.f; in.z = in.z * 2.f - 1.f; out = finalMatrix * in; if (out.w == 0.0) return false; out.x /= out.w; out.y /= out.w; out.z /= out.w; *objx = out.x; *objy = out.y; *objz = out.z; return true; } }
23.385214
176
0.565391
Peixinho
5ece59e0e23c720c19bb40416ba4176396f58711
1,132
hpp
C++
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
13
2020-05-01T02:03:14.000Z
2022-02-03T17:48:26.000Z
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
5
2021-01-22T11:58:21.000Z
2022-01-21T21:06:17.000Z
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
3
2021-01-22T09:05:50.000Z
2022-01-12T09:16:44.000Z
#pragma once #include "Scene.hpp" #include <Algorithm/Algorithm.hpp> NS_ENIGMA_BEGIN class DecryptFileScene : public Scene { public: /* Constructors / Destructor */ DecryptFileScene(); virtual ~DecryptFileScene() = default; private: /* Overrides */ void OnCreate() override; [[maybe_unused]] void OnUpdate(const f32& dt) override; void OnDraw() override; void OnImGuiDraw() override; void OnEvent(Event& event) override; void OnDestroy() override; private: /* Callbacks */ //void OnBrowseInFileButtonPressed(); //void OnBrowseOutFileButtonPressed(); void OnBrowseInFileButtonPressed(); // browse file to decrypt void OnBrowseOutFileLocationButtonPressed(); // browse decrypted file location void OnDecryptButtonPressed(); void OnBackButtonPressed(); private: Algorithm::Type m_type; // Algorithm type, AES, ChaCha, TripleDES... to help us create polymorphic algorithm String m_in_filename; // In File to decrypt String m_out_filename; // Out File to be recover String m_password; // encryption password //bool m_decompress{ true }; // Whether to deompress file with Gzip after decrypting }; NS_ENIGMA_END
29.025641
109
0.762367
BaderEddineOuaich
5ed04b0d11ff119a4796a4b9ec09f1ae30a6fdab
167
cpp
C++
source/F/ReLu.cpp
webbery/MiniEngine
7ff9793be96fc11d9fe04c1fd22ea5ba5a1d80d8
[ "MIT" ]
3
2019-09-25T14:20:32.000Z
2021-11-20T07:53:57.000Z
source/F/ReLu.cpp
webbery/MiniEngine
7ff9793be96fc11d9fe04c1fd22ea5ba5a1d80d8
[ "MIT" ]
1
2020-05-13T04:17:58.000Z
2020-05-13T07:35:00.000Z
source/F/ReLu.cpp
webbery/MiniEngine
7ff9793be96fc11d9fe04c1fd22ea5ba5a1d80d8
[ "MIT" ]
1
2020-05-19T05:03:01.000Z
2020-05-19T05:03:01.000Z
#include "F/ReLu.h" namespace engine { ReLu::ReLu(Node* node) { } void ReLu::forward(/*const Eigen::MatrixXf& value*/) { } void ReLu::backward() { } }
8.35
53
0.586826
webbery
5ed1e4838d85f4f2d8e30f857ef3fd79eddd4bf8
410
hpp
C++
tests/files/src-stm32/include/Power.hpp
Tasssadar/mkdoxy
8d5f563dc83cd90d3f1db4e171580bf56a391a6b
[ "MIT" ]
null
null
null
tests/files/src-stm32/include/Power.hpp
Tasssadar/mkdoxy
8d5f563dc83cd90d3f1db4e171580bf56a391a6b
[ "MIT" ]
19
2021-08-16T21:48:03.000Z
2021-11-13T18:13:56.000Z
tests/files/src-stm32/include/Power.hpp
JakubAndrysek/mkdocs-doxygen-snippets-plugin
9caadb772083e134dd67e59f7981245223b6ce78
[ "MIT" ]
1
2021-11-16T15:58:25.000Z
2021-11-16T15:58:25.000Z
#pragma once void powerInit(); void powerPoll(); uint16_t powerBatteryMv(); uint16_t powerBatteryMidMv(); uint16_t powerTemperatureC(); uint16_t powerVrefMv(); static constexpr uint16_t POWER_CALIBRATE_DEFAULT = 0; static constexpr uint16_t POWER_CALIBRATE_NO_CHANGE = 0xFFFF; void powerCalibrate(uint16_t vccMv, uint16_t bMidMv, uint16_t vref33Mv, uint16_t currentTemperatureC); void powerShutDown();
24.117647
71
0.812195
Tasssadar
5ed9f572fd6dbefe9abae9ed029762f2e65bf9e9
42,489
cpp
C++
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
277
2017-05-18T08:27:10.000Z
2022-03-26T01:31:37.000Z
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
77
2017-09-03T15:35:02.000Z
2022-03-28T18:47:20.000Z
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
37
2017-03-30T03:36:24.000Z
2022-01-28T08:28:36.000Z
#include <babylon/babylon_stl_util.h> #include <babylon/buffers/vertex_buffer.h> #include <babylon/cameras/arc_rotate_camera.h> #include <babylon/interfaces/icanvas.h> #include <babylon/interfaces/irenderable_scene_with_hud.h> #include <babylon/lights/hemispheric_light.h> #include <babylon/materials/standard_material.h> #include <babylon/materials/textures/texture.h> #include <babylon/maths/vector4.h> #include <babylon/meshes/builders/mesh_builder_options.h> #include <babylon/meshes/mesh.h> #include <babylon/meshes/mesh_builder.h> #include <babylon/samples/babylon_register_sample.h> #include <imgui.h> namespace BABYLON { namespace Samples { /** * @brief Extrude Polygon Scene. Example demonstrating how to use MeshBuilder to generate geometry * from extruded data. * @see https://www.babylonjs-playground.com/#TFLTJJ#0 * @see https://doc.babylonjs.com/api/classes/babylon.meshbuilder#extrudepolygon */ class ExtrudePolygonScene : public IRenderableSceneWithHud { public: ExtrudePolygonScene(ICanvas* iCanvas) : IRenderableSceneWithHud(iCanvas) // Roof , _roof{nullptr} , _ceiling{nullptr} // Front , _frontWall{nullptr} , _windowFBL{nullptr} , _windowFBR{nullptr} , _windowFTL{nullptr} , _windowFTR{nullptr} , _windowFTM{nullptr} , _frontDoor{nullptr} // Back , _rearWallnb1{nullptr} , _rearWallnb2{nullptr} , _windowRBL{nullptr} , _windowRBR{nullptr} , _windowRTL{nullptr} , _windowRTR{nullptr} , _windowR1BL{nullptr} , _windowR1TL{nullptr} , _windowR1TR{nullptr} // Left Side , _sideWallnb1{nullptr} , _sideWallnb3{nullptr} , _backDoor{nullptr} // Right Side , _sideWallnb2{nullptr} { } ~ExtrudePolygonScene() override = default; const char* getName() override { return "Extrude Polygon Scene"; } void initializeScene(ICanvas* canvas, Scene* scene) override { // Camera auto camera = ArcRotateCamera::New("Camera", -Math::PI_2, Math::PI / 3.f, 25.f, Vector3::Zero(), scene); camera->target = Vector3(0, 0.f, 4.5f); camera->attachControl(canvas, true); auto light = HemisphericLight::New("hemiLight", Vector3(10, 10, 0), scene); light->intensity = 0.98f; auto wallmat = StandardMaterial::New("wallmaterial", scene); wallmat->diffuseTexture = Texture::New("textures/wallMaterial.jpg", scene); auto innerwallmat = StandardMaterial::New("innerwallmaterial", scene); innerwallmat->diffuseColor = Color3(240.f / 255.f, 223.f / 255.f, 203.f / 255.f); // Front wall polygon shape in XoZ plane std::vector<Vector3> frontWallData{ Vector3(-5.5f, 0.f, -3.f), // Vector3(-0.5f, 0.f, -3.f), // Vector3(-0.5f, 0.f, -0.75f), // Vector3(0.5f, 0.f, -0.75f), // Vector3(0.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, 3.f), // Vector3(-5.5f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> frontWindowHoles{// frontWindowHoles[0] { Vector3(-4.78f, 0.f, -2.3f), // Vector3(-1.58f, 0.f, -2.3f), // Vector3(-1.58f, 0.f, -0.3f), // Vector3(-4.78f, 0.f, -0.3f) // }, // frontWindowHoles[1] { Vector3(1.58f, 0.f, -2.3f), // Vector3(4.78f, 0.f, -2.3f), // Vector3(4.78f, 0.f, -0.3f), // Vector3(1.58f, 0.f, -0.3f) // }, // frontWindowHoles[2] { Vector3(-4.03f, 0.f, 0.75f), // Vector3(-2.13f, 0.f, 0.75f), // Vector3(-2.13f, 0.f, 2.55f), // Vector3(-4.03f, 0.f, 2.55f) // }, // frontWindowHoles[3] { Vector3(-0.65f, 0.f, 0.75f), // Vector3(0.65f, 0.f, 0.75f), // Vector3(0.65f, 0.f, 2.55f), // Vector3(-0.65f, 0.f, 2.55f) // }, // frontWindowHoles[4] { Vector3(2.13f, 0.f, 0.75f), // Vector3(4.03f, 0.f, 0.75f), // Vector3(4.03f, 0.f, 2.55f), // Vector3(2.13f, 0.f, 2.55f) // }}; // Front wall faceUVs std::array<std::optional<Vector4>, 3> frontWallFaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Front Wall PolygonOptions frontWallOptions; frontWallOptions.shape = frontWallData; frontWallOptions.depth = 0.15f; frontWallOptions.holes = frontWindowHoles; frontWallOptions.faceUV = frontWallFaceUV; _frontWall = MeshBuilder::ExtrudePolygon("wall", frontWallOptions, scene); _frontWall->rotation().x = -Math::PI_2; _frontWall->material = wallmat; // Real wall polygon shape in XoZ plane std::vector<Vector3> rearWallnb1Data{ Vector3(1.4f, 0.f, -3.f), // Vector3(5.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, 3.f), // Vector3(1.4f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> rear1WindowHoles{// rear1WindowHoles[0] { Vector3(3.7f, 0.f, -1.8f), // Vector3(4.5f, 0.f, -1.8f), // Vector3(4.5f, 0.f, -0.3f), // Vector3(3.7f, 0.f, -0.3f) // }, // rear1WindowHoles[1] { Vector3(1.9f, 0.f, 0.75f), // Vector3(2.7f, 0.f, 0.75f), // Vector3(2.7f, 0.f, 2.55f), // Vector3(1.9f, 0.f, 2.55f) // }, // rear1WindowHoles[2] { Vector3(4.2f, 0.f, 0.75f), // Vector3(5.f, 0.f, 0.75f), // Vector3(5.f, 0.f, 2.55f), // Vector3(4.2f, 0.f, 2.55f) // }}; // Rear Wall faceUVs std::array<std::optional<Vector4>, 3> rearFaceUV{ Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(0.f, 0.f, 7.f / 15.f, 1.f) // }; // Rear wall 1 PolygonOptions rearWallnb1Options; rearWallnb1Options.shape = rearWallnb1Data; rearWallnb1Options.depth = 0.1f; rearWallnb1Options.holes = rear1WindowHoles; rearWallnb1Options.faceUV = rearFaceUV; _rearWallnb1 = MeshBuilder::ExtrudePolygon("rearWallnb1", rearWallnb1Options, scene); _rearWallnb1->rotation().x = -Math::PI_2; _rearWallnb1->position().z = 6.15f; _rearWallnb1->material = wallmat; // Real wall nb2 polygon shape in XoZ plane std::vector<Vector3> rearWallnb2Data{ Vector3(-5.6f, 0.f, -3.f), // Vector3(1.45f, 0.f, -3.f), // Vector3(1.45f, 0.f, 3.f), // Vector3(-2.075f, 0.f, 5.5f), // Vector3(-5.6f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> rear2WindowHoles{// rear2WindowHoles[0] { Vector3(-5.f, 0.f, -1.8f), // Vector3(-1.85f, 0.f, -1.8f), // Vector3(-1.85f, 0.f, -0.3f), // Vector3(-5.f, 0.f, -0.3f) // }, // rear2WindowHoles[1] { Vector3(-0.8f, 0.f, -1.8f), // Vector3(0.9f, 0.f, -1.8f), // Vector3(0.9f, 0.f, -0.3f), // Vector3(-0.8f, 0.f, -0.3f) // }, // rear2WindowHoles[2] { Vector3(-5.f, 0.f, 0.75f), // Vector3(-1.85f, 0.f, 0.75f), // Vector3(-1.85f, 0.f, 2.55f), // Vector3(-5.f, 0.f, 2.55f) // }, // rear2WindowHoles[3] { Vector3(-0.6f, 0.f, 1.75f), // Vector3(0.7f, 0.f, 1.75f), // Vector3(0.7f, 0.f, 2.55f), // Vector3(-0.6f, 0.f, 2.55f) // }}; // Rear wall 2 PolygonOptions rearWallnb2Options; rearWallnb2Options.shape = rearWallnb2Data; rearWallnb2Options.depth = 0.1f; rearWallnb2Options.holes = rear2WindowHoles; rearWallnb2Options.faceUV = rearFaceUV; _rearWallnb2 = MeshBuilder::ExtrudePolygon("rearWallnb2", rearWallnb2Options, scene); _rearWallnb2->rotation().x = -Math::PI_2; _rearWallnb2->position().z = 9.15f; _rearWallnb2->material = wallmat; // Side wall 1 polygon shape in XoZ plane std::vector<Vector3> sideWallnb1Data{ Vector3(-3.15f, 0.f, -3.f), // Vector3(3.1f, 0.f, -3.f), // Vector3(3.1f, 0.f, 3.f), // Vector3(0.f, 0.f, 5.5f), // Vector3(-3.15f, 0.f, 3.f) // }; // Side wall 1 faceUVs std::array<std::optional<Vector4>, 3> side1FaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Side wall 1 PolygonOptions sideWallnb1Options; sideWallnb1Options.shape = sideWallnb1Data; sideWallnb1Options.depth = 0.1f; sideWallnb1Options.faceUV = side1FaceUV; _sideWallnb1 = MeshBuilder::ExtrudePolygon("sideWallnb1", sideWallnb1Options, scene); _sideWallnb1->rotation().z = -Math::PI_2; _sideWallnb1->rotation().x = -Math::PI_2; _sideWallnb1->position().x = 5.6f; _sideWallnb1->position().z = 3.15f; _sideWallnb1->material = wallmat; // Side wall nb2 polygon shape in XoZ plane std::vector<Vector3> sideWallnb2Data{ Vector3(-3.15f, 0.f, -3.f), // Vector3(6.f, 0.f, -3.f), // Vector3(6.f, 0.f, 3.f), // Vector3(3.1f, 0.f, 3.f), // Vector3(0.f, 0.f, 5.5f), // Vector3(-3.15f, 0.f, 3.f) // }; // Side wall 2 faceUVs std::array<std::optional<Vector4>, 3> side2FaceUV{ Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(0.f, 0.f, 7.f / 15.f, 1.f) // }; // Side wall 2 PolygonOptions sideWallnb2Options; sideWallnb2Options.shape = sideWallnb2Data; sideWallnb2Options.depth = 0.1f; sideWallnb2Options.faceUV = side2FaceUV; _sideWallnb2 = MeshBuilder::ExtrudePolygon("sideWallnb2", sideWallnb2Options, scene); _sideWallnb2->rotation().z = -Math::PI_2; _sideWallnb2->rotation().x = -Math::PI_2; _sideWallnb2->position().x = -5.5f; _sideWallnb2->position().z = 3.15f; _sideWallnb2->material = wallmat; // Side wall 3 std::vector<Vector3> sideWallnb3Data{ Vector3(3.1f, 0.f, -3.f), // Vector3(4.5f, 0.f, -3.f), // Vector3(4.5f, 0.f, -0.75f), // Vector3(5.5f, 0.f, -0.75f), // Vector3(5.5f, 0.f, -3.f), // Vector3(6.f, 0.f, -3.f), // Vector3(6.f, 0.f, 3.f), // Vector3(3.1f, 0.f, 3.f) // }; // Side wall 3 faceUVs std::array<std::optional<Vector4>, 3> side3FaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Side wall 3 PolygonOptions sideWallnb3Options; sideWallnb3Options.shape = sideWallnb3Data; sideWallnb3Options.depth = 0.1f; sideWallnb3Options.faceUV = side3FaceUV; _sideWallnb3 = MeshBuilder::ExtrudePolygon("sideWallnb3", sideWallnb3Options, scene); _sideWallnb3->rotation().z = -Math::PI_2; _sideWallnb3->rotation().x = -Math::PI_2; _sideWallnb3->position().x = 1.45f; _sideWallnb3->position().z = 3.15f; _sideWallnb3->material = wallmat; // Roof material auto roofmat = StandardMaterial::New("roofmat", scene); roofmat->diffuseTexture = Texture::New("textures/roofMaterial.jpg", scene); // Roof 1 polygon shape in XoZ plane std::vector<Vector3> roof1Data{ Vector3(-0.05f, 0.f, 0.f), // Vector3(0.1f, 0.f, 0.f), // Vector3(3.3f, 0.f, 2.65f), // Vector3(6.5f, 0.f, 0.f), // Vector3(6.6f, 0.f, 0.f), // Vector3(3.3f, 0.f, 2.8f) // }; // Roof 1 PolygonOptions roof1Options; roof1Options.shape = roof1Data; roof1Options.depth = 11.5f; auto roof1 = MeshBuilder::ExtrudePolygon("roof1", roof1Options, scene); roof1->rotation().z = -Math::PI_2; roof1->rotation().x = -Math::PI_2; roof1->position().x = 5.7f; roof1->position().y = 2.9f; roof1->position().z = -0.15f; roof1->material = roofmat; // Roof 2 polygon shape in XoZ plane std::vector<Vector3> roof2Data{ Vector3(0.f, 0.f, 0.f), // Vector3(0.142f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.6f), // Vector3(7.476f, 0.f, 0.f), // Vector3(7.618f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.7f) // }; // Roof 2 PolygonOptions roof2Options; roof2Options.shape = roof2Data; roof2Options.depth = 3.2f; auto roof2 = MeshBuilder::ExtrudePolygon("roof2", roof2Options, scene); roof2->rotation().x = -Math::PI_2; roof2->position().x = -5.9f; roof2->position().y = 2.9f; roof2->position().z = 6.3f; roof2->material = roofmat; // Roof 3 polygon shape in XoZ plane std::vector<Vector3> roof3Data{ Vector3(0.3f, 0.f, 0.2f), // Vector3(0.442f, 0.f, 0.2f), // Vector3(3.834f, 0.f, 2.6f), // Vector3(7.476f, 0.f, 0.f), // Vector3(7.618f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.7f) // }; // Roof 3 PolygonOptions roof3Options; roof3Options.shape = roof3Data; roof3Options.depth = 3.2f; auto roof3 = MeshBuilder::ExtrudePolygon("roof3", roof3Options, scene); roof3->rotation().x = -Math::PI_2; roof3->position().x = -5.9f; roof3->position().y = 2.9f; roof3->position().z = 3.1f; roof3->material = roofmat; // Roof _roof = Mesh::MergeMeshes({roof1, roof2, roof3}, true); // Staircase auto stairsDepth = 2.f; auto stairsHeight = 3.f; auto stairsThickness = 0.05f; auto nBStairs = 12; std::vector<Vector3> stairs; auto x = 0.f; auto z = 0.f; // Up stairs.emplace_back(Vector3(x, 0.f, z)); z += stairsHeight / nBStairs - stairsThickness; stairs.emplace_back(Vector3(x, 0.f, z)); for (int i = 0; i < nBStairs; ++i) { x += stairsDepth / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); z += stairsHeight / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); } x += stairsDepth / nBStairs - stairsThickness; stairs.emplace_back(Vector3(x, 0.f, z)); // Down for (int i = 0; i <= nBStairs; i++) { x -= stairsDepth / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); z -= stairsHeight / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); } std::array<std::optional<Color4>, 3> faceColors{ Color4(0.f, 0.f, 0.f, 1.f), // Color4(190.f / 255.f, 139.f / 255.f, 94.f / 255.f, 1.f), // Color4(0.f, 0.f, 0.f, 1.f), // }; // Stairs auto stairsWidth = 1.f; PolygonOptions stairsOptions; stairsOptions.shape = stairs; stairsOptions.depth = stairsWidth; stairsOptions.faceColors = faceColors; auto stairCase = MeshBuilder::ExtrudePolygon("stairs", stairsOptions, scene); stairCase->position().x = 1.37f; stairCase->position().y = -3.f; stairCase->position().z = 2.51f; stairCase->rotation().x = -Math::PI_2; stairCase->rotation().y = -Math::PI_2; // Floor material auto floormat = StandardMaterial::New("floormaterial", scene); floormat->diffuseTexture = Texture::New("textures/floorMaterial.jpg", scene); // Floor polygon shape in XoZ plane std::vector<Vector3> floorData{ Vector3(-5.5f, 0.f, 0), // Vector3(5.5f, 0.f, 0), // Vector3(5.5f, 0.f, 6), // Vector3(1.345f, 0.f, 6), // Vector3(1.345f, 0.f, 9), // Vector3(-5.5f, 0.f, 9) // }; // Stair space std::vector<std::vector<Vector3>> stairSpace{// stairSpace[0] { Vector3(0.27f, 0.f, 2.5f), // Vector3(0.27f, 0.f, 4.5f), // Vector3(1.37f, 0.f, 4.5f), // Vector3(1.37f, 0.f, 2.5f), // }}; // Rear Wall faceUVs std::array<std::optional<Vector4>, 3> floorFaceUV{ Vector4(0.f, 0.f, 0.5f, 1.f), // Vector4(0.f, 0.f, 0.f, 0.f), // Vector4(0.5f, 0.f, 1.f, 1.f) // }; // Floor PolygonOptions floorOptions; floorOptions.shape = floorData; floorOptions.holes = stairSpace; floorOptions.depth = 0.1f; floorOptions.faceUV = floorFaceUV; auto floor = MeshBuilder::ExtrudePolygon("floor", floorOptions, scene); floor->position().y = 0.21f; floor->position().z = 0.15f; floor->material = floormat; // Ground floor polygon shape in XoZ plane std::vector<Vector3> groundFloorData{ Vector3(-5.6f, 0.f, -0.1f), // Vector3(5.6f, 0.f, -0.1f), // Vector3(5.6f, 0.f, 6.1f), // Vector3(1.36f, 0.f, 6.1f), // Vector3(1.36f, 0.f, 9.1f), // Vector3(-5.6f, 0.f, 9.1f) // }; // Ground floor faceUVs std::array<std::optional<Vector4>, 3> groundFloorFaceUV{ Vector4(0.f, 0.f, 0.5f, 1.f), // Vector4(0.f, 0.f, 0.f, 0.f), // Vector4(0.5f, 0.f, 1.f, 1.f) // }; // Ground floor PolygonOptions groundFloorOptions; groundFloorOptions.shape = groundFloorData; groundFloorOptions.depth = 0.04f; groundFloorOptions.faceUV = groundFloorFaceUV; auto groundFloor = MeshBuilder::ExtrudePolygon("groundFloor", groundFloorOptions, scene); groundFloor->position().y = -3.f; groundFloor->position().z = 0.15f; groundFloor->material = floormat; // Ceiling polygon shape in XoZ plane std::vector<Vector3> ceilingData{ Vector3(-5.5f, 0.f, 0.f), // Vector3(5.5f, 0.f, 0.f), // Vector3(5.5f, 0.f, 6.f), // Vector3(1.345f, 0.f, 6.f), // Vector3(1.345f, 0.f, 9.f), // Vector3(-5.5f, 0.f, 9.f) // }; // Ceiling PolygonOptions ceilingOptions; ceilingOptions.shape = ceilingData; ceilingOptions.depth = 0.1f; _ceiling = MeshBuilder::ExtrudePolygon("ceiling", ceilingOptions, scene); _ceiling->position().y = 2.8f; _ceiling->position().z = 0.15f; _ceiling->material = innerwallmat; // Inner wall 1 polygon shape in XoZ plane std::vector<Vector3> innerWallnb1Data{ Vector3(-3.f, 0.f, 0.6f), // Vector3(-3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 6.1f), // Vector3(-3.f, 0.f, 6.1f), // Vector3(-3.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 0.6f), // }; // Door space 1 std::vector<std::vector<Vector3>> doorSpace1{// doorSpace1[0] { Vector3(0.1f, 0.f, 1.6f), // Vector3(0.1f, 0.f, 0.6f), // Vector3(2.f, 0.f, 0.6f), // Vector3(2.f, 0.f, 1.6f) // }}; // Inner wall 1 PolygonOptions innerWallnb1Options; innerWallnb1Options.shape = innerWallnb1Data; innerWallnb1Options.holes = doorSpace1; innerWallnb1Options.depth = 0.1f; auto innerWallnb1 = MeshBuilder::ExtrudePolygon("innerWallnb1", innerWallnb1Options, scene); innerWallnb1->rotation().z = Math::PI_2; innerWallnb1->position().x = 1.35f; innerWallnb1->position().z = 0.15f; innerWallnb1->material = innerwallmat; // Inner wall 1 polygon shape in XoZ plane std::vector<Vector3> innerWallnb2Data{ Vector3(-3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 9.f), // Vector3(-3.f, 0.f, 9.f), // Vector3(-3.f, 0.f, 7.6f), // Vector3(-1.f, 0.f, 7.6f), // Vector3(-1.f, 0.f, 6.6f), // Vector3(-3.f, 0.f, 6.6f), // Vector3(-3.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 0.6f), // Vector3(-3.f, 0.f, 0.6f) // }; // Door space 2 std::vector<std::vector<Vector3>> doorSpace2{// doorSpace2[0] { Vector3(0.1f, 0.f, 0.6f), // Vector3(2.f, 0.f, 0.6f), // Vector3(2.f, 0.f, 1.6f), // Vector3(0.1f, 0.f, 1.6f) // }, // doorSpace2[1] { Vector3(0.1f, 0.f, 4.6f), // Vector3(2.f, 0.f, 4.6f), // Vector3(2.f, 0.f, 5.6f), // Vector3(0.1f, 0.f, 5.6f) // }}; // Inner wall 2 PolygonOptions innerWallnb2options; innerWallnb2options.shape = innerWallnb2Data; innerWallnb2options.holes = doorSpace2; innerWallnb2options.depth = 0.1f; auto innerWallnb2 = MeshBuilder::ExtrudePolygon("innerWallnb2", innerWallnb2options, scene); innerWallnb2->rotation().z = Math::PI_2; innerWallnb2->position().x = 1.35f; innerWallnb2->position().z = 0.15f; innerWallnb2->position().x = -1.4f; innerWallnb2->material = innerwallmat; // Bathroom wall polygon shape in XoZ plane std::vector<Vector3> bathroomWallData{ Vector3(-1.4f, 0.f, 0), // Vector3(-0.5f, 0.f, 0), // Vector3(-0.5f, 0.f, 2), // Vector3(0.5f, 0.f, 2), // Vector3(0.5f, 0.f, 0), // Vector3(1.4f, 0.f, 0), // Vector3(1.4f, 0.f, 6), // Vector3(-1.4f, 0.f, 6) // }; // Door space 3 std::vector<std::vector<Vector3>> doorSpace3{// doorSpace3[0] { Vector3(-0.5f, 0.f, 3.2f), // Vector3(-0.5f, 0.f, 5.2f), // Vector3(0.5f, 0.f, 5.2f), // Vector3(0.5f, 0.f, 3.2f) // }}; // Bathroom wall PolygonOptions bathroomOptions; bathroomOptions.shape = bathroomWallData; bathroomOptions.depth = 0.1f; bathroomOptions.holes = doorSpace3; auto bathroomWall = MeshBuilder::ExtrudePolygon("bathroomWall", bathroomOptions, scene); bathroomWall->rotation().x = -Math::PI_2; bathroomWall->position().y = -3.f; bathroomWall->position().z = 6.f; bathroomWall->material = innerwallmat; // Bedroom 1 wall shape in XoZ plane std::vector<Vector3> bedroom1WallData{ Vector3(-5.5f, 0.f, 0.f), // Vector3(-2.9f, 0.f, 0.f), // Vector3(-2.9f, 0.f, 2.f), // Vector3(-1.9f, 0.f, 2.f), // Vector3(-1.9f, 0.f, 0.f), // Vector3(-1.4f, 0.f, 0.f), // Vector3(-1.4f, 0.f, 6.f), // Vector3(-5.5f, 0.f, 6.f) // }; // Bedroom 1 wall PolygonOptions bedroom1WallOptions; bedroom1WallOptions.shape = bedroom1WallData; bedroom1WallOptions.depth = 0.1f; auto bedroom1Wall = MeshBuilder::ExtrudePolygon("bedroom1Wall", bedroom1WallOptions, scene); bedroom1Wall->rotation().x = -Math::PI_2; bedroom1Wall->position().y = -3; bedroom1Wall->position().z = 4.5; bedroom1Wall->material = innerwallmat; // Bannister wall shape in XoZ plane std::vector<Vector3> bannisterWallData{ Vector3(0.f, 0.f, 0.f), // Vector3(1.f, 0.f, 0.f), // Vector3(1.f, 0.f, 1.4f), // Vector3(1.75f, 0.f, 1.4f), // Vector3(1.75f, 0.f, 0.f), // Vector3(3.5f, 0.f, 0.f), // Vector3(3.5f, 0.f, 3.2f), // Vector3(1.5f, 0.f, 3.2f), // Vector3(0.f, 0.f, 0.75f) // }; auto spindleThickness = 0.05f; auto spindles = 12; auto railGap = (1.5f - spindles * spindleThickness) / (spindles - 1.f); std::vector<std::vector<Vector3>> rail; auto ac = spindleThickness; for (auto s = 0; s < spindles - 1; s++) { std::vector<Vector3> rails; rails.emplace_back(Vector3(ac, 0.f, 0.1f + 1.6f * ac)); rails.emplace_back(Vector3(ac, 0.f, (0.75f - spindleThickness) + 1.6f * ac)); rails.emplace_back( Vector3(ac + railGap, 0.f, (0.75f - spindleThickness) + 1.6f * (ac + railGap))); rails.emplace_back(Vector3(ac + railGap, 0.f, 1.6f * (ac + railGap))); rail.emplace_back(rails); ac += spindleThickness + railGap; } // Bannister wall PolygonOptions bannisterWallOptions; bannisterWallOptions.shape = bannisterWallData; bannisterWallOptions.holes = rail; bannisterWallOptions.depth = 0.1f; auto bannisterWall = MeshBuilder::ExtrudePolygon("bannisterWall", bannisterWallOptions, scene); bannisterWall->rotation().x = -Math::PI_2; bannisterWall->rotation().z = -Math::PI_2; bannisterWall->position().x = 0.4f; bannisterWall->position().y = -3.f; bannisterWall->position().z = 2.51f; // Bannister 1 shape in XoZ plane std::vector<Vector3> bannister1Data{ Vector3(0, 0.f, 0), Vector3(2, 0.f, 0), Vector3(2, 0.f, 0.75), Vector3(0, 0.f, 0.75), }; auto spindle1Thickness = 0.05f; auto spindles1 = 12; auto rail1Gap = (2.f - spindles1 * spindle1Thickness) / (spindles1 - 1.f); std::vector<std::vector<Vector3>> rail1; auto ac1 = spindle1Thickness; for (auto s = 0; s < spindles1 - 1; s++) { std::vector<Vector3> rail1s; rail1s.emplace_back(Vector3(ac1, 0.f, spindle1Thickness)); rail1s.emplace_back(Vector3(ac1, 0.f, 0.75f - spindle1Thickness)); rail1s.emplace_back(Vector3(ac1 + rail1Gap, 0.f, 0.75f - spindle1Thickness)); rail1s.emplace_back(Vector3(ac1 + rail1Gap, 0.f, spindle1Thickness)); rail1.emplace_back(rail1s); ac1 += spindle1Thickness + rail1Gap; } // Bannister 1 PolygonOptions bannister1Options; bannister1Options.shape = bannister1Data; bannister1Options.holes = rail1; bannister1Options.depth = 0.1f; auto bannister1 = MeshBuilder::ExtrudePolygon("bannister1", bannister1Options, scene); bannister1->rotation().x = -Math::PI_2; bannister1->rotation().z = -Math::PI_2; bannister1->position().x = 0.3f; bannister1->position().y = 0.2f; bannister1->position().z = 2.61f; // Bannister 2 shape in XoZ plane std::vector<Vector3> bannister2Data{ Vector3(0, 0.f, 0), Vector3(1, 0.f, 0), Vector3(1, 0.f, 0.75), Vector3(0, 0.f, 0.75), }; auto spindle2Thickness = 0.05f; auto spindles2 = 6; auto rail2Gap = (1.f - spindles2 * spindle2Thickness) / (spindles2 - 1.f); std::vector<std::vector<Vector3>> rail2; auto ac2 = spindle2Thickness; for (auto s = 0; s < spindles2 - 1; s++) { std::vector<Vector3> rail2s; rail2s.emplace_back(Vector3(ac2, 0.f, spindle2Thickness)); rail2s.emplace_back(Vector3(ac2, 0.f, 0.75f - spindle2Thickness)); rail2s.emplace_back(Vector3(ac2 + rail2Gap, 0.f, 0.75f - spindle2Thickness)); rail2s.emplace_back(Vector3(ac2 + rail2Gap, 0.f, spindle2Thickness)); rail2.emplace_back(rail2s); ac2 += spindle2Thickness + rail2Gap; } // Bannister 2 PolygonOptions bannister2Options; bannister2Options.shape = bannister2Data; bannister2Options.holes = rail2; bannister2Options.depth = 0.1f; auto bannister2 = MeshBuilder::ExtrudePolygon("bannister2", bannister2Options, scene); bannister2->rotation().x = -Math::PI_2; bannister2->position().x = 0.3f; bannister2->position().y = 0.2f; bannister2->position().z = 2.61f; // Windo maker function const auto windowMaker = [scene](float width, float height, float frames, float frameDepth, float frameThickness) { std::vector<Vector3> windowShape{ Vector3(0.f, 0.f, 0.f), // Vector3(width, 0.f, 0.f), // Vector3(width, 0.f, height), // Vector3(0.f, 0.f, height) // }; auto glassWidth = (width - (frames + 1.f) * frameThickness) / frames; auto glassTopHeight = height / 3.f - frameThickness; auto glassBotHeight = 2.f * glassTopHeight; std::vector<std::vector<Vector3>> glass; auto acf = frameThickness; for (auto f = 0; f < frames; ++f) { std::vector<Vector3> glass2f; glass2f.emplace_back(Vector3(acf, 0.f, 2.f * frameThickness + glassBotHeight)); glass2f.emplace_back(Vector3(acf + glassWidth, 0.f, 2.f * frameThickness + glassBotHeight)); glass2f.emplace_back( Vector3(acf + glassWidth, 0.f, 2.f * frameThickness + glassBotHeight + glassTopHeight)); glass2f.emplace_back( Vector3(acf, 0.f, 2.f * frameThickness + glassBotHeight + glassTopHeight)); glass.emplace_back(glass2f); std::vector<Vector3> glass2f1; glass2f1.emplace_back(Vector3(acf, 0.f, frameThickness)); glass2f1.emplace_back(Vector3(acf + glassWidth, 0.f, frameThickness)); glass2f1.emplace_back(Vector3(acf + glassWidth, 0.f, frameThickness + glassBotHeight)); glass2f1.emplace_back(Vector3(acf, 0.f, frameThickness + glassBotHeight)); glass.emplace_back(glass2f1); acf += frameThickness + glassWidth; } PolygonOptions windowOptions; windowOptions.shape = windowShape; windowOptions.holes = glass; windowOptions.depth = frameDepth; auto window = MeshBuilder::ExtrudePolygon("window", windowOptions, scene); window->rotation().x = -Math::PI_2; return window; }; _windowFBL = windowMaker(3.2f, 2.f, 4.f, 0.15f, 0.1f); _windowFBL->position().x = -4.78f; _windowFBL->position().y = -2.3f; _windowFBL->position().z = 0.1f; _windowFBR = windowMaker(3.2f, 2.f, 4.f, 0.15f, 0.1f); _windowFBR->position().x = 1.58f; _windowFBR->position().y = -2.3f; _windowFBR->position().z = 0.1f; _windowFTL = windowMaker(1.9f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTL->position().x = -4.03f; _windowFTL->position().y = 0.75f; _windowFTL->position().z = 0.1f; _windowFTR = windowMaker(1.9f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTR->position().x = 2.13f; _windowFTR->position().y = 0.75f; _windowFTR->position().z = 0.1f; _windowFTM = windowMaker(1.3f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTM->position().x = -0.65f; _windowFTM->position().y = 0.75f; _windowFTM->position().z = 0.1f; _windowRBL = windowMaker(3.15f, 1.5f, 4.f, 0.15f, 0.1f); _windowRBL->position().x = -5.f; _windowRBL->position().y = -1.8f; _windowRBL->position().z = 9.f; _windowRBR = windowMaker(1.7f, 1.5f, 2.f, 0.15f, 0.1f); _windowRBR->position().x = -0.8f; _windowRBR->position().y = -1.8f; _windowRBR->position().z = 9.f; _windowRTL = windowMaker(3.15f, 1.8f, 4.f, 0.15f, 0.1f); _windowRTL->position().x = -5.f; _windowRTL->position().y = 0.75f; _windowRTL->position().z = 9.f; _windowRTR = windowMaker(1.3f, 0.8f, 1.f, 0.15f, 0.1f); _windowRTR->position().x = -0.6f; _windowRTR->position().y = 1.75f; _windowRTR->position().z = 9.f; _windowR1BL = windowMaker(0.8f, 1.5f, 1.f, 0.15f, 0.1f); _windowR1BL->position().x = 3.7f; _windowR1BL->position().y = -1.8f; _windowR1BL->position().z = 6.f; _windowR1TL = windowMaker(0.8f, 1.8f, 1.f, 0.15f, 0.1f); _windowR1TL->position().x = 1.9f; _windowR1TL->position().y = 0.75f; _windowR1TL->position().z = 6.f; _windowR1TR = windowMaker(0.8f, 1.8f, 1.f, 0.15f, 0.1f); _windowR1TR->position().x = 4.2f; _windowR1TR->position().y = 0.75f; _windowR1TR->position().z = 6.f; // Door maker function const auto doorMaker = [scene](float width, float height, float depth) { std::vector<Vector3> doorShape{ Vector3(0.f, 0.f, 0.f), // Vector3(width, 0.f, 0.f), // Vector3(width, 0.f, height), // Vector3(0.f, 0.f, height) // }; auto edgeThickness = width / 8.f; auto panelWidth = width - 2.f * edgeThickness; auto panelBotHeight = (height - 3.f * edgeThickness) / 1.75f; auto panelTopHeight = 0.75f * panelBotHeight; std::vector<std::vector<Vector3>> panel; std::vector<Vector3> panel0; panel0.emplace_back(Vector3(edgeThickness, 0.f, 2.f * edgeThickness + panelBotHeight)); panel0.emplace_back( Vector3(edgeThickness + panelWidth, 0.f, 2.f * edgeThickness + panelBotHeight)); panel0.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, 2.f * edgeThickness + panelBotHeight + panelTopHeight)); panel0.emplace_back( Vector3(edgeThickness, 0.f, 2.f * edgeThickness + panelBotHeight + panelTopHeight)); panel.emplace_back(panel0); std::vector<Vector3> panel1; panel1.emplace_back(Vector3(edgeThickness, 0.f, edgeThickness)); panel1.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, edgeThickness)); panel1.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, edgeThickness + panelBotHeight)); panel1.emplace_back(Vector3(edgeThickness, 0.f, edgeThickness + panelBotHeight)); panel.emplace_back(panel1); // Door PolygonOptions doorOptions; doorOptions.shape = doorShape; doorOptions.holes = panel; doorOptions.depth = depth; auto door = MeshBuilder::ExtrudePolygon("door", doorOptions, scene); door->rotation().x = -Math::PI_2; // Bottom panel BoxOptions panelBOptions; panelBOptions.width = panelWidth; panelBOptions.height = panelBotHeight; panelBOptions.depth = depth / 2.f; auto panelB = MeshBuilder::CreateBox("p1b", panelBOptions, scene); panelB->position().x = edgeThickness + panelWidth / 2.f; panelB->position().y = edgeThickness + panelBotHeight / 2.f; panelB->position().z = depth / 2.f; // Top panel BoxOptions panelTOptions; panelTOptions.width = panelWidth; panelTOptions.height = panelTopHeight; panelTOptions.depth = depth / 2.f; auto panelT = MeshBuilder::CreateBox("p1t", panelTOptions, scene); panelT->position().x = edgeThickness + panelWidth / 2; panelT->position().y = 2.f * edgeThickness + panelBotHeight + panelTopHeight / 2.f; panelT->position().z = depth / 2.f; return Mesh::MergeMeshes({door, panelB, panelT}, true); }; auto doormat = StandardMaterial::New("door", scene); doormat->diffuseColor = Color3(82.f / 255.f, 172.f / 255.f, 106.f / 255.f); // Front door _frontDoor = doorMaker(1.f, 2.25f, 0.1f); _frontDoor->position().x = -0.5f; _frontDoor->position().y = -3.f; _frontDoor->position().z = 0.1f; _frontDoor->material = doormat; // Back door _backDoor = doorMaker(1, 2.25f, 0.1f); _backDoor->rotation().y = Math::PI_2; _backDoor->position().x = 1.3f; _backDoor->position().y = -3.f; _backDoor->position().z = 8.65f; _backDoor->material = doormat; hudGui = [=]() { // Checkbox helper const auto renderCheckBox = [](const char* label, bool isSelected) -> bool { bool origValue = isSelected; ImGui::Checkbox(label, &isSelected); return origValue != isSelected; }; // Header ImGui::TextWrapped("%s", "Toggle Visibility"); // Toggle Roof Visibility if (renderCheckBox("Roof", _roof->isVisible)) { _roof->isVisible = !_roof->isVisible; _ceiling->isVisible = !_ceiling->isVisible; } // Toggle Front Visibility if (renderCheckBox("Front", _frontWall->isVisible)) { _frontWall->isVisible = !_frontWall->isVisible; _windowFBL->isVisible = !_windowFBL->isVisible; _windowFBR->isVisible = !_windowFBR->isVisible; _windowFTL->isVisible = !_windowFTL->isVisible; _windowFTR->isVisible = !_windowFTR->isVisible; _windowFTM->isVisible = !_windowFTM->isVisible; _frontDoor->isVisible = !_frontDoor->isVisible; } // Toggle Back Visibility if (renderCheckBox("Back", _rearWallnb1->isVisible)) { _rearWallnb1->isVisible = !_rearWallnb1->isVisible; _rearWallnb2->isVisible = !_rearWallnb2->isVisible; _windowRBL->isVisible = !_windowRBL->isVisible; _windowRBR->isVisible = !_windowRBR->isVisible; _windowRTL->isVisible = !_windowRTL->isVisible; _windowRTR->isVisible = !_windowRTR->isVisible; _windowR1BL->isVisible = !_windowR1BL->isVisible; _windowR1TL->isVisible = !_windowR1TL->isVisible; _windowR1TR->isVisible = !_windowR1TR->isVisible; } // Toggle Left Side Visibility if (renderCheckBox("Left Side", _sideWallnb1->isVisible)) { _sideWallnb1->isVisible = !_sideWallnb1->isVisible; _sideWallnb3->isVisible = !_sideWallnb3->isVisible; _backDoor->isVisible = !_backDoor->isVisible; } // Toggle Right Side Visibility if (renderCheckBox("Right Side", _sideWallnb2->isVisible)) { _sideWallnb2->isVisible = !_sideWallnb2->isVisible; } }; } private: // Roof MeshPtr _roof, _ceiling; // Front MeshPtr _frontWall, _windowFBL, _windowFBR, _windowFTL, _windowFTR, _windowFTM, _frontDoor; // Back MeshPtr _rearWallnb1, _rearWallnb2, _windowRBL, _windowRBR, _windowRTL, _windowRTR, _windowR1BL, _windowR1TL, _windowR1TR; // Left Side MeshPtr _sideWallnb1, _sideWallnb3, _backDoor; // Right Side MeshPtr _sideWallnb2; }; // end of class ExtrudePolygonScene BABYLON_REGISTER_SAMPLE("Meshes", ExtrudePolygonScene) } // end of namespace Samples } // end of namespace BABYLON
41.533724
100
0.512274
samdauwe
5eda7a9a5a1a0619e7d0ea373894e962f5c0bb43
3,546
cpp
C++
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
#include "ai.h" #include "stocks.h" #include "df/general_ref.h" #include "df/item_foodst.h" bool Stocks::willing_to_trade_item(color_ostream & out, df::item *item) { if (virtual_cast<df::item_foodst>(item)) { return true; } if (item->isFoodStorage()) { bool any_contents = false; for (auto ref : item->general_refs) { if (ref->getType() == general_ref_type::CONTAINS_ITEM) { any_contents = true; if (!willing_to_trade_item(out, ref->getItem())) { return false; } } } return any_contents; } return false; } bool Stocks::want_trader_item(color_ostream &, df::item *item, const std::vector<df::item *> & already_want) { if (item->hasSpecificImprovements(improvement_type::WRITING) || item->getType() == item_type::BOOK) { return true; } if (item->getType() == item_type::WOOD || item->getType() == item_type::BOULDER || item->getType() == item_type::BAR) { return true; } if (item->getType() == item_type::CLOTH || item->getType() == item_type::SKIN_TANNED || item->getType() == item_type::THREAD) { return true; } if (item->getType() == item_type::CHEESE || item->getType() == item_type::EGG || item->getType() == item_type::FISH || item->getType() == item_type::FISH_RAW || item->getType() == item_type::MEAT || item->getType() == item_type::PLANT || item->getType() == item_type::PLANT_GROWTH) { return true; } if (item->getType() == item_type::INSTRUMENT) { return true; } if (item->getType() == item_type::ANVIL) { int32_t anvils_wanted = -int32_t(std::count_if(already_want.begin(), already_want.end(), [](df::item *i) -> bool { return i->getType() == item_type::ANVIL; })); anvils_wanted -= count_free[stock_item::anvil]; ai.find_room(room_type::workshop, [&anvils_wanted](room *r) -> bool { if (r->workshop_type == workshop_type::MetalsmithsForge && !r->dfbuilding()) { anvils_wanted++; } return false; }); return anvils_wanted >= 0; } return false; } bool Stocks::want_trader_item_more(df::item *a, df::item *b) { if (a->getType() == item_type::WOOD && b->getType() != item_type::WOOD) { return true; } else if (b->getType() == item_type::WOOD && a->getType() != item_type::WOOD) { return false; } if (a->getType() == item_type::ANVIL && b->getType() != item_type::ANVIL) { return true; } else if (b->getType() == item_type::ANVIL && a->getType() != item_type::ANVIL) { return false; } if ((a->hasSpecificImprovements(improvement_type::WRITING) || a->getType() == item_type::BOOK) && !(b->hasSpecificImprovements(improvement_type::WRITING) || b->getType() == item_type::BOOK)) { return true; } else if ((b->hasSpecificImprovements(improvement_type::WRITING) || b->getType() == item_type::BOOK) && !(a->hasSpecificImprovements(improvement_type::WRITING) || a->getType() == item_type::BOOK)) { return false; } if (a->getType() == item_type::INSTRUMENT && b->getType() != item_type::INSTRUMENT) { return true; } else if (b->getType() == item_type::INSTRUMENT && a->getType() != item_type::INSTRUMENT) { return false; } return false; }
28.829268
285
0.565426
mattregul
5edb4636708ab8b61422e468e1bcf33a5bbf0bb0
456
cpp
C++
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
9
2020-06-02T16:40:40.000Z
2021-10-03T15:22:40.000Z
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
2
2020-11-06T00:00:24.000Z
2022-02-14T01:59:08.000Z
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
2
2021-01-02T15:29:50.000Z
2022-02-23T07:26:00.000Z
#include<errno.h> #include<unistd.h> #include<utility> #include"Net/Fd.hpp" namespace Net { Fd& Fd::operator=(Fd&& o) { auto tmp = Fd(std::move(o)); swap(tmp); return *this; } Fd::~Fd() { if (fd >= 0) { /* Ignore errors. * This is a destructor, so it is * entirely possible that this * occurred due to errno-based * errors. * So, we should preserve the errno. */ auto my_errno = errno; close(fd); errno = my_errno; } } }
15.2
38
0.607456
ZmnSCPxj
5edc373a45e0fb948f85a0796b4b088d34d448ac
3,479
cpp
C++
oneEngine/oneGame/source/after/entities/world/events/EventBanditSpawnSmall.cpp
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
8
2017-12-08T02:59:31.000Z
2022-02-02T04:30:03.000Z
oneEngine/oneGame/source/after/entities/world/events/EventBanditSpawnSmall.cpp
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
2
2021-04-16T03:44:42.000Z
2021-08-30T06:48:44.000Z
oneEngine/oneGame/source/after/entities/world/events/EventBanditSpawnSmall.cpp
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
1
2021-04-16T02:09:54.000Z
2021-04-16T02:09:54.000Z
#include "EventBanditSpawnSmall.h" #include "after/entities/character/npc/zoned/CZonedCharacterController.h" #include "after/entities/world/CNpcSpawner.h" #include "after/types/character/NPC_WorldState.h" #include "after/interfaces/io/CZonedCharacterIO.h" #include "after/entities/character/NPC/CNpcBase.h" #include "core/math/random/Random.h" #include "engine/state/CGameState.h" using namespace GameEvents; EventBanditSpawnSmall::EventBanditSpawnSmall ( void ) : CEventBase() { for ( uint i = 0; i < 3; ++i ) { NPC::npcid_t banditId = NPC::Manager->RequestNPC( NPC::npcid_UNIQUE ); { NPC::characterFile_t characterFile; CRacialStats rstats; rstats.stats = new CharacterStats; rstats.SetDefaults(); characterFile.rstats = &rstats; { // Set race //rstats.iRace = CRACE_ELF; switch ( Random.Next()%4 ) { case 0: rstats.iRace = CRACE_ELF; break; //rstats.iRace = CRACE_FLUXXOR; break; case 1: rstats.iRace = CRACE_ELF; break; case 2: rstats.iRace = CRACE_KITTEN; break; case 3: rstats.iRace = CRACE_HUMAN; break; } // Set gender rstats.iGender = eCharacterGender(Random.Next()%2); // Randomize hairstyle rstats.iHairstyle = Random.Next()%3; // Set companion colors rstats.RerollColors(); // Set facial tattoo if ( Random.Next()%3 == 0 ) { CRacialStats::tattoo_t tattoo; tattoo.color = Color( Random.Range(0.1f,0.5f),Random.Range(0.1f,0.5f),Random.Range(0.1f,0.5f),1.0f ); tattoo.mirror = false; tattoo.type = TATT_CLANMARK; tattoo.pattern = "clan_skullblack"; if ( Random.Next()%2 == 0 ) { tattoo.pattern = "clan_mask2"; } tattoo.projection_angle = Random.Range( 150.0f, 180.0f ); tattoo.projection_dir = Vector3d( 0,1,0 ); tattoo.projection_pos = Vector3d( 0,-15,28 ) / 12.0f; tattoo.projection_scale = Vector3d(1,1,1) * Random.Range( 0.77f, 0.92f ); if ( Random.Chance(0.5f) ) tattoo.projection_scale.x *= -1; rstats.tattooList.push_back( tattoo ); } rstats.iTattooCount = rstats.tattooList.size(); // Set name rstats.sPlayerName = "Bandit"; rstats.sLastName = ""; } NPC::sWorldState worldstate; { characterFile.worldstate = &worldstate; worldstate.mFocus = NPC::AIFOCUS_Wanderer; // should be bandit focus, so can turn to BanditRunner faction when worldstate.travelDirection = Vector3d( 1,0,0 ); bool success = false; while ( !success ) { worldstate.worldPosition = NPC::Spawner->GetSpawnPosition( m_focus_player_actor->transform.position, success );//= pPlayerStats->vPlayerInitSpawnPoint; } worldstate.partyHost = banditId; worldstate.mFaction = NPC::FactionBandit; } NPC::sOpinions opinions; characterFile.opinions = &opinions; NPC::sPreferences prefs; characterFile.prefs = &prefs; // Save generated stats NPC::CZonedCharacterIO io; io.CreateCharacterFile( banditId, characterFile ); // Clean up delete rstats.stats; } // Create bandit :D NPC::CNpcBase* bandit = (NPC::CNpcBase*) NPC::Manager->SpawnNPC( banditId ); // Now, change bandit's equipment // Assign main bandit id to check when should call event over mainBanditId = bandit->GetId(); } } EventBanditSpawnSmall::~EventBanditSpawnSmall ( void ) { } void EventBanditSpawnSmall::Update ( void ) { if ( CGameState::Active()->GetBehavior( mainBanditId ) == NULL ) { DeleteObject( this ); } }
28.056452
156
0.675194
jonting
5edc8bfef4f7236867a536407485d247cc1558d3
2,833
cpp
C++
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
// BEGIN CUT HERE // END CUT HERE #line 5 "IdentifyingWood.cpp" #include <vector> #include <list> #include <bitset> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> using namespace std; int n,m; class IdentifyingWood { public: string s; string t; int dp[11][11]; bool Solve(int p,int q){ if (q==0){return true;} if (p==0){return false;} if (dp[p][q]!=-1){return dp[p][q];} bool res=false; if (s[p-1]==t[q-1]){ res|=Solve(p-1,q-1); } res|=Solve(p-1,q); dp[p][q]=res; return res; } string check(string s, string t) { n=s.length(); m=t.length(); if (m>n){ return "Nope."; } this->s=s; this->t=t; memset(dp,-1,sizeof(dp)); if (Solve(n,m)){ return "Yep, it's wood."; } return "Nope."; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arg0 = "absdefgh"; string Arg1 = "asdf"; string Arg2 = "Yep, it's wood."; verify_case(0, Arg2, check(Arg0, Arg1)); } void test_case_1() { string Arg0 = "oxoxoxox"; string Arg1 = "ooxxoo"; string Arg2 = "Nope."; verify_case(1, Arg2, check(Arg0, Arg1)); } void test_case_2() { string Arg0 = "oxoxoxox"; string Arg1 = "xxx"; string Arg2 = "Yep, it's wood."; verify_case(2, Arg2, check(Arg0, Arg1)); } void test_case_3() { string Arg0 = "qwerty"; string Arg1 = "qwerty"; string Arg2 = "Yep, it's wood."; verify_case(3, Arg2, check(Arg0, Arg1)); } void test_case_4() { string Arg0 = "string"; string Arg1 = "longstring"; string Arg2 = "Nope."; verify_case(4, Arg2, check(Arg0, Arg1)); } // END CUT HERE }; // BEGIN CUT HERE int main() { IdentifyingWood ___test; ___test.run_test(-1); system("pause"); return 0; } // END CUT HERE
32.563218
314
0.590187
zombiecry
5edd03f8d20b117cb6d4ddadac1e529de038f59a
548
hh
C++
src/Zynga/CodeBase/V1/File/Functions.hh
isabella232/zynga-hhvm-phpunit
1690b9d5c6c711fde6d908cc84b014fa8e1a7ef0
[ "BSD-3-Clause" ]
3
2018-05-20T11:41:54.000Z
2020-08-20T14:55:09.000Z
src/Zynga/CodeBase/V1/File/Functions.hh
zynga/zynga-hhvm-phpunit
1690b9d5c6c711fde6d908cc84b014fa8e1a7ef0
[ "BSD-3-Clause" ]
1
2021-02-24T01:22:04.000Z
2021-02-24T01:22:04.000Z
src/Zynga/CodeBase/V1/File/Functions.hh
isabella232/zynga-hhvm-phpunit
1690b9d5c6c711fde6d908cc84b014fa8e1a7ef0
[ "BSD-3-Clause" ]
3
2018-07-30T23:04:34.000Z
2021-01-04T11:10:24.000Z
<?hh // strict namespace Zynga\CodeBase\V1\File; use Zynga\CodeBase\V1\File; use Zynga\CodeBase\V1\Code\Code_Method; class Functions { private File $_parent; private Map<string, Code_Method> $_functions; public function __construct(File $parent) { $this->_parent = $parent; $this->_functions = Map {}; } public function add(string $name, Code_Method $method): bool { $this->_functions->set($name, $method); return true; } public function getAll(): Map<string, Code_Method> { return $this->_functions; } }
20.296296
64
0.682482
isabella232
5edf254d52b46d7f901c8a46cdbc0b992d3eda4f
3,242
cxx
C++
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
// Standard library: #include <iostream> #include <fstream> /// Third Party: // - Boost: #include <boost/serialization/nvp.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_iarchive.hpp> // Ourselves: #include <XY/config.hpp> #if BSTCUD_WITH_EOS == 1 #include <eos/portable_oarchive.hpp> #include <eos/portable_iarchive.hpp> #endif // Ourselves: #include <XY/A.hpp> #include <XY/B.hpp> int main(void) { { { std::ofstream file("test_AB.xml"); boost::archive::xml_oarchive oa(file); xy::A * a_ptr = new xy::A(1); xy::A * b_ptr = new xy::B(2, 3); xy::A * b2_ptr = new xy::B(4, 5); std::clog << "a = " << a_ptr->to_string() << std::endl; std::clog << "b = " << b_ptr->to_string() << std::endl; std::clog << "b2 = " << b2_ptr->to_string() << std::endl; std::clog << "Serializing..." << std::endl; oa & BOOST_SERIALIZATION_NVP(a_ptr); oa & BOOST_SERIALIZATION_NVP(b_ptr); oa & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } { std::ifstream file("test_AB.xml"); boost::archive::xml_iarchive ia(file); xy::A * a_ptr = nullptr; xy::A * b_ptr = nullptr; xy::A * b2_ptr = nullptr; std::clog << "Deserializing..." << std::endl; ia & BOOST_SERIALIZATION_NVP(a_ptr); ia & BOOST_SERIALIZATION_NVP(b_ptr); ia & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; std::clog << "loaded a = " << a_ptr->to_string() << std::endl; std::clog << "loaded b = " << b_ptr->to_string() << std::endl; std::clog << "loaded b2 = " << b2_ptr->to_string() << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } } #if BSTCUD_WITH_EOS == 1 { { std::ofstream file("test_AB.data"); eos::portable_oarchive oa(file); xy::A * a_ptr = new xy::A(1); xy::A * b_ptr = new xy::B(2, 3); xy::A * b2_ptr = new xy::B(4, 5); std::clog << "a = " << a_ptr->to_string() << std::endl; std::clog << "b = " << b_ptr->to_string() << std::endl; std::clog << "b2 = " << b2_ptr->to_string() << std::endl; std::clog << "Serializing..." << std::endl; oa & BOOST_SERIALIZATION_NVP(a_ptr); oa & BOOST_SERIALIZATION_NVP(b_ptr); oa & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } { std::ifstream file("test_AB.data"); eos::portable_iarchive ia(file); xy::A * a_ptr = nullptr; xy::A * b_ptr = nullptr; xy::A * b2_ptr = nullptr; std::clog << "Deserializing..." << std::endl; ia & BOOST_SERIALIZATION_NVP(a_ptr); ia & BOOST_SERIALIZATION_NVP(b_ptr); ia & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; std::clog << "loaded a = " << a_ptr->to_string() << std::endl; std::clog << "loaded b = " << b_ptr->to_string() << std::endl; std::clog << "loaded b2 = " << b2_ptr->to_string() << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } } #endif return 0; }
29.472727
70
0.559531
fmauger
5ee0805621a7661148327ddbf1aa332461ddb931
7,268
cpp
C++
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
660
2017-11-21T15:55:52.000Z
2022-03-31T06:31:00.000Z
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
1,070
2017-12-01T00:26:10.000Z
2022-03-31T17:55:26.000Z
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
309
2017-11-30T08:34:09.000Z
2022-03-30T18:52:07.000Z
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ //! //! \file codechal_kernel_hme_g8.cpp //! \brief Hme kernel implementation for Gen8 platform //! #include "codechal_kernel_hme_g8.h" // clang-format off const uint32_t CodechalKernelHmeG8::Curbe::m_initCurbe[39] = { 0x00000000, 0x00200010, 0x00003939, 0x77a43000, 0x00000000, 0x28300000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; // clang-format on CodechalKernelHmeG8::CodechalKernelHmeG8( CodechalEncoderState *encoder, bool me4xDistBufferSupported) : CodechalKernelHme(encoder, me4xDistBufferSupported) { } MOS_STATUS CodechalKernelHmeG8::SetCurbe(MHW_KERNEL_STATE *kernelState) { CODECHAL_ENCODE_CHK_NULL_RETURN(kernelState); Curbe curbe; uint32_t mvShiftFactor = 0; uint32_t prevMvReadPosFactor = 0; uint32_t scaleFactor; bool useMvFromPrevStep; bool writeDistortions; if (m_32xMeInUse) { useMvFromPrevStep = false; writeDistortions = false; scaleFactor = scalingFactor32X; mvShiftFactor = 1; prevMvReadPosFactor = 0; } else if (m_16xMeInUse) { useMvFromPrevStep = Is32xMeEnabled() ? true : false; writeDistortions = false; scaleFactor = scalingFactor16X; mvShiftFactor = 2; prevMvReadPosFactor = 1; } else if (m_4xMeInUse) { useMvFromPrevStep = Is16xMeEnabled() ? true : false; writeDistortions = true; scaleFactor = scalingFactor4X; mvShiftFactor = 2; prevMvReadPosFactor = 0; } else { return MOS_STATUS_INVALID_PARAMETER; } curbe.m_data.DW3.SubPelMode = m_curbeParam.subPelMode; if (m_fieldScalingOutputInterleaved) { curbe.m_data.DW3.SrcAccess = curbe.m_data.DW3.RefAccess = CodecHal_PictureIsField(m_curbeParam.currOriginalPic); curbe.m_data.DW7.SrcFieldPolarity = CodecHal_PictureIsBottomField(m_curbeParam.currOriginalPic); } curbe.m_data.DW4.PictureHeightMinus1 = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameFieldHeight / scaleFactor) - 1; curbe.m_data.DW4.PictureWidth = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameWidth / scaleFactor); curbe.m_data.DW5.QpPrimeY = m_curbeParam.qpPrimeY; curbe.m_data.DW6.WriteDistortions = writeDistortions; curbe.m_data.DW6.UseMvFromPrevStep = useMvFromPrevStep; curbe.m_data.DW6.SuperCombineDist = SuperCombineDist[m_curbeParam.targetUsage]; curbe.m_data.DW6.MaxVmvR = CodecHal_PictureIsFrame(m_curbeParam.currOriginalPic) ? m_curbeParam.maxMvLen * 4 : (m_curbeParam.maxMvLen >> 1) * 4; if (m_pictureCodingType == B_TYPE) { curbe.m_data.DW1.BiWeight = 32; curbe.m_data.DW13.NumRefIdxL1MinusOne = m_curbeParam.numRefIdxL1Minus1; } if (m_pictureCodingType == B_TYPE || m_pictureCodingType == P_TYPE) { curbe.m_data.DW13.NumRefIdxL0MinusOne = m_curbeParam.numRefIdxL0Minus1; } if (!CodecHal_PictureIsFrame(m_curbeParam.currOriginalPic)) { if (m_pictureCodingType != I_TYPE) { curbe.m_data.DW14.List0RefID0FieldParity = m_curbeParam.list0RefID0FieldParity; curbe.m_data.DW14.List0RefID1FieldParity = m_curbeParam.list0RefID1FieldParity; curbe.m_data.DW14.List0RefID2FieldParity = m_curbeParam.list0RefID2FieldParity; curbe.m_data.DW14.List0RefID3FieldParity = m_curbeParam.list0RefID3FieldParity; curbe.m_data.DW14.List0RefID4FieldParity = m_curbeParam.list0RefID4FieldParity; curbe.m_data.DW14.List0RefID5FieldParity = m_curbeParam.list0RefID5FieldParity; curbe.m_data.DW14.List0RefID6FieldParity = m_curbeParam.list0RefID6FieldParity; curbe.m_data.DW14.List0RefID7FieldParity = m_curbeParam.list0RefID7FieldParity; } if (m_pictureCodingType == B_TYPE) { curbe.m_data.DW14.List1RefID0FieldParity = m_curbeParam.list1RefID0FieldParity; curbe.m_data.DW14.List1RefID1FieldParity = m_curbeParam.list1RefID1FieldParity; } } curbe.m_data.DW15.MvShiftFactor = mvShiftFactor; curbe.m_data.DW15.PrevMvReadPosFactor = prevMvReadPosFactor; // r3 & r4 uint8_t methodIndex; if (m_pictureCodingType == B_TYPE) { CODECHAL_ENCODE_CHK_NULL_RETURN(m_bmeMethodTable); methodIndex = m_curbeParam.bmeMethodTable ? m_curbeParam.bmeMethodTable[m_curbeParam.targetUsage] : m_bmeMethodTable[m_curbeParam.targetUsage]; } else { CODECHAL_ENCODE_CHK_NULL_RETURN(m_meMethodTable); methodIndex = m_curbeParam.meMethodTable ? m_curbeParam.meMethodTable[m_curbeParam.targetUsage] : m_meMethodTable[m_curbeParam.targetUsage]; } uint8_t tableIndex = (m_pictureCodingType == B_TYPE) ? 1 : 0; MOS_SecureMemcpy(&curbe.m_data.SpDelta, 14 * sizeof(uint32_t), codechalEncodeSearchPath[tableIndex][methodIndex], 14 * sizeof(uint32_t)); //r5 curbe.m_data.DW32._4xMeMvOutputDataSurfIndex = BindingTableOffset::meOutputMvDataSurface; curbe.m_data.DW33._16xOr32xMeMvInputDataSurfIndex = BindingTableOffset::meInputMvDataSurface; curbe.m_data.DW34._4xMeOutputDistSurfIndex = BindingTableOffset::meDistortionSurface; curbe.m_data.DW35._4xMeOutputBrcDistSurfIndex = BindingTableOffset::meBrcDistortion; curbe.m_data.DW36.VMEFwdInterPredictionSurfIndex = BindingTableOffset::meCurrForFwdRef; curbe.m_data.DW37.VMEBwdInterPredictionSurfIndex = BindingTableOffset::meCurrForBwdRef; CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData(&curbe.m_data, kernelState->dwCurbeOffset, Curbe::m_curbeSize)); return MOS_STATUS_SUCCESS; }
44.048485
160
0.726472
lacc97
5ee2066454a7ab9999491f028bcaa3647abf74df
712
cpp
C++
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
6
2022-01-23T09:40:33.000Z
2022-03-20T20:53:25.000Z
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
null
null
null
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
1
2022-02-06T21:05:23.000Z
2022-02-06T21:05:23.000Z
 #include "cbase.h" #include "vSheets.h" CSheet_CMatrix::CSheet_CMatrix(CBaseNode *pNode, CNodeView *view, KeyValues *data, Panel *parent) : BaseClass(pNode, view, data, parent) { SetParent(parent); m_pCBox_MType = new ComboBox(this, "cbox_mtype", 10, false); for (int i = 0; i < CMATRIX_LAST; i++) m_pCBox_MType->AddItem(GetCMatrixInfo(i)->szCanvasName, NULL); LoadControlSettings("shadereditorui/vgui/sheet_cmatrix.res"); } CSheet_CMatrix::~CSheet_CMatrix() { } void CSheet_CMatrix::OnResetData() { m_pCBox_MType->ActivateItem(pData->GetInt("i_c_matrix")); } void CSheet_CMatrix::OnApplyChanges() { pData->SetInt("i_c_matrix", m_pCBox_MType->GetActiveItem()); }
26.37037
97
0.706461
cstom4994
5ee413f5311948e62f5d3d287c45a4ae742842f4
294
cpp
C++
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
#include <Arduino.h> #include "smarthome\SmartHome.h" #include <SoftwareSerial.h> SmartHome home = SmartHome(); void setup() { // put your setup code here, to run once: Serial.begin(9600); home.init(); } void loop() { // put your main code here, to run repeatedly: home.run(); }
14
48
0.663265
Forsyth-Creations
5ee5dc81098368d12401b468d376fdbe41907e3a
1,223
cpp
C++
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
1
2021-02-08T14:50:50.000Z
2021-02-08T14:50:50.000Z
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
null
null
null
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; void swapFour(int &x, int &y, int &z,int &a) { int temp = x; x = y; y = z; z = a; a = temp; } void printMatrix(vector<vector<int>> A) { for(int i=0;i<A.size();i++) { for(int j=0;j<A[i].size();j++) { cout<<A[i][j]<< " "; } cout<<"\n"; } } void rotate(vector<vector<int>> &A) { int n = A.size(); int *a,*b,*c,*d; // a b // c d for(int i=0;i<n/2;i++) // outer to inner { for(int j=0;j<n-i-1;j++) // stop one before also stay in inner box { // place all pointers at each corner // move a right, c up, d left, b down (spins left side) a = &A[i][i+j]; b = &A[i+j][n-1-i]; c = &A[n-1-i-j][i]; d = &A[n-1-i][n-1-i-j]; swapFour(*a,*b,*d,*c); } } } int main() { vector<vector<int>> A = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,16} }; printMatrix(A); rotate(A); cout<<"\n"; printMatrix(A); return 0; }
20.383333
79
0.376942
ajaybiswas22
5ee6865fad9c2fcf874d70d1c35635e2714cc1d0
6,602
cpp
C++
Framework/Audio/Audio.cpp
dengwenyi88/Deferred_Lighting
b45b6590150a3119b0c2365f4795d93b3b4f0748
[ "MIT" ]
110
2017-06-23T17:12:28.000Z
2022-02-22T19:11:38.000Z
RunTest/Framework3/Audio/Audio.cpp
dtrebilco/ECSAtto
86a04f0bdc521c79f758df94250c1898c39213c8
[ "MIT" ]
null
null
null
RunTest/Framework3/Audio/Audio.cpp
dtrebilco/ECSAtto
86a04f0bdc521c79f758df94250c1898c39213c8
[ "MIT" ]
3
2018-02-12T00:16:18.000Z
2018-02-18T11:12:35.000Z
/* * * * * * * * * * * * * Author's note * * * * * * * * * * * *\ * _ _ _ _ _ _ _ _ _ _ _ _ * * |_| |_| |_| |_| |_|_ _|_| |_| |_| _|_|_|_|_| * * |_|_ _ _|_| |_| |_| |_|_|_|_|_| |_| |_| |_|_ _ _ * * |_|_|_|_|_| |_| |_| |_| |_| |_| |_| |_| |_|_|_|_ * * |_| |_| |_|_ _ _|_| |_| |_| |_|_ _ _|_| _ _ _ _|_| * * |_| |_| |_|_|_| |_| |_| |_|_|_| |_|_|_|_| * * * * http://www.humus.name * * * * This file is a part of the work done by Humus. You are free to * * use the code in any way you like, modified, unmodified or copied * * into your own work. However, I expect you to respect these points: * * - If you use this file and its contents unmodified, or use a major * * part of this file, please credit the author and leave this note. * * - For use in anything commercial, please request my approval. * * - Share your work and ideas too as much as you can. * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "Audio.h" #include <stdio.h> #include "codec.h" #include "vorbisfile.h" #ifdef _WIN32 # pragma comment (lib, "../Framework3/Libs/OpenAL32.lib") # pragma comment (lib, "../Framework3/Libs/alut.lib") # pragma comment (lib, "../Framework3/Libs/ogg_static.lib") # pragma comment (lib, "../Framework3/Libs/vorbis_static.lib") # pragma comment (lib, "../Framework3/Libs/vorbisfile_static.lib") #endif Audio::Audio(){ dev = alcOpenDevice(NULL); ctx = alcCreateContext(dev, NULL); alcMakeContextCurrent(ctx); // alDistanceModel(AL_INVERSE_DISTANCE); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); //alListenerf(AL_GAIN, 0.0f); } Audio::~Audio(){ clear(); alcMakeContextCurrent(NULL); alcDestroyContext(ctx); alcCloseDevice(dev); } void Audio::clear(){ int index = sounds.getCount(); while (index--){ deleteSound(index); } index = soundSources.getCount(); while (index--){ deleteSoundSource(index); } } SoundID Audio::addSound(const char *fileName, unsigned int flags){ Sound sound; // Clear error flag alGetError(); const char *ext = strrchr(fileName, '.') + 1; char str[256]; if (stricmp(ext, "ogg") == 0){ FILE *file = fopen(fileName, "rb"); if (file == NULL){ sprintf(str, "Couldn't open \"%s\"", fileName); ErrorMsg(str); return SOUND_NONE; } OggVorbis_File vf; memset(&vf, 0, sizeof(vf)); if (ov_open(file, &vf, NULL, 0) < 0){ fclose(file); sprintf(str, "\"%s\" is not an ogg file", fileName); ErrorMsg(str); return SOUND_NONE; } vorbis_info *vi = ov_info(&vf, -1); int nSamples = (uint) ov_pcm_total(&vf, -1); int nChannels = vi->channels; sound.format = nChannels == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; sound.sampleRate = vi->rate; sound.size = nSamples * nChannels; sound.samples = new short[sound.size]; sound.size *= sizeof(short); int samplePos = 0; while (samplePos < sound.size){ char *dest = ((char *) sound.samples) + samplePos; int bitStream, readBytes = ov_read(&vf, dest, sound.size - samplePos, 0, 2, 1, &bitStream); if (readBytes <= 0) break; samplePos += readBytes; } ov_clear(&vf); } else { ALboolean al_bool; ALvoid *data; alutLoadWAVFile(fileName, &sound.format, &data, &sound.size, &sound.sampleRate, &al_bool); sound.samples = (short *) data; } alGenBuffers(1, &sound.buffer); alBufferData(sound.buffer, sound.format, sound.samples, sound.size, sound.sampleRate); if (alGetError() != AL_NO_ERROR){ alDeleteBuffers(1, &sound.buffer); sprintf(str, "Couldn't open \"%s\"", fileName); ErrorMsg(str); return SOUND_NONE; } return insertSound(sound); } SoundID Audio::insertSound(Sound &sound){ for (uint i = 0; i < sounds.getCount(); i++){ if (sounds[i].samples == NULL){ sounds[i] = sound; return i; } } return sounds.add(sound); } void Audio::deleteSound(const SoundID sound){ if (sounds[sound].samples){ alDeleteBuffers(1, &sounds[sound].buffer); alutUnloadWAV(sounds[sound].format, sounds[sound].samples, sounds[sound].size, sounds[sound].sampleRate); //delete sound.samples; sounds[sound].samples = NULL; } } SoundSourceID Audio::addSoundSource(const SoundID sound, uint flags){ SoundSrc soundSource; soundSource.sound = sound; alGenSources(1, &soundSource.source); alSourcei(soundSource.source, AL_LOOPING, (flags & LOOPING)? AL_TRUE : AL_FALSE); alSourcei(soundSource.source, AL_SOURCE_RELATIVE, (flags & RELATIVEPOS)? AL_TRUE : AL_FALSE); alSourcei(soundSource.source, AL_BUFFER, sounds[sound].buffer); alSourcef(soundSource.source, AL_MIN_GAIN, 0.0f); alSourcef(soundSource.source, AL_MAX_GAIN, 1.0f); return insertSoundSource(soundSource); } SoundID Audio::insertSoundSource(SoundSrc &source){ for (uint i = 0; i < soundSources.getCount(); i++){ if (soundSources[i].sound == SOUND_NONE){ soundSources[i] = source; return i; } } return soundSources.add(source); } void Audio::deleteSoundSource(const SoundSourceID source){ if (soundSources[source].sound != SOUND_NONE){ alDeleteSources(1, &soundSources[source].source); soundSources[source].sound = SOUND_NONE; } } void Audio::play(const SoundSourceID source){ alSourcePlay(soundSources[source].source); } void Audio::stop(const SoundSourceID source){ alSourceStop(soundSources[source].source); } void Audio::pause(const SoundSourceID source){ alSourcePause(soundSources[source].source); } bool Audio::isPlaying(const SoundSourceID source){ ALint state; alGetSourcei(soundSources[source].source, AL_SOURCE_STATE, &state); return (state == AL_PLAYING); } void Audio::setListenerOrientation(const vec3 &position, const vec3 &zDir){ alListenerfv(AL_POSITION, position); float orient[] = { zDir.x, zDir.y, zDir.z, 0, -1, 0 }; alListenerfv(AL_ORIENTATION, orient); } void Audio::setSourceGain(const SoundSourceID source, const float gain){ alSourcef(soundSources[source].source, AL_GAIN, gain); } void Audio::setSourcePosition(const SoundSourceID source, const vec3 &position){ alSourcefv(soundSources[source].source, AL_POSITION, position); } void Audio::setSourceAttenuation(const SoundSourceID source, const float rollOff, const float refDistance){ alSourcef(soundSources[source].source, AL_REFERENCE_DISTANCE, refDistance); alSourcef(soundSources[source].source, AL_ROLLOFF_FACTOR, rollOff); }
29.212389
107
0.642684
dengwenyi88
5ee81ea9b33246e8e0912bb59182c86a6f510bbc
4,345
cpp
C++
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
135
2021-05-06T04:03:27.000Z
2022-03-31T01:34:03.000Z
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
17
2021-05-10T06:44:54.000Z
2022-03-07T09:00:43.000Z
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
33
2021-05-05T16:12:17.000Z
2022-03-22T07:56:26.000Z
#include "VGG.h" torch::nn::Sequential make_features(std::vector<int> &cfg, bool batch_norm) { torch::nn::Sequential features; int in_channels = 3; for (auto v : cfg) { if (v == -1) { features->push_back(torch::nn::MaxPool2d(maxpool_options(2, 2))); } else { auto conv2d = torch::nn::Conv2d(conv_options(in_channels, v, 3, 1, 1)); features->push_back(conv2d); if (batch_norm) { features->push_back(torch::nn::BatchNorm2d(torch::nn::BatchNorm2dOptions(v))); } features->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); in_channels = v; } } return features; } VGGImpl::VGGImpl(std::vector<int> _cfg, int num_classes, bool batch_norm_) { cfg = _cfg; batch_norm = batch_norm_; features_ = make_features(cfg, batch_norm); avgpool = torch::nn::AdaptiveAvgPool2d(torch::nn::AdaptiveAvgPool2dOptions(7)); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(512 * 7 * 7, 4096))); classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); classifier->push_back(torch::nn::Dropout()); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, 4096))); classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); classifier->push_back(torch::nn::Dropout()); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, num_classes))); features_ = register_module("features", features_); classifier = register_module("classifier", classifier); } torch::Tensor VGGImpl::forward(torch::Tensor x) { x = features_->forward(x); x = avgpool(x); x = torch::flatten(x, 1); x = classifier->forward(x); return torch::log_softmax(x, 1); } std::vector<torch::Tensor> VGGImpl::features(torch::Tensor x, int encoder_depth) { std::vector<torch::Tensor> ans; int j = 0;// layer index of features_ for (int i = 0; i < cfg.size(); i++) { if (cfg[i] == -1) { ans.push_back(x); if (ans.size() == encoder_depth ) { break; } x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); } else { x = this->features_[j++]->as<torch::nn::Conv2d>()->forward(x); if (batch_norm) { x = this->features_[j++]->as<torch::nn::BatchNorm2d>()->forward(x); } x = this->features_[j++]->as<torch::nn::ReLU>()->forward(x); } } if (ans.size() == encoder_depth && encoder_depth==5) { x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); ans.push_back(x); } return ans; } torch::Tensor VGGImpl::features_at(torch::Tensor x, int stage_num) { assert(stage_num > 0 && stage_num <=5 && "the stage number must in range[1,5]"); int j = 0; int stage_count = 0; for (int i = 0; i < cfg.size(); i++) { if (cfg[i] == -1) { x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); stage_count++; if (stage_count == stage_num) return x; } else { x = this->features_[j++]->as<torch::nn::Conv2d>()->forward(x); if (batch_norm) { x = this->features_[j++]->as<torch::nn::BatchNorm2d>()->forward(x); } x = this->features_[j++]->as<torch::nn::ReLU>()->forward(x); } } return x; } void VGGImpl::load_pretrained(std::string pretrained_path) { VGG net_pretrained = VGG(cfg, 1000, batch_norm); torch::load(net_pretrained, pretrained_path); torch::OrderedDict<std::string, at::Tensor> pretrained_dict = net_pretrained->named_parameters(); torch::OrderedDict<std::string, at::Tensor> model_dict = this->named_parameters(); for (auto n = pretrained_dict.begin(); n != pretrained_dict.end(); n++) { if (strstr((*n).key().data(), "classifier.")) { continue; } model_dict[(*n).key()] = (*n).value(); } torch::autograd::GradMode::set_enabled(false); // make parameters copying possible auto new_params = model_dict; // implement this auto params = this->named_parameters(true /*recurse*/); auto buffers = this->named_buffers(true /*recurse*/); for (auto& val : new_params) { auto name = val.key(); auto* t = params.find(name); if (t != nullptr) { t->copy_(val.value()); } else { t = buffers.find(name); if (t != nullptr) { t->copy_(val.value()); } } } torch::autograd::GradMode::set_enabled(true); return; } void VGGImpl::make_dilated(std::vector<int> stage_list, std::vector<int> dilation_list) { std::cout<< "'VGG' models do not support dilated mode due to Max Pooling operations for downsampling!"; return; }
31.035714
104
0.653855
0x0000dead
5eeefc8955a126639d411835065af8b4d429f63d
244,816
cc
C++
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
61
2020-03-17T12:30:11.000Z
2022-03-01T18:59:11.000Z
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
12
2020-03-24T15:46:54.000Z
2022-01-08T02:03:31.000Z
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
19
2020-03-16T17:32:09.000Z
2022-03-29T23:35:31.000Z
//============================================================================== // Copyright (c) 2010-2021 Advanced Micro Devices, Inc. All rights reserved. /// @author AMD Developer Tools Team /// @file /// @brief Public Counter Definitions for DX12 GFX8. //============================================================================== #include "gpu_perf_api_counter_generator/gpa_counter.h" #include "auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.h" // *** Note, this is an auto-generated file. Do not edit. Execute PublicCounterCompiler to rebuild. void AutoDefinePublicDerivedCountersDx12Gfx8(GpaDerivedCounters& c) { { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); c.DefineDerivedCounter("GPUTime", "Timing", "Time this API command took to execute on the GPU in nanoseconds from the time the previous command reached the bottom of the pipeline (BOP) to the time this command reaches the bottom of the pipeline (BOP). Does not include time that draw calls are processed in parallel.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "cbd338f2-de6c-7b14-92ad-ba724ca2e501"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51134); c.DefineDerivedCounter("ExecutionDuration", "Timing", "GPU command execution duration in nanoseconds, from the time the command enters the top of the pipeline (TOP) to the time the command reaches the bottom of the pipeline (BOP). Does not include time that draw calls are processed in parallel.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "b2f08d0d-af13-cd66-d3b4-b290ad448e69"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51135); c.DefineDerivedCounter("ExecutionStart", "Timing", "GPU command execution start time in nanoseconds. This is the time the command enters the top of the pipeline (TOP).", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "a368f79d-fcfe-2158-71c4-2f0c4eef5aa4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51136); c.DefineDerivedCounter("ExecutionEnd", "Timing", "GPU command execution end time in nanoseconds. This is the time the command reaches the bottom of the pipeline (BOP).", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "0bce206a-0976-06a2-bf20-03fb351035a8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(49743); internal_counters.push_back(49741); c.DefineDerivedCounter("GPUBusy", "Timing", "The percentage of time GPU was busy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,/,(100),*,(100),min", "bef38bf3-1167-0844-81f0-67d2d28ddbc5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(49743); c.DefineDerivedCounter("GPUBusyCycles", "Timing", "Number of GPU cycles that the GPU was busy.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0", "1e84970d-7014-2b8d-d61e-388b5f782691"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(191); internal_counters.push_back(338); internal_counters.push_back(485); internal_counters.push_back(632); internal_counters.push_back(49743); c.DefineDerivedCounter("TessellatorBusy", "Timing", "The percentage of time the tessellation engine is busy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,/,(100),*", "36af6c72-dcfb-8102-4fd4-ce8ddc573365"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(191); internal_counters.push_back(338); internal_counters.push_back(485); internal_counters.push_back(632); c.DefineDerivedCounter("TessellatorBusyCycles", "Timing", "Number of GPU cycles that the tessellation engine is busy.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max", "60289dcb-7b33-46e7-26d1-8a2121605543"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("VSBusy", "Timing", "The percentage of time the ShaderUnit has vertex shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,16,ifnotzero,4,20,ifnotzero,8,24,ifnotzero,(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,max,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max,28,/,(100),*,(100),min", "94caad5e-867c-6c09-cf3a-d05b51df8f3b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); c.DefineDerivedCounter("VSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has vertex shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,16,ifnotzero,4,20,ifnotzero,8,24,ifnotzero,(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,max,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max", "a2086d4e-274b-48a8-3e08-a4ab76ac15dd"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("VSTime", "Timing", "Time vertex shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max,(0),4,20,ifnotzero,8,24,ifnotzero,12,28,ifnotzero,max,29,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "d6ce819e-69af-a241-d07a-5dd8d146e436"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); internal_counters.push_back(49743); c.DefineDerivedCounter("HSBusy", "Timing", "The percentage of time the ShaderUnit has hull shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*,(100),min", "16f30a0b-4cbf-eccd-b13f-ab68dd254d32"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); c.DefineDerivedCounter("HSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has hull shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "753e76ef-8ef8-3f13-b511-4bd9f3589fdb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); internal_counters.push_back(49743); c.DefineDerivedCounter("HSTime", "Timing", "Time hull shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "8386a863-dd34-1526-f703-0f0c7b241bc4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("DSBusy", "Timing", "The percentage of time the ShaderUnit has domain shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,12,ifnotzero,16,ifnotzero,(0),1,5,13,ifnotzero,17,ifnotzero,max,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max,20,/,(100),*,(100),min", "0c626e8a-9b82-b6d4-d9a3-578509316301"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); c.DefineDerivedCounter("DSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has domain shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,12,ifnotzero,16,ifnotzero,(0),1,5,13,ifnotzero,17,ifnotzero,max,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max", "2f3f7561-0549-2232-536d-129ffc5f7703"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("DSTime", "Timing", "Time domain shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,13,ifnotzero,17,ifnotzero,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max,(0),4,8,16,ifnotzero,20,ifnotzero,max,21,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "bfe28947-c727-8a9f-aa59-c218e58bfba5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); internal_counters.push_back(49743); c.DefineDerivedCounter("GSBusy", "Timing", "The percentage of time the ShaderUnit has geometry shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*,(100),min", "876f36d8-d046-833f-7832-673cbffd0a45"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); c.DefineDerivedCounter("GSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has geometry shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "48203b6b-8983-c067-d63e-05da8be5111b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); internal_counters.push_back(49743); c.DefineDerivedCounter("GSTime", "Timing", "Time geometry shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "c73e715f-59af-76e8-9e22-097b94c066c4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); internal_counters.push_back(49743); c.DefineDerivedCounter("PSBusy", "Timing", "The percentage of time the ShaderUnit has pixel shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*", "7e772beb-d82c-bd9a-aed0-fe504d416ce5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); c.DefineDerivedCounter("PSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has pixel shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "b58bea04-ce8e-2984-80f4-8aba7d4c817b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); internal_counters.push_back(49743); c.DefineDerivedCounter("PSTime", "Timing", "Time pixel shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,0,TS_FREQ,/,(1000000000),*,*", "edca7694-7416-e8a6-0c5a-63a5ad5f3d74"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); internal_counters.push_back(49743); c.DefineDerivedCounter("CSBusy", "Timing", "The percentage of time the ShaderUnit has compute shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,comparemax4,8,9,10,11,12,13,14,15,comparemax4,max,16,/,(100),*,(100),min", "493fdd90-8d2b-a055-5e4e-2d29c3396b8c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); c.DefineDerivedCounter("CSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has compute shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,comparemax4,8,9,10,11,12,13,14,15,comparemax4,max", "39bcf1b8-f6b2-4c37-f9af-0a2bb59512f9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); internal_counters.push_back(49743); c.DefineDerivedCounter("CSTime", "Timing", "Time compute shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "1,2,3,4,5,6,7,8,comparemax4,9,10,11,12,13,14,15,16,comparemax4,max,17,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "dbc24916-ecb2-7eef-8d63-7afadaaab6bc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); internal_counters.push_back(163); internal_counters.push_back(310); internal_counters.push_back(457); internal_counters.push_back(604); c.DefineDerivedCounter("VSVerticesIn", "VertexShader", "The number of vertices processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,4,5,6,7,sum4,ifnotzero,8,9,10,11,sum4,8,9,10,11,sum4,ifnotzero", "810a04c8-2ff4-081d-766d-bfa2bd4ad916"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7257); internal_counters.push_back(7556); internal_counters.push_back(7855); internal_counters.push_back(8154); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4865); internal_counters.push_back(5164); internal_counters.push_back(5463); internal_counters.push_back(5762); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9649); internal_counters.push_back(9948); internal_counters.push_back(10247); internal_counters.push_back(10546); internal_counters.push_back(9627); internal_counters.push_back(9926); internal_counters.push_back(10225); internal_counters.push_back(10524); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUInstCount", "VertexShader", "Average number of vector ALU instructions executed in the VS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,24,25,26,27,sum4,/,28,29,30,31,sum4,ifnotzero", "8ec604e4-63f5-e6b5-4558-c38f0b26d4b1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7261); internal_counters.push_back(7560); internal_counters.push_back(7859); internal_counters.push_back(8158); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4869); internal_counters.push_back(5168); internal_counters.push_back(5467); internal_counters.push_back(5766); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9653); internal_counters.push_back(9952); internal_counters.push_back(10251); internal_counters.push_back(10550); internal_counters.push_back(9627); internal_counters.push_back(9926); internal_counters.push_back(10225); internal_counters.push_back(10524); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUInstCount", "VertexShader", "Average number of scalar ALU instructions executed in the VS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,24,25,26,27,sum4,/,28,29,30,31,sum4,ifnotzero", "e3da0383-7322-7f65-8cf2-3ce641578e54"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(49743); internal_counters.push_back(9704); internal_counters.push_back(10003); internal_counters.push_back(10302); internal_counters.push_back(10601); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUBusy", "VertexShader", "The percentage of GPUTime vector ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,13,14,15,16,sum4,17,18,19,20,sum4,ifnotzero,(4),*,NUM_SIMDS,/,12,/,(100),*", "8b3572f7-fda0-eddf-6c93-2ab145b8754b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9704); internal_counters.push_back(10003); internal_counters.push_back(10302); internal_counters.push_back(10601); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUBusyCycles", "VertexShader", "Number of GPU cycles where vector ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,16,17,18,19,sum4,ifnotzero,(4),*,NUM_SIMDS,/", "0af1686e-6d77-2f6e-2862-7bb8e869a776"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(49743); internal_counters.push_back(9709); internal_counters.push_back(10008); internal_counters.push_back(10307); internal_counters.push_back(10606); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUBusy", "VertexShader", "The percentage of GPUTime scalar ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,13,14,15,16,sum4,17,18,19,20,sum4,ifnotzero,NUM_CUS,/,12,/,(100),*", "3bc8730c-e3bc-e2f0-7d24-36974064c25a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9709); internal_counters.push_back(10008); internal_counters.push_back(10307); internal_counters.push_back(10606); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUBusyCycles", "VertexShader", "Number of GPU cycles where scalar ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,16,17,18,19,sum4,ifnotzero,NUM_CUS,/", "357ac7cd-2e1c-dcb0-77f6-37527237f35b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(172); internal_counters.push_back(319); internal_counters.push_back(466); internal_counters.push_back(613); c.DefineDerivedCounter("HSPatches", "HullShader", "The number of patches processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "d1bbd27d-d591-4509-df52-d329fb73a98f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10845); internal_counters.push_back(11144); internal_counters.push_back(11443); internal_counters.push_back(11742); internal_counters.push_back(10823); internal_counters.push_back(11122); internal_counters.push_back(11421); internal_counters.push_back(11720); c.DefineDerivedCounter("HSVALUInstCount", "HullShader", "Average number of vector ALU instructions executed in the HS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "786673bf-d58f-9895-3a37-9d6efb5e5804"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10849); internal_counters.push_back(11148); internal_counters.push_back(11447); internal_counters.push_back(11746); internal_counters.push_back(10823); internal_counters.push_back(11122); internal_counters.push_back(11421); internal_counters.push_back(11720); c.DefineDerivedCounter("HSSALUInstCount", "HullShader", "Average number of scalar ALU instructions executed in the HS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "1af675c4-cb0b-c4c5-c131-2796750f683e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10900); internal_counters.push_back(11199); internal_counters.push_back(11498); internal_counters.push_back(11797); internal_counters.push_back(49743); c.DefineDerivedCounter("HSVALUBusy", "HullShader", "The percentage of GPUTime vector ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "7880d192-8015-0311-d43e-fb0b7a4df179"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10900); internal_counters.push_back(11199); internal_counters.push_back(11498); internal_counters.push_back(11797); c.DefineDerivedCounter("HSVALUBusyCycles", "HullShader", "Number of GPU cycles vector where ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "3afb94e4-e937-5730-0cc9-41d3113ba012"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10905); internal_counters.push_back(11204); internal_counters.push_back(11503); internal_counters.push_back(11802); internal_counters.push_back(49743); c.DefineDerivedCounter("HSSALUBusy", "HullShader", "The percentage of GPUTime scalar ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "34748a4b-9148-0b06-b7b9-5700d6631bde"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10905); internal_counters.push_back(11204); internal_counters.push_back(11503); internal_counters.push_back(11802); c.DefineDerivedCounter("HSSALUBusyCycles", "HullShader", "Number of GPU cycles where scalar ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "9bceabf7-3f01-2fd9-7b1d-8fe46c729efc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); internal_counters.push_back(163); internal_counters.push_back(310); internal_counters.push_back(457); internal_counters.push_back(604); c.DefineDerivedCounter("DSVerticesIn", "DomainShader", "The number of vertices processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,4,5,6,7,sum4,ifnotzero,8,9,10,11,sum4,ifnotzero", "b88d9d05-2418-e639-4e3d-3a5815855f8d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7257); internal_counters.push_back(7556); internal_counters.push_back(7855); internal_counters.push_back(8154); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4865); internal_counters.push_back(5164); internal_counters.push_back(5463); internal_counters.push_back(5762); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUInstCount", "DomainShader", "Average number of vector ALU instructions executed in the DS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,ifnotzero", "03a3e949-82f9-be4d-7228-5eb5ad80915a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7261); internal_counters.push_back(7560); internal_counters.push_back(7859); internal_counters.push_back(8158); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4869); internal_counters.push_back(5168); internal_counters.push_back(5467); internal_counters.push_back(5766); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUInstCount", "DomainShader", "Average number of scalar ALU instructions executed in the DS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,ifnotzero", "73daa728-483e-95d0-5b40-504719aadc1c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(49743); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUBusy", "DomainShader", "The percentage of GPUTime vector ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,9,10,11,12,sum4,ifnotzero,13,14,15,16,sum4,ifnotzero,(4),*,NUM_SIMDS,/,8,/,(100),*", "ddc0dd0c-0c73-b831-a410-cfea8b9713d9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUBusyCycles", "DomainShader", "Number of GPU cycles where vector ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,ifnotzero,(4),*,NUM_SIMDS,/", "1e280912-81ee-a684-823b-94c468d8ebda"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(49743); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUBusy", "DomainShader", "The percentage of GPUTime scalar ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,9,10,11,12,sum4,ifnotzero,13,14,15,16,sum4,ifnotzero,NUM_CUS,/,8,/,(100),*", "b639f64c-24af-348f-6439-43c701b4fc07"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUBusyCycles", "DomainShader", "Number of GPU cycles where scalar ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,ifnotzero,NUM_CUS,/", "b5bf8a0c-e682-1aa6-23d7-c6c6784ffa5c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(76); internal_counters.push_back(223); internal_counters.push_back(370); internal_counters.push_back(517); c.DefineDerivedCounter("GSPrimsIn", "GeometryShader", "The number of primitives passed into the GS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "20c29866-509a-aaab-2697-6b2c38f79953"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); c.DefineDerivedCounter("GSVerticesOut", "GeometryShader", "The number of vertices output by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,ifnotzero", "775b9736-319a-bd8a-48c9-68db9c91d978"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6061); internal_counters.push_back(6360); internal_counters.push_back(6659); internal_counters.push_back(6958); internal_counters.push_back(6039); internal_counters.push_back(6338); internal_counters.push_back(6637); internal_counters.push_back(6936); c.DefineDerivedCounter("GSVALUInstCount", "GeometryShader", "Average number of vector ALU instructions executed in the GS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "21b12bfa-b8cd-2e71-a2d5-f9e9f1d65d61"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6065); internal_counters.push_back(6364); internal_counters.push_back(6663); internal_counters.push_back(6962); internal_counters.push_back(6039); internal_counters.push_back(6338); internal_counters.push_back(6637); internal_counters.push_back(6936); c.DefineDerivedCounter("GSSALUInstCount", "GeometryShader", "Average number of scalar ALU instructions executed in the GS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "a8562594-d335-ca43-61bf-03b72d2b98a5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6116); internal_counters.push_back(6415); internal_counters.push_back(6714); internal_counters.push_back(7013); internal_counters.push_back(49743); c.DefineDerivedCounter("GSVALUBusy", "GeometryShader", "The percentage of GPUTime vector ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "228a4818-1e56-cebb-0720-3b2cdc057a6f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6116); internal_counters.push_back(6415); internal_counters.push_back(6714); internal_counters.push_back(7013); c.DefineDerivedCounter("GSVALUBusyCycles", "GeometryShader", "Number of GPU cycles where vector ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "be217edd-226f-bd97-9a48-46e2809b1933"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6121); internal_counters.push_back(6420); internal_counters.push_back(6719); internal_counters.push_back(7018); internal_counters.push_back(49743); c.DefineDerivedCounter("GSSALUBusy", "GeometryShader", "The percentage of GPUTime scalar ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "f28ce300-800e-9822-39e4-f48528bdb935"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6121); internal_counters.push_back(6420); internal_counters.push_back(6719); internal_counters.push_back(7018); c.DefineDerivedCounter("GSSALUBusyCycles", "GeometryShader", "Number of GPU cycles where scalar ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "b3eace7c-3bc4-0107-887f-923851dc8ea7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(760); internal_counters.push_back(913); internal_counters.push_back(1066); internal_counters.push_back(1219); internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(716); internal_counters.push_back(869); internal_counters.push_back(1022); internal_counters.push_back(1175); internal_counters.push_back(728); internal_counters.push_back(881); internal_counters.push_back(1034); internal_counters.push_back(1187); internal_counters.push_back(717); internal_counters.push_back(870); internal_counters.push_back(1023); internal_counters.push_back(1176); internal_counters.push_back(729); internal_counters.push_back(882); internal_counters.push_back(1035); internal_counters.push_back(1188); internal_counters.push_back(49743); c.DefineDerivedCounter("PrimitiveAssemblyBusy", "Timing", "The percentage of GPUTime that primitive assembly (clipping and culling) is busy. High values may be caused by having many small primitives; mid to low values may indicate pixel shader or output buffer bottleneck.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,4,-,8,12,+,16,+,20,(2),*,+,SU_CLOCKS_PRIM,*,-,1,5,-,9,13,+,17,+,21,(2),*,+,SU_CLOCKS_PRIM,*,-,max,2,6,-,10,14,+,18,+,22,(2),*,+,SU_CLOCKS_PRIM,*,-,max,3,7,-,11,15,+,19,+,23,(2),*,+,SU_CLOCKS_PRIM,*,-,max,(0),max,24,/,(100),*,(100),min", "54ac5640-c4d7-95e2-20e0-6a9fdfc07333"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(760); internal_counters.push_back(913); internal_counters.push_back(1066); internal_counters.push_back(1219); internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(716); internal_counters.push_back(869); internal_counters.push_back(1022); internal_counters.push_back(1175); internal_counters.push_back(728); internal_counters.push_back(881); internal_counters.push_back(1034); internal_counters.push_back(1187); internal_counters.push_back(717); internal_counters.push_back(870); internal_counters.push_back(1023); internal_counters.push_back(1176); internal_counters.push_back(729); internal_counters.push_back(882); internal_counters.push_back(1035); internal_counters.push_back(1188); c.DefineDerivedCounter("PrimitiveAssemblyBusyCycles", "Timing", "Number of GPU cycles the primitive assembly (clipping and culling) is busy. High values may be caused by having many small primitives; mid to low values may indicate pixel shader or output buffer bottleneck.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,4,-,8,12,+,16,+,20,(2),*,+,SU_CLOCKS_PRIM,*,-,1,5,-,9,13,+,17,+,21,(2),*,+,SU_CLOCKS_PRIM,*,-,max,2,6,-,10,14,+,18,+,22,(2),*,+,SU_CLOCKS_PRIM,*,-,max,3,7,-,11,15,+,19,+,23,(2),*,+,SU_CLOCKS_PRIM,*,-,max,(0),max", "99777f2d-9626-c78a-a97c-c4505eba1e5f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(663); internal_counters.push_back(816); internal_counters.push_back(969); internal_counters.push_back(1122); c.DefineDerivedCounter("PrimitivesIn", "PrimitiveAssembly", "The number of primitives received by the hardware. This includes primitives generated by tessellation.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "a515b80d-75c3-c7d2-0d2f-d7766b4759a6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(669); internal_counters.push_back(822); internal_counters.push_back(975); internal_counters.push_back(1128); internal_counters.push_back(709); internal_counters.push_back(862); internal_counters.push_back(1015); internal_counters.push_back(1168); internal_counters.push_back(710); internal_counters.push_back(863); internal_counters.push_back(1016); internal_counters.push_back(1169); internal_counters.push_back(711); internal_counters.push_back(864); internal_counters.push_back(1017); internal_counters.push_back(1170); internal_counters.push_back(712); internal_counters.push_back(865); internal_counters.push_back(1018); internal_counters.push_back(1171); c.DefineDerivedCounter("CulledPrims", "PrimitiveAssembly", "The number of culled primitives. Typical reasons include scissor, the primitive having zero area, and back or front face culling.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,+,2,+,3,+,4,+,5,+,6,+,7,+,8,+,9,+,10,+,11,+,12,+,13,+,14,+,15,+,16,+,17,+,18,+,19,+", "589bdf55-9192-280a-41c3-584bc94f2562"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(676); internal_counters.push_back(829); internal_counters.push_back(982); internal_counters.push_back(1135); c.DefineDerivedCounter("ClippedPrims", "PrimitiveAssembly", "The number of primitives that required one or more clipping operations due to intersecting the view volume or user clip planes.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "5ef6f9d5-155e-5baa-163f-8359d9ea9bbf"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(49743); c.DefineDerivedCounter("PAStalledOnRasterizer", "PrimitiveAssembly", "Percentage of GPUTime that primitive assembly waits for rasterization to be ready to accept data. This roughly indicates for what percentage of time the pipeline is bottlenecked by pixel operations.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,/,(100),*", "6f9f416b-53c1-0457-f88c-7b6ba8973974"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); c.DefineDerivedCounter("PAStalledOnRasterizerCycles", "PrimitiveAssembly", "Number of GPU cycles the primitive assembly waits for rasterization to be ready to accept data. Indicates the number of GPU cycles the pipeline is bottlenecked by pixel operations.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max", "7a8c492a-c566-9328-6805-760dbff5c0f2"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13223); internal_counters.push_back(13257); internal_counters.push_back(13291); internal_counters.push_back(13325); internal_counters.push_back(13228); internal_counters.push_back(13262); internal_counters.push_back(13296); internal_counters.push_back(13330); internal_counters.push_back(13233); internal_counters.push_back(13267); internal_counters.push_back(13301); internal_counters.push_back(13335); internal_counters.push_back(13238); internal_counters.push_back(13272); internal_counters.push_back(13306); internal_counters.push_back(13340); c.DefineDerivedCounter("PSPixelsOut", "PixelShader", "Pixels exported from shader to color buffers. Does not include killed or alpha tested pixels; if there are multiple render targets, each render target receives one export, so this will be 2 for 1 pixel written to two RTs.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,12,13,14,15,sum4,sum4", "24cba16c-baa6-6ecd-95ad-92ecb1338da1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13225); internal_counters.push_back(13259); internal_counters.push_back(13293); internal_counters.push_back(13327); internal_counters.push_back(13230); internal_counters.push_back(13264); internal_counters.push_back(13298); internal_counters.push_back(13332); internal_counters.push_back(13235); internal_counters.push_back(13269); internal_counters.push_back(13303); internal_counters.push_back(13337); internal_counters.push_back(13240); internal_counters.push_back(13274); internal_counters.push_back(13308); internal_counters.push_back(13342); internal_counters.push_back(49743); c.DefineDerivedCounter("PSExportStalls", "PixelShader", "Pixel shader output stalls. Percentage of GPUBusy. Should be zero for PS or further upstream limited cases; if not zero, indicates a bottleneck in late Z testing or in the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,max,5,max,6,max,7,max,8,max,9,max,10,max,11,max,12,max,13,max,14,max,15,max,16,/,(100),*", "9b4f466c-ff97-22bb-557d-84d3c4c51895"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13225); internal_counters.push_back(13259); internal_counters.push_back(13293); internal_counters.push_back(13327); internal_counters.push_back(13230); internal_counters.push_back(13264); internal_counters.push_back(13298); internal_counters.push_back(13332); internal_counters.push_back(13235); internal_counters.push_back(13269); internal_counters.push_back(13303); internal_counters.push_back(13337); internal_counters.push_back(13240); internal_counters.push_back(13274); internal_counters.push_back(13308); internal_counters.push_back(13342); c.DefineDerivedCounter("PSExportStallsCycles", "PixelShader", "Number of GPU cycles the pixel shader output stalls. Should be zero for PS or further upstream limited cases; if not zero, indicates a bottleneck in late Z testing or in the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max,4,max,5,max,6,max,7,max,8,max,9,max,10,max,11,max,12,max,13,max,14,max,15,max", "47c72aad-64e6-0864-d533-d8e0bc27c156"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8453); internal_counters.push_back(8752); internal_counters.push_back(9051); internal_counters.push_back(9350); internal_counters.push_back(8431); internal_counters.push_back(8730); internal_counters.push_back(9029); internal_counters.push_back(9328); c.DefineDerivedCounter("PSVALUInstCount", "PixelShader", "Average number of vector ALU instructions executed in the PS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "eb74389e-435c-4137-ecf1-39eb5bc1cbfe"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8457); internal_counters.push_back(8756); internal_counters.push_back(9055); internal_counters.push_back(9354); internal_counters.push_back(8431); internal_counters.push_back(8730); internal_counters.push_back(9029); internal_counters.push_back(9328); c.DefineDerivedCounter("PSSALUInstCount", "PixelShader", "Average number of scalar ALU instructions executed in the PS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "e6a06580-8a82-96d6-976c-acc121fc5516"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8508); internal_counters.push_back(8807); internal_counters.push_back(9106); internal_counters.push_back(9405); internal_counters.push_back(49743); c.DefineDerivedCounter("PSVALUBusy", "PixelShader", "The percentage of GPUTime vector ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "6ce6fef7-8e33-10b4-f351-af755e177e85"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8508); internal_counters.push_back(8807); internal_counters.push_back(9106); internal_counters.push_back(9405); c.DefineDerivedCounter("PSVALUBusyCycles", "PixelShader", "Number of GPU cycles where vector ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "1e276f86-cd2a-72e7-fc9d-004f666f2981"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8513); internal_counters.push_back(8812); internal_counters.push_back(9111); internal_counters.push_back(9410); internal_counters.push_back(49743); c.DefineDerivedCounter("PSSALUBusy", "PixelShader", "The percentage of GPUTime scalar ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "2ff9f34f-e94b-af4d-18c2-5fbbf6d1727a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8513); internal_counters.push_back(8812); internal_counters.push_back(9111); internal_counters.push_back(9410); c.DefineDerivedCounter("PSSALUBusyCycles", "PixelShader", "Number of GPU cycles where scalar ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "29808906-f128-b078-fc79-820a4b3b3b8d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSThreadGroups", "ComputeShader", "Total number of thread groups.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,sum8", "8ce3fc80-56b2-97f9-8e70-2e8c747cea68"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); c.DefineDerivedCounter("CSWavefronts", "ComputeShader", "The total number of wavefronts used for the CS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,sum8", "42379c6e-369b-c237-8b25-cdb9cdc65c4d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); internal_counters.push_back(12029); internal_counters.push_back(12328); internal_counters.push_back(12627); internal_counters.push_back(12926); c.DefineDerivedCounter("CSThreads", "ComputeShader", "The number of CS threads processed by the hardware.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,4,5,6,7,sum8,8,9,10,11,sum4,ifnotzero", "7a648013-6eac-2665-ac36-13c6f4ac9c26"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12041); internal_counters.push_back(12340); internal_counters.push_back(12639); internal_counters.push_back(12938); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUInsts", "ComputeShader", "The average number of vector ALU instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "376cb1cc-5a40-9d1d-404c-f1736c0c5084"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12104); internal_counters.push_back(12403); internal_counters.push_back(12702); internal_counters.push_back(13001); internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUUtilization", "ComputeShader", "The percentage of active vector ALU threads in a wave. A lower number can mean either more thread divergence in a wave or that the work-group size is not a multiple of 64. Value range: 0% (bad), 100% (ideal - no thread divergence).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,(64),*,/,(100),*,8,9,10,11,12,13,14,15,sum8,ifnotzero,(100),min", "4476879e-cdc0-d602-b24e-9b4a8d38438f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12045); internal_counters.push_back(12344); internal_counters.push_back(12643); internal_counters.push_back(12942); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUInsts", "ComputeShader", "The average number of scalar ALU instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "eb211144-8136-ff86-e8bf-4d0493a904cb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12043); internal_counters.push_back(12342); internal_counters.push_back(12641); internal_counters.push_back(12940); internal_counters.push_back(13448); internal_counters.push_back(13567); internal_counters.push_back(13686); internal_counters.push_back(13805); internal_counters.push_back(13924); internal_counters.push_back(14043); internal_counters.push_back(14162); internal_counters.push_back(14281); internal_counters.push_back(14400); internal_counters.push_back(14519); internal_counters.push_back(14638); internal_counters.push_back(14757); internal_counters.push_back(14876); internal_counters.push_back(14995); internal_counters.push_back(15114); internal_counters.push_back(15233); internal_counters.push_back(15352); internal_counters.push_back(15471); internal_counters.push_back(15590); internal_counters.push_back(15709); internal_counters.push_back(15828); internal_counters.push_back(15947); internal_counters.push_back(16066); internal_counters.push_back(16185); internal_counters.push_back(16304); internal_counters.push_back(16423); internal_counters.push_back(16542); internal_counters.push_back(16661); internal_counters.push_back(16780); internal_counters.push_back(16899); internal_counters.push_back(17018); internal_counters.push_back(17137); internal_counters.push_back(17256); internal_counters.push_back(17375); internal_counters.push_back(17494); internal_counters.push_back(17613); internal_counters.push_back(17732); internal_counters.push_back(17851); internal_counters.push_back(17970); internal_counters.push_back(18089); internal_counters.push_back(18208); internal_counters.push_back(18327); internal_counters.push_back(18446); internal_counters.push_back(18565); internal_counters.push_back(18684); internal_counters.push_back(18803); internal_counters.push_back(18922); internal_counters.push_back(19041); internal_counters.push_back(19160); internal_counters.push_back(19279); internal_counters.push_back(19398); internal_counters.push_back(19517); internal_counters.push_back(19636); internal_counters.push_back(19755); internal_counters.push_back(19874); internal_counters.push_back(19993); internal_counters.push_back(20112); internal_counters.push_back(20231); internal_counters.push_back(20350); internal_counters.push_back(20469); internal_counters.push_back(20588); internal_counters.push_back(20707); internal_counters.push_back(20826); internal_counters.push_back(20945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVFetchInsts", "ComputeShader", "The average number of vector fetch instructions from the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,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,sum64,-,68,69,70,71,sum4,/,72,73,74,75,76,77,78,79,sum8,ifnotzero", "3e2829c0-6215-783b-c271-6d57ff2c520e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12046); internal_counters.push_back(12345); internal_counters.push_back(12644); internal_counters.push_back(12943); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSFetchInsts", "ComputeShader", "The average number of scalar fetch instructions from the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "da09171c-6a0a-584f-fddc-dc5062d63a3e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12042); internal_counters.push_back(12341); internal_counters.push_back(12640); internal_counters.push_back(12939); internal_counters.push_back(13449); internal_counters.push_back(13568); internal_counters.push_back(13687); internal_counters.push_back(13806); internal_counters.push_back(13925); internal_counters.push_back(14044); internal_counters.push_back(14163); internal_counters.push_back(14282); internal_counters.push_back(14401); internal_counters.push_back(14520); internal_counters.push_back(14639); internal_counters.push_back(14758); internal_counters.push_back(14877); internal_counters.push_back(14996); internal_counters.push_back(15115); internal_counters.push_back(15234); internal_counters.push_back(15353); internal_counters.push_back(15472); internal_counters.push_back(15591); internal_counters.push_back(15710); internal_counters.push_back(15829); internal_counters.push_back(15948); internal_counters.push_back(16067); internal_counters.push_back(16186); internal_counters.push_back(16305); internal_counters.push_back(16424); internal_counters.push_back(16543); internal_counters.push_back(16662); internal_counters.push_back(16781); internal_counters.push_back(16900); internal_counters.push_back(17019); internal_counters.push_back(17138); internal_counters.push_back(17257); internal_counters.push_back(17376); internal_counters.push_back(17495); internal_counters.push_back(17614); internal_counters.push_back(17733); internal_counters.push_back(17852); internal_counters.push_back(17971); internal_counters.push_back(18090); internal_counters.push_back(18209); internal_counters.push_back(18328); internal_counters.push_back(18447); internal_counters.push_back(18566); internal_counters.push_back(18685); internal_counters.push_back(18804); internal_counters.push_back(18923); internal_counters.push_back(19042); internal_counters.push_back(19161); internal_counters.push_back(19280); internal_counters.push_back(19399); internal_counters.push_back(19518); internal_counters.push_back(19637); internal_counters.push_back(19756); internal_counters.push_back(19875); internal_counters.push_back(19994); internal_counters.push_back(20113); internal_counters.push_back(20232); internal_counters.push_back(20351); internal_counters.push_back(20470); internal_counters.push_back(20589); internal_counters.push_back(20708); internal_counters.push_back(20827); internal_counters.push_back(20946); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVWriteInsts", "ComputeShader", "The average number of vector write instructions to the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,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,sum64,-,68,69,70,71,sum4,/,72,73,74,75,76,77,78,79,sum8,ifnotzero", "43438c22-e910-b377-b767-b32902e0df0d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12047); internal_counters.push_back(12346); internal_counters.push_back(12645); internal_counters.push_back(12944); internal_counters.push_back(12048); internal_counters.push_back(12347); internal_counters.push_back(12646); internal_counters.push_back(12945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSFlatVMemInsts", "ComputeShader", "The average number of FLAT instructions that read from or write to the video memory executed per work item (affected by flow control). Includes FLAT instructions that read from or write to scratch.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,-,8,9,10,11,sum4,/,12,13,14,15,16,17,18,19,sum8,ifnotzero", "2570b477-13e3-f5b6-e6ff-7159373bc74d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUBusy", "ComputeShader", "The percentage of GPUTime vector ALU instructions are processed. Value range: 0% (bad) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "f1e64815-f6a8-c277-d4f9-d054b443e205"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUBusyCycles", "ComputeShader", "Number of GPU cycles where vector ALU instructions are processed.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "2d0d5852-2658-eb73-68d2-f23f7118c9c3"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12101); internal_counters.push_back(12400); internal_counters.push_back(12699); internal_counters.push_back(12998); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUBusy", "ComputeShader", "The percentage of GPUTime scalar ALU instructions are processed. Value range: 0% (bad) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "3fc35f4e-9882-94e3-6f5f-4e81cd97082a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12101); internal_counters.push_back(12400); internal_counters.push_back(12699); internal_counters.push_back(12998); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUBusyCycles", "ComputeShader", "Number of GPU cycles where scalar ALU instructions are processed.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_CUS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "de58f8fc-8ed4-a799-648d-62ded7b1c4c4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitBusy", "ComputeShader", "The percentage of GPUTime the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account. Value range: 0% to 100% (fetch-bound).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,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,max64,64,/,(100),*,65,66,67,68,69,70,71,72,sum8,ifnotzero", "42ab96e1-0a24-96c8-c4ff-098fa267d78e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitBusyCycles", "ComputeShader", "Number of GPU cycles the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,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,max64,64,65,66,67,68,69,70,71,sum8,ifnotzero", "39d5687f-c727-7c0c-af82-bb711d3897ed"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitStalled", "ComputeShader", "The percentage of GPUTime the memory unit is stalled. Try reducing the number or size of fetches and writes if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,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,max64,64,/,(100),*,65,66,67,68,69,70,71,72,sum8,ifnotzero", "f18e8679-1511-d533-d9ee-4365197f7d0c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitStalledCycles", "ComputeShader", "Number of GPU cycles the memory unit is stalled. Try reducing the number or size of fetches and writes if possible.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,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,max64,64,65,66,67,68,69,70,71,sum8,ifnotzero", "51991c84-ed2b-bf31-c4ab-8f8e9eb8f29f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSWriteUnitStalled", "ComputeShader", "The percentage of GPUTime the write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*,17,18,19,20,21,22,23,24,sum8,ifnotzero", "55118f7a-8f92-726f-78c6-407f689a2eb4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSWriteUnitStalledCycles", "ComputeShader", "Number of GPU cycles the write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,17,18,19,20,21,22,23,sum8,ifnotzero", "be164c60-5e48-acac-9622-29616d09aa9a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12050); internal_counters.push_back(12349); internal_counters.push_back(12648); internal_counters.push_back(12947); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSGDSInsts", "ComputeShader", "The average number of GDS read or GDS write instructions executed per work item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "2a867f3e-4a37-ad16-55d1-f03d74707819"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12049); internal_counters.push_back(12348); internal_counters.push_back(12647); internal_counters.push_back(12946); internal_counters.push_back(12047); internal_counters.push_back(12346); internal_counters.push_back(12645); internal_counters.push_back(12944); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSInsts", "ComputeShader", "The average number of LDS read/write instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,-,8,9,10,11,sum4,/,12,13,14,15,16,17,18,19,sum8,ifnotzero", "61b0b351-7e06-ef8e-a8e0-7a9e3200a836"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12048); internal_counters.push_back(12347); internal_counters.push_back(12646); internal_counters.push_back(12945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSFlatLDSInsts", "ComputeShader", "The average number of FLAT instructions that read from or write to LDS executed per work item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "99672cda-de2b-014c-482e-cf73b90068d5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12076); internal_counters.push_back(12375); internal_counters.push_back(12674); internal_counters.push_back(12973); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSALUStalledByLDS", "ComputeShader", "The percentage of GPUTime ALU units are stalled by the LDS input queue being full or the output queue being not ready. If there are LDS bank conflicts, reduce them. Otherwise, try reducing the number of LDS accesses if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,/,NUM_SHADER_ENGINES,/,(100),*,9,10,11,12,13,14,15,16,sum8,ifnotzero", "6dc4f1c2-bad0-c9ff-156e-883b319a752a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12076); internal_counters.push_back(12375); internal_counters.push_back(12674); internal_counters.push_back(12973); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSALUStalledByLDSCycles", "ComputeShader", "Number of GPU cycles the ALU units are stalled by the LDS input queue being full or the output queue being not ready. If there are LDS bank conflicts, reduce them. Otherwise, try reducing the number of LDS accesses if possible.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_SHADER_ENGINES,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "8f3d5f25-2159-0374-fafe-e26a7799b6c8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12112); internal_counters.push_back(12411); internal_counters.push_back(12710); internal_counters.push_back(13009); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSBankConflict", "ComputeShader", "The percentage of GPUTime LDS is stalled by bank conflicts. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,/,NUM_SIMDS,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "1065ee10-2e41-ea41-1eb3-b61b491752f4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12112); internal_counters.push_back(12411); internal_counters.push_back(12710); internal_counters.push_back(13009); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSBankConflictCycles", "ComputeShader", "Number of GPU cycles the LDS is stalled by bank conflicts. Value range: 0 (optimal) to GPUBusyCycles (bad).", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_SIMDS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "1fd1adf3-c51e-94fd-083e-c482a0a0809e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); c.DefineDerivedCounter("TexUnitBusy", "Timing", "The percentage of GPUTime the texture unit is active. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,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,max64,64,/,(100),*", "36afb8d9-42fc-aafe-66c5-449542153b2c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); c.DefineDerivedCounter("TexUnitBusyCycles", "Timing", "Number of GPU cycles the texture unit is active. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,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,max64", "c68761f2-248c-4f39-6528-c308b1c0807c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13416); internal_counters.push_back(13535); internal_counters.push_back(13654); internal_counters.push_back(13773); internal_counters.push_back(13892); internal_counters.push_back(14011); internal_counters.push_back(14130); internal_counters.push_back(14249); internal_counters.push_back(14368); internal_counters.push_back(14487); internal_counters.push_back(14606); internal_counters.push_back(14725); internal_counters.push_back(14844); internal_counters.push_back(14963); internal_counters.push_back(15082); internal_counters.push_back(15201); internal_counters.push_back(15320); internal_counters.push_back(15439); internal_counters.push_back(15558); internal_counters.push_back(15677); internal_counters.push_back(15796); internal_counters.push_back(15915); internal_counters.push_back(16034); internal_counters.push_back(16153); internal_counters.push_back(16272); internal_counters.push_back(16391); internal_counters.push_back(16510); internal_counters.push_back(16629); internal_counters.push_back(16748); internal_counters.push_back(16867); internal_counters.push_back(16986); internal_counters.push_back(17105); internal_counters.push_back(17224); internal_counters.push_back(17343); internal_counters.push_back(17462); internal_counters.push_back(17581); internal_counters.push_back(17700); internal_counters.push_back(17819); internal_counters.push_back(17938); internal_counters.push_back(18057); internal_counters.push_back(18176); internal_counters.push_back(18295); internal_counters.push_back(18414); internal_counters.push_back(18533); internal_counters.push_back(18652); internal_counters.push_back(18771); internal_counters.push_back(18890); internal_counters.push_back(19009); internal_counters.push_back(19128); internal_counters.push_back(19247); internal_counters.push_back(19366); internal_counters.push_back(19485); internal_counters.push_back(19604); internal_counters.push_back(19723); internal_counters.push_back(19842); internal_counters.push_back(19961); internal_counters.push_back(20080); internal_counters.push_back(20199); internal_counters.push_back(20318); internal_counters.push_back(20437); internal_counters.push_back(20556); internal_counters.push_back(20675); internal_counters.push_back(20794); internal_counters.push_back(20913); internal_counters.push_back(13415); internal_counters.push_back(13534); internal_counters.push_back(13653); internal_counters.push_back(13772); internal_counters.push_back(13891); internal_counters.push_back(14010); internal_counters.push_back(14129); internal_counters.push_back(14248); internal_counters.push_back(14367); internal_counters.push_back(14486); internal_counters.push_back(14605); internal_counters.push_back(14724); internal_counters.push_back(14843); internal_counters.push_back(14962); internal_counters.push_back(15081); internal_counters.push_back(15200); internal_counters.push_back(15319); internal_counters.push_back(15438); internal_counters.push_back(15557); internal_counters.push_back(15676); internal_counters.push_back(15795); internal_counters.push_back(15914); internal_counters.push_back(16033); internal_counters.push_back(16152); internal_counters.push_back(16271); internal_counters.push_back(16390); internal_counters.push_back(16509); internal_counters.push_back(16628); internal_counters.push_back(16747); internal_counters.push_back(16866); internal_counters.push_back(16985); internal_counters.push_back(17104); internal_counters.push_back(17223); internal_counters.push_back(17342); internal_counters.push_back(17461); internal_counters.push_back(17580); internal_counters.push_back(17699); internal_counters.push_back(17818); internal_counters.push_back(17937); internal_counters.push_back(18056); internal_counters.push_back(18175); internal_counters.push_back(18294); internal_counters.push_back(18413); internal_counters.push_back(18532); internal_counters.push_back(18651); internal_counters.push_back(18770); internal_counters.push_back(18889); internal_counters.push_back(19008); internal_counters.push_back(19127); internal_counters.push_back(19246); internal_counters.push_back(19365); internal_counters.push_back(19484); internal_counters.push_back(19603); internal_counters.push_back(19722); internal_counters.push_back(19841); internal_counters.push_back(19960); internal_counters.push_back(20079); internal_counters.push_back(20198); internal_counters.push_back(20317); internal_counters.push_back(20436); internal_counters.push_back(20555); internal_counters.push_back(20674); internal_counters.push_back(20793); internal_counters.push_back(20912); c.DefineDerivedCounter("TexTriFilteringPct", "TextureUnit", "Percentage of pixels that received trilinear filtering. Note that not all pixels for which trilinear filtering is enabled will receive it (e.g. if the texture is magnified).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,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,sum64,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,119,120,121,122,123,124,125,126,127,sum64,0,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,sum64,+,/,(100),*", "1affc3c8-b917-5c81-622b-7004527208ae"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13416); internal_counters.push_back(13535); internal_counters.push_back(13654); internal_counters.push_back(13773); internal_counters.push_back(13892); internal_counters.push_back(14011); internal_counters.push_back(14130); internal_counters.push_back(14249); internal_counters.push_back(14368); internal_counters.push_back(14487); internal_counters.push_back(14606); internal_counters.push_back(14725); internal_counters.push_back(14844); internal_counters.push_back(14963); internal_counters.push_back(15082); internal_counters.push_back(15201); internal_counters.push_back(15320); internal_counters.push_back(15439); internal_counters.push_back(15558); internal_counters.push_back(15677); internal_counters.push_back(15796); internal_counters.push_back(15915); internal_counters.push_back(16034); internal_counters.push_back(16153); internal_counters.push_back(16272); internal_counters.push_back(16391); internal_counters.push_back(16510); internal_counters.push_back(16629); internal_counters.push_back(16748); internal_counters.push_back(16867); internal_counters.push_back(16986); internal_counters.push_back(17105); internal_counters.push_back(17224); internal_counters.push_back(17343); internal_counters.push_back(17462); internal_counters.push_back(17581); internal_counters.push_back(17700); internal_counters.push_back(17819); internal_counters.push_back(17938); internal_counters.push_back(18057); internal_counters.push_back(18176); internal_counters.push_back(18295); internal_counters.push_back(18414); internal_counters.push_back(18533); internal_counters.push_back(18652); internal_counters.push_back(18771); internal_counters.push_back(18890); internal_counters.push_back(19009); internal_counters.push_back(19128); internal_counters.push_back(19247); internal_counters.push_back(19366); internal_counters.push_back(19485); internal_counters.push_back(19604); internal_counters.push_back(19723); internal_counters.push_back(19842); internal_counters.push_back(19961); internal_counters.push_back(20080); internal_counters.push_back(20199); internal_counters.push_back(20318); internal_counters.push_back(20437); internal_counters.push_back(20556); internal_counters.push_back(20675); internal_counters.push_back(20794); internal_counters.push_back(20913); c.DefineDerivedCounter("TexTriFilteringCount", "TextureUnit", "Count of pixels that received trilinear filtering. Note that not all pixels for which trilinear filtering is enabled will receive it (e.g. if the texture is magnified).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,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,sum64", "5785b3a1-a513-18db-4b1c-bdeef75bb2b6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13415); internal_counters.push_back(13534); internal_counters.push_back(13653); internal_counters.push_back(13772); internal_counters.push_back(13891); internal_counters.push_back(14010); internal_counters.push_back(14129); internal_counters.push_back(14248); internal_counters.push_back(14367); internal_counters.push_back(14486); internal_counters.push_back(14605); internal_counters.push_back(14724); internal_counters.push_back(14843); internal_counters.push_back(14962); internal_counters.push_back(15081); internal_counters.push_back(15200); internal_counters.push_back(15319); internal_counters.push_back(15438); internal_counters.push_back(15557); internal_counters.push_back(15676); internal_counters.push_back(15795); internal_counters.push_back(15914); internal_counters.push_back(16033); internal_counters.push_back(16152); internal_counters.push_back(16271); internal_counters.push_back(16390); internal_counters.push_back(16509); internal_counters.push_back(16628); internal_counters.push_back(16747); internal_counters.push_back(16866); internal_counters.push_back(16985); internal_counters.push_back(17104); internal_counters.push_back(17223); internal_counters.push_back(17342); internal_counters.push_back(17461); internal_counters.push_back(17580); internal_counters.push_back(17699); internal_counters.push_back(17818); internal_counters.push_back(17937); internal_counters.push_back(18056); internal_counters.push_back(18175); internal_counters.push_back(18294); internal_counters.push_back(18413); internal_counters.push_back(18532); internal_counters.push_back(18651); internal_counters.push_back(18770); internal_counters.push_back(18889); internal_counters.push_back(19008); internal_counters.push_back(19127); internal_counters.push_back(19246); internal_counters.push_back(19365); internal_counters.push_back(19484); internal_counters.push_back(19603); internal_counters.push_back(19722); internal_counters.push_back(19841); internal_counters.push_back(19960); internal_counters.push_back(20079); internal_counters.push_back(20198); internal_counters.push_back(20317); internal_counters.push_back(20436); internal_counters.push_back(20555); internal_counters.push_back(20674); internal_counters.push_back(20793); internal_counters.push_back(20912); c.DefineDerivedCounter("NoTexTriFilteringCount", "TextureUnit", "Count of pixels that did not receive trilinear filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,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,sum64", "179da29a-81af-c06e-ce8c-a0a731ea030d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13418); internal_counters.push_back(13537); internal_counters.push_back(13656); internal_counters.push_back(13775); internal_counters.push_back(13894); internal_counters.push_back(14013); internal_counters.push_back(14132); internal_counters.push_back(14251); internal_counters.push_back(14370); internal_counters.push_back(14489); internal_counters.push_back(14608); internal_counters.push_back(14727); internal_counters.push_back(14846); internal_counters.push_back(14965); internal_counters.push_back(15084); internal_counters.push_back(15203); internal_counters.push_back(15322); internal_counters.push_back(15441); internal_counters.push_back(15560); internal_counters.push_back(15679); internal_counters.push_back(15798); internal_counters.push_back(15917); internal_counters.push_back(16036); internal_counters.push_back(16155); internal_counters.push_back(16274); internal_counters.push_back(16393); internal_counters.push_back(16512); internal_counters.push_back(16631); internal_counters.push_back(16750); internal_counters.push_back(16869); internal_counters.push_back(16988); internal_counters.push_back(17107); internal_counters.push_back(17226); internal_counters.push_back(17345); internal_counters.push_back(17464); internal_counters.push_back(17583); internal_counters.push_back(17702); internal_counters.push_back(17821); internal_counters.push_back(17940); internal_counters.push_back(18059); internal_counters.push_back(18178); internal_counters.push_back(18297); internal_counters.push_back(18416); internal_counters.push_back(18535); internal_counters.push_back(18654); internal_counters.push_back(18773); internal_counters.push_back(18892); internal_counters.push_back(19011); internal_counters.push_back(19130); internal_counters.push_back(19249); internal_counters.push_back(19368); internal_counters.push_back(19487); internal_counters.push_back(19606); internal_counters.push_back(19725); internal_counters.push_back(19844); internal_counters.push_back(19963); internal_counters.push_back(20082); internal_counters.push_back(20201); internal_counters.push_back(20320); internal_counters.push_back(20439); internal_counters.push_back(20558); internal_counters.push_back(20677); internal_counters.push_back(20796); internal_counters.push_back(20915); internal_counters.push_back(13417); internal_counters.push_back(13536); internal_counters.push_back(13655); internal_counters.push_back(13774); internal_counters.push_back(13893); internal_counters.push_back(14012); internal_counters.push_back(14131); internal_counters.push_back(14250); internal_counters.push_back(14369); internal_counters.push_back(14488); internal_counters.push_back(14607); internal_counters.push_back(14726); internal_counters.push_back(14845); internal_counters.push_back(14964); internal_counters.push_back(15083); internal_counters.push_back(15202); internal_counters.push_back(15321); internal_counters.push_back(15440); internal_counters.push_back(15559); internal_counters.push_back(15678); internal_counters.push_back(15797); internal_counters.push_back(15916); internal_counters.push_back(16035); internal_counters.push_back(16154); internal_counters.push_back(16273); internal_counters.push_back(16392); internal_counters.push_back(16511); internal_counters.push_back(16630); internal_counters.push_back(16749); internal_counters.push_back(16868); internal_counters.push_back(16987); internal_counters.push_back(17106); internal_counters.push_back(17225); internal_counters.push_back(17344); internal_counters.push_back(17463); internal_counters.push_back(17582); internal_counters.push_back(17701); internal_counters.push_back(17820); internal_counters.push_back(17939); internal_counters.push_back(18058); internal_counters.push_back(18177); internal_counters.push_back(18296); internal_counters.push_back(18415); internal_counters.push_back(18534); internal_counters.push_back(18653); internal_counters.push_back(18772); internal_counters.push_back(18891); internal_counters.push_back(19010); internal_counters.push_back(19129); internal_counters.push_back(19248); internal_counters.push_back(19367); internal_counters.push_back(19486); internal_counters.push_back(19605); internal_counters.push_back(19724); internal_counters.push_back(19843); internal_counters.push_back(19962); internal_counters.push_back(20081); internal_counters.push_back(20200); internal_counters.push_back(20319); internal_counters.push_back(20438); internal_counters.push_back(20557); internal_counters.push_back(20676); internal_counters.push_back(20795); internal_counters.push_back(20914); c.DefineDerivedCounter("TexVolFilteringPct", "TextureUnit", "Percentage of pixels that received volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,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,sum64,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,119,120,121,122,123,124,125,126,127,sum64,0,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,sum64,+,/,(100),*", "b5ff6bed-3178-aee4-42dd-c74391c02a2d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13418); internal_counters.push_back(13537); internal_counters.push_back(13656); internal_counters.push_back(13775); internal_counters.push_back(13894); internal_counters.push_back(14013); internal_counters.push_back(14132); internal_counters.push_back(14251); internal_counters.push_back(14370); internal_counters.push_back(14489); internal_counters.push_back(14608); internal_counters.push_back(14727); internal_counters.push_back(14846); internal_counters.push_back(14965); internal_counters.push_back(15084); internal_counters.push_back(15203); internal_counters.push_back(15322); internal_counters.push_back(15441); internal_counters.push_back(15560); internal_counters.push_back(15679); internal_counters.push_back(15798); internal_counters.push_back(15917); internal_counters.push_back(16036); internal_counters.push_back(16155); internal_counters.push_back(16274); internal_counters.push_back(16393); internal_counters.push_back(16512); internal_counters.push_back(16631); internal_counters.push_back(16750); internal_counters.push_back(16869); internal_counters.push_back(16988); internal_counters.push_back(17107); internal_counters.push_back(17226); internal_counters.push_back(17345); internal_counters.push_back(17464); internal_counters.push_back(17583); internal_counters.push_back(17702); internal_counters.push_back(17821); internal_counters.push_back(17940); internal_counters.push_back(18059); internal_counters.push_back(18178); internal_counters.push_back(18297); internal_counters.push_back(18416); internal_counters.push_back(18535); internal_counters.push_back(18654); internal_counters.push_back(18773); internal_counters.push_back(18892); internal_counters.push_back(19011); internal_counters.push_back(19130); internal_counters.push_back(19249); internal_counters.push_back(19368); internal_counters.push_back(19487); internal_counters.push_back(19606); internal_counters.push_back(19725); internal_counters.push_back(19844); internal_counters.push_back(19963); internal_counters.push_back(20082); internal_counters.push_back(20201); internal_counters.push_back(20320); internal_counters.push_back(20439); internal_counters.push_back(20558); internal_counters.push_back(20677); internal_counters.push_back(20796); internal_counters.push_back(20915); c.DefineDerivedCounter("TexVolFilteringCount", "TextureUnit", "Count of pixels that received volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,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,sum64", "4bddc587-d589-8128-e18c-762eab2c871f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13417); internal_counters.push_back(13536); internal_counters.push_back(13655); internal_counters.push_back(13774); internal_counters.push_back(13893); internal_counters.push_back(14012); internal_counters.push_back(14131); internal_counters.push_back(14250); internal_counters.push_back(14369); internal_counters.push_back(14488); internal_counters.push_back(14607); internal_counters.push_back(14726); internal_counters.push_back(14845); internal_counters.push_back(14964); internal_counters.push_back(15083); internal_counters.push_back(15202); internal_counters.push_back(15321); internal_counters.push_back(15440); internal_counters.push_back(15559); internal_counters.push_back(15678); internal_counters.push_back(15797); internal_counters.push_back(15916); internal_counters.push_back(16035); internal_counters.push_back(16154); internal_counters.push_back(16273); internal_counters.push_back(16392); internal_counters.push_back(16511); internal_counters.push_back(16630); internal_counters.push_back(16749); internal_counters.push_back(16868); internal_counters.push_back(16987); internal_counters.push_back(17106); internal_counters.push_back(17225); internal_counters.push_back(17344); internal_counters.push_back(17463); internal_counters.push_back(17582); internal_counters.push_back(17701); internal_counters.push_back(17820); internal_counters.push_back(17939); internal_counters.push_back(18058); internal_counters.push_back(18177); internal_counters.push_back(18296); internal_counters.push_back(18415); internal_counters.push_back(18534); internal_counters.push_back(18653); internal_counters.push_back(18772); internal_counters.push_back(18891); internal_counters.push_back(19010); internal_counters.push_back(19129); internal_counters.push_back(19248); internal_counters.push_back(19367); internal_counters.push_back(19486); internal_counters.push_back(19605); internal_counters.push_back(19724); internal_counters.push_back(19843); internal_counters.push_back(19962); internal_counters.push_back(20081); internal_counters.push_back(20200); internal_counters.push_back(20319); internal_counters.push_back(20438); internal_counters.push_back(20557); internal_counters.push_back(20676); internal_counters.push_back(20795); internal_counters.push_back(20914); c.DefineDerivedCounter("NoTexVolFilteringCount", "TextureUnit", "Count of pixels that did not receive volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,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,sum64", "9fe1a854-17c6-9d26-b2b9-80610cd5827d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13436); internal_counters.push_back(13555); internal_counters.push_back(13674); internal_counters.push_back(13793); internal_counters.push_back(13912); internal_counters.push_back(14031); internal_counters.push_back(14150); internal_counters.push_back(14269); internal_counters.push_back(14388); internal_counters.push_back(14507); internal_counters.push_back(14626); internal_counters.push_back(14745); internal_counters.push_back(14864); internal_counters.push_back(14983); internal_counters.push_back(15102); internal_counters.push_back(15221); internal_counters.push_back(15340); internal_counters.push_back(15459); internal_counters.push_back(15578); internal_counters.push_back(15697); internal_counters.push_back(15816); internal_counters.push_back(15935); internal_counters.push_back(16054); internal_counters.push_back(16173); internal_counters.push_back(16292); internal_counters.push_back(16411); internal_counters.push_back(16530); internal_counters.push_back(16649); internal_counters.push_back(16768); internal_counters.push_back(16887); internal_counters.push_back(17006); internal_counters.push_back(17125); internal_counters.push_back(17244); internal_counters.push_back(17363); internal_counters.push_back(17482); internal_counters.push_back(17601); internal_counters.push_back(17720); internal_counters.push_back(17839); internal_counters.push_back(17958); internal_counters.push_back(18077); internal_counters.push_back(18196); internal_counters.push_back(18315); internal_counters.push_back(18434); internal_counters.push_back(18553); internal_counters.push_back(18672); internal_counters.push_back(18791); internal_counters.push_back(18910); internal_counters.push_back(19029); internal_counters.push_back(19148); internal_counters.push_back(19267); internal_counters.push_back(19386); internal_counters.push_back(19505); internal_counters.push_back(19624); internal_counters.push_back(19743); internal_counters.push_back(19862); internal_counters.push_back(19981); internal_counters.push_back(20100); internal_counters.push_back(20219); internal_counters.push_back(20338); internal_counters.push_back(20457); internal_counters.push_back(20576); internal_counters.push_back(20695); internal_counters.push_back(20814); internal_counters.push_back(20933); internal_counters.push_back(13437); internal_counters.push_back(13556); internal_counters.push_back(13675); internal_counters.push_back(13794); internal_counters.push_back(13913); internal_counters.push_back(14032); internal_counters.push_back(14151); internal_counters.push_back(14270); internal_counters.push_back(14389); internal_counters.push_back(14508); internal_counters.push_back(14627); internal_counters.push_back(14746); internal_counters.push_back(14865); internal_counters.push_back(14984); internal_counters.push_back(15103); internal_counters.push_back(15222); internal_counters.push_back(15341); internal_counters.push_back(15460); internal_counters.push_back(15579); internal_counters.push_back(15698); internal_counters.push_back(15817); internal_counters.push_back(15936); internal_counters.push_back(16055); internal_counters.push_back(16174); internal_counters.push_back(16293); internal_counters.push_back(16412); internal_counters.push_back(16531); internal_counters.push_back(16650); internal_counters.push_back(16769); internal_counters.push_back(16888); internal_counters.push_back(17007); internal_counters.push_back(17126); internal_counters.push_back(17245); internal_counters.push_back(17364); internal_counters.push_back(17483); internal_counters.push_back(17602); internal_counters.push_back(17721); internal_counters.push_back(17840); internal_counters.push_back(17959); internal_counters.push_back(18078); internal_counters.push_back(18197); internal_counters.push_back(18316); internal_counters.push_back(18435); internal_counters.push_back(18554); internal_counters.push_back(18673); internal_counters.push_back(18792); internal_counters.push_back(18911); internal_counters.push_back(19030); internal_counters.push_back(19149); internal_counters.push_back(19268); internal_counters.push_back(19387); internal_counters.push_back(19506); internal_counters.push_back(19625); internal_counters.push_back(19744); internal_counters.push_back(19863); internal_counters.push_back(19982); internal_counters.push_back(20101); internal_counters.push_back(20220); internal_counters.push_back(20339); internal_counters.push_back(20458); internal_counters.push_back(20577); internal_counters.push_back(20696); internal_counters.push_back(20815); internal_counters.push_back(20934); internal_counters.push_back(13438); internal_counters.push_back(13557); internal_counters.push_back(13676); internal_counters.push_back(13795); internal_counters.push_back(13914); internal_counters.push_back(14033); internal_counters.push_back(14152); internal_counters.push_back(14271); internal_counters.push_back(14390); internal_counters.push_back(14509); internal_counters.push_back(14628); internal_counters.push_back(14747); internal_counters.push_back(14866); internal_counters.push_back(14985); internal_counters.push_back(15104); internal_counters.push_back(15223); internal_counters.push_back(15342); internal_counters.push_back(15461); internal_counters.push_back(15580); internal_counters.push_back(15699); internal_counters.push_back(15818); internal_counters.push_back(15937); internal_counters.push_back(16056); internal_counters.push_back(16175); internal_counters.push_back(16294); internal_counters.push_back(16413); internal_counters.push_back(16532); internal_counters.push_back(16651); internal_counters.push_back(16770); internal_counters.push_back(16889); internal_counters.push_back(17008); internal_counters.push_back(17127); internal_counters.push_back(17246); internal_counters.push_back(17365); internal_counters.push_back(17484); internal_counters.push_back(17603); internal_counters.push_back(17722); internal_counters.push_back(17841); internal_counters.push_back(17960); internal_counters.push_back(18079); internal_counters.push_back(18198); internal_counters.push_back(18317); internal_counters.push_back(18436); internal_counters.push_back(18555); internal_counters.push_back(18674); internal_counters.push_back(18793); internal_counters.push_back(18912); internal_counters.push_back(19031); internal_counters.push_back(19150); internal_counters.push_back(19269); internal_counters.push_back(19388); internal_counters.push_back(19507); internal_counters.push_back(19626); internal_counters.push_back(19745); internal_counters.push_back(19864); internal_counters.push_back(19983); internal_counters.push_back(20102); internal_counters.push_back(20221); internal_counters.push_back(20340); internal_counters.push_back(20459); internal_counters.push_back(20578); internal_counters.push_back(20697); internal_counters.push_back(20816); internal_counters.push_back(20935); internal_counters.push_back(13439); internal_counters.push_back(13558); internal_counters.push_back(13677); internal_counters.push_back(13796); internal_counters.push_back(13915); internal_counters.push_back(14034); internal_counters.push_back(14153); internal_counters.push_back(14272); internal_counters.push_back(14391); internal_counters.push_back(14510); internal_counters.push_back(14629); internal_counters.push_back(14748); internal_counters.push_back(14867); internal_counters.push_back(14986); internal_counters.push_back(15105); internal_counters.push_back(15224); internal_counters.push_back(15343); internal_counters.push_back(15462); internal_counters.push_back(15581); internal_counters.push_back(15700); internal_counters.push_back(15819); internal_counters.push_back(15938); internal_counters.push_back(16057); internal_counters.push_back(16176); internal_counters.push_back(16295); internal_counters.push_back(16414); internal_counters.push_back(16533); internal_counters.push_back(16652); internal_counters.push_back(16771); internal_counters.push_back(16890); internal_counters.push_back(17009); internal_counters.push_back(17128); internal_counters.push_back(17247); internal_counters.push_back(17366); internal_counters.push_back(17485); internal_counters.push_back(17604); internal_counters.push_back(17723); internal_counters.push_back(17842); internal_counters.push_back(17961); internal_counters.push_back(18080); internal_counters.push_back(18199); internal_counters.push_back(18318); internal_counters.push_back(18437); internal_counters.push_back(18556); internal_counters.push_back(18675); internal_counters.push_back(18794); internal_counters.push_back(18913); internal_counters.push_back(19032); internal_counters.push_back(19151); internal_counters.push_back(19270); internal_counters.push_back(19389); internal_counters.push_back(19508); internal_counters.push_back(19627); internal_counters.push_back(19746); internal_counters.push_back(19865); internal_counters.push_back(19984); internal_counters.push_back(20103); internal_counters.push_back(20222); internal_counters.push_back(20341); internal_counters.push_back(20460); internal_counters.push_back(20579); internal_counters.push_back(20698); internal_counters.push_back(20817); internal_counters.push_back(20936); internal_counters.push_back(13440); internal_counters.push_back(13559); internal_counters.push_back(13678); internal_counters.push_back(13797); internal_counters.push_back(13916); internal_counters.push_back(14035); internal_counters.push_back(14154); internal_counters.push_back(14273); internal_counters.push_back(14392); internal_counters.push_back(14511); internal_counters.push_back(14630); internal_counters.push_back(14749); internal_counters.push_back(14868); internal_counters.push_back(14987); internal_counters.push_back(15106); internal_counters.push_back(15225); internal_counters.push_back(15344); internal_counters.push_back(15463); internal_counters.push_back(15582); internal_counters.push_back(15701); internal_counters.push_back(15820); internal_counters.push_back(15939); internal_counters.push_back(16058); internal_counters.push_back(16177); internal_counters.push_back(16296); internal_counters.push_back(16415); internal_counters.push_back(16534); internal_counters.push_back(16653); internal_counters.push_back(16772); internal_counters.push_back(16891); internal_counters.push_back(17010); internal_counters.push_back(17129); internal_counters.push_back(17248); internal_counters.push_back(17367); internal_counters.push_back(17486); internal_counters.push_back(17605); internal_counters.push_back(17724); internal_counters.push_back(17843); internal_counters.push_back(17962); internal_counters.push_back(18081); internal_counters.push_back(18200); internal_counters.push_back(18319); internal_counters.push_back(18438); internal_counters.push_back(18557); internal_counters.push_back(18676); internal_counters.push_back(18795); internal_counters.push_back(18914); internal_counters.push_back(19033); internal_counters.push_back(19152); internal_counters.push_back(19271); internal_counters.push_back(19390); internal_counters.push_back(19509); internal_counters.push_back(19628); internal_counters.push_back(19747); internal_counters.push_back(19866); internal_counters.push_back(19985); internal_counters.push_back(20104); internal_counters.push_back(20223); internal_counters.push_back(20342); internal_counters.push_back(20461); internal_counters.push_back(20580); internal_counters.push_back(20699); internal_counters.push_back(20818); internal_counters.push_back(20937); internal_counters.push_back(13441); internal_counters.push_back(13560); internal_counters.push_back(13679); internal_counters.push_back(13798); internal_counters.push_back(13917); internal_counters.push_back(14036); internal_counters.push_back(14155); internal_counters.push_back(14274); internal_counters.push_back(14393); internal_counters.push_back(14512); internal_counters.push_back(14631); internal_counters.push_back(14750); internal_counters.push_back(14869); internal_counters.push_back(14988); internal_counters.push_back(15107); internal_counters.push_back(15226); internal_counters.push_back(15345); internal_counters.push_back(15464); internal_counters.push_back(15583); internal_counters.push_back(15702); internal_counters.push_back(15821); internal_counters.push_back(15940); internal_counters.push_back(16059); internal_counters.push_back(16178); internal_counters.push_back(16297); internal_counters.push_back(16416); internal_counters.push_back(16535); internal_counters.push_back(16654); internal_counters.push_back(16773); internal_counters.push_back(16892); internal_counters.push_back(17011); internal_counters.push_back(17130); internal_counters.push_back(17249); internal_counters.push_back(17368); internal_counters.push_back(17487); internal_counters.push_back(17606); internal_counters.push_back(17725); internal_counters.push_back(17844); internal_counters.push_back(17963); internal_counters.push_back(18082); internal_counters.push_back(18201); internal_counters.push_back(18320); internal_counters.push_back(18439); internal_counters.push_back(18558); internal_counters.push_back(18677); internal_counters.push_back(18796); internal_counters.push_back(18915); internal_counters.push_back(19034); internal_counters.push_back(19153); internal_counters.push_back(19272); internal_counters.push_back(19391); internal_counters.push_back(19510); internal_counters.push_back(19629); internal_counters.push_back(19748); internal_counters.push_back(19867); internal_counters.push_back(19986); internal_counters.push_back(20105); internal_counters.push_back(20224); internal_counters.push_back(20343); internal_counters.push_back(20462); internal_counters.push_back(20581); internal_counters.push_back(20700); internal_counters.push_back(20819); internal_counters.push_back(20938); internal_counters.push_back(13442); internal_counters.push_back(13561); internal_counters.push_back(13680); internal_counters.push_back(13799); internal_counters.push_back(13918); internal_counters.push_back(14037); internal_counters.push_back(14156); internal_counters.push_back(14275); internal_counters.push_back(14394); internal_counters.push_back(14513); internal_counters.push_back(14632); internal_counters.push_back(14751); internal_counters.push_back(14870); internal_counters.push_back(14989); internal_counters.push_back(15108); internal_counters.push_back(15227); internal_counters.push_back(15346); internal_counters.push_back(15465); internal_counters.push_back(15584); internal_counters.push_back(15703); internal_counters.push_back(15822); internal_counters.push_back(15941); internal_counters.push_back(16060); internal_counters.push_back(16179); internal_counters.push_back(16298); internal_counters.push_back(16417); internal_counters.push_back(16536); internal_counters.push_back(16655); internal_counters.push_back(16774); internal_counters.push_back(16893); internal_counters.push_back(17012); internal_counters.push_back(17131); internal_counters.push_back(17250); internal_counters.push_back(17369); internal_counters.push_back(17488); internal_counters.push_back(17607); internal_counters.push_back(17726); internal_counters.push_back(17845); internal_counters.push_back(17964); internal_counters.push_back(18083); internal_counters.push_back(18202); internal_counters.push_back(18321); internal_counters.push_back(18440); internal_counters.push_back(18559); internal_counters.push_back(18678); internal_counters.push_back(18797); internal_counters.push_back(18916); internal_counters.push_back(19035); internal_counters.push_back(19154); internal_counters.push_back(19273); internal_counters.push_back(19392); internal_counters.push_back(19511); internal_counters.push_back(19630); internal_counters.push_back(19749); internal_counters.push_back(19868); internal_counters.push_back(19987); internal_counters.push_back(20106); internal_counters.push_back(20225); internal_counters.push_back(20344); internal_counters.push_back(20463); internal_counters.push_back(20582); internal_counters.push_back(20701); internal_counters.push_back(20820); internal_counters.push_back(20939); internal_counters.push_back(13443); internal_counters.push_back(13562); internal_counters.push_back(13681); internal_counters.push_back(13800); internal_counters.push_back(13919); internal_counters.push_back(14038); internal_counters.push_back(14157); internal_counters.push_back(14276); internal_counters.push_back(14395); internal_counters.push_back(14514); internal_counters.push_back(14633); internal_counters.push_back(14752); internal_counters.push_back(14871); internal_counters.push_back(14990); internal_counters.push_back(15109); internal_counters.push_back(15228); internal_counters.push_back(15347); internal_counters.push_back(15466); internal_counters.push_back(15585); internal_counters.push_back(15704); internal_counters.push_back(15823); internal_counters.push_back(15942); internal_counters.push_back(16061); internal_counters.push_back(16180); internal_counters.push_back(16299); internal_counters.push_back(16418); internal_counters.push_back(16537); internal_counters.push_back(16656); internal_counters.push_back(16775); internal_counters.push_back(16894); internal_counters.push_back(17013); internal_counters.push_back(17132); internal_counters.push_back(17251); internal_counters.push_back(17370); internal_counters.push_back(17489); internal_counters.push_back(17608); internal_counters.push_back(17727); internal_counters.push_back(17846); internal_counters.push_back(17965); internal_counters.push_back(18084); internal_counters.push_back(18203); internal_counters.push_back(18322); internal_counters.push_back(18441); internal_counters.push_back(18560); internal_counters.push_back(18679); internal_counters.push_back(18798); internal_counters.push_back(18917); internal_counters.push_back(19036); internal_counters.push_back(19155); internal_counters.push_back(19274); internal_counters.push_back(19393); internal_counters.push_back(19512); internal_counters.push_back(19631); internal_counters.push_back(19750); internal_counters.push_back(19869); internal_counters.push_back(19988); internal_counters.push_back(20107); internal_counters.push_back(20226); internal_counters.push_back(20345); internal_counters.push_back(20464); internal_counters.push_back(20583); internal_counters.push_back(20702); internal_counters.push_back(20821); internal_counters.push_back(20940); internal_counters.push_back(13444); internal_counters.push_back(13563); internal_counters.push_back(13682); internal_counters.push_back(13801); internal_counters.push_back(13920); internal_counters.push_back(14039); internal_counters.push_back(14158); internal_counters.push_back(14277); internal_counters.push_back(14396); internal_counters.push_back(14515); internal_counters.push_back(14634); internal_counters.push_back(14753); internal_counters.push_back(14872); internal_counters.push_back(14991); internal_counters.push_back(15110); internal_counters.push_back(15229); internal_counters.push_back(15348); internal_counters.push_back(15467); internal_counters.push_back(15586); internal_counters.push_back(15705); internal_counters.push_back(15824); internal_counters.push_back(15943); internal_counters.push_back(16062); internal_counters.push_back(16181); internal_counters.push_back(16300); internal_counters.push_back(16419); internal_counters.push_back(16538); internal_counters.push_back(16657); internal_counters.push_back(16776); internal_counters.push_back(16895); internal_counters.push_back(17014); internal_counters.push_back(17133); internal_counters.push_back(17252); internal_counters.push_back(17371); internal_counters.push_back(17490); internal_counters.push_back(17609); internal_counters.push_back(17728); internal_counters.push_back(17847); internal_counters.push_back(17966); internal_counters.push_back(18085); internal_counters.push_back(18204); internal_counters.push_back(18323); internal_counters.push_back(18442); internal_counters.push_back(18561); internal_counters.push_back(18680); internal_counters.push_back(18799); internal_counters.push_back(18918); internal_counters.push_back(19037); internal_counters.push_back(19156); internal_counters.push_back(19275); internal_counters.push_back(19394); internal_counters.push_back(19513); internal_counters.push_back(19632); internal_counters.push_back(19751); internal_counters.push_back(19870); internal_counters.push_back(19989); internal_counters.push_back(20108); internal_counters.push_back(20227); internal_counters.push_back(20346); internal_counters.push_back(20465); internal_counters.push_back(20584); internal_counters.push_back(20703); internal_counters.push_back(20822); internal_counters.push_back(20941); c.DefineDerivedCounter("TexAveAnisotropy", "TextureUnit", "The average degree of anisotropy applied. A number between 1 and 16. The anisotropic filtering algorithm only applies samples where they are required (e.g. there will be no extra anisotropic samples if the view vector is perpendicular to the surface) so this can be much lower than the requested anisotropy.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,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,sum64,(2),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,119,120,121,122,123,124,125,126,127,sum64,*,+,(4),128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,sum64,*,+,(6),192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,sum64,*,+,(8),256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,sum64,*,+,(10),320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,sum64,*,+,(12),384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,sum64,*,+,(14),448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,sum64,*,+,(16),512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,sum64,*,+,0,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,sum64,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,119,120,121,122,123,124,125,126,127,sum64,+,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,sum64,+,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,sum64,+,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,sum64,+,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,sum64,+,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,sum64,+,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,sum64,+,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,sum64,+,/", "7ca2a2b9-a4eb-ce23-d163-59147e672396"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39289); internal_counters.push_back(39546); internal_counters.push_back(39803); internal_counters.push_back(40060); internal_counters.push_back(40317); internal_counters.push_back(40574); internal_counters.push_back(40831); internal_counters.push_back(41088); internal_counters.push_back(41345); internal_counters.push_back(41602); internal_counters.push_back(41859); internal_counters.push_back(42116); internal_counters.push_back(42373); internal_counters.push_back(42630); internal_counters.push_back(42887); internal_counters.push_back(43144); internal_counters.push_back(49743); c.DefineDerivedCounter("DepthStencilTestBusy", "Timing", "Percentage of time GPU spent performing depth and stencil tests relative to GPUBusy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "6834fb52-42e8-bb50-fd48-ec2f2904e7e0"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39289); internal_counters.push_back(39546); internal_counters.push_back(39803); internal_counters.push_back(40060); internal_counters.push_back(40317); internal_counters.push_back(40574); internal_counters.push_back(40831); internal_counters.push_back(41088); internal_counters.push_back(41345); internal_counters.push_back(41602); internal_counters.push_back(41859); internal_counters.push_back(42116); internal_counters.push_back(42373); internal_counters.push_back(42630); internal_counters.push_back(42887); internal_counters.push_back(43144); c.DefineDerivedCounter("DepthStencilTestBusyCount", "Timing", "Number of GPU cycles spent performing depth and stencil tests.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "e02860fa-c7bd-90ea-2149-69b4e98a636c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39160); internal_counters.push_back(39417); internal_counters.push_back(39674); internal_counters.push_back(39931); internal_counters.push_back(40188); internal_counters.push_back(40445); internal_counters.push_back(40702); internal_counters.push_back(40959); internal_counters.push_back(41216); internal_counters.push_back(41473); internal_counters.push_back(41730); internal_counters.push_back(41987); internal_counters.push_back(42244); internal_counters.push_back(42501); internal_counters.push_back(42758); internal_counters.push_back(43015); internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("HiZTilesAccepted", "DepthAndStencil", "Percentage of tiles accepted by HiZ and will be rendered to the depth or color buffers.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,/,(100),*", "56176f45-d7ff-813d-4f05-3b2f046067e7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("HiZTilesAcceptedCount", "DepthAndStencil", "Count of tiles accepted by HiZ and will be rendered to the depth or color buffers.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "95d4e3f6-b2f0-f26e-8423-aacdfaf79ea3"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39160); internal_counters.push_back(39417); internal_counters.push_back(39674); internal_counters.push_back(39931); internal_counters.push_back(40188); internal_counters.push_back(40445); internal_counters.push_back(40702); internal_counters.push_back(40959); internal_counters.push_back(41216); internal_counters.push_back(41473); internal_counters.push_back(41730); internal_counters.push_back(41987); internal_counters.push_back(42244); internal_counters.push_back(42501); internal_counters.push_back(42758); internal_counters.push_back(43015); c.DefineDerivedCounter("HiZTilesRejectedCount", "DepthAndStencil", "Count of tiles not accepted by HiZ.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "156ba142-7eeb-aa6e-a00a-f8aea4e41e0b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); internal_counters.push_back(39173); internal_counters.push_back(39430); internal_counters.push_back(39687); internal_counters.push_back(39944); internal_counters.push_back(40201); internal_counters.push_back(40458); internal_counters.push_back(40715); internal_counters.push_back(40972); internal_counters.push_back(41229); internal_counters.push_back(41486); internal_counters.push_back(41743); internal_counters.push_back(42000); internal_counters.push_back(42257); internal_counters.push_back(42514); internal_counters.push_back(42771); internal_counters.push_back(43028); c.DefineDerivedCounter("PreZTilesDetailCulled", "DepthAndStencil", "Percentage of tiles rejected because the associated prim had no contributing area.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "cad7f54d-a044-7574-c472-6f2065cbeeac"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39173); internal_counters.push_back(39430); internal_counters.push_back(39687); internal_counters.push_back(39944); internal_counters.push_back(40201); internal_counters.push_back(40458); internal_counters.push_back(40715); internal_counters.push_back(40972); internal_counters.push_back(41229); internal_counters.push_back(41486); internal_counters.push_back(41743); internal_counters.push_back(42000); internal_counters.push_back(42257); internal_counters.push_back(42514); internal_counters.push_back(42771); internal_counters.push_back(43028); c.DefineDerivedCounter("PreZTilesDetailCulledCount", "DepthAndStencil", "Count of tiles rejected because the associated primitive had no contributing area.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "49262c8a-b1e6-90dd-f096-0fc4921715e9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("PreZTilesDetailSurvivingCount", "DepthAndStencil", "Count of tiles surviving because the associated primitive had contributing area.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "f803eaa4-bbed-bd39-775f-a64df92e2c08"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsCulled", "DepthAndStencil", "Percentage of quads that did not have to continue on in the pipeline after HiZ. They may be written directly to the depth buffer, or culled completely. Consistently low values here may suggest that the Z-range is not being fully utilized.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "fa0e319b-5573-6d34-5bab-904769925036"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsCulledCount", "DepthAndStencil", "Count of quads that did not have to continue on in the pipeline after HiZ. They may be written directly to the depth buffer, or culled completely. Consistently low values here may suggest that the Z-range is not being fully utilized.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max", "73b0b39d-6df2-3e24-0b5c-7cb0ac8b6f39"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsAcceptedCount", "DepthAndStencil", "Count of quads that did continue on in the pipeline after HiZ.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "59049ad9-42b5-c7cb-3616-6a8f6a8e4894"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsCulled", "DepthAndStencil", "Percentage of quads rejected based on the detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,sum16,16,17,18,19,sum4,-,(0),max,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "4e77547b-ec55-5663-f034-af59be66d77d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsCulledCount", "DepthAndStencil", "Count of quads rejected based on the detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,sum4,+", "1bf169e6-9304-834e-df5f-0c44d7890a08"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsSurvivingCount", "DepthAndStencil", "Count of quads surviving detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max", "50e25e51-3713-89cb-7f92-559cde5e5532"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); c.DefineDerivedCounter("PostZQuads", "DepthAndStencil", "Percentage of quads for which the pixel shader will run and may be postZ tested.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,sum16,/,(100),*", "58f0d34b-eeb8-e8db-abce-cb72584144be"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); c.DefineDerivedCounter("PostZQuadCount", "DepthAndStencil", "Count of quads for which the pixel shader will run and may be postZ tested.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "08404526-ce35-939b-34c8-a7a35a0ff4d6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39322); internal_counters.push_back(39579); internal_counters.push_back(39836); internal_counters.push_back(40093); internal_counters.push_back(40350); internal_counters.push_back(40607); internal_counters.push_back(40864); internal_counters.push_back(41121); internal_counters.push_back(41378); internal_counters.push_back(41635); internal_counters.push_back(41892); internal_counters.push_back(42149); internal_counters.push_back(42406); internal_counters.push_back(42663); internal_counters.push_back(42920); internal_counters.push_back(43177); c.DefineDerivedCounter("PreZSamplesPassing", "DepthAndStencil", "Number of samples tested for Z before shading and passed.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "3bfe6c4d-7422-ca03-7ea5-e67ff1a00136"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39324); internal_counters.push_back(39581); internal_counters.push_back(39838); internal_counters.push_back(40095); internal_counters.push_back(40352); internal_counters.push_back(40609); internal_counters.push_back(40866); internal_counters.push_back(41123); internal_counters.push_back(41380); internal_counters.push_back(41637); internal_counters.push_back(41894); internal_counters.push_back(42151); internal_counters.push_back(42408); internal_counters.push_back(42665); internal_counters.push_back(42922); internal_counters.push_back(43179); c.DefineDerivedCounter("PreZSamplesFailingS", "DepthAndStencil", "Number of samples tested for Z before shading and failed stencil test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "df7f705e-5162-d3b5-da8b-63466cf9c4e5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39323); internal_counters.push_back(39580); internal_counters.push_back(39837); internal_counters.push_back(40094); internal_counters.push_back(40351); internal_counters.push_back(40608); internal_counters.push_back(40865); internal_counters.push_back(41122); internal_counters.push_back(41379); internal_counters.push_back(41636); internal_counters.push_back(41893); internal_counters.push_back(42150); internal_counters.push_back(42407); internal_counters.push_back(42664); internal_counters.push_back(42921); internal_counters.push_back(43178); c.DefineDerivedCounter("PreZSamplesFailingZ", "DepthAndStencil", "Number of samples tested for Z before shading and failed Z test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "4484e950-f7a4-3800-bc74-78dd297f017e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39319); internal_counters.push_back(39576); internal_counters.push_back(39833); internal_counters.push_back(40090); internal_counters.push_back(40347); internal_counters.push_back(40604); internal_counters.push_back(40861); internal_counters.push_back(41118); internal_counters.push_back(41375); internal_counters.push_back(41632); internal_counters.push_back(41889); internal_counters.push_back(42146); internal_counters.push_back(42403); internal_counters.push_back(42660); internal_counters.push_back(42917); internal_counters.push_back(43174); c.DefineDerivedCounter("PostZSamplesPassing", "DepthAndStencil", "Number of samples tested for Z after shading and passed.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "4995d5d6-2330-b986-508b-fae24856f44c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39321); internal_counters.push_back(39578); internal_counters.push_back(39835); internal_counters.push_back(40092); internal_counters.push_back(40349); internal_counters.push_back(40606); internal_counters.push_back(40863); internal_counters.push_back(41120); internal_counters.push_back(41377); internal_counters.push_back(41634); internal_counters.push_back(41891); internal_counters.push_back(42148); internal_counters.push_back(42405); internal_counters.push_back(42662); internal_counters.push_back(42919); internal_counters.push_back(43176); c.DefineDerivedCounter("PostZSamplesFailingS", "DepthAndStencil", "Number of samples tested for Z after shading and failed stencil test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "ae558af4-f4be-3dd4-7316-b2c4dcf0def8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39320); internal_counters.push_back(39577); internal_counters.push_back(39834); internal_counters.push_back(40091); internal_counters.push_back(40348); internal_counters.push_back(40605); internal_counters.push_back(40862); internal_counters.push_back(41119); internal_counters.push_back(41376); internal_counters.push_back(41633); internal_counters.push_back(41890); internal_counters.push_back(42147); internal_counters.push_back(42404); internal_counters.push_back(42661); internal_counters.push_back(42918); internal_counters.push_back(43175); c.DefineDerivedCounter("PostZSamplesFailingZ", "DepthAndStencil", "Number of samples tested for Z after shading and failed Z test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "b3684c94-814a-c695-c85d-a5b6ab798b35"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39191); internal_counters.push_back(39448); internal_counters.push_back(39705); internal_counters.push_back(39962); internal_counters.push_back(40219); internal_counters.push_back(40476); internal_counters.push_back(40733); internal_counters.push_back(40990); internal_counters.push_back(41247); internal_counters.push_back(41504); internal_counters.push_back(41761); internal_counters.push_back(42018); internal_counters.push_back(42275); internal_counters.push_back(42532); internal_counters.push_back(42789); internal_counters.push_back(43046); internal_counters.push_back(49743); c.DefineDerivedCounter("ZUnitStalled", "DepthAndStencil", "The percentage of GPUTime the depth buffer spends waiting for the color buffer to be ready to accept data. High figures here indicate a bottleneck in color buffer operations.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "5e86c3ad-1726-3157-1d01-7ed188bf854d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39191); internal_counters.push_back(39448); internal_counters.push_back(39705); internal_counters.push_back(39962); internal_counters.push_back(40219); internal_counters.push_back(40476); internal_counters.push_back(40733); internal_counters.push_back(40990); internal_counters.push_back(41247); internal_counters.push_back(41504); internal_counters.push_back(41761); internal_counters.push_back(42018); internal_counters.push_back(42275); internal_counters.push_back(42532); internal_counters.push_back(42789); internal_counters.push_back(43046); c.DefineDerivedCounter("ZUnitStalledCycles", "DepthAndStencil", "Number of GPU cycles the depth buffer spends waiting for the color buffer to be ready to accept data. Larger numbers indicate a bottleneck in color buffer operations.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "4351fa7f-6737-2c3e-3ffb-b3addbdceedd"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39193); internal_counters.push_back(39450); internal_counters.push_back(39707); internal_counters.push_back(39964); internal_counters.push_back(40221); internal_counters.push_back(40478); internal_counters.push_back(40735); internal_counters.push_back(40992); internal_counters.push_back(41249); internal_counters.push_back(41506); internal_counters.push_back(41763); internal_counters.push_back(42020); internal_counters.push_back(42277); internal_counters.push_back(42534); internal_counters.push_back(42791); internal_counters.push_back(43048); internal_counters.push_back(39200); internal_counters.push_back(39457); internal_counters.push_back(39714); internal_counters.push_back(39971); internal_counters.push_back(40228); internal_counters.push_back(40485); internal_counters.push_back(40742); internal_counters.push_back(40999); internal_counters.push_back(41256); internal_counters.push_back(41513); internal_counters.push_back(41770); internal_counters.push_back(42027); internal_counters.push_back(42284); internal_counters.push_back(42541); internal_counters.push_back(42798); internal_counters.push_back(43055); c.DefineDerivedCounter("DBMemRead", "DepthAndStencil", "Number of bytes read from the depth buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(256),*,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,(32),*,+", "dcdb4ee7-bd50-00f7-c028-9e5f4ce888c0"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39205); internal_counters.push_back(39462); internal_counters.push_back(39719); internal_counters.push_back(39976); internal_counters.push_back(40233); internal_counters.push_back(40490); internal_counters.push_back(40747); internal_counters.push_back(41004); internal_counters.push_back(41261); internal_counters.push_back(41518); internal_counters.push_back(41775); internal_counters.push_back(42032); internal_counters.push_back(42289); internal_counters.push_back(42546); internal_counters.push_back(42803); internal_counters.push_back(43060); internal_counters.push_back(39208); internal_counters.push_back(39465); internal_counters.push_back(39722); internal_counters.push_back(39979); internal_counters.push_back(40236); internal_counters.push_back(40493); internal_counters.push_back(40750); internal_counters.push_back(41007); internal_counters.push_back(41264); internal_counters.push_back(41521); internal_counters.push_back(41778); internal_counters.push_back(42035); internal_counters.push_back(42292); internal_counters.push_back(42549); internal_counters.push_back(42806); internal_counters.push_back(43063); c.DefineDerivedCounter("DBMemWritten", "DepthAndStencil", "Number of bytes written to the depth buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,(32),*,+", "de5717f8-8a49-ee44-4645-10de51b37dcf"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43385); internal_counters.push_back(43781); internal_counters.push_back(44177); internal_counters.push_back(44573); internal_counters.push_back(44969); internal_counters.push_back(45365); internal_counters.push_back(45761); internal_counters.push_back(46157); internal_counters.push_back(46553); internal_counters.push_back(46949); internal_counters.push_back(47345); internal_counters.push_back(47741); internal_counters.push_back(48137); internal_counters.push_back(48533); internal_counters.push_back(48929); internal_counters.push_back(49325); c.DefineDerivedCounter("CBMemRead", "ColorBuffer", "Number of bytes read from the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "84b531d8-a1f8-7f49-7c27-7bc97801f1e6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43516); internal_counters.push_back(43912); internal_counters.push_back(44308); internal_counters.push_back(44704); internal_counters.push_back(45100); internal_counters.push_back(45496); internal_counters.push_back(45892); internal_counters.push_back(46288); internal_counters.push_back(46684); internal_counters.push_back(47080); internal_counters.push_back(47476); internal_counters.push_back(47872); internal_counters.push_back(48268); internal_counters.push_back(48664); internal_counters.push_back(49060); internal_counters.push_back(49456); internal_counters.push_back(43383); internal_counters.push_back(43779); internal_counters.push_back(44175); internal_counters.push_back(44571); internal_counters.push_back(44967); internal_counters.push_back(45363); internal_counters.push_back(45759); internal_counters.push_back(46155); internal_counters.push_back(46551); internal_counters.push_back(46947); internal_counters.push_back(47343); internal_counters.push_back(47739); internal_counters.push_back(48135); internal_counters.push_back(48531); internal_counters.push_back(48927); internal_counters.push_back(49323); internal_counters.push_back(43384); internal_counters.push_back(43780); internal_counters.push_back(44176); internal_counters.push_back(44572); internal_counters.push_back(44968); internal_counters.push_back(45364); internal_counters.push_back(45760); internal_counters.push_back(46156); internal_counters.push_back(46552); internal_counters.push_back(46948); internal_counters.push_back(47344); internal_counters.push_back(47740); internal_counters.push_back(48136); internal_counters.push_back(48532); internal_counters.push_back(48928); internal_counters.push_back(49324); internal_counters.push_back(43385); internal_counters.push_back(43781); internal_counters.push_back(44177); internal_counters.push_back(44573); internal_counters.push_back(44969); internal_counters.push_back(45365); internal_counters.push_back(45761); internal_counters.push_back(46157); internal_counters.push_back(46553); internal_counters.push_back(46949); internal_counters.push_back(47345); internal_counters.push_back(47741); internal_counters.push_back(48137); internal_counters.push_back(48533); internal_counters.push_back(48929); internal_counters.push_back(49325); c.DefineDerivedCounter("CBColorAndMaskRead", "ColorBuffer", "Total number of bytes read from the color and mask buffers.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,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,sum64,(32),*", "da41660e-eb6f-32ec-8a64-b32ca17bd7eb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43375); internal_counters.push_back(43771); internal_counters.push_back(44167); internal_counters.push_back(44563); internal_counters.push_back(44959); internal_counters.push_back(45355); internal_counters.push_back(45751); internal_counters.push_back(46147); internal_counters.push_back(46543); internal_counters.push_back(46939); internal_counters.push_back(47335); internal_counters.push_back(47731); internal_counters.push_back(48127); internal_counters.push_back(48523); internal_counters.push_back(48919); internal_counters.push_back(49315); c.DefineDerivedCounter("CBMemWritten", "ColorBuffer", "Number of bytes written to the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "550f8ff8-60b6-a6bf-87d0-25ac9e87de70"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43514); internal_counters.push_back(43910); internal_counters.push_back(44306); internal_counters.push_back(44702); internal_counters.push_back(45098); internal_counters.push_back(45494); internal_counters.push_back(45890); internal_counters.push_back(46286); internal_counters.push_back(46682); internal_counters.push_back(47078); internal_counters.push_back(47474); internal_counters.push_back(47870); internal_counters.push_back(48266); internal_counters.push_back(48662); internal_counters.push_back(49058); internal_counters.push_back(49454); internal_counters.push_back(43373); internal_counters.push_back(43769); internal_counters.push_back(44165); internal_counters.push_back(44561); internal_counters.push_back(44957); internal_counters.push_back(45353); internal_counters.push_back(45749); internal_counters.push_back(46145); internal_counters.push_back(46541); internal_counters.push_back(46937); internal_counters.push_back(47333); internal_counters.push_back(47729); internal_counters.push_back(48125); internal_counters.push_back(48521); internal_counters.push_back(48917); internal_counters.push_back(49313); internal_counters.push_back(43374); internal_counters.push_back(43770); internal_counters.push_back(44166); internal_counters.push_back(44562); internal_counters.push_back(44958); internal_counters.push_back(45354); internal_counters.push_back(45750); internal_counters.push_back(46146); internal_counters.push_back(46542); internal_counters.push_back(46938); internal_counters.push_back(47334); internal_counters.push_back(47730); internal_counters.push_back(48126); internal_counters.push_back(48522); internal_counters.push_back(48918); internal_counters.push_back(49314); internal_counters.push_back(43375); internal_counters.push_back(43771); internal_counters.push_back(44167); internal_counters.push_back(44563); internal_counters.push_back(44959); internal_counters.push_back(45355); internal_counters.push_back(45751); internal_counters.push_back(46147); internal_counters.push_back(46543); internal_counters.push_back(46939); internal_counters.push_back(47335); internal_counters.push_back(47731); internal_counters.push_back(48127); internal_counters.push_back(48523); internal_counters.push_back(48919); internal_counters.push_back(49315); c.DefineDerivedCounter("CBColorAndMaskWritten", "ColorBuffer", "Total number of bytes written to the color and mask buffers.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,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,sum64,(32),*", "29a04b69-8f5f-b770-a0f2-3453e2c99e49"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43419); internal_counters.push_back(43815); internal_counters.push_back(44211); internal_counters.push_back(44607); internal_counters.push_back(45003); internal_counters.push_back(45399); internal_counters.push_back(45795); internal_counters.push_back(46191); internal_counters.push_back(46587); internal_counters.push_back(46983); internal_counters.push_back(47379); internal_counters.push_back(47775); internal_counters.push_back(48171); internal_counters.push_back(48567); internal_counters.push_back(48963); internal_counters.push_back(49359); internal_counters.push_back(43264); internal_counters.push_back(43660); internal_counters.push_back(44056); internal_counters.push_back(44452); internal_counters.push_back(44848); internal_counters.push_back(45244); internal_counters.push_back(45640); internal_counters.push_back(46036); internal_counters.push_back(46432); internal_counters.push_back(46828); internal_counters.push_back(47224); internal_counters.push_back(47620); internal_counters.push_back(48016); internal_counters.push_back(48412); internal_counters.push_back(48808); internal_counters.push_back(49204); c.DefineDerivedCounter("CBSlowPixelPct", "ColorBuffer", "Percentage of pixels written to the color buffer using a half-rate or quarter-rate format.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,/,(100),*,(100),min", "5775943f-0313-7e52-9638-b24a449197bc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43419); internal_counters.push_back(43815); internal_counters.push_back(44211); internal_counters.push_back(44607); internal_counters.push_back(45003); internal_counters.push_back(45399); internal_counters.push_back(45795); internal_counters.push_back(46191); internal_counters.push_back(46587); internal_counters.push_back(46983); internal_counters.push_back(47379); internal_counters.push_back(47775); internal_counters.push_back(48171); internal_counters.push_back(48567); internal_counters.push_back(48963); internal_counters.push_back(49359); c.DefineDerivedCounter("CBSlowPixelCount", "ColorBuffer", "Number of pixels written to the color buffer using a half-rate or quarter-rate format.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "47eacbb0-28c8-22b4-5c69-c00d5813bb1c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36038); internal_counters.push_back(36230); internal_counters.push_back(36422); internal_counters.push_back(36614); internal_counters.push_back(36806); internal_counters.push_back(36998); internal_counters.push_back(37190); internal_counters.push_back(37382); internal_counters.push_back(37574); internal_counters.push_back(37766); internal_counters.push_back(37958); internal_counters.push_back(38150); internal_counters.push_back(38342); internal_counters.push_back(38534); internal_counters.push_back(38726); internal_counters.push_back(38918); c.DefineDerivedCounter("FetchSize", "GlobalMemory", "The total bytes fetched from the video memory. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "664bb3ef-6eca-86b1-1e2d-30cb897b5fa9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36029); internal_counters.push_back(36221); internal_counters.push_back(36413); internal_counters.push_back(36605); internal_counters.push_back(36797); internal_counters.push_back(36989); internal_counters.push_back(37181); internal_counters.push_back(37373); internal_counters.push_back(37565); internal_counters.push_back(37757); internal_counters.push_back(37949); internal_counters.push_back(38141); internal_counters.push_back(38333); internal_counters.push_back(38525); internal_counters.push_back(38717); internal_counters.push_back(38909); c.DefineDerivedCounter("WriteSize", "GlobalMemory", "The total bytes written to the video memory. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "f96f2c16-b1b4-4ec4-229c-fc82e6f80a82"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheHit", "GlobalMemory", "The percentage of fetch, write, atomic, and other instructions that hit the data cache. Value range: 0% (no hit) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,+,/,(100),*", "dfbeebab-f7c1-1211-e502-4aae361e2ad7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheMiss", "GlobalMemory", "The percentage of fetch, write, atomic, and other instructions that miss the data cache. Value range: 0% (optimal) to 100% (all miss).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,+,/,(100),*", "aebc0a53-7f87-60bd-4c4b-2b956846ef83"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); c.DefineDerivedCounter("CacheHitCount", "GlobalMemory", "Count of fetch, write, atomic, and other instructions that hit the data cache.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "43437652-1024-9737-2eb0-0899c0c1feae"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheMissCount", "GlobalMemory", "Count of fetch, write, atomic, and other instructions that miss the data cache.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "d0f8a812-f41b-644f-09d1-14ee03ea3671"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); c.DefineDerivedCounter("MemUnitBusy", "GlobalMemory", "The percentage of GPUTime the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account. Value range: 0% to 100% (fetch-bound).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,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,max64,64,/,(100),*", "a1efa380-4a72-e066-e06a-2ab71a488521"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); c.DefineDerivedCounter("MemUnitBusyCycles", "GlobalMemory", "Number of GPU cycles the memory unit is active. The result includes the stall time (MemUnitStalledCycles). This is measured with all extra fetches and writes and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,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,max64", "168f077c-4797-b2f5-717f-105c725266c8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(49743); c.DefineDerivedCounter("MemUnitStalled", "GlobalMemory", "The percentage of GPUTime the memory unit is stalled. Try reducing the number or size of fetches and writes if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,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,max64,64,/,(100),*", "465ba54f-d250-1453-790a-731b10d230b1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); c.DefineDerivedCounter("MemUnitStalledCycles", "GlobalMemory", "Number of GPU cycles the memory unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,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,max64", "2745659a-0e40-bace-3b9b-86a54f8e4623"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(49743); c.DefineDerivedCounter("WriteUnitStalled", "GlobalMemory", "The percentage of GPUTime the Write unit is stalled. Value range: 0% to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "594ad3ce-d1ec-10fc-7d59-25738e397d72"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); c.DefineDerivedCounter("WriteUnitStalledCycles", "GlobalMemory", "Number of GPU cycles the Write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "ede3305e-abd4-d6bf-6b00-ffc57a29fce3"); } }
51.388749
5,062
0.708009
AdamJMiles
d672c802c84915fc4e0b55e4bc0f6d3631ff8741
43,112
cpp
C++
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
7
2015-03-10T03:36:16.000Z
2021-11-05T01:16:58.000Z
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
1
2020-06-23T10:02:33.000Z
2020-06-24T02:05:47.000Z
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
null
null
null
#include <mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.h> #include <mscorlib/System/mscorlib_System_String.h> #include <mscorlib/Microsoft/Win32/SafeHandles/mscorlib_Microsoft_Win32_SafeHandles_SafeRegistryHandle.h> #include <mscorlib/System/Security/AccessControl/mscorlib_System_Security_AccessControl_RegistrySecurity.h> #include <mscorlib/System/Runtime/Remoting/mscorlib_System_Runtime_Remoting_ObjRef.h> #include <mscorlib/System/mscorlib_System_Type.h> namespace mscorlib { namespace Microsoft { namespace Win32 { //Public Methods void RegistryKey::Dispose() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Dispose", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::Flush() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Flush", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::Close() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Close", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::SetValue(mscorlib::System::String name, mscorlib::System::Object value) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)value; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(const char *name, mscorlib::System::Object value) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)value; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(mscorlib::System::String name, mscorlib::System::Object value, mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ valueKind) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameter_types__[2] = Global::GetType(typeid(valueKind).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)value; mscorlib::System::Int32 __param_valueKind__ = valueKind; __parameters__[2] = &__param_valueKind__; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(const char *name, mscorlib::System::Object value, mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ valueKind) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameter_types__[2] = Global::GetType(typeid(valueKind).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)value; mscorlib::System::Int32 __param_valueKind__ = valueKind; __parameters__[2] = &__param_valueKind__; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::System::Boolean writable) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(writable).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = reinterpret_cast<void*>(writable); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::System::Boolean writable) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(writable).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = reinterpret_cast<void*>(writable); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name, mscorlib::System::Object defaultValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)defaultValue; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name, mscorlib::System::Object defaultValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)defaultValue; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name, mscorlib::System::Object defaultValue, mscorlib::Microsoft::Win32::RegistryValueOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)defaultValue; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name, mscorlib::System::Object defaultValue, mscorlib::Microsoft::Win32::RegistryValueOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)defaultValue; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ RegistryKey::GetValueKind(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueKind", __native_object__, 1, __parameter_types__, __parameters__, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ RegistryKey::GetValueKind(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueKind", __native_object__, 1, __parameter_types__, __parameters__, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; __parameters__[2] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; __parameters__[2] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ registryOptions, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[4]; void *__parameters__[4]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registryOptions).name()); __parameter_types__[3] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_registryOptions__ = registryOptions; __parameters__[2] = &__param_registryOptions__; __parameters__[3] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 4, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ registryOptions, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[4]; void *__parameters__[4]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registryOptions).name()); __parameter_types__[3] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_registryOptions__ = registryOptions; __parameters__[2] = &__param_registryOptions__; __parameters__[3] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 4, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } void RegistryKey::DeleteSubKey(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(mscorlib::System::String subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = (MonoObject*)subkey; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(const char *subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(mscorlib::System::String subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = (MonoObject*)subkey; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(const char *subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(mscorlib::System::String name, mscorlib::System::Boolean throwOnMissingValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingValue).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingValue); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(const char *name, mscorlib::System::Boolean throwOnMissingValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingValue).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingValue); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } mscorlib::System::Security::AccessControl::RegistrySecurity RegistryKey::GetAccessControl() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetAccessControl", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::Security::AccessControl::RegistrySecurity(__result__); } mscorlib::System::Security::AccessControl::RegistrySecurity RegistryKey::GetAccessControl(mscorlib::System::Security::AccessControl::AccessControlSections::__ENUM__ includeSections) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(includeSections).name()); mscorlib::System::Int32 __param_includeSections__ = includeSections; __parameters__[0] = &__param_includeSections__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetAccessControl", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Security::AccessControl::RegistrySecurity(__result__); } std::vector<mscorlib::System::String*> RegistryKey::GetSubKeyNames() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetSubKeyNames", __native_object__, 0, NULL, NULL, NULL); MonoArray *__array_ptr__ = (MonoArray*)__result__; uintptr_t __array_length__ = mono_array_length(__array_ptr__); std::vector<mscorlib::System::String*> __array_result__(__array_length__); for(uintptr_t __array_index__ = 0; __array_index__ < __array_length__; __array_index__++) { MonoObject *__array_item__ = mono_array_get(__array_ptr__,MonoObject*,__array_index__); __array_result__.push_back(new mscorlib::System::String (__array_item__)); } return __array_result__; } std::vector<mscorlib::System::String*> RegistryKey::GetValueNames() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueNames", __native_object__, 0, NULL, NULL, NULL); MonoArray *__array_ptr__ = (MonoArray*)__result__; uintptr_t __array_length__ = mono_array_length(__array_ptr__); std::vector<mscorlib::System::String*> __array_result__(__array_length__); for(uintptr_t __array_index__ = 0; __array_index__ < __array_length__; __array_index__++) { MonoObject *__array_item__ = mono_array_get(__array_ptr__,MonoObject*,__array_index__); __array_result__.push_back(new mscorlib::System::String (__array_item__)); } return __array_result__; } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::FromHandle(mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle handle) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(handle).name()); __parameters__[0] = (MonoObject*)handle; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "FromHandle", NullMonoObject, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::FromHandle(mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle handle, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(handle).name()); __parameter_types__[1] = Global::GetType(typeid(view).name()); __parameters__[0] = (MonoObject*)handle; mscorlib::System::Int32 __param_view__ = view; __parameters__[1] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "FromHandle", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::System::String machineName) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(machineName).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = (MonoObject*)machineName; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, const char *machineName) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType("mscorlib", "System", "String"); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = mono_string_new(Global::GetDomain(), machineName); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::System::String machineName, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(machineName).name()); __parameter_types__[2] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = (MonoObject*)machineName; mscorlib::System::Int32 __param_view__ = view; __parameters__[2] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, const char *machineName, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[2] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = mono_string_new(Global::GetDomain(), machineName); mscorlib::System::Int32 __param_view__ = view; __parameters__[2] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; mscorlib::System::Int32 __param_view__ = view; __parameters__[1] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = (MonoObject*)name; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistryRights::__ENUM__ rights) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(rights).name()); __parameters__[0] = (MonoObject*)name; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_rights__ = rights; __parameters__[2] = &__param_rights__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistryRights::__ENUM__ rights) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(rights).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_rights__ = rights; __parameters__[2] = &__param_rights__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } void RegistryKey::SetAccessControl(mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)registrySecurity; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetAccessControl", __native_object__, 1, __parameter_types__, __parameters__, NULL); } mscorlib::System::String RegistryKey::ToString() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "ToString", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::String(__result__); } //Get Set Properties Methods // Get:Name mscorlib::System::String RegistryKey::get_Name() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_Name", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::String(__result__); } // Get:SubKeyCount mscorlib::System::Int32 RegistryKey::get_SubKeyCount() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_SubKeyCount", __native_object__, 0, NULL, NULL, NULL); return *(mscorlib::System::Int32*)mono_object_unbox(__result__); } // Get:ValueCount mscorlib::System::Int32 RegistryKey::get_ValueCount() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_ValueCount", __native_object__, 0, NULL, NULL, NULL); return *(mscorlib::System::Int32*)mono_object_unbox(__result__); } // Get:Handle mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle RegistryKey::get_Handle() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_Handle", __native_object__, 0, NULL, NULL, NULL); return mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle(__result__); } // Get:View mscorlib::Microsoft::Win32::RegistryView::__ENUM__ RegistryKey::get_View() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_View", __native_object__, 0, NULL, NULL, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryView::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } } } }
58.024226
332
0.733531
brunolauze
d673d0c37431ecff31e029d1f3ab6af51f5cec84
376
cpp
C++
Leetcode_9.cpp
xulu199705/LeetCode
9a654a10117a93f9ad9728d6b86eb3713185545e
[ "MIT" ]
null
null
null
Leetcode_9.cpp
xulu199705/LeetCode
9a654a10117a93f9ad9728d6b86eb3713185545e
[ "MIT" ]
null
null
null
Leetcode_9.cpp
xulu199705/LeetCode
9a654a10117a93f9ad9728d6b86eb3713185545e
[ "MIT" ]
null
null
null
// Palindrome Number #include "leetcode.h" class Solution { public: bool isPalindrome(int x) { string str = std::to_string(x); string str_rev = str; reverse(str_rev.begin(),str_rev.end()); return (str == str_rev ? true : false); } }; static auto speedup = [](){ ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
18.8
47
0.585106
xulu199705