Merge pull request #9 from otavepto/patch-user-stats-icon

Implement `Steam_User_Stats::GetAchievementIcon()`
This commit is contained in:
Detanup01 2024-08-18 19:02:45 +02:00 committed by GitHub
commit f1d4ba689b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 2514 additions and 18624 deletions

View File

@ -29,7 +29,7 @@ const std::chrono::time_point<std::chrono::high_resolution_clock> startup_counte
const std::chrono::time_point<std::chrono::system_clock> startup_time = std::chrono::system_clock::now();
#ifndef EMU_RELEASE_BUILD
dbg_log dbg_logger(get_full_program_path() + "STEAM_LOG.txt");
dbg_log dbg_logger(get_full_program_path() + "STEAM_LOG_" + std::to_string(common_helpers::rand_number(UINT32_MAX)) + ".log");
#endif

View File

@ -208,11 +208,15 @@ private:
std::map<std::string, Leaderboard_config> leaderboards{};
std::map<std::string, Stat_config> stats{};
std::map<size_t, struct Image_Data> images{};
//supported languages
std::set<std::string> supported_languages_set{};
std::string supported_languages{};
public:
constexpr const static int INVALID_IMAGE_HANDLE = 0;
//Depots
std::vector<DepotId_t> depots{};
@ -253,6 +257,9 @@ public:
// when a stat that's tied to an achievement gets a new value, should the emu save that progress only if it's higher?
// the stat itself is always saved regardless of that flag, only affects the achievement progress
bool save_only_higher_stat_achievement_progress = true;
// the emulator loads the achievements icons is memory mainly for `ISteamUserStats::GetAchievementIcon()`
// true means load icons lazily when they are requested, otherwise load icons as soon as the interface ISteamUserStats is initialized
bool lazy_load_achievements_icons = true;
// bypass to make SetAchievement() always return true, prevent some games from breaking
bool achievement_bypass = false;
@ -265,8 +272,6 @@ public:
// enable owning Steam Applications IDs (mostly builtin apps + dedicated servers)
bool enable_builtin_preowned_ids = false;
std::map<int, struct Image_Data> images{};
//subscribed lobby/group ids
std::set<uint64> subscribed_groups{};
std::vector<Group_Clans> subscribed_groups_clans{};
@ -383,6 +388,7 @@ public:
//images
int add_image(const std::string &data, uint32 width, uint32 height);
Image_Data* get_image(int handle);
// overlay auto accept stuff
void acceptAnyOverlayInvites(bool value);

View File

@ -71,6 +71,7 @@ public ISteamUserStats
{
public:
static constexpr auto achievements_user_file = "achievements.json";
static constexpr int UNLOADED_ACH_ICON = -1;
private:
template<typename T>
@ -94,6 +95,8 @@ private:
nlohmann::json defined_achievements{};
nlohmann::json user_achievements{};
std::vector<std::string> sorted_achievement_names{};
bool achievements_icons_loaded = false;
std::map<std::string, int32> stats_cache_int{};
std::map<std::string, float> stats_cache_float{};
@ -109,6 +112,8 @@ private:
void load_achievements();
void save_achievements();
int load_ach_icon(nlohmann::json &defined_ach, bool achieved);
nlohmann::detail::iter_impl<nlohmann::json> defined_achievements_find(const std::string &key);
std::string get_value_for_language(const nlohmann::json &json, std::string_view key, std::string_view language);
@ -132,6 +137,7 @@ private:
InternalSetResult<bool> clear_achievement_internal( const char *pchName );
void send_updated_stats();
void load_achievements_icons();
void steam_run_callback();
// requests from server
@ -207,7 +213,9 @@ public:
// specified achievement.
int GetAchievementIcon( const char *pchName );
std::string get_achievement_icon_name( const char *pchName, bool pbAchieved );
int get_achievement_icon_handle( const std::string &ach_name, bool pbAchieved );
std::string get_achievement_icon_name( const char *pchName, bool achieved );
// Get general attributes for an achievement. Accepts the following keys:

View File

@ -859,9 +859,9 @@ std::vector<image_pixel_t> Local_Storage::load_image(std::string const& image_pa
std::vector<image_pixel_t> res{};
int width{}, height{};
image_pixel_t* img = (image_pixel_t*)stbi_load(image_path.c_str(), &width, &height, nullptr, 4);
if (img != nullptr)
{
res.resize(width*height);
PRINT_DEBUG("stbi_load('%s') -> %s", image_path.c_str(), (img ? "loaded" : stbi_failure_reason()));
if (img) {
res.resize(width * height);
std::copy(img, img + width * height, res.begin());
stbi_image_free(img);
@ -875,19 +875,18 @@ std::string Local_Storage::load_image_resized(std::string const& image_path, std
{
std::string resized_image{};
const size_t resized_img_size = resolution * resolution * 4;
if (image_path.length() > 0) {
if (image_path.size()) {
int width = 0;
int height = 0;
unsigned char *img = stbi_load(image_path.c_str(), &width, &height, nullptr, 4);
PRINT_DEBUG("stbi_load('%s') -> %s", image_path.c_str(), (img == nullptr ? stbi_failure_reason() : "loaded"));
if (img != nullptr) {
PRINT_DEBUG("stbi_load('%s') -> %s", image_path.c_str(), (img ? "loaded" : stbi_failure_reason()));
if (img) {
std::vector<char> out_resized(resized_img_size);
stbir_resize_uint8(img, width, height, 0, (unsigned char*)&out_resized[0], resolution, resolution, 0, 4);
resized_image = std::string((char*)&out_resized[0], out_resized.size());
stbi_image_free(img);
}
} else if (image_data.length() > 0) {
} else if (image_data.size()) {
std::vector<char> out_resized(resized_img_size);
stbir_resize_uint8((unsigned char*)image_data.c_str(), 184, 184, 0, (unsigned char*)&out_resized[0], resolution, resolution, 0, 4);
resized_image = std::string((char*)&out_resized[0], out_resized.size());

View File

@ -353,13 +353,37 @@ std::map<std::string, Stat_config>::const_iterator Settings::setStatDefiniton(co
int Settings::add_image(const std::string &data, uint32 width, uint32 height)
{
int last = static_cast<int>(images.size()) + 1;
struct Image_Data dt;
auto previous_it = std::find_if(images.begin(), images.end(), [&](const std::pair<const size_t, Image_Data> &item) {
return item.second.data == data
&& item.second.height == height
&& item.second.width == width;
});
if (images.end() != previous_it) {
return static_cast<int>(previous_it->first);
}
struct Image_Data dt{};
dt.width = width;
dt.height = height;
dt.data = data;
images[last] = dt;
return last;
auto new_handle = images.size() + 1; // never return 0, it is a bad handle for most ISteamUserStats APIs
images[new_handle] = dt;
return static_cast<int>(new_handle);
}
Image_Data* Settings::get_image(int handle)
{
if (INVALID_IMAGE_HANDLE == handle) {
return nullptr;
}
auto image_it = images.find(handle);
if (images.end() == image_it) {
return nullptr;
}
return &image_it->second;
}

View File

@ -1364,18 +1364,6 @@ static void parse_simple_features(class Settings *settings_client, class Setting
settings_client->steam_deck = ini.GetBoolValue("main::general", "steam_deck", settings_client->steam_deck);
settings_server->steam_deck = ini.GetBoolValue("main::general", "steam_deck", settings_server->steam_deck);
settings_client->disable_leaderboards_create_unknown = ini.GetBoolValue("main::general", "disable_leaderboards_create_unknown", settings_client->disable_leaderboards_create_unknown);
settings_server->disable_leaderboards_create_unknown = ini.GetBoolValue("main::general", "disable_leaderboards_create_unknown", settings_server->disable_leaderboards_create_unknown);
settings_client->allow_unknown_stats = ini.GetBoolValue("main::general", "allow_unknown_stats", settings_client->allow_unknown_stats);
settings_server->allow_unknown_stats = ini.GetBoolValue("main::general", "allow_unknown_stats", settings_server->allow_unknown_stats);
settings_client->stat_achievement_progress_functionality = ini.GetBoolValue("main::general", "stat_achievement_progress_functionality", settings_client->stat_achievement_progress_functionality);
settings_server->stat_achievement_progress_functionality = ini.GetBoolValue("main::general", "stat_achievement_progress_functionality", settings_server->stat_achievement_progress_functionality);
settings_client->save_only_higher_stat_achievement_progress = ini.GetBoolValue("main::general", "save_only_higher_stat_achievement_progress", settings_client->save_only_higher_stat_achievement_progress);
settings_server->save_only_higher_stat_achievement_progress = ini.GetBoolValue("main::general", "save_only_higher_stat_achievement_progress", settings_server->save_only_higher_stat_achievement_progress);
settings_client->immediate_gameserver_stats = ini.GetBoolValue("main::general", "immediate_gameserver_stats", settings_client->immediate_gameserver_stats);
settings_server->immediate_gameserver_stats = ini.GetBoolValue("main::general", "immediate_gameserver_stats", settings_server->immediate_gameserver_stats);
@ -1420,6 +1408,25 @@ static void parse_simple_features(class Settings *settings_client, class Setting
settings_server->enable_builtin_preowned_ids = ini.GetBoolValue("main::misc", "enable_steam_preowned_ids", settings_server->enable_builtin_preowned_ids);
}
// [main::stats]
static void parse_stats_features(class Settings *settings_client, class Settings *settings_server)
{
settings_client->disable_leaderboards_create_unknown = ini.GetBoolValue("main::stats", "disable_leaderboards_create_unknown", settings_client->disable_leaderboards_create_unknown);
settings_server->disable_leaderboards_create_unknown = ini.GetBoolValue("main::stats", "disable_leaderboards_create_unknown", settings_server->disable_leaderboards_create_unknown);
settings_client->allow_unknown_stats = ini.GetBoolValue("main::stats", "allow_unknown_stats", settings_client->allow_unknown_stats);
settings_server->allow_unknown_stats = ini.GetBoolValue("main::stats", "allow_unknown_stats", settings_server->allow_unknown_stats);
settings_client->stat_achievement_progress_functionality = ini.GetBoolValue("main::stats", "stat_achievement_progress_functionality", settings_client->stat_achievement_progress_functionality);
settings_server->stat_achievement_progress_functionality = ini.GetBoolValue("main::stats", "stat_achievement_progress_functionality", settings_server->stat_achievement_progress_functionality);
settings_client->save_only_higher_stat_achievement_progress = ini.GetBoolValue("main::stats", "save_only_higher_stat_achievement_progress", settings_client->save_only_higher_stat_achievement_progress);
settings_server->save_only_higher_stat_achievement_progress = ini.GetBoolValue("main::stats", "save_only_higher_stat_achievement_progress", settings_server->save_only_higher_stat_achievement_progress);
settings_client->lazy_load_achievements_icons = ini.GetBoolValue("main::stats", "lazy_load_achievements_icons", settings_client->lazy_load_achievements_icons);
settings_server->lazy_load_achievements_icons = ini.GetBoolValue("main::stats", "lazy_load_achievements_icons", settings_server->lazy_load_achievements_icons);
}
static std::map<SettingsItf, std::string> old_itfs_map{};
@ -1673,6 +1680,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
settings_server->set_supported_languages(supported_languages);
parse_simple_features(settings_client, settings_server);
parse_stats_features(settings_client, settings_server);
parse_dlc(settings_client, settings_server);
parse_installed_app_Ids(settings_client, settings_server);

View File

@ -1280,9 +1280,15 @@ void Steam_Friends::Callback(Common_Message *msg)
f->set_name(settings->get_local_name());
f->set_appid(settings->get_local_game_id().AppID());
f->set_lobby_id(settings->get_lobby().ConvertToUint64());
int avatar_number = GetLargeFriendAvatar(settings->get_local_steam_id());
if (settings->images[avatar_number].data.length() > 0) f->set_avatar(settings->images[avatar_number].data);
else f->set_avatar("");
auto avatar_info = settings->get_image(avatar_number);
if (avatar_info && avatar_info->data.size()) {
f->set_avatar(avatar_info->data);
} else {
f->set_avatar("");
}
msg_.set_allocated_friend_(f);
network->sendTo(&msg_, true);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,799 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
#include "dll/steam_user_stats.h"
#include <random>
// --- achievement_trigger ---
bool achievement_trigger::should_unlock_ach(float stat) const
{
try {
if (std::stof(max_value) <= stat) return true;
} catch (...) {}
return false;
}
bool achievement_trigger::should_unlock_ach(int32 stat) const
{
try {
if (std::stoi(max_value) <= stat) return true;
} catch (...) {}
return false;
}
bool achievement_trigger::should_indicate_progress(float stat) const
{
// show progress if number < max
try {
if (std::stof(max_value) > stat) return true;
} catch (...) {}
return false;
}
bool achievement_trigger::should_indicate_progress(int32 stat) const
{
// show progress if number < max
try {
if (std::stoi(max_value) > stat) return true;
} catch (...) {}
return false;
}
// --- achievement_trigger ---
void Steam_User_Stats::load_achievements_db()
{
std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file;
local_storage->load_json(file_path, defined_achievements);
}
void Steam_User_Stats::load_achievements()
{
local_storage->load_json_file("", achievements_user_file, user_achievements);
}
void Steam_User_Stats::save_achievements()
{
local_storage->write_json_file("", achievements_user_file, user_achievements);
}
int Steam_User_Stats::load_ach_icon(nlohmann::json &defined_ach, bool achieved)
{
const char *icon_handle_key = achieved ? "icon_handle" : "icon_gray_handle";
int current_handle = defined_ach.value(icon_handle_key, UNLOADED_ACH_ICON);
if (UNLOADED_ACH_ICON != current_handle) { // already loaded
return current_handle;
}
const char *icon_key = achieved ? "icon" : "icon_gray";
if (!achieved && !defined_ach.contains(icon_key)) {
icon_key = "icongray"; // old format
}
std::string icon_filepath = defined_ach.value(icon_key, std::string{});
if (icon_filepath.empty()) {
defined_ach[icon_handle_key] = Settings::INVALID_IMAGE_HANDLE;
return Settings::INVALID_IMAGE_HANDLE;
}
std::string file_path(Local_Storage::get_game_settings_path() + icon_filepath);
unsigned int file_size = file_size_(file_path);
if (!file_size) {
defined_ach[icon_handle_key] = Settings::INVALID_IMAGE_HANDLE;
return Settings::INVALID_IMAGE_HANDLE;
}
int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
std::string img(Local_Storage::load_image_resized(file_path, "", icon_size));
if (img.empty()) {
defined_ach[icon_handle_key] = Settings::INVALID_IMAGE_HANDLE;
return Settings::INVALID_IMAGE_HANDLE;
}
int handle = settings->add_image(img, icon_size, icon_size);
defined_ach[icon_handle_key] = handle;
return handle;
}
nlohmann::detail::iter_impl<nlohmann::json> Steam_User_Stats::defined_achievements_find(const std::string &key)
{
return std::find_if(
defined_achievements.begin(), defined_achievements.end(),
[&key](const nlohmann::json& item) {
const std::string &name = static_cast<const std::string &>( item.value("name", std::string()) );
return common_helpers::str_cmp_insensitive(key, name);
}
);
}
std::string Steam_User_Stats::get_value_for_language(const nlohmann::json &json, std::string_view key, std::string_view language)
{
auto x = json.find(key); // find "displayName", or "description", etc ...
if (json.end() == x) return "";
if (x.value().is_string()) { // ex: "displayName": "some description"
return x.value().get<std::string>();
} else if (x.value().is_object()) {
const auto &obj_kv_pairs = x.value().items();
// try to find target language
auto obj_itr = std::find_if(obj_kv_pairs.begin(), obj_kv_pairs.end(), [&]( decltype(*obj_kv_pairs.begin()) item ) {
return common_helpers::str_cmp_insensitive(item.key(), language);
});
if (obj_itr != obj_kv_pairs.end()) {
return obj_itr.value().get<std::string>();
}
// try to find english language
obj_itr = std::find_if(obj_kv_pairs.begin(), obj_kv_pairs.end(), [&]( decltype(*obj_kv_pairs.begin()) item ) {
return common_helpers::str_cmp_insensitive(item.key(), "english");
});
if (obj_itr != obj_kv_pairs.end()) {
return obj_itr.value().get<std::string>();
}
// try to find the first available language (not "token"),
// if not languages exist, try to find "token"
for (bool search_for_token : { false, true }) {
obj_itr = std::find_if(obj_kv_pairs.begin(), obj_kv_pairs.end(), [&]( decltype(*obj_kv_pairs.begin()) item ) {
return common_helpers::str_cmp_insensitive(item.key(), "token") == search_for_token;
});
if (obj_itr != obj_kv_pairs.end()) {
return obj_itr.value().get<std::string>();
}
}
}
return "";
}
// change achievements without sending back to server
Steam_User_Stats::InternalSetResult<bool> Steam_User_Stats::set_achievement_internal( const char *pchName )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_User_Stats::InternalSetResult<bool> result{};
if (!pchName) return result;
std::string org_name(pchName);
if (settings->achievement_bypass) {
auto &trig = store_stats_trigger[common_helpers::to_lower(org_name)];
trig.m_bGroupAchievement = false;
trig.m_nCurProgress = 100;
trig.m_nGameID = settings->get_local_game_id().ToUint64();
trig.m_nMaxProgress = 100;
memset(trig.m_rgchAchievementName, 0, sizeof(trig.m_rgchAchievementName));
org_name.copy(trig.m_rgchAchievementName, sizeof(trig.m_rgchAchievementName) - 1);
result.success = true;
return result;
}
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(org_name);
} catch(...) { }
if (defined_achievements.end() == it) return result;
result.current_val = true;
result.internal_name = org_name;
result.success = true;
try {
std::string internal_name = it->value("name", std::string());
result.internal_name = internal_name;
auto ach = user_achievements.find(internal_name);
if (user_achievements.end() == ach || ach->value("earned", false) == false) {
user_achievements[internal_name]["earned"] = true;
user_achievements[internal_name]["earned_time"] =
std::chrono::duration_cast<std::chrono::duration<uint32>>(std::chrono::system_clock::now().time_since_epoch()).count();
save_achievements();
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
overlay->AddAchievementNotification(internal_name, user_achievements[internal_name], false);
}
} catch (...) {}
auto &trig = store_stats_trigger[common_helpers::to_lower(org_name)];
trig.m_bGroupAchievement = false;
trig.m_nCurProgress = 100;
trig.m_nGameID = settings->get_local_game_id().ToUint64();
trig.m_nMaxProgress = 100;
memset(trig.m_rgchAchievementName, 0, sizeof(trig.m_rgchAchievementName));
org_name.copy(trig.m_rgchAchievementName, sizeof(trig.m_rgchAchievementName) - 1);
return result;
}
Steam_User_Stats::InternalSetResult<bool> Steam_User_Stats::clear_achievement_internal( const char *pchName )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_User_Stats::InternalSetResult<bool> result{};
if (!pchName) return result;
std::string org_name(pchName);
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(org_name);
} catch(...) { }
if (defined_achievements.end() == it) return result;
result.current_val = false;
result.internal_name = org_name;
result.success = true;
try {
std::string internal_name = it->value("name", std::string());
result.internal_name = internal_name;
auto ach = user_achievements.find(internal_name);
// assume "earned" is true in case the json obj exists, but the key is absent
// assume "earned_time" is UINT32_MAX in case the json obj exists, but the key is absent
if (user_achievements.end() == ach ||
ach->value("earned", true) == true ||
ach->value("earned_time", static_cast<uint32>(UINT32_MAX)) == UINT32_MAX) {
user_achievements[internal_name]["earned"] = false;
user_achievements[internal_name]["earned_time"] = static_cast<uint32>(0);
save_achievements();
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
overlay->AddAchievementNotification(internal_name, user_achievements[internal_name], false);
}
} catch (...) {}
store_stats_trigger.erase(common_helpers::to_lower(org_name));
return result;
}
// Achievement flag accessors
bool Steam_User_Stats::GetAchievement( const char *pchName, bool *pbAchieved )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(pchName);
} catch(...) { }
if (defined_achievements.end() == it) return false;
// according to docs, the function returns true if the achievement was found,
// regardless achieved or not
if (!pbAchieved) return true;
*pbAchieved = false;
try {
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);
if (user_achievements.end() != ach) {
*pbAchieved = ach->value("earned", false);
}
} catch (...) { }
return true;
}
bool Steam_User_Stats::SetAchievement( const char *pchName )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto ret = set_achievement_internal(pchName);
if (ret.success && ret.notify_server) {
auto &new_ach = (*pending_server_updates.mutable_user_achievements())[ret.internal_name];
new_ach.set_achieved(ret.current_val);
if (settings->immediate_gameserver_stats) send_updated_stats();
}
return ret.success;
}
bool Steam_User_Stats::ClearAchievement( const char *pchName )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto ret = clear_achievement_internal(pchName);
if (ret.success && ret.notify_server) {
auto &new_ach = (*pending_server_updates.mutable_user_achievements())[ret.internal_name];
new_ach.set_achieved(ret.current_val);
if (settings->immediate_gameserver_stats) send_updated_stats();
}
return ret.success;
}
// Get the achievement status, and the time it was unlocked if unlocked.
// If the return value is true, but the unlock time is zero, that means it was unlocked before Steam
// began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970.
bool Steam_User_Stats::GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32 *punUnlockTime )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(pchName);
} catch(...) { }
if (defined_achievements.end() == it) return false;
if (pbAchieved) *pbAchieved = false;
if (punUnlockTime) *punUnlockTime = 0;
try {
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);
if (user_achievements.end() != ach) {
if (pbAchieved) *pbAchieved = ach->value("earned", false);
if (punUnlockTime) *punUnlockTime = ach->value("earned_time", static_cast<uint32>(0));
}
} catch (...) {}
return true;
}
// Achievement / GroupAchievement metadata
// Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set.
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback
// which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the
// specified achievement.
int Steam_User_Stats::GetAchievementIcon( const char *pchName )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return Settings::INVALID_IMAGE_HANDLE;
bool achieved = false;
GetAchievement(pchName, &achieved);
std::string ach_name(pchName);
int handle = get_achievement_icon_handle(ach_name, achieved);
UserAchievementIconFetched_t data{};
data.m_bAchieved = achieved ;
data.m_nGameID = settings->get_local_game_id();
data.m_nIconHandle = handle;
ach_name.copy(data.m_rgchAchievementName, sizeof(data.m_rgchAchievementName));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return handle;
}
int Steam_User_Stats::get_achievement_icon_handle( const std::string &ach_name, bool achieved )
{
PRINT_DEBUG("'%s', %i", ach_name.c_str(), (int)achieved);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (ach_name.empty()) return Settings::INVALID_IMAGE_HANDLE;
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(ach_name);
} catch(...) { }
if (defined_achievements.end() == it) return Settings::INVALID_IMAGE_HANDLE;
int handle = load_ach_icon(*it, achieved);
PRINT_DEBUG("returned handle = %i", handle);
return handle;
}
std::string Steam_User_Stats::get_achievement_icon_name( const char *pchName, bool pbAchieved )
{
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return "";
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(pchName);
} catch(...) { }
if (defined_achievements.end() == it) return "";
try {
if (pbAchieved) return it.value()["icon"].get<std::string>();
std::string locked_icon = it.value().value("icon_gray", std::string());
if (locked_icon.size()) return locked_icon;
else return it.value().value("icongray", std::string()); // old format
} catch (...) {}
return "";
}
// Get general attributes for an achievement. Accepts the following keys:
// - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8)
// - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden)
const char * Steam_User_Stats::GetAchievementDisplayAttribute( const char *pchName, const char *pchKey )
{
PRINT_DEBUG("[%s] [%s]", pchName, pchKey);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName || !pchKey || !pchKey[0]) return "";
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(pchName);
} catch(...) { }
if (defined_achievements.end() == it) return "";
if (strncmp(pchKey, "name", sizeof("name")) == 0) {
try {
return it.value()["displayName"].get_ptr<std::string*>()->c_str();
} catch (...) {}
} else if (strncmp(pchKey, "desc", sizeof("desc")) == 0) {
try {
return it.value()["description"].get_ptr<std::string*>()->c_str();
} catch (...) {}
} else if (strncmp(pchKey, "hidden", sizeof("hidden")) == 0) {
try {
return it.value()["hidden"].get_ptr<std::string*>()->c_str();
} catch (...) {}
}
return "";
}
// Achievement progress - triggers an AchievementProgress callback, that is all.
// Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.
bool Steam_User_Stats::IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress )
{
PRINT_DEBUG("'%s' %u %u", pchName, nCurProgress, nMaxProgress);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
if (nCurProgress >= nMaxProgress) return false;
std::string ach_name(pchName);
// find in achievements.json
nlohmann::detail::iter_impl<nlohmann::json> it = defined_achievements.end();
try {
it = defined_achievements_find(ach_name);
} catch(...) { }
if (defined_achievements.end() == it) return false;
// get actual name from achievements.json
std::string actual_ach_name{};
try {
actual_ach_name = it->value("name", std::string());
} catch (...) { }
if (actual_ach_name.empty()) { // fallback
actual_ach_name = ach_name;
}
// check if already achieved
bool achieved = false;
try {
auto ach = user_achievements.find(actual_ach_name);
if (ach != user_achievements.end()) {
achieved = ach->value("earned", false);
}
} catch (...) { }
if (achieved) return false;
// save new progress
try {
auto old_progress = user_achievements.value(actual_ach_name, nlohmann::json{}).value("progress", ~nCurProgress);
if (old_progress != nCurProgress) {
user_achievements[actual_ach_name]["progress"] = nCurProgress;
user_achievements[actual_ach_name]["max_progress"] = nMaxProgress;
save_achievements();
overlay->AddAchievementNotification(actual_ach_name, user_achievements[actual_ach_name], true);
}
} catch (...) {}
{
UserStatsStored_t data{};
data.m_eResult = EResult::k_EResultOK;
data.m_nGameID = settings->get_local_game_id().ToUint64();
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
{
UserAchievementStored_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false;
data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress;
ach_name.copy(data.m_rgchAchievementName, sizeof(data.m_rgchAchievementName) - 1);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
return true;
}
// Used for iterating achievements. In general games should not need these functions because they should have a
// list of existing achievements compiled into them
uint32 Steam_User_Stats::GetNumAchievements()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return (uint32)defined_achievements.size();
}
// Get achievement name iAchievement in [0,GetNumAchievements)
const char * Steam_User_Stats::GetAchievementName( uint32 iAchievement )
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (iAchievement >= sorted_achievement_names.size()) {
return "";
}
return sorted_achievement_names[iAchievement].c_str();
}
// Friends achievements
bool Steam_User_Stats::GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved )
{
PRINT_DEBUG("%s", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievement(pchName, pbAchieved);
}
return false;
}
// See notes for GetAchievementAndUnlockTime above
bool Steam_User_Stats::GetUserAchievementAndUnlockTime( CSteamID steamIDUser, const char *pchName, bool *pbAchieved, uint32 *punUnlockTime )
{
PRINT_DEBUG("%s", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievementAndUnlockTime(pchName, pbAchieved, punUnlockTime);
}
return false;
}
// Requests that Steam fetch data on the percentage of players who have received each achievement
// for the game globally.
// This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t.
STEAM_CALL_RESULT( GlobalAchievementPercentagesReady_t )
SteamAPICall_t Steam_User_Stats::RequestGlobalAchievementPercentages()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
GlobalAchievementPercentagesReady_t data{};
data.m_eResult = EResult::k_EResultOK;
data.m_nGameID = settings->get_local_game_id().ToUint64();
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
// Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch
// the next most achieved afterwards. Will return -1 if there is no data on achievement
// percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback).
int Steam_User_Stats::GetMostAchievedAchievementInfo( char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved )
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return -1;
std::string name(GetAchievementName(0));
if (name.empty()) return -1;
if (pchName && unNameBufLen) {
memset(pchName, 0, unNameBufLen);
name.copy(pchName, unNameBufLen - 1);
}
if (pflPercent) *pflPercent = 90;
if (pbAchieved) {
bool achieved = false;
GetAchievement(name.c_str(), &achieved);
*pbAchieved = achieved;
}
return 0;
}
// Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another
// GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last
// achievement has been iterated.
int Steam_User_Stats::GetNextMostAchievedAchievementInfo( int iIteratorPrevious, char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved )
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (iIteratorPrevious < 0) return -1;
unsigned iIteratorCurrent = static_cast<unsigned>(iIteratorPrevious + 1);
if (iIteratorCurrent >= defined_achievements.size()) return -1;
std::string name(GetAchievementName(iIteratorCurrent));
if (name.empty()) return -1;
if (pchName && unNameBufLen) {
memset(pchName, 0, unNameBufLen);
name.copy(pchName, unNameBufLen - 1);
}
if (pflPercent) {
*pflPercent = (float)(90 * (defined_achievements.size() - iIteratorCurrent) / defined_achievements.size());
}
if (pbAchieved) {
bool achieved = false;
GetAchievement(name.c_str(), &achieved);
*pbAchieved = achieved;
}
return static_cast<int>(iIteratorCurrent);
}
// Returns the percentage of users who have achieved the specified achievement.
bool Steam_User_Stats::GetAchievementAchievedPercent( const char *pchName, float *pflPercent )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto it = defined_achievements_find(pchName);
if (defined_achievements.end() == it) return false;
size_t idx = it - defined_achievements.begin();
if (pflPercent) {
*pflPercent = (float)(90 * (defined_achievements.size() - idx) / defined_achievements.size());
}
return true;
}
// For achievements that have related Progress stats, use this to query what the bounds of that progress are.
// You may want this info to selectively call IndicateAchievementProgress when appropriate milestones of progress
// have been made, to show a progress notification to the user.
bool Steam_User_Stats::GetAchievementProgressLimits( const char *pchName, int32 *pnMinProgress, int32 *pnMaxProgress )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
float fMinProgress{};
float fMaxProgress{};
bool ret = GetAchievementProgressLimits(pchName, &fMinProgress, &fMaxProgress);
if (ret) {
if (pnMinProgress) *pnMinProgress = static_cast<int32>(fMinProgress);
if (pnMaxProgress) *pnMaxProgress = static_cast<int32>(fMaxProgress);
}
return ret;
}
bool Steam_User_Stats::GetAchievementProgressLimits( const char *pchName, float *pfMinProgress, float *pfMaxProgress )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
auto it = defined_achievements.end();
try {
it = defined_achievements_find(pchName);
}
catch (...) {}
if (defined_achievements.end() == it) return false;
if (pfMinProgress) *pfMinProgress = 0;
if (pfMaxProgress) *pfMaxProgress = 0;
try {
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);
if (user_achievements.end() != ach) {
auto it_progress = ach->find("progress");
auto it_max_progress = ach->find("max_progress");
if (ach->end() == it_progress || ach->end() == it_max_progress) return false;
if (pfMinProgress) {
try {
if (it_progress->is_number()) {
*pfMinProgress = it_progress->get<float>();
} else {
auto s_ptr = it_progress->get_ptr<std::string*>();
if (s_ptr) {
*pfMinProgress = std::stof(*s_ptr);
}
}
}catch(...){}
}
if (pfMaxProgress) {
try {
if (it_max_progress->is_number()) {
*pfMaxProgress = it_max_progress->get<float>();
} else {
auto s_ptr = it_max_progress->get_ptr<std::string*>();
if (s_ptr) {
*pfMaxProgress = std::stof(*s_ptr);
}
}
}catch(...){}
}
return true;
}
}
catch (...) {}
return false;
}
// --- steam callbacks
void Steam_User_Stats::load_achievements_icons()
{
if (achievements_icons_loaded) return;
if (settings->lazy_load_achievements_icons) {
achievements_icons_loaded = true;
return;
}
for (auto & defined_ach : defined_achievements) {
load_ach_icon(defined_ach, true);
load_ach_icon(defined_ach, false);
}
achievements_icons_loaded = true;
}

