Commit Graph

2614 Commits

Author SHA1 Message Date
Ray molenkamp
4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044edbd8e8d524db3d02768c4a52f5274be
a670b53abe82f7a36d2caa0d8ae2c67c2bc8c39a
0f541db97c47e5fcd1c71160d71642235d9ea743
be516e8c814dbf7bc43ea91c6913be9f7f96e006
3e88a2f44c413fa7f671f638409a975d59f8c1fb
4e64b772f5ed8f352c2744baece802f70e2430e7
9547e7a317d6f86ab8fbfb3d440f127c2ab75df2
07fe6c5a57d7bcf89318204c0319db1f4a2f5cbd

The problematic commit was 07fe6c5a57d7bcf89318204c0319db1f4a2f5cbd
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Campbell Barton
530ee6e7fa Cleanup: make class doc-strings directly above classes
In some cases it wasn't clear if a comment before a class was meant
to be it's doc-string. Remove blank lines between the class & it's
doc-string.
2023-07-25 14:11:42 +10:00
Ray Molenkamp
0f541db97c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any clog 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/110350
2023-07-21 18:37:30 +02:00
Campbell Barton
08f4f1f41e Cleanup: spelling in comments, capitalize tags 2023-07-20 09:42:00 +10:00
Clément Foucault
cdb8a8929c GHOST: Delete Mac OpenGL support
The maximum OpenGL versions supported on mac
doesn't meet the minimum required version (>=4.3) anymore.

This removes all the OpenGL paths in GHOST
Cocoa backend and from the drop down menu in
the user preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/110185
2023-07-19 14:16:03 +02:00
Jeroen Bakker
567d992a69 Cleanup: Silence Compilation Warnings in GHOST
Pull Request: https://projects.blender.org/blender/blender/pulls/110260
2023-07-19 12:59:49 +02:00
Campbell Barton
29c2e71d1f Cleanup: quiet warnings 2023-07-18 14:18:06 +10:00
Clément Foucault
8191b152ec GHOST: Guard GL context creation behind WITH_OPENGL_BACKEND
Even if not currently needed, it should be possible to compile
without OpenGL.

Also make sure the logic is similar for all GHOST implementations.

Pull Request: https://projects.blender.org/blender/blender/pulls/110165
2023-07-16 19:58:10 +02:00
Clément Foucault
3478093183 GHOST: Bump OpenGL minimum version to 4.3
This removes the GL 3.3 fallback because default viewport engine
now require some features only present in GL 4.3.
Blender now also check for GL version 4.6 instead of 4.5 in some
cases.

Note that this does not remove the OpenGL support on Apple
hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/109390
2023-07-15 15:31:40 +02:00
Campbell Barton
3889baab4f Cleanup: spelling in comments 2023-07-15 15:54:55 +10:00
Harley Acheson
65e8b21a95 Fix #109525: Improved Win32 Repeat Key Filtering
Allows Win32 key repeat filtering to support multiple simultaneously
repeating keys, as can happen with modifiers. Removes
m_keycode_last_repeat_key and instead checks current down status.

Pull Request: https://projects.blender.org/blender/blender/pulls/109991
2023-07-12 20:55:00 +02:00
Germano Cavalcante
75658109be Fix #109630: Grave and Single Quote keys not being detected on MacOS
The `UCKeyTranslate` function was being used wrong.

The `deadKeyState` param should use `kUCKeyTranslateNoDeadKeysMask`
instead of `kUCKeyTranslateNoDeadKeysBit` (optionally could also use
`(1 << kUCKeyTranslateNoDeadKeysBit`)).

This commit also dispenses with accessing the keyAction, as this is not
crucial for determining the key.

Comments have also been added to better describe the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/109987
2023-07-12 20:06:43 +02:00
Harley Acheson
b7a119c785 Fix #40059: Use Modifier Keys Between Windows on Win32
Use modifier keys that are pressed before activating a new window.
Allows call of `wm_window_update_eventstate_modifiers` on
`GHOST_kEventWindowActivate` by using `GetAsyncKeyState` instead of
`GetKeyState` in GHOST_SystemWin32::getModifierKeys, which retrieves
actual hardware state.

Pull Request: https://projects.blender.org/blender/blender/pulls/110020
2023-07-12 20:01:37 +02:00
Ray Molenkamp
1058fd1b2b Ghost: Fix build error with MSVC 17.7 preview 3
the initialization of m_pkts with an int threw an error with
17.7P3 since it decided int -> uint64_t required a narrowing
conversion. Not sure why it got picky here all of a sudden
but given it's not wrong, we may as well fix it properly.

This change changes the queueSize parameter to size_t and
adds a bounds check at the calling site to ensure the value
it gets will be positive before casting.
2023-07-12 09:32:35 -06:00
Harley Acheson
30d44548e3 Fix #109886: Win32 AutoFocus Between Main Windows
Allow auto-focusing between multiple parent (main) windows when they
are immediately adjacent.

Pull Request: https://projects.blender.org/blender/blender/pulls/109946
2023-07-11 21:13:50 +02:00
Clément Foucault
40f89d23cb GHOST: Fix OpenGL backend isolation on Linux
This makes sure you can compile without the
WITH_OPENGL_BACKEND option.
2023-07-11 11:32:45 +02:00
Clément Foucault
1978b4fc92 GHOST: Replace WITH_OPENGL build option
Replaces it by WITH_OPENGL_BACKEND and cleanup its usage.
Limits visibility of opengl enums and cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/109947
2023-07-11 09:17:31 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Guillermo Venegas
751db88748 Fix #109532: Added missing conversion from wl_fixed to int in Wayland
When blender is not focused and a selection is executed
with the mouse, since there is no conversion from `wl_fixed` to `int`,
the bounds of the selection can cause the selection box to be too large,
causing `draw_select_framebuffer_depth_only_setup` to fail when create
`g_select_buffer.texture_depth`.

Ref !109834
2023-07-09 16:57:37 +10:00
Campbell Barton
d7cfa51e49 Cleanup: declare const variables 2023-07-07 16:00:50 +10:00
Jeroen Bakker
4731beec99 Cleanup: Remove unused code in GHOST_ContextCGL
GHOST_ContextCGL used an incorrect compiler directive. When reading
the comment we could also remove it. In order to do the right thing
(fixing directive vs removing code) we opened this pull request to
ask feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/109686
2023-07-06 13:04:18 +02:00
Sergey Sharybin
bad41885db Cleanup: Mark unused function arguments as such
A lot of such cases got discovered since recent change to CLang's
compiler flags for C++.

Pull Request: https://projects.blender.org/blender/blender/pulls/109732
2023-07-05 12:02:06 +02:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Campbell Barton
39cafb43d3 Cleanup: remove unnecessary use of strncpy 2023-07-05 13:58:02 +10:00
Campbell Barton
69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Campbell Barton
35389e8b35 Cleanup: use const qualifier for arguments & variables 2023-06-29 10:56:33 +10:00
Campbell Barton
d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Campbell Barton
0fdc84fcdd Cleanup: remove incorrect/unhelpful comments 2023-06-28 12:17:06 +10:00
Campbell Barton
0f3b691c22 Fix dropping files onto the window under Wayland in some cases
Dropping files from gnome-web onto Blender failed because the
URL data didn't end with a newline.
2023-06-28 00:18:00 +10:00
Campbell Barton
69d92bd3de Cleanup: remove strcpy usage
Remove strcpy use in:

- bone_autoside_name
- BLI_string_flip_side_name
- datatoc_icon utility.
- RNA define error messages.
- RNA UI registration.
- extern/xdnd.
2023-06-20 13:26:38 +10:00
Campbell Barton
8bcad285de Cleanup: remove strcpy usage 2023-06-19 20:40:49 +10:00
Jeroen Bakker
bc6027ebaf Vulkan: Initial/Final Renderpass Layout
Until now the initial renderpass layout wasn't set, resulting
in errors/warnings when using the renderpass. This PR sets the
initial and final renderpass to general so the code knows what
to expect.

