c73be23e17
Revert "Fix T89204: slow repeated rendering with GPUOffscreen.draw_view3d"
...
This reverts commit d03b26edbd
. There is some
refresh issue that needs to be solved before this can be enabled.
2021-06-17 02:06:26 +02:00
d03b26edbd
Fix T89204: slow repeated rendering with GPUOffscreen.draw_view3d
...
Cache the GPUViewport so the framebuffers and associated textures are not
reallocated each time.
2021-06-16 20:19:34 +02:00
f29a738e23
PyAPI: use keyword only arguments
...
Use keyword only arguments for the following functions.
- addon_utils.module_bl_info 2nd arg `info_basis`.
- addon_utils.modules 1st `module_cache`, 2nd arg `refresh`.
- addon_utils.modules_refresh 1st arg `module_cache`.
- bl_app_template_utils.activate 1nd arg `template_id`.
- bl_app_template_utils.import_from_id 2nd arg `ignore_not_found`.
- bl_app_template_utils.import_from_path 2nd arg `ignore_not_found`.
- bl_keymap_utils.keymap_from_toolbar.generate 2nd & 3rd args `use_fallback_keys` & `use_reset`.
- bl_keymap_utils.platform_helpers.keyconfig_data_oskey_from_ctrl 2nd arg `filter_fn`.
- bl_ui_utils.bug_report_url.url_prefill_from_blender 1st arg `addon_info`.
- bmesh.types.BMFace.copy 1st & 2nd args `verts`, `edges`.
- bmesh.types.BMesh.calc_volume 1st arg `signed`.
- bmesh.types.BMesh.from_mesh 2nd..4th args `face_normals`, `use_shape_key`, `shape_key_index`.
- bmesh.types.BMesh.from_object 3rd & 4th args `cage`, `face_normals`.
- bmesh.types.BMesh.transform 2nd arg `filter`.
- bmesh.types.BMesh.update_edit_mesh 2nd & 3rd args `loop_triangles`, `destructive`.
- bmesh.types.{BMVertSeq,BMEdgeSeq,BMFaceSeq}.sort 1st & 2nd arg `key`, `reverse`.
- bmesh.utils.face_split 4th..6th args `coords`, `use_exist`, `example`.
- bpy.data.libraries.load 2nd..4th args `link`, `relative`, `assets_only`.
- bpy.data.user_map 1st..3rd args `subset`, `key_types, `value_types`.
- bpy.msgbus.subscribe_rna 5th arg `options`.
- bpy.path.abspath 2nd & 3rd args `start` & `library`.
- bpy.path.clean_name 2nd arg `replace`.
- bpy.path.ensure_ext 3rd arg `case_sensitive`.
- bpy.path.module_names 2nd arg `recursive`.
- bpy.path.relpath 2nd arg `start`.
- bpy.types.EditBone.transform 2nd & 3rd arg `scale`, `roll`.
- bpy.types.Operator.as_keywords 1st arg `ignore`.
- bpy.types.Struct.{keyframe_insert,keyframe_delete} 2nd..5th args `index`, `frame`, `group`, `options`.
- bpy.types.WindowManager.popup_menu 2nd & 3rd arg `title`, `icon`.
- bpy.types.WindowManager.popup_menu_pie 3rd & 4th arg `title`, `icon`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.blend_paths 1st..3rd args `absolute`, `packed`, `local`.
- bpy.utils.execfile 2nd arg `mod`.
- bpy.utils.keyconfig_set 2nd arg `report`.
- bpy.utils.load_scripts 1st & 2nd `reload_scripts` & `refresh_scripts`.
- bpy.utils.preset_find 3rd & 4th args `display_name`, `ext`.
- bpy.utils.resource_path 2nd & 3rd arg `major`, `minor`.
- bpy.utils.script_paths 1st..4th args `subdir`, `user_pref`, `check_all`, `use_user`.
- bpy.utils.smpte_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.smpte_from_seconds 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.system_resource 2nd arg `subdir`.
- bpy.utils.time_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.time_to_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.units.to_string 4th..6th `precision`, `split_unit`, `compatible_unit`.
- bpy.utils.units.to_value 4th arg `str_ref_unit`.
- bpy.utils.user_resource 2nd & 3rd args `subdir`, `create`
- bpy_extras.view3d_utils.location_3d_to_region_2d 4th arg `default`.
- bpy_extras.view3d_utils.region_2d_to_origin_3d 4th arg `clamp`.
- gpu.offscreen.unbind 1st arg `restore`.
- gpu_extras.batch.batch_for_shader 4th arg `indices`.
- gpu_extras.batch.presets.draw_circle_2d 4th arg `segments`.
- gpu_extras.presets.draw_circle_2d 4th arg `segments`.
- imbuf.types.ImBuf.resize 2nd arg `resize`.
- imbuf.write 2nd arg `filepath`.
- mathutils.kdtree.KDTree.find 2nd arg `filter`.
- nodeitems_utils.NodeCategory 3rd & 4th arg `descriptions`, `items`.
- nodeitems_utils.NodeItem 2nd..4th args `label`, `settings`, `poll`.
- nodeitems_utils.NodeItemCustom 1st & 2nd arg `poll`, `draw`.
- rna_prop_ui.draw 5th arg `use_edit`.
- rna_prop_ui.rna_idprop_ui_get 2nd arg `create`.
- rna_prop_ui.rna_idprop_ui_prop_clear 3rd arg `remove`.
- rna_prop_ui.rna_idprop_ui_prop_get 3rd arg `create`.
- rna_xml.xml2rna 2nd arg `root_rna`.
- rna_xml.xml_file_write 4th arg `skip_typemap`.
2021-06-09 03:05:44 +10:00
2b660e825b
Fix T88365: GPUTexture.read returning a buffer with wrong size
...
The pixel components were not being considered.
2021-05-18 10:01:29 -03:00
ea7b00c64f
Fix T88345: Blender crash on GPUFrameBuffer creation
...
Misuse of indexes.
`color_attachements` has only color ones while `config` has color and depth.
2021-05-18 09:39:31 -03:00
3e6609a0dc
Cleanup: silence unused parameter warnings
...
Introduced in rB48fa029dd11b.
2021-05-15 14:13:22 -03:00
Germano Cavalcante
48fa029dd1
Python GPU: New 'platform' module
...
This module exposes the platform utils defined in the GPU module in C.
This will be useful for porting existing code with `bgl` to `gpu`.
Reviewed By: fclem, brecht, campbellbarton
Maniphest Tasks: T80730
Part of D11147
2021-05-14 12:26:40 -03:00
Germano Cavalcante
3f4f109646
Python GPU: New 'capabilities' module
...
This module exposes the capabilities defined in the GPU module in C.
This will be useful for porting existing code in `bgl` to `gpu`.
Reviewed By: fclem, brecht, campbellbarton
Maniphest Tasks: T80730
Part of D11147
2021-05-14 12:26:40 -03:00
777ba780a6
Cleanup: inconsistent parameter name
2021-05-13 13:06:42 +02:00
75536b5a61
Cleanup: compiler warnings
2021-05-01 00:49:55 +10:00
2bd9a28ff8
Cleanup: Rename #if GPU_USE_PY_REFERENCES
to #ifndef GPU_NO_USE_PY_REFERENCES
...
This is safer for incremental build.
And there was already a macro `GPU_USE_PY_REFERENCES` used elsewhere.
2021-04-30 11:20:39 -03:00
a711aa5b3c
Fix accidental lines removed in the last commit
2021-04-30 11:03:39 -03:00
a35d33d520
Fix gross errors in previous commit
2021-04-30 11:00:57 -03:00
2510bd3a5f
Python GPU: Add new methods to port the code templates in the manual
...
This commit adds a new API tha allow to replace the bgl API in the exemples on:
https://docs.blender.org/api/current/gpu.html
**Overview (New API):**
```
gpu.state: active_framebuffer_get
GPUFramebuffer: read_color
GPUOffscreen: texture_color
```
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D11031
2021-04-30 10:49:54 -03:00
Germano Cavalcante
04b6296e81
Python GPU: Add reference of PyObject GPU object to the GPU object itself
...
Instead of creating different python wrappers for the same GPU object,
return the same `PyObject` created earlier.
This also allows for more secure access to existing GPU objects.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D11044
2021-04-30 10:42:13 -03:00
48c5129d1f
Fix errors in Buffer.dimensions setter
...
- Error accessing the length from a sequence.
- Error comparing a boolean to -1.
Issues introduced in 19360c2c1c
2021-04-22 12:34:26 +10:00
932b23782a
Merge branch 'blender-v2.93-release'
2021-04-21 17:15:46 -03:00
0f66dbea90
Fix wrong flag for 'GPUFrameBuffer.viewport_get'
...
`GPUFrameBuffer.viewport_get` has no args.
2021-04-21 17:15:13 -03:00
19360c2c1c
Python GPU Buffer: Add a 'setter' to Buffer.dimensions
...
The attribute `Buffer.dimensions` does not need to be readonly.
2021-04-21 17:07:11 -03:00
d5c6485372
Cleanup: clang format
2021-04-01 11:18:26 +11:00
645fc0c767
Fix build error on windows
...
Error was caused by using `#if` directive in `PyDoc_STRVAR` macro.
This partially reverts 1e4c35d910
2021-03-31 09:46:38 +02:00
1e4c35d910
PyDoc: correct sphinx syntax for gpu.state.blend_set
2021-03-31 17:42:21 +11:00
3f47df577d
Cleanup: use new BLI_assert_unreachable macro
2021-03-24 12:38:08 +11:00
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
242a278b56
Cleanup: rename offs to offscreen
2021-03-08 14:40:57 +11:00
39b86a989d
Cleanup: use const arrays
2021-03-04 16:58:03 +11:00
a40ccde405
Fix logic for calling PyObject_GC_UnTrack
...
All tracked objects need a matching un-track,
also remove redundant Py_XDECREF call.
2021-03-04 15:18:10 +11:00
Germano Cavalcante
6c6b1c015c
GPU Python: Implement gpu.texture.from_image
...
It can be useful to replace `image.bindcode` and `image.gl_load`.
Used for example in https://docs.blender.org/api/current/gpu.html#d-image
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D10458
2021-03-01 17:38:57 -03:00
5be72125bf
Cleanup: Move some utilities to 'gpu_py.h'
2021-02-24 10:58:15 -03:00
Germano Cavalcante
086d70e910
GPU Python: Use 'PyC_ParseStringEnum' to parse items
...
Currently the GPU module for python has different ways to handle enums.
- Organizing items in `PyC_StringEnumItems` arrays and parsing them with `PyC_ParseStringEnum`.
- Using dedicated functions for each type of enum (`bpygpu_ParsePrimType`, `pygpu_ParseVertCompType` and `pygpu_ParseVertFetchMode`).
Although apparently more efficient (especially `pygpu_ParseVertCompType`
which transforms strings into integers for simple comparison), these
dedicated functions duplicate functionality, increase the complexity of
the code and consequently make it less readable.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D10456
2021-02-22 08:35:52 -03:00
73f4dfa3c5
Cleanup: Clang tidy else after return
2021-02-18 13:58:27 -06:00
7e11595364
Cleanup: clang-format
2021-02-19 02:19:53 +11:00
e79916eb47
Cleanup: order shape_len after shape argument
...
This matches nearly all other argument ordering in Blender,
including Python mathutils API.
2021-02-19 02:19:53 +11:00
10a54bbd06
Cleanup: spelling, correct doc-string arguments
2021-02-19 02:19:53 +11: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
89c79c3ed8
Cleanup: Abbreviate enums with 'UNSIGNED_' in the name
2021-02-17 12:38:21 -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
dae445d94a
Fix T85573: Building with Python 3.10a5 fails
...
Replace deprecated _PyUnicode_AsString{AndSize} usage.
T83626 still needs to be resolved before 3.10 is usable.
2021-02-13 23:09:55 +11:00
aa43e2ec29
PyAPI: use PyModule_AddType utility function
2021-02-12 08:08:16 +11: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
d9eeb7840f
Merge branch 'blender-v2.92-release'
2021-02-10 13:30:07 +01:00
97cc130f47
Fix T85395: Texture paint external edit wrong projection on reapply
...
Caused by rB5b34d11b55e0.
Above commit restored the view matrices in ED_view3d_draw_offscreen
_before_ they can be stored in the ImBuff (see ED_view3d_draw_offscreen
/ texture_paint_image_from_view_exec).
Now make restoring the view matrices optional and dont do this in case
of reprojection, so the used matrices can still be saved in the ImBuff
later.
Reviewed By: campbellbarton
Maniphest Tasks: T85395
Differential Revision: https://developer.blender.org/D10331
2021-02-10 13:25:31 +01: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
ea01c8c5f6
Fix T84402: Off-screen rendering works only once from Python
...
Off-screen drawing doesn't work once the 'bgl' workaround is enabled.
Disable this for off-screen drawing.
2021-01-27 20:23:00 +11:00
af88d23ffa
Revert "Fix typo; Documentation; Expose layer for framebuffer attachament; Add framebuffer viewport setter; Remove framebuffer restore; Expose framebuffer push/pop stack API; Remove blend modes; Remove depth_range_set; Implement GPU_face_culling, GPU_front_facing, GPU_point_size, GPU_line_width, GPU_viewport, GPU_color_mask and GPU_depth_mask"
...
This reverts commit 9db3d1951d
.
This was an accidental commit of the patch D8826
2021-01-10 21:07:04 -03:00
9db3d1951d
Fix typo; Documentation; Expose layer for framebuffer attachament; Add framebuffer viewport setter; Remove framebuffer restore; Expose framebuffer push/pop stack API; Remove blend modes; Remove depth_range_set; Implement GPU_face_culling, GPU_front_facing, GPU_point_size, GPU_line_width, GPU_viewport, GPU_color_mask and GPU_depth_mask
2021-01-10 19:01:53 -03: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