3224 Commits

Author SHA1 Message Date
Campbell Barton
3198b336e1 GHOST/Wayland: only disable VSync when using the OpenGL backend
Also add a reference to SDL's bug report and some notes.
2025-08-14 01:13:30 +00:00
Miguel Pozo
7169a39b79 Fix: GPU Tests on Windows
Use RAII for `GHOST_WindowClass`.

For the main Blender executable, only one `GHOST_System` is ever
created. But when running tests, this can happen multiple times (eg,
GPUOpenGLTest and GPUOpenGLWorkaroundsTest).
This results in `GHOST_SystemWin32` trying to register
`GHOST_WindowClass` multiple times, so `RegisterClassW` fails with
`ERROR_CLASS_ALREADY_EXISTS`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144231
2025-08-12 15:20:01 +02:00
Clément Foucault
cae6c6d81a GPU: Remove Shader Draw Parameter workaround
With 5.0 we start requiring this extension for GL and VK.
All of our target hardware supports it with up to date
drivers.

Some old drivers were disabling this extension because of
buggy behavior. We simply drop support for them in 5.0.

This allows us to remove a lot of code and the last
shader create info override done at startup. This will
unlock more refactoring of the shader create info into
static classes to reduce binary size and other benefits.

## TODO:
- [x] Remove checks for ARB_shader_draw_parameters
- [x] Remove checks for ARB_clip_control
- [x] Check for the extension on startup for OpenGL
- [x] Check for the extension on startup for Vulkan
- [x] ~~Add user facing popup message about minimum
      requirements not being met.~~ Done using the same
      popup as old hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/142334
2025-08-12 14:04:41 +02:00
Jeroen Bakker
42c3f35780 Vulkan: Swap to system memory for device local memory
This PR will swap device local memory to system ram. It relies on
VK_EXT_external_memory and VK_EXT_pageable_device_local_memory
extensions to be supported by the system.

Most platforms support these extensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/144422
2025-08-12 11:51:40 +02:00
Campbell Barton
c00dfded27 Cleanup: consistently hyphenate the term "swap-chain" 2025-08-12 10:12:19 +10:00
Campbell Barton
ab1027c777 Cleanup: capitalization of the term "VSync"
Follow the convention widely used by AMD/Intel/Nvidia.
2025-08-12 10:03:28 +10:00
Brecht Van Lommel
5afe338287 GHOST: Rename GHOST_VSYNC to BLENDER_VSYNC, change description
* GHOST is an implementation detail, Blender environment variables should
  have the BLENDER_ prefix.
* Don't put links in command line help output. We don't do this for other
  arguments either, and it's trivial to search for this online.
* Make description more straightforward and line wrap.
* Use CLOG for logging.

Ref #143049

Pull Request: https://projects.blender.org/blender/blender/pulls/144349
2025-08-11 19:03:58 +02:00
Clément Foucault
856a2a9f87 Fix: GHOST: Build error
Caused by aafef977fb
2025-08-11 12:39:37 +02:00
Christoph Neuhauser
aafef977fb GHOST: Add environment variable for enabling or disabling vsync
This PR proposes to add an environment variable for forcing vsync to
be on or off. My primary use case was to disable vsync for forcing
viewport rendering performance tests not to be capped at the display
refresh rate when #142984 is used for removing animation frame rate
limits.

I initially added the environment variable "GHOST_VSYNC_OFF", but
found "GHOST_VSYNC=0/1" to be more easily understandable.

Usage:
- GHOST_VSYNC=0 => Vsync is forced off
- GHOST_VSYNC=1 => Vsync is forced on

Pull Request: https://projects.blender.org/blender/blender/pulls/143049
2025-08-11 12:09:21 +02:00
Campbell Barton
cd66e6c1a6 GHOST/Wayland: support server-side key-repeat
Support server side key repeat when building with Wayland >=1.24.
2025-08-10 07:54:54 +00:00
Campbell Barton
7c68d603b6 Cleanup: use braces in case statements 2025-08-10 17:31:46 +10:00
Campbell Barton
0a9720a228 Fix #142871: Two cursors visible when panning over a number button
Resolve regression in [0] where setting the cursor wasn't checking
if a software cursor was used. This would then show the hardware &
software cursors.

[0]: 232b106e64
2025-08-10 16:59:57 +10:00
Campbell Barton
388609e7a7 GHOST/Wayland: minor change to error handling when setting the cursor
Don't early exit in the unlikely event setting the cursor fails,
as this could prevent the tablet cursor from being set.
2025-08-10 16:53:59 +10:00
Jeroen Bakker
073b4d4d7b Fix #144048: Vulkan: Crash minimized windows
Swapchain handling of minimized windows wasn't correct. On some
platforms it still tried to create images with no surface.

This PR will discard swapchains of minimized windows, but still being
able to flush the render graph and free resources.