In future this needs to be designed better as the layout will
change when used in as a framebuffer attachment, or presenting
on the screen.

Pull Request: https://projects.blender.org/blender/blender/pulls/109000
2023-06-15 08:39:35 +02:00
Campbell Barton
49594c37ae License headers: use SPDX-FileCopyrightText for CMake files 2023-06-14 23:36:23 +10:00
Campbell Barton
a2c6371e3e License headers: use SPDX-FileCopyrightText in intern/ghost 2023-06-14 17:42:15 +10:00
Jeroen Bakker
2ee2ae93fb Vulkan: Initial Cube(Array) Support
This PR adds initial cube (array) support. Depending on how the texture
is used a different image view is created. When used as a framebuffer
attachment only a single side of the cubemap is attached. The image
view is attached as a 2d texture array. When used as a shader resource
the image view is a cubemap.

Also adds test cases to test both scenarios.

Pull Request: https://projects.blender.org/blender/blender/pulls/108794
2023-06-09 16:09:54 +02:00
Brecht Van Lommel
a2bd080cf3 Cleanup: renaming of GPU contexts for clarity
* opengl_context -> system_gpu_context. This is the operating system OpenGL,
  Metal or Vulkan context provided by GHOST.
* gpu_context -> blender_gpu_context. This is the GPUContext provided by
  the Blender GPU module, which wraps the GHOST context and adds some state.
* Various functions create/destroy/enable/disable both contexts, these have
  just gpu_context in the name now.

Pull Request: https://projects.blender.org/blender/blender/pulls/108723
2023-06-08 15:46:53 +02:00
Campbell Barton
989b5de8e9 Cleanup: remove unused window states, add doc-strings
Note that the GHOST_TWindowState is stored in DNA & that
values shouldn't be changed.
2023-06-08 10:32:00 +10:00
Campbell Barton
f31dfa9b74 Merge branch 'blender-v3.6-release' 2023-06-06 09:49:06 +10:00
Campbell Barton
dd1fe31a74 Cleanup: quiet compiler warnings 2023-06-06 09:34:50 +10:00
Campbell Barton
e27bcb6e3e Cleanup: remove redundant struct qualifier 2023-06-04 19:27:38 +10:00
Campbell Barton
b2950b2ad7 Fix saving a quit.blend on exit when a file failed to load
When a file passed in from the command line failed to load,
blender would exit & save the quit.blend.

Resolve by adding a `do_user_exit_actions` to WM_exit_ex which is
false in backgrounds mode or when an error has occurred.

---

Back-ported [0] & [1] from main with fix [2] included.

[0]: c803ddab29451addcf6378dea8c062b13c507d72
[1]: d7d1c524e3dc1ac17577bb262ec033db8ae1b8f3
[2]: d3d91b79e0a7d4c083dfb627b3e715fb293efc21
2023-05-31 12:35:22 +10:00
Harley Acheson
de10126b1f Fix: Build Warning of Unused Variable
Removing unused variable in GHOST_SystemWin32.cc

Own code, introduced in #108397
2023-05-30 08:54:28 -07:00
Campbell Barton
d7d1c524e3 Cleanup: pass the exit-code to WM_exit
Callers to WM_exit needed to set G.is_break for a predictable exit-code.
This is error prone as G.is_break may be set based on the user having
pressed escape during event handling.

Instead, pass the exit code as an argument.
2023-05-30 12:55:10 +10:00
Harley Acheson
c3b58b5f67 Fix #108356: Group Console with App on Taskbar
Set App Id for the process so our console is grouped on the Task Bar.

Pull Request: https://projects.blender.org/blender/blender/pulls/108397
2023-05-29 23:19:12 +02:00
Harley Acheson
e99a2fb61c Merge branch 'blender-v3.6-release' 2023-05-27 18:45:35 -07:00
Harley Acheson
1b7c6cf150 Windows: Do not auto-focus from our console
Although auto-focus only works between a single Blender instance's
child windows, this does include our own console and we don't want
that. Luckily fixing this only requires a single check for null -
because GetFocus() returns null to us for our console.

Pull Request: https://projects.blender.org/blender/blender/pulls/108362
2023-05-28 03:42:13 +02:00
Christoph Lendenfeld
074abff87e Merge branch 'blender-v3.6-release' 2023-05-26 17:02:35 +02:00
Jason Fielder
9e83211b8d Fix: Implement shared Metal Command queue to resolve sync bugs
Previously, each GHOST Context instantiated its own Metal device
queue. Commands are only synchronized within a queue, this was the
root cause of a number of flickering issues which had previously
been worked-around with synchronization primitives.

New solution uses a shared queue to simplify dependencies and
alleviate possibility of stalls and bugs when resources are modified
or shared across separate GPU command queues.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108223
2023-05-26 16:00:20 +02:00
Harley Acheson
9cf77efaa0 UI: Updated Windows File Registration
Windows file associations using ProgID, needed because of the launcher.
This fixes "pin to taskbar" and Recent Documents lists, allow per-
version jump lists and an "Open with" list with multiple versions.

Pull Request: https://projects.blender.org/blender/blender/pulls/107013
2023-05-24 21:19:56 +02:00
Campbell Barton
13c815085b Cleanup: spelling in comments 2023-05-24 11:21:18 +10:00
Jeroen Bakker
4997748e5e Vulkan: Select Compatible Render Surface
In previous implementation the first available render surface was
selected. For NVIDIA platform this was the correct one, but for
AMD and Intel GPUs this was incorrect. This PR goes over all the
available render surfaces and selects a compatible one.

For now when no compatible render surface is found it will still select
the first available one. With the expectation that the screen is drawn
incorrectly and users would report a bug so we can investigate.

Pull Request: https://projects.blender.org/blender/blender/pulls/108169
2023-05-23 11:03:53 +02:00
Sergey Sharybin
793446cbdc BLI: Replace some macros with inlined functions for C++
Covers the macro ARRAY_SIZE() and STRNCPY.

The problem this change is aimed to solve it to provide cross-platform
compiler-independent safe way pf ensuring that the functions are used
correctly.

The type safety was only ensured for GCC and only for C. The C++
language and Clang compiler would not have detected issues of passing
bare pointer to neither of those macros.

Now the STRNCPY() will only accept a bounded array as the destination
argument, on any compiler.

The ARRAY_SIZE as well, but there are a bit more complications to it
in terms of transparency of the change.

In one place the ARRAY_SIZE was used on float3 type. This worked in the
old code because the type implements subscript operator, and the type
consists of 3 floats. One would argue this is somewhat hidden/implicit
behavior, which better be avoided. So an in-lined value of 3 is used now
there.

Another place is the ARRAY_SIZE used to define a bounded array of the
size which matches bounded array which is a member of a struct. While
the ARRAY_SIZE provides proper size in this case, the compiler does not
believe that the value is known at compile time and errors out with a
message that construction of variable-size arrays is not supported.

Solved by converting the field to std::array<> and adding dedicated
utility to get size of std::array at compile time. There might be a
better way of achieving the same result, or maybe the approach is
fine and just need to find a better place for such utility.

Surely, more macro from the BLI_string.h can be covered with the C++
inlined functions, but need to start somewhere.

There are also quite some changes to ensure the C linkage is not
enforced by code which includes the headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/108041
2023-05-23 09:21:45 +02:00
Campbell Barton
57f593b7ca Merge branch 'blender-v3.6-release' 2023-05-21 13:50:45 +10:00
Campbell Barton
047ff43ee4 Fix GHOST/Wayland configuring an XDG surface before it was handled
xdg_surface_ack_configure must run once the events have been handled
which is not the case configure runs from the event handling thread.

