61 Commits

Author SHA1 Message Date
Jeroen Bakker
c50c3275be Vulkan: Acquire/release swapchain images
`GHOST_SwapWindowBuffers` doesn't fit well when using swapchains. In
that case an approach where swap chain images are acquired and released
would map better. This PR introduces `GHOST_SwapWindowBufferAcquire`
and `GHOST_SwapWindowBufferRelease` to be more in line with vulkan swap
chains.

Previous implementation would first record all GPU commands based on
the last used swap chain. In case a swapchain needed to be recreated
(window resize, move to other monitor) the recorded commands would
not match the swap chain and could lead to artifacts.

OpenGL only implements the release functions as they don't
have a mechanism to acquire a swap chain image. (Need to validate with
the Metal API how this is working and adapt is needed).

Currently when starting blender on a HDR capable display the first frame
would be based on an sRGB surface and presented on an extended RGB
(or other) surface. As these don't match the first frame could be incorrect and
also lead to UBs as another surface is expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/145728
2025-09-11 07:51:30 +02:00
Campbell Barton
ebfa7edeb1 Cleanup: use snake case, replace "m_" prefix with "_" suffix
Follow our own C++ conventions for GHOST.
2025-08-16 16:14:18 +10:00
Campbell Barton
07121d44ae Cleanup: use braces (follow own style guide) 2025-06-11 09:05:26 +00:00
Jacques Lucke
afd760f2b7 UI: Ghost: support horizontal scrolling for 2D editors
Some mice have an additional horizontal scroll wheel. This patch adds support
for receiving such events. By default it is used to scroll 2D editors left and right.

I originally developed this because I was missing it in the spreadsheet, but it
seems to be useful in many other editors too.

It's supported on Linux (Wayland), Windows and macos.

Pull Request: https://projects.blender.org/blender/blender/pulls/138758
2025-05-14 13:33:10 +02:00
Jonas Holzman
733d65e514 GHOST: Remove GHOST_DisplayManager and its implementations
The GHOST_DisplayManager and its implementations are for the most part
unmaintained and almost completely unused in all backends. To clean
things up, and avoid any confusion about how displays are handled in
each respective GHOST backend, this PR completely removes the GHOST
Display Manager, and move the few remaining logic it still held directly
to the corresponding backends.

The backends that were modified (apart from removing the display manager
initialization call from their init) are:

- Win32: `GHOST_SystemWin32::getNumDisplays()` was calling
  `m_displayManager->getNumDisplays`, the underlying system metric call
  (`GetSystemMetrics(SM_CMONITORS)`) was substituted in place.

- SDL: `GHOST_SystemSDL::createWindow` was calling
  `GHOST_DisplayManagerSDL::getCurrentDisplayModeSDL` which returned its
  `m_mode` data member by reference. Since none of the
  `GHOST_DisplayManagerSDL` member function that modified this data member
  were ever called, the variable `memset` initialization call was
  substituted in place from the `DisplayManagerSDL` constructor

Pull Request: https://projects.blender.org/blender/blender/pulls/138066
2025-04-28 14:26:39 +02:00
Campbell Barton
f459d97dfd Cleanup: remove unused full-screen support from GHOST
Remove full-screen support from GHOST API's.
Note that this only had back-end implements for X11 and WIN32.

This was last used for the Game Engine to run games full-screen,
removing as it's unused and it doesn't seem likely to be used in the
future.

This doesn't impact making Blender full-screen from the window menu
which uses a window decoration setting.

