| 
									
										
										
										
											2022-02-11 09:07:11 +11:00
										 |  |  | /* SPDX-License-Identifier: GPL-2.0-or-later
 | 
					
						
							|  |  |  |  * Copyright 2015 Blender Foundation. */ | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup bpygpu | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This file defines the offscreen functionalities of the 'gpu' module | 
					
						
							|  |  |  |  * used for off-screen OpenGL rendering. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-07-20 22:52:31 +10:00
										 |  |  |  * - Use `bpygpu_` for local API. | 
					
						
							|  |  |  |  * - Use `BPyGPU` for public API. | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <Python.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-09 14:49:05 +02:00
										 |  |  | #include "BKE_global.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-10 12:58:59 +01:00
										 |  |  | #include "BKE_lib_id.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | #include "BKE_scene.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 10:47:10 +10:00
										 |  |  | #include "DNA_scene_types.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "DNA_screen_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | #include "DNA_view3d_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 11:38:09 -03:00
										 |  |  | #include "GPU_context.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | #include "GPU_framebuffer.h"
 | 
					
						
							|  |  |  | #include "GPU_texture.h"
 | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  | #include "GPU_viewport.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 12:08:03 +01:00
										 |  |  | #include "ED_view3d_offscreen.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "../mathutils/mathutils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "../generic/py_capi_utils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-22 09:44:57 -03:00
										 |  |  | #include "gpu_py.h"
 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:48:55 -03:00
										 |  |  | #include "gpu_py_texture.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | #include "gpu_py_offscreen.h" /* own include */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | /* Define the free method to avoid breakage. */ | 
					
						
							|  |  |  | #define BPYGPU_USE_GPUOBJ_FREE_METHOD
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-19 15:17:46 +11:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name GPUOffScreen Common Utilities
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							| 
									
										
										
										
											2018-11-19 10:16:27 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  | static const struct PyC_StringEnumItems pygpu_framebuffer_color_texture_formats[] = { | 
					
						
							|  |  |  |     {GPU_RGBA8, "RGBA8"}, | 
					
						
							|  |  |  |     {GPU_RGBA16, "RGBA16"}, | 
					
						
							|  |  |  |     {GPU_RGBA16F, "RGBA16F"}, | 
					
						
							|  |  |  |     {GPU_RGBA32F, "RGBA32F"}, | 
					
						
							|  |  |  |     {0, NULL}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs) | 
					
						
							| 
									
										
										
										
											2018-11-19 10:16:27 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   if (UNLIKELY(py_ofs->ofs == NULL)) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_ReferenceError, | 
					
						
							|  |  |  | #ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
 | 
					
						
							|  |  |  |                     "GPU offscreen was freed, no further access is valid" | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |                     "GPU offscreen: internal error" | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-11-19 10:16:27 -02:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \
 | 
					
						
							|  |  |  |   { \ | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     if (UNLIKELY(pygpu_offscreen_valid_check(bpygpu) == -1)) { \ | 
					
						
							| 
									
										
										
										
											2018-11-19 10:16:27 -02:00
										 |  |  |       return NULL; \ | 
					
						
							|  |  |  |     } \ | 
					
						
							|  |  |  |   } \ | 
					
						
							|  |  |  |   ((void)0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Stack (Context Manager)
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Safer alternative to ensure balanced push/pop calls. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2021-06-24 15:56:58 +10:00
										 |  |  |   PyObject_HEAD /* Required Python macro. */ | 
					
						
							| 
									
										
										
										
											2021-06-24 17:10:22 +10:00
										 |  |  |   BPyGPUOffScreen *py_offscreen; | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   int level; | 
					
						
							|  |  |  |   bool is_explicitly_bound; /* Bound by "bind" method. */ | 
					
						
							|  |  |  | } OffScreenStackContext; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void pygpu_offscreen_stack_context__tp_dealloc(OffScreenStackContext *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |   Py_DECREF(self->py_offscreen); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   PyObject_DEL(self); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_stack_context_enter(OffScreenStackContext *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self->py_offscreen); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (!self->is_explicitly_bound) { | 
					
						
							|  |  |  |     if (self->level != -1) { | 
					
						
							|  |  |  |       PyErr_SetString(PyExc_RuntimeError, "Already in use"); | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |     GPU_offscreen_bind(self->py_offscreen->ofs, true); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |     self->level = GPU_framebuffer_stack_level_get(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_stack_context_exit(OffScreenStackContext *self, | 
					
						
							|  |  |  |                                                     PyObject *UNUSED(args)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self->py_offscreen); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (self->level == -1) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_RuntimeError, "Not yet in use\n"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const int level = GPU_framebuffer_stack_level_get(); | 
					
						
							|  |  |  |   if (level != self->level) { | 
					
						
							|  |  |  |     PyErr_Format( | 
					
						
							|  |  |  |         PyExc_RuntimeError, "Level of bind mismatch, expected %d, got %d\n", self->level, level); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |   GPU_offscreen_unbind(self->py_offscreen->ofs, true); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef pygpu_offscreen_stack_context__tp_methods[] = { | 
					
						
							|  |  |  |     {"__enter__", (PyCFunction)pygpu_offscreen_stack_context_enter, METH_NOARGS}, | 
					
						
							|  |  |  |     {"__exit__", (PyCFunction)pygpu_offscreen_stack_context_exit, METH_VARARGS}, | 
					
						
							|  |  |  |     {NULL}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject PyGPUOffscreenStackContext_Type = { | 
					
						
							|  |  |  |     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUFrameBufferStackContext", | 
					
						
							|  |  |  |     .tp_basicsize = sizeof(OffScreenStackContext), | 
					
						
							|  |  |  |     .tp_dealloc = (destructor)pygpu_offscreen_stack_context__tp_dealloc, | 
					
						
							|  |  |  |     .tp_flags = Py_TPFLAGS_DEFAULT, | 
					
						
							|  |  |  |     .tp_methods = pygpu_offscreen_stack_context__tp_methods, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(pygpu_offscreen_bind_doc, | 
					
						
							|  |  |  |              ".. function:: bind()\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Context manager to ensure balanced bind calls, even in the case of an error.\n"); | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_bind(BPyGPUOffScreen *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   OffScreenStackContext *ret = PyObject_New(OffScreenStackContext, | 
					
						
							|  |  |  |                                             &PyGPUOffscreenStackContext_Type); | 
					
						
							| 
									
										
										
										
											2021-03-08 14:40:57 +11:00
										 |  |  |   ret->py_offscreen = self; | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   ret->level = -1; | 
					
						
							|  |  |  |   ret->is_explicitly_bound = false; | 
					
						
							|  |  |  |   Py_INCREF(self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pygpu_offscreen_stack_context_enter(ret); | 
					
						
							|  |  |  |   ret->is_explicitly_bound = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (PyObject *)ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(pygpu_offscreen_unbind_doc, | 
					
						
							|  |  |  |              ".. method:: unbind(restore=True)\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Unbind the offscreen object.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :arg restore: Restore the OpenGL state, can only be used when the state has been " | 
					
						
							|  |  |  |              "saved before.\n" | 
					
						
							| 
									
										
										
										
											2021-03-16 12:48:00 -03:00
										 |  |  |              "   :type restore: bool\n"); | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   bool restore = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static const char *_keywords[] = {"restore", NULL}; | 
					
						
							| 
									
										
										
										
											2022-04-08 09:41:28 +10:00
										 |  |  |   static _PyArg_Parser _parser = { | 
					
						
							|  |  |  |       "|$" /* Optional keyword only arguments. */ | 
					
						
							|  |  |  |       "O&" /* `restore` */ | 
					
						
							|  |  |  |       ":unbind", | 
					
						
							|  |  |  |       _keywords, | 
					
						
							|  |  |  |       0, | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &restore)) { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GPU_offscreen_unbind(self->ofs, restore); | 
					
						
							|  |  |  |   GPU_apply_state(); | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name GPUOffscreen Type
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self), | 
					
						
							|  |  |  |                                          PyObject *args, | 
					
						
							|  |  |  |                                          PyObject *kwds) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-01-03 01:08:26 +11:00
										 |  |  |   BPYGPU_IS_INIT_OR_ERROR_OBJ; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 11:38:09 -03:00
										 |  |  |   GPUOffScreen *ofs = NULL; | 
					
						
							| 
									
										
										
										
											2020-07-02 17:28:30 +02:00
										 |  |  |   int width, height; | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |   struct PyC_StringEnum pygpu_textureformat = {pygpu_framebuffer_color_texture_formats, GPU_RGBA8}; | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   char err_out[256]; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |   static const char *_keywords[] = {"width", "height", "format", NULL}; | 
					
						
							| 
									
										
										
										
											2022-04-08 09:41:28 +10:00
										 |  |  |   static _PyArg_Parser _parser = { | 
					
						
							|  |  |  |       "i"  /* `width` */ | 
					
						
							|  |  |  |       "i"  /* `height` */ | 
					
						
							|  |  |  |       "|$" /* Optional keyword only arguments. */ | 
					
						
							|  |  |  |       "O&" /* `format` */ | 
					
						
							|  |  |  |       ":GPUOffScreen.__new__", | 
					
						
							|  |  |  |       _keywords, | 
					
						
							|  |  |  |       0, | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast( | 
					
						
							|  |  |  |           args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat)) { | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 11:38:09 -03:00
										 |  |  |   if (GPU_context_active_get()) { | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |     ofs = GPU_offscreen_create(width, height, true, pygpu_textureformat.value_found, err_out); | 
					
						
							| 
									
										
										
										
											2020-05-26 11:38:09 -03:00
										 |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |     STRNCPY(err_out, "No active GPU context found"); | 
					
						
							| 
									
										
										
										
											2020-05-26 11:38:09 -03:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   if (ofs == NULL) { | 
					
						
							|  |  |  |     PyErr_Format(PyExc_RuntimeError, | 
					
						
							|  |  |  |                  "gpu.offscreen.new(...) failed with '%s'", | 
					
						
							|  |  |  |                  err_out[0] ? err_out : "unknown error"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   return BPyGPUOffScreen_CreatePyObject(ofs); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen_width_doc, "Width of the texture.\n\n:type: `int`"); | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type)) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  |   return PyLong_FromLong(GPU_offscreen_width(self->ofs)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen_height_doc, "Height of the texture.\n\n:type: `int`"); | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type)) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  |   return PyLong_FromLong(GPU_offscreen_height(self->ofs)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen_color_texture_doc, | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |              "OpenGL bindcode for the color texture.\n\n:type: `int`"); | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | static PyObject *pygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type)) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  |   GPUTexture *texture = GPU_offscreen_color_texture(self->ofs); | 
					
						
							|  |  |  |   return PyLong_FromLong(GPU_texture_opengl_bindcode(texture)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:48:55 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen_texture_color_doc, | 
					
						
							|  |  |  |              "The color texture attached.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              ":type: :class:`gpu.types.GPUTexture`"); | 
					
						
							|  |  |  | static PyObject *pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void *UNUSED(type)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  |   GPUTexture *texture = GPU_offscreen_color_texture(self->ofs); | 
					
						
							| 
									
										
										
										
											2021-04-30 11:00:57 -03:00
										 |  |  |   return BPyGPUTexture_CreatePyObject(texture, true); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:48:55 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | PyDoc_STRVAR( | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     pygpu_offscreen_draw_view3d_doc, | 
					
						
							| 
									
										
										
										
											2021-08-04 19:24:19 -04:00
										 |  |  |     ".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix, " | 
					
						
							|  |  |  |     "do_color_management=False)\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     "\n" | 
					
						
							|  |  |  |     "   Draw the 3d viewport in the offscreen object.\n" | 
					
						
							|  |  |  |     "\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg scene: Scene to draw.\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     "   :type scene: :class:`bpy.types.Scene`\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg view_layer: View layer to draw.\n" | 
					
						
							| 
									
										
										
										
											2018-11-09 13:46:09 -02:00
										 |  |  |     "   :type view_layer: :class:`bpy.types.ViewLayer`\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg view3d: 3D View to get the drawing settings from.\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     "   :type view3d: :class:`bpy.types.SpaceView3D`\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg region: Region of the 3D View (required as temporary draw target).\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     "   :type region: :class:`bpy.types.Region`\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg view_matrix: View Matrix (e.g. ``camera.matrix_world.inverted()``).\n" | 
					
						
							| 
									
										
										
										
											2018-11-09 13:46:09 -02:00
										 |  |  |     "   :type view_matrix: :class:`mathutils.Matrix`\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |     "   :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n" | 
					
						
							| 
									
										
										
										
											2021-08-04 11:20:10 +02:00
										 |  |  |     "   :type projection_matrix: :class:`mathutils.Matrix`\n" | 
					
						
							|  |  |  |     "   :arg do_color_management: Color manage the output.\n" | 
					
						
							|  |  |  |     "   :type do_color_management: bool\n"); | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |   MatrixObject *py_mat_view, *py_mat_projection; | 
					
						
							|  |  |  |   PyObject *py_scene, *py_view_layer, *py_region, *py_view3d; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   struct Depsgraph *depsgraph; | 
					
						
							|  |  |  |   struct Scene *scene; | 
					
						
							|  |  |  |   struct ViewLayer *view_layer; | 
					
						
							|  |  |  |   View3D *v3d; | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |   ARegion *region; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 11:20:10 +02:00
										 |  |  |   bool do_color_management = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-08 09:41:28 +10:00
										 |  |  |   static const char *_keywords[] = { | 
					
						
							|  |  |  |       "scene", | 
					
						
							|  |  |  |       "view_layer", | 
					
						
							|  |  |  |       "view3d", | 
					
						
							|  |  |  |       "region", | 
					
						
							|  |  |  |       "view_matrix", | 
					
						
							|  |  |  |       "projection_matrix", | 
					
						
							|  |  |  |       "do_color_management", | 
					
						
							|  |  |  |       NULL, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   static _PyArg_Parser _parser = { | 
					
						
							|  |  |  |       "O"  /* `scene` */ | 
					
						
							|  |  |  |       "O"  /* `view_layer` */ | 
					
						
							|  |  |  |       "O"  /* `view3d` */ | 
					
						
							|  |  |  |       "O"  /* `region` */ | 
					
						
							|  |  |  |       "O&" /* `view_matrix` */ | 
					
						
							|  |  |  |       "O&" /* `projection_matrix` */ | 
					
						
							|  |  |  |       "|$" /* Optional keyword only arguments. */ | 
					
						
							|  |  |  |       "O&" /* `do_color_management` */ | 
					
						
							|  |  |  |       ":draw_view3d", | 
					
						
							|  |  |  |       _keywords, | 
					
						
							|  |  |  |       0, | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2018-09-27 00:22:57 -03:00
										 |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast(args, | 
					
						
							|  |  |  |                                         kwds, | 
					
						
							|  |  |  |                                         &_parser, | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |                                         &py_scene, | 
					
						
							|  |  |  |                                         &py_view_layer, | 
					
						
							|  |  |  |                                         &py_view3d, | 
					
						
							|  |  |  |                                         &py_region, | 
					
						
							| 
									
										
										
										
											2018-11-13 16:23:31 +01:00
										 |  |  |                                         Matrix_Parse4x4, | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |                                         &py_mat_view, | 
					
						
							| 
									
										
										
										
											2018-11-13 16:23:31 +01:00
										 |  |  |                                         Matrix_Parse4x4, | 
					
						
							| 
									
										
										
										
											2021-08-04 11:20:10 +02:00
										 |  |  |                                         &py_mat_projection, | 
					
						
							| 
									
										
										
										
											2021-08-04 19:24:19 -04:00
										 |  |  |                                         PyC_ParseBool, | 
					
						
							| 
									
										
										
										
											2021-08-04 11:20:10 +02:00
										 |  |  |                                         &do_color_management) || | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |       (!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) || | 
					
						
							|  |  |  |        !(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) || | 
					
						
							|  |  |  |        !(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) || | 
					
						
							|  |  |  |        !(region = PyC_RNA_AsPointer(py_region, "Region")))) { | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-09 10:44:02 -02:00
										 |  |  |   BLI_assert(BKE_id_is_in_global_main(&scene->id)); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-21 11:56:03 +02:00
										 |  |  |   depsgraph = BKE_scene_ensure_depsgraph(G_MAIN, scene, view_layer); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-27 20:21:55 +11:00
										 |  |  |   /* Disable 'bgl' state since it interfere with off-screen drawing, see: T84402. */ | 
					
						
							|  |  |  |   const bool is_bgl = GPU_bgl_get(); | 
					
						
							|  |  |  |   if (is_bgl) { | 
					
						
							|  |  |  |     GPU_bgl_end(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 16:23:31 +01:00
										 |  |  |   GPU_offscreen_bind(self->ofs, true); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-30 09:04:50 +11:00
										 |  |  |   /* Cache the #GPUViewport so the frame-buffers and associated textures are
 | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  |    * not reallocated each time, see: T89204 */ | 
					
						
							|  |  |  |   if (!self->viewport) { | 
					
						
							|  |  |  |     self->viewport = GPU_viewport_create(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     GPU_viewport_tag_update(self->viewport); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   ED_view3d_draw_offscreen(depsgraph, | 
					
						
							|  |  |  |                            scene, | 
					
						
							|  |  |  |                            v3d->shading.type, | 
					
						
							|  |  |  |                            v3d, | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |                            region, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |                            GPU_offscreen_width(self->ofs), | 
					
						
							|  |  |  |                            GPU_offscreen_height(self->ofs), | 
					
						
							| 
									
										
										
										
											2021-03-04 16:57:30 +11:00
										 |  |  |                            (const float(*)[4])py_mat_view->matrix, | 
					
						
							|  |  |  |                            (const float(*)[4])py_mat_projection->matrix, | 
					
						
							| 
									
										
										
										
											2019-06-06 08:37:43 +02:00
										 |  |  |                            true, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |                            true, | 
					
						
							|  |  |  |                            "", | 
					
						
							| 
									
										
										
										
											2021-08-04 11:20:10 +02:00
										 |  |  |                            do_color_management, | 
					
						
							| 
									
										
										
										
											2021-02-10 12:46:43 +01:00
										 |  |  |                            true, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |                            self->ofs, | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  |                            self->viewport); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 16:23:31 +01:00
										 |  |  |   GPU_offscreen_unbind(self->ofs, true); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-27 20:21:55 +11:00
										 |  |  |   if (is_bgl) { | 
					
						
							|  |  |  |     GPU_bgl_start(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | #ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen_free_doc, | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |              ".. method:: free()\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |              "   Free the offscreen object.\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |              "   The framebuffer, texture and render objects will no longer be accessible.\n"); | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | static PyObject *pygpu_offscreen_free(BPyGPUOffScreen *self) | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | { | 
					
						
							|  |  |  |   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  |   if (self->viewport) { | 
					
						
							|  |  |  |     GPU_viewport_free(self->viewport); | 
					
						
							|  |  |  |     self->viewport = NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   GPU_offscreen_free(self->ofs); | 
					
						
							|  |  |  |   self->ofs = NULL; | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-11-19 10:16:27 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  |   if (self->viewport) { | 
					
						
							|  |  |  |     GPU_viewport_free(self->viewport); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-03-30 06:12:48 +11:00
										 |  |  |   if (self->ofs) { | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     GPU_offscreen_free(self->ofs); | 
					
						
							| 
									
										
										
										
											2019-03-30 06:12:48 +11:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |   Py_TYPE(self)->tp_free((PyObject *)self); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | static PyGetSetDef pygpu_offscreen__tp_getseters[] = { | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"color_texture", | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      (getter)pygpu_offscreen_color_texture_get, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |      (setter)NULL, | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      pygpu_offscreen_color_texture_doc, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2021-04-30 10:48:55 -03:00
										 |  |  |     {"texture_color", | 
					
						
							|  |  |  |      (getter)pygpu_offscreen_texture_color_get, | 
					
						
							|  |  |  |      (setter)NULL, | 
					
						
							|  |  |  |      pygpu_offscreen_texture_color_doc, | 
					
						
							|  |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     {"width", (getter)pygpu_offscreen_width_get, (setter)NULL, pygpu_offscreen_width_doc, NULL}, | 
					
						
							|  |  |  |     {"height", (getter)pygpu_offscreen_height_get, (setter)NULL, pygpu_offscreen_height_doc, NULL}, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | static struct PyMethodDef pygpu_offscreen__tp_methods[] = { | 
					
						
							|  |  |  |     {"bind", (PyCFunction)pygpu_offscreen_bind, METH_NOARGS, pygpu_offscreen_bind_doc}, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     {"unbind", | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      (PyCFunction)pygpu_offscreen_unbind, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |      METH_VARARGS | METH_KEYWORDS, | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      pygpu_offscreen_unbind_doc}, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |     {"draw_view3d", | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      (PyCFunction)pygpu_offscreen_draw_view3d, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |      METH_VARARGS | METH_KEYWORDS, | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |      pygpu_offscreen_draw_view3d_doc}, | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | #ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     {"free", (PyCFunction)pygpu_offscreen_free, METH_NOARGS, pygpu_offscreen_free_doc}, | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-02-03 14:01:45 +11:00
										 |  |  |     {NULL, NULL, 0, NULL}, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_offscreen__tp_doc, | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |              ".. class:: GPUOffScreen(width, height, *, format='RGBA8')\n" | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |              "\n" | 
					
						
							|  |  |  |              "   This object gives access to off screen buffers.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |              "   :arg width: Horizontal dimension of the buffer.\n" | 
					
						
							| 
									
										
										
										
											2021-03-16 12:48:00 -03:00
										 |  |  |              "   :type width: int\n" | 
					
						
							| 
									
										
										
										
											2018-11-13 14:55:15 +01:00
										 |  |  |              "   :arg height: Vertical dimension of the buffer.\n" | 
					
						
							| 
									
										
										
										
											2021-12-29 11:45:27 -03:00
										 |  |  |              "   :type height: int\n" | 
					
						
							|  |  |  |              "   :arg format: Internal data format inside GPU memory for color attachment " | 
					
						
							|  |  |  |              "texture. Possible values are:\n" | 
					
						
							|  |  |  |              "      `RGBA8`,\n" | 
					
						
							|  |  |  |              "      `RGBA16`,\n" | 
					
						
							|  |  |  |              "      `RGBA16F`,\n" | 
					
						
							|  |  |  |              "      `RGBA32F`,\n" | 
					
						
							|  |  |  |              "   :type format: str\n"); | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | PyTypeObject BPyGPUOffScreen_Type = { | 
					
						
							|  |  |  |     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUOffScreen", | 
					
						
							|  |  |  |     .tp_basicsize = sizeof(BPyGPUOffScreen), | 
					
						
							|  |  |  |     .tp_dealloc = (destructor)BPyGPUOffScreen__tp_dealloc, | 
					
						
							|  |  |  |     .tp_flags = Py_TPFLAGS_DEFAULT, | 
					
						
							| 
									
										
										
											
												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 10:48:08 -03:00
										 |  |  |     .tp_doc = pygpu_offscreen__tp_doc, | 
					
						
							|  |  |  |     .tp_methods = pygpu_offscreen__tp_methods, | 
					
						
							|  |  |  |     .tp_getset = pygpu_offscreen__tp_getseters, | 
					
						
							|  |  |  |     .tp_new = pygpu_offscreen__tp_new, | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Public API
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *BPyGPUOffScreen_CreatePyObject(GPUOffScreen *ofs) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPyGPUOffScreen *self; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   self = PyObject_New(BPyGPUOffScreen, &BPyGPUOffScreen_Type); | 
					
						
							|  |  |  |   self->ofs = ofs; | 
					
						
							| 
									
										
										
										
											2021-11-23 13:55:17 +01:00
										 |  |  |   self->viewport = NULL; | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return (PyObject *)self; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #undef BPY_GPU_OFFSCREEN_CHECK_OBJ
 |