Pull Request: https://projects.blender.org/blender/blender/pulls/144189
2025-08-08 11:03:02 +02:00
Jeroen Bakker
97f1aeb84c Vulkan: Remove support for render passes
Vulkan 1.0 render passes have been replaced by dynamic rendering in 1.2.
Blender Vulkan backend was implemented with dynamic rendering in mind.
All our supported platforms support dynamic rendering. Render pass support
was added to try to work around an issue with legacy drivers. However these
drivers also fail with render passes.

Using render passes had several limitations (blending and some workbench
features were not supported).  As no GPU uses it and it is quite some code
to support it is better to remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/144149
2025-08-08 08:08:58 +02:00
Campbell Barton
cccc2c77c5 Cleanup: consistent for C-style comment blocks 2025-08-08 07:37:33 +10:00
Jeroen Bakker
9d039ef29e Fix #141806: Crash with certain layers enabled
This PR removes the deferred allocation of swapchain images. A lot of layers
don't support this and will crash when used.

Thanks to Jorn Visser to point out the potential issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/143924
2025-08-05 10:11:06 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Campbell Barton
941582324c Cleanup: pass const arguments to sort, use C++ radian conversion 2025-07-31 16:18:13 +10:00
Campbell Barton
7c5ba9cb2c Cleanup: pass const arguments in GHOST/Wayland implementation 2025-07-31 03:45:42 +00:00
Felipe Choi
024291987c GHOST/Wayland: add basic touch-screen support
Generate mouse events from touch devices on Wayland.

The code tracks a single contact point and converts it to mouse moves,
LMB presses & releases. Multi-touch, pinch & swipe aren't yet supported.

Addresses #121449.

Ref !143416

Co-authored-by: Campbell Barton <campbell@blender.org>
2025-07-31 03:20:08 +00:00
Jonas Holzman
d95c2bc406 GHOST: Rename Metal Context from ContextCGL to ContextMTL
This commit renames the GHOST Metal graphic context class and related
files / references from `GHOST_ContextCGL` to `GHOST_ContextMTL`. When
the Metal backend was first introduced, this context file contained
both the old OpenGL context (CGL, for macOS Core OpenGL API), and the
newer Metal context. Since #110185 all CGL related code was removed
from the class, making it Metal only, and thus rendering the old class
name outdated and potentially misleading. In addition to the rename,
unused OpenGL related forward declarations and old TODOs were also
removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/142519
2025-07-24 13:28:44 +02:00
Campbell Barton
c1b2a1af74 Cleanup: quiet unused warnings 2025-07-24 14:37:28 +10:00
Campbell Barton
c3b8702466 GHOST: ignore GHOST_ASSERT in release builds
Error in [0] made GHOST assert in release builds.

[0]: 4d227dd593
2025-07-24 01:10:25 +00:00
Campbell Barton
008ed81d26 Fix #141777: Crash closing an unfocused window on Wayland 2025-07-20 16:31:57 +10:00
Campbell Barton
1762a66b82 Cleanup: use const cast 2025-07-20 15:27:07 +10:00
Jeroen Bakker
4de5da1ea2 OpenXR: Compile without OpenGL backend
This PR allows blender to be compiled with OpenXR, but without
OpenGL support.

For investigating a bug we needed to compile Blender without
OpenGL (`WITH_OPENGL_BACKEND=OFF`) but it would fail to
compile OpenXR (`WITH_XR_OPENXR=ON`). This PR tweakes
the preprocess directives to compile the openxr graphics
binding without OpenGL.

Co-authored-by: Jonas Holzman <jonas@holzman.fr>
Pull Request: https://projects.blender.org/blender/blender/pulls/141668
2025-07-19 21:40:49 +02:00
Sebastian Parborg
17b9759942 CMake: Sync up minimum version to 3.10
Besides being more consistent with the minimum version we use, this also
fixes warnings when using CMake 4.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/142497
2025-07-19 20:37:10 +02:00
Campbell Barton
751cfe4a74 GHOST/Wayland: invert cursor color, pre-multiply alpha
- Cursors in wayland are expected to use pre-multiplied alpha.
  Note that cursor generators create straight alpha,
  pre multiplier in the wayland backend.
- Invert cursor colors on Wayland since dark cursors are often default,
  this could use dark theme settings in the future.
2025-07-18 14:13:38 +10:00
Campbell Barton
4e3b58423c Cleanup: use snake case for GHOST's can_invert_color argument 2025-07-18 12:53:32 +10:00
Campbell Barton
c52c8874e9 GHOST/Wayland: scalable vector cursor support via cursor-generators
Support showing vector cursors at the appropriate size based on each
monitors DPI.

This solves incorrectly sized cursors with Hi-DPI outputs as well as
supporting outputs with different DPI's.

Instead of passing pixel data, pass an object that can generate cursors,
GHOST/Wayland can then ensure the correct size is used based on the
display the cursor is shown on.

