Commit Graph

3036 Commits

Author SHA1 Message Date
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
Jeroen Bakker
7ecacbc3e6 Vulkan/OpenXR: Support VK_KHR_external_memory_win32
This PR add support to use a win32 handle to perform share render
result with the OpenXR vulkan instance. This is only possible when
the GPU matches. Otherwise a CPU roundtrip will be performed.

Pull Request: https://projects.blender.org/blender/blender/pulls/137093
2025-04-08 15:21:55 +02:00
Jeroen Bakker
22ae59d28d Vulkan: Include Win32 extensions definitions
Includes win32 specific extensions definitions when including
`vk_common.hh`. Inside `gpu_context.cc` vulkan needs to be
included before opengl, otherwise windows 10 builders will
report a warning.

```
[6421/7520] Building CXX object source\blender\gpu\CMakeFiles\bf_gpu.dir\intern\gpu_context.cc.obj
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\minwindef.h(130): warning C4005: 'APIENTRY': macro redefinition
C:\Users\blender\git\blender-vexp\blender.git\lib\windows_x64\epoxy\include\epoxy/gl.h(59): note: see previous definition of 'APIENTRY'
```

Pull Request: https://projects.blender.org/blender/blender/pulls/137134
2025-04-08 14:10:01 +02:00
Jeroen Bakker
70995180ed Fix: Vulkan/OpenXR: Incorrect swapchain image layout
In the OpenXR/Vulkan specs it is mentioned that the swapchain layout
should be set to optimal color attachment. This wasn't the case and
could lead to validation errors.

Also fixes a memory size validation error. Not concerning as it was
abount already backed memory.

Pull Request: https://projects.blender.org/blender/blender/pulls/137143
2025-04-08 13:35:23 +02:00
Campbell Barton
0b369b6613 Cleanup: remove GHOST_TaskbarX11
This only worked for Ubuntu's discontinued Unity desktop.

Even though `libunity.so` can be used outside of Unity,
it's no longer actively developed.

Ref: !137128
2025-04-08 10:56:29 +00:00
Campbell Barton
3a51d140d8 Cleanup: remove WITH_X11_XF86VMODE since mode setting is no longer used
Setting the display mode was last used for the Game Engine
remove the CMake option WITH_X11_XF86VMODE and the associated code.

Ref: !137126
2025-04-08 10:56:27 +00:00
Jeroen Bakker
566c3d0846 Fix: Vulkan/OpenXR: Crash when vulkan physical device not found
When using SteamVR without starting SteamVR, the physical device cannot
be found. This isn't reported to the user nicely. This change will
tell the user why OpenXR couldn't be started.

Note that the physical device can be created when SteamVR has already
launched. OpenGL will start SteamVR automatically, but seems Vulkan
isn't able to do that.
2025-04-08 11:30:29 +02:00
Campbell Barton
f459d97dfd Cleanup: remove unused full-screen support from GHOST
Remove full-screen support from GHOST API's.
Note that this only had back-end implements for X11 and WIN32.

This was last used for the Game Engine to run games full-screen,
removing as it's unused and it doesn't seem likely to be used in the
future.

This doesn't impact making Blender full-screen from the window menu
which uses a window decoration setting.

Ref: !137050
2025-04-08 05:18:57 +00:00
Campbell Barton
0ff9a162c1 Fix: memory leak on Wayland with IME
For practical purposes this only leaks on exit,
unless seats are change at run-time.
2025-04-07 11:24:02 +00:00
Campbell Barton
e7c9ea3b27 Cleanup: correct typo in variable name & comments 2025-04-05 08:49:20 +00:00
Jesse Yurkovich
40cbc09d56 Cleanup: correct typos
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/137009
2025-04-04 22:58:10 +02:00
Miguel Pozo
2d75688259 GHOST: Add GHOST_GetActiveGPUContext()
Track the (per-thread) active `GHOST_Context`.
This is required to restore the active context after creating a new one
if the current context is unknown.
(Required for creating GPU contexts in the GPU module without depending
on the WM module)

Pull Request: https://projects.blender.org/blender/blender/pulls/136992
2025-04-04 18:14:13 +02:00
Jeroen Bakker
a46643af0f Vulkan/OpenXR: Add support for VK_KHR_external_memory_fd
Current implementation uses a CPU roundtrip to transfer render result
to the Xr Swapchain. This PR adds support for sharing the render result
on Linux systems by using file descriptors.

To extend this solution to win32 or dx handles can be done by extending
the data transfer modes, register the correct extensions. When not
using the same GPU between Blender and OpenXR the CPU roundtrip
will still be used.

Solution has been validated with monado simulator and seems to be as
fast as OpenGL.