View File

@ -0,0 +1,689 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
#include "dll/steam_user_stats.h"
#include <random>
// --- Steam_Leaderboard ---
Steam_Leaderboard_Entry* Steam_Leaderboard::find_recent_entry(const CSteamID &steamid) const
{
auto my_it = std::find_if(entries.begin(), entries.end(), [&steamid](const Steam_Leaderboard_Entry &item) {
return item.steam_id == steamid;
});
if (entries.end() == my_it) return nullptr;
return const_cast<Steam_Leaderboard_Entry*>(&*my_it);
}
void Steam_Leaderboard::remove_entries(const CSteamID &steamid)
{
auto rm_it = std::remove_if(entries.begin(), entries.end(), [&](const Steam_Leaderboard_Entry &item){
return item.steam_id == steamid;
});
if (entries.end() != rm_it) entries.erase(rm_it, entries.end());
}
void Steam_Leaderboard::remove_duplicate_entries()
{
if (entries.size() <= 1) return;
auto rm = std::remove_if(entries.begin(), entries.end(), [&](const Steam_Leaderboard_Entry& item) {
auto recent = find_recent_entry(item.steam_id);
return &item != recent;
});
if (entries.end() != rm) entries.erase(rm, entries.end());
}
void Steam_Leaderboard::sort_entries()
{
if (sort_method == k_ELeaderboardSortMethodNone) return;
if (entries.size() <= 1) return;
std::sort(entries.begin(), entries.end(), [this](const Steam_Leaderboard_Entry &item1, const Steam_Leaderboard_Entry &item2) {
if (sort_method == k_ELeaderboardSortMethodAscending) {
return item1.score < item2.score;
} else { // k_ELeaderboardSortMethodDescending
return item1.score > item2.score;
}
});
}
// --- Steam_Leaderboard ---
/*
layout of each item in the leaderboard file
| steamid - lower 32-bits | steamid - higher 32-bits | score (4 bytes) | score details count (4 bytes) | score details array (4 bytes each) ...
[0] | [1] | [2] | [3] | [4]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ main header ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
std::vector<Steam_Leaderboard_Entry> Steam_User_Stats::load_leaderboard_entries(const std::string &name)
{
constexpr const static unsigned int MAIN_HEADER_ELEMENTS_COUNT = 4;
constexpr const static unsigned int ELEMENT_SIZE = (unsigned int)sizeof(uint32_t);
std::vector<Steam_Leaderboard_Entry> out{};
std::string leaderboard_name(common_helpers::ascii_to_lowercase(name));
unsigned read_bytes = local_storage->file_size(Local_Storage::leaderboard_storage_folder, leaderboard_name);
if ((read_bytes == 0) ||
(read_bytes < (ELEMENT_SIZE * MAIN_HEADER_ELEMENTS_COUNT)) ||
(read_bytes % ELEMENT_SIZE) != 0) {
return out;
}
std::vector<uint32_t> output(read_bytes / ELEMENT_SIZE);
if (local_storage->get_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )output.data(), read_bytes) != read_bytes) return out;
unsigned int i = 0;
while (true) {
if ((i + MAIN_HEADER_ELEMENTS_COUNT) > output.size()) break; // invalid main header, or end of buffer
Steam_Leaderboard_Entry new_entry{};
new_entry.steam_id = CSteamID((uint64)output[i] + (((uint64)output[i + 1]) << 32));
new_entry.score = (int32)output[i + 2];
uint32_t details_count = output[i + 3];
i += MAIN_HEADER_ELEMENTS_COUNT; // skip main header
if ((i + details_count) > output.size()) break; // invalid score details count
for (uint32_t j = 0; j < details_count; ++j) {
new_entry.score_details.push_back(output[i]);
++i; // move past this score detail
}
PRINT_DEBUG("'%s': user %llu, score %i, details count = %zu",
name.c_str(), new_entry.steam_id.ConvertToUint64(), new_entry.score, new_entry.score_details.size()
);
out.push_back(new_entry);
}
PRINT_DEBUG("'%s' total entries = %zu", name.c_str(), out.size());
return out;
}
void Steam_User_Stats::save_my_leaderboard_entry(const Steam_Leaderboard &leaderboard)
{
auto my_entry = leaderboard.find_recent_entry(settings->get_local_steam_id());
if (!my_entry) return; // we don't have a score entry
PRINT_DEBUG("saving entries for leaderboard '%s'", leaderboard.name.c_str());
std::vector<uint32_t> output{};
uint64_t steam_id = my_entry->steam_id.ConvertToUint64();
output.push_back((uint32_t)(steam_id & 0xFFFFFFFF)); // lower 4 bytes
output.push_back((uint32_t)(steam_id >> 32)); // higher 4 bytes
output.push_back(my_entry->score);
output.push_back((uint32_t)my_entry->score_details.size());
for (const auto &detail : my_entry->score_details) {
output.push_back(detail);
}
std::string leaderboard_name(common_helpers::ascii_to_lowercase(leaderboard.name));
unsigned int buffer_size = static_cast<unsigned int>(output.size() * sizeof(output[0])); // in bytes
local_storage->store_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )&output[0], buffer_size);
}
Steam_Leaderboard_Entry* Steam_User_Stats::update_leaderboard_entry(Steam_Leaderboard &leaderboard, const Steam_Leaderboard_Entry &entry, bool overwrite)
{
bool added = false;
auto user_entry = leaderboard.find_recent_entry(entry.steam_id);
if (!user_entry) { // user doesn't have an entry yet, create one
added = true;
leaderboard.entries.push_back(entry);
user_entry = &leaderboard.entries.back();
} else if (overwrite) {
added = true;
*user_entry = entry;
}
if (added) { // if we added a new entry then we have to sort and find the target entry again
leaderboard.sort_entries();
user_entry = leaderboard.find_recent_entry(entry.steam_id);
PRINT_DEBUG("added/updated entry for user %llu", entry.steam_id.ConvertToUint64());
}
return user_entry;
}
unsigned int Steam_User_Stats::find_cached_leaderboard(const std::string &name)
{
unsigned index = 1;
for (const auto &leaderboard : cached_leaderboards) {
if (common_helpers::str_cmp_insensitive(leaderboard.name, name)) return index;
++index;
}
return 0;
}
unsigned int Steam_User_Stats::cache_leaderboard_ifneeded(const std::string &name, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType)
{
unsigned int board_handle = find_cached_leaderboard(name);
if (board_handle) return board_handle;
// PRINT_DEBUG("cache miss '%s'", name.c_str());
// create a new entry in-memory and try reading the entries from disk
struct Steam_Leaderboard new_board{};
new_board.name = common_helpers::ascii_to_lowercase(name);
new_board.sort_method = eLeaderboardSortMethod;
new_board.display_type = eLeaderboardDisplayType;
new_board.entries = load_leaderboard_entries(name);
new_board.sort_entries();
new_board.remove_duplicate_entries();
// save it in memory for later
cached_leaderboards.push_back(new_board);
board_handle = static_cast<unsigned int>(cached_leaderboards.size());
PRINT_DEBUG("cached a new leaderboard '%s' %i %i",
new_board.name.c_str(), (int)eLeaderboardSortMethod, (int)eLeaderboardDisplayType
);
return board_handle;
}
void Steam_User_Stats::send_my_leaderboard_score(const Steam_Leaderboard &board, const CSteamID *steamid, bool want_scores_back)
{
if (!settings->share_leaderboards_over_network) return;
const auto my_entry = board.find_recent_entry(settings->get_local_steam_id());
Leaderboards_Messages::UserScoreEntry *score_entry_msg = nullptr;
if (my_entry) {
score_entry_msg = new Leaderboards_Messages::UserScoreEntry();
score_entry_msg->set_score(my_entry->score);
score_entry_msg->mutable_score_details()->Assign(my_entry->score_details.begin(), my_entry->score_details.end());
}
auto board_info_msg = new Leaderboards_Messages::LeaderboardInfo();
board_info_msg->set_allocated_board_name(new std::string(board.name));
board_info_msg->set_sort_method(board.sort_method);
board_info_msg->set_display_type(board.display_type);
auto board_msg = new Leaderboards_Messages();
if (want_scores_back) board_msg->set_type(Leaderboards_Messages::UpdateUserScoreMutual);
else board_msg->set_type(Leaderboards_Messages::UpdateUserScore);
board_msg->set_appid(settings->get_local_game_id().AppID());
board_msg->set_allocated_leaderboard_info(board_info_msg);
// if we have an entry
if (score_entry_msg) board_msg->set_allocated_user_score_entry(score_entry_msg);
Common_Message common_msg{};
common_msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
if (steamid) common_msg.set_dest_id(steamid->ConvertToUint64());
common_msg.set_allocated_leaderboards_messages(board_msg);
if (steamid) network->sendTo(&common_msg, false);
else network->sendToAll(&common_msg, false);
}
void Steam_User_Stats::request_user_leaderboard_entry(const Steam_Leaderboard &board, const CSteamID &steamid)
{
if (!settings->share_leaderboards_over_network) return;
auto board_info_msg = new Leaderboards_Messages::LeaderboardInfo();
board_info_msg->set_allocated_board_name(new std::string(board.name));
board_info_msg->set_sort_method(board.sort_method);
board_info_msg->set_display_type(board.display_type);
auto board_msg = new Leaderboards_Messages();
board_msg->set_type(Leaderboards_Messages::RequestUserScore);
board_msg->set_appid(settings->get_local_game_id().AppID());
board_msg->set_allocated_leaderboard_info(board_info_msg);
Common_Message common_msg{};
common_msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
common_msg.set_dest_id(steamid.ConvertToUint64());
common_msg.set_allocated_leaderboards_messages(board_msg);
network->sendTo(&common_msg, false);
}
void Steam_User_Stats::steam_user_stats_network_leaderboards(void *object, Common_Message *msg)
{
// PRINT_DEBUG_ENTRY();
auto inst = (Steam_User_Stats *)object;
inst->network_callback_leaderboards(msg);
}
// Leaderboard functions
// asks the Steam back-end for a leaderboard by name, and will create it if it's not yet
// This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT(LeaderboardFindResult_t)
SteamAPICall_t Steam_User_Stats::FindOrCreateLeaderboard( const char *pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType )
{
PRINT_DEBUG("'%s'", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchLeaderboardName) {
LeaderboardFindResult_t data{};
data.m_hSteamLeaderboard = 0;
data.m_bLeaderboardFound = 0;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
unsigned int board_handle = cache_leaderboard_ifneeded(pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType);
send_my_leaderboard_score(cached_leaderboards[board_handle - 1], nullptr, true);
LeaderboardFindResult_t data{};
data.m_hSteamLeaderboard = board_handle;
data.m_bLeaderboardFound = 1;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1); // TODO is the timing ok?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return ret;
}
// as above, but won't create the leaderboard if it's not found
// This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT( LeaderboardFindResult_t )
SteamAPICall_t Steam_User_Stats::FindLeaderboard( const char *pchLeaderboardName )
{
PRINT_DEBUG("'%s'", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchLeaderboardName) {
LeaderboardFindResult_t data{};
data.m_hSteamLeaderboard = 0;
data.m_bLeaderboardFound = 0;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
std::string name_lower(common_helpers::ascii_to_lowercase(pchLeaderboardName));
const auto &settings_Leaderboards = settings->getLeaderboards();
auto it = settings_Leaderboards.begin();
for (; settings_Leaderboards.end() != it; ++it) {
if (common_helpers::str_cmp_insensitive(it->first, name_lower)) break;
}
if (settings_Leaderboards.end() != it) {
auto &config = it->second;
return FindOrCreateLeaderboard(pchLeaderboardName, config.sort_method, config.display_type);
} else if (!settings->disable_leaderboards_create_unknown) {
return FindOrCreateLeaderboard(pchLeaderboardName, k_ELeaderboardSortMethodDescending, k_ELeaderboardDisplayTypeNumeric);
} else {
LeaderboardFindResult_t data{};
data.m_hSteamLeaderboard = find_cached_leaderboard(name_lower);
data.m_bLeaderboardFound = !!data.m_hSteamLeaderboard;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
}
// returns the name of a leaderboard
const char * Steam_User_Stats::GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("%llu", hSteamLeaderboard);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return "";
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].name.c_str();
}
// returns the total number of entries in a leaderboard, as of the last request
int Steam_User_Stats::GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("%llu", hSteamLeaderboard);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return 0;
return (int)cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].entries.size();
}
// returns the sort method of the leaderboard
ELeaderboardSortMethod Steam_User_Stats::GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("%llu", hSteamLeaderboard);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardSortMethodNone;
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].sort_method;
}
// returns the display type of the leaderboard
ELeaderboardDisplayType Steam_User_Stats::GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("%llu", hSteamLeaderboard);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardDisplayTypeNone;
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].display_type;
}
// Asks the Steam back-end for a set of rows in the leaderboard.
// This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t
// LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below)
// You can ask for more entries than exist, and it will return as many as do exist.
// k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries]
// k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate
// e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after
// k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t )
SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd )
{
PRINT_DEBUG("%llu %i [%i, %i]", hSteamLeaderboard, eLeaderboardDataRequest, nRangeStart, nRangeEnd);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //might return callresult even if hSteamLeaderboard is invalid
int entries_count = (int)cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].entries.size();
// https://partner.steamgames.com/doc/api/ISteamUserStats#ELeaderboardDataRequest
if (eLeaderboardDataRequest != k_ELeaderboardDataRequestFriends) {
int required_count = nRangeEnd - nRangeStart + 1;
if (required_count < 0) required_count = 0;
if (required_count < entries_count) entries_count = required_count;
}
LeaderboardScoresDownloaded_t data{};
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = hSteamLeaderboard;
data.m_cEntryCount = entries_count;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1); // TODO is this timing ok?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return ret;
}
// as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers
// if a user doesn't have a leaderboard entry, they won't be included in the result
// a max of 100 users can be downloaded at a time, with only one outstanding call at a time
STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers)
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t )
SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard,
STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID *prgUsers, int cUsers )
{
PRINT_DEBUG("%i %llu", cUsers, cUsers > 0 ? prgUsers[0].ConvertToUint64() : 0);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //might return callresult even if hSteamLeaderboard is invalid
auto& board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)];
bool ok = true;
int total_count = 0;
if (prgUsers && cUsers > 0) {
for (int i = 0; i < cUsers; ++i) {
const auto &user_steamid = prgUsers[i];
if (!user_steamid.IsValid()) {
ok = false;
PRINT_DEBUG("bad userid %llu", user_steamid.ConvertToUint64());
break;
}
if (board.find_recent_entry(user_steamid)) ++total_count;
request_user_leaderboard_entry(board, user_steamid);
}
}
PRINT_DEBUG("total count %i", total_count);
// https://partner.steamgames.com/doc/api/ISteamUserStats#DownloadLeaderboardEntriesForUsers
if (!ok || total_count > 100) return k_uAPICallInvalid;
LeaderboardScoresDownloaded_t data{};
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = hSteamLeaderboard;
data.m_cEntryCount = total_count;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1); // TODO is this timing ok?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return ret;
}
// Returns data about a single leaderboard entry
// use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries
// e.g.
// void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded )
// {
// for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ )
// {
// LeaderboardEntry_t leaderboardEntry;
// int32 details[3]; // we know this is how many we've stored previously
// GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 );
// assert( leaderboardEntry.m_cDetails == 3 );
// ...
// }
// once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid
bool Steam_User_Stats::GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t *pLeaderboardEntry, int32 *pDetails, int cDetailsMax )
{
PRINT_DEBUG("[%i] (%i) %llu %p %p", index, cDetailsMax, hSteamLeaderboardEntries, pLeaderboardEntry, pDetails);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboardEntries > cached_leaderboards.size() || hSteamLeaderboardEntries <= 0) return false;
const auto &board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboardEntries - 1)];
if (index < 0 || static_cast<size_t>(index) >= board.entries.size()) return false;
const auto &target_entry = board.entries[index];
if (pLeaderboardEntry) {
LeaderboardEntry_t entry{};
entry.m_steamIDUser = target_entry.steam_id;
entry.m_nGlobalRank = 1 + (int)(&target_entry - &board.entries[0]);
entry.m_nScore = target_entry.score;
*pLeaderboardEntry = entry;
}
if (pDetails && cDetailsMax > 0) {
for (unsigned i = 0; i < target_entry.score_details.size() && i < static_cast<unsigned>(cDetailsMax); ++i) {
pDetails[i] = target_entry.score_details[i];
}
}
return true;
}
// Uploads a user score to the Steam back-end.
// This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t
// Details are extra game-defined information regarding how the user got that score
// pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list
STEAM_CALL_RESULT( LeaderboardScoreUploaded_t )
SteamAPICall_t Steam_User_Stats::UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32 *pScoreDetails, int cScoreDetailsCount )
{
PRINT_DEBUG("%llu %i", hSteamLeaderboard, nScore);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //TODO: might return callresult even if hSteamLeaderboard is invalid
auto &board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)];
auto my_entry = board.find_recent_entry(settings->get_local_steam_id());
int current_rank = my_entry
? 1 + (int)(my_entry - &board.entries[0])
: 0;
int new_rank = current_rank;
bool score_updated = false;
if (my_entry) {
switch (eLeaderboardUploadScoreMethod)
{
case k_ELeaderboardUploadScoreMethodKeepBest: { // keep user's best score
if (board.sort_method == k_ELeaderboardSortMethodAscending) { // keep user's lowest score
score_updated = nScore < my_entry->score;
} else { // keep user's highest score
score_updated = nScore > my_entry->score;
}
}
break;
case k_ELeaderboardUploadScoreMethodForceUpdate: { // always replace score with specified
score_updated = my_entry->score != nScore;
}
break;
default: break;
}
} else { // no entry yet for us
score_updated = true;
}
if (score_updated || (eLeaderboardUploadScoreMethod == k_ELeaderboardUploadScoreMethodForceUpdate)) {
Steam_Leaderboard_Entry new_entry{};
new_entry.steam_id = settings->get_local_steam_id();
new_entry.score = nScore;
if (pScoreDetails && cScoreDetailsCount > 0) {
for (int i = 0; i < cScoreDetailsCount; ++i) {
new_entry.score_details.push_back(pScoreDetails[i]);
}
}
update_leaderboard_entry(board, new_entry);
new_rank = 1 + (int)(board.find_recent_entry(settings->get_local_steam_id()) - &board.entries[0]);
// check again in case this was a forced update
// avoid disk write if score is the same
if (score_updated) save_my_leaderboard_entry(board);
send_my_leaderboard_score(board);
}
LeaderboardScoreUploaded_t data{};
data.m_bSuccess = 1; //needs to be success or DOA6 freezes when uploading score.
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_nScore = nScore;
data.m_bScoreChanged = score_updated;
data.m_nGlobalRankNew = new_rank;
data.m_nGlobalRankPrevious = current_rank;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1); // TODO is this timing ok?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return ret;
}
SteamAPICall_t Steam_User_Stats::UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, int32 nScore, int32 *pScoreDetails, int cScoreDetailsCount )
{
PRINT_DEBUG("old");
return UploadLeaderboardScore(hSteamLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, pScoreDetails, cScoreDetailsCount);
}
// Attaches a piece of user generated content the user's entry on a leaderboard.
// hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare().
// This call is asynchronous, with the result returned in LeaderboardUGCSet_t.
STEAM_CALL_RESULT( LeaderboardUGCSet_t )
SteamAPICall_t Steam_User_Stats::AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC )
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardUGCSet_t data{};
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) {
data.m_eResult = k_EResultFail;
} else {
data.m_eResult = k_EResultOK;
}
data.m_hSteamLeaderboard = hSteamLeaderboard;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
// --- networking callbacks
// only triggered when we have a message
// someone updated their score
void Steam_User_Stats::network_leaderboard_update_score(Common_Message *msg, Steam_Leaderboard &board, bool send_score_back)
{
CSteamID sender_steamid((uint64)msg->source_id());
PRINT_DEBUG("got score for user %llu on leaderboard '%s' (send our score back=%i)",
(uint64)msg->source_id(), board.name.c_str(), (int)send_score_back
);
// when players initally load a board, and they don't have an entry in it,
// they send this msg but without their user score entry
if (msg->leaderboards_messages().has_user_score_entry()) {
const auto &user_score_msg = msg->leaderboards_messages().user_score_entry();
Steam_Leaderboard_Entry updated_entry{};
updated_entry.steam_id = sender_steamid;
updated_entry.score = user_score_msg.score();
updated_entry.score_details.reserve(user_score_msg.score_details().size());
updated_entry.score_details.assign(user_score_msg.score_details().begin(), user_score_msg.score_details().end());
update_leaderboard_entry(board, updated_entry);
}
// if the sender wants back our score, send it to all, not just them
// in case we have 3 or more players and none of them have our data
if (send_score_back) send_my_leaderboard_score(board);
}
// someone is requesting our score on a leaderboard
void Steam_User_Stats::network_leaderboard_send_my_score(Common_Message *msg, const Steam_Leaderboard &board)
{
CSteamID sender_steamid((uint64)msg->source_id());
PRINT_DEBUG("user %llu requested our score for leaderboard '%s'", (uint64)msg->source_id(), board.name.c_str());
send_my_leaderboard_score(board, &sender_steamid);
}
void Steam_User_Stats::network_callback_leaderboards(Common_Message *msg)
{
// network->sendToAll() sends to current user also
if (msg->source_id() == settings->get_local_steam_id().ConvertToUint64()) return;
if (settings->get_local_game_id().AppID() != msg->leaderboards_messages().appid()) return;
if (!msg->leaderboards_messages().has_leaderboard_info()) {
PRINT_DEBUG("error empty leaderboard msg");
return;
}
const auto &board_info_msg = msg->leaderboards_messages().leaderboard_info();
PRINT_DEBUG("attempting to cache leaderboard '%s'", board_info_msg.board_name().c_str());
unsigned int board_handle = cache_leaderboard_ifneeded(
board_info_msg.board_name(),
(ELeaderboardSortMethod)board_info_msg.sort_method(),
(ELeaderboardDisplayType)board_info_msg.display_type()
);
switch (msg->leaderboards_messages().type()) {
// someone updated their score
case Leaderboards_Messages::UpdateUserScore:
network_leaderboard_update_score(msg, cached_leaderboards[board_handle - 1], false);
break;
// someone updated their score and wants us to share back ours
case Leaderboards_Messages::UpdateUserScoreMutual:
network_leaderboard_update_score(msg, cached_leaderboards[board_handle - 1], true);
break;
// someone is requesting our score on a leaderboard
case Leaderboards_Messages::RequestUserScore:
network_leaderboard_send_my_score(msg, cached_leaderboards[board_handle - 1]);
break;
default:
PRINT_DEBUG("unhandled type %i", (int)msg->leaderboards_messages().type());
break;
}
}

View File

@ -0,0 +1,846 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
#include "dll/steam_user_stats.h"
#include <random>
// change stats without sending back to server
bool Steam_User_Stats::clear_stats_internal()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
bool notify_server = false;
for (const auto &stat : settings->getStats()) {
std::string stat_name(common_helpers::ascii_to_lowercase(stat.first));
switch (stat.second.type)
{
case GameServerStats_Messages::StatInfo::STAT_TYPE_INT: {
auto data = stat.second.default_value_int;
bool needs_disk_write = false;
auto it_res = stats_cache_int.find(stat_name);
if (stats_cache_int.end() == it_res || it_res->second != data) {
needs_disk_write = true;
notify_server = true;
}
stats_cache_int[stat_name] = data;
if (needs_disk_write) local_storage->store_data(Local_Storage::stats_storage_folder, stat_name, (char *)&data, sizeof(data));
}
break;
case GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT:
case GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE: {
auto data = stat.second.default_value_float;
bool needs_disk_write = false;
auto it_res = stats_cache_float.find(stat_name);
if (stats_cache_float.end() == it_res || it_res->second != data) {
needs_disk_write = true;
notify_server = true;
}
stats_cache_float[stat_name] = data;
if (needs_disk_write) local_storage->store_data(Local_Storage::stats_storage_folder, stat_name, (char *)&data, sizeof(data));
}
break;
default: PRINT_DEBUG("unhandled type %i", (int)stat.second.type); break;
}
}
return notify_server;
}
Steam_User_Stats::InternalSetResult<int32> Steam_User_Stats::set_stat_internal( const char *pchName, int32 nData )
{
PRINT_DEBUG("<int32> '%s' = %i", pchName, nData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_User_Stats::InternalSetResult<int32> result{};
if (!pchName) return result;
std::string stat_name(common_helpers::ascii_to_lowercase(pchName));
const auto &stats_config = settings->getStats();
auto stats_data = stats_config.find(stat_name);
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
Stat_config cfg{};
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_INT;
cfg.default_value_int = 0;
stats_data = settings->setStatDefiniton(stat_name, cfg);
}
if (stats_config.end() == stats_data) return result;
if (stats_data->second.type != GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
result.internal_name = stat_name;
result.current_val = nData;
auto cached_stat = stats_cache_int.find(stat_name);
if (stats_cache_int.end() != cached_stat) {
if (cached_stat->second == nData) {
result.success = true;
return result;
}
}
auto stat_trigger = achievement_stat_trigger.find(stat_name);
if (stat_trigger != achievement_stat_trigger.end()) {
for (auto &t : stat_trigger->second) {
if (t.should_unlock_ach(nData)) {
set_achievement_internal(t.name.c_str());
}
if (settings->stat_achievement_progress_functionality && t.should_indicate_progress(nData)) {
bool indicate_progress = true;
// appid 1482380 needs that otherwise it will spam progress indications while driving
if (settings->save_only_higher_stat_achievement_progress) {
try {
auto user_ach_it = user_achievements.find(t.name);
if (user_achievements.end() != user_ach_it) {
auto user_progress_it = user_ach_it->find("progress");
if (user_ach_it->end() != user_progress_it) {
int32 user_progress = *user_progress_it;
if (nData <= user_progress) {
indicate_progress = false;
}
}
}
} catch(...){}
}
if (indicate_progress) {
IndicateAchievementProgress(t.name.c_str(), nData, std::stoi(t.max_value));
}
}
}
}
if (local_storage->store_data(Local_Storage::stats_storage_folder, stat_name, (char* )&nData, sizeof(nData)) == sizeof(nData)) {
stats_cache_int[stat_name] = nData;
result.success = true;
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
return result;
}
return result;
}
Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo::Stat_Type, float>> Steam_User_Stats::set_stat_internal( const char *pchName, float fData )
{
PRINT_DEBUG("<float> '%s' = %f", pchName, fData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo::Stat_Type, float>> result{};
if (!pchName) return result;
std::string stat_name(common_helpers::ascii_to_lowercase(pchName));
const auto &stats_config = settings->getStats();
auto stats_data = stats_config.find(stat_name);
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
Stat_config cfg{};
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT;
cfg.default_value_float = 0;
stats_data = settings->setStatDefiniton(stat_name, cfg);
}
if (stats_config.end() == stats_data) return result;
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
result.internal_name = stat_name;
result.current_val.first = stats_data->second.type;
result.current_val.second = fData;
auto cached_stat = stats_cache_float.find(stat_name);
if (stats_cache_float.end() != cached_stat) {
if (cached_stat->second == fData) {
result.success = true;
return result;
}
}
auto stat_trigger = achievement_stat_trigger.find(stat_name);
if (stat_trigger != achievement_stat_trigger.end()) {
for (auto &t : stat_trigger->second) {
if (t.should_unlock_ach(fData)) {
set_achievement_internal(t.name.c_str());
}
if (settings->stat_achievement_progress_functionality && t.should_indicate_progress(fData)) {
bool indicate_progress = true;
// appid 1482380 needs that otherwise it will spam progress indications while driving
if (settings->save_only_higher_stat_achievement_progress) {
try {
auto user_ach_it = user_achievements.find(t.name);
if (user_achievements.end() != user_ach_it) {
auto user_progress_it = user_ach_it->find("progress");
if (user_ach_it->end() != user_progress_it) {
float user_progress = *user_progress_it;
if (fData <= user_progress) {
indicate_progress = false;
}
}
}
} catch(...){}
}
if (indicate_progress) {
IndicateAchievementProgress(t.name.c_str(), (uint32)fData, (uint32)std::stof(t.max_value));
}
}
}
}
if (local_storage->store_data(Local_Storage::stats_storage_folder, stat_name, (char* )&fData, sizeof(fData)) == sizeof(fData)) {
stats_cache_float[stat_name] = fData;
result.success = true;
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
return result;
}
return result;
}
Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo::Stat_Type, float>> Steam_User_Stats::update_avg_rate_stat_internal( const char *pchName, float flCountThisSession, double dSessionLength )
{
PRINT_DEBUG("%s", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo::Stat_Type, float>> result{};
if (!pchName) return result;
std::string stat_name(common_helpers::ascii_to_lowercase(pchName));
const auto &stats_config = settings->getStats();
auto stats_data = stats_config.find(stat_name);
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
Stat_config cfg{};
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE;
cfg.default_value_float = 0;
stats_data = settings->setStatDefiniton(stat_name, cfg);
}
if (stats_config.end() == stats_data) return result;
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
result.internal_name = stat_name;
char data[sizeof(float) + sizeof(float) + sizeof(double)];
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, stat_name, (char* )data, sizeof(*data));
float oldcount = 0;
double oldsessionlength = 0;
if (read_data == sizeof(data)) {
memcpy(&oldcount, data + sizeof(float), sizeof(oldcount));
memcpy(&oldsessionlength, data + sizeof(float) + sizeof(float), sizeof(oldsessionlength));
}
oldcount += flCountThisSession;
oldsessionlength += dSessionLength;
float average = static_cast<float>(oldcount / oldsessionlength);
memcpy(data, &average, sizeof(average));
memcpy(data + sizeof(float), &oldcount, sizeof(oldcount));
memcpy(data + sizeof(float) * 2, &oldsessionlength, sizeof(oldsessionlength));
result.current_val.first = stats_data->second.type;
result.current_val.second = average;
if (local_storage->store_data(Local_Storage::stats_storage_folder, stat_name, data, sizeof(data)) == sizeof(data)) {
stats_cache_float[stat_name] = average;
result.success = true;
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
return result;
}
return result;
}
void Steam_User_Stats::steam_user_stats_network_stats(void *object, Common_Message *msg)
{
// PRINT_DEBUG_ENTRY();
auto inst = (Steam_User_Stats *)object;
inst->network_callback_stats(msg);
}
// Ask the server to send down this user's data and achievements for this game
STEAM_CALL_BACK( UserStatsReceived_t )
bool Steam_User_Stats::RequestCurrentStats()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
UserStatsReceived_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = settings->get_local_steam_id();
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return true;
}
// Data accessors
bool Steam_User_Stats::GetStat( const char *pchName, int32 *pData )
{
PRINT_DEBUG("<int32> '%s' %p", pchName, pData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
std::string stat_name = common_helpers::ascii_to_lowercase(pchName);
const auto &stats_config = settings->getStats();
auto stats_data = stats_config.find(stat_name);
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
Stat_config cfg{};
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_INT;
cfg.default_value_int = 0;
stats_data = settings->setStatDefiniton(stat_name, cfg);
}
if (stats_config.end() == stats_data) return false;
if (stats_data->second.type != GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return false;
auto cached_stat = stats_cache_int.find(stat_name);
if (cached_stat != stats_cache_int.end()) {
if (pData) *pData = cached_stat->second;
return true;
}
int32 output = 0;
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, stat_name, (char* )&output, sizeof(output));
if (read_data == sizeof(int32)) {
stats_cache_int[stat_name] = output;
if (pData) *pData = output;
return true;
}
stats_cache_int[stat_name] = stats_data->second.default_value_int;
if (pData) *pData = stats_data->second.default_value_int;
return true;
}
bool Steam_User_Stats::GetStat( const char *pchName, float *pData )
{
PRINT_DEBUG("<float> '%s' %p", pchName, pData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
std::string stat_name = common_helpers::ascii_to_lowercase(pchName);
const auto &stats_config = settings->getStats();
auto stats_data = stats_config.find(stat_name);
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
Stat_config cfg{};
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT;
cfg.default_value_float = 0;
stats_data = settings->setStatDefiniton(stat_name, cfg);
}
if (stats_config.end() == stats_data) return false;
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return false;
auto cached_stat = stats_cache_float.find(stat_name);
if (cached_stat != stats_cache_float.end()) {
if (pData) *pData = cached_stat->second;
return true;
}
float output = 0.0;
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, stat_name, (char* )&output, sizeof(output));
if (read_data == sizeof(float)) {
stats_cache_float[stat_name] = output;
if (pData) *pData = output;
return true;
}
stats_cache_float[stat_name] = stats_data->second.default_value_float;
if (pData) *pData = stats_data->second.default_value_float;
return true;
}
// Set / update data
bool Steam_User_Stats::SetStat( const char *pchName, int32 nData )
{
PRINT_DEBUG("<int32> '%s' = %i", pchName, nData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto ret = set_stat_internal(pchName, nData );
if (ret.success && ret.notify_server ) {
auto &new_stat = (*pending_server_updates.mutable_user_stats())[ret.internal_name];
new_stat.set_stat_type(GameServerStats_Messages::StatInfo::STAT_TYPE_INT);
new_stat.set_value_int(ret.current_val);
if (settings->immediate_gameserver_stats) send_updated_stats();
}
return ret.success;
}
bool Steam_User_Stats::SetStat( const char *pchName, float fData )
{
PRINT_DEBUG("<float> '%s' = %f", pchName, fData);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto ret = set_stat_internal(pchName, fData);
if (ret.success && ret.notify_server) {
auto &new_stat = (*pending_server_updates.mutable_user_stats())[ret.internal_name];
new_stat.set_stat_type(ret.current_val.first);
new_stat.set_value_float(ret.current_val.second);
if (settings->immediate_gameserver_stats) send_updated_stats();
}
return ret.success;
}
bool Steam_User_Stats::UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength )
{
PRINT_DEBUG("'%s'", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto ret = update_avg_rate_stat_internal(pchName, flCountThisSession, dSessionLength);
if (ret.success && ret.notify_server) {
auto &new_stat = (*pending_server_updates.mutable_user_stats())[ret.internal_name];
new_stat.set_stat_type(ret.current_val.first);
new_stat.set_value_float(ret.current_val.second);
if (settings->immediate_gameserver_stats) send_updated_stats();
}
return ret.success;
}
// Store the current data on the server, will get a callback when set
// And one callback for every new achievement
//
// If the callback has a result of k_EResultInvalidParam, one or more stats
// uploaded has been rejected, either because they broke constraints
// or were out of date. In this case the server sends back updated values.
// The stats should be re-iterated to keep in sync.
bool Steam_User_Stats::StoreStats()
{
// no need to exchange data with gameserver, we already do that in run_callback() and on each stat/ach update (immediate mode)
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
UserStatsStored_t data{};
data.m_eResult = k_EResultOK;
data.m_nGameID = settings->get_local_game_id().ToUint64();
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.01);
for (auto &kv : store_stats_trigger) {
callbacks->addCBResult(kv.second.k_iCallback, &kv.second, sizeof(kv.second));
}
store_stats_trigger.clear();
return true;
}
// Friends stats
// downloads stats for the user
// returns a UserStatsReceived_t received when completed
// if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail
// these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data
STEAM_CALL_RESULT( UserStatsReceived_t )
SteamAPICall_t Steam_User_Stats::RequestUserStats( CSteamID steamIDUser )
{
PRINT_DEBUG("%llu", steamIDUser.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
// Enable this to allow hot reload achievements status
//if (steamIDUser == settings->get_local_steam_id()) {
// load_achievements();
//}
UserStatsReceived_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = steamIDUser;
// appid 756800 expects both: a callback (global event occurring in the Steam environment),
// and a callresult (the specific result of this function call)
// otherwise it will lock-up and hang at startup
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return ret;
}
// requests stat information for a user, usable after a successful call to RequestUserStats()
bool Steam_User_Stats::GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData )
{
PRINT_DEBUG("'%s' %llu", pchName, steamIDUser.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
} else {
*pData = 0;
}
return true;
}
bool Steam_User_Stats::GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData )
{
PRINT_DEBUG("%s %llu", pchName, steamIDUser.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchName) return false;
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
} else {
*pData = 0;
}
return true;
}
// Reset stats
bool Steam_User_Stats::ResetAllStats( bool bAchievementsToo )
{
PRINT_DEBUG("bAchievementsToo = %i", (int)bAchievementsToo);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
clear_stats_internal(); // this will save stats to disk if necessary
if (!settings->disable_sharing_stats_with_gameserver) {
for (const auto &stat : settings->getStats()) {
std::string stat_name(common_helpers::ascii_to_lowercase(stat.first));
auto &new_stat = (*pending_server_updates.mutable_user_stats())[stat_name];
new_stat.set_stat_type(stat.second.type);
switch (stat.second.type)
{
case GameServerStats_Messages::StatInfo::STAT_TYPE_INT:
new_stat.set_value_int(stat.second.default_value_int);
break;
case GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE:
case GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT:
new_stat.set_value_float(stat.second.default_value_float);
break;
default: PRINT_DEBUG("unhandled type %i", (int)stat.second.type); break;
}
}
}
if (bAchievementsToo) {
bool needs_disk_write = false;
for (auto &kv : user_achievements.items()) {
try {
auto &name = kv.key();
auto &item = kv.value();
// assume "earned" is true in case the json obj exists, but the key is absent
if (item.value("earned", true) == true) needs_disk_write = true;
item["earned"] = false;
item["earned_time"] = static_cast<uint32>(0);
try {
auto defined_ach_it = defined_achievements_find(name);
if (defined_achievements.end() != defined_ach_it) {
auto defined_progress_it = defined_ach_it->find("progress");
if (defined_ach_it->end() != defined_progress_it) { // if the schema had "progress"
uint32 val = 0;
try {
auto defined_min_val = defined_progress_it->value("min_val", std::string("0"));
val = std::stoul(defined_min_val);
} catch(...){}
item["progress"] = val;
}
}
}catch(...){}
// this won't actually trigger a notification, just updates the data
overlay->AddAchievementNotification(name, item, false);
} catch(const std::exception& e) {
PRINT_DEBUG("ERROR: %s", e.what());
}
}
if (needs_disk_write) save_achievements();
if (!settings->disable_sharing_stats_with_gameserver) {
for (const auto &item : user_achievements.items()) {
auto &new_ach = (*pending_server_updates.mutable_user_achievements())[item.key()];
new_ach.set_achieved(false);
}
}
}
if (!settings->disable_sharing_stats_with_gameserver && settings->immediate_gameserver_stats) send_updated_stats();
return true;
}
// Requests global stats data, which is available for stats marked as "aggregated".
// This call is asynchronous, with the results returned in GlobalStatsReceived_t.
// nHistoryDays specifies how many days of day-by-day history to retrieve in addition
// to the overall totals. The limit is 60.
STEAM_CALL_RESULT( GlobalStatsReceived_t )
SteamAPICall_t Steam_User_Stats::RequestGlobalStats( int nHistoryDays )
{
PRINT_DEBUG("%i", nHistoryDays);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
GlobalStatsReceived_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
}
// Gets the lifetime totals for an aggregated stat
bool Steam_User_Stats::GetGlobalStat( const char *pchStatName, int64 *pData )
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return false;
}
bool Steam_User_Stats::GetGlobalStat( const char *pchStatName, double *pData )
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return false;
}
// Gets history for an aggregated stat. pData will be filled with daily values, starting with today.
// So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago,
// etc. cubData is the size in bytes of the pubData buffer. Returns the number of
// elements actually set.
int32 Steam_User_Stats::GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) int64 *pData, uint32 cubData )
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return 0;
}
int32 Steam_User_Stats::GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) double *pData, uint32 cubData )
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return 0;
}
// --- steam callbacks
void Steam_User_Stats::send_updated_stats()
{
if (pending_server_updates.user_stats().empty() && pending_server_updates.user_achievements().empty()) return;
if (settings->disable_sharing_stats_with_gameserver) return;
auto new_updates_msg = new GameServerStats_Messages::AllStats(pending_server_updates);
pending_server_updates.clear_user_stats();
pending_server_updates.clear_user_achievements();
auto gameserverstats_msg = new GameServerStats_Messages();
gameserverstats_msg->set_type(GameServerStats_Messages::UpdateUserStatsFromUser);
gameserverstats_msg->set_allocated_update_user_stats(new_updates_msg);
Common_Message msg{};
// https://protobuf.dev/reference/cpp/cpp-generated/#string
// set_allocated_xxx() takes ownership of the allocated object, no need to delete
msg.set_allocated_gameserver_stats_messages(gameserverstats_msg);
msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
// here we send to all gameservers on the network because we don't know the server steamid
network->sendToAllGameservers(&msg, true);
PRINT_DEBUG("sent updated stats: %zu stats, %zu achievements",
new_updates_msg->user_stats().size(), new_updates_msg->user_achievements().size()
);
}
// --- networking callbacks
// only triggered when we have a message
// server wants all stats
void Steam_User_Stats::network_stats_initial(Common_Message *msg)
{
if (!msg->gameserver_stats_messages().has_initial_user_stats()) {
PRINT_DEBUG("error empty msg");
return;
}
uint64 server_steamid = msg->source_id();
auto all_stats_msg = new GameServerStats_Messages::AllStats();
// get all stats
auto &stats_map = *all_stats_msg->mutable_user_stats();
const auto &current_stats = settings->getStats();
for (const auto &stat : current_stats) {
auto &this_stat = stats_map[stat.first];
this_stat.set_stat_type(stat.second.type);
switch (stat.second.type)
{
case GameServerStats_Messages::StatInfo::STAT_TYPE_INT: {
int32 val = 0;
GetStat(stat.first.c_str(), &val);
this_stat.set_value_int(val);
}
break;
case GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE: // we set the float value also for avg
case GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT: {
float val = 0;
GetStat(stat.first.c_str(), &val);
this_stat.set_value_float(val);
}
break;
default:
PRINT_DEBUG("Request_AllUserStats unhandled stat type %i", (int)stat.second.type);
break;
}
}
// get all achievements
auto &achievements_map = *all_stats_msg->mutable_user_achievements();
for (const auto &ach : defined_achievements) {
const std::string &name = static_cast<const std::string &>( ach.value("name", std::string()) );
auto &this_ach = achievements_map[name];
// achieved or not
bool achieved = false;
GetAchievement(name.c_str(), &achieved);
this_ach.set_achieved(achieved);
}
auto initial_stats_msg = new GameServerStats_Messages::InitialAllStats();
// send back same api call id
initial_stats_msg->set_steam_api_call(msg->gameserver_stats_messages().initial_user_stats().steam_api_call());
initial_stats_msg->set_allocated_all_data(all_stats_msg);
auto gameserverstats_msg = new GameServerStats_Messages();
gameserverstats_msg->set_type(GameServerStats_Messages::Response_AllUserStats);
gameserverstats_msg->set_allocated_initial_user_stats(initial_stats_msg);
Common_Message new_msg{};
// https://protobuf.dev/reference/cpp/cpp-generated/#string
// set_allocated_xxx() takes ownership of the allocated object, no need to delete
new_msg.set_allocated_gameserver_stats_messages(gameserverstats_msg);
new_msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
new_msg.set_dest_id(server_steamid);
network->sendTo(&new_msg, true);
PRINT_DEBUG("server requested all stats, sent %zu stats, %zu achievements",
initial_stats_msg->all_data().user_stats().size(), initial_stats_msg->all_data().user_achievements().size()
);
}
// server has updated/new stats
void Steam_User_Stats::network_stats_updated(Common_Message *msg)
{
if (!msg->gameserver_stats_messages().has_update_user_stats()) {
PRINT_DEBUG("error empty msg");
return;
}
auto &new_user_data = msg->gameserver_stats_messages().update_user_stats();
// update our stats
for (auto &new_stat : new_user_data.user_stats()) {
switch (new_stat.second.stat_type())
{
case GameServerStats_Messages::StatInfo::STAT_TYPE_INT: {
set_stat_internal(new_stat.first.c_str(), new_stat.second.value_int());
}
break;
case GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE:
case GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT: {
set_stat_internal(new_stat.first.c_str(), new_stat.second.value_float());
// non-INT values could have avg values
if (new_stat.second.has_value_avg()) {
auto &avg_val = new_stat.second.value_avg();
update_avg_rate_stat_internal(new_stat.first.c_str(), avg_val.count_this_session(), avg_val.session_length());
}
}
break;
default:
PRINT_DEBUG("UpdateUserStats unhandled stat type %i", (int)new_stat.second.stat_type());
break;
}
}
// update achievements
for (auto &new_ach : new_user_data.user_achievements()) {
if (new_ach.second.achieved()) {
set_achievement_internal(new_ach.first.c_str());
} else {
clear_achievement_internal(new_ach.first.c_str());
}
}
PRINT_DEBUG("server sent updated user stats, %zu stats, %zu achievements",
new_user_data.user_stats().size(), new_user_data.user_achievements().size()
);
}
void Steam_User_Stats::network_callback_stats(Common_Message *msg)
{
// network->sendToAll() sends to current user also
if (msg->source_id() == settings->get_local_steam_id().ConvertToUint64()) return;
uint64 server_steamid = msg->source_id();
switch (msg->gameserver_stats_messages().type())
{
// server wants all stats
case GameServerStats_Messages::Request_AllUserStats:
network_stats_initial(msg);
break;
// server has updated/new stats
case GameServerStats_Messages::UpdateUserStatsFromServer:
network_stats_updated(msg);
break;
// a user has updated/new stats
case GameServerStats_Messages::UpdateUserStatsFromUser:
// nothing
break;
default:
PRINT_DEBUG("unhandled type %i", (int)msg->gameserver_stats_messages().type());
break;
}
}

View File

@ -81,11 +81,11 @@ bool Steam_Utils::GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight )
if (!iImage || !pnWidth || !pnHeight) return false;
auto image = settings->images.find(iImage);
if (settings->images.end() == image) return false;
auto image_info = settings->get_image(iImage);
if (!image_info) return false;
*pnWidth = image->second.width;
*pnHeight = image->second.height;
*pnWidth = image_info->width;
*pnHeight = image_info->height;
return true;
}
@ -99,10 +99,10 @@ bool Steam_Utils::GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize
if (!iImage || !pubDest || nDestBufferSize <= 0) return false;
auto image = settings->images.find(iImage);
if (settings->images.end() == image) return false;
auto image_info = settings->get_image(iImage);
if (!image_info) return false;
image->second.data.copy((char *)pubDest, nDestBufferSize);
image_info->data.copy((char *)pubDest, nDestBufferSize);
return true;
}

View File

@ -63,24 +63,16 @@ enum class notification_type
struct Overlay_Achievement
{
// avoids spam loading on failure
constexpr const static int ICON_LOAD_MAX_TRIALS = 3;
std::string name{};
std::string title{};
std::string description{};
std::string icon_name{};
std::string icon_gray_name{};
std::string name{}; // internal schema name
std::string title{}; // displayName
std::string description{}; // description
uint32 progress{};
uint32 max_progress{};
bool hidden{};
bool achieved{};
uint32 unlock_time{};
std::weak_ptr<uint64_t> icon{};
std::weak_ptr<uint64_t> icon_gray{};
uint8_t icon_load_trials = ICON_LOAD_MAX_TRIALS;
uint8_t icon_gray_load_trials = ICON_LOAD_MAX_TRIALS;
std::pair< std::weak_ptr<uint64_t>, bool > icon{};
std::pair< std::weak_ptr<uint64_t>, bool > icon_gray{};
};
struct Notification
@ -107,7 +99,6 @@ struct NotificationsCoords
class Steam_Overlay
{
constexpr static const char ACH_SOUNDS_FOLDER[] = "sounds";
constexpr static const char ACH_FALLBACK_DIR[] = "achievement_images";
constexpr static const int renderer_detector_polling_ms = 100;
@ -159,7 +150,6 @@ class Steam_Overlay
// some stuff has to be initialized once the renderer hook is ready
std::atomic<bool> late_init_imgui = false;
bool late_init_ach_icons = false;
// changed each time a notification is posted or overlay is shown/hidden
std::atomic_uint32_t renderer_frame_processing_requests = 0;
@ -235,7 +225,6 @@ class Steam_Overlay
void create_fonts();
void load_audio();
void load_achievements_data();
void initial_load_achievements_icons();
void overlay_state_hook(bool ready);
void allow_renderer_frame_processing(bool state, bool cleaning_up_overlay = false);

View File

@ -85,7 +85,23 @@ void Steam_Overlay::overlay_run_callback(void* object)
{
// PRINT_DEBUG_ENTRY();
Steam_Overlay* _this = reinterpret_cast<Steam_Overlay*>(object);
// bail immediately if we can't lock the overlay mutex, deadlock scenario:
// 1. ** the background thread locks the global mutex
// 2. -- the user opens the overlay
// 3. -- the overlay proc is triggered the next frame, locking the overlay mutex
// 4. ** the background thread locks the global mutex and runs this callback
// 5. ** this callback (already having the global mutex) attempts to lock the overlay mutex (already locked before)
// 6. ** this callback, and the background thread, are now blocked, note that the global mutex is still locked
// 7. -- in the same frame, some code in the overlay proc attempts to call a steam API which usually locks the global mutex
// sice the global mutex is still locked, the overlay proc is also blocked,
// and now both the background thread and the overlay proc and locked
// even worse, the global mutex is locked forever now
if (!_this->overlay_mutex.try_lock()) return;
_this->steam_run_callback();
_this->overlay_mutex.unlock();
}
void Steam_Overlay::overlay_networking_callback(void* object, Common_Message* msg)
@ -356,9 +372,6 @@ void Steam_Overlay::load_achievements_data()
ach.unlock_time = 0;
}
ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true);
ach.icon_gray_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false);
float pnMinProgress = 0, pnMaxProgress = 0;
if (steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress)) {
ach.progress = (uint32)pnMinProgress;
@ -374,40 +387,6 @@ void Steam_Overlay::load_achievements_data()
}
void Steam_Overlay::initial_load_achievements_icons()
{
{
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (late_init_ach_icons) return;
}
PRINT_DEBUG_ENTRY();
for (auto &ach : achievements) {
{
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!is_ready || !setup_overlay_called) {
PRINT_DEBUG("early exit");
return;
}
}
try_load_ach_icon(ach, true);
{
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!is_ready || !setup_overlay_called) {
PRINT_DEBUG("early exit");
return;
}
}
try_load_ach_icon(ach, false);
}
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
late_init_ach_icons = true;
}
// called initially and when window size is updated
void Steam_Overlay::overlay_state_hook(bool ready)
{
@ -662,7 +641,10 @@ void Steam_Overlay::show_test_achievement()
if (achievements.size()) {
size_t rand_idx = common_helpers::rand_number(achievements.size() - 1);
ach.icon = achievements[rand_idx].icon;
auto &rand_ach = achievements[rand_idx];
bool achieved = rand_idx < (achievements.size() / 2);
try_load_ach_icon(rand_ach, achieved);
ach.icon = achieved ? rand_ach.icon : rand_ach.icon_gray;
}
bool for_progress = false;
@ -1126,13 +1108,16 @@ void Steam_Overlay::build_notifications(float width, float height)
case notification_type::achievement_progress:
case notification_type::achievement: {
const auto &ach = it->ach.value();
if (!ach.icon.expired() && ImGui::BeginTable("imgui_table", 2)) {
auto& [icon_rsrc, _] = (notification_type)it->type == notification_type::achievement
? ach.icon
: ach.icon_gray;
if (!icon_rsrc.expired() && ImGui::BeginTable("imgui_table", 2)) {
ImGui::TableSetupColumn("imgui_table_image", ImGuiTableColumnFlags_WidthFixed, settings->overlay_appearance.icon_size);
ImGui::TableSetupColumn("imgui_table_text");
ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size);
ImGui::TableSetColumnIndex(0);
ImGui::Image((ImTextureID)*ach.icon.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));
ImGui::Image((ImTextureID)*icon_rsrc.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));
ImGui::TableSetColumnIndex(1);
ImGui::TextWrapped("%s", it->message.c_str());
@ -1259,7 +1244,7 @@ void Steam_Overlay::post_achievement_notification(Overlay_Achievement &ach, bool
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!Ready()) return;
try_load_ach_icon(ach, !for_progress);
try_load_ach_icon(ach, !for_progress); // for progress notifications we want to load the gray icon
submit_notification(
for_progress ? notification_type::achievement_progress : notification_type::achievement,
ach.title + "\n" + ach.description,
@ -1284,43 +1269,27 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved)
{
if (!_renderer) return false;
std::weak_ptr<uint64_t> &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
const std::string &icon_name = achieved ? ach.icon_name : ach.icon_gray_name;
uint8_t &load_trials = achieved ? ach.icon_load_trials : ach.icon_gray_load_trials;
if (!icon_rsrc.expired()) return true;
if (load_trials && icon_name.size()) {
--load_trials;
std::string file_path(Local_Storage::get_game_settings_path() + icon_name);
unsigned int file_size = file_size_(file_path);
if (!file_size) {
file_path = Local_Storage::get_game_settings_path() + Steam_Overlay::ACH_FALLBACK_DIR + PATH_SEPARATOR + icon_name;
file_size = file_size_(file_path);
}
auto& [icon_rsrc, attempted] = achieved ? ach.icon : ach.icon_gray;
if (attempted || !icon_rsrc.expired()) return true;
const int icon_handle = get_steam_client()->steam_user_stats->get_achievement_icon_handle(ach.name, achieved);
auto image_info = settings->get_image(icon_handle);
if (image_info) {
int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
if (file_size) {
std::string img(Local_Storage::load_image_resized(file_path, "", icon_size));
if (img.size()) {
icon_rsrc = _renderer->CreateImageResource(
(void*)img.c_str(),
(void*)image_info->data.c_str(),
icon_size, icon_size);
if (!icon_rsrc.expired()) load_trials = Overlay_Achievement::ICON_LOAD_MAX_TRIALS;
PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)!icon_rsrc.expired());
}
}
}
attempted = true;
return !icon_rsrc.expired();
}
// Try to make this function as short as possible or it might affect game's fps.
void Steam_Overlay::overlay_render_proc()
{
initial_load_achievements_icons();
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!Ready()) return;
@ -1517,7 +1486,7 @@ void Steam_Overlay::render_main_window()
ImGui::Separator();
bool could_create_ach_table_entry = false;
if (!x.icon.expired() || !x.icon_gray.expired()) {
if (!x.icon.first.expired() || !x.icon_gray.first.expired()) {
if (ImGui::BeginTable(x.title.c_str(), 2)) {
could_create_ach_table_entry = true;
@ -1526,21 +1495,13 @@ void Steam_Overlay::render_main_window()
ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size);
ImGui::TableSetColumnIndex(0);
if (achieved) {
if (!x.icon.expired()) {
auto& [icon_rsrc, _] = achieved ? x.icon : x.icon_gray;
if (!icon_rsrc.expired()) {
ImGui::Image(
(ImTextureID)*x.icon.lock().get(),
(ImTextureID)*icon_rsrc.lock().get(),
ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)
);
}
} else {
if (!x.icon_gray.expired()) {
ImGui::Image(
(ImTextureID)*x.icon_gray.lock().get(),
ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)
);
}
}
ImGui::TableSetColumnIndex(1);
// the next column is the achievement text below
@ -1680,8 +1641,6 @@ void Steam_Overlay::networking_msg_received(Common_Message *msg)
{
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!Ready()) return;
if (msg->has_steam_messages()) {
Friend frd;
frd.set_id(msg->source_id());
@ -1702,8 +1661,6 @@ void Steam_Overlay::networking_msg_received(Common_Message *msg)
void Steam_Overlay::steam_run_callback()
{
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!Ready()) return;
if (overlay_state_changed) {
@ -1881,14 +1838,14 @@ void Steam_Overlay::UnSetupOverlay()
PRINT_DEBUG("releasing any images resources");
for (auto &ach : achievements) {
if (!ach.icon.expired()) {
_renderer->ReleaseImageResource(ach.icon);
ach.icon.reset();
if (!ach.icon.first.expired()) {
_renderer->ReleaseImageResource(ach.icon.first);
ach.icon.first.reset();
}
if (!ach.icon_gray.expired()) {
_renderer->ReleaseImageResource(ach.icon_gray);
ach.icon_gray.reset();
if (!ach.icon_gray.first.expired()) {
_renderer->ReleaseImageResource(ach.icon_gray.first);
ach.icon_gray.first.reset();
}
}
@ -1906,7 +1863,7 @@ void Steam_Overlay::UnSetupOverlay()
bool Steam_Overlay::Ready() const
{
return !settings->disable_overlay && is_ready && late_init_imgui && late_init_ach_icons;
return !settings->disable_overlay && is_ready && late_init_imgui;
}
bool Steam_Overlay::NeedPresent() const

View File

@ -1,245 +0,0 @@
//
// File: vk_icd.h
//
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* 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.
*
*/
#ifndef VKICD_H
#define VKICD_H
#include "vulkan.h"
#include <stdbool.h>
// Loader-ICD version negotiation API. Versions add the following features:
// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
// or vk_icdNegotiateLoaderICDInterfaceVersion.
// Version 1 - Add support for vk_icdGetInstanceProcAddr.
// Version 2 - Add Loader/ICD Interface version negotiation
// via vk_icdNegotiateLoaderICDInterfaceVersion.
// Version 3 - Add ICD creation/destruction of KHR_surface objects.
// Version 4 - Add unknown physical device extension querying via
// vk_icdGetPhysicalDeviceProcAddr.
// Version 5 - Tells ICDs that the loader is now paying attention to the
// application version of Vulkan passed into the ApplicationInfo
// structure during vkCreateInstance. This will tell the ICD
// that if the loader is older, it should automatically fail a
// call for any API version > 1.0. Otherwise, the loader will
// manually determine if it can support the expected version.
// Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices.
#define CURRENT_LOADER_ICD_INTERFACE_VERSION 6
#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
// Old typedefs that don't follow a proper naming convention but are preserved for compatibility
typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
// file directly, it won't be found.
#ifndef PFN_GetPhysicalDeviceProcAddr
typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
#endif
// Typedefs for loader/ICD interface
typedef VkResult (VKAPI_PTR *PFN_vk_icdNegotiateLoaderICDInterfaceVersion)(uint32_t* pVersion);
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName);
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
#if defined(VK_USE_PLATFORM_WIN32_KHR)
typedef VkResult (VKAPI_PTR *PFN_vk_icdEnumerateAdapterPhysicalDevices)(VkInstance instance, LUID adapterLUID,
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
#endif
// Prototypes for loader/ICD interface
#if !defined(VK_NO_PROTOTYPES)
#ifdef __cplusplus
extern "C" {
#endif
VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion);
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName);
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName);
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID,
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
* The ICD must reserve space for a pointer for the loader's dispatch
* table, at the start of <each object>.
* The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
*/
#define ICD_LOADER_MAGIC 0x01CDC0DE
typedef union {
uintptr_t loaderMagic;
void *loaderData;
} VK_LOADER_DATA;
static inline void set_loader_magic_value(void *pNewObject) {
VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
loader_info->loaderMagic = ICD_LOADER_MAGIC;
}
static inline bool valid_loader_magic_value(void *pNewObject) {
const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
}
/*
* Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
* contains the platform-specific connection and surface information.
*/
typedef enum {
VK_ICD_WSI_PLATFORM_MIR,
VK_ICD_WSI_PLATFORM_WAYLAND,
VK_ICD_WSI_PLATFORM_WIN32,
VK_ICD_WSI_PLATFORM_XCB,
VK_ICD_WSI_PLATFORM_XLIB,
VK_ICD_WSI_PLATFORM_ANDROID,
VK_ICD_WSI_PLATFORM_MACOS,
VK_ICD_WSI_PLATFORM_IOS,
VK_ICD_WSI_PLATFORM_DISPLAY,
VK_ICD_WSI_PLATFORM_HEADLESS,
VK_ICD_WSI_PLATFORM_METAL,
VK_ICD_WSI_PLATFORM_DIRECTFB,
VK_ICD_WSI_PLATFORM_VI,
VK_ICD_WSI_PLATFORM_GGP,
VK_ICD_WSI_PLATFORM_SCREEN,
} VkIcdWsiPlatform;
typedef struct {
VkIcdWsiPlatform platform;
} VkIcdSurfaceBase;
#ifdef VK_USE_PLATFORM_MIR_KHR
typedef struct {
VkIcdSurfaceBase base;
MirConnection *connection;
MirSurface *mirSurface;
} VkIcdSurfaceMir;
#endif // VK_USE_PLATFORM_MIR_KHR
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
typedef struct {
VkIcdSurfaceBase base;
struct wl_display *display;
struct wl_surface *surface;
} VkIcdSurfaceWayland;
#endif // VK_USE_PLATFORM_WAYLAND_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
typedef struct {
VkIcdSurfaceBase base;
HINSTANCE hinstance;
HWND hwnd;
} VkIcdSurfaceWin32;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_XCB_KHR
typedef struct {
VkIcdSurfaceBase base;
xcb_connection_t *connection;
xcb_window_t window;
} VkIcdSurfaceXcb;
#endif // VK_USE_PLATFORM_XCB_KHR
#ifdef VK_USE_PLATFORM_XLIB_KHR
typedef struct {
VkIcdSurfaceBase base;
Display *dpy;
Window window;
} VkIcdSurfaceXlib;
#endif // VK_USE_PLATFORM_XLIB_KHR
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
typedef struct {
VkIcdSurfaceBase base;
IDirectFB *dfb;
IDirectFBSurface *surface;
} VkIcdSurfaceDirectFB;
#endif // VK_USE_PLATFORM_DIRECTFB_EXT
#ifdef VK_USE_PLATFORM_ANDROID_KHR
typedef struct {
VkIcdSurfaceBase base;
struct ANativeWindow *window;
} VkIcdSurfaceAndroid;
#endif // VK_USE_PLATFORM_ANDROID_KHR
#ifdef VK_USE_PLATFORM_MACOS_MVK
typedef struct {
VkIcdSurfaceBase base;
const void *pView;
} VkIcdSurfaceMacOS;
#endif // VK_USE_PLATFORM_MACOS_MVK
#ifdef VK_USE_PLATFORM_IOS_MVK
typedef struct {
VkIcdSurfaceBase base;
const void *pView;
} VkIcdSurfaceIOS;
#endif // VK_USE_PLATFORM_IOS_MVK
#ifdef VK_USE_PLATFORM_GGP
typedef struct {
VkIcdSurfaceBase base;
GgpStreamDescriptor streamDescriptor;
} VkIcdSurfaceGgp;
#endif // VK_USE_PLATFORM_GGP
typedef struct {
VkIcdSurfaceBase base;
VkDisplayModeKHR displayMode;
uint32_t planeIndex;
uint32_t planeStackIndex;
VkSurfaceTransformFlagBitsKHR transform;
float globalAlpha;
VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
VkExtent2D imageExtent;
} VkIcdSurfaceDisplay;
typedef struct {
VkIcdSurfaceBase base;
} VkIcdSurfaceHeadless;
#ifdef VK_USE_PLATFORM_METAL_EXT
typedef struct {
VkIcdSurfaceBase base;
const CAMetalLayer *pLayer;
} VkIcdSurfaceMetal;
#endif // VK_USE_PLATFORM_METAL_EXT
#ifdef VK_USE_PLATFORM_VI_NN
typedef struct {
VkIcdSurfaceBase base;
void *window;
} VkIcdSurfaceVi;
#endif // VK_USE_PLATFORM_VI_NN
#ifdef VK_USE_PLATFORM_SCREEN_QNX
typedef struct {
VkIcdSurfaceBase base;
struct _screen_context *context;
struct _screen_window *window;
} VkIcdSurfaceScreen;
#endif // VK_USE_PLATFORM_SCREEN_QNX
#endif // VKICD_H

