3224 Commits

Author SHA1 Message Date
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
Sebastian Parborg
e4aa758d70 Fix #137346: IME input getting lost when using Wayland
Our IME input system relied on passing around pointers to global variables.
However this will not work as the Wayland input handling is multithreaded so the content of the global variable would change while the event loop were reading the data.

Pull Request: https://projects.blender.org/blender/blender/pulls/138871
2025-05-16 14:21:06 +02:00
Jeroen Bakker
606d24d88a Fix #138942: Vulkan: Use different scaling on first swapchain
First time a swap chain is created an incorrect resolution can be
reported back by the driver as the window is still initializing. We
stretch the swap chain to cover to reduce a black line rendering in top
of the window (due to content flipping). Any subsequent frame will not
do stretching to reduce artifacts when resizing the window.

Pull Request: https://projects.blender.org/blender/blender/pulls/138964
2025-05-16 08:47:04 +02:00
Jeroen Bakker
3b3cab471a Fix #138843: Vulkan: Swapchain issues
- Reduce artifacts during resizing to also recreate the swapchain
  when acquire image is suboptimal
- Do not stretch when backbuffer and swapchain have a different size

Pull Request: https://projects.blender.org/blender/blender/pulls/138925
2025-05-15 11:57:44 +02:00
Campbell Barton
3ec7748485 Cleanup: spelling in comments (make check_spelling_*)
Also replace term "playhead" with "current-frame".
2025-05-15 10:13:23 +10:00
Campbell Barton
7da0ecccce GHOST/SDL: support horizontal scroll events 2025-05-14 21:48:41 +10:00
Jacques Lucke
afd760f2b7 UI: Ghost: support horizontal scrolling for 2D editors
Some mice have an additional horizontal scroll wheel. This patch adds support
for receiving such events. By default it is used to scroll 2D editors left and right.

I originally developed this because I was missing it in the spreadsheet, but it
seems to be useful in many other editors too.

It's supported on Linux (Wayland), Windows and macos.

Pull Request: https://projects.blender.org/blender/blender/pulls/138758
2025-05-14 13:33:10 +02:00
Josh Belanich
dc02cc1d31 Fix: Vulkan: Soundness issues for Vulkan submission fences
Fixes a few render synchronization soundness issues I discovered when investigating
why resetting the pools after the submission fence in #137305 ended up causing #137395.

1. Ensure the number of submission fences in GHOST_ContextVK is the same
   as the number of resource pools in VKThreadData. Otherwise, the
   fences might get misaligned, making it difficult to predict which
   submission a fence's signal corresponds to.

2. In swapBuffers, pass the current m_frame_data's fence and semaphores
   to the Vulkan backend callbacks, rather than the following
   m_frame_data. This fixes an observed soundness issue where the fences
   were off-by-one. Now, the backend callbacks can be sure that both the
   next frame is ready for construction (and it's resources can be
   cleaned), and will use the correctly aligned fences and semaphores
   during command buffer submission.

3. Do not recreate the m_frame_data's fences during recreateSwapchain.
   This would lead to unsoundness immediately following
   recreateSwapchain where all the fences are signaled but those frames
   might still be in flight.

Pull Request: https://projects.blender.org/blender/blender/pulls/137580
2025-05-13 15:45:46 +02:00
Jeroen Bakker
e934792169 Fix #138032: Vulkan: Loading minimized windows on Windows/NVIDIA
Minimized windows have the resolution of 0,0. The surface supports
swapchains with this resolution, however it doesn't work and leads
to crashes and UBs.

This PR fixes this to use a minimum resolution of 1,1.

Pull Request: https://projects.blender.org/blender/blender/pulls/138750
2025-05-12 10:30:13 +02:00
Campbell Barton
837703e585 Fix: failure to start on Wayland/GNOME with monitors at different scales
With two or more monitors of different scales, Blender would fail to
start in some cases when it opened on a monitor at a size that wasn't
a multiple of the monitors scale.