Performance can be improved by using GPU based synchronization.
Current API is limited as we cannot chain the different renders and
swapchains.

Pull Request: https://projects.blender.org/blender/blender/pulls/136933
2025-04-04 16:01:06 +02:00
Jeroen Bakker
d6687de291 Cleanup: Code-style 2025-04-04 11:56:02 +02:00
Campbell Barton
4139d4a8f0 Cleanup: spelling in comments (make check_spelling_*) 2025-04-04 12:48:04 +11:00
Jeroen Bakker
d271b69c67 Vulkan: Optimize swapchain image selection
Improve the number of images that are requested in the swapchain. For
mailbox presentation mode we select tripple buffering. For V-Sync
presentation mode we select double buffering.

In future we might want to make the presentation mode and swapchain
images dynamic based on the actual action that the user is performing.
When doing action that benefit from low latency (paint cursor) we should
select mailbox, otherwise we can use fifo to reduce CPU/GPU usage and
safe some energy usage along the way. See #136923 for design task.

Pull Request: https://projects.blender.org/blender/blender/pulls/136922
2025-04-03 10:30:09 +02:00
Campbell Barton
58e971138b Cleanup: quiet warnings from clangd
Also remove spaces around field id, following our own convention.
2025-04-03 13:51:52 +11:00
Brecht Van Lommel
98b3b36411 Refactor: Build: Add bf::dependencies::eigen target
To make adding a dependeny on TBB easier.

Additional changes:
* Using LIB for libmv tests, as it now brings in includes
* Removing Eigen header listing in iTaSC

Pull Request: https://projects.blender.org/blender/blender/pulls/136865
2025-04-02 16:50:46 +02:00
Campbell Barton
90fd070c28 Cleanup: spelling in comments (make check_spelling_*) 2025-04-02 03:02:01 +00:00
Harley Acheson
8325e7f5e4 UI: Use busyButClickableCursor for MacOS Wait Cursor
MacOS is currently using one of our custom "hourglass" cursors during
busy times. This PR changes it to an OS-supplied cursor, a pointer
arrow with an animated blue spinner, meant for this purpose. Although
undocumented it has been used by many applications for many years.
Including Firefox for 11 years now.

Pull Request: https://projects.blender.org/blender/blender/pulls/136735
2025-04-02 01:30:13 +02:00
Jeroen Bakker
439a4e4687 Vulkan: Partial revert of swap chain refactor.
On Windows presenting mode mailbox would reduce lag. We might want to be
more selective on which mode to use when.
2025-04-01 16:33:31 +02:00
Jeroen Bakker
aed9f22233 Refactor: Vulkan: swapchain
This PR refactors the way how swapchains are used.

Allow scaling of the swapchain content to the actual resolution of the swapchain.
can reduce artefacts when resizing windows when supported.

When frame rate is to fast the previous implementation could use a semaphore
that were still in use, leading to unwanted stuttering on certain platforms. Waiting
when the rendering has finished (GHOST_Frame.submission_fence), before the
next image is acquired from the swap chain.

Mailbox has been disabled as it can calculate more frames then actually been
presented, leading to a lag and increased  power usage on others.

Pull Request: https://projects.blender.org/blender/blender/pulls/136603
2025-04-01 16:01:22 +02:00
Campbell Barton
00deec7c66 Cleanup: spelling in comments 2025-04-01 12:37:36 +11:00
Campbell Barton
fc8f6ee853 Cleanup: resolve ignored qualifier warning for CLANG 2025-04-01 01:01:38 +00:00
Jeroen Bakker
472cc10cea Fix #136521: Vulkan: Use mailbox present mode by default
Mailbox is lowest latency V-Sync enabled mode. Previously we selected
FIFO as that was always available and has more support when using debug
tools.

Improve the #136521 situation as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/136753
2025-03-31 11:06:08 +02:00
Campbell Barton
5d232486e6 Cleanup: minor clarifications in doc-strings for NDOF & OSKEY 2025-03-28 14:06:36 +11:00
Campbell Barton
38d9d971e5 WM: add a "Hyper" capability flag
Avoids the need to check against ghost backends.
2025-03-28 13:46:39 +11:00
Campbell Barton
460b1a805d Fix #134733: NDOF jumps when switching between applications
Window de-activation wasn't reliably clearing the NDOF motion state.

See code-comments for details.
2025-03-28 12:48:30 +11:00
Campbell Barton
403900909a GHOST/Win32: Set the window "inactive" on window de-activation
Match the behavior of other platforms by clearing the active window
when it's de-activated.

On Win32 Blender always considered the last-active window to be active
because de-activation wasn't handled.

Part of !136122, needed to fix #134733.

Co-authored-by: Kamil Galik <kgalik@3dconnexion.com>
2025-03-28 12:48:30 +11:00
Brecht Van Lommel
378b4e2ca4 Refactor: Improve image buffer save/load functions in GHOST 2025-03-27 22:31:03 +01:00
Jeroen Bakker
3885a37541 Vulkan: Initial OpenXR support
The Blender's VkInstance cannot be shared with OpenXR VkInstance. The
reason is a chicken and egg problem where OpenXR needs to be started
before Vulkan. OpenXR can add special vulkan specific requirements
(instance&device) that are only available when the user starts an OpenXR
session.

The goal implementation is to share memory between both instances using
[VK_KHR_external_memory](https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_external_memory.html) and related extensions. However this seems
to be a bridge to far as a initial step. Reason: There are not that many
samples/ guides and documentation to be found to handle the workflow that
we require. We want to do a smaller step by step approach to gain the needed
knowledge.

For that reason this PR does the most stupidest thing that can be done to
share memory between instances. Download the render result to CPU RAM share
the host pointer with the OpenXR instance which copies it to the swap chain.
Also the synchronization is done using wait idle commands.

<video src="attachments/32a0d69b-c3fa-4272-aea0-d207609afaaf" title="Screencast From 2025-03-18 11-16-17.webm" controls></video>

**Gaining knowledge**

- Experiment with `VK_KHR_external_memory_host` extension for uploading vertex buffers (not related to OpenXR).
- Import host pointer with `VK_KHR_external_memory_host`. This reduces the additional
  memcpy on OpenXR side.
- Export host pointer from Blender side from a mappable buffer.
- Replace host pointers with fd/dmabuf/winhandle
- Remove mappable buffer.

Ref #133718

Pull Request: https://projects.blender.org/blender/blender/pulls/133824
2025-03-27 16:57:51 +01:00
Gon Solo
eaee5fc658 Fix: Spelling mistake in Vulkan error print
Pull Request: https://projects.blender.org/blender/blender/pulls/136535
2025-03-26 14:25:49 +01:00
Campbell Barton
36038df7ec Unbreak build with older versions of XKB 2025-03-26 11:45:13 +11:00
Campbell Barton
5e2b421996 WM: support the "Hyper" modifier key on Linux
Add support for a 5th modifier key called "hyper",
this is a modifier supported on Wayland & X11 although
other platforms could support an additional modifier too.

Both GNOME and KDE can map CapsLock to Hyper.
Other compositors can use the XKB_DEFAULT_OPTIONS environment variable.

This allows users to have an additional modifier for their own use
that doesn't conflict with other keys.

Ref !136340
2025-03-26 10:39:55 +11:00
Miguel Pozo
078d9b4a57 Fix #136345: Win32 Error# (6): The handle is invalid
Calling wglMakeCurrent(nullptr, nullptr) without an active context
returns an error, so we always pass the device context handle.

Pull Request: https://projects.blender.org/blender/blender/pulls/136462
2025-03-25 15:41:30 +01:00
Miguel Pozo
dcaa945293 Fix: Renderdoc sessions crash on startup (WGL)
The crash regression comes from 583e2b7240.

Pass the s_sharedHGLRC directly to wglCreateContextAttribsARB instead
of using wglShareLists.
Context: https://github.com/baldurk/renderdoc/issues/1224

This doesn't only fix the recent regression, but solves all the long
standing issues with Renderdoc on Windows (F12 rendering support,
multiple windows, deferred compilation...).

(Fix suggested by @LazyDodo)

Pull Request: https://projects.blender.org/blender/blender/pulls/136140
2025-03-25 15:34:48 +01:00
Campbell Barton
debef6b78f Fix: NDOF HID mapping ignored on Unix
Changes in [0] caused NDOF support on Unix to ignore the `hid_map_`.

- Add updateButtonRAW which takes the RAW button values and maps them
  using `hid_map_` (what `updateButton` did before [0]).
- Keep the existing `updateButton` function using mapped events as
  updateButtonsBitmask & updateButtonsArray GHOST_NDOF_ButtonT ordered
  values.

[0]: c3d92f32dc
2025-03-25 06:36:52 +00:00
Campbell Barton
d513433570 Fix: NDOF assert on Unix when using NDOF as the window looses focus
Allow for the last checked time to be equal to the current time.
2025-03-25 13:31:29 +11:00
Jeroen Bakker
7e68042137 Fix: Vulkan: Advance to next swapchain semaphore
The render frame wasn't increased -> always the same semaphore was
selected. In case rendering is fast (or swapchain needs to be
recreated) it could select a semaphore that still had some pending
operations.
2025-03-24 12:48:16 +01:00