Cleanup: Miscellaneous cleanups to newly C++ headers

This commit is contained in:
Hans Goudey 2024-03-23 10:10:52 -04:00
parent 1dc16f909d
commit 374b80b84a
18 changed files with 70 additions and 55 deletions

View File

@ -12,4 +12,4 @@
* However, it is currently of little use. */
// #define BPYGPU_USE_GPUOBJ_FREE_METHOD
PyObject *BPyInit_gpu(void);
PyObject *BPyInit_gpu();

View File

@ -10,20 +10,22 @@
#include "BLI_compiler_attrs.h"
struct GPUBatch;
#define USE_GPU_PY_REFERENCES
extern PyTypeObject BPyGPUBatch_Type;
#define BPyGPUBatch_Check(v) (Py_TYPE(v) == &BPyGPUBatch_Type)
typedef struct BPyGPUBatch {
struct BPyGPUBatch {
PyObject_VAR_HEAD
/* The batch is owned, we may support thin wrapped batches later. */
struct GPUBatch *batch;
GPUBatch *batch;
#ifdef USE_GPU_PY_REFERENCES
/* Just to keep a user to prevent freeing buf's we're using */
PyObject *references;
#endif
} BPyGPUBatch;
};
PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1);
PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch) ATTR_NONNULL(1);

View File