In practice this could lead to glitches resizing windows, although some
flickering on startup remains on KDE which would be good to resolve.
2023-05-21 13:47:56 +10:00
Campbell Barton
3a286a735f Merge branch 'blender-v3.6-release' 2023-05-19 19:56:20 +10:00
Campbell Barton
c007e6a346 Fix occasional crash on exit under Wayland
pthread_cancel was sometimes called once the thread had exited,
resolve this by having the function wait to be canceled.
2023-05-19 19:51:42 +10:00
Campbell Barton
9af19822f0 Merge branch 'blender-v3.6-release' 2023-05-19 16:27:42 +10:00
Campbell Barton
2ce7f3ec71 Fix crash on exit under Wayland with multiple windows open
Exiting with multiple overlapping windows (a file selector for e.g.)
reliably crashes.

Closing the windows on exit caused the the keyboard enter handler to be
called with a NULL window surface (wl_surface).

While this doesn't look to be documented anywhere, SDL's code-comments
note this happens when windows have just been closed.
GTK also check surfaces for NULL.
2023-05-19 16:25:56 +10:00
Campbell Barton
3db0bde21d Merge branch 'blender-v3.6-release' 2023-05-19 15:14:27 +10:00
Campbell Barton
2eaacbaa3f Fix memory leak on exit under GHOST/Wayland 2023-05-19 15:10:51 +10:00
Sergey Sharybin
406cfd214a Refactor ImBuf buffer access
The goal is to make it more explicit and centralized operation to
assign and steal buffer data, with proper ownership tracking.

The buffers and ownership flags are wrapped into their dedicated
structures now.

There should be no functional changes currently, it is a preparation
for allowing implicit sharing of the ImBuf buffers. Additionally, in
the future it is possible to more buffer-specific information (such
as color space) next to the buffer data itself. It is also possible
to clean up the allocation flags (IB_rect, ...) to give them more
clear naming and not have stored in the ImBuf->flags as they are only
needed for allocation.

The most dangerous part of this change is the change of byte buffer
data from `int*` to `uint8_t*`. In a lot of cases the byte buffer was
cast to `uchar*`, so those casts are now gone. But some code is
operating on `int*` so now there are casts in there. In practice this
should be fine, since we only support 64bit platforms, so allocations
are aligned. The real things to watch out for here is the fact that
allocation and offsetting from the byte buffer now need an explicit 4
channel multiplier.

Once everything is C++ it will be possible to simplify public
functions even further.

Pull Request: https://projects.blender.org/blender/blender/pulls/107609
2023-05-18 10:19:01 +02:00
Campbell Barton
a9358f5274 Fix Blender failing to start in Gnome when X11 isn't available
Only make libdecor a hard-requirement for using Wayland in gnome-shell
when X11 is available, as it's possible to disable Xwayland.

This also fixes window-borders not being used in gnome-shell when
WITH_GHOST_X11 is off.

Now it's possible to test Blender under gnome without libdecor by
uninstalling libdecor & running with DISPLAY environment variable
set to an empty string - useful for troubleshooting issues which
could be caused by libdecor.
2023-05-18 09:33:46 +10:00
Jeroen Bakker
b029db5461 Vulkan: AMD Swapchain
This PR enabled the swapchain to be used with AMD GPUs.
The issue is that we had to separate the swapchain into
2 functions and therefore the rendering is also not
controlled at the same time.

Semaphores were finished, before being used and the
driver stalled when waiting for those Semaphores.

This doesn't solve the issue that renderdoc can still
crash the graphics driver.

Pull Request: https://projects.blender.org/blender/blender/pulls/107840
2023-05-11 14:29:38 +02:00
Jeroen Bakker
6a20b0022c Vulkan: Swap Chain
This PR replaces the previous implementation of the swap chain.
The previous implementation was based on a gaming loop where
inside a single function an image is requested, the drawing occurs
and the requested image is presented on screen.

In blender the drawing isn't controlled in a single function and
this approach lead to freezes, missing frames and other
artifacts.

This approach is not be the final approach but a step into a
direction where the acquiring of the next image in the swap chain
is separated from the swapping.

Pull Request: https://projects.blender.org/blender/blender/pulls/107740
2023-05-11 12:51:05 +02:00
Jeroen Bakker
f428fd8229 Vulkan: Share Device Between Contexts
Previous GHOST_ContextVK would create a logical device for each
context. Blender uses multiple contexts at the same time and wasn't able
to share resources between them as the logical device where different.

This patch will create a single logical device and share them between
multiple contexts. This allows sharing memory/shaders between contexts
and make sure that all memory allocations are freed from the device it
was allocated from.

Some allocations in Blender are freed when there isn't a context, this
was failing in the previous implementation. We didn't noticed it before
as we didn't test multiple contexts.

This patch also moves device specific data structures from VKContext to
VKDevice like the descriptor pools, debug layers etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/107606
2023-05-04 10:06:48 +02:00
Campbell Barton
a0db0a5580 Cleanup: move comments wrapped with MultiLine control statements
In some cases comments at the end of control statements were wrapped
onto new lines which made it read as if they applied to the next line
instead of the (now) previous line.

Relocate comments to the previous line or in some cases the end of the
line (before the brace) to avoid confusion.

Note that in quite a few cases these blocks didn't read well
even before MultiLine was used as comments after the brace caused
wrapping across multiple lines in a way that didn't follow
formatting used everywhere else.
2023-05-02 09:54:48 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Campbell Barton
46316b29dc GHOST/Wayland: remove keyboard modifier mismatch warning suppression
Detecting when to show warnings about GHOST/XKB modifier
mismatches was rather involved, remove the check as it's
unnecessary for Gnome-Shell >= v43.

Older versions of Gnome-Shell will show warnings on window activation
with modifier keys held.
2023-05-01 11:57:45 +10:00
Campbell Barton
4efacf7e85 GHOST/Wayland: use GHOST modifiers, not XKB without an active windows
Reading modifiers from XKB caused a complications in getModifierKeys(..)
when called on a window that was activated, before the keyboard enter
handler had run - because the keys held by GHOST had not yet been
updated by XKB. This caused a problem which Gnome-shell which runs
the keyboard-enter handler after window activation.

This change would have fixed the Super key being stuck, see: #107314.
Keep the previous fix since in the unlikely case GHOST & XKB get out of
sync, stuck modifier keys should still be prevented.

This change means the warning for GHOST & XKB getting out of sync
can be enabled for Gnome-shell again, as it was previously suppressed
as it happened frequently on window activation.
2023-05-01 11:57:13 +10:00
Campbell Barton
7b8ba7f101 Fix #107314: OS key stuck when switching windows with GNOME/Wayland
Tapping the OS key to switch windows could cause the OS key to stick.

On window deactivation the OS key was considered held, activating the
window later read the XKB modifier state before the keyboard_enter &
keyboard_modifier callbacks had run.

When they ran later, the mis-match between XKB and GHOST was not taken
into account, causing the OS key to stick.
2023-04-28 16:06:37 +10:00
Jeroen Bakker
26147b29a7 Vulkan: Construct a Vulkan 1.2 Context.
Apparently we always constructed a Vulkan 1.0 Context, although we
are targetting Vulkan 1.2. This also lead to incorrect expectations
when using the Vulkan Memory allocator.

Pull Request: https://projects.blender.org/blender/blender/pulls/107300
2023-04-24 15:32:17 +02:00
AgAmemnno
bebb17a973 Vulkan: Provide Debug Utilities
This PR uses the VK_EXT_debug_utils extension, but it's only for labeling, so it doesn't rely on the VK_LAYER_KHRONOS_validation functionality.

The functions that do these things are loaded into the runtime as vulkan extensions.

Declare the function pointers in a struct and make them members of vk_context.

Pull Request: https://projects.blender.org/blender/blender/pulls/106098
2023-04-21 12:32:40 +02:00
Campbell Barton
54ce0ac922 Cleanup: use const variables when reading X11 events 2023-04-21 09:12:31 +10:00
Campbell Barton
62806012ed Cleanup: resolve uninitialized members in GHOST Window & SystemX11
While this didn't cause bugs, initialize members to avoid problems
in the future.

