Commit Graph
405 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 86cd7c43e1 GLSLProgram: Cut it down to what's actually used, fix a shader leak
This is a leftover from the old "native" library. Its only users are the Win32 GE
debugger's preview windows, which call glsl_create_source/destroy/bind/unbind and
read four locations off the struct.

Everything else was dead: glsl_create was declared but never defined anywhere,
which made the entire file-loading and auto-reload half of glsl_recompile
unreachable (glsl_create_source always passes empty filenames), along with the
mtime fields, AutoCharArrayBuf and the VFS/stat includes. glsl_attrib_loc,
glsl_uniform_loc and glsl_get_program had no callers, and the active_programs set
was written and never read. The unused convenience locations cost a
glGetUniformLocation round trip each at link time.

The bug: the vertex shader was leaked when its own compile failed - the fragment
path right below it already deleted it correctly. Failed links leaked the program
object too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vd8ntC2brCUtCrDJMqLbs8
2026-08-28 23:27:28 +02:00
Henrik RydgårdandClaude Opus 5 2b9d556772 OpenGL: Drop the dead Intel dual-source check, fix the ES3 init fallback
The Intel workaround sscanf'd "Build %d.%d.%d.%d" against glGetString(GL_VERSION),
which reads like "4.5.0 - Build 26.20.100.7870" - sscanf literals have to match
from the start, so it never returned 4 and HasIntelDualSrcBug was never consulted.
It's been inert since it was written, and the drivers it targeted are long gone.
Removing it orphaned the two helpers, so those go too.

Separately, when gl3stubInit() fails we left ver[0] at 3 while clearing GLES3.
Extension enumeration keys off the version, not the flag, so it went on to call
glGetStringi - one of the very entry points whose absence makes gl3stubInit()
fail. Drop back to 2.0 on that path, like the branch above it already does, and
null-check what glGetStringi hands back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vd8ntC2brCUtCrDJMqLbs8
2026-08-28 23:27:21 +02:00
Henrik Rydgård be922eca62 Make OpenGL render thread shutdown more robust. 2026-08-04 16:44:55 +02:00
Henrik Rydgård b6d7c18f39 Try to eliminate a race condition 2026-08-03 23:09:07 +02:00
Henrik Rydgård 10a5d2f810 OpenGL: Improve checks for fragment shader float precision.
Fixes #22001 (although there may be other artifacts).
2026-07-30 10:03:15 +02:00
Henrik Rydgård b46566adc2 Logging improvements 2026-07-29 14:42:24 +02:00
Henrik Rydgård f8ccc78e31 OpenGL on Android: Don't try to detect version too early 2026-07-29 14:40:01 +02:00
Henrik Rydgård 1649d2fcae Also merge away the iOS GL graphics context 2026-07-26 20:16:24 +02:00
Henrik Rydgård ccff34b431 Reuse the AndroidJavaGLContext as the new generic OpenGLGraphicsContext 2026-07-26 20:07:14 +02:00
Henrik Rydgård 568ffe5a05 Use the common EmuThread implementation on iOS as well 2026-07-26 12:04:51 +02:00
Henrik Rydgård 57e6bafb62 Remove largely ineffective and nearly not functional "low memory mode". Unlikely to save us. 2026-07-16 15:28:40 +02:00
Henrik Rydgård ebc564a465 Centralize handling of another GPU flag 2026-06-27 13:50:03 +02:00
Henrik Rydgård f60e27a9b7 Just some refactoring of the GPUStatistics struct, and more use of StringWriter 2026-05-29 14:40:31 +02:00
Herman Semenoff b1d140e8e7 OpenGL/Vulkan/UI: duplicate fields move to separate const reference var 2026-05-27 12:26:12 +02:00
Henrik Rydgård dd125b2e4d Delete obsolete (and non-working) support for GPUs without non-pow-2 textures. 2026-05-24 14:15:34 +02:00
Henrik Rydgård 2a745bc98d Apple buildfix 2026-05-21 16:36:32 +02:00
Henrik Rydgård 4a420c95c2 Remove some redundant device caps, show clip/cull/depth-clamp in system info 2026-05-21 11:59:26 +02:00
Henrik Rydgård 28166cb35d Add "allocation slack" to our pushbuffers. Fixes a memory overwrite bug
Reported by Joseph on Discord.

Sometimes, things could align perfectly so allocations happend exactly
at the end of a pushbuffer. At the same time, we allow our vertex decoder to write an extra few
bytes if it needs to for speed. Unfortunately I missed this interaction,
resulting in some uncommon crashes that were especially common with
heavy-geometry things like modified GTA LCS with PS2 assets, for
example.

The problem was reported with Vulkan, but our OpenGL backend had the
same issue too.
2026-05-13 15:55:34 +02:00
Henrik Rydgård a78e0e76de Disable the GPU profiler for OpenGL. Also restrict to in-game. 2026-05-06 00:27:20 +02:00
Chris Healy 49bfbd49cd OpenGL: Integrate GLProfiler into render pass execution
Integrates the GLProfiler into GLQueueRunner to provide GPU timestamp
profiling for OpenGL render passes, similar to the Vulkan backend.

Profiled operations:
- RenderPass (with tag name for identification)
- Copy operations
- Blit operations
- Readback operations
- ReadbackImage operations

The profiler is initialized in CreateDeviceObjects() and shutdown in
DestroyDeviceObjects(). Timing results are logged each frame when the
GPU profile debug overlay is enabled.

Signed-off-by: Chris Healy <cphealy@gmail.com>
2026-03-18 09:52:43 -07:00
Chris Healy ba59170b0b OpenGL: Add GLProfiler for GPU timestamp profiling
Adds a new GLProfiler class for GPU-side timestamp profiling, similar to
VulkanProfiler. Uses GL_EXT_disjoint_timer_query (GLES) or GL_ARB_timer_query
(desktop GL).

