Commit Graph

22 Commits

Author SHA1 Message Date
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Jeroen Bakker
03caffe540 GPU: Deprecate GPU_DATA_UINT_24_8
GPU_DATA_UINT_24_8 isn't used anymore. We cannot phase out the data type
as it can still be used by add-ons. This PR will deprecate
`GPU_DATA_UINT_24_8`. When used in an add-on a deprecation message will
be shown.

Pull Request: https://projects.blender.org/blender/blender/pulls/140715
2025-06-20 12:17:20 +02:00
Campbell Barton
715a8268fa Build: resolve errors & deprecation warnings with Python 3.14 beta
Python 3.14 has moved some functionality into the public API,
use the updated names even with older Python versions.

Also resolve an error caused by variable reuse with delayed annotation
evaluation for TextureProperties_MixIn on startup.

Resolve #140695.
2025-06-20 14:34:25 +10:00
Jeroen Bakker
09af302457 GPU: Remove depth24 texture format
Metal and AMD/Intel/Vulkan don't support depth24 texture formats
natively. The backends implemented fallback to use depth32f in
stead.

Recently we removed all usages of depth24 to use depth32 and the
next step is to remove the depth24 format and the workarounds in
the backend.

Note: The removal of `GPU_DATA_UINT_24_8` isn't part of this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/140659
2025-06-19 16:24:06 +02:00
Jeroen Bakker
11ab2de07a Python/GPU: Deprecate DEPTH24 formats
GPU_DEPTH24_STENCIL8 and GPU_DEPTH_COMPONENT24 are deprecated in Blender
5.0. Internally they will be removed. When used via python they are
automatically converted to their DEPTH32F variant and a deprecation
warning will be displayed.

Pull Request: https://projects.blender.org/blender/blender/pulls/140644
2025-06-19 13:31:40 +02:00
Campbell Barton
e3d6051181 Cleanup: suppress cast-function-type warnings for CLANG
Extend the existing GCC pragma's and add the warning suppression
for Cycles & Freestyle.
2025-04-01 12:06:03 +11:00
Brecht Van Lommel
c7502b092d Cleanup: Various clang-tidy warnings in gpu
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Bastien Montagne
0b3a7cbe69 Cleanup: Move BKE_image.h and related headers to C++.
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/130174
2024-11-12 16:53:54 +01:00
Campbell Barton
3bcfb151c1 PyDoc: use Python's type annotation syntax for doc-strings
Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
2024-11-03 15:44:35 +11:00
Bastien Montagne
c3247aa4f0 Refactor: Move BPY generic headers to proper C++ ones.
NOTE: `bgl.h` was left unchanged, as it is deprecated code anyway, and
its conversion to C++ does not seem immediately trivial.
2024-09-25 18:04:27 +02:00
Brecht Van Lommel
da9f586748 Fix #104061: Python GPU module unusable after too early import
Add-ons may attempt to load the GPU module in background mode when no GPU
context has been initialized yet. This would give an error on import.

If then later the GPU context does get initialized, for example for a
render engine, import would still fail as the module is cached.

This reverts commit d7f124f06f, and again
throws errors in methods and constructors instead of module import.

Pull Request: https://projects.blender.org/blender/blender/pulls/123395
2024-06-19 17:54:35 +02:00
Hans Goudey
1dc16f909d Cleanup: Move GPU Python headers to C++ 2024-03-23 10:06:45 -04:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Brecht Van Lommel
abf4c4d9ef Refactor: Change functions to retrieve GPU textures from images
* For materials with UDIM tiles support, get array and mapping in one call
* For viewers that can use render results, add a dedicated function
* Fix potential use of render results in stencil overlay and grease pencil

Pull Request: https://projects.blender.org/blender/blender/pulls/117563
2024-02-01 20:32:24 +01:00
Campbell Barton
7436b578dd Cleanup: force wrapping all uses of PyDoc_STRVAR
Without this, minor edits can re-indent the whole doc-string at a
different level, causing diffs to be unnecessary noisy.
2024-01-25 10:22:16 +11: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
Campbell Barton
a6837ac517 PyAPI: support building with the up-coming Python 3.12
- Account for new member in _PyArg_Parser.

- Many Python op-codes have been removed.
  For the moment these are disabled in is_opcode_secure.
  Some should be added back as intrinsics, noted in code-comments.
2023-08-30 14:08:56 +10: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
Campbell Barton
de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton
d1aac3b08c Cleanup: various non-functional changes for C++ (python, makesrna)
- Remove redundant void, struct.
- Use function style casts.
2023-07-22 11:33:36 +10:00
Campbell Barton
056a7bbb5c Cleanup: ignore GCC cast-function-type warning for PyMethodDef's
PyMethodDef::ml_flags define the function signature making the warning
meaningless.
2023-07-22 11:13:55 +10:00
Jacques Lucke
ec05e5a3fc Python: move remaining python files to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110352
2023-07-21 19:41:03 +02:00