View File

@ -1,210 +0,0 @@
//
// File: vk_layer.h
//
/*
* Copyright (c) 2015-2017 The Khronos Group Inc.
* Copyright (c) 2015-2017 Valve Corporation
* Copyright (c) 2015-2017 LunarG, Inc.
*
* 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.
*
*/
/* Need to define dispatch table
* Core struct can then have ptr to dispatch table at the top
* Along with object ptrs for current and next OBJ
*/
#pragma once
#include "vulkan.h"
#if defined(__GNUC__) && __GNUC__ >= 4
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
#else
#define VK_LAYER_EXPORT
#endif
#define MAX_NUM_UNKNOWN_EXTS 250
// Loader-Layer version negotiation API. Versions add the following features:
// Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr
// or vk_icdNegotiateLoaderLayerInterfaceVersion.
// Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and
// vk_icdNegotiateLoaderLayerInterfaceVersion.
#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2
#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1
#define VK_CURRENT_CHAIN_VERSION 1
// Typedef for use in the interfaces below
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
// Version negotiation values
typedef enum VkNegotiateLayerStructType {
LAYER_NEGOTIATE_UNINTIALIZED = 0,
LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
} VkNegotiateLayerStructType;
// Version negotiation structures
typedef struct VkNegotiateLayerInterface {
VkNegotiateLayerStructType sType;
void *pNext;
uint32_t loaderLayerInterfaceVersion;
PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr;
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr;
PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr;
} VkNegotiateLayerInterface;
// Version negotiation functions
typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct);
// Function prototype for unknown physical device extension command
typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
// ------------------------------------------------------------------------------------------------
// CreateInstance and CreateDevice support structures
/* Sub type of structure for instance and device loader ext of CreateInfo.
* When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
* or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
* then VkLayerFunction indicates struct type pointed to by pNext
*/
typedef enum VkLayerFunction_ {
VK_LAYER_LINK_INFO = 0,
VK_LOADER_DATA_CALLBACK = 1,
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2,
VK_LOADER_FEATURES = 3,
} VkLayerFunction;
typedef struct VkLayerInstanceLink_ {
struct VkLayerInstanceLink_ *pNext;
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr;
} VkLayerInstanceLink;
/*
* When creating the device chain the loader needs to pass
* down information about it's device structure needed at
* the end of the chain. Passing the data via the
* VkLayerDeviceInfo avoids issues with finding the
* exact instance being used.
*/
typedef struct VkLayerDeviceInfo_ {
void *device_info;
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
} VkLayerDeviceInfo;
typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
void *object);
typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
void *object);
typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
typedef enum VkLoaderFeastureFlagBits {
VK_LOADER_FEATURE_PHYSICAL_DEVICE_SORTING = 0x00000001,
} VkLoaderFlagBits;
typedef VkFlags VkLoaderFeatureFlags;
typedef struct {
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
const void *pNext;
VkLayerFunction function;
union {
VkLayerInstanceLink *pLayerInfo;
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
struct {
PFN_vkLayerCreateDevice pfnLayerCreateDevice;
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice;
} layerDevice;
VkLoaderFeatureFlags loaderFeatures;
} u;
} VkLayerInstanceCreateInfo;
typedef struct VkLayerDeviceLink_ {
struct VkLayerDeviceLink_ *pNext;
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
} VkLayerDeviceLink;
typedef struct {
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
const void *pNext;
VkLayerFunction function;
union {
VkLayerDeviceLink *pLayerInfo;
PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
} u;
} VkLayerDeviceCreateInfo;
#ifdef __cplusplus
extern "C" {
#endif
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct);
typedef enum VkChainType {
VK_CHAIN_TYPE_UNKNOWN = 0,
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1,
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2,
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3,
} VkChainType;
typedef struct VkChainHeader {
VkChainType type;
uint32_t version;
uint32_t size;
} VkChainHeader;
typedef struct VkEnumerateInstanceExtensionPropertiesChain {
VkChainHeader header;
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *,
VkExtensionProperties *);
const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink;
#if defined(__cplusplus)
inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const {
return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties);
}
#endif
} VkEnumerateInstanceExtensionPropertiesChain;
typedef struct VkEnumerateInstanceLayerPropertiesChain {
VkChainHeader header;
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *);
const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink;
#if defined(__cplusplus)
inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const {
return pfnNextLayer(pNextLink, pPropertyCount, pProperties);
}
#endif
} VkEnumerateInstanceLayerPropertiesChain;
typedef struct VkEnumerateInstanceVersionChain {
VkChainHeader header;
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *);
const struct VkEnumerateInstanceVersionChain *pNextLink;
#if defined(__cplusplus)
inline VkResult CallDown(uint32_t *pApiVersion) const {
return pfnNextLayer(pNextLink, pApiVersion);
}
#endif
} VkEnumerateInstanceVersionChain;
#ifdef __cplusplus
}
#endif

