Commit Graph

3224 Commits

Author SHA1 Message Date
Campbell Barton
e6044da029 Merge branch 'blender-v5.0-release' 2025-10-17 11:50:01 +11:00
Campbell Barton
c1a7d6f24d Docs: update cursor warp comment, note vulkan buffer size bug
Cursor warping is now supported by Wayland protocols, however I'd
rather not use it given the issues it's caused on other platforms.
2025-10-17 00:46:40 +00:00
Jeroen Bakker
69286ef55e Merge branch 'blender-v5.0-release' 2025-10-16 13:35:34 +02:00
Guillermo Venegas
2c4ecbd536 Fix #146989: Add presentation fences
Swapchains can be destroyed safely after a new image
is presented in a new swapchain or when all submission
and presentation fences are signaled, this last ones
where missing causing issues with some drivers when
recreating swapchains.

Pull Request: https://projects.blender.org/blender/blender/pulls/147226
2025-10-16 13:34:21 +02:00
Sean Kim
59746fde64 Merge branch 'blender-v5.0-release' 2025-10-15 19:32:24 -07:00
Campbell Barton
3099cd2124 Fix #148142: Cannot interact with normal windows (GNOME 48.4)
Resolve regression with GNOME-48 & LIBDECOR caused by fix for GNOME-49
(see !148104).

New normal (non-maximized) windows were not refreshing and ignored
cursor input. Workaround the issue be resetting the title.

See code-comments for details.

Ref !148178
2025-10-16 02:28:38 +00:00
Campbell Barton
093fd9235b Merge branch 'blender-v5.0-release' 2025-10-15 15:26:50 +11:00
Campbell Barton
5f72d112dd Fix #144919: Opening windows hangs on GNOME-49 with Wayland
Opening "normal" windows (non-maximized) windows was hanging.
Blender was waiting for a "configure" event with a valid size,
which stopped being sent in GNOME-49.

Even though GNOME-49.1 will resolve the problem, according to the
GNOME developers Blender's use of Wayland was incorrect.

Resolve the issue with the following changes:

- Don't wait for the `xdg_toplevel` to be when creating new windows.
  Instead, defer setting the window state using logic that was already
  used for Vulkan.
- Set new window's pending size - used if no size is received
  from LIBDECOR's "configure" callback.
- When the window is "configured" always set the window "state"
  even if the size is not yet known.

Ref !148104
2025-10-15 15:25:11 +11:00
Jonas Holzman
4db85e7a8e Merge branch 'blender-v5.0-release' 2025-10-14 14:41:13 +02:00
Jonas Holzman
e6064b2be3 Fix #134818: macOS: Hidden mouse grab not keeping mouse in window
This commit fixes an issue where WM cursor grabbing, when used
in "hidden" mode (`GHOST_kGrabHide`) would unexpectedly not prevent the
cursor from escaping the Blender window and revealing itself when
hovering over macOS desktop elements like the application Dock.

