Commit Graph

2904 Commits

Author SHA1 Message Date
Jeroen Bakker
399060aa0e Merge branch 'blender-v4.3-release' 2024-10-14 15:45:34 +02:00
Jeroen Bakker
af151e89a7 Fix: Vulkan: Unguarded Access Device Queues
Multiple threads can access the same device queue from different
threads. This could happen when doing a cycles preview render, baking
eevee volume probes or generating material previews.

This PR adds a mutex around access to the device queues.

Detected when researching #128608

Pull Request: https://projects.blender.org/blender/blender/pulls/128974
2024-10-14 15:30:11 +02:00
Campbell Barton
3350eeba62 Merge branch 'blender-v4.3-release' 2024-10-12 22:48:08 +11:00
Campbell Barton
15be0030f6 Cleanup: various non-functional C++ changes
- Avoid shadowing.
- Use default functions.
- Remove unused struct member from GpencilBatchCache.
2024-10-12 22:44:19 +11:00
Campbell Barton
0cec2462cd Cleanup: remove redundant checks in Wayland drag & drop
Since #128766 was fixed, there is no need for an `in_use` check.
2024-10-10 09:14:25 +11:00
Campbell Barton
930a8b199b Merge branch 'blender-v4.3-release' 2024-10-09 22:37:38 +11:00
Campbell Barton
20756a07cd Fix #128766: crash dropping files with Wayland
Dropping files could crash ~10% of the time on some systems,
although I wasn't able to reproduce the error.

The ownership of GWL_Seat::data_offer_dnd wasn't handled correctly,
where the value could be handled by both wl_data_device_listener::leave
& drop callbacks.

Resolve by ensuring the data-offer is handled by the drop callback.
2024-10-09 22:29:16 +11:00
Campbell Barton
7dc92ab0d1 Merge branch 'blender-v4.3-release' 2024-10-09 15:36:23 +11:00
Campbell Barton
8d7c98a3c8 GHOST/Unix: always use getpwuid for home directory access
getpwuid for accessing home wasn't used when looking up the path
for older Blender versions. There is no reason for the code-paths
to differ. Use a shared utility function to access home.
2024-10-09 15:34:07 +11:00
Campbell Barton
7d33cd9877 GHOST/Wayland: reference the stable tablet-v2 API
The tablet API become stable in wayland-protocol 1.35

NOTE: this was reverted [0] because I missed adding the files to lib.
The files have been included, so use the stable API.

No functional changes expected.

[0]: c525e4db83
2024-10-08 09:37:52 +11:00
Campbell Barton
c1f18be1ba Merge branch 'blender-v4.3-release' 2024-10-07 13:05:28 +11:00
Campbell Barton
6039cb17e6 Unix: use getpwuid() to access home when the variable/tilde expand fails
This was already done in GHOST, but not BKE_appdir_folder_home.

Also null check the return value from getpwuid() as it's not
guaranteed to be non-null.
2024-10-07 13:00:56 +11:00
secext2022
528bd239f0 Fix #114210: IME fails with WLROOTS based WAYLAND compositors
Wayland text input could not switch input method.

When using an input method editor (e.g. input Chinese),
switching the input method (e.g. input English -> input Chinese)
during input text was not supported.

Resolve the issue by calling `zwp_text_input_v3_disable` every time
after receiving a `leave` event, and call `zwp_text_input_v3_enable`
every time after receive `enter` event, when text input is enabled.

Ref: !127824
2024-10-04 14:53:30 +10:00
Jonas Holzman
92d00678ac macOS: Add Image Clipboard Copy/Paste Support
This Pull Request adds support for image clipboard copy-pasting to the Image Viewer on macOS, accepting sources from both raw image data and image files.

Tracking Issue: #111404

Pull Request: https://projects.blender.org/blender/blender/pulls/126574
2024-10-01 18:32:32 +02:00
Jeroen Bakker
71b7dd8079 Vulkan: Remove core 1.2 extensions
Vulkan backend registered extensions that were already part of Vulkan
1.2 core. These extensions don't need to be registered.

Pull Request: https://projects.blender.org/blender/blender/pulls/128408
2024-10-01 13:40:13 +02:00
Kevin Chuang
9f4da19800 Vulkan: Add support for VK_KHR_fragment_shader_barycentric
This PR introduces support for the extension `VK_KHR_fragment_shader_barycentric`,
and includes a few miscellaneous improvements related to it.

1. Add support for `VK_KHR_fragment_shader_barycentric`, if the physical device
  supports it. Otherwise, gpu_BaryCoord is generated through an injected geom
  shader, like it was previously.
2. Simplify the logic of checking has_geometry_stage in vert shader.
3. Fix a potential issue of location mismatch in an injected geom shader.

Related to #127687
Resolves #126228

Pull Request: https://projects.blender.org/blender/blender/pulls/127995
2024-10-01 09:32:59 +02:00
Jason Fielder
eb3fe75392 Metal: Add support for parallel compilation and precompilation specialisation
This speeds up EEVEE startup and material compilation time.

Authored by Apple: James McCarthy
Pull Request: https://projects.blender.org/blender/blender/pulls/125657
2024-09-30 11:21:28 +02:00
Jeroen Bakker
3bec05518d Vulkan: Remove always failing extension
Since the introduction of vulkan loader in vulkan (not Blender) the
molten vk extension always leads to a failed registration. This
extension is only available when using the loader. Blender doesn't use
the vulkan loader so we should remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/128354
2024-09-30 10:14:10 +02:00
Jeroen Bakker
ecaa69f9cf Cleanup: Vulkan: Use optional extension for maintenance 4
Maintenance 4 is an optional extension, however it was added to required
extension when the extension is availble. This would also be checked
when adding it as an optional extension.

Detected when reviewing !127995

Pull Request: https://projects.blender.org/blender/blender/pulls/128353
2024-09-30 09:29:58 +02:00
Campbell Barton
381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00
Campbell Barton
840c65f442 Cleanup: spelling in comments 2024-09-25 19:24:20 +10:00
Campbell Barton
1d0f0604ac GHOST/Wayland: set cursor hand identifiers
These were added in [0] reusing the "move" cursor,
set the values to ID's used by KDE & GNOME cursor themes.

[0]: 458c60269b
2024-09-25 13:08:54 +10:00
Harley Acheson
e0352eb807 Platforms: Win32 Calm GHOST_WindowWin32 initializing Warning
Calm Warning C5038: data member 'GHOST_WindowWin32::m_debug_context'
will be initialized after... 'GHOST_WindowWin32::m_preferred_device'

Pull Request: https://projects.blender.org/blender/blender/pulls/128098
2024-09-25 01:06:19 +02:00
Jeroen Bakker
ddb2179e37 Vulkan: GPU device selection
Allows users to override the auto detection for GPU
selection. Normally the GPU selection is done by looping
over the order Vulkan provides and finding the highest
performing device based on its type (discrete, integrated,
software).

However users might have multiple discrete cards and want
to switch between them. Or developers want to validate other
GPUs without rebooting.

This PR adds the ability to override the auto detection
for the vulkan backend.

![image](/attachments/5d9198a8-af08-4eee-aa73-363edea11cd9)

**Future improvements**:
- This PR does not include a command line option. This can be added
  later for render farms.

Pull Request: https://projects.blender.org/blender/blender/pulls/127860
2024-09-23 11:18:24 +02:00
Campbell Barton
7feccafbb0 Cleanup: various non functional changes
- Use const arguments.
- Quiet unused assignment warnings.
- Use explicit cast to suppress CPPCHECK's truncLongCastReturn warning.
2024-09-23 11:20:14 +10:00
Campbell Barton
4bd0cc888e Cleanup: various non functional changes
- Reduce variable scope.
- Function style casts.
- Avoid variable shadowing.
- Quiet unused assignment warnings.
- Remove redundant call in GHOST_WindowNULL constructor.
2024-09-22 18:25:40 +10:00
Campbell Barton
0fc27c8d81 Cleanup: spelling in comments 2024-09-20 13:14:57 +10:00
Jeroen Bakker
214a47f15c Vulkan: Make Unused Attachments Optional
Windows/Intel and Apple drivers do not support dynamic
rendering unused attachments. Due to mistakes we made
this extension partly optional. Eg. the extension was
optional, but its settings were not.

