Blender  V2.93
gpu_py_texture.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
26 #include <Python.h>
27 
28 #include "BLI_string.h"
29 
30 #include "DNA_image_types.h"
31 
32 #include "GPU_context.h"
33 #include "GPU_texture.h"
34 
35 #include "BKE_image.h"
36 
37 #include "../generic/py_capi_utils.h"
38 
39 #include "gpu_py.h"
40 #include "gpu_py_buffer.h"
41 
42 #include "gpu_py_texture.h" /* own include */
43 
44 /* -------------------------------------------------------------------- */
48 static const struct PyC_StringEnumItems pygpu_textureformat_items[] = {
49  {GPU_RGBA8UI, "RGBA8UI"},
50  {GPU_RGBA8I, "RGBA8I"},
51  {GPU_RGBA8, "RGBA8"},
52  {GPU_RGBA32UI, "RGBA32UI"},
53  {GPU_RGBA32I, "RGBA32I"},
54  {GPU_RGBA32F, "RGBA32F"},
55  {GPU_RGBA16UI, "RGBA16UI"},
56  {GPU_RGBA16I, "RGBA16I"},
57  {GPU_RGBA16F, "RGBA16F"},
58  {GPU_RGBA16, "RGBA16"},
59  {GPU_RG8UI, "RG8UI"},
60  {GPU_RG8I, "RG8I"},
61  {GPU_RG8, "RG8"},
62  {GPU_RG32UI, "RG32UI"},
63  {GPU_RG32I, "RG32I"},
64  {GPU_RG32F, "RG32F"},
65  {GPU_RG16UI, "RG16UI"},
66  {GPU_RG16I, "RG16I"},
67  {GPU_RG16F, "RG16F"},
68  {GPU_RG16, "RG16"},
69  {GPU_R8UI, "R8UI"},
70  {GPU_R8I, "R8I"},
71  {GPU_R8, "R8"},
72  {GPU_R32UI, "R32UI"},
73  {GPU_R32I, "R32I"},
74  {GPU_R32F, "R32F"},
75  {GPU_R16UI, "R16UI"},
76  {GPU_R16I, "R16I"},
77  {GPU_R16F, "R16F"},
78  {GPU_R16, "R16"},
79  {GPU_R11F_G11F_B10F, "R11F_G11F_B10F"},
80  {GPU_DEPTH32F_STENCIL8, "DEPTH32F_STENCIL8"},
81  {GPU_DEPTH24_STENCIL8, "DEPTH24_STENCIL8"},
82  {GPU_SRGB8_A8, "SRGB8_A8"},
83  {GPU_RGB16F, "RGB16F"},
84  {GPU_SRGB8_A8_DXT1, "SRGB8_A8_DXT1"},
85  {GPU_SRGB8_A8_DXT3, "SRGB8_A8_DXT3"},
86  {GPU_SRGB8_A8_DXT5, "SRGB8_A8_DXT5"},
87  {GPU_RGBA8_DXT1, "RGBA8_DXT1"},
88  {GPU_RGBA8_DXT3, "RGBA8_DXT3"},
89  {GPU_RGBA8_DXT5, "RGBA8_DXT5"},
90  {GPU_DEPTH_COMPONENT32F, "DEPTH_COMPONENT32F"},
91  {GPU_DEPTH_COMPONENT24, "DEPTH_COMPONENT24"},
92  {GPU_DEPTH_COMPONENT16, "DEPTH_COMPONENT16"},
93  {0, NULL},
94 };
95 
97 {
98  if (UNLIKELY(bpygpu_tex->tex == NULL)) {
99  PyErr_SetString(PyExc_ReferenceError,
101  "GPU texture was freed, no further access is valid"
102 #else
103  "GPU texture: internal error"
104 #endif
105  );
106 
107  return -1;
108  }
109  return 0;
110 }
111 
112 #define BPYGPU_TEXTURE_CHECK_OBJ(bpygpu) \
113  { \
114  if (UNLIKELY(pygpu_texture_valid_check(bpygpu) == -1)) { \
115  return NULL; \
116  } \
117  } \
118  ((void)0)
119 
122 /* -------------------------------------------------------------------- */
126 static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
127 {
129 
130  PyObject *py_size;
131  int size[3] = {1, 1, 1};
132  int layers = 0;
133  int is_cubemap = false;
134  struct PyC_StringEnum pygpu_textureformat = {pygpu_textureformat_items, GPU_RGBA8};
135  BPyGPUBuffer *pybuffer_obj = NULL;
136  char err_out[256] = "unknown error. See console";
137 
138  static const char *_keywords[] = {"size", "layers", "is_cubemap", "format", "data", NULL};
139  static _PyArg_Parser _parser = {"O|$ipO&O!:GPUTexture.__new__", _keywords, 0};
140  if (!_PyArg_ParseTupleAndKeywordsFast(args,
141  kwds,
142  &_parser,
143  &py_size,
144  &layers,
145  &is_cubemap,
147  &pygpu_textureformat,
149  &pybuffer_obj)) {
150  return NULL;
151  }
152 
153  int len = 1;
154  if (PySequence_Check(py_size)) {
155  len = PySequence_Size(py_size);
156  if ((len < 1) || (len > 3)) {
157  PyErr_Format(PyExc_ValueError,
158  "GPUTexture.__new__: \"size\" must be between 1 and 3 in length (got %d)",
159  len);
160  return NULL;
161  }
162  if (PyC_AsArray(size, py_size, len, &PyLong_Type, false, "GPUTexture.__new__") == -1) {
163  return NULL;
164  }
165  }
166  else if (PyLong_Check(py_size)) {
167  size[0] = PyLong_AsLong(py_size);
168  }
169  else {
170  PyErr_SetString(PyExc_ValueError, "GPUTexture.__new__: Expected an int or tuple as first arg");
171  return NULL;
172  }
173 
174  void *data = NULL;
175  if (pybuffer_obj) {
176  if (pybuffer_obj->format != GPU_DATA_FLOAT) {
177  PyErr_SetString(PyExc_ValueError,
178  "GPUTexture.__new__: Only Buffer of format `FLOAT` is currently supported");
179  return NULL;
180  }
181 
182  int component_len = GPU_texture_component_len(pygpu_textureformat.value_found);
183  int component_size_expected = sizeof(float);
184  size_t data_space_expected = (size_t)size[0] * size[1] * size[2] * max_ii(1, layers) *
185  component_len * component_size_expected;
186  if (is_cubemap) {
187  data_space_expected *= 6 * size[0];
188  }
189 
190  if (bpygpu_Buffer_size(pybuffer_obj) < data_space_expected) {
191  PyErr_SetString(PyExc_ValueError, "GPUTexture.__new__: Buffer size smaller than requested");
192  return NULL;
193  }
194  data = pybuffer_obj->buf.as_void;
195  }
196 
197  GPUTexture *tex = NULL;
198  if (is_cubemap && len != 1) {
199  STRNCPY(err_out,
200  "In cubemaps the same dimension represents height, width and depth. No tuple needed");
201  }
202  else if (size[0] < 1 || size[1] < 1 || size[2] < 1) {
203  STRNCPY(err_out, "Values less than 1 are not allowed in dimensions");
204  }
205  else if (layers && len == 3) {
206  STRNCPY(err_out, "3D textures have no layers");
207  }
208  else if (!GPU_context_active_get()) {
209  STRNCPY(err_out, "No active GPU context found");
210  }
211  else {
212  const char *name = "python_texture";
213  if (is_cubemap) {
214  if (layers) {
216  name, size[0], layers, 1, pygpu_textureformat.value_found, data);
217  }
218  else {
219  tex = GPU_texture_create_cube(name, size[0], 1, pygpu_textureformat.value_found, data);
220  }
221  }
222  else if (layers) {
223  if (len == 2) {
225  name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, data);
226  }
227  else {
229  name, size[0], layers, 1, pygpu_textureformat.value_found, data);
230  }
231  }
232  else if (len == 3) {
233  tex = GPU_texture_create_3d(name,
234  size[0],
235  size[1],
236  size[2],
237  1,
238  pygpu_textureformat.value_found,
240  NULL);
241  }
242  else if (len == 2) {
244  name, size[0], size[1], 1, pygpu_textureformat.value_found, data);
245  }
246  else {
247  tex = GPU_texture_create_1d(name, size[0], 1, pygpu_textureformat.value_found, data);
248  }
249  }
250 
251  if (tex == NULL) {
252  PyErr_Format(PyExc_RuntimeError, "gpu.texture.new(...) failed with '%s'", err_out);
253  return NULL;
254  }
255 
257 }
258 
259 PyDoc_STRVAR(pygpu_texture_width_doc, "Width of the texture.\n\n:type: `int`");
260 static PyObject *pygpu_texture_width_get(BPyGPUTexture *self, void *UNUSED(type))
261 {
263  return PyLong_FromLong(GPU_texture_width(self->tex));
264 }
265 
266 PyDoc_STRVAR(pygpu_texture_height_doc, "Height of the texture.\n\n:type: `int`");
267 static PyObject *pygpu_texture_height_get(BPyGPUTexture *self, void *UNUSED(type))
268 {
270  return PyLong_FromLong(GPU_texture_height(self->tex));
271 }
272 
273 PyDoc_STRVAR(pygpu_texture_format_doc, "Format of the texture.\n\n:type: `str`");
274 static PyObject *pygpu_texture_format_get(BPyGPUTexture *self, void *UNUSED(type))
275 {
278  return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_textureformat_items, format));
279 }
280 
282  pygpu_texture_clear_doc,
283  ".. method:: clear(format='FLOAT', value=(0.0, 0.0, 0.0, 1.0))\n"
284  "\n"
285  " Fill texture with specific value.\n"
286  "\n"
287  " :param format: The format that describes the content of a single item.\n"
288  " Possible values are `FLOAT`, `INT`, `UINT`, `UBYTE`, `UINT_24_8` and `10_11_11_REV`.\n"
289  " :type type: str\n"
290  " :arg value: sequence each representing the value to fill.\n"
291  " :type value: sequence of 1, 2, 3 or 4 values\n");
292 static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObject *kwds)
293 {
295  struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items};
296  union {
297  int i[4];
298  float f[4];
299  char c[4];
300  } values;
301 
302  PyObject *py_values;
303 
304  static const char *_keywords[] = {"format", "value", NULL};
305  static _PyArg_Parser _parser = {"$O&O:clear", _keywords, 0};
306  if (!_PyArg_ParseTupleAndKeywordsFast(
307  args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_dataformat, &py_values)) {
308  return NULL;
309  }
310 
311  int shape = PySequence_Size(py_values);
312  if (shape == -1) {
313  return NULL;
314  }
315 
316  if (shape > 4) {
317  PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is 4");
318  return NULL;
319  }
320 
321  if (shape != 1 &&
323  PyErr_SetString(PyExc_AttributeError,
324  "`UINT_24_8` and `10_11_11_REV` only support single values");
325  return NULL;
326  }
327 
328  memset(&values, 0, sizeof(values));
329  if (PyC_AsArray(&values,
330  py_values,
331  shape,
332  pygpu_dataformat.value_found == GPU_DATA_FLOAT ? &PyFloat_Type : &PyLong_Type,
333  false,
334  "clear") == -1) {
335  return NULL;
336  }
337 
338  if (pygpu_dataformat.value_found == GPU_DATA_UBYTE) {
339  /* Convert to byte. */
340  values.c[0] = values.i[0];
341  values.c[1] = values.i[1];
342  values.c[2] = values.i[2];
343  values.c[3] = values.i[3];
344  }
345 
346  GPU_texture_clear(self->tex, pygpu_dataformat.value_found, &values);
347  Py_RETURN_NONE;
348 }
349 
350 PyDoc_STRVAR(pygpu_texture_read_doc,
351  ".. method:: read()\n"
352  "\n"
353  " Creates a buffer with the value of all pixels.\n"
354  "\n");
355 static PyObject *pygpu_texture_read(BPyGPUTexture *self)
356 {
358  eGPUTextureFormat tex_format = GPU_texture_format(self->tex);
359 
360  /* #GPU_texture_read is restricted in combining 'data_format' with 'tex_format'.
361  * So choose data_format here. */
362  eGPUDataFormat best_data_format;
363  switch (tex_format) {
367  best_data_format = GPU_DATA_FLOAT;
368  break;
371  best_data_format = GPU_DATA_UINT_24_8;
372  break;
373  case GPU_R8UI:
374  case GPU_R16UI:
375  case GPU_RG16UI:
376  case GPU_R32UI:
377  best_data_format = GPU_DATA_UINT;
378  break;
379  case GPU_RG16I:
380  case GPU_R16I:
381  best_data_format = GPU_DATA_INT;
382  break;
383  case GPU_R8:
384  case GPU_RG8:
385  case GPU_RGBA8:
386  case GPU_RGBA8UI:
387  case GPU_SRGB8_A8:
388  best_data_format = GPU_DATA_UBYTE;
389  break;
390  case GPU_R11F_G11F_B10F:
391  best_data_format = GPU_DATA_10_11_11_REV;
392  break;
393  default:
394  best_data_format = GPU_DATA_FLOAT;
395  break;
396  }
397 
398  void *buf = GPU_texture_read(self->tex, best_data_format, 0);
399  const Py_ssize_t shape[3] = {GPU_texture_height(self->tex),
400  GPU_texture_width(self->tex),
401  GPU_texture_component_len(tex_format)};
402 
403  int shape_len = (shape[2] == 1) ? 2 : 3;
404  return (PyObject *)BPyGPU_Buffer_CreatePyObject(best_data_format, shape, shape_len, buf);
405 }
406 
407 #ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
408 PyDoc_STRVAR(pygpu_texture_free_doc,
409  ".. method:: free()\n"
410  "\n"
411  " Free the texture object.\n"
412  " The texture object will no longer be accessible.\n");
413 static PyObject *pygpu_texture_free(BPyGPUTexture *self)
414 {
416 
417  GPU_texture_free(self->tex);
418  self->tex = NULL;
419  Py_RETURN_NONE;
420 }
421 #endif
422 
424 {
425  if (self->tex) {
426  GPU_texture_free(self->tex);
427  }
428  Py_TYPE(self)->tp_free((PyObject *)self);
429 }
430 
431 static PyGetSetDef pygpu_texture__tp_getseters[] = {
432  {"width", (getter)pygpu_texture_width_get, (setter)NULL, pygpu_texture_width_doc, NULL},
433  {"height", (getter)pygpu_texture_height_get, (setter)NULL, pygpu_texture_height_doc, NULL},
434  {"format", (getter)pygpu_texture_format_get, (setter)NULL, pygpu_texture_format_doc, NULL},
435  {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
436 };
437 
438 static struct PyMethodDef pygpu_texture__tp_methods[] = {
439  {"clear",
440  (PyCFunction)pygpu_texture_clear,
441  METH_VARARGS | METH_KEYWORDS,
442  pygpu_texture_clear_doc},
443  {"read", (PyCFunction)pygpu_texture_read, METH_NOARGS, pygpu_texture_read_doc},
444 #ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
445  {"free", (PyCFunction)pygpu_texture_free, METH_NOARGS, pygpu_texture_free_doc},
446 #endif
447  {NULL, NULL, 0, NULL},
448 };
449 
451  pygpu_texture__tp_doc,
452  ".. class:: GPUTexture(size, layers=0, is_cubemap=False, format='RGBA8', data=None)\n"
453  "\n"
454  " This object gives access to off GPU textures.\n"
455  "\n"
456  " :arg size: Dimensions of the texture 1D, 2D, 3D or cubemap.\n"
457  " :type size: tuple or int\n"
458  " :arg layers: Number of layers in texture array or number of cubemaps in cubemap array\n"
459  " :type layers: int\n"
460  " :arg is_cubemap: Indicates the creation of a cubemap texture.\n"
461  " :type is_cubemap: int\n"
462  " :arg format: Internal data format inside GPU memory. Possible values are:\n"
463  " `RGBA8UI`,\n"
464  " `RGBA8I`,\n"
465  " `RGBA8`,\n"
466  " `RGBA32UI`,\n"
467  " `RGBA32I`,\n"
468  " `RGBA32F`,\n"
469  " `RGBA16UI`,\n"
470  " `RGBA16I`,\n"
471  " `RGBA16F`,\n"
472  " `RGBA16`,\n"
473  " `RG8UI`,\n"
474  " `RG8I`,\n"
475  " `RG8`,\n"
476  " `RG32UI`,\n"
477  " `RG32I`,\n"
478  " `RG32F`,\n"
479  " `RG16UI`,\n"
480  " `RG16I`,\n"
481  " `RG16F`,\n"
482  " `RG16`,\n"
483  " `R8UI`,\n"
484  " `R8I`,\n"
485  " `R8`,\n"
486  " `R32UI`,\n"
487  " `R32I`,\n"
488  " `R32F`,\n"
489  " `R16UI`,\n"
490  " `R16I`,\n"
491  " `R16F`,\n"
492  " `R16`,\n"
493  " `R11F_G11F_B10F`,\n"
494  " `DEPTH32F_STENCIL8`,\n"
495  " `DEPTH24_STENCIL8`,\n"
496  " `SRGB8_A8`,\n"
497  " `RGB16F`,\n"
498  " `SRGB8_A8_DXT1`,\n"
499  " `SRGB8_A8_DXT3`,\n"
500  " `SRGB8_A8_DXT5`,\n"
501  " `RGBA8_DXT1`,\n"
502  " `RGBA8_DXT3`,\n"
503  " `RGBA8_DXT5`,\n"
504  " `DEPTH_COMPONENT32F`,\n"
505  " `DEPTH_COMPONENT24`,\n"
506  " `DEPTH_COMPONENT16`,\n"
507  " :type format: str\n"
508  " :arg data: Buffer object to fill the texture.\n"
509  " :type data: :class:`gpu.types.Buffer`\n");
510 PyTypeObject BPyGPUTexture_Type = {
511  PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUTexture",
512  .tp_basicsize = sizeof(BPyGPUTexture),
513  .tp_dealloc = (destructor)BPyGPUTexture__tp_dealloc,
514  .tp_flags = Py_TPFLAGS_DEFAULT,
515  .tp_doc = pygpu_texture__tp_doc,
516  .tp_methods = pygpu_texture__tp_methods,
517  .tp_getset = pygpu_texture__tp_getseters,
518  .tp_new = pygpu_texture__tp_new,
519 };
520 
523 /* -------------------------------------------------------------------- */
526 PyDoc_STRVAR(pygpu_texture_from_image_doc,
527  ".. function:: from_image(image)\n"
528  "\n"
529  " Get GPUTexture corresponding to an Image datablock. The GPUTexture memory is "
530  "shared with Blender.\n"
531  " Note: Colors read from the texture will be in scene linear color space and have "
532  "premultiplied or straight alpha matching the image alpha mode.\n"
533  "\n"
534  " :arg image: The Image datablock.\n"
535  " :type image: `bpy.types.Image`\n"
536  " :return: The GPUTexture used by the image.\n"
537  " :rtype: :class:`gpu.types.GPUTexture`\n");
538 static PyObject *pygpu_texture_from_image(PyObject *UNUSED(self), PyObject *arg)
539 {
540  Image *ima = PyC_RNA_AsPointer(arg, "Image");
541  if (ima == NULL) {
542  return NULL;
543  }
544 
545  ImageUser iuser;
546  BKE_imageuser_default(&iuser);
547  GPUTexture *tex = BKE_image_get_gpu_texture(ima, &iuser, NULL);
548 
549  /* Increase the texture reference count. */
551 
553 }
554 
555 static struct PyMethodDef pygpu_texture__m_methods[] = {
556  {"from_image", (PyCFunction)pygpu_texture_from_image, METH_O, pygpu_texture_from_image_doc},
557  {NULL, NULL, 0, NULL},
558 };
559 
560 PyDoc_STRVAR(pygpu_texure__m_doc, "This module provides utils for textures.");
561 static PyModuleDef pygpu_texture_module_def = {
562  PyModuleDef_HEAD_INIT,
563  .m_name = "gpu.texture",
564  .m_doc = pygpu_texure__m_doc,
565  .m_methods = pygpu_texture__m_methods,
566 };
567 
570 /* -------------------------------------------------------------------- */
574 int bpygpu_ParseTexture(PyObject *o, void *p)
575 {
576  if (o == Py_None) {
577  *(GPUTexture **)p = NULL;
578  return 1;
579  }
580 
581  if (!BPyGPUTexture_Check(o)) {
582  PyErr_Format(
583  PyExc_ValueError, "expected a texture or None object, got %s", Py_TYPE(o)->tp_name);
584  return 0;
585  }
586 
588  return 0;
589  }
590 
591  *(GPUTexture **)p = ((BPyGPUTexture *)o)->tex;
592  return 1;
593 }
594 
595 PyObject *bpygpu_texture_init(void)
596 {
597  PyObject *submodule;
598  submodule = PyModule_Create(&pygpu_texture_module_def);
599 
600  return submodule;
601 }
602 
605 /* -------------------------------------------------------------------- */
610 {
611  BPyGPUTexture *self;
612 
613  self = PyObject_New(BPyGPUTexture, &BPyGPUTexture_Type);
614  self->tex = tex;
615 
616  return (PyObject *)self;
617 }
618 
621 #undef BPYGPU_TEXTURE_CHECK_OBJ
typedef float(TangentPoint)[2]
struct GPUTexture * BKE_image_get_gpu_texture(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:439
void BKE_imageuser_default(struct ImageUser *iuser)
Definition: image.c:3451
MINLINE int max_ii(int a, int b)
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
#define UNUSED(x)
#define UNLIKELY(x)
#define ELEM(...)
GPUContext * GPU_context_active_get(void)
Definition: gpu_context.cc:136
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
GPUTexture * GPU_texture_create_2d_array(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:256
GPUTexture * GPU_texture_create_1d_array(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:243
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:532
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:237
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:384
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:527
void * GPU_texture_read(GPUTexture *tex, eGPUDataFormat data_format, int miplvl)
Definition: gpu_texture.cc:371
eGPUDataFormat
Definition: GPU_texture.h:171
@ GPU_DATA_UINT_24_8
Definition: GPU_texture.h:176
@ GPU_DATA_INT
Definition: GPU_texture.h:173
@ GPU_DATA_10_11_11_REV
Definition: GPU_texture.h:177
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:175
@ GPU_DATA_UINT
Definition: GPU_texture.h:174
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:172
void GPU_texture_ref(GPUTexture *tex)
Definition: gpu_texture.cc:522
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
eGPUTextureFormat
Definition: GPU_texture.h:84
@ GPU_R16UI
Definition: GPU_texture.h:112
@ GPU_RG16F
Definition: GPU_texture.h:104
@ GPU_DEPTH32F_STENCIL8
Definition: GPU_texture.h:120
@ GPU_R32F
Definition: GPU_texture.h:111
@ GPU_R16I
Definition: GPU_texture.h:113
@ GPU_SRGB8_A8
Definition: GPU_texture.h:122
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_R32I
Definition: GPU_texture.h:110
@ GPU_RG8UI
Definition: GPU_texture.h:96
@ GPU_R16F
Definition: GPU_texture.h:114
@ GPU_SRGB8_A8_DXT5
Definition: GPU_texture.h:152
@ GPU_RG8I
Definition: GPU_texture.h:97
@ GPU_RG16I
Definition: GPU_texture.h:103
@ GPU_RG32UI
Definition: GPU_texture.h:99
@ GPU_RGBA32F
Definition: GPU_texture.h:91
@ GPU_RGBA16F
Definition: GPU_texture.h:94
@ GPU_RG8
Definition: GPU_texture.h:98
@ GPU_RG32I
Definition: GPU_texture.h:100
@ GPU_SRGB8_A8_DXT1
Definition: GPU_texture.h:150
@ GPU_RG16
Definition: GPU_texture.h:105
@ GPU_RGBA32UI
Definition: GPU_texture.h:89
@ GPU_R8I
Definition: GPU_texture.h:107
@ GPU_R16
Definition: GPU_texture.h:115
@ GPU_RG16UI
Definition: GPU_texture.h:102
@ GPU_RGBA8I
Definition: GPU_texture.h:87
@ GPU_RGBA8_DXT1
Definition: GPU_texture.h:153
@ GPU_RGBA8UI
Definition: GPU_texture.h:86
@ GPU_RGBA16UI
Definition: GPU_texture.h:92
@ GPU_RGBA16I
Definition: GPU_texture.h:93
@ GPU_R8UI
Definition: GPU_texture.h:106
@ GPU_RGBA16
Definition: GPU_texture.h:95
@ GPU_SRGB8_A8_DXT3
Definition: GPU_texture.h:151
@ GPU_RGBA8_DXT3
Definition: GPU_texture.h:154
@ GPU_RG32F
Definition: GPU_texture.h:101
@ GPU_R8
Definition: GPU_texture.h:108
@ GPU_DEPTH_COMPONENT24
Definition: GPU_texture.h:167
@ GPU_RGB16F
Definition: GPU_texture.h:128
@ GPU_R32UI
Definition: GPU_texture.h:109
@ GPU_RGBA32I
Definition: GPU_texture.h:90
@ GPU_RGBA8_DXT5
Definition: GPU_texture.h:155
@ GPU_DEPTH_COMPONENT32F
Definition: GPU_texture.h:166
@ GPU_DEPTH_COMPONENT16
Definition: GPU_texture.h:168
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:119
@ GPU_RGBA8
Definition: GPU_texture.h:88
GPUTexture * GPU_texture_create_3d(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:263
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
Definition: gpu_texture.cc:554
GPUTexture * GPU_texture_create_cube(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:276
size_t GPU_texture_component_len(eGPUTextureFormat format)
Definition: gpu_texture.cc:616
GPUTexture * GPU_texture_create_cube_array(const char *name, int w, int d, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:282
PyObject * self
Definition: bpy_driver.c:185
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
struct PyC_StringEnumItems bpygpu_dataformat_items[]
Definition: gpu_py.c:52
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
Definition: gpu_py.h:28
BPyGPUBuffer * BPyGPU_Buffer_CreatePyObject(const int format, const Py_ssize_t *shape, const int shape_len, void *buffer)
PyTypeObject BPyGPU_BufferType
size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer)
#define BPYGPU_USE_GPUOBJ_FREE_METHOD
static PyObject * pygpu_texture_read(BPyGPUTexture *self)
static PyObject * pygpu_texture_format_get(BPyGPUTexture *self, void *UNUSED(type))
PyTypeObject BPyGPUTexture_Type
static PyObject * pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
static struct PyMethodDef pygpu_texture__m_methods[]
static struct PyMethodDef pygpu_texture__tp_methods[]
PyObject * bpygpu_texture_init(void)
static const struct PyC_StringEnumItems pygpu_textureformat_items[]
static void BPyGPUTexture__tp_dealloc(BPyGPUTexture *self)
PyObject * BPyGPUTexture_CreatePyObject(GPUTexture *tex)
static PyObject * pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObject *kwds)
static int pygpu_texture_valid_check(BPyGPUTexture *bpygpu_tex)
static PyGetSetDef pygpu_texture__tp_getseters[]
static PyObject * pygpu_texture_width_get(BPyGPUTexture *self, void *UNUSED(type))
PyDoc_STRVAR(pygpu_texture_width_doc, "Width of the texture.\n\n:type: `int`")
#define BPYGPU_TEXTURE_CHECK_OBJ(bpygpu)
int bpygpu_ParseTexture(PyObject *o, void *p)
static PyObject * pygpu_texture_from_image(PyObject *UNUSED(self), PyObject *arg)
static PyObject * pygpu_texture_height_get(BPyGPUTexture *self, void *UNUSED(type))
static PyModuleDef pygpu_texture_module_def
struct BPyGPUTexture BPyGPUTexture
#define BPyGPUTexture_Check(v)
format
Definition: logImageCore.h:47
static unsigned c
Definition: RandGen.cpp:97
int PyC_ParseStringEnum(PyObject *o, void *p)
void * PyC_RNA_AsPointer(PyObject *value, const char *type_name)
const char * PyC_StringEnum_FindIDFromValue(const struct PyC_StringEnumItems *items, const int value)
int PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length, const PyTypeObject *type, const bool is_double, const char *error_prefix)
void * as_void
Definition: gpu_py_buffer.h:46
union BPyGPUBuffer::@1119 buf
PyObject_HEAD struct GPUTexture * tex
uint len