Commit Graph

3115 Commits

Author SHA1 Message Date
Jonas Holzman
95abfc00a5 Merge branch 'blender-v4.5-release' 2025-07-03 00:07:52 +02:00
Jonas Holzman
b0ffd4cb07 Fix: macOS: Support multi-monitor window positioning
This commit brings multi-monitor window positioning support to the macOS
GHOST backend. This fixes a plethora of issues with macOS window
creation and positioning, such as:

 * Windows not being properly restored when loading a file with Load UI
 * Users default startup windows not being properly restored on multiple
   screens
 * Temporary windows (Settings, Render, Playblast, etc..) wrongly
   appearing in unexpected places / other screens
 * Duplicating an area into a new window (AKA popping out an editor) not
   working on non-primary screens.
 * etc..

Internally, this makes all macOS windows coordinates be relative to the
user primary monitor, instead of being local to the currently focused
one. I have tested this to properly work using all sorts of multiple
screen arrangements, and can also confirm that restoring windows from
screens that do not exist anymore / are now out of bounds (due to being
unplugged or re-arranged) also works properly, in which case they get
snapped back to the closest available screen similarly to other backends.

This fixes issue #126410 and implements behavior described in TODO task #69819.

Pull Request: https://projects.blender.org/blender/blender/pulls/141159
2025-07-03 00:05:52 +02:00
Campbell Barton
3d15acee1f GHOST/Wayland: correct tablet serial argument for setting cursors
While the previous logic tended to work as it would use the serial
for the last active table event - follow the spec and and always pass
in the serial for the proximity_in event.
2025-07-02 23:13:29 +10:00
Campbell Barton
53a5eef579 Cleanup: minor tweaks to ghost cursor internals
- Use the typed enum for wayland cursor ID's.
- Return an std::optional<...> for cursor access,
  with std::nullopt when the cursor doesn't have an equivalent value
  from ghost.
- Add "stub" calls to `update_cursor_scale` where removed as part of
  !140366 but will be needed when custom cursors support updating
  based on output scale.
2025-07-02 21:34:27 +10:00
Sebastian Parborg
232b106e64 GHOST: Implement the cursor shape protocol and remove X11 cursors from the wayland backend
This makes the the cursor drawing be handled by the Wayland compositor
unless the cursor shape is not in the standard cursor shape set.
For custom cursor shape, Blender still manually draws and handles these.

Removal of the X11 cursors was done because:
1. Greatly simplifies the code (and compositors not supporting the cursor
    shape protocol will fallback to Blenders built in cursors).

2. On a lot of compositors the X11 cursor theme is not set per default,
       this would lead to us falling back to a default theme. This would
       in almost all cases not match the actual cursor theme of the user.
       The fallback theme would also look quite ugly and the cursor size
       would be inconsistent with the rest of the system.

Pull Request: https://projects.blender.org/blender/blender/pulls/140366
2025-07-01 15:16:44 +02:00
Campbell Barton
bfd3ff7e3d Cleanup: use const custom cursor arguments to GHOST
Also use int[2] for size & hot-spot arguments to avoid passing
around so many arguments.
2025-07-01 15:22:38 +10:00
Campbell Barton
5bdc6df9d1 Cleanup: de-duplicate doc-strings in GHOST
Move doc-strings to GHOST's "implementation" classes,
use `\copydoc` to reference them from classes in `intern`.

Doc-strings were copied between the classes, but had gotten out of sync
or only ever existed in one of the files.
2025-07-01 13:33:54 +10:00
Campbell Barton
7b02b813f8 GHOST/Wayland: support RGBA custom-cursors 2025-07-01 03:01:25 +00:00
Harley Acheson
ac457b9836 UI: SVG Icons as Internal Custom Mouse Cursors
This PR replaces our current custom mouse cursors (defined in
wm_cursors.cc using bitmaps and masks that we edit with a python
program) with SVG sources that are rasterized at the exact size when
needed. For Windows this would also replace the 29 platform-specific
"cur" files, although this PR does not actually remove those. For Linux
this creates the same kind of cursor as now (1bpp XBitMap) but at a
better size.