While may sound overly complicated it actually simplifies displaying
cursors on Wayland, especially for multiple monitors at different DPI's.
Showing cursors at higher or lower resolutions than the monitor's DPI
also behaves differently on GNOME & Plasma, resulting in situations
where the cursor would show larger/smaller than expected.

Details:

- Take advantage of the recently added SVG cursors & BLF time cursor
  !140990 & !141367.
- Setting bitmap cursors via GHOST_SetCustomCursorShape is now a no-op
  for Wayland since it's no longer used. This was supported in an
  earlier version of this PR and could be restored if needed.
- While fractional scaling works it relies on the compositor downscaling
  the cursors. Ideally they would be rendered at the target size but
  this isn't a priority as the difference isn't noticeable.

Ref !141597
2025-07-18 12:38:52 +10:00
Campbell Barton
e8e188cb7d Cleanup: various non-functional changes for C++ 2025-07-17 12:32:30 +10:00
Campbell Barton
4d227dd593 GHOST: show assertion failures even when WITH_ASERT_ABORT=OFF
This makes GHOST_ASSERT behave like BLI_assert, where any non release
build shows an error even when assert doesn't abort.
2025-07-17 11:43:43 +10:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Campbell Barton
6eec7e3bb1 Merge branch 'blender-v4.5-release' 2025-07-13 16:25:52 +10:00
Campbell Barton
2983ea4616 Cleanup: format 2025-07-13 16:25:25 +10:00
Campbell Barton
d4b2f719c3 Merge branch 'blender-v4.5-release' 2025-07-13 15:48:34 +10:00
Campbell Barton
601b5f49f0 Disable fix for #141846
While this works in 4.5x it could lock the UI in some cases in main.
Avoid possible regressions & disable for now.
2025-07-13 15:43:22 +10:00
Campbell Barton
98a949f997 Fix #141846: Successive calls to change the cursor exits on Wayland
Calling wm.progress_update() from Python in a loop would exit
under Wayland.

Resolve by calling wl_display_dispatch after changing the cursor.
2025-07-13 04:56:39 +00:00
Harley Acheson
bea1dbfab0 UI: Cursor Time for RGBA Platforms
The Windows and Wayland platforms can both create antialiased mouse
cursors from SVG sources. Platforms with WM_CAPABILITY_CURSOR_RGBA
can therefore show a better version of "WM_cursor_time". Instead of
four blocky digits in two rows this displays beautiful digits in a
single row.

Pull Request: https://projects.blender.org/blender/blender/pulls/141367
2025-07-12 05:22:41 +02:00
Jorn Visser
035bc3e7ca Fix #115940, #111152: Handle access violations while loading Wintab
Some Wintab drivers can randomly crash while loading. Guard against this
by catching such exceptions using SEH. Also save and restore the current
unhandled exception filter as some drivers replace it with their own for
some reason.

Pull Request: https://projects.blender.org/blender/blender/pulls/141685
2025-07-10 19:59:34 +02:00
Hans Goudey
e573d9dd24 Revert "Wayland: Set surface color management"
This reverts commit 965b4dce6d.

This commit caused #141688.
2025-07-09 15:11:58 -04:00
Brecht Van Lommel
bc507861f2 Logging: Some tweaks to capitalization and log levels
For NDOF, Vulkan context, operators and events.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
d7cc940825 Logging: Log GHOST backend, GPU backend and GPU device
Important information that could not be found directly in the logs yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Jeroen Bakker
965b4dce6d Wayland: Set surface color management
This PR solves running Wayland on compositors that don't support HDR/
color management. It also allows to let Blender window be drawn across
monitor boundaries and being transferred and clamped to the monitor
it is being displayed on.

From our point of view monitor configurations is a compositor/OS
responsibility. This PR provides the compositor that the provided
swapchain image will be using sRGB whitepoints and transfer
function. The compositor should then take care of performing the
final transfer to the monitor color volume.

The color management protocol doesn't provide guarantees that
every compositor does this. It is mentioned as a recommendation
and 'should do this'.

Pull Request: https://projects.blender.org/blender/blender/pulls/141598
2025-07-09 10:50:20 +02:00
Jeroen Bakker
3fca75d0d7 Vulkan: Only select HDR swapchain on Wayland
Half float swapchains were selected even on platforms that are not able
to use HDR. This PR will limit the creation of HDR swapchains only to
Wayland.

Pull Request: https://projects.blender.org/blender/blender/pulls/141650
2025-07-09 09:00:34 +02:00
Campbell Barton
f528e3d61c GHOST/Wayland: support "resize" cursors from the shape protocol
Also add comments for the different crosshair cursors.
2025-07-09 13:54:47 +10:00
Campbell Barton
542503ddf2 Cleanup: format 2025-07-08 18:01:57 +10:00
Campbell Barton
c0e9edd70c Refactor: minor changes to prepare for Hi-DPI custom cursors on Wayland 2025-07-08 17:22:26 +10:00