1
1
Commit Graph

144 Commits

Author SHA1 Message Date
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
a45a881534 Spelling: familly -> family.
Fix spelling mistake originated from tmp-vulkan branch.
2023-02-03 10:16:01 +01:00
9cb061f4f0 Cleanup: spelling in comments 2022-12-05 12:58:18 +11:00
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
Jeroen Bakker
3655eb7ff0 Blender: Add command line argument to switch gpu backends.
Add command line argument to switch gpu backend. Add `--gpu-backend` option to
override the gpu backend selected by Blender.

Values for this option that will be available in releases for now are:
* opengl: Force blender to select OpenGL backend.

During development and depending on compile options additional values can exist:
* metal: Force Blender to select Metal backend.

When this option isn't provided the internal logic for GPU backend selection will be used.
Note that this is at the time of writing the same as always selecting the opengl backend.

Reviewed By: fclem, brecht, MichaelPW

Differential Revision: https://developer.blender.org/D16297
2022-10-19 15:13:26 +02:00
a24f11e0ec UI: show the windowing environment in the "About" splash
Show the windowing environment on non MS-Windows/Apple systems,
since X11/WAYLAND are selected startup there was no convenient way
for users to know which back-end was being used.

Include the windowing environment in the About splash & system-info.txt
since it will be useful for handling bug reports.

This commit adds a private API call not intended for general use
as I would like to be able to remove this later and it's only needed
in the specific case of testing if Blender is using WAYLAND or X11
(which maybe be used via XWayland).

Python scripts can already inspect the system to check which windowing
environment used, the API call is mainly useful for troubleshooting.
2022-10-10 11:22:41 +11:00
6d1d1bf2b1 Cleanup: spelling in comments
Also add missing task ID.
2022-09-28 09:41:31 +10:00
84ddb8b3cc UI: add preference to disable touchpad multitouch gestures
Available on Windows and macOS, where such gestures are supported.
For Windows, disabling this option restores touchpad behavior to
match Blender 3.2.

Ref T97925

Differential Revision: https://developer.blender.org/D16005
2022-09-26 22:59:35 +02:00
6c6a53fad3 Cleanup: spelling in comments, formatting, move comments into headers 2022-09-06 16:25:20 +10:00
3195a38120 Introduce headless OpenGL rendering on Linux
With this patch true headless OpenGL rendering is now possible on Linux.
It changes the logic of the WITH_HEADLESS build flag.

The headless backend is now always available with regular builds and
Blender will try to fall back to it if it fails to initialize other
backends while in background mode.

The headless backend only works on Linux as EGL is not used on Mac or Windows.
libepoxy does support windows and mac, so this can perhaps be remedied in the future.

Reviewed By: Brecht, Jeroen, Campbell

Differential Revision: http://developer.blender.org/D15555
2022-08-15 16:54:29 +02:00
6bd2c6789b GHOST: get/set cursor position now uses client instead of screen coords
Use client (window) relative coordinates for cursor position access,
this only moves the conversion from window-manager into GHOST,
(no functional changes).

This is needed for fix a bug in GHOST/Wayland which doesn't support
accessing absolute cursor coordinates & the window is needed to properly
access the cursor coordinates.

As it happens every caller to GHOST_GetCursorPosition was already making
the values window-relative, so there is little benefit in attempting to
workaround the problem on the Wayland side.

If needed the screen-space versions of functions can be exposed again.
2022-06-30 23:46:57 +10:00
a617929683 Cleanup: rename misleading/inconsistent GHOST types
Remove mask suffix from:
- GHOST_TButtonMask
- GHOST_TModifierKeyMask
.. neither are used as bit-masks.

Remove 'Grab' from:
- GHOST_kGrabAxisNone
- GHOST_kGrabAxisY
.. matching the existing GHOST_TAxisFlag & GHOST_kAxisX.
2022-06-27 20:36:40 +10:00
498f079d2c GHOST/Wayland: support displaying custom software cursors
Add a method to access the custom cursor from GHOST which is used
for drawing a software cursor. This means the knife tools cursor now
work as expected.

Although non-custom cursors are still not supported.
2022-06-18 17:16:42 +10:00
35b2b9b6e6 Fix T98793: Wayland clamps cursor movement fails with gnome-shell
The current gnome-shell (v42.2) has a bug where grabbing the cursor
doesn't scale the region when confining it to the window.

For Hi-DPI displays this means the cursor may be confined to a quarter
of the window, making grab unusable.

Even though this has been fixed up-stream the issue remains in the
latest release - so workaround the problem by implementing window
confined grab using a software cursor.

This is only used gnome-shell for displays that use Hi-DPI scaling.
2022-06-18 15:06:46 +10:00
f59418fd92 Cleanup: use booleans for GHOST C-API
Also use GHOST_ prefix for public functions.
2022-06-17 17:18:06 +10:00
65b1b1cd34 GHOST/Wayland: workaround inability to access window position
Wayland doesn't support accessing the position making functionality that
would map events to other windows fail, sometimes considering windows
overlapping when they weren't (as all window positions were zeroed).

