Commit Graph

2766 Commits

Author SHA1 Message Date
Campbell Barton 75afef1372 Cleanup: use braces for GHOST Cocoa *.mm sources 2023-09-17 09:16:09 +10:00
Campbell Barton 635a4eac05 Fix delete key setting a control character in wmEvent::utf8_buf
The check for control characters didn't account for delete (127).
This wasn't noticeable in most cases as delete is mapped to delete text.
Pressing Shift-Delete would enter 127 control character in the
text-editor, 3D text & Python console. This happened X11 & Wayland,
I didn't check other platforms.
2023-09-15 16:01:00 +10:00
Campbell Barton b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Ray Molenkamp 5f8dfa231d CMake: Fix building with WITH_VULKAN_BACKEND
Ghost uses vulkan in its public headers but none of the projects that
depend on ghost had the vulkan headers in its includes nor did
bf_intern_ghost expose this vulkan dependency itself publicly yet.

bf_windowmanager also did not express its dependency on
bf_intern_ghost yet used its headers.

this change fixes both issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/112259
2023-09-12 15:07:41 +02:00
Campbell Barton 057c9364fc Cleanup: use braces around statements 2023-09-12 14:48:20 +10:00
Jeroen Bakker 81c6eb9c7f Vulkan: Enable Shader Draw Parameters Support
Shader draw parameter support is needed for Workbench-next. (Almost) All
devices that we support also supports shader draw parameters. This PR
doesn't include a workaround for devices that don't have support.

For end-users this PR will allow workbench-next to render the object on
the correct location. Before this patch they were always drawn on the origin.

The catch is that OpenGL uses gl_InstanceID which always starts counting at 0.
Vulkan has gl_InstanceIndex which holds the correct instance number. By
subtracting the gl_InstanceIndex from gl_BaseInstance will get the correct
gl_InstanceID.

This patch also activates some device extensions to perform in shader printf
statements inside a shader. Documentation for this will be added to the dev
docs how to use them.

Pull Request: https://projects.blender.org/blender/blender/pulls/111461
2023-09-11 15:04:54 +02:00
Campbell Barton 4fc5d287ac Cleanup: doxygen parameters, blank comment lines 2023-09-08 16:53:30 +10:00
ChengduLittleA bf8d3c157a Fix #111820: Missing type casting in XrGraphicsBinding.cc
The line `oxr_binding.egl.getProcAddress = eglGetProcAddress` supposedly
needs a type casting for it to compile successfully under llvm16.

Pull Request: https://projects.blender.org/blender/blender/pulls/111915
2023-09-06 15:26:51 +02:00
Campbell Barton 4dd5385807 GHOST/Wayland: remove exception if wl_keyboard_listener::keymap fails
This would cause Blender to exist, log the message & return instead.
2023-09-06 16:19:33 +10:00
Campbell Barton d06bd5d1f0 GHOST: remove prefix from exception messages
The back-end name is already included remove duplicate information.
2023-09-06 16:08:06 +10:00
Campbell Barton 51e3cd1603 Fix Wayland error message displaying when running on X11
Problem caused by [0], resolve by only printing error messages
when none of the GHOST back-ends are able to start.

[0]: f58d596c36
2023-09-06 15:38:34 +10:00
Campbell Barton bedfc68e3f Cleanup: use function style integer casts, modernize headers 2023-09-05 11:10:44 +10:00
Campbell Barton 0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Campbell Barton e3fd80dd64 Fix building with GHOST/Wayland & Vulkan 2023-09-01 22:04:34 +10:00
Campbell Barton cc5dd9e3d3 Cleanup: use libdecor_ prefix for libdecor_frame_interface callbacks
These names weren't obviously related to libdecor.
2023-09-01 16:09:16 +10:00
Campbell Barton e711af8987 GHOST/Wayland: correction to xdg_toplevel_listener::configure use
Zero width/height should be ignored, don't overwrite the window
size set by the client in this case.
2023-09-01 16:09:16 +10:00
Campbell Barton 0026d20c8c Cleanup: quiet compiler warnings, correct doxy section 2023-08-30 10:57:17 +10:00
Jeroen Bakker bee3f645d8 Vulkan: Rewrite GHOST_ContextVK
This is a rewrite of GHOST_ContextVK to align with Metal backend as described
in #111389 - solution 3 with the adaptation that GHOST is still responsible
for presenting the swap chain image and a post callback is still needed in
case the swapchain is recreated.