GHOST::SystemX11
- m_keyboard_vector
- m_keycode_last_repeat_key

GHOST::Window
- m_cursorGrabInitPos
- m_userData
2023-04-21 09:06:25 +10:00
Brecht Van Lommel
13d30b0481 Cleanup: fix various warnings on Windows
Ensure windows.h is included before some other headers to avoid
redefining macros.

Pull Request: https://projects.blender.org/blender/blender/pulls/107189
2023-04-20 20:46:13 +02:00
Ankit Meel
f04a7a07e3 macOS: Add open files to system recent files
Completes the TODO in GHOST_SystemPathsCocoa::addToSystemRecentFiles
Also renames the filename parameter to the more appropriate filepath.

The recently opened/saved file will now also show up in:
- Blender Dock icon > Right click.
- Three finger swipe down in Open Blender i.e., App Expose

Based on a earlier contribution by @jenkm.

Pull Request: https://projects.blender.org/blender/blender/pulls/107174
2023-04-20 23:53:08 +05:30
Campbell Barton
335d32153e Cleanup: remove dead code, reduce variable scope 2023-04-20 13:57:31 +10:00
Campbell Barton
62cc09f267 Cleanup: match argument names between functions & declarations 2023-04-20 13:52:58 +10:00
Campbell Barton
b132118f89 Cleanup: balance doxygen grouping, minor grouping adjustment 2023-04-19 09:02:21 +10:00
Mateusz Albecki
0fd14d659b GHOST/Wayland: Fix disposeContext with VK
During createOffscreenContext with VK backend enabled wl_surface
was not stored in the context's user data. This resulted in nullptr
dereference later on during disposeContext. Added a line that sets
user data and additionally added nullptr checks in disposeContext.

Ref !107057.
2023-04-19 07:44:06 +10:00
Dalai Felinto
664b31ea73 Cleanup: make format 2023-04-18 09:45:01 +02:00
Campbell Barton
e78c3c9d96 Docs: comments for disabling the front-buffer & view3d offset correction
Expand on why front-buffer support is always disabled on Wayland &
why viewport orbit around selection offset correction isn't used for
perspective views.
2023-04-17 12:27:34 +10:00
Harley Acheson
de7e3454fb UI: Capabilities Flag for Clipboard Image copy/paste
This adds an WM_capabilities_flag to indicate that a platform
implements support for copying and pasting images using a shared
clipboard.

Pull Request: https://projects.blender.org/blender/blender/pulls/106990
2023-04-16 21:04:55 +02:00
Campbell Barton
e1571cb105 Cleanup: correct terms, spelling in comments 2023-04-16 20:41:22 +10:00
Campbell Barton
6cc2c16d06 Fix #106264: Color picker broken with Wayland & AMD GPU
- Use off-screen drawing when reading from the front-buffer isn't
  supported.

- Add a capabilities flag for reading the front-buffer which is always
  disabled on WAYLAND.

- Add GPU_offscreen_read_pixels_region, used for reading a sub-region of
  an off-screen buffer - use for color-picking a single pixel.
2023-04-16 20:16:54 +10:00
Harley Acheson
39bcf6bdc9 UI: Allow Clipboard Copy/Paste Images
Adds operators to copy and paste to and from the OS clipboard, but only
implemented for Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/105833
2023-04-14 03:48:17 +02:00
Ankit Meel
ed4374f089 Fix #66722: file doesn't open if app not focused
After double clicking a file, user can click on a different app and
Blender will lose focus. Then it stays on splash screen. So fetch any
window instead of relying on active one to open the file.

pull request #106769
2023-04-13 10:48:29 +05:30
Campbell Barton
0a270e3513 Revert "GHOST/Wayland: avoid up-scaling window content"
This reverts commit 4fe26856152304350930dbeebc31521aa31f0f9f.

Always use the preferred_scale requested by the compositor as this
did not work so well in the intended use case (where the low resolution
monitor text was scaled down and difficult to see).

After discussion with @ZedDB, revert this change since there are cases
where either functionality might be preferred - to ensure Blender's UI
is visible on a low resolution mirrored projector for e.g.

Changing the behavior of the preferred scale makes most sense in the
compositor, instead of controlling it on a per-application basis.
2023-04-13 13:14:24 +10:00
Campbell Barton
28a8a3c086 Fix crash on startup under the RIVER Wayland compositor
Defer acting on the tag to update scale as it caused the window
to use the wrong scale on startup & exit.

GTK/KDE applications seem to postpone updating scale so use this by
default as glitches with scale tend to be caused by updating the scale
too frequently instead of not quickly enough.
2023-04-12 15:54:06 +10:00
Campbell Barton
ddb6928882 GHOST/Wayland: resize the EGL buffer & change surface scale immediately
There is no need to postpone these operations when configuring the frame
only postpone committing the surface change.

Deferring these operations caused flickering when moving windows
between monitors of different scale on both GNOME & KDE.
2023-04-12 15:54:06 +10:00
Campbell Barton
c6d6869171 GHOST/Wayland: suppress EGL_BAD_SURFACE error on exit
Freeing ContextEGL would attempt to free the context's EGLSurface,
which was already freed by the native-window, causing 2x bad-surface
errors on exit.

Suppress the warning by clearing the surface from releaseNativeHandles
when the surface was created by a native window.
2023-04-12 13:12:01 +10:00
Campbell Barton
ccea39b538 Cleanup: spelling in comments 2023-04-12 11:24:10 +10:00
Campbell Barton
17e2862603 Fix new windows on Hi-DPI monitors having incorrect size under Wayland
Updating the buffer scale increased the window size based on the
previous window scale. Since the previous scale (DPI) newly created
windows restored from a `.blend` file isn't known, don't scale the
window size when updating the window's scale for the first time.
2023-04-11 16:05:27 +10:00
Campbell Barton
4fe2685615 GHOST/Wayland: avoid up-scaling window content
When a window overlaps multiple outputs, always use the resolution
on the output with the highest resolution. This means Blender never
shows low resolution content up-scaled.
2023-04-11 16:00:59 +10:00
Campbell Barton
f50c319a4b GHOST/Wayland: refactor window scaling logic
Share logic between fractional & non-fractional window scaling.

This also enables fractional-scaling without scaling fixed sized buffers
for compositors without support for fractional_scale_manager_v1.
2023-04-11 16:00:56 +10:00
Campbell Barton
34f386c730 GHOST/Wayland: store API compatible fractional scaling values
Use values compatible with Wayland's fractional-scale API.

No funcitonal changes.
2023-04-11 16:00:54 +10:00
Campbell Barton
520c112732 GHOST: comment on use of libunity for the taskbar in X11
While the DBUS API's libunity uses are still in wide use,
libunity.so it's self isn't. Note that we should use DBUS directly.
2023-04-07 13:39:19 +10:00
Campbell Barton
b626f1fd18 Cleanup: use ".cc" & ".hh" extensions for intern/ghost 2023-04-06 08:29:57 +10:00
Campbell Barton
075d92184b Cleanup: correct comment, quiet warnings 2023-04-05 20:11:08 +10:00
Campbell Barton
440cccecdc Cleanup: spelling in comments 2023-04-05 14:39:51 +10:00
Campbell Barton
648417bfff GHOST/Wayland: improve internal fractional scaling behavior
Logic for the recently included fractional scaling support [0] was
difficult to reason about as it depended on two different callbacks
one that listened to a preferred scale, another that tracked which
physical displays the window overlapped.
Checking if fractional scaling was in used depended on the order
the callbacks ran - which is undefined.

In practice - mixing non-fractional and fractional displays would
flicker when the window was moved between monitors.

Resolve this problem with the following changes:

- When the fractional-scale manager is supported,
  only respond to the scale from it's preferred_scale callback.
- When no fractional-scale manager is available,
  set the scale based on the scale of overlapping outputs.