Features:
- Scoped Begin()/End() profiling with printf-style naming
- Automatic GPU disjoint detection (frequency changes invalidate results)
- Millisecond timing output via INFO_LOG
- Pre-allocated query pool (1024 queries max per frame)
- Nested scope support with indented output

Signed-off-by: Chris Healy <cphealy@gmail.com>
2026-03-18 09:52:43 -07:00
Chris Healy 856e6ed49b OpenGL: Add timer query extension detection
Add detection for GL_EXT_disjoint_timer_query (OpenGL ES) and
GL_ARB_timer_query (desktop GL) extensions. These extensions provide
GPU timestamp queries for profiling render pass durations.

Also adds function pointer declarations for glQueryCounter,
glGetQueryObjecti64v, and glGetQueryObjectui64v.

Signed-off-by: Chris Healy <cphealy@gmail.com>
2026-03-18 09:52:42 -07:00
Chris Healy 7ea1260ef0 OpenGL: Fix GLES3 detection for Mesa/Panfrost Mali drivers
The original code checked for "Mali" in GL_RENDERER and disabled GLES3
for all Mali GPUs, which was a workaround for bugs in ARM's proprietary
Mali driver. However, Mesa/Panfrost (open-source Mali driver) does not
have these bugs and should be allowed to use GLES3.

This patch:
- Adds GPU_VENDOR_MESA for identifying Mesa drivers via GL_VENDOR
- Changes the GLES3 ban to only apply when GL_VENDOR="ARM" (proprietary)
- Allows Mesa/Panfrost Mali GPUs to use GLES3 features

Expected behavior:
- ARM proprietary driver (GL_VENDOR="ARM"): GLES3 disabled (preserved)
- Mesa/Panfrost (GL_VENDOR="Mesa"): GLES3 enabled
- Other Mesa drivers: Unaffected

Related issues: #4078, #15413

Signed-off-by: Chris Healy <cphealy@gmail.com>
2026-03-08 21:41:20 -07:00
Henrik Rydgård 5e6ec70280 Minor stuff 2026-03-01 12:09:43 +01:00
Henrik Rydgård 48c6faa762 ImDebugger: Fix texture viewer in OpenGL mode and partially in D3D11 mode (swapped colors) 2026-02-17 18:19:23 +01:00
Henrik Rydgård 1cc2b7233a Fix some minor visual UI issues
See #21223
2026-02-15 19:57:56 +01:00
Henrik Rydgård 2c0bdcf678 InstallZipScreen improvements, small cleanup 2026-02-10 11:34:59 +01:00
Henrik Rydgård d6ebfed432 Fix some bugs and warnings from a pass of static analysis 2026-01-29 17:41:54 +01:00
Henrik Rydgård 64461329e7 More minor fixes and cleanups 2026-01-02 14:20:20 +01:00
Henrik Rydgård 02d621c0f6 OpenGL ES: Correct check for 3D texture support. 2026-01-02 14:20:20 +01:00
Henrik Rydgård 1ac218960f OpenGL / FramebufferManager: Improve asserts for raster blits 2026-01-01 14:15:37 +01:00
Henrik Rydgård c999367471 Fix crash in DrawPixels in "skip framebuffer effects" mode 2025-12-15 17:18:17 +01:00
Henrik Rydgård 1efcaafd5a Add query for max texture size 2025-11-15 15:26:02 +01:00
Henrik Rydgård 7cc4a0f3a3 Add more accurate sleep function (well, not more accurate on Windows unfortunately) 2025-10-21 12:11:23 +02:00
Henrik Rydgård d265336912 Warning fix 2025-10-21 11:16:19 +02:00
Henrik Rydgård c5b1f2ffb0 OpenGL: Call SwapInterval properly 2025-10-20 22:45:42 +02:00
Henrik Rydgård 042cf87248 Rework the present mode settings, refactor. 2025-10-20 21:28:38 +02:00
Henrik Rydgård 176c55da25 Remove unused "interval" concept from presentation mode 2025-10-19 18:18:06 +02:00
Henrik Rydgård d43b1d4618 String function cleanup 2025-08-31 14:45:41 +02:00
Henrik Rydgård 9218fe9b59 Rework the shutdown logic in the OpenGL backend. Eliminated race conditions. 2025-08-31 10:57:06 +02:00
Henrik Rydgård b813a6c30f Logging improvements 2025-08-31 00:59:51 +02:00
Henrik Rydgård 539abb8d4f More minor cleanups 2025-08-31 00:59:51 +02:00
Henrik Rydgård 00a13bfb14 Fix static analysis warnings (pointless move, empty instead of size) 2025-08-31 00:59:51 +02:00
Henrik Rydgård 6cfea96e58 Remove D3D9 support, to make future changes easier 2025-06-10 15:07:16 +02:00
Henrik Rydgård dbe6ec80a0 Fix some bad "for (auto x : y)" usage 2025-04-29 16:46:14 +02:00
Henrik Rydgård 41b77bf1ae More log cleanup 2025-04-14 22:27:51 +02:00
Henrik Rydgård 4dd3621fa0 Remove some unnecessary <algorithm> includes. 2024-12-18 17:04:27 +01:00
Henrik Rydgård 111d0c872d Global rename of FBChannel to Aspect, also make it a class enum 2024-12-15 22:24:05 +01:00
Henrik Rydgård 6763c13f88 ImGui: Finish implementing pipeline switching for all backends 2024-11-27 01:19:05 +01:00
Henrik Rydgård 09779e0f44 ImGui drawing: Allow varying the pipeline when binding textures 2024-11-26 19:59:09 +01:00