Commit Graph

6484 Commits

Author SHA1 Message Date
Campbell Barton
ea86a77bc5 Docs: add notes on populating bpy.app.driver_namespace
Address issues raised by #114155.

Also fix sphinx documentation generation using incorrect identifiers
when looking up references from PyStruct types
(was looking for `bpy.app.bpy.app.driver_namespace.py`).
2023-10-31 21:34:32 +11:00
Brecht Van Lommel
39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Clément Foucault
b0e7a6db56 Merge branch 'blender-v4.0-release'
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
2023-10-20 17:23:53 +02:00
Anthony Roberts
4e69e49e7e Add check for Qualcomm devices on Windows
Some of these devices are not capable of running >=4.0, due to issues
with Mesa's Compute Shaders and their D3D drivers.

This PR marks those GPUs as unsupported, and prints info to stdout.

A driver update will be available for 8cx Gen3 on the 17th October
from here:
https://www.qualcomm.com/products/mobile/snapdragon/pcs-and-tablets/snapdragon-8-series-mobile-compute-platforms/snapdragon-8cx-gen-3-compute-platform#Software

It will take longer via the standard MS Windows Update channels,
as there is certification, testing, etc required, but it is possible
to get the drivers, at least.

This issue applies even when using emulated x64.

If this does not get merged, all WoA devices will break with 4.0,
where older ones will just launch a grey screen and crash, and newer
ones will open, but scenes will not render correctly in Workbench.

These devices work by using Mesa's D3D12 Gallium driver ("GLOn12"),
which is why we have to read the DirectX driver version - the version
reported by OpenGL is the mesa version, which is independent of the
driver (which is the part with the bug).

Pull Request: https://projects.blender.org/blender/blender/pulls/113674
2023-10-20 17:18:35 +02:00
Sergey Sharybin
85c557ffa2 Cleanup: Rename BLI_string_utils.h to BLI_string_utils.hh
All users of it are now C++, which opens doors to add C++ to the
public API.
2023-10-20 10:27:26 +02:00
Campbell Barton
e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Christoph Lendenfeld
dcca6c2b8c Refactor: Remove nla_cache parameter from insert_keyframe
No functional changes.

The parameter was only passed in as `nullptr` or
as empty list that was immediately freed after without use.

Pull Request: https://projects.blender.org/blender/blender/pulls/113817
2023-10-17 11:48:29 +02:00
Campbell Barton
6b0769c448 Merge branch 'blender-v4.0-release' 2023-10-17 20:01:00 +11:00
Campbell Barton
5ac392ca40 Fix #102300: SSL/HTTPS Request Unable to Get Local Issuer Certificate
Resolve an error with SSL using a hard coded path to certificates on
Linux causing HTTPS access to fail.
request.urlopen(..) couldn't access any HTTPS URL's.
2023-10-17 19:58:34 +11:00
Bastien Montagne
9859622a66 BKE_reports: make the API thread-safe.
This commit makes using (most of) `BKE_report` API safe in
multi-threaded situation.

This is achieved by adding a `std::mutex` lock to the `ReportList`
struct (in a slightly convoluted way unfortunately, due to this being a
DNA struct). This lock is then used to make most operations on
`Reportlist` data thread-safe.

Note that while working on this, a few other minor issues aroze in
existing usages of Reportlist by the WM code, mainly the fact that
`wm_init_reports` and `wm_free_reports` were both useless:
  - init was called in a context where there is not yet any WM, so it
    was doing nothing.
  - free was called on a WM that would be later freed (as part of Main
    freeing), which would also call cleanup code for its `reports` data.
Both have been removed.

Further more, `wm_add_default` (which is the only place where a WM ID is
created) did not initialize properly it reports data, this has been
fixed.

This change is related to the wmJob thread-safety tasks and PRs (#112537,
!113548).

Pull Request: https://projects.blender.org/blender/blender/pulls/113561
2023-10-13 11:29:59 +02:00
Christoph Lendenfeld
555731f8aa Refactor: Move keyframing code to animrig
No functional changes.

Move the following keyframing functions to the animrig folder
* `insert_keyframe_direct`
* `insert_keyframe`
* `delete_keyframe`
* `clear_keyframe`

In order to disentangle the code I had to move the following as well
* `delete_keyframe_fcurve`
* `visualkey_can_use`
* `visualkey_get_values`

In order to sort the functions I made 3 files (and their header counterparts)
* fcurve.cc
* keyframing.cc
* visualkey.cc

The following functions I made public so they won't get duplicated
* `update_autoflags_fcurve_direct`
* `ANIM_setting_get_rna_values`

There are public keyframing functions that
I left in the editors/animation/keyframing.cc file
I'd like to limit the scope of this refactor, and then
clean up the moved functions before moving even more over

Part of #113278

Pull Request: https://projects.blender.org/blender/blender/pulls/113503
2023-10-12 12:46:47 +02:00
Jesse Yurkovich
2f026bf5ef Merge branch 'blender-v4.0-release' 2023-10-11 22:45:34 -07:00
Jesse Yurkovich
fa987dc059 Fix #110524: Use correct typed API to retrieve python GPU buffer sizes
Large GPU buffers can overflow their dimension property due to the use
of `PyLong_AsLong` instead of `PyLong_AsSsize_t` when processing the
buffer shape.

Pull Request: https://projects.blender.org/blender/blender/pulls/113566
2023-10-12 07:44:13 +02:00
Hans Goudey
8f27baf388 Merge branch 'blender-v4.0-release' 2023-10-09 23:54:43 +02:00
Hans Goudey
976eaae02f Cleanup: Move BKE_object.hh to C++
Simplifies the fix to #111120, where the object bounds functions
may return a C++ type instead of `BoundBox`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113462
2023-10-09 23:41:53 +02:00
Campbell Barton
1bb098bf44 CMake: WITH_OPENGL_BACKEND=OFF excludes EGL/EPOXY includes & libraries
This isn't complete as opensubdiv, hydra & XR still depend on OpenGL.
2023-10-07 18:30:17 +11:00
Jeroen Bakker
c801c73d79 Python: Update BGL Deprecation Warning
BGL is deprecated and will not work on Metal devices. Although the
inital plan was to remove it in Blender 4.0, We don't see any harm
to still have it in the code-base until OpenGL itself is deprecated.

Add-on developers are warned when using the BGL module that the
add-on/script will not work on all platforms.

There are still some limitations inside the GPU module that needs
a more friendly API. This API isn't clear at this time.

Pull Request: https://projects.blender.org/blender/blender/pulls/112579
2023-10-06 07:37:44 +02:00
Colin Basnett
46647ed911 Fix typo in documentation for BMVertSeq.new
Ref !113190.
2023-10-04 15:13:06 +11:00
Campbell Barton
c2ff509159 Fix incorrect function name in foreach_get/foreach_set exceptions 2023-10-01 14:19:44 +11:00
Campbell Barton
18f8579e38 Follow up to fix for #111117, remove array/collection length lookup
Revert a change from [0]. There is no need to count items in the
collection/array as the property iterator can detect this.

[0]: a280e8a68c
2023-10-01 14:07:56 +11:00
Martijn Versteegh
3f633503d3 Fix #111117: Partially revert a280e8a6
The size check was incorrect for mixed triangle/ngon/quad meshes.

Pull Request: https://projects.blender.org/blender/blender/pulls/112879
2023-10-01 00:17:46 +02:00
Hans Goudey
916d4c9d9b Cleanup: Move BKE_screen.h to C++
See #103343
2023-09-25 17:53:11 -04:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Campbell Barton
5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Hans Goudey
867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Campbell Barton
aba119e192 Cleanup: quiet CMake uninitialized variable warning, sort file lists 2023-09-22 11:04:25 +10:00
Sergey Sharybin
e807bf23f1 Cleanup: -Wmissing-braces compiler warning
Pull Request: https://projects.blender.org/blender/blender/pulls/112680
2023-09-21 17:50:05 +02:00
Jeroen Bakker
6d91d36161 GPU: Remove GPU_shader_storage_buffer_objects_support
Blender 4.0 requires OpenGL 4.3 which always support SSBO's.
Platforms that don't support enough SSBO bind points will be marked
as unsupported.

Users who start Blender on those platforms will be informed via a
dialog. This PR also updates the `--debug-gpu-force-workarounds`
to match our minimum requirements. Note that some bugs are still
there that should be solved in other PRs:

* Workbench only renders the object using a unit matrix this is because
  there is a bug in the workaround for shader_draw_parameters
* Navigating with middle mouse button is not working. Unsure what the
  cause is, but might be a missing feature check in the OpenGL backend.

Related to #112224

Pull Request: https://projects.blender.org/blender/blender/pulls/112572
2023-09-21 12:55:51 +02:00
Campbell Barton
fb81c37077 Cleanup: avoid redundant strlen calls 2023-09-20 12:11:33 +10:00
Campbell Barton
a288ab45b7 Fix Python exceptions from RNA methods showed twice
When RNA classes called into their Python methods,
exceptions would display twice once when reported and again from
PyErr_Print. This could happen when a Python defined poll method raised
an exception.

It also wasn't possible to suppress by redirecting `sys.stderr` for
example, because reporting printed directly to the stdout.

Resolve these issues by suppressing the reports output,
leaving PyErr_Print to output errors to sys.stderr.
2023-09-19 19:47:40 +10:00
Campbell Barton
75748f9d7a Fix error displaying exceptions in some cases
Replacing PyErr_Print with PyErr_Display in [0] caused string errors
not to display because PyErr_Display doesn't normalize the exception.

Normalizing before displaying the error resolves this.

[0]: 6a0f98aeef
2023-09-19 18:25:28 +10:00
Campbell Barton
e8df5cec83 PyAPI: free internal Python data using sys.exit(..)
Previously BPY_python_end wasn't called when scripts called sys.exit()
because BPY_python_end exited the Python interpreter.