Looking at the original issue in past Blender versions, testing with the
Walk Navigation operator, this used to work in Blender 3.2, and broke
in Blender 3.3. Bisecting leads to commit 4c4e8cc926 (Fix T99021:
Walk-mode doesn't work in Wayland), which switched the Walk Navigation
mouse warping method from custom `WM_cursor_warp` logic to using
`WM_cursor_grab_{enable/disable}`.

Then, looking at the WM_cursor_grab Cocoa implementation, more
especially at the `GHOST_kGrabHide` case in `handleMouseEvent`, a
comment ("Cursor hidden grab operation : no cursor move") suggests that
hiding the cursor would previously prevent it from moving (possibly in
earlier macOS versions?).

This fix, the simplest I could come up with other than implementing
simple window warping for the `GHOST_kGrabHide` case (similar to what's
done on Windows, see #113066) is to use
`CGAssociateMouseAndMouseCursorPosition` to disable cursor movements
for the duration of the hidden grab, effectively restoring the original
behavior indicated in the comment.

Pull Request: https://projects.blender.org/blender/blender/pulls/148007
2025-10-14 14:31:02 +02:00
Campbell Barton
eedf15e3b7 X11: add support for --no-window-frame 2025-10-14 11:07:50 +11:00
Campbell Barton
14014045fc Cleanup: quiet unused argument warning when building without WAYLAND 2025-10-14 09:37:00 +11:00
Clément Foucault
909b682547 Metal: Fix race condition in ghost context destruction routines
Found when running with ASAN on through Xcode. Crashed on exit.

Multiple threads can release their own context at the same time
and thus release the `metal_layer_` multiple times, resulting
in use after free.

Pull Request: https://projects.blender.org/blender/blender/pulls/147972
2025-10-13 14:33:53 +02:00
Campbell Barton
3349b97987 Core: add --no-window-frame command line option
Add a command line option to load Blender without a window frame.

Currently this is only used on Wayland, enabled for WITH_UI_TESTS since
attempting to load LIBDECOR caused the tests to crash on start on Fedora.
For tests there is no need to use LIBDECOR, so disable the window frame.
This can also be used by users who don't want to use the X11 fallback if
LIBDECOR can't be found.

Ref !147716
2025-10-13 09:47:07 +00:00
Campbell Barton
5d671a4ade Cleanup: correct typos & clarify doc-strings for GHOST/Wayland 2025-10-08 13:30:11 +11:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Campbell Barton
7f36eebf5c Wayland: lower the requirement for the xdg_output_manager for Rocky8
GHOST/Wayland failed to initialize on older versions of GNOME.
Lower the requirement so Blender can start on the build-bot.

Ref !147165
2025-10-02 21:51:23 +10:00
Jeroen Bakker
44194579a5 Cleanup: Silence compilation warning
This change silences a compilation warning on non windows/x64 systems.
2025-09-26 10:03:39 +02:00
Jeroen Bakker
be4a34d103 Refactor: Vulkan: Move memory allocator ownership to GHOST.
This PR moves the ownership of vulkan memory allocator from gpu/device
to GHOST/context/device. This will allow in the future a cleaner control
flow between OpenXR and Vulkan. Currently as the ownership is in the gpu
module many objects would need to pass from GHOST to the GPU module to be
shared between the 2 allocators. Moving both (OpenXR/Context) allocator
to GHOST would reduce the complexity.

Pull Request: https://projects.blender.org/blender/blender/pulls/146819
2025-09-26 09:34:48 +02:00
Jeroen Bakker
1a0a35ac93 Fix #146559: Vulkan: Wide lines not working in custom PyGPU shaders
For wide line rendering it is preferred to use polyline shaders. However
creating a custom shader is complicated and a stone to far for many
scriptors.

This PR allows using line_width_set when wide line rendering is
supported by the platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/146762
2025-09-25 14:02:11 +02:00
Campbell Barton
30485e6122 Cleanup: grammar, confusing wording 2025-09-24 03:06:11 +00:00
Campbell Barton
4a6268e092 Cleanup: various non functional changes for C++ 2025-09-20 16:28:02 +10:00
Campbell Barton
66c19a21d8 Fix #145557: Memory leak on exit with custom wayland cursor shapes
While the leak only occurred on GNOME, there is no guarantee the
compositor releases cursor buffer before exiting.
2025-09-16 15:25:14 +10:00
Campbell Barton
975f42b7b2 Cleanup: use doxygen comments to end groups 2025-09-12 10:19:56 +10:00
Brecht Van Lommel
45dca5c994 Vulkan: Enable wide gamut colors on Windows when HDR mode is off
Only use when Windows Automatic Color Management (ACM) is enabled.
That way we know Windows will automatically convert from extended sRGB
linear to the appropriate color space for the display.

When we previously tried this there were some issues, but I think it was due
to ACM being off. This has been confirmed to work on NVIDIA and AMD, and
Intel is not expected to support this (yet) for the same reasons there is no HDR.

Pull Request: https://projects.blender.org/blender/blender/pulls/146041
2025-09-11 15:44:38 +02:00
Jeroen Bakker
c50c3275be Vulkan: Acquire/release swapchain images
`GHOST_SwapWindowBuffers` doesn't fit well when using swapchains. In
that case an approach where swap chain images are acquired and released
would map better. This PR introduces `GHOST_SwapWindowBufferAcquire`
and `GHOST_SwapWindowBufferRelease` to be more in line with vulkan swap
chains.

Previous implementation would first record all GPU commands based on
the last used swap chain. In case a swapchain needed to be recreated
(window resize, move to other monitor) the recorded commands would
not match the swap chain and could lead to artifacts.

OpenGL only implements the release functions as they don't
have a mechanism to acquire a swap chain image. (Need to validate with
the Metal API how this is working and adapt is needed).

Currently when starting blender on a HDR capable display the first frame
would be based on an sRGB surface and presented on an extended RGB
(or other) surface. As these don't match the first frame could be incorrect and
also lead to UBs as another surface is expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/145728
2025-09-11 07:51:30 +02:00
Campbell Barton
3c7f4edd92 Cleanup: spelling in comments & string
Also back-tick quote literals in CMakeLists files.
2025-09-06 09:27:54 +10:00
Jeroen Bakker
1c360091aa Fix: Vulkan: Validation error on Qualcomm GPU
Qualcomm GPU doesn't support image load/store on framebuffers. We use
load store to convert to the correct color space. This PR will only
set the VK_IMAGE_USAGE_STORAGE_BIT when HDR is available. As Qualcomm
doesn't support HDR using Vulkan this is safe.

Pull Request: https://projects.blender.org/blender/blender/pulls/145775
2025-09-05 11:09:17 +02:00
Jeroen Bakker
f4cd45d71e Cleanup: Pass variable by ref 2025-09-05 09:19:16 +02:00
Jeroen Bakker
aa7664eacc Fix: Incorrect test for WITH_GHOST_X11 2025-09-05 09:17:58 +02:00
Harley Acheson
91997ea89f UI: Save Temp Window Sizes & Positions
Allow temporary windows (like File Browser, Preferences, Render,
Drivers, Info) to open at their last positions and sizes.

Pull Request: https://projects.blender.org/blender/blender/pulls/104727
2025-09-05 00:05:50 +02:00
Jeroen Bakker
a3621841e0 Refactor: GHOST_ContextVK
Improving readability of GHOST_ContextVK

- Introduces GHOST_Extensions for a common interface to device/instance
  extensions
- Introduces GHOST_InstanceVK for instance based API (used to be part of
  GHOST_DeviceVK)

During the refactor found out that the generic queue family would always
be 0, this is most of the time the case, but could lead to issues when
setting up more complex setups.

Pull Request: https://projects.blender.org/blender/blender/pulls/145721
2025-09-04 14:12:55 +02:00
Jonas Holzman
9d95f02e83 OpenXR: Display error enum string in debug mode
Up until now, when encountering an OpenXR error / exception in debug
mode, only the raw OpenXR error enum int value would be displayed, which
wasn't really descriptive nor useful. To remedy this, this commit adds
an `xrResultToString` call to additionally convert this value into its
corresponding enum string.

See PR for an example error print.

Pull Request: https://projects.blender.org/blender/blender/pulls/142582
2025-09-02 23:05:49 +02:00
Jeroen Bakker
dfd168f905 Vulkan: Remove resource pools
Multiple previous changes made resource pools obsolete. Resource
pools were used to keep track of resources when the frame is rendered.
Multiple frames can be rendered at the same time and resources could
overlap.

This has been replaced (not this commit) to be part of the render graph
and when an submission has completed the resources are recycled.

Continuation of: https://projects.blender.org/blender/blender/pulls/145408

Pull Request: https://projects.blender.org/blender/blender/pulls/145511
2025-09-01 15:34:14 +02:00
Jeroen Bakker
f80083491a Revert "Vulkan: Remove resource pools"
This reverts commit ce0406b97b.
Reports on blender-coders mentioned that it could fail on startup.
2025-09-01 12:39:39 +02:00
Jeroen Bakker
ce0406b97b Vulkan: Remove resource pools
Multiple previous changes made resource pools obsolete. Resource
pools were used to keep track of resources when the frame is rendered.
Multiple frames can be rendered at the same time and resources could
overlap.

This has been replaced (not this commit) to be part of the render graph
and when an submission has completed the resources are recycled.

Pull Request: https://projects.blender.org/blender/blender/pulls/145408
2025-09-01 08:37:55 +02:00
Jeroen Bakker
a97ef00787 Fix #145314: Vulkan: Disable HDR on incapable drivers
This PR disables HDR when driver doesn't support
`VK_EXT_swapchain_colorspace`. It could be that Windows detect support
(DirectX) and allow users to enable HDR. But that it isn't supported by
the Vulkan part of the driver.

In case of Windows there might be an issue with using SRGB non
linear on F16 swapchains where somewhere an additional transform is
being performed. After adding support for other color spaces we should
remove the support of this swapchain configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/145325
2025-08-28 15:18:38 +02:00
Brecht Van Lommel
20a19c7aa4 Vulkan: Tweaks to improve HDR display on Windows
* Improve accuracy of warning when HDR display is not supported, taking into
  account HDR mode on/off on Windows.
* When HDR mode is disabled on Windows, don't create a HDR swapchain. This
  saves memory, and avoids a color difference on NVIDIA. That's because NVIDIA
  is the only GPU we've tested that allows a HDR swapchain when HDR mode is
  off, and we don't currently know the expected transforms for that case.
* Recreate swapchain when HDR mode on/off switch is detected.
* Update HDR info when window gains focus.

Note this means there is no wide gamut when Windows HDR is off, but it was
already not working. For that we may need to add support for something like
10bit VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, or whatever is commonly
available outside of HDR mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/144959
2025-08-28 11:03:24 +02:00
Jeroen Bakker
31fa6b62f9 Fix: Vulkan: Incorrect framebuffer size
When a file is loaded with a minimized window the VKFramebuffer can
contain incorrect texture/data that result in a crash when maximizing the
window.

Pull Request: https://projects.blender.org/blender/blender/pulls/145171
2025-08-28 09:38:39 +02:00
John Kiril Swenson
96f5bb9f05 VSE: Slip toolbar tool
This PR adds a slip tool in the toolbar with its own custom icon for
applying slips using the mouse. This is useful for e.g. tablets where a
keyboard is not handy and a button would be best to activate the
operator.

There is also a custom cursor that appears when hovering over valid,
slippable strips (and a "stop" icon when the strip cannot be slipped).

Alt may be used in order to ignore slipping connected strips when using
the tool, similar to selection logic. The slip tool only performs its
sole function of slipping and as such does not change the selection
state.

In the future, we can also add "slide" functionality to the same tool,
giving it multiple functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/143513
2025-08-25 20:36:01 +02:00
Jeroen Bakker
0ea1feabd9 Vulkan: HDR support for Windows
This PR adds HDR support for Windows for `VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT`
on `VK_FORMAT_R16G16B16A16_SFLOAT` swapchains .

For nonlinear surface formats (sRGB and extended sRGB) the back buffer is blit into the swapchain,
When VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT is used as surface format a compute shader
is used to flip and invert the gamma.

SDR white level is updated from a few window event changes, but actually
none of them immediately respond to SDR white level changes in the system.
That requires using the WinRT API, which we don't do so far.

Current limitations:
- Intel GPU support
- Dual GPU support

In the future we may add controls inside Blender for absolute HDR nits,
across different platforms. But this makes behavior closer to macOS.

See !144565 for details

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/144717
2025-08-22 10:11:55 +02:00
Jeroen Bakker
451b0f2a87 Refactor: Vulkan move queue ownership to device
Pull Request: https://projects.blender.org/blender/blender/pulls/144934
2025-08-22 08:46:46 +02:00
Campbell Barton
ebfa7edeb1 Cleanup: use snake case, replace "m_" prefix with "_" suffix
Follow our own C++ conventions for GHOST.
2025-08-16 16:14:18 +10:00
Jeroen Bakker
f4103acb3f Refactor: Vulkan: Swapchain submission fence
First advance to the next frame and use the same index for all
resources. Previous implementation used a fence of the next frame, what
added confusion why that was actually needed.

Should not make a change in functionality or performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/144615
2025-08-15 13:46:42 +02:00
Campbell Barton
3be9f89ad3 Cleanup: quiet unused warning & correct typo 2025-08-15 18:55:52 +10:00
Jeroen Bakker
1f1098c498 Vulkan: Remove MoltenVK
Blender had some support for using MoltenVK. However there are some key
issues why MotlenVK cannot be used. Bugs have been reported up-stream.
As it doesn't work and holds back regular developments it will be removed
from the main branch.

Any efforts on making Vulkan run on Apple (including KosmicKrisp)
is considered a community effort and can be done in a development
branch.

Pull Request: https://projects.blender.org/blender/blender/pulls/144602
2025-08-15 09:36:38 +02:00
Jeroen Bakker
7286885789 Vulkan: Update VMA to 3.3.0
Updated to latest release. Has some fixes and a new API for easy
integration with Volk.

Pull Request: https://projects.blender.org/blender/blender/pulls/144434
2025-08-14 13:20:45 +02:00
Thomas Dinges
b60ed07236 Cleanup: make format 2025-08-14 07:59:45 +02:00
Campbell Barton
99bcf746a0 Cleanup: remove header added last commit 2025-08-14 15:19:58 +10:00
Campbell Barton
5540b9440a CLI: move VSync from an environment variable to an argument
Add a command line argument --gpu-vsync on/off/auto.

Prefer command line arguments for GPU settings,
as it means the value is error checked and set when Blender starts.

Also refactor GHOST_Context to take a parameter argument which
includes the stereo-visual & debug arguments and includes the newly
added vsync setting. This makes it possible to add GPU context
parameters more easily in the future.

It also removes redundant parsing & setting the VSync setting for
off-screen contexts.

Changes to recent PR !143049.

Ref !144473
2025-08-14 05:16:12 +00:00