Commit Graph

2866 Commits

Author SHA1 Message Date
Campbell Barton
ad00f9657b GHOST/Wayland: update the cursor scale even when hidden
When the output scale changes, the theme scale wasn't updated
when the current cursor had no surface.
2024-09-04 19:34:15 +10:00
Jonas Holzman
8b569bac0d Obj-C Refactor: Autoreleasepool and property dot-notation refactor
Autoreleasepool:
- Replace outdated `NSAutoreleasePool` `init`/`drain` mechanism with
  the modern `@autoreleasepool {}` block. Leading to simpler and
  cleaner code, and more flexible functions return placement.
- Add missing `autoreleasepool` in code.
  The rule being that in an MRR (Manual Retain-Release / non-automatic
  reference counting) environments, "Cocoa expects there to be an
  autorelease pool always available. If a pool is not available,
  autoreleased objects do not get released and you leak memory"
  (quote from Apple Dev Docs).
  As we cannot make safe assumptions about function call sites, and
  cannot rely on a main autoreleasepool like a standard Obj-C
  application, every piece of Objective-C code that calls any sort of
  Cocoa function should be wrapped in an `autoreleasepool {}` block for
  eventual internal `autorelease` call to be honored.
- Add missing `release` / `autorelease`, make correct MRR pairs

A next step would be to start transitioning the Blender Obj-C codebase
from MRR to automatic reference counting (ARC).

Dot-Notation:
- Use Objective-C dot notation to follow modern Objective-C practices,
  and provide a more familiar syntax to programmers coming from C/C++,
  (`foo.prop` instead of `[foo prop]` for access, `foo.prop = bar`
  instead of `[foo setProp:bar]` for setting).