This PR makes the extension fully optional. However
without the extension some drivers might make incorrect
assumptions. This should be solved when it is more clear
why some drivers are still crashing when using dynamic
rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/127839
2024-09-19 13:03:50 +02:00
Jonas Holzman
b427253a4d Obj-C Refactor: General Code Style cleanups
As part of a more general Objective-C GHOST refactor and in an effort to
modernize the macOS backend for further works, this commit cleans up the
codestyle of Objective-C files. Based off the Blender C/C++ style guide,
in addition to some Objective-C specific style changes.

Changes:
- `const` correctness, use nullptr, initializer list for simple struct
- Reduced variable scope for simple functions, removed unused variables
- Use braces for conditional statements, no else after return
- Annotate inheritted function of GHOST Cocoa classes with override and
  use `= default` to define trivial constructors
- Use #import instead of #include for Objective-C headers
    This is only for correctness. As the Objective-C #import directive
    is really just an #include with an implicit #pragma once.
- Use proper C-style comments instead of #pragma mark
    #pragma mark is an XCode feature to mark code chapters, to follow
    the Blender codestyle, and make the Objective-C code more editor
    agnostic, these were replaced with multi-line C-style comments.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126770
2024-09-19 11:37:52 +02:00
Campbell Barton
9b39b4c91c Cleanup: use const pointers/references 2024-09-15 23:14:09 +10:00
Campbell Barton
c6afb0e270 Core: remove sdlew/WITH_SDL_DYNLOAD & disable SDL by default
Disable dynamic SDL loading as well as disable SDL for release builds.

This was only used for audio output which can already use OpenAL
if there are back-ends not natively supported by Blender.

- Remove extern/sdlew/
- Remove the WITH_SDL_DYNLOAD build option.
- Remove `bpy.app.sdl.available`.

Ref !127554
2024-09-13 22:44:35 +10:00
Campbell Barton
bd606a3516 Cleanup: use switch statement mouse button checks
Warns if events button types are omitted.
Also use a define for GHOST_kButtonNum.
2024-09-13 12:32:56 +10:00
Jonas Holzman
3130f97e85 Obj-C Refactor: Use idiomatic Obj-C objects for Window/App delegates
Changes:
- Renamed `CocoaWindowDelegate` to `BlenderWindowDelegate` and
  `CocoaWindow` to `BlenderWindow` for clarity, and remove the confusion
  between `CocoaWindow` and `WindowCocoa`
- Use idiomatic Objective-C properties instead of raw instance
  variables, synthesized with the `m_` prefix instead of the default
  Objective-C `_` to be closer to the current GHOST style.
- Use idiomatic Objective-C initWith constructors instead of setter
  functions
- Function and initializer call and name adjustments

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126767
2024-09-11 11:53:59 +02:00
Harley Acheson
458c60269b UI: Hand Cursors
Add multiple "hand" mouse cursors. These are mostly needed for Mac,
which needs open, close, and pointing hand cursors. This also adds
similar for Windows, but just for completeness and testing.

Pull Request: https://projects.blender.org/blender/blender/pulls/127164
2024-09-06 19:05:59 +02:00
Jonas Holzman
73f2bdd1ed Obj-C Refactor: WindowViewCocoa refactor
Changes:
- Use macros to reduce Cocoa event forwarding boilerplate
- Use @autoreleasepool where necessary
- Use idiomatic Objective-C properties for `COCOA_VIEW_CLASS`

Style Changes:
- Use C-Style Comments
- Use braces for conditional statements
- Use Objective-C dot-notation

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126769
2024-09-06 11:15:57 +02:00
Campbell Barton
71000ebe91 Correct error in event number define 2024-09-05 11:31:47 +10:00
Campbell Barton
0f20c6ed7e Refactor: improve GHOST/Wayland pointer handling
Generate all pointer (mouse) events from the "frame" callback as this
is the intended behavior according to the wl_pointer_listener docs.

In practice it's unlikely users would notice any difference however
there are potentially subtle differences because events were previously
created before all the pointer data had been collected.

This also has some minor advantages as each frame event no longer
needs to detect if scrolling is needed and in the case of motion events:
calculate the time-stamp twice.
2024-09-05 10:45:46 +10:00
Campbell Barton
5b48e61230 Refactor: minor changes to GHOST's tablet events
- Remove "Unset" element in the enum as it's not so useful.
- Handle buttons last (in a "default" case for release builds).
2024-09-05 09:29:09 +10:00
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