Skip to content

Linux port of Nabla Examples - #297

Open
raydelto wants to merge 7 commits into
Devsh-Graphics-Programming:masterfrom
raydelto:linux-port
Open

raydelto wants to merge 7 commits into
Devsh-Graphics-Programming:masterfrom
raydelto:linux-port

Conversation

@raydelto

@raydelto raydelto commented Oct 8, 2026

Copy link
Copy Markdown

Description

Companion to the Nabla Linux port PR (Devsh-Graphics-Programming/Nabla#1101). The examples' common code and a few examples assume Win32 or MSVC. This PR makes the common code build on Linux (Clang 20, X11/XCB), and the tested examples (01, 02, 08, 21, 23) run there. 09 builds and opens a window but waits for mouse input, which the XCB backend doesn't provide yet. The Win32 window-manager and surface selection is preserved. Three shared changes also apply on Windows: the depth-layout initialization, the 09 clamp expression and test 23's loop bound. Windows/MSVC has not been built.

  • common/.../SimpleWindowedApplication.hpp: create IWindowManagerXcb on Linux and log an error when there is no X server (DISPLAY unset). Other platforms log "No window manager is implemented for this platform yet!" and return false instead of hitting #error.
  • common/.../MonoWindowApplication.hpp and 08_HelloSwapchain: create CSurfaceVulkanXcb on Linux, CSurfaceVulkanWin32 on Windows.
  • common/.../CSwapchainFramebuffersAndDepth.hpp: the depth-stencil attachment layout is a depth/stencil pair, so it is now set through its .depth member. Initializing the pair from a single enum doesn't compile with Clang.
  • 01_HelloCoreSystemAsset: use CColoredStdoutLoggerANSI when not on Windows.
  • 09_GeometryCreator: core::clamp(gcIndex, 0ull, size()-1) mixes unsigned long long with size_t (unsigned long on LP64) and doesn't deduce. Use size_t(0).
  • 23_Arithmetic2UnitTest (all platforms): with requiredSubgroupSize, Vulkan caps the workgroup at requiredSubgroupSize * maxComputeWorkgroupSubgroups (VUID-VkPipelineShaderStageCreateInfo-pNext-02756). The loop went up to maxComputeWorkGroupInvocations for every subgroup size. On Intel (64 subgroups max, SIMD8) that made a 1024-invocation pipeline, a validation error and a GPU hang. The loop now stops at min(maxComputeWorkGroupInvocations, subgroupSize*maxComputeWorkgroupSubgroups). NVIDIA (subgroup 32 only) is unaffected.

Testing

These results come from the recorded runs of the merged fork PRs and their reviews, not one combined re-run. Ubuntu 24.04, Clang 20.1.2 + LLD, Release, LunarG SDK 1.4.363.0 with the Khronos validation layer, on an RTX 3050 (NVIDIA 580.178.04) and an Intel UHD TGL GT1 (Mesa 25.2.8), together with the Nabla Linux port branch.

Example RTX 3050 Intel UHD
01_HelloCoreSystemAsset pass pass
02_HelloCompute pass pass
21_LRUCacheUnitTest pass pass
23_Arithmetic2UnitTest pass GPU hang fixed by this PR; the unmodified run then crashes (exit 139) inside Mesa ANV's shader compiler on one pipeline (driver bug, details in the Nabla PR)
08_HelloSwapchain (X11) renders; resize, minimize, maximize, close; 0 validation messages same

01 and 21 are CPU/VFS tests, so passing with each ICD selected doesn't show GPU execution. 09_GeometryCreator builds but waits for a mouse, and XCB input is not implemented yet. Not tested: Windows/MSVC, GCC, Wayland, and any example not listed above.

TODO list:

  • Build these changes on Windows/MSVC and check that they preserve the intended behaviour. The one intended change is the corrected workgroup cap in 23, for devices whose maxComputeWorkgroupSubgroups limits the workgroup size. The depth-layout initialization and the 09 clamp also change there.
  • Merge before the Nabla PR, then bump examples_tests in Nabla to the merge commit and restore the Devsh submodule URL.
  • Decide whether to include the Linux port of 70_FLIPFluids here or in a follow-up PR (still under review on the fork).

raydelto and others added 7 commits October 7, 2026 16:41
- Win32 window manager and surface only on Windows; other platforms log
  that no window manager exists yet instead of #error (XCB is NAB-9 scope).
- Depth attachment ref: brace-init SDepthStencilLayout explicitly (Clang
  doesn't elide braces in designated initializers).
- 01_HelloCoreSystemAsset: ANSI stdout logger off Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a required subgroup size the workgroup can't exceed
requiredSubgroupSize*maxComputeWorkgroupSubgroups. Intel ANV (TGL GT1)
reports 64, so SIMD8 x 1024 was invalid usage and hung the GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NAB-7: Build headless examples on Linux, cap test 23 workgroup size
SimpleWindowedApplication and MonoWindowApplication create an IWindowManagerXcb
and a CSurfaceVulkanXcb on Linux; 08_HelloSwapchain picks the surface class
per platform. Windows paths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
size_t is unsigned long on Linux, so clamping against 0ull failed to deduce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NAB-9: XCB windows and Vulkan surfaces in the windowed examples on Linux
* NAB-13: Run 70_FLIPFluids on Linux

- Create an XCB surface on Linux, as the other windowed examples do.
- Drop the local CSwapchainFramebuffersAndDepth and CEventCallback, which
  clash with the nbl::examples versions now in common, and fix two
  narrowing/explicit-constructor errors Clang reports.
- Don't block the frame loop waiting for an input device. Without one the
  camera orbits the tank and the drop restarts every 12 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* NAB-16: Acquire FLIPFluids input without blocking

Checking for a device and then calling the blocking getDefault left a gap:
if the last mouse or keyboard disconnected in between, the frame waited
forever instead of falling back to autoplay.

InputSystem gains tryGetDefault{,Mouse,Keyboard}, which check for a device
and bind the reader under the same lock and return false when none is
connected. getDefault keeps blocking and shares the selection code.

Adds the NBL_EXAMPLES_INPUT_SYSTEM CTest (no GPU or display needed), which
covers absent and connected devices, disconnect after and during
acquisition, and the blocking getDefault still waiting for a device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant