Commit Graph

57 Commits

Author SHA1 Message Date
Campbell Barton
753b6c031b PyDoc: include keyword only parameter in doc-strings 2025-08-26 02:14:30 +00:00
Campbell Barton
78c9d16919 PyDoc: correct types, consistent formatting for doc-strings in C++
Correct some types, ensure multi-line docs end with a newline,
sentences end with a full stop.
2025-08-22 14:05:28 +10:00
Clément Foucault
5681d41ca5 Fix: GPU: Wrong default size for compute local group size
The doc string was updated by 16430b10f1
but the default were not changed.
2025-08-21 11:32:43 +02:00
Clément Foucault
16430b10f1 EEVEE: World Sun Shadow no longer works in 4.5
On some drivers, the GLSL compiler doesn't reflect the omitted
`local_size_*` of a compute shader inside `gl_WorkGroupSize`.

This lead to the 2D size computation of 1D workgroups to become
0 which was bypassing the parallel reduction algorithms.

Ensuring `local_size_*` are always set fixes the issue.

For clarity, also fix the 1D shaders to not use `gl_WorkGroupSize.y`.
This also fix a copy paste error in the Metal backend.

This issue affected AMD drivers on Windows.

Rel #142046

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/144056
2025-08-07 09:40:57 +02:00
Clément Foucault
1611dc2fb3 GPU: Rever mass renaming removing GPUTexture type from python
This was accidentaly commited in 32d64d35bb
2025-07-24 18:19:59 +02:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
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
Campbell Barton
83ee7a3122 Merge branch 'blender-v4.5-release' 2025-06-27 18:58:40 +10:00
Andrej730
6dc0c85de6 Fix: PyDocs: GPUShader, use ref for better navigation
Also note removal version.

Ref !140846
2025-06-27 18:52:53 +10: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
Campbell Barton
6197335658 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 04:19:35 +00: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
Clément Foucault
59df50c326 GPU: Refactor Qualifier and ImageType
This allow to use types closer to GLSL in resource
declaration.

These are aliased for clarity in the GPU
module (i.e. `isampler2D` is shortened to `Int2D`).

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/137954
2025-04-24 14:38:13 +02:00
Clément Foucault
a6fa1b5969 DRW: Rename common_*_lib.glsl to follow module prefix 2025-04-16 20:19:09 +02:00
Clément Foucault
9990273d04 GPU: Change Type enum to use lower case values
This is to help for future resource declaration
using macros.

Rel #137261

Pull Request: https://projects.blender.org/blender/blender/pulls/137367
2025-04-11 22:39:01 +02:00
nutti
eb3fb565bd PyDoc: correct formatting for GPUShaderCreateInfo.depth_write
Ref !136846
2025-04-04 10:18:34 +11:00
Campbell Barton
7ae020ecd1 Cleanup: use our utility function to create a PyUnicode from a std:str 2025-04-01 12:33:56 +11:00
Jeroen Bakker
5a5471b622 Python: Add GPUShaderCreateInfo.depth_write method
Setting depth_write option of ShaderCreateInfo isn't available in
python GPU module. This PR adds support of it.

References #136732

Pull Request: https://projects.blender.org/blender/blender/pulls/136752
2025-03-31 12:37:56 +02:00
Brecht Van Lommel
27accea53e Cleanup: Various clang-tidy warnings in python
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Campbell Barton
b00550916c PyDoc: correct use of single back-ticks 2024-11-03 21:50:33 +11: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
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
Hans Goudey
4d03de9113 Cleanup: Make format 2024-01-18 11:40:19 -05:00
Thomas Dinges
64fc6d7890 Docs: Replace most wiki links with links to new developer docs
Exceptions:
* Links to personal wiki pages
* Pages that are not in the new developer docs yet (like Human Interface Guidelines)
* tools\check_wiki\check_wiki_file_structure.py needs a refactor
2024-01-18 16:49:38 +01:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Campbell Barton
4d965615fc Cleanup: various C++ changes (use ELEM & string copy macros) 2023-12-17 16:25:10 +11:00
Jason Fielder
9313750f0a Metal: Add fallback path for texture atomics V2
This patch adds an alternative path for devices/OSs
which do not support native texture atomics in Metal.
Support is encapsulated within the backend, ensuring
any allocated texture with the USAGE_ATOMIC flag is
allocated with a backing buffer, upon which atomic
operations happen.

The shader generation is also changed for the atomic
case, which instructs the backend to insert additional
buffer bind-points for the buffer resource. As Metal
also only supports buffer-backed textures for
textureBuffers or 2D textures, TextureArrays and
3D textures are emulated within a 2D texture, with
sample locations being indirected.

All usage of atomic textures MUST now utilise the
correct atomic texture types in the high level shader
and GPUShaderCreateInfo declarations.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115956
2023-12-11 23:00:20 +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
Campbell Barton
5ab2f61d44 Cleanup: remove use of 'auto' 2023-09-08 16:53:27 +10:00
Jason Fielder
68c4e05427 GPU: Add support for rasterization order groups
Enables performance optimizations and new rendering
features through allowing colour attachments to be
tagged with a rasterization order group. This means that
all accesses to the same pixel location are guaranteed
to happen in submission order.

This lays the ground work for tile-based architecture
optimizations, enabling additional features for
deferred rendering which allow subsequent passes
which operate on pixel data to occur in order, while
memory remains on-tile.

This patch allows fragment outputs to be tagged
with a raster order group and also adds a new
FragmentTileIn parameter to a shader, which allows
speciication of incoming parameters from a previous
draw.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/111748
2023-09-04 18:45:40 +02: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
d594954bf2 Cleanup: use C++ compatible struct declarations for Python API
Also add m_base & ob_base comments.
2023-07-16 18:13:15 +10:00
Campbell Barton
74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton
3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Jeroen Bakker
fd9b197226 GPU: Fix using FLOAT_2D_ARRAY and FLOAT_3D textures via Python.
Translation from python enum values were incorrect and textures created
in python using those types would result in faulty textures. In
renderdoc those textures would not bind.
2022-12-06 20:16:39 +01:00
Hans Goudey
97746129d5 Cleanup: replace UNUSED macro with commented args in C++ code
This is the conventional way of dealing with unused arguments in C++,
since it works on all compilers.

Regex find and replace: `UNUSED\((\w+)\)` -> `/*$1*/`
2022-10-03 17:38:16 -05: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
f68cfd6bb0 Cleanup: replace C-style casts with functional casts for numeric types 2022-09-25 20:17:08 +10:00
Campbell Barton
add1b6ab3c Cleanup: spelling in comments 2022-09-23 14:33:43 +10:00
Campbell Barton
4baa6e57bd Cleanup: prefer 'arg' over 'params' for sphinx documentation
While both are supported, 'arg' is in more common use so prefer it.
2022-09-19 14:24:31 +10:00
Thomas Dinges
cc8ea6ac67 Metal: MTLShader and MTLShaderGenerator implementation.
Full support for translation and compilation of shaders in Metal, using
GPUShaderCreateInfo. Includes render pipeline state creation and management,
enabling all standard GPU viewport rendering features in Metal.

Authored by Apple: Michael Parkin-White, Marco Giordano

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15563
2022-09-01 22:28:40 +02:00