This seemed only to cause problems with LIBDECOR however the buffer size
should always be a multiple of the buffer scale, so ensure its always
valid.

See #135764 for details (a closely related bug).
2025-05-09 21:36:12 +10:00
Campbell Barton
2cd2f2ea4d Cleanup: quiet missing parenthesis & unused function warnings 2025-05-09 02:13:33 +00:00
Jeroen Bakker
d648ffb0f1 Fix #138140: Vulkan: Disable swapchain maintenance1
There are issues with our implementation.
- X11 can flip image incorrectly.
- VVL complains of incorrect usage.

Disabling the extension for now until it is more clear what is not
correct.
2025-05-08 15:36:45 +02:00
Campbell Barton
302a5541b3 Cleanup: don't assign the native size to the logical size
This size isn't used unless `has_size_logical` is true,
setting fallback values that aren't used is confusing especially since
output rotation isn't applied - unlike the actual logical size.
2025-05-08 12:11:42 +00:00
Campbell Barton
8836d41542 Fix #135764: Crash on startup with mutli-monitors on Gnome Wayland
Rotated outputs caused a workaround for a bug in GNOME to fail.

Also check the native size since the `size_logical` would always
be set to match the `size_native`.
2025-05-08 12:11:40 +00:00
Campbell Barton
f7dc522834 Fix: output rotation checks with WAYLAND
Only 90 & 270 degree transforms were accounted for.
Check for 90 degree rotation using a flag to include
flipped & rotated output transform.
2025-05-08 12:11:39 +00:00
Campbell Barton
702a7a0ba3 Docs: clarify usage of wayland output sizes 2025-05-08 12:11:37 +00:00
Jorn Visser
d73950790c Fix: GHOST: Accept dropped text with only CF_UNICODETEXT format present
Check for both `CF_TEXT` and `CF_UNICODETEXT` in
`GHOST_DropTargetWin32::getGhostType` because, unlike for the clipboard,
Windows does not synthesize `CF_TEXT` from `CF_UNICODETEXT` and vice
versa for drag and drop operations. Since `getGhostData` already
supports `CF_UNICODETEXT`, this is all that's necessary to make it work.

I encountered this issue when trying to drag text from Notepad++ into
Blender's text editor.

Pull Request: https://projects.blender.org/blender/blender/pulls/138524
2025-05-07 00:53:52 +02:00
Jonas Holzman
733d65e514 GHOST: Remove GHOST_DisplayManager and its implementations
The GHOST_DisplayManager and its implementations are for the most part
unmaintained and almost completely unused in all backends. To clean
things up, and avoid any confusion about how displays are handled in
each respective GHOST backend, this PR completely removes the GHOST
Display Manager, and move the few remaining logic it still held directly
to the corresponding backends.

The backends that were modified (apart from removing the display manager
initialization call from their init) are:

- Win32: `GHOST_SystemWin32::getNumDisplays()` was calling
  `m_displayManager->getNumDisplays`, the underlying system metric call
  (`GetSystemMetrics(SM_CMONITORS)`) was substituted in place.

- SDL: `GHOST_SystemSDL::createWindow` was calling
  `GHOST_DisplayManagerSDL::getCurrentDisplayModeSDL` which returned its
  `m_mode` data member by reference. Since none of the
  `GHOST_DisplayManagerSDL` member function that modified this data member
  were ever called, the variable `memset` initialization call was
  substituted in place from the `DisplayManagerSDL` constructor

Pull Request: https://projects.blender.org/blender/blender/pulls/138066
2025-04-28 14:26:39 +02:00
Campbell Barton
f36f23e772 Cleanup: de-duplicate & simplify assignment 2025-04-26 21:28:01 +10:00
Campbell Barton
c90e8bae0b Cleanup: spelling in comments & replace some use of single quotes
Previously spell checker ignored text in single quotes however this
meant incorrect spelling was ignored in text where it shouldn't have
been.

