Blender  V3.3
gpu_py_capabilities.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
10 #include <Python.h>
11 
12 #include "BLI_utildefines.h"
13 
14 #include "GPU_capabilities.h"
15 
16 #include "gpu_py_capabilities.h" /* own include */
17 
18 /* -------------------------------------------------------------------- */
22 PyDoc_STRVAR(pygpu_max_texture_size_get_doc,
23  ".. function:: max_texture_size_get()\n"
24  "\n"
25  " Get estimated maximum texture size to be able to handle.\n"
26  "\n"
27  " :return: Texture size.\n"
28  " :rtype: int\n");
29 static PyObject *pygpu_max_texture_size_get(PyObject *UNUSED(self))
30 {
31  return PyLong_FromLong(GPU_max_texture_size());
32 }
33 
34 PyDoc_STRVAR(pygpu_max_texture_layers_get_doc,
35  ".. function:: max_texture_layers_get()\n"
36  "\n"
37  " Get maximum number of layers in texture.\n"
38  "\n"
39  " :return: Number of layers.\n"
40  " :rtype: int\n");
41 static PyObject *pygpu_max_texture_layers_get(PyObject *UNUSED(self))
42 {
43  return PyLong_FromLong(GPU_max_texture_layers());
44 }
45 
46 PyDoc_STRVAR(pygpu_max_textures_get_doc,
47  ".. function:: max_textures_get()\n"
48  "\n"
49  " Get maximum supported texture image units used for\n"
50  " accessing texture maps from the vertex shader and the\n"
51  " fragment processor.\n"
52  "\n"
53  " :return: Texture image units.\n"
54  " :rtype: int\n");
55 static PyObject *pygpu_max_textures_get(PyObject *UNUSED(self))
56 {
57  return PyLong_FromLong(GPU_max_textures());
58 }
59 
60 PyDoc_STRVAR(pygpu_max_textures_vert_get_doc,
61  ".. function:: max_textures_vert_get()\n"
62  "\n"
63  " Get maximum supported texture image units used for\n"
64  " accessing texture maps from the vertex shader.\n"
65  "\n"
66  " :return: Texture image units.\n"
67  " :rtype: int\n");
68 static PyObject *pygpu_max_textures_vert_get(PyObject *UNUSED(self))
69 {
70  return PyLong_FromLong(GPU_max_textures_vert());
71 }
72 
73 PyDoc_STRVAR(pygpu_max_textures_geom_get_doc,
74  ".. function:: max_textures_geom_get()\n"
75  "\n"
76  " Get maximum supported texture image units used for\n"
77  " accessing texture maps from the geometry shader.\n"
78  "\n"
79  " :return: Texture image units.\n"
80  " :rtype: int\n");
81 static PyObject *pygpu_max_textures_geom_get(PyObject *UNUSED(self))
82 {
83  return PyLong_FromLong(GPU_max_textures_geom());
84 }
85 
86 PyDoc_STRVAR(pygpu_max_textures_frag_get_doc,
87  ".. function:: max_textures_frag_get()\n"
88  "\n"
89  " Get maximum supported texture image units used for\n"
90  " accessing texture maps from the fragment shader.\n"
91  "\n"
92  " :return: Texture image units.\n"
93  " :rtype: int\n");
94 static PyObject *pygpu_max_textures_frag_get(PyObject *UNUSED(self))
95 {
96  return PyLong_FromLong(GPU_max_textures_frag());
97 }
98 
99 PyDoc_STRVAR(pygpu_max_uniforms_vert_get_doc,
100  ".. function:: max_uniforms_vert_get()\n"
101  "\n"
102  " Get maximum number of values held in uniform variable\n"
103  " storage for a vertex shader.\n"
104  "\n"
105  " :return: Number of values.\n"
106  " :rtype: int\n");
107 static PyObject *pygpu_max_uniforms_vert_get(PyObject *UNUSED(self))
108 {
109  return PyLong_FromLong(GPU_max_uniforms_vert());
110 }
111 
112 PyDoc_STRVAR(pygpu_max_uniforms_frag_get_doc,
113  ".. function:: max_uniforms_frag_get()\n"
114  "\n"
115  " Get maximum number of values held in uniform variable\n"
116  " storage for a fragment shader.\n"
117  "\n"
118  " :return: Number of values.\n"
119  " :rtype: int\n");
120 static PyObject *pygpu_max_uniforms_frag_get(PyObject *UNUSED(self))
121 {
122  return PyLong_FromLong(GPU_max_uniforms_frag());
123 }
124 
125 PyDoc_STRVAR(pygpu_max_batch_indices_get_doc,
126  ".. function:: max_batch_indices_get()\n"
127  "\n"
128  " Get maximum number of vertex array indices.\n"
129  "\n"
130  " :return: Number of indices.\n"
131  " :rtype: int\n");
132 static PyObject *pygpu_max_batch_indices_get(PyObject *UNUSED(self))
133 {
134  return PyLong_FromLong(GPU_max_batch_indices());
135 }
136 
137 PyDoc_STRVAR(pygpu_max_batch_vertices_get_doc,
138  ".. function:: max_batch_vertices_get()\n"
139  "\n"
140  " Get maximum number of vertex array vertices.\n"
141  "\n"
142  " :return: Number of vertices.\n"
143  " :rtype: int\n");
144 static PyObject *pygpu_max_batch_vertices_get(PyObject *UNUSED(self))
145 {
146  return PyLong_FromLong(GPU_max_batch_vertices());
147 }
148 
149 PyDoc_STRVAR(pygpu_max_vertex_attribs_get_doc,
150  ".. function:: max_vertex_attribs_get()\n"
151  "\n"
152  " Get maximum number of vertex attributes accessible to\n"
153  " a vertex shader.\n"
154  "\n"
155  " :return: Number of attributes.\n"
156  " :rtype: int\n");
157 static PyObject *pygpu_max_vertex_attribs_get(PyObject *UNUSED(self))
158 {
159  return PyLong_FromLong(GPU_max_vertex_attribs());
160 }
161 
162 PyDoc_STRVAR(pygpu_max_varying_floats_get_doc,
163  ".. function:: max_varying_floats_get()\n"
164  "\n"
165  " Get maximum number of varying variables used by\n"
166  " vertex and fragment shaders.\n"
167  "\n"
168  " :return: Number of variables.\n"
169  " :rtype: int\n");
170 static PyObject *pygpu_max_varying_floats_get(PyObject *UNUSED(self))
171 {
172  return PyLong_FromLong(GPU_max_varying_floats());
173 }
174 
175 PyDoc_STRVAR(pygpu_extensions_get_doc,
176  ".. function:: extensions_get()\n"
177  "\n"
178  " Get supported extensions in the current context.\n"
179  "\n"
180  " :return: Extensions.\n"
181  " :rtype: tuple of string\n");
182 static PyObject *pygpu_extensions_get(PyObject *UNUSED(self))
183 {
184  int extensions_len = GPU_extensions_len();
185  PyObject *ret = PyTuple_New(extensions_len);
186  PyObject **ob_items = ((PyTupleObject *)ret)->ob_item;
187  for (int i = 0; i < extensions_len; i++) {
188  ob_items[i] = PyUnicode_FromString(GPU_extension_get(i));
189  }
190 
191  return ret;
192 }
193 
196 /* -------------------------------------------------------------------- */
200 static struct PyMethodDef pygpu_capabilities__tp_methods[] = {
201  {"max_texture_size_get",
202  (PyCFunction)pygpu_max_texture_size_get,
203  METH_NOARGS,
204  pygpu_max_texture_size_get_doc},
205  {"max_texture_layers_get",
206  (PyCFunction)pygpu_max_texture_layers_get,
207  METH_NOARGS,
208  pygpu_max_texture_layers_get_doc},
209  {"max_textures_get",
210  (PyCFunction)pygpu_max_textures_get,
211  METH_NOARGS,
212  pygpu_max_textures_get_doc},
213  {"max_textures_vert_get",
214  (PyCFunction)pygpu_max_textures_vert_get,
215  METH_NOARGS,
216  pygpu_max_textures_vert_get_doc},
217  {"max_textures_geom_get",
218  (PyCFunction)pygpu_max_textures_geom_get,
219  METH_NOARGS,
220  pygpu_max_textures_geom_get_doc},
221  {"max_textures_frag_get",
222  (PyCFunction)pygpu_max_textures_frag_get,
223  METH_NOARGS,
224  pygpu_max_textures_frag_get_doc},
225  {"max_uniforms_vert_get",
226  (PyCFunction)pygpu_max_uniforms_vert_get,
227  METH_NOARGS,
228  pygpu_max_uniforms_vert_get_doc},
229  {"max_uniforms_frag_get",
230  (PyCFunction)pygpu_max_uniforms_frag_get,
231  METH_NOARGS,
232  pygpu_max_uniforms_frag_get_doc},
233  {"max_batch_indices_get",
234  (PyCFunction)pygpu_max_batch_indices_get,
235  METH_NOARGS,
236  pygpu_max_batch_indices_get_doc},
237  {"max_batch_vertices_get",
238  (PyCFunction)pygpu_max_batch_vertices_get,
239  METH_NOARGS,
240  pygpu_max_batch_vertices_get_doc},
241  {"max_vertex_attribs_get",
242  (PyCFunction)pygpu_max_vertex_attribs_get,
243  METH_NOARGS,
244  pygpu_max_vertex_attribs_get_doc},
245  {"max_varying_floats_get",
246  (PyCFunction)pygpu_max_varying_floats_get,
247  METH_NOARGS,
248  pygpu_max_varying_floats_get_doc},
249  {"extensions_get", (PyCFunction)pygpu_extensions_get, METH_NOARGS, pygpu_extensions_get_doc},
250  {NULL, NULL, 0, NULL},
251 };
252 
253 PyDoc_STRVAR(pygpu_capabilities__tp_doc, "This module provides access to the GPU capabilities.");
254 static PyModuleDef pygpu_capabilities_module_def = {
255  PyModuleDef_HEAD_INIT,
256  .m_name = "gpu.capabilities",
257  .m_doc = pygpu_capabilities__tp_doc,
258  .m_methods = pygpu_capabilities__tp_methods,
259 };
260 
262 {
263  PyObject *submodule;
264 
265  submodule = PyModule_Create(&pygpu_capabilities_module_def);
266 
267  return submodule;
268 }
269 
#define UNUSED(x)
int GPU_max_textures_vert(void)
int GPU_max_texture_size(void)
int GPU_max_textures_frag(void)
int GPU_max_uniforms_frag(void)
int GPU_max_texture_layers(void)
int GPU_max_batch_indices(void)
int GPU_max_textures_geom(void)
const char * GPU_extension_get(int i)
int GPU_max_textures(void)
int GPU_max_batch_vertices(void)
int GPU_extensions_len(void)
int GPU_max_uniforms_vert(void)
int GPU_max_varying_floats(void)
int GPU_max_vertex_attribs(void)
static PyObject * pygpu_max_texture_layers_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_vertex_attribs_get(PyObject *UNUSED(self))
PyObject * bpygpu_capabilities_init(void)
static PyObject * pygpu_max_textures_geom_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_textures_frag_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_textures_get(PyObject *UNUSED(self))
static PyObject * pygpu_extensions_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_texture_size_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_varying_floats_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_textures_vert_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_uniforms_frag_get(PyObject *UNUSED(self))
static PyObject * pygpu_max_batch_indices_get(PyObject *UNUSED(self))
static PyModuleDef pygpu_capabilities_module_def
static PyObject * pygpu_max_uniforms_vert_get(PyObject *UNUSED(self))
PyDoc_STRVAR(pygpu_max_texture_size_get_doc, ".. function:: max_texture_size_get()\n" "\n" " Get estimated maximum texture size to be able to handle.\n" "\n" " :return: Texture size.\n" " :rtype: int\n")
static struct PyMethodDef pygpu_capabilities__tp_methods[]
static PyObject * pygpu_max_batch_vertices_get(PyObject *UNUSED(self))
return ret