Pull Request: https://projects.blender.org/blender/blender/pulls/140990
2025-07-01 04:59:49 +02:00
Campbell Barton
5e927eae1b Docs: corrections, clarifications to code-comments 2025-06-28 10:46:57 +10:00
Julian Eisel
4b2d60a2c3 Ghost: Make special user directory query thread safe
Similar to e0ff7731e0.

Noticed a data race when working on blender/blender!130543, which calls
this function from a thread. Make this thread safe by avoiding returning
of static memory, instead use an optional `std::string`.

Pull Request: https://projects.blender.org/blender/blender/pulls/141083
2025-06-27 15:16:35 +02:00
Jeroen Bakker
e058e4f8ca Merge branch 'blender-v4.5-release' 2025-06-27 11:28:54 +02:00
Jeroen Bakker
a74b663bf9 Cleanup: Vulkan: Enable extensions (2)
Missing part of the cleanup done by 225449b96d
2025-06-27 11:26:24 +02:00
Jeroen Bakker
f957d132e7 Merge branch 'blender-v4.5-release' 2025-06-27 10:51:30 +02:00
Jeroen Bakker
225449b96d Cleanup: Vulkan: Enable extensions
When the list of extensions is constructed for `vkCreateDevice` it
uses a function that retrieves all extensions just to iterate to
check a specific extension is supported. However there is already a
list cached that is that is the subset of the desired extensions that
are supported by the device.

This cleanup will use that list instead of requiring all supported
extensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/141074
2025-06-27 10:50:58 +02:00
Jeroen Bakker
fc8a617687 Merge branch 'blender-v4.5-release' 2025-06-27 08:59:25 +02:00
Jeroen Bakker
d67b705d1c Fix: Vulkan: Validation error Wayland+NVIDIA
This PR fixes a validation error about the swapchain semaphores. When
swapchain maintenance 1 is supported the semaphores can be reused, but
requires a fence. We didn't implement the fence. This PR doesn't reuse
the semaphores as introducing the fence leads to more changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/141066
2025-06-27 08:58:37 +02:00
Campbell Barton
5d553e1dd0 Merge branch 'blender-v4.5-release' 2025-06-25 04:42:53 +00:00
Campbell Barton
2a757f469c Fix cursor size being ignored by custom cursors under Wayland
The theme cursor size was ignored when setting custom cursors
such as the knife, only the DPI from GHOST was taken into account.

This meant cursors such as the knife would sometimes display too small.

Now when the theme-size is larger, a larger cursor will be used.

Currently the theme size is read from XCURSOR_SIZE environment variable
however it may be read from the system preferences in the future.

Also fix the software cursor sizes which incorrectly used the UI scale
preference which is ignored by cursor sizes.
2025-06-25 04:39:57 +00:00
Jeroen Bakker
e63a20fee1 Vulkan: HDR support for Wayland
This change enables HDR support for wayland as an experimental feature.
It supports both non-linear extended sRGB and un-clamped sRGB.

Windows isn't supported as the HDR settings are not accessible via an
API and would require similar settings that games use to configure the
monitor. Adding those sliders isn't what we would like to add.

Vulkan (working group) is working on new extensions that might change
the shortcomings. It isn't clear yet what the extension will do and what
the impact is for applications that want to use it. When the extension
is out we should review at the situation again.

Pull Request: https://projects.blender.org/blender/blender/pulls/133159
2025-06-24 11:51:14 +02:00
Jonas Holzman
c8aa20f8b3 Cleanup: Remove titlebar text color from decoration style settings
When the colored titlebar decoration style was implemented in
PR #123982, both the titlebar background and foreground were exposed
to the OS backends to be used when styling the Blender window titlebar.

In practice, both backends that implement this decoration style (Win32
and macOS/Cocoa) only use the background color, and they either rely on
the OS to automatically set the text color or use the color HSV value
component to switch between the OS dark/white color.

While it was thought to still keep this value around for a potential
future backend implementation, the color settings parsed to obtain the
titlebar color (`TH_BUTBACK_TEXT_HI`, which wasn't properly suited for
this feature to begin with) has been replaced by `TH_TEXT` in #140726,
which ends up being too bright to be used as titlebar text for most
themes/use cases.