View File

@ -1,84 +0,0 @@
//
// File: vk_platform.h
//
/*
** Copyright 2014-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
#ifndef VK_PLATFORM_H_
#define VK_PLATFORM_H_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
/*
***************************************************************************************************
* Platform-specific directives and type declarations
***************************************************************************************************
*/
/* Platform-specific calling convention macros.
*
* Platforms should define these so that Vulkan clients call Vulkan commands
* with the same calling conventions that the Vulkan implementation expects.
*
* VKAPI_ATTR - Placed before the return type in function declarations.
* Useful for C++11 and GCC/Clang-style function attribute syntax.
* VKAPI_CALL - Placed after the return type in function declarations.
* Useful for MSVC-style calling convention syntax.
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
*
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
*/
#if defined(_WIN32)
// On Windows, Vulkan commands use the stdcall convention
#define VKAPI_ATTR
#define VKAPI_CALL __stdcall
#define VKAPI_PTR VKAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
// is true even if the rest of the application passes floats on the stack,
// as it does by default when compiling for the armeabi-v7a NDK ABI.
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
#define VKAPI_CALL
#define VKAPI_PTR VKAPI_ATTR
#else
// On other platforms, use the default calling convention
#define VKAPI_ATTR
#define VKAPI_CALL
#define VKAPI_PTR
#endif
#if !defined(VK_NO_STDDEF_H)
#include <stddef.h>
#endif // !defined(VK_NO_STDDEF_H)
#if !defined(VK_NO_STDINT_H)
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#endif // !defined(VK_NO_STDINT_H)
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif

View File

@ -1,69 +0,0 @@
//
// File: vk_sdk_platform.h
//
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* 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.
*/
#ifndef VK_SDK_PLATFORM_H
#define VK_SDK_PLATFORM_H
#if defined(_WIN32)
#define NOMINMAX
#ifndef __cplusplus
#undef inline
#define inline __inline
#endif // __cplusplus
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
// C99:
// Microsoft didn't implement C99 in Visual Studio; but started adding it with
// VS2013. However, VS2013 still didn't have snprintf(). The following is a
// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
// "CMakeLists.txt" file).
// NOTE: This is fixed in Visual Studio 2015.
#define snprintf _snprintf
#endif
#define strdup _strdup
#endif // _WIN32
// Check for noexcept support using clang, with fallback to Windows or GCC version numbers
#ifndef NOEXCEPT
#if defined(__clang__)
#if __has_feature(cxx_noexcept)
#define HAS_NOEXCEPT
#endif
#else
#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46
#define HAS_NOEXCEPT
#else
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS
#define HAS_NOEXCEPT
#endif
#endif
#endif
#ifdef HAS_NOEXCEPT
#define NOEXCEPT noexcept
#else
#define NOEXCEPT
#endif
#endif
#endif // VK_SDK_PLATFORM_H

View File

@ -1,92 +0,0 @@
#ifndef VULKAN_H_
#define VULKAN_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
#include "vk_platform.h"
#include "vulkan_core.h"
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include "vulkan_android.h"
#endif
#ifdef VK_USE_PLATFORM_FUCHSIA
#include <zircon/types.h>
#include "vulkan_fuchsia.h"
#endif
#ifdef VK_USE_PLATFORM_IOS_MVK
#include "vulkan_ios.h"
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
#include "vulkan_macos.h"
#endif
#ifdef VK_USE_PLATFORM_METAL_EXT
#include "vulkan_metal.h"
#endif
#ifdef VK_USE_PLATFORM_VI_NN
#include "vulkan_vi.h"
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <wayland-client.h>
#include "vulkan_wayland.h"
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <windows.h>
#include "vulkan_win32.h"
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
#include <xcb/xcb.h>
#include "vulkan_xcb.h"
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
#include <X11/Xlib.h>
#include "vulkan_xlib.h"
#endif
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
#include <directfb.h>
#include "vulkan_directfb.h"
#endif
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include "vulkan_xlib_xrandr.h"
#endif
#ifdef VK_USE_PLATFORM_GGP
#include <ggp_c/vulkan_types.h>
#include "vulkan_ggp.h"
#endif
#ifdef VK_USE_PLATFORM_SCREEN_QNX
#include <screen/screen.h>
#include "vulkan_screen.h"
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
#include "vulkan_beta.h"
#endif
#endif // VULKAN_H_

