Cleanup: Move GPU Python headers to C++

This commit is contained in:
Hans Goudey 2024-03-23 10:06:45 -04:00
parent a54c9b9e36
commit 1dc16f909d
42 changed files with 99 additions and 251 deletions

View File

@ -36,25 +36,25 @@ set(SRC
gpu_py_vertex_buffer.cc
gpu_py_vertex_format.cc
gpu_py.h
gpu_py_api.h
gpu_py_batch.h
gpu_py_buffer.h
gpu_py_capabilities.h
gpu_py_compute.h
gpu_py_element.h
gpu_py_framebuffer.h
gpu_py_matrix.h
gpu_py_offscreen.h
gpu_py_platform.h
gpu_py_select.h
gpu_py_shader.h
gpu_py_state.h
gpu_py_texture.h
gpu_py_types.h
gpu_py_uniformbuffer.h
gpu_py_vertex_buffer.h
gpu_py_vertex_format.h
gpu_py.hh
gpu_py_api.hh
gpu_py_batch.hh
gpu_py_buffer.hh
gpu_py_capabilities.hh
gpu_py_compute.hh
gpu_py_element.hh
gpu_py_framebuffer.hh
gpu_py_matrix.hh
gpu_py_offscreen.hh
gpu_py_platform.hh
gpu_py_select.hh
gpu_py_shader.hh
gpu_py_state.hh
gpu_py_texture.hh
gpu_py_types.hh
gpu_py_uniformbuffer.hh
gpu_py_vertex_buffer.hh
gpu_py_vertex_format.hh
)
set(LIB

View File

@ -17,7 +17,7 @@
#include "../generic/py_capi_utils.h"
#include "gpu_py.h" /* own include */
#include "gpu_py.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name GPU Enums

View File

@ -10,16 +10,8 @@
#include "../generic/py_capi_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
extern struct PyC_StringEnumItems bpygpu_primtype_items[];
extern struct PyC_StringEnumItems bpygpu_dataformat_items[];
PyObject *bpygpu_create_module(PyModuleDef *module_type);
int bpygpu_finalize_type(PyTypeObject *py_type);
#ifdef __cplusplus
}
#endif

View File

@ -16,16 +16,16 @@
#include "BLI_utildefines.h"
#include "gpu_py_capabilities.h"
#include "gpu_py_compute.h"
#include "gpu_py_matrix.h"
#include "gpu_py_platform.h"
#include "gpu_py_select.h"
#include "gpu_py_state.h"
#include "gpu_py_types.h"
#include "gpu_py_capabilities.hh"
#include "gpu_py_compute.hh"
#include "gpu_py_matrix.hh"
#include "gpu_py_platform.hh"
#include "gpu_py_select.hh"
#include "gpu_py_state.hh"
#include "gpu_py_types.hh"
#include "gpu_py.h"
#include "gpu_py_api.h" /* Own include. */
#include "gpu_py.hh"
#include "gpu_py_api.hh" /* Own include. */
/* -------------------------------------------------------------------- */
/** \name GPU Module

View File

@ -8,16 +8,8 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* Each type object could have a method for free GPU resources.
* However, it is currently of little use. */
// #define BPYGPU_USE_GPUOBJ_FREE_METHOD
PyObject *BPyInit_gpu(void);
#ifdef __cplusplus
}
#endif

View File

@ -21,12 +21,12 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py.h"
#include "gpu_py_element.h"
#include "gpu_py_shader.h"
#include "gpu_py_vertex_buffer.h"
#include "gpu_py.hh"
#include "gpu_py_element.hh"
#include "gpu_py_shader.hh"
#include "gpu_py_vertex_buffer.hh"
#include "gpu_py_batch.h" /* own include */
#include "gpu_py_batch.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Utility Functions

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define USE_GPU_PY_REFERENCES
extern PyTypeObject BPyGPUBatch_Type;
@ -31,7 +27,3 @@ typedef struct BPyGPUBatch {
} BPyGPUBatch;
PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -21,9 +21,9 @@
#include "../generic/py_capi_utils.h"
#include "gpu_py.h"
#include "gpu_py.hh"
#include "gpu_py_buffer.h"
#include "gpu_py_buffer.hh"
#define PYGPU_BUFFER_PROTOCOL
#define MAX_DIMENSIONS 64

View File

@ -8,10 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPU_BufferType;
#define BPyGPU_Buffer_Check(v) (Py_TYPE(v) == &BPyGPU_BufferType)
@ -51,7 +47,3 @@ BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(int format,
const Py_ssize_t *shape,
int shape_len,
void *buffer);
#ifdef __cplusplus
}
#endif

View File