- Add support for postponing the buffers commit call to prevent
  flickering when changing the windows scale.

Other changes:

- Use a lock before setting the pending frame state from
  wp_fractional_scale_handle_preferred_scale.
- Ensure pending actions that themselves trigger pending actions
  run in the time gwl_window_pending_actions_handle is called.
- Rename GWL_Window::scale -> GWL_WindowFrame::buffer_scale.

[0]: cde99075e87032d99d986182e98d9c367b22d417
2023-04-04 17:35:42 +10:00
Campbell Barton
95ffc4ba3a GHOST/Wayland: remove fractional-scale ifdef's
Depend on fractional-scale when searching for wayland-protocols

This will impact builders that don't use Blender's `../lib/` and
have wayland-protocols older than v1.31.
2023-04-04 17:26:37 +10:00
Campbell Barton
cde99075e8 GHOST/Wayland: add fractional-scale interface support
Previously, fractional scaling was detected but set an integer buffer
scale which the compositor would down-scale causing blurry output.

Now the fractional scaling interface is used when available to set the
DPI and set the internal buffers size & viewport transformation to
ensure 1:1 pixels from Blender to the Wayland output.

Tested to work with multiple monitors with mixed
fractional/non-fractional scale.

Note that this change causes a regression for when fractional scaling
is set on a compositor without support for fractional-scale-v1.
Supporting fractional scaling in both cases is possible but overly
complicated. This case already wasn't working so well - with blurry
output due to image scaling, now the DPI wont be accurate in this case
although Blender is still usable.
2023-03-31 13:03:50 +11:00
Sergey Sharybin
a12a8a71bb Remove "All Rights Reserved" from Blender Foundation copyright code
The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.

The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.

However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.

This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software ...

This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
2023-03-30 10:51:59 +02:00
Campbell Barton
0fcecc5c1e Cleanup: use methods to convert to/from window scale
Simplifies adding support for the fractional-scale protocol which
requires events to be fractially scaled.
2023-03-30 17:36:31 +11:00
Campbell Barton
a62f6c8290 Fix out-of-bounds array access when building with GHOST_OPENGL_ALPHA
While this is off by default, best replace hard coded sizes to avoid
out of bounds access if the enum is expanded.
2023-03-30 09:51:44 +11:00
Sergey Sharybin
d32d787f5f Clang-Format: Allow empty functions to be single-line
For example

```
OIIOOutputDriver::~OIIOOutputDriver()
{
}
```

becomes

```
OIIOOutputDriver::~OIIOOutputDriver() {}
```

Saves quite some vertical space, which is especially handy for
constructors.

Pull Request: https://projects.blender.org/blender/blender/pulls/105594
2023-03-29 16:50:54 +02:00
Campbell Barton
c0a252b833 Fix #105895: UI scaled down with 125% fractional scaling on Wayland
The DPI returned by the GHOST/Wayland didn't account the buffer being
rendered at a higher (non-fractional) resolution, then scaled down.

This caused the software cursor and UI to rendered very small.
A fractional scale of 101% would show the UI just over 50% of the size
(making the UI to be close to half the scale it should have been).

Resolve by accounting for down-scaling of the buffer to it's
fractional size.
2023-03-29 17:48:53 +11:00
Campbell Barton
35f770a689 Cleanup: duplicate words in comments 2023-03-29 14:17:32 +11:00
Kazashi Yoshioka
a64877f045 Vulkan: Added prerequisite checks for using VK_Layer_Validation
This PR adds pre-checks when enabling validation layers.

For validation layers to work some platforms require that
the Vulkan SDK is installed. Validation layers are activated
when running blender with `--debug-gpu`.

Sometimes we expect users to run with `--debug-gpu` for
narrowing down an issue and we cannot expect them to have
the Vulkan SDK installed.

This patch will check if the `VK_LAYER_PATH` is available
and that the configuration file of the validation layer is
present. If this isn't the case we don't activate the
requested validation layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/105922
2023-03-28 10:45:44 +02:00
Campbell Barton
a88c77eaac Cleanup: use struct comments for gwl_registry_handlers declaration 2023-03-28 17:05:25 +11:00
Campbell Barton
3071ec486b GHOST/Wayland: support window activation
Calling render (for example) with an existing window open now activates
the window on Wayland. Tested to work on GNOME & KDE.

Use the xdg-activation protocol which typically brings the
window to the foreground.

Partially resolves #102985.
2023-03-28 16:08:10 +11:00
Campbell Barton
8132b4a927 GHOST/Wayland: GWL_Seat::data_source_serial when modifiers are set
All keyboard/cursor events should set the data_source_serial,
also update doc-string.
2023-03-28 16:05:32 +11:00
Campbell Barton
4ee705ca4f Cleanup: use a system method to access the APP_ID
Move the app-id out window initialization code.
Make it possible for other methods to access the APP_ID.
2023-03-28 16:05:31 +11:00
Campbell Barton
4bead379c6 Cleanup: remove redundant (void) in C++ function declarations 2023-03-28 15:57:48 +11:00
Campbell Barton
2ec4ce18ae Cleanup: use 'override' specifier for GHOST: X11, SDL & None with CLANG
Clang would warn about failure to use 'override' when a single
method was added that used 'override' when none of the other methods
did.

This meant a single correct use of override caused noisy compiler
warnings (for CLANG but not GCC).
Avoid this by using 'override' where appropriate.
2023-03-28 15:57:48 +11:00
Campbell Barton
bb2dc141f2 Cleanup: spelling in comments 2023-03-27 12:08:14 +11:00
Campbell Barton
99d7816d06 Cleanup: suppress clang-tidy warnings in GHOST_Types.h 2023-03-27 11:07:27 +11:00
Campbell Barton
4e51008a82 GHOST: replace multiple functions with a single capabilities flag
Adding checks for platform capabilities involved adding functions
to multiple classes and was too involved.

Replace this with a single GHOST_System::getCapabilities() function.
2023-03-27 11:01:20 +11:00
Hans Goudey
cef82a1d39 Cleanup: Grammar: "it's" vs "its" 2023-03-24 08:34:21 -04:00
Campbell Barton
03cfa75bcc Merge branch 'blender-v3.5-release' 2023-03-24 22:42:33 +11:00
Campbell Barton
cb4f7cac24 Fix #106040: pasting long text fails in Gnome-Shell/Wayland
Workaround gnome-shell including uninitialized memory when pasting
from the clipboard. Where `read` would not write data into the range
return by the length.

Reading from the pipe into a power-of-two buffer
works around the problem.

It's not clear why this only impacts gnome-shell - as there is no
significant down-side to changing the buffer size, apply a workaround.

Ref !106091.
2023-03-24 22:25:26 +11:00
Campbell Barton
a016d142e8 Fix #106040: pasting long text fails in Gnome-Shell/Wayland
Workaround gnome-shell including uninitialized memory when pasting
from the clipboard. Where `read` woud

Reading from the pipe into a power-of-two buffer
works around the problem.

It's not clear why this only impacts gnome-shell - as there is no
significant down-side to changing the buffer size, apply a workaround.
2023-03-24 17:12:02 +11:00
Campbell Barton
3dcd4df70c UI: support the primary clipboard for console & 3D text selection
Only the text editor supported the primary clipboard & only for modal
selection. Now selecting text in the console & 3D text editing also
sets the primary clipboard under X11 & Wayland.

Notes:

- Pasting from the primary clipboard isn't yet exposed in the key-map
  so in practice it's only useful for pasting text outside of Blender.
- Use skip-save option when pasting from the primary selection
  so this is never used by the regular paste shortcut.
- This commit adds a primary-clipboard flag to WM_capabilities_flag() so
  creating the the copy-buffer is only performed when necessary.