This PR also includes some smaller improvements in stability.

Technical documentation: https://developer.blender.org/docs/eevee_and_viewport/gpu/vulkan/swap_chain/

* Renderpasses and framebuffers are not owned anymore by GHOST_ContextVK
* VKFramebuffer doesn't contain a swap chain image.
* Swapchain images can only be used as a blit destination or present source.
  Not as an attachment.
* GHOST_ContextVK::swapBuffers would call a callback with the image the
  GPU module needs to blit the results to.
* Clearing of depth/stencil attachments when no depth write state is set.
* Enable VK_KHR_maintenance4 to relax the stage interface mapping.
* Removes most vulkan validation warnings/errors.
* Detection of frame buffer changes that needs to be applied before
  performing a command requiring render pass (draw/clear attachment)

**Benefits**

* Late retrieval of a swap chain image results in better overall performance as
  Blender doesn't need to wait until the image is presented on the screen.
* Easier API and clearer state (transitions)
* More control over Image layouts and command buffer states. (Better alignment with
  Vulkan API)

Pull Request: https://projects.blender.org/blender/blender/pulls/111473
2023-08-29 15:05:08 +02:00
Hans Goudey eafe8332c7 Fix: Compile error with Ghost X11 off and Wayland on
‘const’ qualifiers cannot be applied to ‘const std::runtime_error&’
2023-08-28 16:15:21 -04:00
Vitor Boschi e5a0d11c4e UI: Allow eyedropper outside of Blender (X11)
Implements the GHOST_GetPixelAtCursor for the X11 backend, allowing
the user to sample any color displayed on the screen.

Noted some limitations in the code-comments.

Ref !111493.
2023-08-26 17:20:05 +10:00
Harley Acheson f69c7afe57 Fix #111295: Add Missing Win32 Platform-Specific Window functions
Add platform-specific (Windows) versions of getOSWindow() and
getWindowUnderCursor().

Pull Request: https://projects.blender.org/blender/blender/pulls/111359
2023-08-25 22:09:54 +02:00
Campbell Barton 0f0a2d9038 Correct error printing NDOF rotation 2023-08-23 15:36:34 +10:00
Campbell Barton 3405e14446 GHOST: handle all event types in GHOST_EventPrinter::processEvent
- Adjust switch statement to warn when members aren't accounted for.
- Print NDOF button/motion data.
2023-08-23 15:31:21 +10:00
Campbell Barton c52965e9c7 Cleanup: simplify struct declarations 2023-08-23 13:45:19 +10:00
Campbell Barton f58d596c36 GHOST/Wayland: print the exception message on failure
When GHOST_SystemWayland can't be created, print the run-time error
unless X11 is available as a fallback.
2023-08-22 16:08:55 +10:00
Campbell Barton 4760908b6e Fix potential buffer overflow & un-terminated strings on macOS
- GHOST_SystemPathsCocoa::getUserSpecialDir
  used `strncpy` without ensuring the string was null terminated.
- GHOST_SystemPathsCocoa::getBinaryDir
  used `strcpy` without checking the destination buffer size.
2023-08-21 11:53:22 +10:00
Campbell Barton 0a04a6d1a1 Cleanup: quiet GCC's -Wsuggest-attribute=format warning 2023-08-17 16:52:45 +10:00
Campbell Barton a7c1a57957 CMake: correct WITH_X11_XF86VMODE include path 2023-08-17 11:53:49 +10:00
Germano Cavalcante fc39963b31 Cleanup: Deduplicate code
By unifying the return, we don't need to duplicate the `CoTaskMemFree`
call.

Ref 84718feb4b.
2023-08-16 18:29:12 -03:00
Guillermo Venegas 84718feb4b Fix potential leaks using SHGetKnownFolderPath
Documentation for `SHGetKnownFolderPath` remarks that the `PWSTR`
parameter should always be freed with `CoTaskMemFree`  even if it
succeeds or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/111128
2023-08-16 23:10:00 +02:00
Campbell Barton 92c4756d02 Fix replacement of "Blender Foundation" in recent header change
The recent change to header copyrights [0] unintentionally changed
"Blender Foundation" to "Blender Authors" for the WIN32 file path
which blender is installed into.

Revert lines changed that aren't related to copyright text.

[0]: e955c94ed3
2023-08-16 21:21:55 +10:00
Harley Acheson 5741a5d433 UI: Allow Eyedropper Outside of Blender
This adds a new Ghost function, GHOST_GetPixelAtCursor, that allows
picking colors from outside of Blender windows. This only has an
implementation for the Windows platform, but this should allow other
platforms to also do so if possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/105324
2023-08-16 01:14:36 +02:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Jeroen Bakker dd4ab50065 GPU: Add Dummy Backend For Unsupported Platforms
With the introduction of metal and vulkan we use a different
GPU backend selection which broke the dialog box for unsupported
platforms.

Blender asserted and segfaulted before the dialog was being shown
to the user.

This patch solves this by introducing a dummy GPU backend in case no
GPU backend was supported by OpenGL, Metal and Vulkan Backend.

It also adds the showMessageBox to GHOST_SystemCocoa.

Related to #110335

Pull Request: https://projects.blender.org/blender/blender/pulls/110919
2023-08-15 14:15:12 +02:00
Campbell Barton 311fa9768d Cleanup: spelling in comments 2023-08-12 16:29:51 +10:00
Campbell Barton 9810942adf Cleanup: avoid uninitialized members in GHOST classes 2023-08-11 09:34:08 +10:00
Campbell Barton cc95c02a89 Fix building WITH_OPENGL_BACKEND=OFF 2023-08-10 17:40:24 +10:00
Campbell Barton ea10e601fd Cleanup: use _get() suffix for GHOST/Wayland methods
Avoid variables shadowing methods for common names such as
scale & outputs.
2023-08-10 17:38:34 +10:00
Campbell Barton 23cd37de25 Cleanup: redundant checks 2023-08-10 17:11:24 +10:00
Jason Fielder 2367ed2ef2 macOS: Enable support for EDR rendering
Add a High Dynamic Range option in the Color Management > Display panel.
This enables display of extended color ranges above 1.0 for the 3D
viewport, image editor and render previews.

This requires a monitor that can display HDR colors, and a view
transform designed for HDR output. The Standard view transform works,
but Filmic does not as it was designed to bring values into the 0..1
range for SDR displays.

This patch is limited to allowing the display to visualize extended
colors, but does not include future looking work to better integrate HDR
into the full workflow.

It is implemented by rendering to high bit-depth texture formats for
the user interface, and uncapping the color range in color management.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/105662
2023-08-09 14:25:15 +02:00
Campbell Barton da0fef65c0 Cleanup: remove unsafe string API use
This was only enabled WITH_GHOST_DEBUG, getKeyString now returns
a static string instead of filling in a buffer.
2023-08-09 15:50:32 +10:00
Campbell Barton bff7962c80 Cleanup: remove redundant struct/void in C++, function style casts 2023-08-09 13:37:37 +10:00
Campbell Barton 5f1b02937a Cleanup: remove 'struct' prefix from GHOST/Wayland types
Move struct members into sub-structs (wl/wp/xdg/xkb) to prevent
naming collisions with the types & struct members.
2023-08-09 12:54:19 +10:00
Clément Foucault 983ff8e616 GPU: Framebuffer: Add multi viewport support
This add the possibility to define different
viewports inside a single framebuffer and
let the vertex shader decide which viewport
to render to.