In cases single quotes were used for literal strings
(such as variables, code & compiler flags),
replace these with back-ticks.

In cases they were used for UI labels,
replace these with double quotes.

In cases they were used to reference symbols,
replace them with doxygens symbol link syntax (leading hash).

Apply some spelling corrections & tweaks (for check_spelling_* targets).
2025-04-26 11:17:13 +00:00
Campbell Barton
01c32a9ccc Cleanup: trailing space 2025-04-24 12:44:27 +10:00
Campbell Barton
6c1a8cf4ce Fix #136999: wrong menu placement after walk navigation under Wayland
When grabbing & hiding cursor under Wayland visually restored the
cursor location but didn't generate a motion event to update the
`wmWindow::eventstate`. Further events that used the cursor location
used the hidden location unless the user moved the cursor beforehand.
2025-04-17 03:34:28 +00:00
Campbell Barton
1131682665 Cleanup: use wl_fixed_t for high precision cursor position
This was already done for the most-part.
2025-04-17 03:34:27 +00:00
Campbell Barton
707a3aa4f9 Cleanup: remove redundant check
Missed in cleanup !137050.
2025-04-17 03:34:25 +00:00
Harley Acheson
914d2e8164 UI: Reverse Pen Y Tilt Expected Direction
It is more convenient for math reasons, for Blender to treat a pen tilt
toward the user as a positive angle. This PR just reverses all the
comments about the expected values. And also reverses the values from
WinTab, Windows Ink, and Wayland to match.

Pull Request: https://projects.blender.org/blender/blender/pulls/137636
2025-04-17 04:26:58 +02:00
Campbell Barton
64f5dee6d7 Cleanup: spelling in comments (make check_spelling_*) 2025-04-17 12:06:12 +10:00
Harley Acheson
2e1a12905d Cleanup: Remove WIN32_COMPOSITING
This PR removes unused Win32 code that we've had for about 13 years,
hidden behind a define that we've never enabled. The intent of this
optional code was to allow showing Blender windows as transparent,
something that looked pretty cool back then. The main method used was
an API call of DwmEnableBlurBehindWindow, but this function has not
done anything since Windows 8 because styles and tastes have changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/137620
2025-04-16 22:01:29 +02:00
Harley Acheson
cf4778df74 UI: Remove Initial Win32 White Flash During Startup
On the Windows platform we get an initial bright white flash during
startup, before we start drawing on our canvas. This PR changes that
initial color to a mid-grey that is much less noticeable. After this
initial fill is done we then clear the background brush so Windows will
not use it later and slow down resizing by adding extra WM_PAINT
messages and fills.

Pull Request: https://projects.blender.org/blender/blender/pulls/137488
2025-04-16 19:51:45 +02:00
Harley Acheson
e1e250aa84 UI: Consistent Pen Tilt Values
Pen tilt values come into Blender through ghost platforms and device
drivers with inconsistent and ambiguous directions. This PR codifies
that we consider tilt-x positive values to be rightward, negative
values as leftward. Similarly tilt-y positive is away from the user,
negative is toward the user. Comments are updated to make this clear.
This fixes Windows Ink (currently always returning left and away). This
also reverses the Wayland tily-y values to match. We might still have
to consider a user preference to swap directions if we find differences
within a platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/137501
2025-04-15 20:23:32 +02:00
Jeroen Bakker
9eb0f59264 Cleanup: Vulkan: Remove obsolete extension 2025-04-15 12:16:52 +02:00
John Kiril Swenson
5a2a6da0a2 VSE: Blade Tool Cursor
This patch adds initial cursor support for the blade tool, with bitmaps
for 16x16, 24x24, and 32x32 cursors.

Additional Changes:
- Locked strips now show a "stop" icon when hovered over.
- Previously, the frame to split was truncated when clicking in between frames.
  Now, round to the closest frame.
