Improve SDL debug info.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2020-11-14 09:29:21 +00:00
parent 4840b7b0ac
commit 78a7c98c3e
4 changed files with 50 additions and 14 deletions

View file

@ -6,6 +6,7 @@ add_executable(sa2
emulator.cpp
gamepad.cpp
sdirectsound.cpp
utils.cpp
)
find_package(Boost REQUIRED

View file

@ -15,6 +15,7 @@
#include "frontends/sa2/emulator.h"
#include "frontends/sa2/gamepad.h"
#include "frontends/sa2/sdirectsound.h"
#include "frontends/sa2/utils.h"
#include "StdAfx.h"
#include "Common.h"
@ -216,6 +217,8 @@ void run_sdl(int argc, const char * argv [])
const int sw = GetFrameBufferBorderlessWidth();
const int sh = GetFrameBufferBorderlessHeight();
std::cerr << std::fixed << std::setprecision(2);
std::shared_ptr<SDL_Window> win(SDL_CreateWindow(g_pAppTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sw, sh, SDL_WINDOW_SHOWN), SDL_DestroyWindow);
if (!win)
{
@ -230,25 +233,13 @@ void run_sdl(int argc, const char * argv [])
return;
}
SDL_RendererInfo info;
SDL_GetRendererInfo(ren.get(), &info);
std::cerr << "SDL Renderer: " << info.name << std::endl;
std::cerr << "Supported pixel formats:" << std::endl;
for (size_t i = 0; i < info.num_texture_formats; ++i)
{
std::cerr << SDL_GetPixelFormatName(info.texture_formats[i]) << std::endl;
}
std::cerr << std::fixed << std::setprecision(2);
const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
std::cerr << "Selected format: " << SDL_GetPixelFormatName(format) << std::endl;
printRendererInfo(std::cerr, ren, format);
std::shared_ptr<SDL_Texture> tex(SDL_CreateTexture(ren.get(), format, SDL_TEXTUREACCESS_STATIC, width, height), SDL_DestroyTexture);
const int fps = getRefreshRate();
std::cerr << "Refresh rate: " << fps << "Hz, " << 1000.0 / fps << "ms" << std::endl;
std::cerr << "Video refresh rate: " << fps << "Hz, " << 1000.0 / fps << "ms" << std::endl;
Emulator emulator(win, ren, tex);
Timer global;

View file

@ -0,0 +1,37 @@
#include "frontends/sa2/utils.h"
#include <ostream>
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat)
{
SDL_RendererInfo info;
SDL_GetRendererInfo(ren.get(), &info);
const size_t n = SDL_GetNumRenderDrivers();
os << "SDL: " << n << " drivers" << std::endl;
for(size_t i = 0; i < n; ++i)
{
SDL_RendererInfo info;
SDL_GetRenderDriverInfo(i, &info);
os << " " << i << ": " << info.name << std::endl;
}
if (SDL_GetRendererInfo(ren.get(), &info) == 0)
{
os << "Active driver: " << info.name << std::endl;
os << " SDL_RENDERER_SOFTWARE: " << ((info.flags & SDL_RENDERER_SOFTWARE) > 0) << std::endl;
os << " SDL_RENDERER_ACCELERATED: " << ((info.flags & SDL_RENDERER_ACCELERATED) > 0) << std::endl;
os << " SDL_RENDERER_PRESENTVSYNC: " << ((info.flags & SDL_RENDERER_PRESENTVSYNC) > 0) << std::endl;
os << " SDL_RENDERER_TARGETTEXTURE: " << ((info.flags & SDL_RENDERER_TARGETTEXTURE) > 0) << std::endl;
os << "Supported pixel formats:" << std::endl;
for (size_t i = 0; i < info.num_texture_formats; ++i)
{
os << " " << SDL_GetPixelFormatName(info.texture_formats[i]) << std::endl;
}
os << "Selected format: " << SDL_GetPixelFormatName(pixelFormat) << std::endl;
}
else
{
os << "No Renderinfo" << std::endl;
}
}

View file

@ -0,0 +1,7 @@
#pragma once
#include <SDL.h>
#include <memory>
#include <iosfwd>
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat);