Cleanup: Rename #if GPU_USE_PY_REFERENCES to #ifndef GPU_NO_USE_PY_REFERENCES

This is safer for incremental build.

And there was already a macro `GPU_USE_PY_REFERENCES` used elsewhere.
This commit is contained in:
2021-04-30 11:20:39 -03:00
parent a711aa5b3c
commit 2bd9a28ff8
10 changed files with 16 additions and 16 deletions

View File

@@ -24,7 +24,7 @@
#pragma once #pragma once
#define PROGRAM_NO_OPTI 0 #define PROGRAM_NO_OPTI 0
#define USE_PY_REFERENCES 1 //#define GPU_NO_USE_PY_REFERENCES
#if defined(NDEBUG) #if defined(NDEBUG)
# define TRUST_NO_ONE 0 # define TRUST_NO_ONE 0

View File

@@ -209,7 +209,7 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *fb,
void (*callback)(void *userData, int level), void (*callback)(void *userData, int level),
void *userData); void *userData);
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb); void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb);
void GPU_framebuffer_py_reference_set(GPUFrameBuffer *gpu_fb, void **py_ref); void GPU_framebuffer_py_reference_set(GPUFrameBuffer *gpu_fb, void **py_ref);
#endif #endif

View File

@@ -270,7 +270,7 @@ bool GPU_texture_depth(const GPUTexture *tex);
bool GPU_texture_stencil(const GPUTexture *tex); bool GPU_texture_stencil(const GPUTexture *tex);
bool GPU_texture_integer(const GPUTexture *tex); bool GPU_texture_integer(const GPUTexture *tex);
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
void **GPU_texture_py_reference_get(GPUTexture *tex); void **GPU_texture_py_reference_get(GPUTexture *tex);
void GPU_texture_py_reference_set(GPUTexture *tex, void **py_ref); void GPU_texture_py_reference_set(GPUTexture *tex, void **py_ref);
#endif #endif

View File

