Graphics Backend & GPU Selection
Everything that decides which graphics API and which physical GPU your application runs on happens before the first Gorilla3D component exists. Gorilla.Context.Backend is the unit that controls it — backend selection, forcing the discrete GPU on hybrid laptops, enumerating the GPUs of the system and detecting the hybrid copy-back scenario that silently costs a large part of your frame rate.
Unit: Gorilla.Context.Backend
Platforms: Windows (full), Linux (full), WSL2 (reduced), Android / macOS (backend selection + display enumeration), iOS (backend selection only)
Important:
Gorilla.Context.Backendmust be the first unit in theusesclause of your.dprand every setting described here must be applied beforeApplication.Initialize. The vendor drivers evaluate the settings while their DLL / shared object is being loaded — afterwards they are ignored without any error message.
Table of Contents
- Overview
- Selecting the Graphics Backend
- Forcing the High-Performance GPU
- Hybrid Graphics and the Copy-Back Problem
- Detecting Copy-Back at Runtime
- Enumerating the GPUs of the System
- Diagnostics Report
- Enumerating the Displays
- How the Detection Works
- Recommended Startup Pattern
- API Reference
- Troubleshooting
Overview
The unit covers four independent jobs:
| Job | Entry point |
|---|---|
| Choose OpenGL or Vulkan | GorillaGraphicsBackend |
| Ask the system for the discrete GPU | ForceToUseNVIDIAorAMDGPU |
| Enumerate all GPUs without a graphics context | GetGpuAdapters |
| Detect / report the hybrid copy-back scenario | GetHybridGraphicsState, CheckHybridGraphicsState, GetGpuDiagnosticsReport |
None of these functions needs an OpenGL, Vulkan or Direct3D context. They can — and should — run as the very first statements of your process.
Calling convention: All functions are class methods of
TGorillaSystemand are called without an instance, e.g.TGorillaSystem.ForceToUseNVIDIAorAMDGPU(). For readability, the text below names them without the class prefix; the code examples show the full call.
Selecting the Graphics Backend
program MyProject;
uses
Gorilla.Context.Backend, // must be listed FIRST
System.StartUpCopy,
FMX.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
{$IF Defined(MSWINDOWS) and Defined(CPUX64)}
GorillaGraphicsBackend := gbVulkan;
{$ENDIF}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| Value | Meaning |
|---|---|
gbDefault |
Platform default — OpenGL / OpenGL ES (default value) |
gbOpenGL |
Explicitly request OpenGL / OpenGL ES |
gbVulkan |
Explicitly request Vulkan (Windows x64, Linux, Android) |
Two inline helpers let you branch on the active backend anywhere in your code:
if TGorillaSystem.IsVulkanBackend() then
// Vulkan specific path
else if TGorillaSystem.IsOpenGLBackend() then
// OpenGL / GLES path (TRUE for gbDefault and gbOpenGL)
If the requested backend is not available on the target machine, the framework falls back to OpenGL. See Windows for the Vulkan feature matrix.
Forcing the High-Performance GPU
On a hybrid system (integrated GPU + discrete GPU) the operating system decides which GPU a process renders on. ForceToUseNVIDIAorAMDGPU requests the discrete one:
begin
TGorillaSystem.ForceToUseNVIDIAorAMDGPU(); // as early as possible!
Application.Initialize;
...
Or fully automatic — define GORILLA_FORCE_HIGHPERFORMANCE_GPU for your project and the unit calls it in its own initialization section, which is the earliest possible moment inside a Delphi process (before the .dpr body runs):
{$DEFINE GORILLA_FORCE_HIGHPERFORMANCE_GPU}
What happens on Windows
NVIDIA Optimus and AMD PowerXpress look for two exported symbols in the process image and switch to the discrete GPU when they are non-zero:
NvOptimusEnablement := 1;
AmdPowerXpressRequestHighPerformance := 1;
Why a runtime assignment and not a constant? Delphi cannot export an initialized variable (compiler error
E2276), so unlike in C the value cannot be baked into the export table of the image at link time. It has to be written at runtime, and it only takes effect as long as the vendor OpenGL / Vulkan driver DLL has not been loaded yet. That is exactly why the call has to be the first thing your process does.
Limitation: This selects the rendering GPU. It cannot change which GPU drives the display — that is what causes the copy-back described below.
What happens on Linux
Linux has no equivalent of the exported symbol. The GPU is selected through environment variables that libglvnd / Mesa / the Vulkan loader evaluate while they load their vendor library. ForceToUseNVIDIAorAMDGPU picks the discrete GPU (a discrete vendor that is not the one driving the console) and sets:
| Driver | Variables set |
|---|---|
Proprietary NVIDIA (nvidia) |
__NV_PRIME_RENDER_OFFLOAD=1, __GLX_VENDOR_LIBRARY_NAME=nvidia, __VK_LAYER_NV_optimus=NVIDIA_only |
Mesa stack (amdgpu, radeon, nouveau) |
DRI_PRIME=pci-0000_01_00_0 (unambiguous PCI form instead of the legacy DRI_PRIME=1), MESA_VK_DEVICE_SELECT=<vendor>:<device> |
| WSL2 / WSLg | MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA / AMD |
Nothing is done on a single-GPU system.
Your environment always wins. All variables are written with
overwrite = 0, so an explicit setting made by the user or by a launch script (DRI_PRIME=1 ./mygame) is never overwritten by Gorilla3D.
Inside WSL2 there is no PCI GPU enumeration at all — /sys/class/drm/card0 is a dxgkrnl node without vendor, device or boot_vga attributes and without any connector. Gorilla3D detects WSL, determines the vendor from the user-mode driver mounted below /usr/lib/wsl/lib (libnvidia-ml.so.1, nvidia-smi, libamdhip64.so, libhsa-runtime64.so) and sets MESA_D3D12_DEFAULT_ADAPTER_NAME accordingly. This replaces the manual assignment of TGorillaContextLinux.AUTO_SELECT_GPU. If the vendor cannot be determined, nothing is guessed. See Linux.
Hybrid Graphics and the Copy-Back Problem
This is the single most common cause of "my 3D application runs at 20 FPS on a gaming laptop with an RTX GPU".
On a typical hybrid laptop the panel is physically wired to the integrated GPU, while your application renders on the discrete GPU:
+------------------+ PCIe copy per frame +-------------------+
| Discrete GPU | ----------------------> | Integrated GPU | --> Panel
| renders frame | (the "copy back") | scans out |
+------------------+ +-------------------+
Every single finished frame has to be copied from the video memory of the rendering GPU back over the PCIe bus into the memory of the display GPU before it can be shown. The effects are:
- A hard frame rate ceiling that does not improve when you lower the rendering quality.
- Cost that scales with resolution — a 4K panel copies four times the data of a 1080p panel.
- Stalls: the render GPU frequently has to wait for the copy of the previous frame to finish.
- GPU utilisation figures that look fine while the frame rate does not.
ForceToUseNVIDIAorAMDGPU cannot fix this. It makes the discrete GPU render — which is what you want — but the display path stays where the hardware put it. There are only three real remedies, and all of them live outside of the application:
- MUX switch / "Discrete GPU only" mode in the manufacturer's control software (Lenovo Vantage, MSI Center, ASUS Armoury Crate, …) or in the BIOS. This rewires the panel to the discrete GPU and removes the copy completely.
- Move the window to a monitor that the discrete GPU scans out itself. On many laptops the HDMI / DisplayPort outputs are wired directly to the dGPU.
TGpuDisplayInfo.RenderAdapterHasOutputstells you whether such a monitor is already connected. - Connect an external monitor to the video output of the discrete GPU, if the machine has one.
That is why Gorilla3D does not try to work around the situation — it detects and reports it, so you and your users know what is going on instead of blaming the framework.
Detecting Copy-Back at Runtime
The ready-made check
uses Gorilla.Context.Backend;
begin
TGorillaSystem.ForceToUseNVIDIAorAMDGPU();
// Shows a warning dialog when render GPU <> display GPU
TGorillaSystem.CheckHybridGraphicsState();
// ... or raise an exception instead of showing a dialog:
// TGorillaSystem.CheckHybridGraphicsState(True);
Application.Initialize;
CheckHybridGraphicsState does nothing at all when there is no copy-back. Otherwise it builds a message naming both GPUs, explaining the per-frame copy and listing the remedies above (including the "move the window" hint when the render GPU already drives a monitor) and then:
| Platform | Output |
|---|---|
| Windows | MessageBoxW with a warning icon — deliberately not FMX, so the unit stays usable as the very first unit of the .dpr |
| Linux | Written to stderr. A stock Delphi Linux target has no FMX (FmxLinux is a separate product), so pass AThrowException = True or evaluate GetHybridGraphicsState yourself when you want a GUI message |
| Other | ShowMessage |
Evaluating the state yourself
var
LInfo : TGpuDisplayInfo;
begin
LInfo := TGorillaSystem.GetHybridGraphicsState();
if LInfo.IsHybridCopyBack then
begin
Log('Rendering on : ' + LInfo.RenderAdapterName);
Log('Displayed by : ' + LInfo.DisplayAdapterName);
if LInfo.RenderAdapterHasOutputs then
Log('Move the window to the monitor attached to the dedicated GPU.');
end;
end;
TGpuDisplayInfo
| Field | Description |
|---|---|
RenderAdapterName |
GPU that will be used for 3D rendering |
DisplayAdapterName |
GPU that scans out the primary monitor |
IsHybridCopyBack |
TRUE when both are different — every frame is copied between them |
Detected |
TRUE only when both GPUs could be identified reliably. When FALSE, IsHybridCopyBack is always FALSE and the name fields may be empty or best-effort guesses |
RenderAdapterLuid |
LUID (Windows) / PCI slot id (Linux) of the rendering GPU, 0 when unknown |
DisplayAdapterLuid |
The same for the GPU driving the primary monitor |
RenderAdapterVendorId |
PCI vendor id of the rendering GPU, compare against GORILLA_GPU_VENDOR_* |
RenderAdapterHasOutputs |
TRUE when the rendering GPU scans out at least one desktop display. Combined with IsHybridCopyBack = TRUE this means the user can escape the copy-back by moving the window to that monitor |
HardwareAdapterCount |
Number of non-software adapters found in the system |
No false positives. A copy-back is only reported when both GPUs were identified by their LUID and both LUIDs differ. Adapter name strings are never compared — that would produce false positives as soon as one name is unknown or reported differently by two APIs.
Enumerating the GPUs of the System
var
LAdapters : TGorillaGpuAdapterInfoArray;
I : Integer;
begin
if TGorillaSystem.GetGpuAdapters(LAdapters) then
for I := 0 to High(LAdapters) do
if not LAdapters[I].IsSoftware then
Log(Format('%s (%s), %d MB VRAM, %d displays',
[LAdapters[I].Name,
LAdapters[I].VendorName(),
LAdapters[I].DedicatedVideoMemory div (1024 * 1024),
LAdapters[I].AttachedDisplayCount]));
end;
GetGpuAdapters returns FALSE when the operating system offers no context-independent enumeration (everything except Windows and native Linux — on Android the renderer name is only known after the context has been created).
TGorillaGpuAdapterInfo
| Field | Description |
|---|---|
Name |
Human readable adapter name, e.g. NVIDIA GeForce RTX 4070 |
VendorId / DeviceId |
PCI ids — compare VendorId against the GORILLA_GPU_VENDOR_* constants |
DedicatedVideoMemory |
On-board video memory in bytes |
Luid |
Locally unique id, stable while the system runs (on Linux derived from the PCI slot) |
IsSoftware |
TRUE for software rasterizers (WARP / "Microsoft Basic Render Driver") |
OutputCount |
Number of outputs DXGI reports. Informational only — see the warning below |
AttachedDisplayCount |
Number of desktop displays this GPU really scans out |
DrivesPrimaryMonitor |
TRUE when this adapter really scans out the primary monitor / the console |
DriverName |
Kernel driver bound to the GPU (nvidia, nouveau, amdgpu, i915) — Linux only |
PciSlot |
PCI slot as 0000:01:00.0 — Linux only, needed to build a DRI_PRIME selector |
VendorName() |
Short vendor name derived from VendorId, hex fallback for unknown vendors |
IsDiscreteVendor() |
TRUE for vendors that usually ship discrete GPUs (NVIDIA, AMD) |
Do not use
OutputCountto decide who owns the display. On hybrid systems DXGI happily attributes the panel to the discrete GPU although the integrated GPU owns the display path. UseAttachedDisplayCount/DrivesPrimaryMonitorinstead.
Vendor id constants
| Constant | Value |
|---|---|
GORILLA_GPU_VENDOR_NVIDIA |
$10DE |
GORILLA_GPU_VENDOR_AMD |
$1002 |
GORILLA_GPU_VENDOR_INTEL |
$8086 |
GORILLA_GPU_VENDOR_MICROSOFT |
$1414 (software adapters like WARP) |
GORILLA_GPU_VENDOR_QUALCOMM |
$5143 |
GORILLA_GPU_VENDOR_ARM |
$13B5 |
Diagnostics Report
GetGpuDiagnosticsReport builds a multiline, human readable report of all GPUs and the detected render / display constellation. Write it into your log file and ask for it in bug reports — it answers most "why is it slow on my machine" questions immediately:
Log(TGorillaSystem.GetGpuDiagnosticsReport());
GPU adapters:
[0] NVIDIA GeForce RTX 4070 Laptop GPU (NVIDIA, device 0x28a0), displays 0, VRAM 8188 MB (dxgi outputs 1)
[1] Intel(R) Iris(R) Xe Graphics (Intel, device 0x46a6), displays 1, VRAM 128 MB, primary monitor
[2] Microsoft Basic Render Driver (Microsoft, device 0x008c), displays 0, software
Render adapter : NVIDIA GeForce RTX 4070 Laptop GPU
Display adapter: Intel(R) Iris(R) Xe Graphics
Detected : True
Hybrid copyback: True
The example above is the classic copy-back constellation: DXGI claims the NVIDIA GPU owns a display (dxgi outputs 1), the real display path says the Intel GPU does — and the Intel GPU is right.
Enumerating the Displays
TGorillaSystem.GetDisplays lists every display attached to the desktop — name, position in the virtual desktop, work area, current and supported video modes, physical size, UI scale factor and the GPU that scans it out. Like the GPU enumeration it needs no graphics context and may be called before Application.Initialize, e.g. to pick a fullscreen resolution or the monitor to open the main window on.
var LDisplays : TGorillaDisplayInfoArray;
LDisplay : TGorillaDisplayInfo;
LMode : TGorillaDisplayMode;
begin
if TGorillaSystem.GetDisplays(LDisplays) then
for LDisplay in LDisplays do
begin
Log(LDisplay.ToString()); // "DELL U2720Q [\\.\DISPLAY2] 3840 x 2160, 32 bit, 60.00 Hz"
for LMode in LDisplay.Modes do
Log(' ' + LMode.ToString());
end;
// only the primary display, without the (slower) mode list
if TGorillaSystem.GetPrimaryDisplay(LDisplay, false) then
Log(Format('%.1f" at %.0f ppi', [LDisplay.DiagonalInches(), LDisplay.PixelsPerInch()]));
end;
Modes is sorted from the largest resolution and highest refresh rate downwards and contains no duplicates — Modes[0] usually is the native mode of the panel. Pass AWithModes = False when you only need the current mode; enumerating all modes is the slowest part of the query on Windows.
TGorillaDisplayInfo
| Field | Description |
|---|---|
DeviceName |
OS name of the output. Windows: \\.\DISPLAY1, Linux: connector eDP-1 / DP-2, macOS: CGDirectDisplayID, Android: display id |
FriendlyName |
Monitor name, e.g. DELL U2720Q — from the EDID where possible |
AdapterName / AdapterId |
GPU that really scans out the display. AdapterId equals TGorillaGpuAdapterInfo.Luid of the matching GetGpuAdapters entry (Windows, Linux) |
Bounds |
Position and size in the virtual desktop |
WorkArea |
Bounds without task bar, dock, menu bar or system bars |
IsPrimary |
Primary / main display |
CurrentMode |
Width, Height, BitsPerPixel, RefreshRate of the active mode |
Modes |
All supported modes (empty with AWithModes = False) |
WidthMm / HeightMm |
Physical image size, 0 when unknown |
ScaleFactor |
UI scale of the OS, 1.0 = 100 % |
DiagonalInches() / PixelsPerInch() |
Derived from the physical size, 0 when unknown |
Platform matrix
| Windows | Linux (X11 / XWayland) | Linux (no X server) | macOS | Android | |
|---|---|---|---|---|---|
| Source | GDI + EDID (registry) + WDDM | XRandR + EDID | DRM connectors in /sys/class/drm |
CoreGraphics + NSScreen | DisplayManager |
Bounds |
pixels, virtual desktop | pixels, virtual desktop | unknown position, starts at 0,0 | points, global display space | pixels, own space per display |
WorkArea |
yes | = Bounds |
= Bounds |
yes | yes (without system bars) |
CurrentMode |
yes | yes | preferred mode of the monitor | yes (physical pixels) | yes (current orientation) |
Modes |
yes | yes | EDID timings + resolutions | yes (desktop usable) | yes (natural orientation) |
| Refresh rate | integer Hz | exact | EDID timings only | 0 on some built-in panels | yes |
FriendlyName |
EDID | EDID | EDID | localizedName (10.15+) |
Display.getName |
| Physical size | EDID | EDID, else XRandR | EDID | CGDisplayScreenSize |
from xdpi / ydpi |
ScaleFactor |
GetDpiForMonitor |
Xft.dpi (global) |
1.0 | backingScaleFactor |
density |
AdapterName |
yes (WDDM path) | yes (PCI slot of the card) | yes | — | — |
iOS returns FALSE.
Windows:
GetDpiForMonitorreports 96 dpi for DPI unaware processes, soScaleFactorstays 1.0 there. FMX applications are per-monitor DPI aware through their default manifest; plain console tools are not.Linux: XRandR is loaded dynamically (
libX11.so.6,libXrandr.so.2) — no link dependency, and the fallback to sysfs happens automatically under pure Wayland or on the console. The EDID is taken from the XRandREDIDoutput property and otherwise from the matching DRM connector; the match is done by connector name and, for the NVIDIA / AMD DDX drivers with their own naming (DP-0,DisplayPort-0), by identical EDID bytes. While enumerating, a no-op Xlib error handler is installed, because the default one terminates the process when a monitor is unplugged between two requests.macOS: call from the main thread (NSScreen).
GetDisplayDiagnosticsReport() formats all of this for log files:
Displays:
[0] Lenovo DisplayHDR (\\.\DISPLAY1), primary
bounds 0,0 2560x1600, work area 0,0 2560x1552, scale 100%
current 2560 x 1600, 32 bit, 240.00 Hz, 52 modes
physical 345 x 215 mm, 16.0", 188 ppi
adapter Intel(R) Iris(R) Xe Graphics
On a hybrid laptop the adapter line is a quick cross-check of the copy-back report: the panel is scanned out by the integrated GPU.
How the Detection Works
Windows
| Question | Source |
|---|---|
| Which GPUs exist? | IDXGIFactory1.EnumAdapters1 — needs only dxgi.dll, no device |
| Which GPU renders? | IDXGIFactory6.EnumAdapterByGpuPreference with DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE — the same GPU the NVIDIA / AMD driver selects for a high-performance process |
| Which GPU scans out a display? | The WDDM kernel thunk D3DKMTOpenAdapterFromGdiDisplayName (gdi32.dll), which maps a GDI display name like \\.\DISPLAY1 to the LUID of the adapter that really owns that display path |
The two obvious alternatives lie on hybrid systems and are therefore not used:
EnumDisplayDevicesreturns the GDI adapter string, which stays on the integrated GPU even after a MUX switch.IDXGIAdapter.EnumOutputsattributes the panel to the discrete GPU although the integrated GPU owns the display path (measured on an RTX 4070 Laptop + Iris Xe: DXGI says NVIDIA ownsDISPLAY1, the WDDM display path says Intel — and Intel is right).
IDXGIFactory5 / IDXGIFactory6 are not declared by the Delphi RTL (which stops at Winapi.DXGI1_4), so the unit declares them itself. When DXGI 1.6 is unavailable (Windows 10 before build 1803) the render adapter is picked heuristically: a discrete vendor first, then the largest amount of dedicated video memory. When the WDDM thunk is unavailable, the DXGI output attribution is kept as a best-effort fallback.
Linux
The enumeration walks /sys/class/drm/:
card*entries without a dash are GPUs, entries with a dash (card0-eDP-1) are connectors.device/vendor,device/deviceanddevice/ueventdeliver the PCI ids,DRIVERandPCI_SLOT_NAME. The PCI slot is converted into a 64-bit id — Linux has no LUID, but the slot is just as unique and just as stable while the system runs.device/boot_vga = 1marks the GPU the firmware brought the console up on — the integrated GPU on a hybrid laptop, and the analogue to the primary monitor on Windows.- A connector whose
statusisconnectedincreasesAttachedDisplayCountof its card. - The proprietary NVIDIA driver publishes no product name through sysfs — it is read from
/proc/driver/nvidia/gpus/<pci-slot>/informationinstead.
Attributes are read with a plain TFileStream loop on purpose: sysfs reports a size of one page (4096 bytes) for every attribute while the actual read returns far fewer bytes, so anything relying on Stream.Size (TStringList.LoadFromFile, TFile.ReadAllText) raises. A missing attribute is the normal case and never travels as an exception, so the debugger does not stop on every probe.
Other platforms
GetGpuAdapters returns FALSE and GetHybridGraphicsState reports Detected = False. On Android the renderer name is only known after the OpenGL or Vulkan context has been created. Backend selection via GorillaGraphicsBackend still works everywhere.
Recommended Startup Pattern
program MyProject;
uses
Gorilla.Context.Backend, // FIRST unit - before FMX, before everything else
System.StartUpCopy,
System.SysUtils,
System.IOUtils,
FMX.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
procedure WriteGpuLog();
begin
try
TFile.WriteAllText(
TPath.Combine(TPath.GetDocumentsPath(), 'gpu-report.txt'),
TGorillaSystem.GetGpuDiagnosticsReport());
except
// never let diagnostics kill the startup
end;
end;
begin
// 1) Request the discrete GPU - must happen before any driver DLL is loaded
TGorillaSystem.ForceToUseNVIDIAorAMDGPU();
// 2) Pick the graphics backend
{$IF Defined(MSWINDOWS) and Defined(CPUX64)}
GorillaGraphicsBackend := gbVulkan;
{$ENDIF}
// 3) Persist the constellation for support cases
WriteGpuLog();
// 4) Warn the user about an unavoidable per-frame copy
TGorillaSystem.CheckHybridGraphicsState();
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Order matters. Steps 1 and 2 have to run before
Application.Initializeand before the first Gorilla3D component is created. Steps 3 and 4 only read the system state and may be moved anywhere — for example behind a "Diagnostics" menu item of your application.
API Reference
| Function / Variable | Description |
|---|---|
GorillaGraphicsBackend : TGorillaGraphicsBackend |
Global backend selector (gbDefault, gbOpenGL, gbVulkan). Default gbDefault |
TGorillaSystem.IsVulkanBackend() : Boolean |
TRUE when the Vulkan backend is selected |
TGorillaSystem.IsOpenGLBackend() : Boolean |
TRUE for gbDefault and gbOpenGL |
TGorillaSystem.ForceToUseNVIDIAorAMDGPU() |
Requests the discrete GPU. Windows: exported Optimus / PowerXpress symbols. Linux: PRIME / Mesa environment variables |
TGorillaSystem.GetGpuAdapters(out AAdapters) : Boolean |
Enumerates all GPUs including the displays they really scan out. No graphics context needed. FALSE when unsupported |
TGorillaSystem.GetActiveDisplayAdapterName() : String |
First adapter name the OS reports as attached to the desktop (Windows) |
TGorillaSystem.GetActiveRenderAdapterName() : String |
Name of the GPU that will be used for rendering, empty when it cannot be determined |
TGorillaSystem.GetHybridGraphicsState() : TGpuDisplayInfo |
Full render / display constellation including IsHybridCopyBack |
TGorillaSystem.GetGpuDiagnosticsReport() : String |
Multiline report of all GPUs and the detected constellation, for logs and bug reports |
TGorillaSystem.CheckHybridGraphicsState(AThrowException = False) |
Warns about a copy-back scenario — dialog by default, exception when True |
GetDisplays(out ADisplays; AWithModes = True) : Boolean |
Enumerates all desktop displays with modes, physical size, scale and scanning GPU. No graphics context needed. FALSE on iOS |
GetPrimaryDisplay(out ADisplay; AWithModes = True) : Boolean |
The primary display, or the first one when none is marked primary |
GetDisplayDiagnosticsReport() : String |
Multiline report of all displays, for logs and bug reports |
NvOptimusEnablement, AmdPowerXpressRequestHighPerformance |
Exported symbols evaluated by the NVIDIA / AMD drivers (Windows). Assigned by ForceToUseNVIDIAorAMDGPU |
GORILLA_FORCE_HIGHPERFORMANCE_GPU |
Conditional define — calls ForceToUseNVIDIAorAMDGPU in the initialization section of the unit |
Troubleshooting
| Symptom | Cause / Remedy |
|---|---|
| Low frame rate on a gaming laptop, independent of the quality settings | Classic copy-back. Run GetGpuDiagnosticsReport() — when it says Hybrid copyback: True, enable the MUX switch / "Discrete GPU only" mode or move the window to a monitor attached to the dedicated GPU |
ForceToUseNVIDIAorAMDGPU has no effect |
Called too late — the vendor driver DLL was already loaded. Move it to the very first line of the .dpr or use GORILLA_FORCE_HIGHPERFORMANCE_GPU |
| Application still renders on the integrated GPU | A per-application override in the NVIDIA / AMD control panel or in the Windows graphics settings takes precedence over the exported symbols |
Detected = False, all names empty |
No context-independent enumeration on this platform (Android, macOS, iOS), or DXGI / sysfs delivered nothing. A copy-back is then never reported |
Hybrid copyback: False although two GPUs are installed |
Both LUIDs are identical or one GPU could not be identified — the check is deliberately conservative and never guesses |
WSL2: GPU adapters: not enumerable inside WSL |
Expected. The GPU is reached through the Mesa d3d12 driver. Set MESA_D3D12_DEFAULT_ADAPTER_NAME (done automatically when the vendor driver is detected below /usr/lib/wsl/lib) |
Linux: the wrong GPU is used although DRI_PRIME is set |
Intentional — an explicitly set environment variable is never overwritten by Gorilla3D |
GetDisplays: ScaleFactor is 1.0 on a scaled Windows desktop |
The process is not DPI aware (e.g. a console tool without manifest) — Windows then virtualizes the DPI to 96 |
Linux: all displays start at 0,0 and WorkArea = Bounds |
No X server reachable ($DISPLAY unset, pure Wayland without XWayland) — the sysfs fallback cannot know the desktop layout |
macOS: RefreshRate = 0 |
Many built-in panels do not publish their refresh rate through CoreGraphics |
Related Topics
- Gorilla.Context.Backend Unit Reference — complete API of this unit
- Viewport — the component that creates the graphics context
- Renderer — what happens inside a frame
- Windows Platform — Vulkan feature matrix
- Linux Platform — Mesa, PRIME and WSL2 setup
- Requirements — supported graphics APIs