@ -15,8 +15,8 @@
#include "GPU_capabilities.hh"
#include "gpu_py.h"
#include "gpu_py_capabilities.h" /* own include */
#include "gpu_py.hh"
#include "gpu_py_capabilities.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Functions

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_capabilities_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -19,9 +19,9 @@
#include "../generic/python_compat.h"
#include "gpu_py.h"
#include "gpu_py_compute.h" /* own include */
#include "gpu_py_shader.h"
#include "gpu_py.hh"
#include "gpu_py_compute.hh" /* own include */
#include "gpu_py_shader.hh"
PyDoc_STRVAR(
/* Wrap. */

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_compute_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -18,8 +18,8 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py.h"
#include "gpu_py_element.h" /* own include */
#include "gpu_py.hh"
#include "gpu_py_element.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name IndexBuf Type

View File

@ -8,10 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUIndexBuf_Type;
#define BPyGPUIndexBuf_Check(v) (Py_TYPE(v) == &BPyGPUIndexBuf_Type)
@ -22,7 +18,3 @@ typedef struct BPyGPUIndexBuf {
} BPyGPUIndexBuf;
PyObject *BPyGPUIndexBuf_CreatePyObject(struct GPUIndexBuf *elem);
#ifdef __cplusplus
}
#endif

View File

@ -24,10 +24,10 @@
#include "../mathutils/mathutils.h"
#include "gpu_py.h"
#include "gpu_py_buffer.h"
#include "gpu_py_framebuffer.h" /* own include */
#include "gpu_py_texture.h"
#include "gpu_py.hh"
#include "gpu_py_buffer.hh"
#include "gpu_py_framebuffer.hh" /* own include */
#include "gpu_py_texture.hh"
/* -------------------------------------------------------------------- */
/** \name GPUFrameBuffer Common Utilities

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUFrameBuffer_Type;
#define BPyGPUFrameBuffer_Check(v) (Py_TYPE(v) == &BPyGPUFrameBuffer_Type)
@ -29,7 +25,3 @@ typedef struct BPyGPUFrameBuffer {
PyObject *BPyGPUFrameBuffer_CreatePyObject(struct GPUFrameBuffer *fb, bool shared_reference)
ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -26,8 +26,8 @@
#include "GPU_matrix.hh"
#undef USE_GPU_PY_MATRIX_API
#include "gpu_py.h"
#include "gpu_py_matrix.h" /* own include */
#include "gpu_py.hh"
#include "gpu_py_matrix.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Helper Functions

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_matrix_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -35,9 +35,9 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py_texture.h"
#include "gpu_py_texture.hh"
#include "gpu_py_offscreen.h" /* own include */
#include "gpu_py_offscreen.hh" /* own include */
/* Define the free method to avoid breakage. */
#define BPYGPU_USE_GPUOBJ_FREE_METHOD

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUOffScreen_Type;
#define BPyGPUOffScreen_Check(v) (Py_TYPE(v) == &BPyGPUOffScreen_Type)
@ -27,7 +23,3 @@ typedef struct BPyGPUOffScreen {
} BPyGPUOffScreen;
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -16,8 +16,8 @@
#include "GPU_context.hh"
#include "GPU_platform.hh"
#include "gpu_py.h"
#include "gpu_py_platform.h" /* Own include. */
#include "gpu_py.hh"
#include "gpu_py_platform.hh" /* Own include. */
/* -------------------------------------------------------------------- */
/** \name Functions

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_platform_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -22,8 +22,8 @@
#include "GPU_select.hh"
#include "gpu_py.h"
#include "gpu_py_select.h" /* Own include. */
#include "gpu_py.hh"
#include "gpu_py_select.hh" /* Own include. */
/* -------------------------------------------------------------------- */
/** \name Methods

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_select_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -23,12 +23,12 @@
#include "../mathutils/mathutils.h"
#include "gpu_py.h"
#include "gpu_py_texture.h"
#include "gpu_py_uniformbuffer.h"
#include "gpu_py_vertex_format.h"
#include "gpu_py.hh"
#include "gpu_py_texture.hh"
#include "gpu_py_uniformbuffer.hh"
#include "gpu_py_vertex_format.hh"
#include "gpu_py_shader.h" /* own include */
#include "gpu_py_shader.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Enum Conversion.

View File

@ -12,10 +12,6 @@
# include "../generic/py_capi_utils.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* 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
@ -69,7 +65,3 @@ typedef struct BPyGPUShaderCreateInfo {
PyObject *BPyGPUStageInterfaceInfo_CreatePyObject(struct GPUStageInterfaceInfo *interface);
PyObject *BPyGPUShaderCreateInfo_CreatePyObject(struct GPUShaderCreateInfo *info);
#ifdef __cplusplus
}
#endif

