Files
sgiannop 9efe1c6471 perf/diag: VBO double-buffering + in-game timing overlay
VBO double-buffering (New3D):
- Allocate 2x RAM region [ROM_VERTS][RAM_slot0][RAM_slot1]; toggle
  m_ramSlot each frame so CPU writes slot N while GPU reads slot N-1.
- GL_MAP_UNSYNCHRONIZED_BIT added to UpdateDynamic: safe with double-
  buffer, eliminates driver GPU sync stall on GLES3/TBDR.
- vboOffset for RAM models adjusted to include slot offset.
- ramVerts guard: clamp upload to MAX_RAM_VERTS to prevent overflow
  at high PPC frequencies (66MHz+ generates more geometry per frame).

Shader (R3DShaderTriangles.h):
- Fragment 'in' varyings annotated with explicit 'highp' to match vertex
  shader output precision. Required for GLES3 precision consistency;
  also prepares for future mediump fragment optimisation.
- GetR3DFragment() helper added to GLSLVersion for when mediump fragment
  path is properly implemented (not yet wired in).

In-game timing overlay (libretroGui):
- Libretro_InitOverlay / Libretro_ShutdownOverlay / Libretro_DrawTimingOverlay
  added; renders ImGui window with PPC/Render/GPU/Sync/Sound/Total (ms).
- GPU timer via GL_EXT_disjoint_timer_query if available (guarded against
  NULL function pointer); shows 0.0ms when extension absent.
- Overlay initialised in context_reset, destroyed in context_destroy.

Model3.cpp: remove leftover DumpTimings() debug call from RunMainBoardFrame.
2026-06-21 14:52:15 +03:00

111 lines
2.9 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "GLSLVersion.h"
namespace Graphics {
bool GLSLVersion::IsGLES()
{
#if defined(ANDROID) || defined(CORE_GLES) || defined(HAVE_GLES)
return true;
#else
return false;
#endif
}
std::string GLSLVersion::BuildPrecisionString(int flags)
{
std::string precision;
if (flags & (int)PrecisionFlags::FLOAT)
precision += "precision highp float;\n";
if (flags & (int)PrecisionFlags::INT)
precision += "precision highp int;\n";
if (flags & (int)PrecisionFlags::SAMPLER_UINT)
precision += "precision highp usampler2D;\n";
if (flags & (int)PrecisionFlags::SAMPLER_INT)
precision += "precision highp isampler2D;\n";
if (flags & (int)PrecisionFlags::ANDROID_DEFINE)
precision += "#define ANDROID 1\n";
return precision;
}
std::string GLSLVersion::Get(int flags)
{
if (IsGLES()) {
std::string version = "#version 300 es\n";
version += BuildPrecisionString(flags);
return version;
} else {
return "#version 410 core\n";
}
}
std::string GLSLVersion::Get2D()
{
// 2D rendering needs float and int precision
return Get((int)PrecisionFlags::FLOAT | (int)PrecisionFlags::INT);
}
std::string GLSLVersion::Get3D()
{
// Standard 3D rendering needs float precision
return Get((int)PrecisionFlags::FLOAT);
}
std::string GLSLVersion::GetPostProcess()
{
// Post-processing (SuperAA, etc.) needs float precision
return Get((int)PrecisionFlags::FLOAT);
}
std::string GLSLVersion::Get3DAdvanced()
{
// Advanced 3D (R3DShader) needs float and sampler precision
return Get(
(int)PrecisionFlags::FLOAT |
(int)PrecisionFlags::SAMPLER_UINT |
(int)PrecisionFlags::SAMPLER_INT |
(int)PrecisionFlags::ANDROID_DEFINE
);
}
std::string GLSLVersion::GetR3D(bool useQuads)
{
if (IsGLES()) {
// GLES always uses version 300 es with advanced precision
return Get3DAdvanced();
} else {
// Desktop: use 450 core if quads, otherwise 410 core
return useQuads ? "#version 450 core\n" : "#version 410 core\n";
}
}
std::string GLSLVersion::GetR3DFragment(bool useQuads)
{
if (IsGLES()) {
// Fragment shaders use mediump float for 2× throughput on mobile GPUs.
// Colors, textures and lighting are all fine with 16-bit precision.
// Samplers and ints keep highp so data texture lookups stay accurate.
return Get(
(int)PrecisionFlags::INT |
(int)PrecisionFlags::SAMPLER_UINT |
(int)PrecisionFlags::SAMPLER_INT |
(int)PrecisionFlags::ANDROID_DEFINE
// NOTE: FLOAT is intentionally omitted → default mediump float
) + "precision mediump float;\n";
} else {
return useQuads ? "#version 450 core\n" : "#version 410 core\n";
}
}
std::string GLSLVersion::GetImGui()
{
if (IsGLES()) {
return "#version 300 es";
} else {
return "#version 410";
}
}
} // namespace Graphics