- Exception for singleton class properties / methods
  (`[NSPasteboard generalPasteboard]` instead of
  `NSPasteboard.generalPasteboard`) and nested method calls that mix
  property and methods.
  (Example: [NSApp windowWithWindowNumber:[window_number integerValue]]`
   or `[view convertRectToBacking:[view bounds]]`)

When possible, or necessary, refactored functions were simplified or
refactored, in which case the Blender code style was applied. As such
there is some overlap with PR #126770, especially when it comes to const
correctness.

Due to the fact that these two refactors are quite interlinked, and for
easier reviewing / avoiding complicated merge conflicts, they're shipped
in a single PR.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126771
2024-09-03 11:38:32 +02:00
Campbell Barton
d19c13eb82 Cleanup: spelling & punctuation in comments 2024-09-03 12:59:37 +10:00
Jeroen Bakker
509123c877 Vulkan: Initial support for multiple windows
- Resource pools are shared between multiple swap chains to reduce
  code complexity
- Fix issue where activating a new graphical context could still leave
  the previous context rendering.
- Known issue: opening files with more windows require a redraw.

Reference: #126499
Pull Request: https://projects.blender.org/blender/blender/pulls/126961
2024-08-30 10:01:56 +02:00
Jeroen Bakker
b710194876 Cleanup: Remove unused code
Pull Request: https://projects.blender.org/blender/blender/pulls/126960
2024-08-30 09:23:01 +02:00
Nathan Vegdahl
dc2272e538 Cleanup: run make format 2024-08-29 17:46:54 +02:00
Jonas Holzman
4449fba2f3 Obj-C Refactor: Remove unsound use of const in Objective-C code
The use of `const` for Objective-C object pointer is not standard and
generally unsound. Unlike a C++ class, which has support for const and
non-const methods. An Objective-C object will still respond to mutable
selectors even if its object pointer is const, making it semantically
useless.

Another problem with const Objective-C object is that they cannot be
properly passed into other Objective-C object selectors due to type
differences. Even if that selector didn't modify the underlying object.

For consistency with general Objective-C code style guidelines, usage of
const pointer syntax (`Class *const`) were also removed.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126768
2024-08-29 15:59:07 +02:00
Campbell Barton
08d5eb8f9c Cleanup: cmake formatting 2024-08-21 23:20:34 +10:00
Campbell Barton
5a0e8317f4 Cleanup: use const vars/args 2024-08-21 19:19:38 +10:00
Campbell Barton
bf529e248a Fix #124693: Wrong cursor after saving with multiple windows on Wayland
The last set cursor of any window was being used under Wayland.
Support for per-window cursor shapes to resolve the problem.
2024-08-21 17:29:55 +10:00
Jeroen Bakker
ef3ceb3629 Vulkan: Resource Pools
This PR implements #126353; In short: keep discard list as part of swap chain images. This allows
better determination when resources are actually not in use anymore.

## Resource pool

Resource pools keep track of the resources for a swap chain image.

In Blender this is a bit more complicated due to the way GPUContext work. A single thread can have
multiple contexts. Some of them have a swap chain (GHOST Window) other don't (draw manager). The
resource pool should be shared between the contexts running on the same thread.

When opening multiple windows there are also multiple swap chains to consider.

### Discard pile

Resource handles that are deleted and stored in the discard pile. When we are sure that these
resources are not used on the GPU anymore these are destroyed.

### Reusable resources

There are other resources as well like:
- Descriptor sets
- Descriptor pools

## Open issues

There are some limitations that require future PRs to fix including:
- Background rendering
- Handling multiple windows
- Improve CPU/GPU synchronization
- Reuse staging buffers

Pull Request: https://projects.blender.org/blender/blender/pulls/126353
2024-08-19 15:37:48 +02:00
Campbell Barton
92f633e7cb Fix #105895: tiny mouse cursor with 125% fractional scaling on Wayland
This only impacted configurations that don't include large cursor sizes
which isn't so common.

However when it does happen the cursors are small enough that they're
difficult to see.
2024-08-16 22:59:41 +10:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
YimingWu
04c5a9f053 Fix #126136: Show GUI message box for unsupported GPUs on X11
On X11 windowing systems there's no `MessageBox` prompt like on
win32 that could show users that they have unsupported GPUs,
this leads to confusion to them as they typically don't open
blender from a command line so none of the messages could be
available. This patch utilizes `system->showMessageBox` to display
a GUI message box telling the user that the GPU is unsupported.

Pull Request: https://projects.blender.org/blender/blender/pulls/126220
2024-08-15 08:37:03 +02:00
Harley Acheson
13795b5df1 UI: Custom VSE Handle Cursors for Mac
Mac Platform-specific PDF cursors for VSE handle types.

Pull Request: https://projects.blender.org/blender/blender/pulls/125471
2024-07-26 17:31:25 +02:00
Campbell Barton
b73d8595bb Cleanup: add missing cursor entries for Wayland 2024-07-26 17:09:12 +10:00
Harley Acheson
459572b15f UI: Custom Windows Cursors for VSE Handles
VSE has three mouse cursors defined, WM_CURSOR_LEFT_HANDLE,
WM_CURSOR_RIGHT_HANDLE, and WM_CURSOR_BOTH_HANDLES that are currently
always using our default cursor format. This format works on all
platforms but does not support multiple sizes or antialiasing. This
PR makes these use custom cursors (created by Pablo Vazquez) on the
Windows platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/125252
2024-07-25 18:21:16 +02:00
Campbell Barton
2edc2393d2 Cleanup: spelling in comments 2024-07-25 10:17:42 +10:00
Campbell Barton
62afbbef9b Cleanup: use const variables & args, pass args by reference 2024-07-25 10:17:40 +10:00
Campbell Barton
cb8c5d77d9 Fix error in NDOF button range check
Correct error in 3da3f678eb
2024-07-24 12:49:46 +10:00
Kamil Galik
3da3f678eb GHOST/NDOF: Extend NDOF devices support on Windows
Commit adds support for new format of RawInput packets used by
3Dconnexion devices: SpaceMouse Enterprise, Keyboard Pro and Numpad Pro
specifically. This required distinguishing processing button data
delivered as a bitmask and as a numbers array.

Basically it allows for using said devices buttons in Blender including
using these buttons in shortcuts.

Changes work only for Windows. MacOS will allow only for older format
that is bitmask.

Details:

- NDOF button event values have been moved into the public GHOST_Types.h
  header and are no longer aligned to the WM event values.
  This was done so the values could be changed to match hardware/drivers
  without breaking key-maps stored in user preferences.
- Keyboard Pro and Numpad Pro buttons are not currently used because
  they don't map to any standard keyboard events.
  These could be supported, see the PR for details.

Ref: !124155
2024-07-24 12:37:08 +10:00
Campbell Barton
f85c29dc5c Cleanup: move Wayland's private window member into GWL_Window
Keep private options in one place: GWL_Window.
2024-07-22 09:58:41 +10:00
Campbell Barton
a616799607 Fix window activation on startup with Wayland & libdecor
Libdecor would attempt to activate the window before it was
known to the window manager, causing the GHOST_kEventWindowActivate
event not to be sent.

Resolve by skipping window manager activation when the window has
not yet been initialized.
2024-07-20 13:55:43 +10:00
Campbell Barton
c1deaeb57a Cleanup: quiet compiler warning with LIBDECOR disabled 2024-07-18 15:10:45 +10:00
Campbell Barton
80f0c613c0 Fix #123096: Opening & closing a window freezes Blender under Wayland
Skipping window decoration creation apparently resolves the freeze,
although I'm unable to redo this on my system.
2024-07-17 23:59:18 +10:00
Campbell Barton
84b0ccdd4b Merge branch 'blender-v4.2-release' 2024-07-15 19:42:57 +10:00
Campbell Barton
cec4531dde Fix window creation error on wayland when EGL resource allocation fails
Quickly opening & closing windows could result in an error allocating
the EGL context.

In my tests the window would be created but not display (in GNOME)
hanging for a while although Blender could be usable again after a
while. However some users report this crashing (see #123096).

Change the behavior to match X11, where failure to set the context
makes the GHOSTWindow::getValid return false.

In my tests the Blender window is created after a short delay.
This may also resolve #123096.
2024-07-15 19:41:51 +10:00
Campbell Barton
8fdb190278 Cleanup: typos in comments (duplicate words) 2024-07-14 18:55:43 +10:00
Campbell Barton
9fb0d3c3ef Cleanup: spelling in comments 2024-07-13 16:56:57 +10:00
Jeroen Bakker
5705065db1 Fix: GHOST: Incorrect check for compilation with wayland 2024-07-11 08:34:30 +02:00
Jeroen Bakker
c929e251db Fix 102994: GHOST: Fix transparent viewports
On specific platforms the viewport could be rendered transparent on
top of the OS desktop. Mesa adviced us to enable a `EGL_PRESENT_OPAQUE`
when its extension exists.

Partially fixes #102994; mesa-zink (https://docs.mesa3d.org/drivers/zink.html)
still shows transparent viewports. As this PR already improves the situation we
it will be merged.

Pull Request: https://projects.blender.org/blender/blender/pulls/124395

Pull Request: https://projects.blender.org/blender/blender/pulls/124485
2024-07-10 22:02:24 +02:00
Jeroen Bakker
a2ba481c71 Fix 102994: GHOST: Fix transparent viewports
On specific platforms the viewport could be rendered transparent on
top of the OS desktop. Mesa adviced us to enable a `EGL_PRESENT_OPAQUE`
when its extension exists.

Partially fixes #102994; mesa-zink (https://docs.mesa3d.org/drivers/zink.html)
still shows transparent viewports. As this PR already improves the situation we
it will be merged.

Pull Request: https://projects.blender.org/blender/blender/pulls/124395
2024-07-10 21:59:13 +02:00
Fermin
ad58c9eaca XR: Add passthrough support for Meta Quest devices
Uses the OpenXR extension XR_FB_PASSTHROUGH_EXTENSION_NAME,
compatible mainly with the Meta Quest family of devices.

Currently, passthrough support over OpenXR is disabled by default
in the Quest Link app, and must be manually enabled in its settings
to use this feature.

The performance of the passthrough render varies with the quality
of the connection between the headset and the PC. For better results,
connecting the headset directly through USB to the PC, or at least
connecting the PC to the local network over ethernet, is recommended.

Thanks a lot to [KISKA](https://kiska.com/)
for their support in the development of this feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/124204
2024-07-09 06:10:17 +02:00
Campbell Barton
2b88bcdd3a Merge branch 'blender-v4.2-release' 2024-07-05 20:49:38 +10:00
Campbell Barton
a796589ed1 Fix memory leak in GHOST_WindowX11::getDPIHint
XrmDatabase wasn't destroyed when it successfully found the DPI.
2024-07-05 20:33:36 +10:00
Jeroen Bakker
84cbf33b38 Vulkan: Enable multi draw indirect feature
Multi draw indirect is used by the overlay engine and can lead
to a validation error when multiple instances are drawn.

This PR enabled the feature. We expect that all our devices can handle
this feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/124141
2024-07-04 10:42:20 +02:00
Bastien Montagne
2d7f00e410 Merge branch 'blender-v4.2-release' 2024-06-26 11:50:27 +02:00
Bastien Montagne
c525e4db83 Revert "GHOST/Wayland: reference the stable tablet-v2 API"
The currently available `wayland-protocol` libraries in lib-linux_x64
repo do not appear to be advertised 1.36 (or 1.35) versions, since the
tablet protocol is not available among the stable ones.

This reverts commit 2a85eaaf16.

Pull Request: https://projects.blender.org/blender/blender/pulls/123774
2024-06-26 11:48:55 +02:00
Campbell Barton
9ee6da08ab Merge branch 'blender-v4.2-release' 2024-06-26 16:29:57 +10:00
Campbell Barton
2a85eaaf16 GHOST/Wayland: reference the stable tablet-v2 API
The tablet API become stable in wayland-protocol 1.35
2024-06-26 16:26:18 +10:00
Jeroen Bakker
a7a554479f Vulkan: Fix compilation issue macOs due to renamed variable
Pull Request: https://projects.blender.org/blender/blender/pulls/123503
2024-06-20 19:21:47 +02:00
Jeroen Bakker
76cae1c4e6 Vulkan: Dynamic rendering unused attachments
Add support for VK_EXT_dynamic_rendering_unused_attachments. Although
this is required, it needs to be registered optional for now due to
lacking support when using renderdoc.

Pull Request: https://projects.blender.org/blender/blender/pulls/123483
2024-06-20 14:47:39 +02:00
Jeroen Bakker
faf0171c36 Vulkan: Make stencil export optional
`VK_EXT_shader_stencil_export` isn't supported by NVIDIA devices.
This extension was recently added to support EEVEE PBR layer selection.

This PR makes this extension optional and selects the work around
when not supported by the physical device.

Fixes #114385

Pull Request: https://projects.blender.org/blender/blender/pulls/123470
2024-06-20 14:12:07 +02:00
Jeroen Bakker
4353b7ffba Vulkan: Remove unused code
Vulkan backend has recently switched to a render graph approach. Many
code was left so we could develop the render graph beside the previous
implementation. Last week we removed the switch. This PR will remove
most of the unused code. There might be some left and will be removed
when detected.

Pull Request: https://projects.blender.org/blender/blender/pulls/123422
2024-06-20 11:34:19 +02:00
YimingWu
ef1d5c629b Fix #123212: Support LSGT key for X11.
The LSGT (GrLess) key is not processed in X11 while it's processed in
Win32. This attempts to fix the behaviour.

Pull Request: https://projects.blender.org/blender/blender/pulls/123354
2024-06-20 08:01:43 +02:00
Campbell Barton
295ffeeb02 Merge branch 'blender-v4.2-release' 2024-06-19 19:40:18 +10:00
Campbell Barton
50bb98fba5 Fix #123339: Blender fails to build with older versions of wayland
Follow up to [0] which only addressed one of the issues.

[0]: bc7cb481da
2024-06-19 19:36:10 +10:00
Campbell Barton
033a3f09b6 Merge branch 'blender-v4.2-release' 2024-06-18 20:38:38 +10:00
Campbell Barton
bc7cb481da Fix #123339: Blender fails to build with older versions of wayland 2024-06-18 20:37:25 +10:00
Campbell Barton
08ddd98d73 Merge branch 'blender-v4.2-release' 2024-06-18 19:50:40 +10:00