@ -17,7 +17,7 @@ extern PyTypeObject BPyGPU_BufferType;
*
* For Python access to GPU functions requiring a pointer.
*/
typedef struct BPyGPUBuffer {
struct BPyGPUBuffer {
PyObject_VAR_HEAD
PyObject *parent;
@ -33,7 +33,7 @@ typedef struct BPyGPUBuffer {
void *as_void;
} buf;
} BPyGPUBuffer;
};
size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer);
/**

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_capabilities_init(void);
PyObject *bpygpu_capabilities_init();

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_compute_init(void);
PyObject *bpygpu_compute_init();

View File

@ -8,13 +8,15 @@
#pragma once
struct GPUIndexBuf;
extern PyTypeObject BPyGPUIndexBuf_Type;
#define BPyGPUIndexBuf_Check(v) (Py_TYPE(v) == &BPyGPUIndexBuf_Type)
typedef struct BPyGPUIndexBuf {
struct BPyGPUIndexBuf {
PyObject_VAR_HEAD
struct GPUIndexBuf *elem;
} BPyGPUIndexBuf;
GPUIndexBuf *elem;
};
PyObject *BPyGPUIndexBuf_CreatePyObject(struct GPUIndexBuf *elem);
PyObject *BPyGPUIndexBuf_CreatePyObject(GPUIndexBuf *elem);

View File

@ -10,18 +10,20 @@
#include "BLI_compiler_attrs.h"
struct GPUFrameBuffer;
extern PyTypeObject BPyGPUFrameBuffer_Type;
#define BPyGPUFrameBuffer_Check(v) (Py_TYPE(v) == &BPyGPUFrameBuffer_Type)
typedef struct BPyGPUFrameBuffer {
struct BPyGPUFrameBuffer {
PyObject_HEAD
struct GPUFrameBuffer *fb;
GPUFrameBuffer *fb;
#ifndef GPU_NO_USE_PY_REFERENCES
bool shared_reference;
#endif
} BPyGPUFrameBuffer;
};
PyObject *BPyGPUFrameBuffer_CreatePyObject(struct GPUFrameBuffer *fb, bool shared_reference)
PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_reference)
ATTR_NONNULL(1);

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_matrix_init(void);
PyObject *bpygpu_matrix_init();

View File

@ -10,16 +10,17 @@
#include "BLI_compiler_attrs.h"
struct GPUOffScreen;
struct GPUViewport;
extern PyTypeObject BPyGPUOffScreen_Type;
#define BPyGPUOffScreen_Check(v) (Py_TYPE(v) == &BPyGPUOffScreen_Type)
struct GPUViewport;
typedef struct BPyGPUOffScreen {
struct BPyGPUOffScreen {
PyObject_HEAD
struct GPUOffScreen *ofs;
struct GPUViewport *viewport;
} BPyGPUOffScreen;
GPUOffScreen *ofs;
GPUViewport *viewport;
};
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
PyObject *BPyGPUOffScreen_CreatePyObject(GPUOffScreen *ofs) ATTR_NONNULL(1);

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_platform_init(void);
PyObject *bpygpu_platform_init();

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_select_init(void);
PyObject *bpygpu_select_init();

View File

@ -12,6 +12,9 @@
# include "../generic/py_capi_utils.h"
#endif
struct GPUShaderCreateInfo;
struct GPUStageInterfaceInfo;
/* Make sure that there is always a reference count for PyObjects of type String as the strings are
* passed by reference in the #GPUStageInterfaceInfo and #GPUShaderCreateInfo APIs. */
#define USE_GPU_PY_REFERENCES
@ -40,18 +43,18 @@ extern PyTypeObject BPyGPUStageInterfaceInfo_Type;
#define BPyGPUShaderCreateInfo_Check(v) (Py_TYPE(v) == &BPyGPUShaderCreateInfo_Type)
#define BPyGPUStageInterfaceInfo_Check(v) (Py_TYPE(v) == &BPyGPUStageInterfaceInfo_Type)
typedef struct BPyGPUStageInterfaceInfo {
struct BPyGPUStageInterfaceInfo {
PyObject_VAR_HEAD
struct GPUStageInterfaceInfo *interface;
GPUStageInterfaceInfo *interface;
#ifdef USE_GPU_PY_REFERENCES
/* Just to keep a user to prevent freeing buf's we're using. */
PyObject *references;
#endif
} BPyGPUStageInterfaceInfo;
};
typedef struct BPyGPUShaderCreateInfo {
struct BPyGPUShaderCreateInfo {
PyObject_VAR_HEAD
struct GPUShaderCreateInfo *info;
GPUShaderCreateInfo *info;
#ifdef USE_GPU_PY_REFERENCES
/* Just to keep a user to prevent freeing buf's we're using. */
PyObject *vertex_source;
@ -61,7 +64,7 @@ typedef struct BPyGPUShaderCreateInfo {
PyObject *references;
#endif
size_t constants_total_size;
} BPyGPUShaderCreateInfo;
};
PyObject *BPyGPUStageInterfaceInfo_CreatePyObject(struct GPUStageInterfaceInfo *interface);
PyObject *BPyGPUShaderCreateInfo_CreatePyObject(struct GPUShaderCreateInfo *info);
PyObject *BPyGPUStageInterfaceInfo_CreatePyObject(GPUStageInterfaceInfo *interface);
PyObject *BPyGPUShaderCreateInfo_CreatePyObject(GPUShaderCreateInfo *info);

View File

@ -8,4 +8,4 @@
#pragma once
PyObject *bpygpu_state_init(void);
PyObject *bpygpu_state_init();

View File

@ -10,18 +10,19 @@
#include "BLI_compiler_attrs.h"
struct GPUTexture;
extern PyTypeObject BPyGPUTexture_Type;
extern const struct PyC_StringEnumItems pygpu_textureformat_items[];
#define BPyGPUTexture_Check(v) (Py_TYPE(v) == &BPyGPUTexture_Type)
typedef struct BPyGPUTexture {
struct BPyGPUTexture {
PyObject_HEAD
struct GPUTexture *tex;
} BPyGPUTexture;
GPUTexture *tex;
};
int bpygpu_ParseTexture(PyObject *o, void *p);
PyObject *bpygpu_texture_init(void);
PyObject *bpygpu_texture_init();
PyObject *BPyGPUTexture_CreatePyObject(struct GPUTexture *tex, bool shared_reference)
ATTR_NONNULL(1);
PyObject *BPyGPUTexture_CreatePyObject(GPUTexture *tex, bool shared_reference) ATTR_NONNULL(1);

View File

@ -21,4 +21,4 @@
#include "gpu_py_vertex_buffer.hh"
#include "gpu_py_vertex_format.hh"
PyObject *bpygpu_types_init(void);
PyObject *bpygpu_types_init();

View File

@ -10,13 +10,15 @@
#include "BLI_compiler_attrs.h"
struct GPUUniformBuf;
extern PyTypeObject BPyGPUUniformBuf_Type;
#define BPyGPUUniformBuf_Check(v) (Py_TYPE(v) == &BPyGPUUniformBuf_Type)
typedef struct BPyGPUUniformBuf {
struct BPyGPUUniformBuf {
PyObject_HEAD
struct GPUUniformBuf *ubo;
} BPyGPUUniformBuf;
GPUUniformBuf *ubo;
};
PyObject *BPyGPUUniformBuf_CreatePyObject(struct GPUUniformBuf *ubo) ATTR_NONNULL(1);
PyObject *BPyGPUUniformBuf_CreatePyObject(GPUUniformBuf *ubo) ATTR_NONNULL(1);

View File

@ -10,14 +10,16 @@
#include "BLI_compiler_attrs.h"
struct GPUVertBuf;
extern PyTypeObject BPyGPUVertBuf_Type;
#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type)
typedef struct BPyGPUVertBuf {
struct BPyGPUVertBuf {
PyObject_VAR_HEAD
/* The buf is owned, we may support thin wrapped batches later. */
struct GPUVertBuf *buf;
} BPyGPUVertBuf;
GPUVertBuf *buf;
};
PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *buf) ATTR_NONNULL(1);
PyObject *BPyGPUVertBuf_CreatePyObject(GPUVertBuf *buf) ATTR_NONNULL(1);

View File

@ -14,9 +14,9 @@ extern PyTypeObject BPyGPUVertFormat_Type;
#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type)
typedef struct BPyGPUVertFormat {
struct BPyGPUVertFormat {
PyObject_VAR_HEAD
struct GPUVertFormat fmt;
} BPyGPUVertFormat;
GPUVertFormat fmt;
};
PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt);
PyObject *BPyGPUVertFormat_CreatePyObject(GPUVertFormat *fmt);