Disable dragging between windows when accessing the window the position
isn't supported.
2022-06-16 15:22:46 +10:00
2601b9832d GHOST: add back-trace handler to the API
Add a back-trace handler to GHOST, so error handlers can include a
back-trace (when supported).

No functional changes.
2022-06-10 18:36:10 +10:00
8b8fbffeea Fix software cursor being used with absolute events in Wayland
The software cursor was being enabled with absolute events,
causing a problem with absolute tablet events.

This caused both cursors to be visible at once when using a tablet
(with D15152 applied).
2022-06-09 10:11:25 +10:00
a1d2efd190 GHOST/Wayland: draw a software-cursor when wrapping cursor motion
As Wayland doesn't support moving the cursor, draw a cross-hair cursor
at the location used by Blender.

Without this, the cursor was locked at the location where grab started,
making some actions unusable since the cursor location was invisible.

Resolves T77311.
2022-06-08 13:16:14 +10:00
93e4b15767 Cleanup: clang-tidy for GHOST X11/SDL/Wayland/NULL backends
Also early exit in some functions.
2022-05-29 13:25:58 +10:00
bf80dc2bd4 Add debugging info for Wintab activated by argument --debug-wintab.
Bonus: Added docs for `--debug-ghost`.

Differential Revision: https://developer.blender.org/D14610
2022-04-17 15:21:59 -07:00
94b2d83421 Cleanup: move documentation to headers, other minor corrections 2022-03-23 17:18:42 +11:00
aa500c4fca Cleanup: use back-slash for doxygen commands, color after parameters 2022-03-02 12:11:08 +11:00
bfe37b7255 Merge branch 'blender-v3.1-release' 2022-03-01 18:35:48 -03:00
9bd586a01e Fix T95608: Mac issues with drag drop on multi-monitor
Mousemove events are sent to windows.

In Windows OS, almost all mousemove events are sent to the window whose
mouse cursor is over.

On MacOS, the window with mousemove events is always the active window.
It doesn't matter if the mouse cursor is inside or outside the window.

So, in order for non-active windows to also have events,
`WM_window_find_under_cursor` is called to find those windows and send
the same events.

The problem is that to find the window, `WM_window_find_under_cursor`
only has the mouse coordinates available, it doesn't differentiate
which monitor these coordinates came from.

So the mouse on one monitor may incorrectly send events to a window on
another monitor.

The solution used is to use a native API on Mac to detect the window
under the cursor.

For Windows and Linux nothing has changed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D14197
2022-03-01 18:25:12 -03:00
c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Shrey Aggarwal
f021d46752 Cleanup: GHOST_ISystem::toggleConsole API
GHOST_ISystem::toggleConsole had a somewhat misleading name
it could be fed 4 different values, so it was not as much a
toggle as a set console window state.

This change renames `toggleConsole` to a more appropriately
named `setConsoleWindowState` and replaces the integer it had
to an enum so it's easy to tell what is being asked of it at
the call site.

Reviewed By: LazyDodo
Differential Revision: https://developer.blender.org/D14020
2022-02-08 17:40:48 -07:00
a87253942d Cleanup: Remove GHOST_isUpsideDownContext.
GHOST API only has a header definition. No implementation or usage.
2021-11-12 09:38:25 +01:00
9dda65455b XR Controller Support Step 4: Controller Drawing
Addresses T77127 (Controller Drawing).

Adds VR controller visualization and custom drawing via draw
handlers. Add-ons can draw to the XR surface (headset display) and
mirror window by adding a View3D draw handler of region type 'XR' and
draw type 'POST_VIEW'.  Controller drawing and custom overlays can be
toggled individually as XR session options, which will be added in a
future update to the VR Scene Inspection add-on.

For the actual drawing, the OpenXR XR_MSFT_controller_model extension
is used to load a glTF model provided by the XR runtime. The model's
vertex data is then used to create a GPUBatch in the XR session
state. Finally, this batch is drawn via the XR surface draw handler
mentioned above.

For runtimes that do not support the controller model extension, a
a simple fallback shape (sphere) is drawn instead.

Reviewed By: Severin, fclem

Differential Revision: https://developer.blender.org/D10948
2021-10-12 16:18:05 +09:00
a7bb537a61 Cleanup: unnecessary double pointers in XR module
No functional changes.
2021-08-07 21:30:15 +09:00
e844e9e8f3 XR Controller Support Step 2: Action Maps
Addresses the remaining portions of T77137 (Python API for Controller
Interaction), which was partially completed by D10942.

Adds an XR "action maps" system for loading XR action data from a
Python script. Action maps are accessible via the Python API, and are used
to pass default actions to the VR session during the
xr_session_start_pre() callback.

Since action maps are stored only as runtime data, they will be
cleaned up with the rest of the VR runtime data on file read or exit.