Ref: !137050
2025-04-08 05:18:57 +00:00
Campbell Barton
39295476d0 Cleanup: store const events in GHOST's event handling logic 2023-10-08 15:23:40 +11:00
Campbell Barton
d4dbbab5d9 Cleanup: locate break statements inside the case body
Follow the convention used almost everywhere in Blender's code.
2023-09-23 21:17:50 +10:00
Campbell Barton
057c9364fc Cleanup: use braces around statements 2023-09-12 14:48:20 +10:00
Campbell Barton
a2c6371e3e License headers: use SPDX-FileCopyrightText in intern/ghost 2023-06-14 17:42:15 +10: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
b626f1fd18 Cleanup: use ".cc" & ".hh" extensions for intern/ghost 2023-04-06 08:29:57 +10:00
Campbell Barton
4bead379c6 Cleanup: remove redundant (void) in C++ function declarations 2023-03-28 15:57:48 +11: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
Campbell Barton
21d77a417e Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb0.
2022-09-25 22:31:31 +10:00
Campbell Barton
95f05a6a4b Cleanup: spelling in comments 2022-09-16 18:14:33 +10:00
Campbell Barton
fe63124c3e Cleanup: add missing braces in GHOST 2022-08-12 11:13:07 +10:00
Campbell Barton
f59418fd92 Cleanup: use booleans for GHOST C-API
Also use GHOST_ prefix for public functions.
2022-06-17 17:18:06 +10:00
Campbell Barton
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
Campbell Barton
2289e26fa3 Cleanup: correct spelling in comments, remove profanity 2021-07-11 15:31:36 +10:00
Campbell Barton
5bbbc98471 Cleanup: spelling in comments 2021-07-07 13:42:46 +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
Campbell Barton
addb1a5c9a Cleanup: spelling in comments 2021-07-02 12:15:29 +10:00
Campbell Barton
3e4863376e Cleanup: use boolean for has_event variable & return value 2021-05-04 00:17:45 +10:00
Harley Acheson
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
Brecht Van Lommel
2580fa1602 Cleanup: remove STR_String usage from GHOST 2020-04-28 12:57:39 +02:00
Dalai Felinto
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
Campbell Barton
0b36780fb4 Revert "Cleanup: Cleanup: style, use braces for GHOST (X11/SDL)"
This reverts commit 935c9ab0de.

Clang-tidy was making unrelated *fixes*.
2019-06-04 11:36:54 +10:00
Campbell Barton
935c9ab0de Cleanup: Cleanup: style, use braces for GHOST (X11/SDL) 2019-06-04 11:30:31 +10:00
Campbell Barton
5b1fcf8833 Cleanup: comments (long lines) in ghost 2019-05-01 20:32:38 +10:00
Campbell Barton
108045faa0 ClangFormat: format '#if 0' code in intern/ 2019-04-17 08:17:13 +02:00
Campbell Barton
e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton
3316853323 Cleanup: conform headers to have license first
Also remove doxy comments for licenses and add missing GPL header.
2019-02-18 08:22:11 +11:00
Campbell Barton
4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton
65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton
58e8c71cbd Cleanup: strip ghost trailing space 2018-06-04 18:47:57 +02:00
Campbell Barton
72565fbf30 Cleanup: style, spelling 2015-07-06 17:45:11 +10:00
Campbell Barton
e84b0e4c35 Ghost: update tests for recent changes 2015-04-04 17:21:18 +11:00
Campbell Barton
ea9d94cf28 Spelling 2014-08-06 05:41:14 +10:00
Campbell Barton
c1c26c36f6 Style Cleanup: remove preprocessor indentation (updated wiki style guide too) 2013-12-22 14:12:19 +11:00
Campbell Barton
43c83e2458 fix double free in ghost c++ gears test program. 2013-09-11 01:15:13 +00:00
Campbell Barton
47ec91e8d3 code clenup: comments and some style edits on ghost/osx (odd indentation) 2012-09-06 02:10:09 +00:00
Campbell Barton
8b865c01cd style cleanup: comments 2012-06-30 22:49:33 +00:00
Campbell Barton
f5f25b81e8 style cleanup:
also fix for building ghost test and fix double free in one of the tests
2012-06-17 09:58:26 +00:00
Campbell Barton
9abd6e7651 style cleanup 2012-05-24 13:18:53 +00:00
Campbell Barton
9c9a5b882d style cleanup: ghost 2012-05-19 09:57:55 +00:00
Campbell Barton
e84c0980a3 correct indentation and some whitespace edits (no functional changes) 2011-11-11 13:09:14 +00:00
Campbell Barton
4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Campbell Barton
f9ea19ac12 spaces -> tabs (only whitespace changes) 2011-10-06 22:02:50 +00:00
Campbell Barton
5913179f85 CMake file to build ghost tests again. 2011-07-03 16:17:38 +00:00