2023-03-24 17:09:39 +11:00
Campbell Barton
ebd7298594 Cleanup: avoid repeating defaults for pointer scroll under Wayland 2023-03-23 15:19:00 +11:00
Campbell Barton
e4300bbf2d Cleanup: quiet warnings by using system-includes for ./extern/
extern/json & extern/fmtlib reported warnings with GCC 12.2.1.
As these libraries aren't maintained as part of Blender, treat them as
system-includes.
2023-03-22 14:18:14 +11:00
Campbell Barton
3afe88b6c7 Cleanup: cmake indentation 2023-03-22 14:14:15 +11:00
Campbell Barton
d3bab78d05 Merge branch 'blender-v3.5-release' 2023-03-22 12:25:26 +11:00
Campbell Barton
cf82e5fe57 Fix incorrect cursor size on Wayland with the RIVER compositor
Use XCURSOR_THEME & XCURSOR_SIZE environment variables for Wayland.
While this isn't an official part of the spec, many Wayland compositors
& applications use these variables.
2023-03-22 11:17:24 +11:00
Campbell Barton
f54af343f1 Merge branch 'blender-v3.5-release' 2023-03-21 12:57:20 +11:00
Campbell Barton
5332537fc5 Cleanup: add struct comments for GHOST/Wayland 2023-03-21 12:54:19 +11:00
Campbell Barton
5404841421 Merge branch 'blender-v3.5-release' 2023-03-21 11:53:44 +11:00
Campbell Barton
98272e5bb2 Fix #104272: Inverted (natural) option ignored on Wayland
Detect axis inversion, depends on the upcoming Wayland v1.22 release
which will need Linux libs to be upgraded too.
2023-03-21 11:47:10 +11:00
Campbell Barton
bc6985a6c1 Cleanup: doxygen comments 2023-03-14 12:51:37 +11:00
Campbell Barton
896ba33336 GHOST: use logging for GHOST_NDOFManagerUnix
Even for debug builds, NDOF info on startup is unnecessarily noisy.
2023-03-10 13:12:27 +11:00
Jeroen Bakker
d21b9a4bb6 Vulkan: Warn Developer When Layer Not Found.
Currently a developer that starts blender with `--debug-gpu` or
runs the GPU test cases can receive an error when not the full
VulkanSDK is installed.

The VulkanSDK isn't required for normal developement and
therefore it is better to show it as a warning.

NOTE: VulkanSDK is adviced to use when developing in the Vulkan
backend as it contains tools that helps/speed up the development
and validation during development.

Pull Request: https://projects.blender.org/blender/blender/pulls/105599
2023-03-09 14:55:40 +01:00
Campbell Barton
b3625e6bfd Cleanup: comment blocks 2023-03-09 10:39:49 +11:00
Harley Acheson
56d2298271 Fix #105435: Pause Win32 Auto-Focus During Text Entry
Don't allow the hover of mouse to auto-raise another window while you
are entering data into a text or number input.

Pull Request: https://projects.blender.org/blender/blender/pulls/105446
2023-03-08 22:20:34 +01:00
Germano Cavalcante
7fcb262dfd Cleanup: resolve some unreferenced parameter warnings in MSVC
When the warning level is set to 4, some unreferenced parameter
warnings can appear

This commit resolves some of those warnings.
2023-03-07 21:39:44 -03:00
Campbell Barton
5b152a4880 Docs: correct doc-string for wmEvent::customdata
Also cross-reference custom-data with GHOST_TEventType.
2023-03-07 15:57:18 +11:00
Campbell Barton
05324e2e3c Cleanup: spelling in comments 2023-03-03 10:09:20 +11:00
Jeroen Bakker
8d9819e07f Fix: Not all vulkan code-paths where compiled.
Fix issue where old `WITH_VULKAN` was still used. It should
have used `WITH_VULKAN_BACKEND`.
2023-02-28 05:36:06 +01:00
Campbell Barton
efb86b75ee Cleanup: comment block formatting 2023-02-27 21:51:57 +11:00
Campbell Barton
dc08ff3c2e Cleanup: spelling in comments 2023-02-27 21:00:30 +11:00
Chris Blackbourn
86ceb6722f Cleanup: format 2023-02-26 11:55:22 +13:00
Harley Acheson
defd95afcd Win32: Auto-Raise and -Focus Windows on Hover
On the Windows platform, raise windows and give them focus as the mouse
hovers over them. This allows keyboard shortcuts for the area under the
mouse without having to click the window caption to make them active.

Pull Request #104681
2023-02-22 10:26:43 -08:00
Harley Acheson
8b63966236 Revert 104438: Windows Spanning Multiple Monitors
Revert of commits that allowed non-temp Blender windows to be saved
and restored that spanned multiple monitors on the Windows platform.
This causes problems with temp windows (like Preferences & Render) that
cannot currently be fixed.

See 104956 for much more details.

This change is being redone after it was accidentally reverted.

Differential Revision: https://projects.blender.org/blender/blender/pulls/104956

Reviewed by Ray Molenkamp
2023-02-21 15:45:45 -08:00
Jeroen Bakker
7fb1f060ff Vulkan: Initial Compute Shaders support
This patch adds initial support for compute shaders to
the vulkan backend. As the development is oriented to the test-
cases we have the implementation is limited to what is used there.

It has been validated that with this patch that the following test
cases are running as expected
- `GPUVulkanTest.gpu_shader_compute_vbo`
- `GPUVulkanTest.gpu_shader_compute_ibo`
- `GPUVulkanTest.gpu_shader_compute_ssbo`
- `GPUVulkanTest.gpu_storage_buffer_create_update_read`
- `GPUVulkanTest.gpu_shader_compute_2d`

This patch includes:
- Allocating VkBuffer on device.
- Uploading data from CPU to VkBuffer.
- Binding VkBuffer as SSBO to a compute shader.
- Execute compute shader and altering VkBuffer.
- Download the VkBuffer to CPU ram.
- Validate that it worked.
- Use device only vertex buffer as SSBO
- Use device only index buffer as SSBO
- Use device only image buffers

GHOST API has been changed as the original design was created before
we even had support for compute shaders in blender. The function
`GHOST_getVulkanBackbuffer` has been separated to retrieve the command
buffer without a backbuffer (`GHOST_getVulkanCommandBuffer`). In order
to do correct command buffer processing we needed access to the queue
owned by GHOST. This is returned as part of the `GHOST_getVulkanHandles`
function.

Open topics (not considered part of this patch)
- Memory barriers & command buffer encoding
- Indirect compute dispatching
- Rest of the test cases
- Data conversions when requested data format is different than on device.
- GPUVulkanTest.gpu_shader_compute_1d is supported on AMD devices.
  NVIDIA doesn't seem to support 1d textures.

Pull-request: #104518
2023-02-21 15:04:52 +01:00
Julian Eisel
c437a8aea8 Revert release branch only commit after merge
This is a revert of a revert, because the initial revert is only
supposed to be in the release branch.

This reverts commit 3eed00dc546b5930b255572901915ccbc26c0e69.
2023-02-20 11:51:16 +01:00
Julian Eisel
3eed00dc54 Revert "GPencil: Include UV information in simplify->sample modifier."
This reverts commit 19222627c6b57df77d3bc9ae60d7850ab7e23abb.

Something went wrong here, seems like this commit merged the main branch
into the release branch, which should never be done.
2023-02-20 11:20:07 +01:00
YimingWu
19222627c6 GPencil: Include UV information in simplify->sample modifier.
Simplify modifier sample mode didn't transfer UV parameters, now fixed.

Pull Request #104942
2023-02-19 11:45:22 +01:00
Dalai Felinto
4ec9aff2af Revert "Fix #104850: Create Geometry Nodes operators fails if not in English"
This reverts commit 68181c2560db25c1bd2b70beccf6022c5aa00f39.

I merged 3.6 into 3.5 by mistake. Basically I had a PR against main,
 then changed it in the last minute to be against 3.5 via the
 web-interface unaware that I shouldn't do it without updating the
 patch.

 Original Pull Request: #104889