This only contain the GL and VK implementation.
The Vulkan implementation works but still
has a validation error related to shader features
and extension. The test passes nonetheless.

Pull Request: https://projects.blender.org/blender/blender/pulls/110923
2023-08-08 17:12:49 +02:00
Jeroen Bakker b1357f6790 Vulkan: Error When Creating Windows Offscreen Context
Thanks to UPBGE developers to point this one out.

Pull Request: https://projects.blender.org/blender/blender/pulls/110892
2023-08-07 14:58:06 +02:00
Campbell Barton 7f34ad736a Cleanup: spelling in comments 2023-08-05 13:54:25 +10:00
Campbell Barton de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton 8c8ff6b85b Cleanup: spelling in comments, use C-style comments 2023-08-03 09:44:28 +10:00
Campbell Barton 7cc3ef3260 Cleanup: use C++ includes, various non-functional changes for C++ 2023-08-02 20:30:02 +10:00
Campbell Barton dec70e84b6 Cleanup: use nullptr in intern/ghost 2023-08-02 00:21:44 +10:00
Campbell Barton 8d4c847052 Fix #110627: crash on start with Wayland
Older versions of Wayland would crash on startup because of the
requested zwp_pointer_gestures_v1 version.

Resolve by supporting older versions.
2023-07-31 22:59:54 +10:00
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 :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
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]: c803ddab29
[1]: d7d1c524e3
[2]: d3d91b79e0
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 4fe2685615.

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]: cde99075e8
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 3eed00dc54.
2023-02-20 11:51:16 +01:00
Julian Eisel 3eed00dc54 Revert "GPencil: Include UV information in simplify->sample modifier."
This reverts commit 19222627c6.

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 68181c2560.

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

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]: 7de1a4d1d8
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]: fd36221930
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]: 37b256e26f
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 a3a9459050.

And fixes T103337.

a3a9459050 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]: a3a9459050
[0]: 9fd6dae793
[1]: 4cac8025f0
[2]: 230744d6fd
[3]: 0240b89599
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
9fd6dae793,
4cac8025f0 (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]: 4c4e8cc926
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
Campbell Barton a132b068bc Cleanup: use ELEM macro 2022-12-08 13:59:42 +11:00
Thomas Dinges de9f32a666 Merge branch 'blender-v3.4-release' 2022-12-06 18:27:44 +01:00
Campbell Barton 38e1b92b7a Fix T102964: Key-map event type values changed for NDOF buttons
Regression in [0] changed NDOF key-map values.

Restore the previous values & add missing view buttons to
rna_enum_event_type_items.

[0]: ecda118be4

Differential Revision: https://developer.blender.org/D16701
2022-12-06 18:26:24 +01:00
Campbell Barton 979b295154 Fix incorrect cursor motion coordinates for WIN32
Cursor motion events on windows read the position from GetCursorPos()
which wasn't always the same location stored in `lParam`.

In situations where events were handled immediately this wasn't often a
problem, for heavier scenes or when updates between event handling was
slow - many in-between cursor events would be incorrect.

This behavior dates back to the initial commit, there doesn't seem to be
a good reason not to use the cursor coordinates from the event.

