Commit Graph

65 Commits

Author SHA1 Message Date
b71b1ae384 Python GPU: Improve the Python GPU API documentation
This fixes some errors of continuity and consistency of formatting on
https://docs.blender.org/api/current/gpu.html

This also details the description of some parameters.

Differential Revision: https://developer.blender.org/D10531
2021-03-16 12:48:39 -03:00
5be72125bf Cleanup: Move some utilities to 'gpu_py.h' 2021-02-24 10:58:15 -03:00
a7750f95b9 GPU Python: Rename 'uniform_buffer' to 'uniform_block'
From the the opengl wiki:
> Buffer objects are associated with a program's uniform block similarly to the way that texture objects are associated with sampler uniforms.
2021-02-17 13:23:35 -03:00
4430e8a008 Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer         #"__init__", "to_list"
gpu.types.GPUTexture     #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__",  "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf  #"__init__", "update"
gpu.state                #"blend_set",  "blend_get",  "depth_test_set",  "depth_test_get",  "depth_mask_set",  "depth_mask_get",  "viewport_set",  "viewport_get",  "line_width_set",  "line_width_get",  "point_size_set",  "color_mask_set",  "face_culling_set", "front_facing_set",  "program_point_size_set"
```

Add these methods to existing objects:
```
gpu.types.GPUShader  #"uniform_sample", "uniform_buffer"
```

Maniphest Tasks: T80481

Differential Revision: https://developer.blender.org/D8826
2021-02-17 12:27:19 -03:00
b7e1660d40 Cleanup: Use 'pygpu_' prefix in the cpython GPU module
`py_` prefix can be confused with the Python's own API's.
2021-02-17 10:38:59 -03:00
ed817d62bd Cleanup: Python GPU: Use consistent prefixes for local API
It was not following the own documentation at the top code that mentions
that for local API the prefix is "bpygpu_".
2021-02-11 16:13:02 -03:00
4895d1f9ce Cleanup: replace '_imp' function suffix with '_impl'
Use the more common abbreviation for `implementation`.
2021-02-04 13:10:29 +11:00
b10fac0432 Docs: Remove wrong debug flag info
Removed the `--debug-gpu-shaders` argument in bc94036a76 but forgot to amend
these changes.
2021-01-31 15:53:09 +01:00
ba83ad226d Fix error in recent commit
Introduced in rBcada56b1f72f537f9ab007cfafd430ac10c292fb
2020-12-11 17:54:27 -03:00
bbd7f94d8a Cleanup: Python GPU: change prefix 'bpygpu_' to 'py_' in static functions 2020-12-11 16:06:22 -03:00
cada56b1f7 Cleanup: GPU Python: Use 'PyC_ParseStringEnum' for string enum 2020-12-11 16:06:22 -03:00
YimingWu
b35b8c8849 Adding 3D_POLYLINE_UNIFORM_COLOR to PyGPU shader API
This would allow python script to access `lineWidth` uniform when drawing lines
without using `glLineWidth`.

Reviewed By: Jeroen Bakker

Differential Revision: https://developer.blender.org/D9518
2020-11-13 08:23:04 +01:00
72335d5e89 Pydoc: Move builtin GPU shader information to code
This fixes a compile warning for sphinx.
This commit includes some reformating of the information.
2020-10-11 18:21:28 -04:00
1b575cbb75 Cleanup: Pydoc strings 2020-10-11 18:19:42 -04:00
d023c4104c Cleanup: spelling, correct comments 2020-09-11 14:57:27 +10:00
efa7aaa97f Cleanup: use const variables where possible in the Python API 2020-08-20 16:10:13 +10:00
216d78687d GPUShader: GL backend isolation 2020-08-18 21:30:09 +02:00
b82cb0ad32 Cleanup: GPU: Remove GPU_shaderinterface_uniform_ensure 2020-06-02 16:46:38 +02:00
cecda64e2e GPU: ShaderInterface: Refactor to setup all uniform at creation time
This remove the complexity of queriying the locations at runtime and
allows for more performance and upfront binding specifications.

The benefit of doing everything at creation time is that we can assign binding
points in a predictable order which is going to be somewhat the same for
every similar shader.

This also rewrite GPU_vertformat_from_shader to not use shaderface.

This is to keep the shaderface simple. If it becomes necessary to not query
the shader after creation (i.e: vulkan?) we could just create the vert
format in advance at compilation for PyGPU shaders.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7879
2020-06-02 12:11:39 +02:00
21c658b718 GPUShader: Implement workaround for gizmo drawing on sRGB framebuffer
This solution involves adding a uniform to each fragment shader that is
used by gizmo drawing and use the framebuffer state to set this uniform
accordingly.

This solution can also be carried to external shaders (addons).
A single line of code would then be enough to fix the issue.

The only trickery here is the dummy define:
`#define srgb_to_framebuffer_space(a)`
This is in order to avoid breaking other DRW shaders that use the same
fragment shader code but do not need the tranformation.