As such, this PR removes this unused titlebar decoration style setting.
Future backends that wishes the implement the colored titlebar
decoration style should either use an existing OS/DE text color or use
a set white/dark text color, similarly to what the Cocoa backend does.

Pull Request: https://projects.blender.org/blender/blender/pulls/140823
2025-06-22 22:17:02 +02:00
Campbell Barton
07121d44ae Cleanup: use braces (follow own style guide) 2025-06-11 09:05:26 +00:00
Campbell Barton
0e5d2a3fc7 Merge branch 'blender-v4.5-release' 2025-06-11 16:23:28 +10:00
Campbell Barton
c8e31d34b4 Cleanup: quiet CMake warnings from use of undefined variables 2025-06-11 16:22:18 +10:00
Jeroen Bakker
17e3d6c844 Merge branch 'blender-v4.5-release' 2025-06-10 14:41:01 +02:00
Jeroen Bakker
f23f498864 Fix #139815: Vulkan: Infinite loop when loading minimized windows
e934792169 introduced a workaround for
NVIDIA windows where NVIDIA drivers fail to allocate swapchain images
of minimized windows. The fix was to clamp it to 1,1. With this clamping
AMD driver seems to tell Blender that the created swapchain is suboptimal,
and needs to be recreated. This results in over and over creation of
swapchains as they are all considered sub-optimal.

This PR limits the clamping to NVIDIA drivers only.

Pull Request: https://projects.blender.org/blender/blender/pulls/140112
2025-06-10 14:39:51 +02:00
Miguel Pozo
b9a3b62a4d Merge branch 'blender-v4.5-release' 2025-06-06 17:11:47 +02:00
Jeroen Bakker
4a88c14d95 Fix #139917: Vulkan: Increase number of render frames
The number of render frames influences how long discarded memory will be
kept. There are platforms that require 5 frames to work succesfully.

Pull Request: https://projects.blender.org/blender/blender/pulls/139934
2025-06-06 16:02:47 +02:00
Jeroen Bakker
35483d86c8 Merge branch 'blender-v4.5-release' 2025-06-06 10:22:11 +02:00
Jeroen Bakker
66d361bd29 Vulkan: Add support for descriptor buffers
Descriptor sets/pools are known to be troublesome as it doesn't match
how GPUs work, or how application want to work, adding more complexity
than needed. This results is quite an overhead allocating and
deallocating descriptor sets.

This PR will use descriptor buffers when they are available. Most platforms
support descriptor buffers. When not available descriptor pools/sets
will be used.

Although this is a feature I would like to land it in 4.5 due to the API changes.
This makes it easier to fix issues when 4.5 is released.
The feature can easily be disabled by setting the feature to false if it has
to many problems.

Pull Request: https://projects.blender.org/blender/blender/pulls/138266
2025-06-06 10:20:36 +02:00
Campbell Barton
54eb530a4d Cleanup: const-correctness for GHOST's IME events 2025-06-05 17:39:02 +10:00
Campbell Barton
6a1fa176ef Cleanup: spelling in comments & duplicate terms (check_spelling.py)
Also minor clarification in doc-string.
2025-06-04 01:51:29 +00:00
Jeroen Bakker
aa8c56935e Refactor: Vulkan: Move code from header to compile unit
!139630 requires the implementation to be part of the compile
unit.
2025-06-03 10:39:47 +02:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Campbell Barton
da339d31cd Fix out-of-bounds write with Wayland compose-key event handling
`xkb_compose_state_get_utf8` may return multiple characters, while
this isn't supported, prevent a buffer overflow & report a warning.

Co-authored-by: Phoenix Katsch <phoenixkatsch@gmail.com>

Ref: !114612
2025-05-30 20:34:50 +10:00
Campbell Barton
60aede77af Fix use after free error rendering in background mode on Wayland
The event handing thread wasn't properly shutdown in background mode.

Resolve by disabling threaded event handling in background mode.
2025-05-30 12:32:06 +10:00
Campbell Barton
fbe28d16bd Cleanup: use a separate logging callback in background in Wayland 2025-05-30 12:07:40 +10:00
Hans Goudey
91803e130f Cleanup: Grammar: Fix uses of "for e.g."
e.g. stands for "exempli gratia" in Latin which means "for example".
The best way to make sure it makes sense when writing is to just expand
it to "for example". In these cases where the text was "for e.g.", that
leaves us with "for for example" which makes no sense. This commit fixes
all 110 cases, mostly just just replacing the words with "for example",
but also restructuring the text a bit more in a few cases, mostly by
moving "e.g." to the beginning of a list in parentheses.