Noticed when investigating T102346.
2022-12-06 17:18:01 +11:00
Campbell Barton d486f33d63 GHOST: OpenGL errors now use "file:line: " contention for errors
Make OpenGL errors match formatting used by GCC & clang
(as well as Blender's logging), so utilities that recognize this
convention can be used to quickly access this location.
2022-12-06 14:48:38 +11:00
Campbell Barton 9cb061f4f0 Cleanup: spelling in comments 2022-12-05 12:58:18 +11:00
Campbell Barton 0dee238c8c Cleanup: remove duplicate doc-strings
Duplicating doc-strings in both header & implementation
should be avoided as they often diverge & maintaining them is more work.
2022-12-05 12:54:04 +11:00
Peter Kim 63ae0939ed Merge branch 'blender-v3.4-release' 2022-11-23 10:22:42 +09:00
Peter Kim db28a8b3d1 Fix T102322: Crash on exiting VR session when using DirectX backend
This prevents Blender from crashing with an access violation when
stopping a VR session using the DirectX backend. The issue occurred for
any headset on Windows+Nvidia when using the SteamVR runtime and thus
affected a large number of users.

The workaround presented here is to simply skip unregistering the
shared resources on exit, as either of the calls to
`wglDXUnregisterObjectNV()` or `wglDXCloseDeviceNV()` will result in an
access violation. While not ideal, this avoids the crash and doesn't
present any issues when starting a new VR session.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D16569
2022-11-23 10:21:17 +09:00
Jeroen Bakker dd5fdb9370 GPU: Add MoltenVK as dependencies to Vulkan SDK.
MoltenVK is part of the vulkan SDK. Blender requires the vulkan SDK
to compile. This patch adds the MoltenVK includes and libraries to
the Vulkan includes and libraries.
2022-11-22 14:07:34 +01:00
Jeroen Bakker b79e5ae4f2 GHOST: Add missing C_API function to header file.
- GHOST_GetDrawingContext was missing.
2022-11-22 12:45:49 +01:00
Jeroen Bakker 6dac345a64 GHOST: Vulkan Backend.
This adds a vulkan backend to GHOST. The code was extracted from the
tmp-vulkan branch. The main difference with the original code is that
GHOST isn't responsible for fallback. For Metal backend there is already
an idea that the GPU module is responsible for the fallback, not the system.

For Blender we target Vulkan 1.2 at the time of this patch.
MoltenVK (needed to convert Vulkan calls to Metal) has been added as
a separate package.

This patch isn't useful for end-users, currently when starting blender with
`--gpu-backend vulkan` it would crash as the `VBBackend` doesn't initialize
the expected global structs in the GPU module.

Validated to be working on Windows and Apple. Linux still needs to be tested.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13155
2022-11-22 11:29:09 +01:00
Campbell Barton 4cac8025f0 Cleanup: use int32_t type, update comments
Reference WIP patches for warping on the spot, follow up to T102346.
2022-11-20 10:39:43 +11:00
Campbell Barton 9fd6dae793 Fix T102346: Mouse escapes window during walk navigation
Regression in [0] which exposed a problem with GHOST_kGrabHide on Win32
and to some extent X11.

Prior to [0], walk mode used it's own warping logic (hiding the cursor
& recording the motion between events). Using GHOST's grabbing makes
sense in this case as it's not very convenient for operators to
implement their own cursor warping, however doing so exposed a problem
where the mouse cursor could leave the window.
This would happen because the cursor needed to be within 2px of the
screen edge before warping.

Resolve by warping within a small region in the middle of the window.

Note that warping to the window center on each motion would be ideal
but is more involved as the logic for Win32 & X11 doesn't work properly
when every motion warps, so this needs further investigation to support.

This problem doesn't apply to GHOST/Cocoa which warps every motion event
on the spot and GHOST/Wayland doesn't set the mouse position at all to
implement this functionality.