- Previously, the blade operator was able to select padded strip handles
  outside of strip bounds. This bug has been resolved, so that selection with
  the blade tool can only happen via box-select passthrough.

Pull Request: https://projects.blender.org/blender/blender/pulls/136749
2025-04-13 22:49:18 +02:00
Campbell Barton
5affe5fc6d Cleanup: spelling in comments (make check_spelling_*) 2025-04-12 19:31:29 +10:00
Campbell Barton
d700bc5f54 Cleanup: remove use of unsafe string functions 2025-04-12 18:42:44 +10:00
Campbell Barton
3bf92a6e83 Cleanup: rename nullptr to null for null-characters 2025-04-11 23:55:00 +00:00
Campbell Barton
44444a550e Fix #135039: Vulkan: Blender does not start with Wayland in GNOME
Remove logic to access LIBDECOR's underlying XDG window since it
required an "dummy-buffer" workaround which caused a crash with recent
drivers that require a DMA buffer.

This introduces a slight flicker on startup in some cases
see code-comments for details.

Ref: !136289
2025-04-11 09:44:46 +00:00
Jeroen Bakker
3da222cb9a Vulkan/OpenXR: Direct3D Bridge
Some OpenXR platforms do not support OpenGL or Vulkan. To support these
platforms we use a bridge. Blender still renders in OpenGL/Vulkan, but
will copy the render result into a D3D11 swapchain.

OpenGL doesn this by importing the D3D11 swapchain into the OpenGL
context and perfor OpenGL calls to update the swapchain. However for
vulkan that could lead to construct 3 context for OpenXR

- Blender GPU Context
- OpenXR D3D Context
- New context that imports the Blender render result and the OpenXR
  Swapchain image and copies them.

Due to Direct3D limitations importing into a vulkan context has known
issues (driver + extensions). Secondly we are not sure if we are running
on the same device as the OpenXR swapchain. The solution provided with
this PR is to only support CPU data transfers.

**SteamVR using d3d bridge**

SteamVR normally would use the Vulkan binding. But by changing the binding
priority in code you can make it select the D3D bridge.

<img width="1518" alt="Screenshot 2025-04-10 114534.png" src="attachments/f856bb2b-9ad5-4bb2-9cfd-a1412da9edd1">

It has been tested and validated to work using Mixed reality portal as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/137264
2025-04-10 16:15:27 +02:00
Jeroen Bakker
969e70fed8 Fix: Vulkan: Unable to start on WoA
Current Windows on ARM GPUs don't support
extenral memory. External memory is required
for OpenXR. So most likely OpenXR will not work
on these devices.

Most (read all) OpenXR platforms that support
vulkan also require external memory. So might
just be that those platforms won't work at all
on these devices.

In any case when not supported, the GHOST
OpenXR platform will use CPU for data transfer.
2025-04-10 10:15:23 +02:00
Jeroen Bakker
ae8665b8b2 Cleanup: Missing pragma once 2025-04-10 09:36:19 +02:00
Jeroen Bakker
6f6df389a1 Cleanup: OpenXR: Move Direct3D to its own compile unit
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/137255
2025-04-10 09:32:48 +02:00
Jeroen Bakker
07a9306bb4 Cleanup: Vulkan/OpenXR: Pass Blender context via constructor
Similar to Direct3D.

Pull Request: https://projects.blender.org/blender/blender/pulls/137254
2025-04-10 08:51:20 +02:00
Jeroen Bakker
a564a27c1f Cleanup: OpenXR: Introduce a Direct3D base class.
For the Vulkan/OpenXR code will be shared with the OpenGL-Direct3D
bridge. This cleanup separates the OpenGL specifics in its own class.

Pull Request: https://projects.blender.org/blender/blender/pulls/137252
2025-04-10 08:50:52 +02:00
Campbell Barton
b2dbfa7d77 Cleanup: spelling in comments, use doxygen comments 2025-04-10 13:02:29 +10:00