Commit Graph

6514 Commits

Author SHA1 Message Date
Jesse Yurkovich
d304ba7906 Cleanup: Rename GPU_select header to indicate its move to C++
From a prior PR[0] there was a desire to rename this header to more
clearly indicate it's C++ now.

[0] !112491

Pull Request: https://projects.blender.org/blender/blender/pulls/115631
2023-12-01 03:39:03 +01:00
Brecht Van Lommel
9ffd6dabf0 Fix build error in freestyle when not using precompiled headers 2023-11-30 14:31:29 +01:00
Campbell Barton
15db0cb446 Cleanup: use style for doxygen comment blocks 2023-11-30 14:15:11 +11:00
Campbell Barton
8c473df8c3 Cleanup: suppress CLANG warnings, remove unused variables 2023-11-30 10:48:33 +11:00
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Campbell Barton
d96cdb2231 Cleanup: simplify Python API use running scripts
- Remove unnecessary exception if Py_CompileStringObject fails.
- Remove unnecessary PyErr_Occurred check if Py_CompileStringObject
  succeeds (based on incorrect assumption from [0]).
- Pass closeit=1 to PyRun_FileExFlags so it's responsible for closing
  the file before executing code.
- Remove unnecessary temporary ReportList.

[0]: b9f6d66328
2023-11-28 22:33:09 +11:00
Campbell Barton
41739cd3fd PyAPI: remove use of stub script to execute files on WIN32
Workaround potential C-API `FILE` incompatibility by reading the
file data into memory, compiling & running it - matching existing logic
for text buffers text buffers. This replaces the in-lined stub-script
that re-opened the file from Python.

While the down-side of the stub-script was minor, it required some
non-obvious logic and had the disadvantage of requiring 2x scripts to
execute whenever a file was executed on WIN32.

Expose BLI_file_read_data_as_mem_from_handle as a public function
since it's useful to be able to read an existing FILE into memory.
2023-11-28 17:50:28 +11:00
Campbell Barton
48bc74953c PyAPI: raise an error when executing a directory on non-Windows systems
Passing a directory to --python would run it as a script without errors
since the directory would read as an empty file.

Raise an error instead because this is what Python it's self does.

This would already happen on WIN32 because the stub script was
executing the file from Python.
2023-11-28 17:40:07 +11:00
Campbell Barton
d71c449d25 PyAPI: use binary file access running scripts on non-WIN32 platforms
Python itself uses binary file access when opening files so this
shouldn't cause any problems.
2023-11-28 16:59:52 +11:00
Campbell Barton
2e1486da60 PyAPI: call 'sys.excepthook' for text editor exceptions
Resolves #115090, where exceptions from the text editor called
`sys.excepthook` in v3.6 but not in v4.0.

The error was caused by PyC_ExceptionBuffer calling PyErr_Display
instead of PyErr_Print.

While technically a regression in [0], the behavior in 3.6x wasn't
working properly either since a user-defined `sys.excepthook` could
prevent PyC_ExceptionBuffer from accessing the exception text.

Resolve with the following changes:

- BPy_errors_to_report has been updated not to print errors.
  Previously BPy_errors_to_report would *sometimes* print the error,
  which complicated situations where the caller wanted predictable
  behavior (always printing or never printing).

- `PyErr_Print()` must be used to display errors to the output,
  this will call `sys.excepthook` as it used to.

It's better not to rely on side effects of BPy_errors_to_report()
for error handling.

[0]: 6a0f98aeef
2023-11-28 13:13:41 +11:00
Ray Molenkamp
1b6cd937ff Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf 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/115425
2023-11-25 23:37:24 +01:00
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph 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/115422
2023-11-25 22:51:59 +01:00
Ray Molenkamp
b683bcc46c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any bf_intern_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/115323
2023-11-24 17:12:24 +01:00
Harley Acheson
b4b898063e Cleanup: Make format
Formatting changes resulting from Make Format
2023-11-23 15:09:36 -08:00
Jure Triglav
319ff28b7b Initial exposure of compute dispatch and image store in Python API
Motivation: When discussing with @Jeroen-Bakker and @aras_p about how to
approach sorting when rendering Gaussian splats in Blender, we realised that
compute shaders could help there (and have many other use cases), and that also
due to Blender 4.0 being on OpenGL >= 4.3, we can now rely on compute shaders
existing.

This PR is an initial pass for that functionality. It comes with a Python example, which
runs a compute shader and saves the output to a texture, which is then rendered in the
viewport.

There is no exposed support for storage buffers yet, but I expect I'll be able to work on
them soon if this is accepted.