Reviewed By: Julian Eisel, Hans Goudey

Differential Revision: https://developer.blender.org/D10943
2021-08-05 23:40:17 +09:00
d3d4be1db3 XR: Action Binding Improvements
Provides several important improvements to the runtime action
bindings operation and internal API.

Moves input-specific action data (input thresholds, input regions,
pose offsets/spaces) from actions to more granular action bindings.
This allows a single action to be mapped to a variety of inputs,
without having to share a single input threshold, region, or space.

Also removes the need for action space creation API, as spaces for
pose actions will be automatically created with the bindings.

The correct action data for the current inputs is set by calling
xrGetCurrentInteractionProfile() to get the current profile and then
retrieving the corresponding mapped data.

Does not bring about any changes for users since only internal
runtime functionality is currently affected.

Reviewed By: Julian Eisel

Differential Revision: http://developer.blender.org/D12077
2021-08-05 13:14:26 +09:00
828c66f393 Cleanup: spelling in comments 2021-07-26 12:32:42 +10:00
Yuki Hashimoto
22bef356ae Cleanup: correct the comment in ghost
The same comments were written in clientToScreen and screenToClient in
GHOST. I corrected them.

Ref D11986
2021-07-21 23:14:03 +10:00
36584bbc2d Cleanup: quiet discarded-qualifiers warning 2021-07-06 12:05:25 +10:00
Nicholas Rishel
f3ec0d8e58 Replace Ghost integrals with stdint fixed width integers.
Also replace integer with bool in Ghost API when only used as boolean,
and uint8* with char* in Ghost API when variable is a string.

Reviewed By: brecht

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

Signed-off-by: Nicholas Rishel <rishel.nick@gmail.com>
2021-07-05 11:00:45 -07:00
addb1a5c9a Cleanup: spelling in comments 2021-07-02 12:15:29 +10:00
cb12fb78ca XR Controller Support Step 1: Internal Abstractions for OpenXR Actions
Adds internal API for creating and managing OpenXR actions at the
GHOST and WM layers. Does not bring about any changes for users since
XR action functionality is not yet exposed in the Python API (will be
added in a subsequent patch).

OpenXR actions are a means to communicate with XR input devices and
can be used to retrieve button/pose states or apply haptic feedback.
Actions are bound to device inputs via a semantic path binding
(https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#semantic-path-interaction-profiles),
which serves as an XR version of keymaps.

Main features:

- Abstraction of OpenXR action management functions to GHOST-XR,
  WM-XR APIs.
- New "xr_session_start_pre" callback for creating actions at
  appropriate point in the XR session.
- Creation of name-identifiable action sets/actions.
- Binding of actions to controller inputs.
- Acquisition of controller button states.
- Acquisition of controller poses.
- Application of controller haptic feedback.
- Carefully designed error handling and useful error reporting
  (e.g. action set/action name included in error message).

Reviewed By: Julian Eisel

Differential Revision: http://developer.blender.org/D10942
2021-05-16 03:36:31 +09:00
3e4863376e Cleanup: use boolean for has_event variable & return value 2021-05-04 00:17:45 +10:00
1c4ae8a11c UI: Removal of GHOST_CreateDialogWindow
Simplification of window creation code to allow greater flexibility.

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

Reviewed by Brecht Van Lommel
2021-02-09 16:14:31 -08:00
612598acd7 Cleanup: doxy comments (use colon after parameter name)
Also remove colon after `\note`.
2020-12-15 12:34:25 +11:00
eed6bf22a4 Cleanup: doxygen comments in ghost
Use colon after parameters, use hash to reference symbols.
2020-11-06 14:25:44 +11:00
058d29ed9a GHOST: Enable debug context on offscreen context too
This was a long standing TODO. This was also preventing debug callbacks
form other context than the main window.
2020-09-01 00:30:36 +02:00
1b1129f82a Code Style: use "#pragma once" in intern/ghost
More information can be found in D8466.
2020-08-07 10:18:01 +02:00
e062def3b4 Cleanup: spelling 2020-07-15 13:11:22 +10:00
d1f4adab24 Cleanup: spelling, correct reference to 'Mesh.mcol' 2020-05-29 12:58:29 +10:00
c43473e884 Cleanup: remove GHOST API to query tablet state from Window
It's not used by Blender anymore and it's unreliable since this state really
only makes sense associated with events in a particular order.

Ref D6675
2020-04-08 12:25:40 +02:00
d52326bab3 Cleanup: spelling 2020-04-03 12:38:04 +11:00
34465a7fb0 VR: Refactor DirectX context management
All DirectX management happens on Ghost level now, higher level code can
just assume everything is OpenGL (except of the upside-down drawing that
still needs to be done for DirectX). This is similar to how the
metal-layer is hidden outside of Ghost.

The Ghost-XR graphics binding for DirectX is responsible for managing
the DirectX compatibility now.
2020-04-02 17:43:45 +02:00