2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
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
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup bpygpu
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-01-07 12:39:13 +01:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
2024-06-19 17:54:35 +02:00
|
|
|
#include "BLI_sys_types.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
|
|
|
extern PyTypeObject BPyGPU_BufferType;
|
|
|
|
|
|
|
|
|
|
#define BPyGPU_Buffer_Check(v) (Py_TYPE(v) == &BPyGPU_BufferType)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Buffer Object
|
|
|
|
|
*
|
|
|
|
|
* For Python access to GPU functions requiring a pointer.
|
|
|
|
|
*/
|
2024-03-23 10:10:52 -04:00
|
|
|
struct BPyGPUBuffer {
|
2021-04-01 11:15:47 +11:00
|
|
|
PyObject_VAR_HEAD
|
|
|
|
|
PyObject *parent;
|
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 format;
|
|
|
|
|
int shape_len;
|
|
|
|
|
Py_ssize_t *shape;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
char *as_byte;
|
|
|
|
|
int *as_int;
|
|
|
|
|
uint *as_uint;
|
|
|
|
|
float *as_float;
|
|
|
|
|
|
|
|
|
|
void *as_void;
|
|
|
|
|
} buf;
|
2024-03-23 10:10:52 -04: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
|
|
|
|
2025-06-28 00:15:23 +00:00
|
|
|
[[nodiscard]] size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer);
|
2021-12-02 17:24:04 +11:00
|
|
|
/**
|
|
|
|
|
* Create a buffer object
|
|
|
|
|
*
|
|
|
|
|
* \param shape: An array of `shape_len` integers representing the size of each dimension.
|
|
|
|
|
* \param buffer: When not NULL holds a contiguous buffer
|
|
|
|
|
* with the correct format from which the buffer will be initialized
|
|
|
|
|
*/
|
2025-06-28 00:15:23 +00:00
|
|
|
[[nodiscard]] BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(int format,
|
|
|
|
|
const Py_ssize_t *shape,
|
|
|
|
|
int shape_len,
|
|
|
|
|
void *buffer);
|