Commit Graph

2974 Commits

Author SHA1 Message Date
Aki Sakurai
c551d2a819 Fix: Inverted tablet pen Y tilt on macOS
On macOS, the tablet pen Y tilt behavior is inverted; an increase in the
tilt value corresponds to tilting the device away from the user. Account
for this difference by negating the Y tilt axis in the Cocoa pen tablet
handling code.

Refs:
* 0f128fd7c5/src/plugins/platforms/cocoa/qnsview_tablet.mm (L63)
* https://source.chromium.org/chromium/chromium/src/+/main:components/input/web_input_event_builders_mac.mm;drc=0af5ffa1e4cc4cc4f818725f8fee93ec57855e4b;l=421

Pull Request: https://projects.blender.org/blender/blender/pulls/133932
2025-02-06 11:20:31 +01:00
Hans Goudey
93ab2813a7 Cleanup: Remove unnecessary "using" statements 2025-02-05 18:27:43 -05:00
Harley Acheson
3f4a1cabbf UI: On Win11 Use WM Window Decoration Styles API
On Windows 11 use the new WM Window Decoration Styles API, introduced
in ce42d92503. This will match the OS Title bar color to  that of the
main window top bar and also do similar color matching with content
in separate windows like Preferences. Note that this will not have any
effect on versions of Windows prior to 11.

Pull Request: https://projects.blender.org/blender/blender/pulls/134054
2025-02-05 17:15:35 +01:00
Campbell Barton
4669e0f1ab Fix UNIX NDOF state being start/finish during continuous motion
Logic to ensure finish events were sent wasn't working properly
because processing the events could run before the SPNAV API had
filled the event queue.

Resolve by adding a delay of 100ms, before generating a "finish" event.

For the user this caused the NDOF Guide to flicker while navigating.
2025-02-05 22:03:02 +11:00
Campbell Barton
613e34b559 Docs: cross reference progress enum for GHOST/WM API's
Note that these enums need to be kept in sync.
2025-02-05 21:53:52 +11:00
Campbell Barton
df3d1bf506 Cleanup: use const arguments & variables where appropriate 2025-02-05 14:38:56 +11:00
Campbell Barton
bc6dc89d50 Cleanup: quiet check_spelling_* warnings, use doxygen doc-strings 2025-02-05 10:29:00 +11:00
Jonas Holzman
ce42d92503 macOS: Colored Titlebar and WM Window Decoration Styles API - GSoC 2024
As part of the GSoC 2024 project "Improvements to the Blender macOS User
Interface Experience" [1], this patch implements colored titlebar window
decorations on macOS, based on the current Blender theme colors.

Additionally, this patch introduces a new WM/GHOST API for implementing
and enabling custom decoration styles on any system/desktop environment
that support customizing window decorations.

[1]: https://devtalk.blender.org/t/gsoc-2024-proposal-improvements-to-the-blender-macos-user-interface-experience/34022)

Pull Request: https://projects.blender.org/blender/blender/pulls/123982
2025-02-04 16:18:19 +01:00
Campbell Barton
95393726b0 Cleanup: quiet check_spelling_* warnings 2025-02-04 14:43:20 +11:00
Campbell Barton
ded798ba28 Fix #133921: Borderless windows on Wayland when run from VSCode
Workaround a problem where Electron overrides XDG_CURRENT_DESKTOP
by checking if an "ORIGINAL_" prefixed version of the variable.
2025-02-03 19:35:11 +11:00
Brecht Van Lommel
0d92a7f57a Cleanup: Various clang-tidy warnings in intern
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Jeroen Bakker
58003a9114 Cleanup: Vulkan: Remove non-compatible surface selection
This was useful in the beginning to ensure we supported most surface
configurations. However it seems that there are not that many surface
configurations to support.

Pull Request: https://projects.blender.org/blender/blender/pulls/133186
2025-01-17 10:34:56 +01:00
Jeroen Bakker
80ec04b4ef Cleanup: Vulkan: Use full surface format
GHOST_ContextVK used to pass only the surface texture format to
the GPU backend, it didn't pass the color space. This PR also includes
the color space.

Pull Request: https://projects.blender.org/blender/blender/pulls/133185
2025-01-17 10:28:22 +01:00
Jonas Holzman
96babd5e9f UI: Support canceling Eyedropper color picking operations
Have `eyedropper_color_sample_fl` return success, in case platform
sampling starts but is canceled (Async return on MacOS). Removes any
chance of returning black color on failures.

Pull Request: https://projects.blender.org/blender/blender/pulls/133124
2025-01-16 04:13:48 +01:00
Hans Goudey
bbc8216951 Cleanup: Formatting 2025-01-14 11:41:03 -05:00
Neko-Asakura
60a3f886c6 macOS: Use NSColorSampler for picking colors outside of the Blender window
#115187 introduced the eyedropper tool for use outside blender on macOS,
but the following issues remain:

1. Users must grant screen capture permission to blender.
2. No visual cue. (cursor icon cannot display as an eyedropper outside
   blender)
3. Users must press `Enter` to activate the picker.
4. `CGWindowListCreateImage` function has been deprecated as of macOS
   14.0

The proposed fix is to use `NSColorSampler` class to select colours
directly from onscreen content. It offers:
1. Permission free (no screen capture permission required).
2. A clear visual cue when selecting colours.

Known issue:
1. Still need press `Enter` to activate the picker.

Pull Request: https://projects.blender.org/blender/blender/pulls/131593
2025-01-14 17:20:41 +01:00
Jeff Moguillansky
75dc76bceb Vulkan: Add support for dynamic rendering local read
This will add support for `VK_KHR_dynamic_rendering_local_read` when supported.
The extension allows reading from an attachment that has been written to by a
previous command.

Per platform optimizations still need to happen in future changes. Change will
 be limited to Qualcomm devices (in a future commit).

On Qualcomm devices this provides an uplift of 16% when using shader_balls.blend

Pull Request: https://projects.blender.org/blender/blender/pulls/131053
2025-01-13 08:10:31 +01:00
Campbell Barton
61a2f7a431 Cleanup: resolve check_spelling & check_licenses warnings 2025-01-08 11:31:43 +11:00
Harley Acheson
d99d19cd22 Fix #68256: Win32 Treat AltGr Exactly as Alt Key
Windows Only. On some keyboard layouts, the right Alt key behaves as an
"AltGR" key. This key emits both right alt and left ctrl key events,
which means that it won't match keyboard shortcuts set to just Alt.
This PR, for just layouts that include AltGr, if the scancode is for
right Alt yet the virtual key is actually the control key then ignore
these key events. This treats AltGr exactly as Alt.

Pull Request: https://projects.blender.org/blender/blender/pulls/132536
2025-01-06 22:12:40 +01:00
Jeroen Bakker
818c886350 Vulkan: Timeline semaphores
This PR will add timeline semaphores to be required. It doesn't use
the timeline semaphores yet, but as multiple developments will
rely on it it is better to add the requirement.

Pull Request: https://projects.blender.org/blender/blender/pulls/132683
2025-01-06 11:44:13 +01:00
Sybren A. Stüvel
97510267f1 Cleanup: silence compiler warning about unused result of ftruncate()
`ftruncate()` is annotated such that the compiler (at least GCC 13)
warns when the returned status is not used.

This commit adds a `GHOST_ASSERT()` to check that result in debug
builds. In non-debug builds it's discarded without checking, but
explicitly as to not trigger this warning.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/132108
2025-01-06 11:29:37 +01:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Campbell Barton
1b0cef86fa Fix UNIX crash on startup when HOME isn't set
Regression in [0] which re-introduced #2931.

Accessing environment variables must always null check the result.

Resolve by checking the result as well as replacing $HOME
access with a function that falls back to `passwd::pw_dir`.

Also add code-comments to to clarify the current behavior.

[0]: b308b360eb
2025-01-02 14:46:55 +11:00
Jonas Holzman
b99497bf21 macOS: Fix path icon not being cleared when creating a new file
This commit fixes a small bug where the macOS native titlebar file path
icon (often referred to as proxy icon) wouldn't be cleared when creating
a new blank file and would instead retain its previous state. This was
caused by the GHOST setPath() function being short-circuited by the
&& operator, since `has_filepath` was false. The GHOST WindowCocoa
setPath() function was also simplified to remove unneeded exception
handling.

Pull Request: https://projects.blender.org/blender/blender/pulls/132359
2024-12-27 18:15:23 +01:00
Ray Molenkamp
a0d9826b3c Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132336
2024-12-25 23:32:15 +01:00
Harley Acheson
e0930e0173 Fix #79702: Do Not Process Character Input With Win Key
Windows Only. When the Blender active area is Text Editor, pressing
Win-L will lock the computer, and will also add an "L" to the text
editor. This is an annoyance when script editing. This PR just makes
anything entered with Win key held return nothing.

Pull Request: https://projects.blender.org/blender/blender/pulls/131638
2024-12-23 22:26:24 +01:00
Ray Molenkamp
b7407aabb5 Cleanup: CMake: Modernize bf_gpu dependencies
Pretty straightforward

- Remove any bf_gpu paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132286
2024-12-23 21:38:19 +01:00
Jeroen Bakker
398851024a Vulkan: Add support for headless rendering
Blender can be started headless. In that case GHOST will use
GHOST_SystemHeadless. This system only supported OpenGL. This change
will add support for Vulkan. For users this allows to render using
Vulkan without the need of X11 or Wayland.

This should fix the cause why Vulkan tests are crashing on build-bot. They
will not work reliable due to a threading issue which is still in investigation.

Pull Request: https://projects.blender.org/blender/blender/pulls/131682
2024-12-17 13:29:07 +01:00
YimingWu
b308b360eb Fix #131641: Use getenv for GHOST_kUserSpecialDirCaches
`GHOST_kUserSpecialDirCaches` was using `xdg-user-dir` to get home dir,
however in some linux distributions `xdg-user-dir` may not be available
by default. Thus use `getenv("HOME")` instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/131780
2024-12-13 13:56:14 +01:00
Jeroen Bakker
b8d67aa10f Vulkan: Make provoking vertex optional for MoltenVK
Provoking vertex isn't supported by Metal and MoltenVK. As it only has
some minor artefacts we make it optional when using MoltenVK.

Pull Request: https://projects.blender.org/blender/blender/pulls/131815
2024-12-13 09:56:37 +01:00
Campbell Barton
5dd67c6e1c Cleanup: sort CMake path lists 2024-12-09 09:18:50 +11:00
Jonas Holzman
720fc44ca3 GHOST: Fix X11 clipboard selection requests
This commit fixes a pretty long-standing bug in the X11 clipboard code
which caused selection target requests (and thus pasting) to sometimes
fail on certain softwares like Firefox.

The problem lied in the fact that the property format used when setting
the supported target list was dependent on the original request, when
it should always be XA_ATOM (a list of Atom), this can be seen in other
implementations, like GLFW.

This commit also cleans up the surrounding code, by using m_atom to
access atoms instead of redeclaring them in the function, which also
clears up a few instance where the difference between `xse->target`
(the request target) and `target` (the TARGETS Atom) was really unclear.

Pull Request: https://projects.blender.org/blender/blender/pulls/131507
2024-12-06 17:10:50 +01:00
Jeroen Bakker
dc6bd96eeb Fix #131315: Vulkan: Provoking vertex incorrect
In OpenGL the last vertex is the provoking vertex. In Vulkan the first
vertex is the provoking vertex. This PR uses `VK_EXT_provoking_vertex`
to use the last vertex as the provoking vertex.

Pull Request: https://projects.blender.org/blender/blender/pulls/131412
2024-12-05 11:03:29 +01:00
Jeroen Bakker
108a0f2ec0 Vulkan: Share driver check between GPU and GHOST
GPU and GHOST require to have identical checks to remove faulty drivers.
When not done GHOST can still select a device that isn't supported and
lead to freezing interfaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/131241
2024-12-02 14:50:32 +01:00
Guillermo Venegas
7f7f9e987f Fix #130817: Make resource pool to cycle when swapchain images are presented
Its not standard how `Present Engines` return images for presentation, and
currently is expected that they cycle between swap-chain images with each
`vkAcquireNextImageKHR` call.

However present engines could return any available image, that can mean
to reuse the last presented one if available. (This seem to be the behavior
using `Layered on DXGI Swapchain` the default `Present Method` used
with latest NVIDIA drivers on Windows).

Since resource pools expects to images to cycle in a sequential order, if any
present engine always return the same image for presentation only a single
resource pool would be used for each rendered frame, and since resources
are only released by cycling between resource pools, this resource pool would
overflow since it never releases any resource.

This changes makes resource pools to cycle each time a image is presented.

Pull Request: https://projects.blender.org/blender/blender/pulls/131129
2024-11-29 12:35:44 +01:00
Harley Acheson
0193579e90 UI: Win32 - Clipboard Image Paste from File Path
On the Windows platform allow pasting an image into the Image Editor
based on a filepath in the clipboard. For example, selecting "copy" on
the context menu in the file system. This checks for CF_HDROP format
and should work for all image formats we support.

Pull Request: https://projects.blender.org/blender/blender/pulls/127782
2024-11-27 23:55:18 +01:00
Jonas Holzman
9a8e9bb61b Fix #129985: macOS headless build fails due to missing CGL context symbols
When making a `headless` macOS build, linking would fail complaining
about missing `GHOST_ContextCGL` symbols, which are required by the Metal
backend. This commit fixes this issue by compiling the macOS CGL GHOST
Context if the Metal backend is enabled, instead of only depending on
`WITH_HEADLESS`, similarly to what's done on Linux/other *nix systems.

Pull Request: https://projects.blender.org/blender/blender/pulls/130847
2024-11-25 22:43:19 +01:00
Jeroen Bakker
69f94df026 Fix #130164: Vulkan: Freeze when resizing window
When resizing window some platforms could freeze. The cause was that
depending on a platform the swap chain could get out of date when
acquiring the next swapchain image or when presenting the swap chain
image to the queue.

We only covered one scenario. This PR implements the scenario to
recreating the swap chain when the image could not be acquired.

Pull Request: https://projects.blender.org/blender/blender/pulls/130909
2024-11-25 15:31:09 +01:00
Jeroen Bakker
c2695e2dcc Vulkan: Add support for legacy platforms
Dynamic rendering is a Vulkan 1.3 feature. Most platforms have support
for them, but there are several legacy platforms that don't support dynamic
rendering or have driver bugs that don't allow us to use it.

This change will make dynamic rendering optional allowing legacy
platforms to use Vulkan.

**Limitations**

`GPU_LOADACTION_CLEAR` is implemented as clear attachments.
Render passes do support load clear, but adding support to it would
add complexity as it required multiple pipeline variations to support
suspend/resume rendering. It isn't clear when which variation should
be used what lead to compiling to many pipelines and branches in the
codebase. Using clear attachments doesn't require the complexity
for what is expected to be only used by platforms not supported by
the GPU vendors.

Subpass inputs and dual source blending are not supported as
Subpass inputs can alter the exact binding location of attachments.
Fixing this would add code complexity that is not used.

Ref: #129063

**Current state**

![image](/attachments/9ce012e5-2d88-4775-a636-2b74de812826)

Pull Request: https://projects.blender.org/blender/blender/pulls/129062
2024-11-19 16:30:31 +01:00
Jeroen Bakker
1a6c586e81 Vulkan: Use Vulkan 1.1 feature enablement
Shader draw parameters was enabled by query-ing the extension. The
feature is core in Vulkan 1.1, and our minimum requirement is Vulkan
1.2. In stead of querying the extension we should use enable the
feature via `VkPhysicalDeviceVulkan11Features`.

This was detected when working on !129062

Pull Request: https://projects.blender.org/blender/blender/pulls/130441
2024-11-18 15:11:42 +01:00
Jacques Lucke
64a9260921 Core: remove WITH_CXX_GUARDEDALLOC option
This implements the proposal from #124512. For that it contains the following
changes:
* Remove the global override of `new`/`delete` when `WITH_CXX_GUARDEDALLOC` was
  enabled.
* Always use `MEM_CXX_CLASS_ALLOC_FUNCS` where it is currently used. This used
  to be guarded by `WITH_CXX_GUARDEDALLOC` in some but not all cases. This means
  that a few classes which didn't use our guarded allocator by default before,
  are now using it.

Pull Request: https://projects.blender.org/blender/blender/pulls/130181
2024-11-13 13:39:49 +01:00
Jonas Holzman
263212c4fa Merge branch 'blender-v4.3-release' 2024-11-09 01:35:36 +01:00
Jonas Holzman
574e08272c Cleanup: make format 2024-11-09 01:33:16 +01:00
Jonas Holzman
13c31f3912 Fix #129424: macOS Image Editor Copy/Paste upside down
This commits fixes a bug where the new macOS Image Editor image copy
paste feature was correctly pasting images from macOS to Blender, but
wrongly copying image from Blender to other software upside-down.
This was fixed by porting the row inversion logic present in
GHOST_SystemCocoa::getClipboardImage to the putClipboardImage function.

Pull Request: https://projects.blender.org/blender/blender/pulls/129938
2024-11-09 01:30:03 +01:00
Jonas Holzman
5b30f82d2c Fix #129424: macOS Image Editor Copy/Paste upside down
This commits fixes a bug where the new macOS Image Editor image copy
paste feature was correctly pasting images from macOS to Blender, but
wrongly copying image from Blender to other software upside-down.
This was fixed by porting the row inversion logic present in
GHOST_SystemCocoa::getClipboardImage to the putClipboardImage function.

Pull Request: https://projects.blender.org/blender/blender/pulls/129938
2024-11-08 23:28:53 +01:00
Campbell Barton
e46c58df7c Merge branch 'blender-v4.3-release' 2024-11-02 15:44:22 +11:00
Campbell Barton
99387c0749 Cleanup: spelling in comments, docs & error 2024-11-02 15:43:27 +11:00
Campbell Barton
650acfd167 Merge branch 'blender-v4.3-release' 2024-11-02 15:27:53 +11:00
Campbell Barton
d9badb73ca GHOST/SDL: map the GrLess key 2024-11-02 15:10:05 +11:00
Clément Foucault
47f7aaa2cc Merge branch 'blender-v4.3-release' 2024-11-01 12:16:38 +01:00