2023-02-17 18:45:42 +01:00
Dalai Felinto
68181c2560 Fix #104850: Create Geometry Nodes operators fails if not in English
Note that the node group has its sockets names
translated, while the built-in nodes don't.

So we need to use data_ for the built-in nodes names,
and the sockets of the created node groups.

Pull Request #104889
2023-02-17 18:39:17 +01:00
Germano Cavalcante
a755e6e63f Revert "MSVC: lower C4100 warning level from 4 to 3"
This reverts commit db4e7616f3590c04484fe8a015b6a02b7a1ede44.

Caused many issues when compiling mantaflow.
2023-02-14 15:36:35 -03:00
Germano Cavalcante
db4e7616f3 MSVC: lower C4100 warning level from 4 to 3
This better aligns with OSX/Linux warnings.

Although `__pragma(warning(suppress:4100))` is not the same as
`__attribute__((__unused__))` in gcc (which only affects the attribute
instead of the line), it still seems to be better to use it than to
hide the warning entirely.
2023-02-14 14:38:18 -03:00
Campbell Barton
91346755ce Cleanup: use '#' prefix for issues instead of 'T'
Match the convention from Gitea instead of Phabricator's T for tasks.
2023-02-12 14:56:05 +11:00
Campbell Barton
ce44953933 Cleanup: various C++ cleanups 2023-02-11 14:04:35 +11:00
Campbell Barton
4cbe0bff34 Cleanup: spelling in comments 2023-02-10 11:34:20 +11:00
Campbell Barton
ca183993a5 Fix freeing uninitialized pointer in GHOST/Wayland + X11 fallback
Freeing the timer manager didn't account for Wayland being partially
initialized.
2023-02-09 23:41:03 +11:00
Campbell Barton
0381fe7bfe Cleanup: update username in code-comments: campbellbarton -> ideasman42
Gitea migration changed my username, update code-comments.
2023-02-09 11:33:48 +11:00
Campbell Barton
dbca0cc9d5 Fix crash on exit under Wayland
Order of free error from [0] caused the timer manager
to be freed before the timer.

[0]: 7de1a4d1d81ffd4cd2e75d911426edc847267244
2023-02-07 15:12:05 +11:00
Campbell Barton
a99022e22d Cleanup: spelling in comments 2023-02-07 14:17:01 +11:00
Campbell Barton
7de1a4d1d8 Fix GHOST/Wayland thread-unsafe timer-manager manipulation
Mutex locks for manipulating GHOST_System::m_timerManager from
GHOST_SystemWayland relied on WAYLAND being the only user of the
timer-manager.

This isn't the case as timers are fired from
`GHOST_System::dispatchEvents`.

Resolve by using a separate timer-manager for wayland key-repeat timers.
2023-02-06 12:25:04 +11:00
Campbell Barton
d3949a4fdb Fix GHOST/Wayland thread-unsafe key-repeat timer checks
Resolve a thread safety issue reported by valgrind's helgrind checker,
although I wasn't able to redo the error in practice.

NULL check on the key-repeat timer also needs to lock, otherwise it's
possible the timer is set in another thread before the lock is acquired.

Now all key-repeat timer access which may run from a thread
locks the timer mutex before any checks or timer manipulation.
2023-02-06 12:25:04 +11:00
Jeroen Bakker
ab3e1809b6 Vulkan: Select graphics queue with compute capabilities.
There might be cases that the graphics queue and compute
queue are separated, but that would be something that we
will solve in the future.
2023-02-03 10:16:01 +01:00
Jeroen Bakker
a45a881534 Spelling: familly -> family.
Fix spelling mistake originated from tmp-vulkan branch.
2023-02-03 10:16:01 +01:00
Campbell Barton
27b4916b1a Cleanup: spelling in comments
Also minor changes in comments:
- Reference BLENDER_HISTORY_FILE instead of the literal file-name
  (simplifies looking up usage).
- Use usernames in tags, as noted in code-style.
2023-01-31 14:22:23 +11:00
Jeroen Bakker
a36c1cabce Vulkan: Changes to CMake config.
Paths to vulkan libraries, paths and related components were
hardcoded in the platform cmake file. This patch separates
this by using adding CMake modules for Vulkan and ShaderC.

This change has only been applied to the macOs configuration as
that is currently our main platform for development. Other platforms
will be added during the development of the Vulkan back-end.
2023-01-30 12:04:44 +01:00
Campbell Barton
adcb0edca0 Cleanup: clang-tidy, replace defines with enum, redundant parenthesis 2023-01-25 11:53:06 +11:00
Jason Fielder
84c25fdcaa Metal: Improve command buffer handling and workload scheduling.
Improve handling for cases where maximum in-flight command buffer count is exceeded. This can occur during light-baking operations. Ensures the application handles this gracefully and also improves workload pipelining by situationally stalling until GPU work has completed, if too much work is queued up.

This may have a tangible benefit for T103742 by ensuring Blender does not queue up too much GPU work.

Authored by Apple: Michael Parkin-White

Ref T96261
Ref T103742
Depends on D17018

Reviewed By: fclem

Maniphest Tasks: T103742, T96261

Differential Revision: https://developer.blender.org/D17019
2023-01-23 17:47:21 +01:00
Campbell Barton
537db96fb7 GHOST/NDOF: don't send button events when there is no active window
NDOF events without an active window were ignored and printed
warnings in the console.
2023-01-22 21:06:10 +11:00
Campbell Barton
cbd15d387f GHOST/Wayland: don't send activate/deactivate on pointer enter/leave
This isn't correct as window activation is handled separately
from the cursor entering/leaving a window.

This would call de-activate when the cursor moved outside the window
even though the window remained focused.

Rely on focus changes which already handle activate/deactivate events.
2023-01-21 23:09:22 +11:00
Campbell Barton
721bd5e6cf Fix invalid swapBuffer calls & outdated window decorations on Wayland
Swap-buffers was being deferred (to prevent it being called
from the event handling thread) however when it was called the
OpenGL context might not be active (especially with multiple windows).

Moving the cursor between windows made eglSwapBuffers report:
EGL Error (0x300D): EGL_BAD_SURFACE.

Resolve this by removing swapBuffer calls and instead add a
GHOST_kEventWindowUpdateDecor event intended for redrawing
client-side-decoration.

Besides the warning, this results an error with LIBDECOR window frames
not redrawing when a window became inactive.
2023-01-20 18:05:52 +11:00
Campbell Barton
c2120b8c4f CMake: suppress missing-variable-declarations warnings with Clang
Code generated by wayland-scanner contained missing declarations.
2023-01-19 17:10:42 +11:00
Campbell Barton
5cbc8ce3b1 Fix ASAN error when Wayland fell back to X11
An alternative fix to [0] which caused an error with ASAN
(freeing an GHOST_ISystem instead of a GHOST_System).
Reported by @Baardaap in chat, I'm unable to reproduce the issue.

Instead of calling the destructor directly, add a private method that
deletes data before raising an exception.

[0]: fd36221930e35efd2c09af8fb91234a510e3b9dc
2023-01-16 15:29:22 +11:00
Campbell Barton
33c30af742 Cleanup: comments in struct declarations
Use a consistent style for declaring the names of struct members
in their declarations. Note that this convention was already used in
many places but not everywhere.

Remove spaces around the text (matching commented arguments) with
the advantage that the the spell checking utility skips these terms.
Making it possible to extract & validate these comments automatically.

Also use struct names for `bAnimChannelType` & `bConstraintTypeInfo`
which were using brief descriptions.
2023-01-16 13:27:35 +11:00
Campbell Barton
0c2a3054ba Fix high CPU use when idle under Wayland
Recently the event handling thread for Wayland sometimes used 100% of a
CPU core while idle.

Resolve by waiting for changes to the Wayland file-handle when
there are no events to read.
2023-01-13 17:48:52 +11:00
Campbell Barton
bbe7183cd3 GHOST/Wayland: fix threaded event handling
The previous fix from T100855 [0] no longer works on my system
(3.4.1 release also fails for GNOME/KDE/WLROOTS compositors).