Pull Request: https://projects.blender.org/blender/blender/pulls/139596
2025-05-29 21:21:18 +02:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Jeroen Bakker
6b1ef63f4d Fix: Vulkan: Swapchain validation
On selected platforms there were some validation errors. It was caused by
platforms that returned a different number of swapchain images then were
requested. In that case the semaphores can get out of sync.

Current mechanism isn't future proof as the max number of images are
statically defined.

For this change the present semaphores is also separated from the frames
to better support out of order swapchain images.

Pull Request: https://projects.blender.org/blender/blender/pulls/139446
2025-05-26 16:31:02 +02:00
Jeroen Bakker
4f76c75da2 Vulkan: Add ghost.vulkan logging
GHOST backend didn't use logging. This PR adds an initial ghost.vulkan
logging and improves the reporting of logging in vulkan.

logging can be enabled by `blender --log "gpu.vulkan,ghost.vulkan" --log-level 2`
it shows the optional extensions that are enabled and information about swap chain
events.

Pull Request: https://projects.blender.org/blender/blender/pulls/139437
2025-05-26 12:55:00 +02:00
Jeroen Bakker
bd139fef14 Fix: Vulkan: Validation error on devices without external memory
Qualcomm devices don't support external memory, but there an external
memory pool was still being constructed. This PR skips the creation and
asserts when using external memory on those devices.

Pull Request: https://projects.blender.org/blender/blender/pulls/139326
2025-05-23 15:59:29 +02:00
Jeroen Bakker
ea22ef739d Cleanup: Vulkan: Remove explicit feature VVL
We should not enable features explicitly. This also prints an info
record when using VVL. When you want to enable specific features
use vkconfig/vkLoader.

Pull Request: https://projects.blender.org/blender/blender/pulls/139324
2025-05-23 11:04:56 +02:00
Jeroen Bakker
b2a3caac5b Fix #138140: Vulkan: First few frames squashed on X11
Previous swapchain fixes didn't solve the issue on X11 so for X11 we still need
to disable VK_EXT_swapchain_maintenance1.

Pull Request: https://projects.blender.org/blender/blender/pulls/139270
2025-05-22 14:15:28 +02:00
Jeroen Bakker
60990f6b72 Refactor: OpenXR: Add begin and end submit swapchain handler
Graphics bindings would be able to share resources more easily.
Extracted from !139140

Pull Request: https://projects.blender.org/blender/blender/pulls/139155
2025-05-20 14:04:45 +02:00
Sebastian Parborg
62ccba022c Fix #139007: Input string refresh calls missing for Win IME
The update/refresh calls got removed by mistake in #138871.
2025-05-19 16:06:19 +02:00
Jeroen Bakker
808ba086f1 Cleanup: Vulkan: Feature chain
In stead of keeping track of a local variable this PR will keep a list
of all feature structs and at the end populate the pNext.

Pull Request: https://projects.blender.org/blender/blender/pulls/139092
2025-05-19 15:45:50 +02:00
Jeroen Bakker
e844e0c90d Vulkan: Enable robustness2 null descriptors
This change will enable VK_EXT_robustness2.nullDescriptors feature.
It will be able to guarantee that shaders run even when some resources
are not attached.

There should not be any difference with before as this feature is often
the default behavior of GPUs. However it makes the intent more explicit
that failing allocations can still run similar to OpenGL. It is expected
that some tweaks are needed in Vulkan backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/139090
2025-05-19 14:43:55 +02:00
Jeroen Bakker
2143eb7a4f Refactor: Vulkan/OpenXR: Import memory handles only once
Importing memory is done to often. when memory doens't change the
previous imported memory can be used.

The idea is to keep track of the last used buffer and keep reusing
it until the view/resolution has changed. This should not happen during
a session.

Pull Request: https://projects.blender.org/blender/blender/pulls/138984
2025-05-19 12:32:08 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00