View File

@ -1,125 +0,0 @@
#ifndef VULKAN_ANDROID_H_
#define VULKAN_ANDROID_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_android_surface 1
struct ANativeWindow;
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
typedef struct VkAndroidSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkAndroidSurfaceCreateFlagsKHR flags;
struct ANativeWindow* window;
} VkAndroidSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
VkInstance instance,
const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#define VK_ANDROID_external_memory_android_hardware_buffer 1
struct AHardwareBuffer;
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 4
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer"
typedef struct VkAndroidHardwareBufferUsageANDROID {
VkStructureType sType;
void* pNext;
uint64_t androidHardwareBufferUsage;
} VkAndroidHardwareBufferUsageANDROID;
typedef struct VkAndroidHardwareBufferPropertiesANDROID {
VkStructureType sType;
void* pNext;
VkDeviceSize allocationSize;
uint32_t memoryTypeBits;
} VkAndroidHardwareBufferPropertiesANDROID;
typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID {
VkStructureType sType;
void* pNext;
VkFormat format;
uint64_t externalFormat;
VkFormatFeatureFlags formatFeatures;
VkComponentMapping samplerYcbcrConversionComponents;
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
VkSamplerYcbcrRange suggestedYcbcrRange;
VkChromaLocation suggestedXChromaOffset;
VkChromaLocation suggestedYChromaOffset;
} VkAndroidHardwareBufferFormatPropertiesANDROID;
typedef struct VkImportAndroidHardwareBufferInfoANDROID {
VkStructureType sType;
const void* pNext;
struct AHardwareBuffer* buffer;
} VkImportAndroidHardwareBufferInfoANDROID;
typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
} VkMemoryGetAndroidHardwareBufferInfoANDROID;
typedef struct VkExternalFormatANDROID {
VkStructureType sType;
void* pNext;
uint64_t externalFormat;
} VkExternalFormatANDROID;
typedef struct VkAndroidHardwareBufferFormatProperties2ANDROID {
VkStructureType sType;
void* pNext;
VkFormat format;
uint64_t externalFormat;
VkFormatFeatureFlags2KHR formatFeatures;
VkComponentMapping samplerYcbcrConversionComponents;
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
VkSamplerYcbcrRange suggestedYcbcrRange;
VkChromaLocation suggestedXChromaOffset;
VkChromaLocation suggestedYChromaOffset;
} VkAndroidHardwareBufferFormatProperties2ANDROID;
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(
VkDevice device,
const struct AHardwareBuffer* buffer,
VkAndroidHardwareBufferPropertiesANDROID* pProperties);
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(
VkDevice device,
const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo,
struct AHardwareBuffer** pBuffer);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,833 +0,0 @@
#ifndef VULKAN_BETA_H_
#define VULKAN_BETA_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_video_queue 1
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR)
#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 2
#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue"
typedef enum VkQueryResultStatusKHR {
VK_QUERY_RESULT_STATUS_ERROR_KHR = -1,
VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0,
VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1,
VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkQueryResultStatusKHR;
typedef enum VkVideoCodecOperationFlagBitsKHR {
VK_VIDEO_CODEC_OPERATION_INVALID_BIT_KHR = 0,
#ifdef VK_ENABLE_BETA_EXTENSIONS
VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT = 0x00010000,
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT = 0x00020000,
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_EXT = 0x00000001,
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_EXT = 0x00000002,
#endif
VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoCodecOperationFlagBitsKHR;
typedef VkFlags VkVideoCodecOperationFlagsKHR;
typedef enum VkVideoChromaSubsamplingFlagBitsKHR {
VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_BIT_KHR = 0,
VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001,
VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002,
VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004,
VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008,
VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoChromaSubsamplingFlagBitsKHR;
typedef VkFlags VkVideoChromaSubsamplingFlagsKHR;
typedef enum VkVideoComponentBitDepthFlagBitsKHR {
VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0,
VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001,
VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004,
VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010,
VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoComponentBitDepthFlagBitsKHR;
typedef VkFlags VkVideoComponentBitDepthFlagsKHR;
typedef enum VkVideoCapabilityFlagBitsKHR {
VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001,
VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002,
VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoCapabilityFlagBitsKHR;
typedef VkFlags VkVideoCapabilityFlagsKHR;
typedef enum VkVideoSessionCreateFlagBitsKHR {
VK_VIDEO_SESSION_CREATE_DEFAULT_KHR = 0,
VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001,
VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoSessionCreateFlagBitsKHR;
typedef VkFlags VkVideoSessionCreateFlagsKHR;
typedef VkFlags VkVideoBeginCodingFlagsKHR;
typedef VkFlags VkVideoEndCodingFlagsKHR;
typedef enum VkVideoCodingControlFlagBitsKHR {
VK_VIDEO_CODING_CONTROL_DEFAULT_KHR = 0,
VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001,
VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoCodingControlFlagBitsKHR;
typedef VkFlags VkVideoCodingControlFlagsKHR;
typedef enum VkVideoCodingQualityPresetFlagBitsKHR {
VK_VIDEO_CODING_QUALITY_PRESET_NORMAL_BIT_KHR = 0x00000001,
VK_VIDEO_CODING_QUALITY_PRESET_POWER_BIT_KHR = 0x00000002,
VK_VIDEO_CODING_QUALITY_PRESET_QUALITY_BIT_KHR = 0x00000004,
VK_VIDEO_CODING_QUALITY_PRESET_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoCodingQualityPresetFlagBitsKHR;
typedef VkFlags VkVideoCodingQualityPresetFlagsKHR;
typedef struct VkVideoQueueFamilyProperties2KHR {
VkStructureType sType;
void* pNext;
VkVideoCodecOperationFlagsKHR videoCodecOperations;
} VkVideoQueueFamilyProperties2KHR;
typedef struct VkVideoProfileKHR {
VkStructureType sType;
void* pNext;
VkVideoCodecOperationFlagBitsKHR videoCodecOperation;
VkVideoChromaSubsamplingFlagsKHR chromaSubsampling;
VkVideoComponentBitDepthFlagsKHR lumaBitDepth;
VkVideoComponentBitDepthFlagsKHR chromaBitDepth;
} VkVideoProfileKHR;
typedef struct VkVideoProfilesKHR {
VkStructureType sType;
void* pNext;
uint32_t profileCount;
const VkVideoProfileKHR* pProfiles;
} VkVideoProfilesKHR;
typedef struct VkVideoCapabilitiesKHR {
VkStructureType sType;
void* pNext;
VkVideoCapabilityFlagsKHR capabilityFlags;
VkDeviceSize minBitstreamBufferOffsetAlignment;
VkDeviceSize minBitstreamBufferSizeAlignment;
VkExtent2D videoPictureExtentGranularity;
VkExtent2D minExtent;
VkExtent2D maxExtent;
uint32_t maxReferencePicturesSlotsCount;
uint32_t maxReferencePicturesActiveCount;
} VkVideoCapabilitiesKHR;
typedef struct VkPhysicalDeviceVideoFormatInfoKHR {
VkStructureType sType;
void* pNext;
VkImageUsageFlags imageUsage;
const VkVideoProfilesKHR* pVideoProfiles;
} VkPhysicalDeviceVideoFormatInfoKHR;
typedef struct VkVideoFormatPropertiesKHR {
VkStructureType sType;
void* pNext;
VkFormat format;
} VkVideoFormatPropertiesKHR;
typedef struct VkVideoPictureResourceKHR {
VkStructureType sType;
const void* pNext;
VkOffset2D codedOffset;
VkExtent2D codedExtent;
uint32_t baseArrayLayer;
VkImageView imageViewBinding;
} VkVideoPictureResourceKHR;
typedef struct VkVideoReferenceSlotKHR {
VkStructureType sType;
const void* pNext;
int8_t slotIndex;
const VkVideoPictureResourceKHR* pPictureResource;
} VkVideoReferenceSlotKHR;
typedef struct VkVideoGetMemoryPropertiesKHR {
VkStructureType sType;
const void* pNext;
uint32_t memoryBindIndex;
VkMemoryRequirements2* pMemoryRequirements;
} VkVideoGetMemoryPropertiesKHR;
typedef struct VkVideoBindMemoryKHR {
VkStructureType sType;
const void* pNext;
uint32_t memoryBindIndex;
VkDeviceMemory memory;
VkDeviceSize memoryOffset;
VkDeviceSize memorySize;
} VkVideoBindMemoryKHR;
typedef struct VkVideoSessionCreateInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t queueFamilyIndex;
VkVideoSessionCreateFlagsKHR flags;
const VkVideoProfileKHR* pVideoProfile;
VkFormat pictureFormat;
VkExtent2D maxCodedExtent;
VkFormat referencePicturesFormat;
uint32_t maxReferencePicturesSlotsCount;
uint32_t maxReferencePicturesActiveCount;
} VkVideoSessionCreateInfoKHR;
typedef struct VkVideoSessionParametersCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoSessionParametersKHR videoSessionParametersTemplate;
VkVideoSessionKHR videoSession;
} VkVideoSessionParametersCreateInfoKHR;
typedef struct VkVideoSessionParametersUpdateInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t updateSequenceCount;
} VkVideoSessionParametersUpdateInfoKHR;
typedef struct VkVideoBeginCodingInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoBeginCodingFlagsKHR flags;
VkVideoCodingQualityPresetFlagsKHR codecQualityPreset;
VkVideoSessionKHR videoSession;
VkVideoSessionParametersKHR videoSessionParameters;
uint32_t referenceSlotCount;
const VkVideoReferenceSlotKHR* pReferenceSlots;
} VkVideoBeginCodingInfoKHR;
typedef struct VkVideoEndCodingInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEndCodingFlagsKHR flags;
} VkVideoEndCodingInfoKHR;
typedef struct VkVideoCodingControlInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoCodingControlFlagsKHR flags;
} VkVideoCodingControlInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities);
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties);
typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession);
typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pVideoSessionMemoryRequirementsCount, VkVideoGetMemoryPropertiesKHR* pVideoSessionMemoryRequirements);
typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t videoSessionBindMemoryCount, const VkVideoBindMemoryKHR* pVideoSessionBindMemories);
typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters);
typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo);
typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo);
typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo);
typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR(
VkPhysicalDevice physicalDevice,
const VkVideoProfileKHR* pVideoProfile,
VkVideoCapabilitiesKHR* pCapabilities);
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo,
uint32_t* pVideoFormatPropertyCount,
VkVideoFormatPropertiesKHR* pVideoFormatProperties);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR(
VkDevice device,
const VkVideoSessionCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkVideoSessionKHR* pVideoSession);
VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR(
VkDevice device,
VkVideoSessionKHR videoSession,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR(
VkDevice device,
VkVideoSessionKHR videoSession,
uint32_t* pVideoSessionMemoryRequirementsCount,
VkVideoGetMemoryPropertiesKHR* pVideoSessionMemoryRequirements);
VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR(
VkDevice device,
VkVideoSessionKHR videoSession,
uint32_t videoSessionBindMemoryCount,
const VkVideoBindMemoryKHR* pVideoSessionBindMemories);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR(
VkDevice device,
const VkVideoSessionParametersCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkVideoSessionParametersKHR* pVideoSessionParameters);
VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR(
VkDevice device,
VkVideoSessionParametersKHR videoSessionParameters,
const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo);
VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR(
VkDevice device,
VkVideoSessionParametersKHR videoSessionParameters,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR(
VkCommandBuffer commandBuffer,
const VkVideoBeginCodingInfoKHR* pBeginInfo);
VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR(
VkCommandBuffer commandBuffer,
const VkVideoEndCodingInfoKHR* pEndCodingInfo);
VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR(
VkCommandBuffer commandBuffer,
const VkVideoCodingControlInfoKHR* pCodingControlInfo);
#endif
#define VK_KHR_video_decode_queue 1
#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 2
#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue"
typedef enum VkVideoDecodeFlagBitsKHR {
VK_VIDEO_DECODE_DEFAULT_KHR = 0,
VK_VIDEO_DECODE_RESERVED_0_BIT_KHR = 0x00000001,
VK_VIDEO_DECODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoDecodeFlagBitsKHR;
typedef VkFlags VkVideoDecodeFlagsKHR;
typedef struct VkVideoDecodeInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoDecodeFlagsKHR flags;
VkOffset2D codedOffset;
VkExtent2D codedExtent;
VkBuffer srcBuffer;
VkDeviceSize srcBufferOffset;
VkDeviceSize srcBufferRange;
VkVideoPictureResourceKHR dstPictureResource;
const VkVideoReferenceSlotKHR* pSetupReferenceSlot;
uint32_t referenceSlotCount;
const VkVideoReferenceSlotKHR* pReferenceSlots;
} VkVideoDecodeInfoKHR;
typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pFrameInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR(
VkCommandBuffer commandBuffer,
const VkVideoDecodeInfoKHR* pFrameInfo);
#endif
#define VK_KHR_portability_subset 1
#define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1
#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset"
typedef struct VkPhysicalDevicePortabilitySubsetFeaturesKHR {
VkStructureType sType;
void* pNext;
VkBool32 constantAlphaColorBlendFactors;
VkBool32 events;
VkBool32 imageViewFormatReinterpretation;
VkBool32 imageViewFormatSwizzle;
VkBool32 imageView2DOn3DImage;
VkBool32 multisampleArrayImage;
VkBool32 mutableComparisonSamplers;
VkBool32 pointPolygons;
VkBool32 samplerMipLodBias;
VkBool32 separateStencilMaskRef;
VkBool32 shaderSampleRateInterpolationFunctions;
VkBool32 tessellationIsolines;
VkBool32 tessellationPointMode;
VkBool32 triangleFans;
VkBool32 vertexAttributeAccessBeyondStride;
} VkPhysicalDevicePortabilitySubsetFeaturesKHR;
typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
VkStructureType sType;
void* pNext;
uint32_t minVertexInputBindingStrideAlignment;
} VkPhysicalDevicePortabilitySubsetPropertiesKHR;
#define VK_KHR_video_encode_queue 1
#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 3
#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue"
typedef enum VkVideoEncodeFlagBitsKHR {
VK_VIDEO_ENCODE_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_RESERVED_0_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeFlagBitsKHR;
typedef VkFlags VkVideoEncodeFlagsKHR;
typedef enum VkVideoEncodeRateControlFlagBitsKHR {
VK_VIDEO_ENCODE_RATE_CONTROL_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_RATE_CONTROL_RESET_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeRateControlFlagBitsKHR;
typedef VkFlags VkVideoEncodeRateControlFlagsKHR;
typedef enum VkVideoEncodeRateControlModeFlagBitsKHR {
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR = 0,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 1,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 2,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeRateControlModeFlagBitsKHR;
typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR;
typedef struct VkVideoEncodeInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeFlagsKHR flags;
uint32_t qualityLevel;
VkExtent2D codedExtent;
VkBuffer dstBitstreamBuffer;
VkDeviceSize dstBitstreamBufferOffset;
VkDeviceSize dstBitstreamBufferMaxRange;
VkVideoPictureResourceKHR srcPictureResource;
const VkVideoReferenceSlotKHR* pSetupReferenceSlot;
uint32_t referenceSlotCount;
const VkVideoReferenceSlotKHR* pReferenceSlots;
} VkVideoEncodeInfoKHR;
typedef struct VkVideoEncodeRateControlInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeRateControlFlagsKHR flags;
VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode;
uint32_t averageBitrate;
uint16_t peakToAverageBitrateRatio;
uint16_t frameRateNumerator;
uint16_t frameRateDenominator;
uint32_t virtualBufferSizeInMs;
} VkVideoEncodeRateControlInfoKHR;
typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR(
VkCommandBuffer commandBuffer,
const VkVideoEncodeInfoKHR* pEncodeInfo);
#endif
#define VK_EXT_video_encode_h264 1
#include "vk_video/vulkan_video_codec_h264std.h"
#include "vk_video/vulkan_video_codec_h264std_encode.h"
#define VK_EXT_VIDEO_ENCODE_H264_SPEC_VERSION 2
#define VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_EXT_video_encode_h264"
typedef enum VkVideoEncodeH264CapabilityFlagBitsEXT {
VK_VIDEO_ENCODE_H264_CAPABILITY_CABAC_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H264_CAPABILITY_CAVLC_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BI_PRED_IMPLICIT_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H264_CAPABILITY_TRANSFORM_8X8_BIT_EXT = 0x00000008,
VK_VIDEO_ENCODE_H264_CAPABILITY_CHROMA_QP_OFFSET_BIT_EXT = 0x00000010,
VK_VIDEO_ENCODE_H264_CAPABILITY_SECOND_CHROMA_QP_OFFSET_BIT_EXT = 0x00000020,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_DISABLED_BIT_EXT = 0x00000040,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_ENABLED_BIT_EXT = 0x00000080,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_PARTIAL_BIT_EXT = 0x00000100,
VK_VIDEO_ENCODE_H264_CAPABILITY_MULTIPLE_SLICE_PER_FRAME_BIT_EXT = 0x00000200,
VK_VIDEO_ENCODE_H264_CAPABILITY_EVENLY_DISTRIBUTED_SLICE_SIZE_BIT_EXT = 0x00000400,
VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264CapabilityFlagBitsEXT;
typedef VkFlags VkVideoEncodeH264CapabilityFlagsEXT;
typedef enum VkVideoEncodeH264InputModeFlagBitsEXT {
VK_VIDEO_ENCODE_H264_INPUT_MODE_FRAME_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H264_INPUT_MODE_SLICE_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H264_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264InputModeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH264InputModeFlagsEXT;
typedef enum VkVideoEncodeH264OutputModeFlagBitsEXT {
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_SLICE_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264OutputModeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH264OutputModeFlagsEXT;
typedef enum VkVideoEncodeH264CreateFlagBitsEXT {
VK_VIDEO_ENCODE_H264_CREATE_DEFAULT_EXT = 0,
VK_VIDEO_ENCODE_H264_CREATE_RESERVED_0_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H264_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264CreateFlagBitsEXT;
typedef VkFlags VkVideoEncodeH264CreateFlagsEXT;
typedef struct VkVideoEncodeH264CapabilitiesEXT {
VkStructureType sType;
const void* pNext;
VkVideoEncodeH264CapabilityFlagsEXT flags;
VkVideoEncodeH264InputModeFlagsEXT inputModeFlags;
VkVideoEncodeH264OutputModeFlagsEXT outputModeFlags;
VkExtent2D minPictureSizeInMbs;
VkExtent2D maxPictureSizeInMbs;
VkExtent2D inputImageDataAlignment;
uint8_t maxNumL0ReferenceForP;
uint8_t maxNumL0ReferenceForB;
uint8_t maxNumL1Reference;
uint8_t qualityLevelCount;
VkExtensionProperties stdExtensionVersion;
} VkVideoEncodeH264CapabilitiesEXT;
typedef struct VkVideoEncodeH264SessionCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkVideoEncodeH264CreateFlagsEXT flags;
VkExtent2D maxPictureSizeInMbs;
const VkExtensionProperties* pStdExtensionVersion;
} VkVideoEncodeH264SessionCreateInfoEXT;
typedef struct VkVideoEncodeH264SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t spsStdCount;
const StdVideoH264SequenceParameterSet* pSpsStd;
uint32_t ppsStdCount;
const StdVideoH264PictureParameterSet* pPpsStd;
} VkVideoEncodeH264SessionParametersAddInfoEXT;
typedef struct VkVideoEncodeH264SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxSpsStdCount;
uint32_t maxPpsStdCount;
const VkVideoEncodeH264SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoEncodeH264SessionParametersCreateInfoEXT;
typedef struct VkVideoEncodeH264DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
int8_t slotIndex;
const StdVideoEncodeH264PictureInfo* pStdPictureInfo;
} VkVideoEncodeH264DpbSlotInfoEXT;
typedef struct VkVideoEncodeH264NaluSliceEXT {
VkStructureType sType;
const void* pNext;
const StdVideoEncodeH264SliceHeader* pSliceHeaderStd;
uint32_t mbCount;
uint8_t refFinalList0EntryCount;
const VkVideoEncodeH264DpbSlotInfoEXT* pRefFinalList0Entries;
uint8_t refFinalList1EntryCount;
const VkVideoEncodeH264DpbSlotInfoEXT* pRefFinalList1Entries;
uint32_t precedingNaluBytes;
uint8_t minQp;
uint8_t maxQp;
} VkVideoEncodeH264NaluSliceEXT;
typedef struct VkVideoEncodeH264VclFrameInfoEXT {
VkStructureType sType;
const void* pNext;
uint8_t refDefaultFinalList0EntryCount;
const VkVideoEncodeH264DpbSlotInfoEXT* pRefDefaultFinalList0Entries;
uint8_t refDefaultFinalList1EntryCount;
const VkVideoEncodeH264DpbSlotInfoEXT* pRefDefaultFinalList1Entries;
uint32_t naluSliceEntryCount;
const VkVideoEncodeH264NaluSliceEXT* pNaluSliceEntries;
const VkVideoEncodeH264DpbSlotInfoEXT* pCurrentPictureInfo;
} VkVideoEncodeH264VclFrameInfoEXT;
typedef struct VkVideoEncodeH264EmitPictureParametersEXT {
VkStructureType sType;
const void* pNext;
uint8_t spsId;
VkBool32 emitSpsEnable;
uint32_t ppsIdEntryCount;
const uint8_t* ppsIdEntries;
} VkVideoEncodeH264EmitPictureParametersEXT;
typedef struct VkVideoEncodeH264ProfileEXT {
VkStructureType sType;
const void* pNext;
StdVideoH264ProfileIdc stdProfileIdc;
} VkVideoEncodeH264ProfileEXT;
#define VK_EXT_video_encode_h265 1
#include "vk_video/vulkan_video_codec_h265std.h"
#include "vk_video/vulkan_video_codec_h265std_encode.h"
#define VK_EXT_VIDEO_ENCODE_H265_SPEC_VERSION 2
#define VK_EXT_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_EXT_video_encode_h265"
typedef VkFlags VkVideoEncodeH265CapabilityFlagsEXT;
typedef enum VkVideoEncodeH265InputModeFlagBitsEXT {
VK_VIDEO_ENCODE_H265_INPUT_MODE_FRAME_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_INPUT_MODE_SLICE_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265InputModeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265InputModeFlagsEXT;
typedef enum VkVideoEncodeH265OutputModeFlagBitsEXT {
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_SLICE_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265OutputModeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265OutputModeFlagsEXT;
typedef VkFlags VkVideoEncodeH265CreateFlagsEXT;
typedef enum VkVideoEncodeH265CtbSizeFlagBitsEXT {
VK_VIDEO_ENCODE_H265_CTB_SIZE_8_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_EXT = 0x00000008,
VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265CtbSizeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265CtbSizeFlagsEXT;
typedef struct VkVideoEncodeH265CapabilitiesEXT {
VkStructureType sType;
const void* pNext;
VkVideoEncodeH265CapabilityFlagsEXT flags;
VkVideoEncodeH265InputModeFlagsEXT inputModeFlags;
VkVideoEncodeH265OutputModeFlagsEXT outputModeFlags;
VkVideoEncodeH265CtbSizeFlagsEXT ctbSizes;
VkExtent2D inputImageDataAlignment;
uint8_t maxNumL0ReferenceForP;
uint8_t maxNumL0ReferenceForB;
uint8_t maxNumL1Reference;
uint8_t maxNumSubLayers;
uint8_t qualityLevelCount;
VkExtensionProperties stdExtensionVersion;
} VkVideoEncodeH265CapabilitiesEXT;
typedef struct VkVideoEncodeH265SessionCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkVideoEncodeH265CreateFlagsEXT flags;
const VkExtensionProperties* pStdExtensionVersion;
} VkVideoEncodeH265SessionCreateInfoEXT;
typedef struct VkVideoEncodeH265SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t vpsStdCount;
const StdVideoH265VideoParameterSet* pVpsStd;
uint32_t spsStdCount;
const StdVideoH265SequenceParameterSet* pSpsStd;
uint32_t ppsStdCount;
const StdVideoH265PictureParameterSet* pPpsStd;
} VkVideoEncodeH265SessionParametersAddInfoEXT;
typedef struct VkVideoEncodeH265SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxVpsStdCount;
uint32_t maxSpsStdCount;
uint32_t maxPpsStdCount;
const VkVideoEncodeH265SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoEncodeH265SessionParametersCreateInfoEXT;
typedef struct VkVideoEncodeH265DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
int8_t slotIndex;
const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo;
} VkVideoEncodeH265DpbSlotInfoEXT;
typedef struct VkVideoEncodeH265ReferenceListsEXT {
VkStructureType sType;
const void* pNext;
uint8_t referenceList0EntryCount;
const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList0Entries;
uint8_t referenceList1EntryCount;
const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList1Entries;
const StdVideoEncodeH265ReferenceModifications* pReferenceModifications;
} VkVideoEncodeH265ReferenceListsEXT;
typedef struct VkVideoEncodeH265NaluSliceEXT {
VkStructureType sType;
const void* pNext;
uint32_t ctbCount;
const VkVideoEncodeH265ReferenceListsEXT* pReferenceFinalLists;
const StdVideoEncodeH265SliceHeader* pSliceHeaderStd;
} VkVideoEncodeH265NaluSliceEXT;
typedef struct VkVideoEncodeH265VclFrameInfoEXT {
VkStructureType sType;
const void* pNext;
const VkVideoEncodeH265ReferenceListsEXT* pReferenceFinalLists;
uint32_t naluSliceEntryCount;
const VkVideoEncodeH265NaluSliceEXT* pNaluSliceEntries;
const StdVideoEncodeH265PictureInfo* pCurrentPictureInfo;
} VkVideoEncodeH265VclFrameInfoEXT;
typedef struct VkVideoEncodeH265EmitPictureParametersEXT {
VkStructureType sType;
const void* pNext;
uint8_t vpsId;
uint8_t spsId;
VkBool32 emitVpsEnable;
VkBool32 emitSpsEnable;
uint32_t ppsIdEntryCount;
const uint8_t* ppsIdEntries;
} VkVideoEncodeH265EmitPictureParametersEXT;
typedef struct VkVideoEncodeH265ProfileEXT {
VkStructureType sType;
const void* pNext;
StdVideoH265ProfileIdc stdProfileIdc;
} VkVideoEncodeH265ProfileEXT;
#define VK_EXT_video_decode_h264 1
#include "vk_video/vulkan_video_codec_h264std_decode.h"
#define VK_EXT_VIDEO_DECODE_H264_SPEC_VERSION 3
#define VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME "VK_EXT_video_decode_h264"
typedef enum VkVideoDecodeH264PictureLayoutFlagBitsEXT {
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_EXT = 0,
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_EXT = 0x00000001,
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_EXT = 0x00000002,
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoDecodeH264PictureLayoutFlagBitsEXT;
typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsEXT;
typedef VkFlags VkVideoDecodeH264CreateFlagsEXT;
typedef struct VkVideoDecodeH264ProfileEXT {
VkStructureType sType;
const void* pNext;
StdVideoH264ProfileIdc stdProfileIdc;
VkVideoDecodeH264PictureLayoutFlagsEXT pictureLayout;
} VkVideoDecodeH264ProfileEXT;
typedef struct VkVideoDecodeH264CapabilitiesEXT {
VkStructureType sType;
void* pNext;
uint32_t maxLevel;
VkOffset2D fieldOffsetGranularity;
VkExtensionProperties stdExtensionVersion;
} VkVideoDecodeH264CapabilitiesEXT;
typedef struct VkVideoDecodeH264SessionCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkVideoDecodeH264CreateFlagsEXT flags;
const VkExtensionProperties* pStdExtensionVersion;
} VkVideoDecodeH264SessionCreateInfoEXT;
typedef struct VkVideoDecodeH264SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t spsStdCount;
const StdVideoH264SequenceParameterSet* pSpsStd;
uint32_t ppsStdCount;
const StdVideoH264PictureParameterSet* pPpsStd;
} VkVideoDecodeH264SessionParametersAddInfoEXT;
typedef struct VkVideoDecodeH264SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxSpsStdCount;
uint32_t maxPpsStdCount;
const VkVideoDecodeH264SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoDecodeH264SessionParametersCreateInfoEXT;
typedef struct VkVideoDecodeH264PictureInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoDecodeH264PictureInfo* pStdPictureInfo;
uint32_t slicesCount;
const uint32_t* pSlicesDataOffsets;
} VkVideoDecodeH264PictureInfoEXT;
typedef struct VkVideoDecodeH264MvcEXT {
VkStructureType sType;
const void* pNext;
const StdVideoDecodeH264Mvc* pStdMvc;
} VkVideoDecodeH264MvcEXT;
typedef struct VkVideoDecodeH264DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo;
} VkVideoDecodeH264DpbSlotInfoEXT;
#define VK_EXT_video_decode_h265 1
#include "vk_video/vulkan_video_codec_h265std_decode.h"
#define VK_EXT_VIDEO_DECODE_H265_SPEC_VERSION 1
#define VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME "VK_EXT_video_decode_h265"
typedef VkFlags VkVideoDecodeH265CreateFlagsEXT;
typedef struct VkVideoDecodeH265ProfileEXT {
VkStructureType sType;
const void* pNext;
StdVideoH265ProfileIdc stdProfileIdc;
} VkVideoDecodeH265ProfileEXT;
typedef struct VkVideoDecodeH265CapabilitiesEXT {
VkStructureType sType;
void* pNext;
uint32_t maxLevel;
VkExtensionProperties stdExtensionVersion;
} VkVideoDecodeH265CapabilitiesEXT;
typedef struct VkVideoDecodeH265SessionCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkVideoDecodeH265CreateFlagsEXT flags;
const VkExtensionProperties* pStdExtensionVersion;
} VkVideoDecodeH265SessionCreateInfoEXT;
typedef struct VkVideoDecodeH265SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t spsStdCount;
const StdVideoH265SequenceParameterSet* pSpsStd;
uint32_t ppsStdCount;
const StdVideoH265PictureParameterSet* pPpsStd;
} VkVideoDecodeH265SessionParametersAddInfoEXT;
typedef struct VkVideoDecodeH265SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxSpsStdCount;
uint32_t maxPpsStdCount;
const VkVideoDecodeH265SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoDecodeH265SessionParametersCreateInfoEXT;
typedef struct VkVideoDecodeH265PictureInfoEXT {
VkStructureType sType;
const void* pNext;
StdVideoDecodeH265PictureInfo* pStdPictureInfo;
uint32_t slicesCount;
const uint32_t* pSlicesDataOffsets;
} VkVideoDecodeH265PictureInfoEXT;
typedef struct VkVideoDecodeH265DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo;
} VkVideoDecodeH265DpbSlotInfoEXT;
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +0,0 @@
#ifndef VULKAN_DIRECTFB_H_
#define VULKAN_DIRECTFB_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_directfb_surface 1
#define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1
#define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface"
typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT;
typedef struct VkDirectFBSurfaceCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkDirectFBSurfaceCreateFlagsEXT flags;
IDirectFB* dfb;
IDirectFBSurface* surface;
} VkDirectFBSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(
VkInstance instance,
const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
IDirectFB* dfb);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,258 +0,0 @@
#ifndef VULKAN_FUCHSIA_H_
#define VULKAN_FUCHSIA_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_FUCHSIA_imagepipe_surface 1
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface"
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA;
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkImagePipeSurfaceCreateFlagsFUCHSIA flags;
zx_handle_t imagePipeHandle;
} VkImagePipeSurfaceCreateInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA(
VkInstance instance,
const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#define VK_FUCHSIA_external_memory 1
#define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1
#define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory"
typedef struct VkImportMemoryZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagBits handleType;
zx_handle_t handle;
} VkImportMemoryZirconHandleInfoFUCHSIA;
typedef struct VkMemoryZirconHandlePropertiesFUCHSIA {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
} VkMemoryZirconHandlePropertiesFUCHSIA;
typedef struct VkMemoryGetZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
VkExternalMemoryHandleTypeFlagBits handleType;
} VkMemoryGetZirconHandleInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandleFUCHSIA)(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t zirconHandle, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA(
VkDevice device,
const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
zx_handle_t* pZirconHandle);
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(
VkDevice device,
VkExternalMemoryHandleTypeFlagBits handleType,
zx_handle_t zirconHandle,
VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
#endif
#define VK_FUCHSIA_external_semaphore 1
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore"
typedef struct VkImportSemaphoreZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkSemaphoreImportFlags flags;
VkExternalSemaphoreHandleTypeFlagBits handleType;
zx_handle_t zirconHandle;
} VkImportSemaphoreZirconHandleInfoFUCHSIA;
typedef struct VkSemaphoreGetZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkExternalSemaphoreHandleTypeFlagBits handleType;
} VkSemaphoreGetZirconHandleInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA(
VkDevice device,
const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA(
VkDevice device,
const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
zx_handle_t* pZirconHandle);
#endif
#define VK_FUCHSIA_buffer_collection 1
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA)
#define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 2
#define VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME "VK_FUCHSIA_buffer_collection"
typedef VkFlags VkImageFormatConstraintsFlagsFUCHSIA;
typedef enum VkImageConstraintsInfoFlagBitsFUCHSIA {
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_RARELY_FUCHSIA = 0x00000001,
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_OFTEN_FUCHSIA = 0x00000002,
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_RARELY_FUCHSIA = 0x00000004,
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_OFTEN_FUCHSIA = 0x00000008,
VK_IMAGE_CONSTRAINTS_INFO_PROTECTED_OPTIONAL_FUCHSIA = 0x00000010,
VK_IMAGE_CONSTRAINTS_INFO_FLAG_BITS_MAX_ENUM_FUCHSIA = 0x7FFFFFFF
} VkImageConstraintsInfoFlagBitsFUCHSIA;
typedef VkFlags VkImageConstraintsInfoFlagsFUCHSIA;
typedef struct VkBufferCollectionCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
zx_handle_t collectionToken;
} VkBufferCollectionCreateInfoFUCHSIA;
typedef struct VkImportMemoryBufferCollectionFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkImportMemoryBufferCollectionFUCHSIA;
typedef struct VkBufferCollectionImageCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkBufferCollectionImageCreateInfoFUCHSIA;
typedef struct VkBufferCollectionConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t minBufferCount;
uint32_t maxBufferCount;
uint32_t minBufferCountForCamping;
uint32_t minBufferCountForDedicatedSlack;
uint32_t minBufferCountForSharedSlack;
} VkBufferCollectionConstraintsInfoFUCHSIA;
typedef struct VkBufferConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCreateInfo createInfo;
VkFormatFeatureFlags requiredFormatFeatures;
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
} VkBufferConstraintsInfoFUCHSIA;
typedef struct VkBufferCollectionBufferCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkBufferCollectionBufferCreateInfoFUCHSIA;
typedef struct VkSysmemColorSpaceFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t colorSpace;
} VkSysmemColorSpaceFUCHSIA;
typedef struct VkBufferCollectionPropertiesFUCHSIA {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
uint32_t bufferCount;
uint32_t createInfoIndex;
uint64_t sysmemPixelFormat;
VkFormatFeatureFlags formatFeatures;
VkSysmemColorSpaceFUCHSIA sysmemColorSpaceIndex;
VkComponentMapping samplerYcbcrConversionComponents;
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
VkSamplerYcbcrRange suggestedYcbcrRange;
VkChromaLocation suggestedXChromaOffset;
VkChromaLocation suggestedYChromaOffset;
} VkBufferCollectionPropertiesFUCHSIA;
typedef struct VkImageFormatConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkImageCreateInfo imageCreateInfo;
VkFormatFeatureFlags requiredFormatFeatures;
VkImageFormatConstraintsFlagsFUCHSIA flags;
uint64_t sysmemPixelFormat;
uint32_t colorSpaceCount;
const VkSysmemColorSpaceFUCHSIA* pColorSpaces;
} VkImageFormatConstraintsInfoFUCHSIA;
typedef struct VkImageConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t formatConstraintsCount;
const VkImageFormatConstraintsInfoFUCHSIA* pFormatConstraints;
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
VkImageConstraintsInfoFlagsFUCHSIA flags;
} VkImageConstraintsInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferCollectionFUCHSIA)(VkDevice device, const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferCollectionFUCHSIA* pCollection);
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
typedef void (VKAPI_PTR *PFN_vkDestroyBufferCollectionFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetBufferCollectionPropertiesFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, VkBufferCollectionPropertiesFUCHSIA* pProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferCollectionFUCHSIA(
VkDevice device,
const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkBufferCollectionFUCHSIA* pCollection);
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionImageConstraintsFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionBufferConstraintsFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
VKAPI_ATTR void VKAPI_CALL vkDestroyBufferCollectionFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferCollectionPropertiesFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
VkBufferCollectionPropertiesFUCHSIA* pProperties);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,58 +0,0 @@
#ifndef VULKAN_GGP_H_
#define VULKAN_GGP_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_GGP_stream_descriptor_surface 1
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface"
typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP;
typedef struct VkStreamDescriptorSurfaceCreateInfoGGP {
VkStructureType sType;
const void* pNext;
VkStreamDescriptorSurfaceCreateFlagsGGP flags;
GgpStreamDescriptor streamDescriptor;
} VkStreamDescriptorSurfaceCreateInfoGGP;
typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP(
VkInstance instance,
const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#define VK_GGP_frame_token 1
#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1
#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token"
typedef struct VkPresentFrameTokenGGP {
VkStructureType sType;
const void* pNext;
GgpFrameToken frameToken;
} VkPresentFrameTokenGGP;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
#ifndef VULKAN_IOS_H_
#define VULKAN_IOS_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_MVK_ios_surface 1
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 3
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
typedef struct VkIOSSurfaceCreateInfoMVK {
VkStructureType sType;
const void* pNext;
VkIOSSurfaceCreateFlagsMVK flags;
const void* pView;
} VkIOSSurfaceCreateInfoMVK;
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(
VkInstance instance,
const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
#ifndef VULKAN_MACOS_H_
#define VULKAN_MACOS_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_MVK_macos_surface 1
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef struct VkMacOSSurfaceCreateInfoMVK {
VkStructureType sType;
const void* pNext;
VkMacOSSurfaceCreateFlagsMVK flags;
const void* pView;
} VkMacOSSurfaceCreateInfoMVK;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(
VkInstance instance,
const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,54 +0,0 @@
#ifndef VULKAN_METAL_H_
#define VULKAN_METAL_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_metal_surface 1
#ifdef __OBJC__
@class CAMetalLayer;
#else
typedef void CAMetalLayer;
#endif
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
typedef struct VkMetalSurfaceCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags;
const CAMetalLayer* pLayer;
} VkMetalSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(
VkInstance instance,
const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
#ifndef VULKAN_VI_H_
#define VULKAN_VI_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_NN_vi_surface 1
#define VK_NN_VI_SURFACE_SPEC_VERSION 1
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
typedef VkFlags VkViSurfaceCreateFlagsNN;
typedef struct VkViSurfaceCreateInfoNN {
VkStructureType sType;
const void* pNext;
VkViSurfaceCreateFlagsNN flags;
void* window;
} VkViSurfaceCreateInfoNN;
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(
VkInstance instance,
const VkViSurfaceCreateInfoNN* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,54 +0,0 @@
#ifndef VULKAN_WAYLAND_H_
#define VULKAN_WAYLAND_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_wayland_surface 1
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
typedef struct VkWaylandSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkWaylandSurfaceCreateFlagsKHR flags;
struct wl_display* display;
struct wl_surface* surface;
} VkWaylandSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
VkInstance instance,
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
struct wl_display* display);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,315 +0,0 @@
#ifndef VULKAN_WIN32_H_
#define VULKAN_WIN32_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_win32_surface 1
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
typedef struct VkWin32SurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkWin32SurfaceCreateFlagsKHR flags;
HINSTANCE hinstance;
HWND hwnd;
} VkWin32SurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
VkInstance instance,
const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex);
#endif
#define VK_KHR_external_memory_win32 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportMemoryWin32HandleInfoKHR;
typedef struct VkExportMemoryWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportMemoryWin32HandleInfoKHR;
typedef struct VkMemoryWin32HandlePropertiesKHR {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
} VkMemoryWin32HandlePropertiesKHR;
typedef struct VkMemoryGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
VkExternalMemoryHandleTypeFlagBits handleType;
} VkMemoryGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR(
VkDevice device,
const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
VkDevice device,
VkExternalMemoryHandleTypeFlagBits handleType,
HANDLE handle,
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
#endif
#define VK_KHR_win32_keyed_mutex 1
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t acquireCount;
const VkDeviceMemory* pAcquireSyncs;
const uint64_t* pAcquireKeys;
const uint32_t* pAcquireTimeouts;
uint32_t releaseCount;
const VkDeviceMemory* pReleaseSyncs;
const uint64_t* pReleaseKeys;
} VkWin32KeyedMutexAcquireReleaseInfoKHR;
#define VK_KHR_external_semaphore_win32 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkSemaphoreImportFlags flags;
VkExternalSemaphoreHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportSemaphoreWin32HandleInfoKHR;
typedef struct VkExportSemaphoreWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportSemaphoreWin32HandleInfoKHR;
typedef struct VkD3D12FenceSubmitInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t waitSemaphoreValuesCount;
const uint64_t* pWaitSemaphoreValues;
uint32_t signalSemaphoreValuesCount;
const uint64_t* pSignalSemaphoreValues;
} VkD3D12FenceSubmitInfoKHR;
typedef struct VkSemaphoreGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkExternalSemaphoreHandleTypeFlagBits handleType;
} VkSemaphoreGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR(
VkDevice device,
const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
VkDevice device,
const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
#endif
#define VK_KHR_external_fence_win32 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
typedef struct VkImportFenceWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkFence fence;
VkFenceImportFlags flags;
VkExternalFenceHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportFenceWin32HandleInfoKHR;
typedef struct VkExportFenceWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportFenceWin32HandleInfoKHR;
typedef struct VkFenceGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkFence fence;
VkExternalFenceHandleTypeFlagBits handleType;
} VkFenceGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR(
VkDevice device,
const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
VkDevice device,
const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
#endif
#define VK_NV_external_memory_win32 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoNV {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagsNV handleType;
HANDLE handle;
} VkImportMemoryWin32HandleInfoNV;
typedef struct VkExportMemoryWin32HandleInfoNV {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
} VkExportMemoryWin32HandleInfoNV;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
VkDevice device,
VkDeviceMemory memory,
VkExternalMemoryHandleTypeFlagsNV handleType,
HANDLE* pHandle);
#endif
#define VK_NV_win32_keyed_mutex 1
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
VkStructureType sType;
const void* pNext;
uint32_t acquireCount;
const VkDeviceMemory* pAcquireSyncs;
const uint64_t* pAcquireKeys;
const uint32_t* pAcquireTimeoutMilliseconds;
uint32_t releaseCount;
const VkDeviceMemory* pReleaseSyncs;
const uint64_t* pReleaseKeys;
} VkWin32KeyedMutexAcquireReleaseInfoNV;
#define VK_EXT_full_screen_exclusive 1
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
typedef enum VkFullScreenExclusiveEXT {
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
VkStructureType sType;
void* pNext;
VkFullScreenExclusiveEXT fullScreenExclusive;
} VkSurfaceFullScreenExclusiveInfoEXT;
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
VkStructureType sType;
void* pNext;
VkBool32 fullScreenExclusiveSupported;
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
VkStructureType sType;
const void* pNext;
HMONITOR hmonitor;
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes);
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
VkDevice device,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
VkDeviceGroupPresentModeFlagsKHR* pModes);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,55 +0,0 @@
#ifndef VULKAN_XCB_H_
#define VULKAN_XCB_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_xcb_surface 1
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
typedef struct VkXcbSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkXcbSurfaceCreateFlagsKHR flags;
xcb_connection_t* connection;
xcb_window_t window;
} VkXcbSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
VkInstance instance,
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
xcb_connection_t* connection,
xcb_visualid_t visual_id);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,55 +0,0 @@
#ifndef VULKAN_XLIB_H_
#define VULKAN_XLIB_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_xlib_surface 1
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef struct VkXlibSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkXlibSurfaceCreateFlagsKHR flags;
Display* dpy;
Window window;
} VkXlibSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
VkInstance instance,
const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
Display* dpy,
VisualID visualID);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,45 +0,0 @@
#ifndef VULKAN_XLIB_XRANDR_H_
#define VULKAN_XLIB_XRANDR_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_acquire_xlib_display 1
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT(
VkPhysicalDevice physicalDevice,
Display* dpy,
VkDisplayKHR display);
VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT(
VkPhysicalDevice physicalDevice,
Display* dpy,
RROutput rrOutput,
VkDisplayKHR* pDisplay);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -15,6 +15,26 @@ steam_deck=0
# 1=enable avatar functionality
# default=0
enable_account_avatar=0
# 1=synchronize user stats/achievements with game servers as soon as possible instead of caching them until the next call to `Steam_RunCallbacks()`
# not recommended to enable this
# default=0
immediate_gameserver_stats=0
# 1=use the proper type of the server list (internet, friends, etc...) when requested by the game
# 0=always return the type of the server list as "LAN server"
# not recommended to enable this
# default=0
matchmaking_server_list_actual_type=0
# 1=grab the server details for match making using an actual server query
# 0=use the info from the local network messages shared between client/server
# not recommended to enable this, currently breaks some games
# default=0
matchmaking_server_details_via_source_query=0
# very basic crash logger/printer
# this is intended to debug some annoying scenarios, and best used with the debug build of the emu
# default=
crash_printer_location=./path/relative/to/dll/crashes.txt
[main::stats]
# 1=prevent `Steam_User_Stats::FindLeaderboard()` from always succeeding and creating the unknown leaderboard
# not recommended to enable this
# default=0
@ -39,24 +59,13 @@ stat_achievement_progress_functionality=1
# also has no impact on the functions which directly change stats, achievements, or achievements progress
# default=1
save_only_higher_stat_achievement_progress=1
# 1=synchronize user stats/achievements with game servers as soon as possible instead of caching them until the next call to `Steam_RunCallbacks()`
# not recommended to enable this
# default=0
immediate_gameserver_stats=0
# 1=use the proper type of the server list (internet, friends, etc...) when requested by the game
# 0=always return the type of the server list as "LAN server"
# not recommended to enable this
# default=0
matchmaking_server_list_actual_type=0
# 1=grab the server details for match making using an actual server query
# 0=use the info from the local network messages shared between client/server
# not recommended to enable this, currently breaks some games
# default=0
matchmaking_server_details_via_source_query=0
# very basic crash logger/printer
# this is intended to debug some annoying scenarios, and best used with the debug build of the emu
# default=
crash_printer_location=./path/relative/to/dll/crashes.txt
# the emulator loads the achievements icons is memory
# this is needed for APIs like `ISteamUserStats::GetAchievementIcon()`
# the loaded icon size is controlled by [overlay::appearance] -> Icon_Size, in configs.overlay.ini
# 1=load icons lazily when they are requested
# 0=load icons as soon as the interface ISteamUserStats is initialized
# default=1
lazy_load_achievements_icons=1
[main::connectivity]
# 1=prevent hooking OS networking APIs and allow any external requests

View File

@ -32,9 +32,9 @@ def generate_stats_achievements(
out['hidden'] = 0
for x in ach['display']:
value = ach['display'][x]
if x == 'name':
if f'{x}'.lower() == 'name':
x = 'displayName'
elif x == 'desc':
elif f'{x}'.lower() == 'desc':
x = 'description'
elif x == 'Hidden' or f'{x}'.lower() == 'hidden':
x = 'hidden'