@@ -72,7 +72,7 @@ FrameBuffer::~FrameBuffer()
} }
} }
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
if (this->py_ref) { if (this->py_ref) {
*this->py_ref = nullptr; *this->py_ref = nullptr;
} }
@@ -479,7 +479,7 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb,
unwrap(gpu_fb)->recursive_downsample(max_lvl, callback, userData); unwrap(gpu_fb)->recursive_downsample(max_lvl, callback, userData);
} }
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb) void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb)
{ {
return unwrap(gpu_fb)->py_ref; return unwrap(gpu_fb)->py_ref;

View File

@@ -100,7 +100,7 @@ class FrameBuffer {
bool scissor_test_ = false; bool scissor_test_ = false;
bool dirty_state_ = true; bool dirty_state_ = true;
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
public: public:
/** /**
* Reference of a pointer that needs to be cleaned when deallocating the frame-buffer. * Reference of a pointer that needs to be cleaned when deallocating the frame-buffer.

View File

@@ -61,7 +61,7 @@ Texture::~Texture()
} }
} }
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
if (this->py_ref) { if (this->py_ref) {
*this->py_ref = nullptr; *this->py_ref = nullptr;
} }
@@ -587,7 +587,7 @@ bool GPU_texture_array(const GPUTexture *tex)
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_ARRAY) != 0; return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_ARRAY) != 0;
} }
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
void **GPU_texture_py_reference_get(GPUTexture *tex) void **GPU_texture_py_reference_get(GPUTexture *tex)
{ {
return unwrap(tex)->py_ref; return unwrap(tex)->py_ref;

View File

@@ -80,7 +80,7 @@ class Texture {
int refcount = 1; int refcount = 1;
/** Width & Height (of source data), optional. */ /** Width & Height (of source data), optional. */
int src_w = 0, src_h = 0; int src_w = 0, src_h = 0;
#if USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
/** /**
* Reference of a pointer that needs to be cleaned when deallocating the texture. * Reference of a pointer that needs to be cleaned when deallocating the texture.
* Points to #BPyGPUTexture.tex * Points to #BPyGPUTexture.tex

View File

@@ -75,7 +75,7 @@ static void pygpu_framebuffer_free_if_possible(GPUFrameBuffer *fb)
static void pygpu_framebuffer_free_safe(BPyGPUFrameBuffer *self) static void pygpu_framebuffer_free_safe(BPyGPUFrameBuffer *self)
{ {
if (self->fb) { if (self->fb) {
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
GPU_framebuffer_py_reference_set(self->fb, NULL); GPU_framebuffer_py_reference_set(self->fb, NULL);
if (!self->shared_reference) if (!self->shared_reference)
#endif #endif
@@ -639,7 +639,7 @@ PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_refer
{ {
BPyGPUFrameBuffer *self; BPyGPUFrameBuffer *self;
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
if (shared_reference) { if (shared_reference) {
void **ref = GPU_framebuffer_py_reference_get(fb); void **ref = GPU_framebuffer_py_reference_get(fb);
if (ref) { if (ref) {
@@ -657,7 +657,7 @@ PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_refer
self = PyObject_New(BPyGPUFrameBuffer, &BPyGPUFrameBuffer_Type); self = PyObject_New(BPyGPUFrameBuffer, &BPyGPUFrameBuffer_Type);
self->fb = fb; self->fb = fb;
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
self->shared_reference = shared_reference; self->shared_reference = shared_reference;
BLI_assert(GPU_framebuffer_py_reference_get(fb) == NULL); BLI_assert(GPU_framebuffer_py_reference_get(fb) == NULL);

View File

@@ -29,7 +29,7 @@ extern PyTypeObject BPyGPUFrameBuffer_Type;
typedef struct BPyGPUFrameBuffer { typedef struct BPyGPUFrameBuffer {
PyObject_HEAD struct GPUFrameBuffer *fb; PyObject_HEAD struct GPUFrameBuffer *fb;
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
bool shared_reference; bool shared_reference;
#endif #endif
} BPyGPUFrameBuffer; } BPyGPUFrameBuffer;

View File

@@ -412,7 +412,7 @@ static PyObject *pygpu_texture_free(BPyGPUTexture *self)
static void BPyGPUTexture__tp_dealloc(BPyGPUTexture *self) static void BPyGPUTexture__tp_dealloc(BPyGPUTexture *self)
{ {
if (self->tex) { if (self->tex) {
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
GPU_texture_py_reference_set(self->tex, NULL); GPU_texture_py_reference_set(self->tex, NULL);
#endif #endif
GPU_texture_free(self->tex); GPU_texture_free(self->tex);
@@ -600,7 +600,7 @@ PyObject *BPyGPUTexture_CreatePyObject(GPUTexture *tex, bool shared_reference)
BPyGPUTexture *self; BPyGPUTexture *self;
if (shared_reference) { if (shared_reference) {
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
void **ref = GPU_texture_py_reference_get(tex); void **ref = GPU_texture_py_reference_get(tex);
if (ref) { if (ref) {
/* Retrieve BPyGPUTexture reference. */ /* Retrieve BPyGPUTexture reference. */
@@ -617,7 +617,7 @@ PyObject *BPyGPUTexture_CreatePyObject(GPUTexture *tex, bool shared_reference)
self = PyObject_New(BPyGPUTexture, &BPyGPUTexture_Type); self = PyObject_New(BPyGPUTexture, &BPyGPUTexture_Type);
self->tex = tex; self->tex = tex;
#if GPU_USE_PY_REFERENCES #ifndef GPU_NO_USE_PY_REFERENCES
BLI_assert(GPU_texture_py_reference_get(tex) == NULL); BLI_assert(GPU_texture_py_reference_get(tex) == NULL);
GPU_texture_py_reference_set(tex, &self->tex); GPU_texture_py_reference_set(tex, &self->tex);
#endif #endif