Related to T74139

Reviewed By: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D7261
2020-04-14 20:44:56 +02:00
9a9f39e466 Cleanup: remove redundant 'char *' casts 2019-12-20 10:42:57 +11:00
0ec6564668 Cleanup: unused headers (GPU) 2019-09-14 00:22:24 +10:00
14b2c41216 Cleanup: doxy sections 2019-08-02 12:30:57 +10:00
f2da21e052 Python GPU Shader: Fix crash when uniform is not found.
Error in string format.
2019-06-05 08:45:12 -03:00
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
de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
744f633986 Cleanup: trailing commas
Needed for clan-format not to wrap onto one line.
2019-02-03 14:59:11 +11:00
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
f20dbc293f Cleanup: blank lines over doxy headers 2019-01-26 21:43:24 +11:00
2e4f1b592f Cleanup: use eGPU prefix for GPU enum types 2019-01-23 14:16:03 +11:00
4c95899098 GPU: Rename GPU_shader_get_uniform to GPU_shader_get_uniform_ensure
This is in order to make the API more multithread friendly inside the
draw manager.

GPU_shader_get_uniform will only serve to query the shader interface and
not do any GL call, making it threadsafe.

For now it only print a warning if the uniform was not queried before.
2019-01-17 19:44:01 +01:00
72e2a0cfb6 Cleanup: py-gpu error checks
Move gpu initialization checks to the start of each function instead
of mixing with argument parsing.
2019-01-03 01:08:26 +11:00
d07bc44a96 Revert file rename from T59773 fix
Mixing file rename with other changes should be avoided.

Using 'module_py_api' convention here
is in keeping with imbuf, idprop, blf & bmesh.
No reason for gpu to have a different convention.
2019-01-03 00:55:07 +11:00
945007b32e Fix T59773: Raise exception if the gpu module is used in backgound mode.
Instead of crashing, an error message is displayed if a function of the gpu module is called without a GPU context.

Reviewers: brecht, campbellbarton, JacquesLucke, mont29

Subscribers: abdelmatinboulbayam, amir.shehata

Differential Revision: https://developer.blender.org/D4143
2019-01-02 10:01:46 -02:00
69a9bcc206 minor cleanup 2018-11-14 13:06:11 +01:00
61ecd3d24e minor cleanup 2018-11-14 13:06:10 +01:00
92166ecd91 Py API: Remove GPUShader.transform_feedback_enable/disable
It couldn't really be used in the current implementation, so it is better to remove it instead of confusing everyone.
2018-11-14 12:27:09 +01:00
72369c638d Cleanup: python doc-strings
Indentation & trailing space.
2018-11-14 09:05:07 +11:00
444f1fd423 Py API Docs: Cleanup 2018-11-13 15:25:51 +01:00
a8e9959e07 API Docs: gpu api introduction + examples 2018-11-05 19:28:28 +01:00
974d158f3f PyAPI: GPU: improve GPUShader.from_builtin and GPUShader.code_from_builtin description. 2018-10-30 11:38:42 -03:00
41a284212a Cleanup: fix compiler warnings. 2018-10-28 17:46:51 +01:00
065d19e223 Fix parsing single int for uniform_int
This worked for float but not int.
2018-10-26 11:59:49 +11:00
0589368615 GPUShader: shader.uniform_float, matrix parsing
Add checks to parse 3x3 or 4x4 matrices,
also use error from `mathutils_array_parse` instead of overwriting.
2018-10-24 18:47:36 +11:00
fc3d771801 GPUShader: shader.uniform_float parameters
Allow to pass in single numbers, sequences and mathutils.* types into `shader.uniform_float`.

Reviewers: mano-wii

Differential Revision: https://developer.blender.org/D3820
2018-10-23 10:19:08 +02:00
e5182fa101 Cleanup: rename VertBuf.fill_attribute > attr_fill 2018-10-23 10:50:48 +11:00
59054d5eba Python API: fix docstrings 2018-10-22 15:01:25 +02:00
e333765d3e Python GPU: Best description for exceptions 2018-10-12 15:48:55 -03:00
b0b547bd1e Python GPU: Update shader.from_builtin and shader.code_from_builtin description. 2018-10-09 12:18:28 -03:00