[0]: 4c4e8cc926
2022-11-19 20:57:59 +11:00
Campbell Barton 33fa053fe8 GHOST/Wayland: add missing lock in setWindowCursorShape
Also add some comments for locking.
2022-11-16 21:35:56 +11:00
Campbell Barton 02fa3a8128 Cleanup: remove unused window_manger reference in GHOST_WindowWayland 2022-11-16 21:04:30 +11:00
Campbell Barton 88c9f1266d GHOST/Wayland: add additional locks for correctness
Some of these functions should use locks although they didn't show up
as needing locks at runtime (using valgrind's helgrind), as some aren't
called often or aren't used at all. Add locks for correctness & to
prevent errors in the future.

- GHOST_SystemWayland::disposeContext
- GHOST_SystemWayland::getAllDisplayDimensions
- GHOST_SystemWayland::getButtons
- GHOST_SystemWayland::getMainDisplayDimensions
- GHOST_SystemWayland::getNumDisplays
- GHOST_WindowWayland::setWindowCustomCursorShape
2022-11-16 12:32:13 +11:00
Campbell Barton 1f5e1b59a3 GHOST/Wayland: quiet key modifier warning under gnome-shell
This was already suppressed in `getModifierKeys`,
but `keyboard_depressed_state_key_event` was still warning.
2022-11-16 12:31:30 +11:00
Campbell Barton c2c41fb14c Fix missing title-bar redrawing with Wayland & libdecor
Regression in [0], changing active/inactive missed redrawing the
title-bar,

[0]: 37b256e26f
2022-11-16 12:31:30 +11:00
Campbell Barton 64a114d11c GHOST/Wayland: add build option to set the XDG app-id
Add WITH_GHOST_WAYLAND_APP_ID so people making custom builds may
differentiate the blender instance by version/branch etc.
2022-11-16 12:31:30 +11:00
Campbell Barton d1a5f24e73 Cleanup: move GHOST_WindowWayland::swapBuffers behind ifdef
The callback is only used for an assertion.
2022-11-16 12:31:30 +11:00
Campbell Barton aee5fcc120 GHOST/Wayland: improve workaround for libdecor setting the window state
libdecor has a workaround where creating the window would loop until
the windows configure callback ran.

Simplify this workaround by setting the initial state on the underlying
xdg_toplevel struct.

Also correct mixup between bool / GHOST_TSuccess types.
2022-11-16 12:31:29 +11:00
Campbell Barton 9f0e9f36be GHOST/Wayland: extend on comments regarding locking 2022-11-16 12:31:29 +11:00
Campbell Barton 3ff7d0796d GHOST/Wayland: limit the size of the events_pending vector
Avoid keeping allocated overly large events_pending vector in case of
long delays between processing events.

While in practice this isn't likely to cause problems, it's better to
avoid keeping unnecessarily large allocations.

Also remove invalid comment.
2022-11-15 16:36:57 +11:00
Campbell Barton 37b256e26f Fix T100855: Input while Blender is unresponsive exits under Wayland
Consume events in a thread to prevent Wayland's event buffer from
overflowing Waylands internal buffer and closing the connection.
From a users perspective this seemed like a crash.

Details:

- This is a workaround for a known bug in Wayland [0].
  Threaded event handling has been if-defed so it can be removed when
  it's no longer needed.

- GTK & QT use threaded event handling to avoid this problem
  (SDL on the other hand doesn't).

- The complexity and number of locks needed to handle events in a
  separate thread is a significant down-side, but as far as I can see
  this is necessary.

- Re-connecting to the Wayland server is possible but not practical as
  the OpenGL context is lost and as far as I can tell it's not possible
  to keep it active (see: D16492).

[0]: https://gitlab.freedesktop.org/wayland/wayland/-/issues/159
2022-11-15 15:26:31 +11:00
Campbell Barton f1646a4d5e GHOST/Wayland: share logic for xdg/libdecor window configuration
Split frame & frame_pending structs, making window actions simpler
to reason about.
2022-11-15 14:49:44 +11:00
Campbell Barton 56f783d883 GHOST/Wayland: only use a single swapBuffers for libdecor redrawing
Using a single draw works in my tests and I couldn't reproduce the
issue noted in the comment.

Also apply minor cleanup, assigning a variable before calling methods to
reduce diff-noise in planned changes.
2022-11-15 12:30:54 +11:00
Campbell Barton 0190b104c8 GHOST/Wayland: fix building when GHOST_OPENGL_ALPHA is defined 2022-11-14 12:01:26 +11:00
Campbell Barton d7971972fa GHOST/Wayland: call exit() when Wayland has a fatal error
Without this, a fatal error simply floods the stderr with the same
message without exiting.

Also add note on why reconnecting to the display server isn't practical.
2022-11-14 10:37:08 +11:00
Campbell Barton fe6114aaf5 GHOST/Wayland: remove display listener (was warning on startup)
This already has a default listener which uses waylands logging.
2022-11-14 10:12:34 +11:00
Campbell Barton a582abd923 Cleanup: add a system reference to the wayland window
Avoid relying on GHOST_ISystem::getSystem(), store the system instead.
2022-11-12 17:35:17 +11:00
Campbell Barton 436e6dca24 Fix window title not redrawing with Wayland/libdecor 2022-11-12 17:06:58 +11:00
Campbell Barton bc3f5c7e14 GHOST/Wayland: skip resizing the EGL surface unnecessarily
wl_egl_window_resize ran when the window became active/inactive for e.g.
2022-11-12 16:38:51 +11:00
Campbell Barton 787ae01dad Cleanup: move title into GWL_Window
Nearly all Wayland window data is stored in this struct,
follow this convention so GWL_Window functions can be self contained.
2022-11-12 16:26:53 +11:00
Campbell Barton 19ba229391 Cleanup: move Wayland window state utilities into lower level functions
Add low level gwl_window_* functions.
2022-11-12 16:26:51 +11:00
Campbell Barton 2a17fd40a5 Fix non-interactive window borders after changes to event handling
Regression in [0] causes LIBDECOR interactions not to be detected.

[0]: deb8ae6bd1
2022-11-12 16:26:50 +11:00
Campbell Barton 7931ae0df3 Cleanup: use snake-case for WAYLAND utility functions
It wasn't so obvious which functions were part of the GHOST API
and which system functions were utilities.

This convention was already in place but not always followed.
2022-11-12 15:25:51 +11:00
Campbell Barton deb8ae6bd1 GHOST/Wayland: replace roundtrip with dispatch_pending
Add a non-blocking version wrapper for wl_display_dispatch_pending.
This uses roughly the same logic as Wayland_PumpEvents in SDL.
Noticed this when investigating T100855.

Note that performing a round-trip doesn't seem necessary from looking
into QT/GTK & SDL event handling loops.
2022-11-12 15:11:43 +11:00
Campbell Barton 2a6a492a82 GHOST/Wayland: report a message when there is a fatal error
Help troubleshooting T100855.
2022-11-10 16:51:44 +11:00
Campbell Barton 4b6d58fd6d Cleanup: minor naming changes, make listener struct const 2022-11-10 16:47:55 +11:00
Campbell Barton 7e4e8cca7d GHOST/Wayland: add wl_display_listener for debugging
Currently only used for logging to help with debugging.
2022-11-10 11:12:52 +11:00
Campbell Barton 79dae1a43f Cleanup: compiler warnings (unused-parameter & missing-declarations) 2022-11-10 11:10:01 +11:00
Campbell Barton fb52a09840 Fix T102287: Unhandled Numpad Separator on QWERTZ under Wayland 2022-11-09 14:33:39 +11:00
Campbell Barton 60043a6158 Cleanup: quiet unused argument warning 2022-11-05 17:08:53 +11:00
Campbell Barton 889b3385b5 Cleanup: spelling in comments 2022-11-02 10:18:19 +11:00
Campbell Barton fe863b59db Fix T102194: unhandled number keys on AZERTY layout under Wayland
Support layouts such as AZERTY where the shift key is held for number
keys. Text entry remains unchanged but these keys now activate shortcuts
as expected.

This matches a fix in X11 for the same problem: T47228.
2022-11-01 14:28:54 +11:00
Campbell Barton afc091c3c4 Cleanup: spelling in comments 2022-11-01 12:24:58 +11:00
Campbell Barton 4d78211070 Cleanup: disambiguate naming for Wayland surfaces
Name surfaces for their use.
2022-11-01 11:32:17 +11:00