View File

@ -19,8 +19,8 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py_shader.h" /* own include */
#include "gpu_py_texture.h"
#include "gpu_py_shader.hh" /* own include */
#include "gpu_py_texture.hh"
#define USE_PYGPU_SHADER_INFO_IMAGE_METHOD

View File

@ -19,9 +19,9 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "gpu_py.h"
#include "gpu_py_framebuffer.h"
#include "gpu_py_state.h" /* own include */
#include "gpu_py.hh"
#include "gpu_py_framebuffer.hh"
#include "gpu_py_state.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Helper Functions

View File

@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_state_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -25,10 +25,10 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py.h"
#include "gpu_py_buffer.h"
#include "gpu_py.hh"
#include "gpu_py_buffer.hh"
#include "gpu_py_texture.h" /* own include */
#include "gpu_py_texture.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name GPUTexture Common Utilities

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUTexture_Type;
extern const struct PyC_StringEnumItems pygpu_textureformat_items[];
@ -29,7 +25,3 @@ PyObject *bpygpu_texture_init(void);
PyObject *BPyGPUTexture_CreatePyObject(struct GPUTexture *tex, bool shared_reference)
ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -11,8 +11,8 @@
#include <Python.h>
#include "gpu_py.h"
#include "gpu_py_types.h" /* own include */
#include "gpu_py.hh"
#include "gpu_py_types.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name GPU Types Module

View File

@ -1,32 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bpygpu
*/
#pragma once
#include "gpu_py_buffer.h"
#include "gpu_py_batch.h"
#include "gpu_py_compute.h"
#include "gpu_py_element.h"
#include "gpu_py_framebuffer.h"
#include "gpu_py_offscreen.h"
#include "gpu_py_shader.h"
#include "gpu_py_texture.h"
#include "gpu_py_uniformbuffer.h"
#include "gpu_py_vertex_buffer.h"
#include "gpu_py_vertex_format.h"
#ifdef __cplusplus
extern "C" {
#endif
PyObject *bpygpu_types_init(void);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,24 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bpygpu
*/
#pragma once
#include "gpu_py_buffer.hh"
#include "gpu_py_batch.hh"
#include "gpu_py_compute.hh"
#include "gpu_py_element.hh"
#include "gpu_py_framebuffer.hh"
#include "gpu_py_offscreen.hh"
#include "gpu_py_shader.hh"
#include "gpu_py_texture.hh"
#include "gpu_py_uniformbuffer.hh"
#include "gpu_py_vertex_buffer.hh"
#include "gpu_py_vertex_format.hh"
PyObject *bpygpu_types_init(void);

View File

@ -20,7 +20,7 @@
#include "../generic/python_compat.h"
#include "gpu_py_uniformbuffer.h" /* own include */
#include "gpu_py_uniformbuffer.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name GPUUniformBuf Common Utilities

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUUniformBuf_Type;
#define BPyGPUUniformBuf_Check(v) (Py_TYPE(v) == &BPyGPUUniformBuf_Type)
@ -24,7 +20,3 @@ typedef struct BPyGPUUniformBuf {
} BPyGPUUniformBuf;
PyObject *BPyGPUUniformBuf_CreatePyObject(struct GPUUniformBuf *ubo) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -19,8 +19,8 @@
#include "../generic/python_compat.h"
#include "../generic/python_utildefines.h"
#include "gpu_py_vertex_buffer.h" /* own include */
#include "gpu_py_vertex_format.h"
#include "gpu_py_vertex_buffer.hh" /* own include */
#include "gpu_py_vertex_format.hh"
/* -------------------------------------------------------------------- */
/** \name Utility Functions

View File

@ -10,10 +10,6 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUVertBuf_Type;
#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type)
@ -25,7 +21,3 @@ typedef struct BPyGPUVertBuf {
} BPyGPUVertBuf;
PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *buf) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@ -14,7 +14,7 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
#include "gpu_py_vertex_format.h" /* own include */
#include "gpu_py_vertex_format.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Enum Conversion

View File

@ -10,10 +10,6 @@
#include "GPU_vertex_format.hh"
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPyGPUVertFormat_Type;
#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type)
@ -24,7 +20,3 @@ typedef struct BPyGPUVertFormat {
} BPyGPUVertFormat;
PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt);
#ifdef __cplusplus
}
#endif

View File

@ -68,7 +68,7 @@
#include "../generic/blf_py_api.h"
#include "../generic/idprop_py_api.h"
#include "../generic/imbuf_py_api.h"
#include "../gpu/gpu_py_api.h"
#include "../gpu/gpu_py_api.hh"
#include "../mathutils/mathutils.h"
/* Logging types to use anywhere in the Python modules. */