The newly added parts are:
1. `gpu.compute.dispatch()`
2. a way set the compute source to `GPUShaderCreateInfo`: `shader_info.compute_source()`
3. a way to set the image store for `GPUShaderCreateInfo`: `shader_info.image()`
4. a way to set the `local_group_size` for `GPUShaderCreateInfo`: `shader_info.local_group_size(x,y,z)`
5. a way to get `max_work_group_size` from capabilities: `gpu.capabilities.max_work_group_size_get(index)`
6. a way to get `max_work_group_count` from capabilities: `gpu.capabilities.max_work_group_count_get(index)`

Pull Request: https://projects.blender.org/blender/blender/pulls/114238
2023-11-23 14:23:26 +01:00
Bastien Montagne
f0f378d31e Fix #115151, step one: Fallback to ID_OB in case of defined unknown ID type.
This is mainly intended to support forward compatibility with future,
unknwon ID types. Actual reported issue will be fixed in next commit.
2023-11-21 18:54:00 +01:00
Hans Goudey
29f3d54e91 Cleanup: Grammar in comments
- it's self vs. itself
- boiler plate vs boilerplate
2023-11-21 09:42:39 -05:00
Hans Goudey
f2bcd73bd2 Mesh: Move sculpt mask to a generic attribute
Store paint masks as generic float attributes, with the name
`".sculpt_mask"`. This is similar to 060a534141, which made
the same change for face sets. The benefits are general
consistency, nicer code, and more support in newer areas
that deal with attributes like geometry nodes.

The RNA API is replaced with one created in Python. The new
API only presents a single layer as an attribute class, so it
should be simpler to use in general:
- Before: `object.data.vertex_paint_masks[0].data[0].value`
- After: `object.data.vertex_paint_mask.data[0].value`

Pull Request: https://projects.blender.org/blender/blender/pulls/115119
2023-11-20 17:42:01 +01:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
nutti
cf41153798 Docs: include cls in bpy.utils.unregister_class
Ref: !114523
2023-11-10 14:32:23 +11:00
Campbell Barton
fdbf235ba3 Merge branch 'blender-v4.0-release' 2023-11-09 18:45:17 +11:00
Thomas Barlow
1058a93994 Fix #106696: Invalid flag combinations used in #PyObject_GetBuffer
Code using #PyObject_GetBuffer was combining the `PyBUF_FORMAT` and
`PyBUF_SIMPLE` flags, but the documentation specifies that
`PyBUF_FORMAT` can be |'d to any of the flags except `PyBUF_SIMPLE`
because the latter already implies format `B` (unsigned bytes).

The flags in such cases have been replaced with
`PyBUF_ND | PyBUF_FORMAT`, which has the additional requirement that the
buffer must provide it's `shape` field.

This fixes `memoryview` objects raising a `BufferError` when requested,
due to the invalid combination of flags making them be considered
invalid buffers when they would otherwise be valid.

Ref: !106697
2023-11-09 18:43:05 +11:00
Brecht Van Lommel
7618d4a0ac Merge branch 'blender-v4.0-release' into main 2023-11-07 20:32:33 +01:00
Brecht Van Lommel
fb2f77d088 Fix macOS Python SSL still not using bundled certificate
The code from 5ac392ca4 did not work on macOS since WITH_INSTALL_PORTABLE
is not set there. This issue was hidden before, but now happens due to
the changes in #114569 to avoid using /etc/ssl.
2023-11-07 20:13:20 +01:00
Aras Pranckevicius
13dbeac13c cleanup: remove "sa" acos/asin/sqrt functions and use "safe_" variants
Cleanup talked about in the previous semi-related PR, #114501

- saacos, saasin, sasqrt have been 100% identical to saacosf,
  saasinf, sasqrtf since 2012.
- For all the above, there exist more intuitively named safe_acosf,
  safe_asinf, safe_sqrtf that do the same thing, so switch all code to those.

Pull Request: https://projects.blender.org/blender/blender/pulls/114593
2023-11-07 19:49:01 +01:00
Campbell Barton
611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton
374295799a Merge branch 'blender-v4.0-release' 2023-11-01 11:40:49 +11:00
Andrej730
977c62c708 Docs: remove dpi from blf.size doc as it's deprecated
DPI argument of blf.size is deprecated, remove it from docs.

Ref !114319.
2023-11-01 11:37:16 +11:00
Campbell Barton
f60d1b3537 Merge branch 'blender-v4.0-release' 2023-10-31 21:36:37 +11:00
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