Commit Graph

1195 Commits

Author SHA1 Message Date
Henrik Rydgård 898bf428ab Warning fixes 2026-04-06 15:34:55 -06:00
Henrik Rydgård 02a624075a Android: Make the "Auto" rotation mode override user rotation lock (SENSOR mode) 2026-03-31 10:43:27 -06:00
Henrik Rydgård 3083d37728 Add support for the raintegration menu rebuild event 2026-03-26 17:18:12 -06: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
Henrik Rydgård 836bbaf4c8 Merge pull request #21398 from chealy/fix-panfrost-gles3
OpenGL: Fix GLES3 detection for Mesa/Panfrost Mali drivers
2026-03-17 22:43:38 +01:00
Henrik Rydgård 30c717cb4a Merge pull request #21386 from chealy/gpu-shader-optimizations
GPU: Shader optimizations using inversesqrt and dead code removal
2026-03-17 22:31:06 +01:00
Henrik Rydgård 7e3079b035 VulkanRenderManager: Try to survive StopThreads being called twice (shouldn't happen, but...) 2026-03-13 10:33:00 +01: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
Chris Healy 9ed5dcdc27 GPU: Use inversesqrt for light distance and half-vector calculations
Replace length()/normalize() with inversesqrt() pattern for better
performance on mobile GPUs. The inversesqrt instruction is a single
hardware operation, while length() requires sqrt(dot()) and normalize()
requires inversesqrt internally plus a multiply.

Changes:
1. Light distance calculation:
   Before: distance = length(toLight); toLight /= distance;
   After:  distSq = dot(toLight, toLight);
           invDist = inversesqrt(distSq);
           distance = distSq * invDist;
           toLight *= invDist;

2. Specular half-vector normalization:
   Before: ldot = dot(normalize(toLight + vec3(0,0,1)), worldnormal);
   After:  halfVec = toLight + vec3(0,0,1);
           halfInvLen = inversesqrt(dot(halfVec, halfVec));
           ldot = dot(halfVec, worldnormal) * halfInvLen;

Also reuses distSq in attenuation calculation to avoid recomputing
distance*distance.

Offline shader compiler results (vertex shader with 4-light ubershader):

Mali (malioc):
  G31 (Bifrost): 44.90 -> 40.50 cycles (-9.8%)
  G52 (Bifrost): 14.97 -> 13.50 cycles (-9.8%)
  G310 (Valhall): 13.88 -> 12.88 cycles (-7.2%)
  G57 (Valhall):  7.60 ->  6.97 cycles (-8.3%)

PowerVR (Profiling Compilers):
  Series 8 GE8300: 322 -> 302 ALU cycles (-6.2%)
  Series 9 GM9445: 296 -> 280 ALU cycles (-5.4%)
  Series B BXM:    560 -> 540 instructions (-3.6%)

Signed-off-by: Chris Healy <cphealy@gmail.com>
2026-03-08 19:13:41 -07:00
Henrik Rydgård 5e6ec70280 Minor stuff 2026-03-01 12:09:43 +01:00
Henrik Rydgård 845f9f3d55 Add missing check to Vulkan init. Disable validation on android-x86-64
The latter is broken in the Android SDK emulator.
2026-02-27 23:57:50 +01:00
Henrik Rydgård 9097dd935a Somewhat improve the UI of the adhoc server list 2026-02-26 17:17:42 +01:00
Henrik Rydgård e50199ad0a Fix the gemini-written video player to actually work 2026-02-26 09:33:26 +01:00
Henrik Rydgård 5aeb38412d Fix another valgrind warning 2026-02-19 11:46:14 +01:00
Henrik Rydgård 5a5c7028b9 Assorted warning fixes and data initialization to please valgrind 2026-02-19 11:24:46 +01:00
Henrik Rydgård 5b33918ac4 VulkanBarrier: Change a hard assert to a debug assert, add fallback code. 2026-02-18 11:35:55 +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 facf6cb4b9 Vulkan: Try to survive VK_ERROR_SURFACE_LOST_KHR 2026-02-17 10:18:08 +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 00b28e28dc Mac/iOS: Avoid a vulkan warning about primitive restart 2026-02-10 10:41:52 +01:00
Henrik Rydgård eb234a1563 Finish the split. Greatly simplifies the render code in EmuScreen. 2026-02-08 10:46:16 +01:00
Henrik Rydgård 236a0acf71 Minor tweaks 2026-02-06 11:37:09 +01:00
Henrik Rydgård 841e4c8564 Add various checks trying to avoid various crashes found in Google Play crash reports. 2026-02-05 11:12:53 +01:00
Henrik Rydgård 0c3f6afeef Vulkan: Fix MSAA crash due to silly typo 2026-02-05 11:03:33 +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 68a8ba856f Warning fix, delete unused code 2026-01-24 10:43:48 +01:00
Henrik Rydgård 7bca84252e Vulkan: Add support for doing intra-buffer block copies with vkCmdCopyImage. 2026-01-22 13:47:41 +01:00
Henrik Rydgård f12472aede Give a name to an old mali GPU bug 2026-01-22 13:32:43 +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 502da9315d Add a sanity check after acquiring swapchain images 2026-01-01 14:48:35 +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
Stanislav c49081cb75 Add support run on LLVMpipe
Tested on few VM with Mesa LLVMpipe driver some games, no crashes
2025-11-15 17:32:58 +02:00
Henrik Rydgård 1efcaafd5a Add query for max texture size 2025-11-15 15:26:02 +01:00
Henrik Rydgård 28b9bc2fb3 Make more dev screens usable in portrait by converting them to TabbedDialogScreen 2025-10-23 15:33:09 +02:00
Henrik Rydgård 1c49ad7b29 Support screen rotation on iOS (unrestricted) 2025-10-22 15:13:21 +02: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 82bba691dd Unexpose the specialized Vulkan presentation modes for now 2025-10-20 19:53:21 +02:00
Henrik Rydgård b4f7635719 Vulkan: Check the available present modes right after initializing the surface 2025-10-20 19:52:24 +02:00
Henrik Rydgård 80bd32325c Move the present mode from the CreateInfo to InitSwapchain 2025-10-20 16:33:34 +02:00
Henrik Rydgård 6338832015 Vulkan: Smoothly recreate the swapchain using oldSwapchain on "resize" on Windows 2025-10-20 15:42:34 +02:00
Henrik Rydgård 176c55da25 Remove unused "interval" concept from presentation mode 2025-10-19 18:18:06 +02:00
Henrik Rydgård 60d25cb97d Change the UI rendering shaders to apply vertex color alpha properly 2025-10-16 11:07:05 +02:00