Change this behavior to call BPY_python_end without exiting the Python
interpreter while freeing Blender/Python data.

While leaks in the context of sys.exit aren't especially important
it's generally preferable for sys.exit() to match Blender's code-paths
for exiting to avoid unexpected behavior.
2023-09-19 15:50:41 +10:00
Campbell Barton
a8b6c4c826 Docs: update code-comments for sys.exit() & handling SystemExit
Some of the comments for exiting were outdated & vague.
Add additional comments to clarify out SystemExit, sys.exit() & atexit
are used to handle exit requests from Python within Blender.
2023-09-19 15:01:08 +10:00
Campbell Barton
393c365daf Cleanup: code-comment formatting, remove commented prints 2023-09-19 15:00:21 +10:00
Campbell Barton
6a0f98aeef Fix memory leak in PyC_ExceptionBuffer for Py 3.12
Non-matching calls to PyErr_Fetch/Restore cause a leak in v3.12,
so ensure calls are symmetrical or avoid where possible.

Simplify extraction of the exception buffer.

- Only overwrite the stderr (the stdio isn't used).
- Simplify pyc_exception_buffer_handle_system_exit usage.
- Remove goto's.

Also simplify calling conventions for PyC_ExceptionBuffer functions.
- They must be called when an error has occurred.
- Always return a string, never null since a null return value would
  only happened in rare/unexpected cases which wasn't being checked
  for by some callers, leading to potential crashes.
2023-09-18 22:09:19 +10:00
Campbell Barton
19b9ee7f74 Cleanup: remove commented out PyC_ExceptionBuffer function
The internals of PyErr_Print/PyErr_Display & the traceback module
are different enough that it's not likely the Python traceback
implementation will be used.
2023-09-18 22:09:18 +10:00
Campbell Barton
2d057c0238 Cleanup: remove unnecessary PyErr_Fetch/Restore use in bpy_rna
srna_from_self had logic to replace the exception unless there was
already an exception set. This logic isn't needed, except in some
disabled code which has been updated. If srna_from_self ran with an
exception set it would leak memory in Python 3.12.
2023-09-18 17:38:55 +10:00
Campbell Barton
688595842e Fix memory leak with collections attributes in RNA for Python 3.12
PyErr_Fetch needs to call PyErr_Restore, avoid a resource leak by
not raising an error in the first place.
2023-09-18 17:15:43 +10:00
Campbell Barton
e3444fd314 Cleanup: various non-functional C++ changes 2023-09-17 09:05:40 +10:00
Campbell Barton
67c9056bed Fix memory leak in PyC_Err_Format_Prefix for Python 3.12
In Python 3.12 Every PyErr_Fetch must have a matching PyErr_Restore
call, otherwise references are created and never de-referenced.
2023-09-15 14:26:49 +10:00
Campbell Barton
425cc82aff Cleanup: remove unnecessary PyC_Err_Format_Prefix use
In this case there is no error to prefix, use PyErr_Format instead.
2023-09-15 14:23:16 +10:00
Campbell Barton
9903a692cc Cleanup: clarify & simplify Python traceback extraction
- Remove duplicate PyErr_NormalizeException call.
- Avoid unnecessary traceback casts.
- Remove warning about #97731 which has been resolved.
- Clarify comments.
2023-09-15 13:17:12 +10:00
Campbell Barton
9d92f03536 Fix #112399: Memory leak with exceptions from scripts in the text editor
Regression in [0] caused the function to jump to the error in the text
editor not to restore the exception, using the trace-back being iterated
over instead of the original value.

[0]: 2d2baeaf04
2023-09-15 12:23:42 +10:00
Campbell Barton
bcda667d37 Fix crash executing a script when sys.modules doesn't contain __main__
While in practice sys.modules has __main__ module, the purpose of
PyC_MainModule_Backup/Restore is to temporarily override __main__.

Running code outside of the text editor (callbacks for timers for e.g.)
could remove the __main__ module which would then crash when running
a script from the text editor.
2023-09-15 12:23:41 +10:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Hans Goudey
b67bf17139 Cleanup: Remove unnecessary extern "C" from Python files 2023-09-13 15:23:17 -04:00
Andrej730
0f6444a3ef Docs: add note to mathutils.Matrix.normalize()
Ref !111253.
2023-09-13 13:04:48 +10:00
Campbell Barton
5ab2f61d44 Cleanup: remove use of 'auto' 2023-09-08 16:53:27 +10:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
nutti
1494929f94 Python API: Fix docstring from method to classmethod
`draw_handler_add` and `draw_handler_remove` method of bpy.types.SpaceXXX
should be class method not method. However, Python API document does not show
the classmethod.

This PR fixes the Python API document of them.

Pull Request: https://projects.blender.org/blender/blender/pulls/111107
2023-09-05 12:56:41 +02:00