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
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.
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.
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
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.
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
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 #127687Resolves#126228
Pull Request: https://projects.blender.org/blender/blender/pulls/127995
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
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
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.

**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
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
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
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
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
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
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
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.
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
- 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
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
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
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.