bi: Add SDL renderer report
This includes information on the renderer's name, whether it's a software renderer or it's hardware accelerated, whether vsync is enabled, and the maximum texture size. (The other items in SDL_RendererInfo do not seem particularly relevant to us right now.)
This commit is contained in:
parent
1a430b7ecc
commit
daf126c75d
3 changed files with 50 additions and 0 deletions
|
@ -568,6 +568,12 @@ list_formatter video_settings_report_internal(const std::string& heading = "")
|
|||
fmt.insert("Final render target size", geometry_to_string(video::output_size()));
|
||||
fmt.insert("Screen refresh rate", std::to_string(video::current_refresh_rate()));
|
||||
|
||||
const auto& renderer_report = video::renderer_report();
|
||||
|
||||
for(const auto& info : renderer_report) {
|
||||
fmt.insert(info.first, info.second);
|
||||
}
|
||||
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
|
|
@ -828,4 +828,33 @@ void update_buffers(bool autoupdate)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> renderer_report()
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> res;
|
||||
SDL_Renderer* rnd;
|
||||
SDL_RendererInfo ri;
|
||||
|
||||
if(window && (rnd = *window) && SDL_GetRendererInfo(rnd, &ri) == 0) {
|
||||
std::string renderer_name = ri.name ? ri.name : "<unknown>";
|
||||
|
||||
if(ri.flags & SDL_RENDERER_SOFTWARE) {
|
||||
renderer_name += " (sw)";
|
||||
}
|
||||
|
||||
if(ri.flags & SDL_RENDERER_ACCELERATED) {
|
||||
renderer_name += " (hw)";
|
||||
}
|
||||
|
||||
std::string renderer_max = std::to_string(ri.max_texture_width) +
|
||||
'x' +
|
||||
std::to_string(ri.max_texture_height);
|
||||
|
||||
res.emplace_back("Renderer", renderer_name);
|
||||
res.emplace_back("Maximum texture size", renderer_max);
|
||||
res.emplace_back("VSync", ri.flags & SDL_RENDERER_PRESENTVSYNC ? "on" : "off");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace video
|
||||
|
|
|
@ -322,6 +322,21 @@ private:
|
|||
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(quit)
|
||||
};
|
||||
|
||||
|
||||
/***************/
|
||||
/* Diagnostics */
|
||||
/***************/
|
||||
|
||||
/**
|
||||
* Provides diagnostic information about the current renderer for the @a build_info API.
|
||||
*/
|
||||
std::vector<std::pair<std::string, std::string>> renderer_report();
|
||||
|
||||
|
||||
/**************************/
|
||||
/* Implementation details */
|
||||
/**************************/
|
||||
|
||||
/* This should only be used by draw.cpp for drawing, and texture.cpp for
|
||||
* texture creation. Try not to use it for anything else. */
|
||||
SDL_Renderer* get_renderer();
|
||||
|
|
Loading…
Add table
Reference in a new issue