Resolve by removing the loop from the wait-on-file handle check.
Also reduce locking/unlocking calls.

[0]: 37b256e26feb454d9febd84dac1b1ce8b8d84d90
2023-01-13 17:48:50 +11:00
Jeroen Bakker
eeff49a3b1 macOS: Replace PboardTypes with PasteboardTypes.
Related to {T103758}.

- NSStringPboardType is replaced by NSPasteboardTypeString
- NSTIFFPboardType is replaced by NSPasteboardTypeTIFF
2023-01-12 08:48:48 +01:00
Jeroen Bakker
3590e263e0 macOS: Remove user notifications.
User notifications in Blender were always annoying and therefore by default turned off.
- When tweaking compositor/material tree a notification was shown.
- When rendering an animation for each frame a notification was shown.

The reason for this was that it was automatically shown when a background job was
finished and Blender wasn't the top most application.

In stead of migrating user notification to UserNotification.framework it was decided
to remove it for now. If in the future notifications should be added back we should
start with a design to figure out where notifications makes sense.

Reviewed By: sergey, brecht

Maniphest Tasks: T103757

Differential Revision: https://developer.blender.org/D16955
2023-01-12 08:39:56 +01:00
Jeroen Bakker
387fc9b40b MacOS: Silence OpenGL deprecation warnings.
OpenGL is deprecated by Apple and triggers a warning when used. The goal
is that OpenGL is replaced by Metal backend, but we are not there yet.

To improve tracability of new warnings we hide deprecation warnings
when the GHOST_ContextCGL.h file is included.

NOTE: This change silences other deprecation warnings as well.
2023-01-10 14:57:23 +01:00
Campbell Barton
ed66321996 GHOST/Wayland: simplify logic for disconnecting monitors under Wayland
The T103586 fix effectively ran the wl_surface_listener.leave callback
to as WLROOTS based compositors doesn't run them. Remove the workaround
since it's an error in WLROOTS to be fixed upstream.

Temporarily using the wrong window scale when disconnecting a monitor
on configurations that use different DPI per monitor is a minor enough
issue that I don't think it makes sense to workaround in GHOST.
2023-01-10 17:50:29 +11:00
Campbell Barton
fdcbad37be Fix window creation with Hi-DPI exiting under Wayland
Wayland requires the windows surface size is divisible by the surface
scale. This wasn't guaranteed when creating new temporary windows.

This meant opening the preferences could exit Blender with an error
with Hi-DPI configurations.
2023-01-10 16:27:11 +11:00
Jacques Lucke
c9ab76db5c Cleanup: don't use designated initializers in c++
This is a c++20 feature.
2023-01-04 12:31:59 +01:00
Campbell Barton
cdd07ddb93 Cleanup: move doc-string to header 2023-01-04 16:06:42 +11:00
Campbell Barton
cbd12e730a Fix T103586: Crash removing monitor under Wayland & WLROOTS compositors
WLROOTS compositors don't run surface leave callbacks,
while this may be considered a bug in WLROOTS, neither GTK/SDL crash
so workaround the crash too.

This also fixes a minor glitch where the cursor scale wasn't updated
when changing monitor scale at run-time.
2023-01-04 16:04:12 +11:00
Campbell Barton
50dbedf0d8 GHOST/Wayland: add missing call to destroy xdg_output
Match logic from SDL.
2023-01-04 16:04:12 +11:00
Germano Cavalcante
1a986f7eba Revert "Fix erratic mouse wrapping movement on Windows (2)"
This reverts commit a3a9459050a96e75138b3441c069898f211f179c.

And fixes T103337.

a3a9459050a9 has some flaws and it needs to go through review (See D16803).

Conflicts:
	intern/ghost/intern/GHOST_SystemWin32.cpp
2022-12-19 10:41:05 -03:00
Campbell Barton
2ac6e26c25 Cleanup: cmake formatting 2022-12-17 13:33:27 +11:00
Campbell Barton
6797de4e10 Cleanup: spelling in comments 2022-12-17 13:15:33 +11:00
Campbell Barton
79a34758f5 Fix T103253: Infinite drag of number buttons is broken on WIN32
Recent reverting of changes to cursor grabbing intended to match
Blender 3.3 release. This is the case for 3.4x branch, however there is
an additional change to grabbing on WIN32 by Germano [0] which is a
significant improvement on old grabbing logic for Windows.
So instead of matching 3.3x behavior, restore logic that keeps
the cursor centered while grabbing & hidden.

This re-introduces T102792 issue displaying the paint-brush while
dragging buttons, this will have to be solved separately.

Re-apply [1] & [2], revert [3] & [4].

[4]: a3a9459050a96e75138b3441c069898f211f179c
[0]: 9fd6dae7939a65b67045749a0eadeb6864ded183
[1]: 4cac8025f00798938813f52dcb117be83db97f22
[2]: 230744d6fd96dcf5afe66a8f9b9f6f8bbe1f41bb
[3]: 0240b895994aa58258db6897ae0d6478da7fce5f
2022-12-16 18:38:22 +11:00
Campbell Barton
18cc1b1108 Fix cursor warping display under Wayland
Under Wayland the transform cursor wasn't displaying the warped cursor.

This worked on other platforms because cursor motion is warped where as
Wayland simulates cursor warping, so it's necessary to apply warping
when requesting the cursor location too.
2022-12-15 15:22:52 +11:00
Campbell Barton
d715573aea Cleanup: declare GHOST_Window::getCursorGrabBounds as const
Needed so it the method can be called on a cosnt GHOST_Window.
2022-12-15 15:10:51 +11:00
Campbell Barton
b147af2b7e Cleanup: remove duplicate doc-strings 2022-12-15 14:56:58 +11:00
Campbell Barton
230744d6fd Revert "Fix T102346: Mouse escapes window during walk navigation"
This reverts commits
9fd6dae7939a65b67045749a0eadeb6864ded183,
4cac8025f00798938813f52dcb117be83db97f22 (minor cleanup).

Re-introducing T102346, which will be fixed in isolation.

Unfortunately even when the cursor is hidden & grabbed,
the underlying cursor coordinates are still shown in some cases.

This caused bug where dragging a button in the sculpt-context popup
would draw the brush at unexpected locations because internally
the cursor was warping in the middle of the window, reported as T102792.

Resolving this issue with the paint cursor is possible but tend towards
over-complicated solutions.

Revert this change in favor of a more localized workaround for walk-mode
(as was done prior [0] to fix T99021).

[0]: 4c4e8cc926a672ac60692b3fb8c20249f9cae679
2022-12-15 12:15:23 +11:00
Germano Cavalcante
a3a9459050 Fix erratic mouse wrapping movement on Windows (2)
This is a solution in response to the issues mentioned in comments on
rBe4f1d719080a and T103088.

Apparently the workaround of checking if the mouse is already inside
the area on the next event doesn't work for some tablets.

Perhaps the order of events or some very small jitter is causing this
issue on tablets. (Couldn't confirm).

Whatever the cause, the solution of checking the timestamp of the event
and thus ignoring the outdated ones is theoretically safer.

It is the same solution seen in MacOS.

Also calling `SendInput` 3 times every warp ensures that at least one
event is dispatched.
2022-12-14 16:08:21 -03:00
Campbell Barton
fd36221930 GHOST/Wayland: fix memory leak when Wayland fails to start 2022-12-14 17:09:55 +11:00
Harley Acheson
93a629f147 Fix T103119: Allow Win32 Diacritical Composition
Allow keyboard layouts which include "dead keys" to enter diacritics
by calling MapVirtualKeyW even when not key_down.

See D16770 for more details.

Differential Revision: https://developer.blender.org/D16770

Reviewed by Campbell Barton
2022-12-13 18:30:20 -08:00
Jacques Lucke
b50c475cd2 Cleanup: move listbase.c to c++ 2022-12-13 18:13:10 +01:00