Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-11-06 19:49:09 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-11-06 20:08:25 +0300
commit16732def37c5a66f3ea28dbe247b09cc6bca6677 (patch)
tree5d14f5c920a1411e336bd80b12becbb3f73de19a /source/blender/gpu
parent88926375a0e4e45f72c87b9e487c060ddd3c9216 (diff)
Cleanup: Clang-Tidy modernize-use-nullptr
Replace `NULL` with `nullptr` in C++ code. No functional changes.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_batch.cc20
-rw-r--r--source/blender/gpu/intern/gpu_context.cc10
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc30
-rw-r--r--source/blender/gpu/intern/gpu_immediate.cc18
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer.cc6
-rw-r--r--source/blender/gpu/intern/gpu_matrix.cc16
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc24
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc16
-rw-r--r--source/blender/gpu/intern/gpu_uniform_buffer.cc16
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.cc10
-rw-r--r--source/blender/gpu/opengl/gl_batch.cc18
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc18
-rw-r--r--source/blender/gpu/opengl/gl_drawlist.cc18
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.cc10
-rw-r--r--source/blender/gpu/opengl/gl_immediate.cc8
-rw-r--r--source/blender/gpu/opengl/gl_shader.cc8
-rw-r--r--source/blender/gpu/opengl/gl_shader_interface.cc4
-rw-r--r--source/blender/gpu/opengl/gl_texture.cc32
-rw-r--r--source/blender/gpu/opengl/gl_uniform_buffer.cc4
-rw-r--r--source/blender/gpu/opengl/gl_vertex_array.cc2
-rw-r--r--source/blender/gpu/opengl/gl_vertex_buffer.cc8
21 files changed, 148 insertions, 148 deletions
diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc
index 511ddd210af..3bf1233c000 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -73,21 +73,21 @@ void GPU_batch_init_ex(GPUBatch *batch,
GPUIndexBuf *elem,
eGPUBatchFlag owns_flag)
{
- BLI_assert(verts != NULL);
+ BLI_assert(verts != nullptr);
/* Do not pass any other flag */
BLI_assert((owns_flag & ~(GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX)) == 0);
batch->verts[0] = verts;
for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; v++) {
- batch->verts[v] = NULL;
+ batch->verts[v] = nullptr;
}
for (int v = 0; v < GPU_BATCH_INST_VBO_MAX_LEN; v++) {
- batch->inst[v] = NULL;
+ batch->inst[v] = nullptr;
}
batch->elem = elem;
batch->prim_type = prim_type;
batch->flag = owns_flag | GPU_BATCH_INIT | GPU_BATCH_DIRTY;
- batch->shader = NULL;
+ batch->shader = nullptr;
}
/* This will share the VBOs with the new batch. */
@@ -171,7 +171,7 @@ int GPU_batch_instbuf_add_ex(GPUBatch *batch, GPUVertBuf *insts, bool own_vbo)
batch->flag |= GPU_BATCH_DIRTY;
for (uint v = 0; v < GPU_BATCH_INST_VBO_MAX_LEN; v++) {
- if (batch->inst[v] == NULL) {
+ if (batch->inst[v] == nullptr) {
/* for now all VertexBuffers must have same vertex_len */
if (batch->inst[0]) {
/* Allow for different size of vertex buffer (will choose the smallest number of verts). */
@@ -195,9 +195,9 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
batch->flag |= GPU_BATCH_DIRTY;
for (uint v = 0; v < GPU_BATCH_VBO_MAX_LEN; v++) {
- if (batch->verts[v] == NULL) {
+ if (batch->verts[v] == nullptr) {
/* for now all VertexBuffers must have same vertex_len */
- if (batch->verts[0] != NULL) {
+ if (batch->verts[0] != nullptr) {
/* This is an issue for the HACK inside DRW_vbo_request(). */
// BLI_assert(verts->vertex_len == batch->verts[0]->vertex_len);
}
@@ -246,7 +246,7 @@ void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count)
/* Draw multiple instance of a batch without having any instance attributes. */
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
{
- BLI_assert(batch->inst[0] == NULL);
+ BLI_assert(batch->inst[0] == nullptr);
GPU_shader_bind(batch->shader);
GPU_batch_draw_advanced(batch, 0, 0, 0, i_count);
@@ -255,7 +255,7 @@ void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
void GPU_batch_draw_advanced(
GPUBatch *gpu_batch, int v_first, int v_count, int i_first, int i_count)
{
- BLI_assert(Context::get()->shader != NULL);
+ BLI_assert(Context::get()->shader != nullptr);
Batch *batch = static_cast<Batch *>(gpu_batch);
if (v_count == 0) {
@@ -269,7 +269,7 @@ void GPU_batch_draw_advanced(
if (i_count == 0) {
i_count = (batch->inst[0]) ? batch->inst_(0)->vertex_len : 1;
/* Meh. This is to be able to use different numbers of verts in instance vbos. */
- if (batch->inst[1] != NULL) {
+ if (batch->inst[1] != nullptr) {
i_count = min_ii(i_count, batch->inst_(1)->vertex_len);
}
}
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc
index 3ebfd80241d..a9d32dcf297 100644
--- a/source/blender/gpu/intern/gpu_context.cc
+++ b/source/blender/gpu/intern/gpu_context.cc
@@ -54,7 +54,7 @@
using namespace blender::gpu;
-static thread_local Context *active_ctx = NULL;
+static thread_local Context *active_ctx = nullptr;
/* -------------------------------------------------------------------- */
/** \name gpu::Context methods
@@ -98,7 +98,7 @@ Context *Context::get()
GPUContext *GPU_context_create(void *ghost_window)
{
- if (GPUBackend::get() == NULL) {
+ if (GPUBackend::get() == nullptr) {
/* TODO move where it make sense. */
GPU_backend_init(GPU_BACKEND_OPENGL);
}
@@ -114,7 +114,7 @@ void GPU_context_discard(GPUContext *ctx_)
{
Context *ctx = unwrap(ctx_);
delete ctx;
- active_ctx = NULL;
+ active_ctx = nullptr;
}
/* ctx can be NULL */
@@ -166,7 +166,7 @@ static GPUBackend *g_backend;
void GPU_backend_init(eGPUBackendType backend_type)
{
- BLI_assert(g_backend == NULL);
+ BLI_assert(g_backend == nullptr);
switch (backend_type) {
#if WITH_OPENGL_BACKEND
@@ -185,7 +185,7 @@ void GPU_backend_exit(void)
/* TODO assert no resource left. Currently UI textures are still not freed in their context
* correctly. */
delete g_backend;
- g_backend = NULL;
+ g_backend = nullptr;
}
GPUBackend *GPUBackend::get()
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index a16856e0dec..dca1b169307 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -58,7 +58,7 @@ FrameBuffer::FrameBuffer(const char *name)
dirty_state_ = true;
for (int i = 0; i < ARRAY_SIZE(attachments_); i++) {
- attachments_[i].tex = NULL;
+ attachments_[i].tex = nullptr;
attachments_[i].mip = -1;
attachments_[i].layer = -1;
}
@@ -67,7 +67,7 @@ FrameBuffer::FrameBuffer(const char *name)
FrameBuffer::~FrameBuffer()
{
for (int i = 0; i < ARRAY_SIZE(attachments_); i++) {
- if (attachments_[i].tex != NULL) {
+ if (attachments_[i].tex != nullptr) {
reinterpret_cast<Texture *>(attachments_[i].tex)->detach_from(this);
}
}
@@ -150,7 +150,7 @@ void FrameBuffer::recursive_downsample(int max_lvl,
/* Replace attached mip-level for each attachment. */
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
Texture *tex = reinterpret_cast<Texture *>(attachments_[att].tex);
- if (tex != NULL) {
+ if (tex != nullptr) {
/* Some Intel HDXXX have issue with rendering to a mipmap that is below
* the texture GL_TEXTURE_MAX_LEVEL. So even if it not correct, in this case
* we allow GL_TEXTURE_MAX_LEVEL to be one level lower. In practice it does work! */
@@ -169,7 +169,7 @@ void FrameBuffer::recursive_downsample(int max_lvl,
}
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
- if (attachments_[att].tex != NULL) {
+ if (attachments_[att].tex != nullptr) {
/* Reset mipmap level range. */
reinterpret_cast<Texture *>(attachments_[att].tex)->mip_range_set(0, max_lvl);
/* Reset base level. NOTE: might not be the one bound at the start of this function. */
@@ -242,14 +242,14 @@ void GPU_framebuffer_restore(void)
GPUFrameBuffer *GPU_framebuffer_active_get(void)
{
Context *ctx = Context::get();
- return wrap(ctx ? ctx->active_fb : NULL);
+ return wrap(ctx ? ctx->active_fb : nullptr);
}
/* Returns the default frame-buffer. Will always exists even if it's just a dummy. */
GPUFrameBuffer *GPU_framebuffer_back_get(void)
{
Context *ctx = Context::get();
- return wrap(ctx ? ctx->back_left : NULL);
+ return wrap(ctx ? ctx->back_left : nullptr);
}
bool GPU_framebuffer_bound(GPUFrameBuffer *gpu_fb)
@@ -314,7 +314,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb,
if (depth_attachment.mip == -1) {
/* GPU_ATTACHMENT_LEAVE */
}
- else if (depth_attachment.tex == NULL) {
+ else if (depth_attachment.tex == nullptr) {
/* GPU_ATTACHMENT_NONE: Need to clear both targets. */
fb->attachment_set(GPU_FB_DEPTH_STENCIL_ATTACHMENT, depth_attachment);
fb->attachment_set(GPU_FB_DEPTH_ATTACHMENT, depth_attachment);
@@ -487,7 +487,7 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb,
static struct {
GPUFrameBuffer *framebuffers[FRAMEBUFFER_STACK_DEPTH];
uint top;
-} FrameBufferStack = {{0}};
+} FrameBufferStack = {{nullptr}};
static void gpuPushFrameBuffer(GPUFrameBuffer *fb)
{
@@ -526,7 +526,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs)
BLI_assert(ctx);
for (int i = 0; i < MAX_CTX_FB_LEN; i++) {
- if (ofs->framebuffers[i].fb == NULL) {
+ if (ofs->framebuffers[i].fb == nullptr) {
ofs->framebuffers[i].ctx = ctx;
GPU_framebuffer_ensure_config(&ofs->framebuffers[i].fb,
{
@@ -552,7 +552,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs)
for (int i = 0; i < MAX_CTX_FB_LEN; i++) {
GPU_framebuffer_free(ofs->framebuffers[i].fb);
- ofs->framebuffers[i].fb = NULL;
+ ofs->framebuffers[i].fb = nullptr;
}
return gpu_offscreen_fb_get(ofs);
@@ -569,16 +569,16 @@ GPUOffScreen *GPU_offscreen_create(
width = max_ii(1, width);
ofs->color = GPU_texture_create_2d(
- "ofs_color", width, height, 1, (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL);
+ "ofs_color", width, height, 1, (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, nullptr);
if (depth) {
- ofs->depth = GPU_texture_create_2d("ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, NULL);
+ ofs->depth = GPU_texture_create_2d("ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, nullptr);
}
if ((depth && !ofs->depth) || !ofs->color) {
BLI_snprintf(err_out, 256, "GPUTexture: Texture allocation failed.");
GPU_offscreen_free(ofs);
- return NULL;
+ return nullptr;
}
GPUFrameBuffer *fb = gpu_offscreen_fb_get(ofs);
@@ -586,7 +586,7 @@ GPUOffScreen *GPU_offscreen_create(
/* check validity at the very end! */
if (!GPU_framebuffer_check_valid(fb, err_out)) {
GPU_offscreen_free(ofs);
- return NULL;
+ return nullptr;
}
GPU_framebuffer_restore();
return ofs;
@@ -620,7 +620,7 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
{
- GPUFrameBuffer *fb = NULL;
+ GPUFrameBuffer *fb = nullptr;
if (restore) {
fb = gpuPopFrameBuffer();
}
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index 9437f18cb14..110774640f1 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -39,7 +39,7 @@
using namespace blender::gpu;
-static thread_local Immediate *imm = NULL;
+static thread_local Immediate *imm = nullptr;
void immActivate()
{
@@ -48,7 +48,7 @@ void immActivate()
void immDeactivate()
{
- imm = NULL;
+ imm = nullptr;
}
GPUVertFormat *immVertexFormat()
@@ -59,7 +59,7 @@ GPUVertFormat *immVertexFormat()
void immBindShader(GPUShader *shader)
{
- BLI_assert(imm->shader == NULL);
+ BLI_assert(imm->shader == nullptr);
imm->shader = shader;
imm->builtin_shader_bound = GPU_SHADER_TEXT; /* Default value. */
@@ -83,10 +83,10 @@ void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUnbindProgram()
{
- BLI_assert(imm->shader != NULL);
+ BLI_assert(imm->shader != nullptr);
GPU_shader_unbind();
- imm->shader = NULL;
+ imm->shader = nullptr;
}
/* XXX do not use it. Special hack to use OCIO with batch API. */
@@ -193,7 +193,7 @@ static void wide_line_workaround_end()
immUnbindProgram();
immBindShader(imm->prev_shader);
- imm->prev_shader = NULL;
+ imm->prev_shader = nullptr;
}
}
@@ -236,7 +236,7 @@ GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
imm->vertex_data = (uchar *)GPU_vertbuf_get_data(verts);
- imm->batch = GPU_batch_create_ex(prim_type, verts, NULL, GPU_BATCH_OWNS_VBO);
+ imm->batch = GPU_batch_create_ex(prim_type, verts, nullptr, GPU_BATCH_OWNS_VBO);
imm->batch->flag |= GPU_BATCH_BUILDING;
return imm->batch;
@@ -270,7 +270,7 @@ void immEnd()
}
GPU_batch_set_shader(imm->batch, imm->shader);
imm->batch->flag &= ~GPU_BATCH_BUILDING;
- imm->batch = NULL; /* don't free, batch belongs to caller */
+ imm->batch = nullptr; /* don't free, batch belongs to caller */
}
else {
imm->end();
@@ -279,7 +279,7 @@ void immEnd()
/* Prepare for next immBegin. */
imm->prim_type = GPU_PRIM_NONE;
imm->strict_vertex_len = true;
- imm->vertex_data = NULL;
+ imm->vertex_data = nullptr;
wide_line_workaround_end();
}
diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc
index 36f18f2da49..65932d2dbf4 100644
--- a/source/blender/gpu/intern/gpu_index_buffer.cc
+++ b/source/blender/gpu/intern/gpu_index_buffer.cc
@@ -69,7 +69,7 @@ void GPU_indexbuf_init(GPUIndexBufBuilder *builder,
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v)
{
#if TRUST_NO_ONE
- assert(builder->data != NULL);
+ assert(builder->data != nullptr);
assert(builder->index_len < builder->max_index_len);
assert(v <= builder->max_allowed_index);
#endif
@@ -79,7 +79,7 @@ void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v)
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *builder)
{
#if TRUST_NO_ONE
- assert(builder->data != NULL);
+ assert(builder->data != nullptr);
assert(builder->index_len < builder->max_index_len);
#endif
builder->data[builder->index_len++] = RESTART_INDEX;
@@ -336,7 +336,7 @@ GPUIndexBuf *GPU_indexbuf_create_subrange(GPUIndexBuf *elem_src, uint start, uin
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *builder, GPUIndexBuf *elem)
{
- BLI_assert(builder->data != NULL);
+ BLI_assert(builder->data != nullptr);
/* Transfer data ownership to GPUIndexBuf.
* It will be uploaded upon first use. */
unwrap(elem)->init(builder->index_len, builder->data);
diff --git a/source/blender/gpu/intern/gpu_matrix.cc b/source/blender/gpu/intern/gpu_matrix.cc
index 0274966d4b9..5fcf5994d1d 100644
--- a/source/blender/gpu/intern/gpu_matrix.cc
+++ b/source/blender/gpu/intern/gpu_matrix.cc
@@ -606,7 +606,7 @@ const float (*GPU_matrix_projection_get(float m[4][4]))[4]
const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat4 temp;
m = temp;
}
@@ -617,12 +617,12 @@ const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
const float (*GPU_matrix_normal_get(float m[3][3]))[3]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat3 temp3;
m = temp3;
}
- copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(NULL));
+ copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(nullptr));
invert_m3(m);
transpose_m3(m);
@@ -632,7 +632,7 @@ const float (*GPU_matrix_normal_get(float m[3][3]))[3]
const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat3 temp3;
m = temp3;
}
@@ -658,17 +658,17 @@ void GPU_matrix_bind(GPUShader *shader)
int32_t P_inv = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_PROJECTION_INV);
if (MV != -1) {
- GPU_shader_uniform_vector(shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(NULL));
+ GPU_shader_uniform_vector(shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(nullptr));
}
if (P != -1) {
- GPU_shader_uniform_vector(shader, P, 16, 1, (const float *)GPU_matrix_projection_get(NULL));
+ GPU_shader_uniform_vector(shader, P, 16, 1, (const float *)GPU_matrix_projection_get(nullptr));
}
if (MVP != -1) {
GPU_shader_uniform_vector(
- shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(NULL));
+ shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(nullptr));
}
if (N != -1) {
- GPU_shader_uniform_vector(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(NULL));
+ GPU_shader_uniform_vector(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(nullptr));
}
if (MV_inv != -1) {
Mat4 m;
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index c13321ed205..fef07371a56 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -291,7 +291,7 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
const char *shname)
{
/* At least a vertex shader and a fragment shader are required. */
- BLI_assert((fragcode != NULL) && (vertcode != NULL));
+ BLI_assert((fragcode != nullptr) && (vertcode != nullptr));
Shader *shader = GPUBackend::get()->shader_alloc(shname);
@@ -342,14 +342,14 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
shader->geometry_shader_from_glsl(sources);
}
- if (tf_names != NULL && tf_count > 0) {
+ if (tf_names != nullptr && tf_count > 0) {
BLI_assert(tf_type != GPU_SHADER_TFB_NONE);
shader->transform_feedback_names_set(Span<const char *>(tf_names, tf_count), tf_type);
}
if (!shader->finalize()) {
delete shader;
- return NULL;
+ return nullptr;
};
return wrap(shader);
@@ -374,7 +374,7 @@ GPUShader *GPU_shader_create(const char *vertcode,
const char *shname)
{
return GPU_shader_create_ex(
- vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, shname);
+ vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, nullptr, 0, shname);
}
GPUShader *GPU_shader_create_from_python(const char *vertcode,
@@ -383,9 +383,9 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
const char *libcode,
const char *defines)
{
- char *libcodecat = NULL;
+ char *libcodecat = nullptr;
- if (libcode == NULL) {
+ if (libcode == nullptr) {
libcode = datatoc_gpu_shader_colorspace_lib_glsl;
}
else {
@@ -393,7 +393,7 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
}
GPUShader *sh = GPU_shader_create_ex(
- vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, "pyGPUShader");
+ vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, nullptr, 0, "pyGPUShader");
MEM_SAFE_FREE(libcodecat);
return sh;
@@ -402,9 +402,9 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_is_alloc)
{
bool is_alloc = false;
- if (str_arr == NULL) {
+ if (str_arr == nullptr) {
*r_is_alloc = false;
- return NULL;
+ return nullptr;
}
/* Skip empty strings (avoid alloc if we can). */
while (str_arr[0] && str_arr[0][0] == '\0') {
@@ -450,7 +450,7 @@ struct GPUShader *GPU_shader_create_from_arrays_impl(
struct {
const char *str;
bool is_alloc;
- } str_dst[4] = {{0}};
+ } str_dst[4] = {{nullptr}};
const char **str_src[4] = {params->vert, params->frag, params->geom, params->defs};
for (int i = 0; i < ARRAY_SIZE(str_src); i++) {
@@ -461,7 +461,7 @@ struct GPUShader *GPU_shader_create_from_arrays_impl(
BLI_snprintf(name, sizeof(name), "%s_%d", func, line);
GPUShader *sh = GPU_shader_create(
- str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, name);
+ str_dst[0].str, str_dst[1].str, str_dst[2].str, nullptr, str_dst[3].str, name);
for (int i = 0; i < ARRAY_SIZE(str_dst); i++) {
if (str_dst[i].is_alloc) {
@@ -502,7 +502,7 @@ void GPU_shader_unbind(void)
if (ctx->shader) {
ctx->shader->unbind();
}
- ctx->shader = NULL;
+ ctx->shader = nullptr;
#endif
}
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 99d286c3abd..d134d718cbe 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -49,14 +49,14 @@ Texture::Texture(const char *name)
}
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- fb_[i] = NULL;
+ fb_[i] = nullptr;
}
}
Texture::~Texture()
{
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- if (fb_[i] != NULL) {
+ if (fb_[i] != nullptr) {
fb_[i]->attachment_remove(fb_attachment_[i]);
}
}
@@ -142,7 +142,7 @@ bool Texture::init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format)
void Texture::attach_to(FrameBuffer *fb, GPUAttachmentType type)
{
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- if (fb_[i] == NULL) {
+ if (fb_[i] == nullptr) {
fb_attachment_[i] = type;
fb_[i] = fb;
return;
@@ -156,7 +156,7 @@ void Texture::detach_from(FrameBuffer *fb)
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
if (fb_[i] == fb) {
fb_[i]->attachment_remove(fb_attachment_[i]);
- fb_[i] = NULL;
+ fb_[i] = nullptr;
return;
}
}
@@ -226,7 +226,7 @@ static inline GPUTexture *gpu_texture_create(const char *name,
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
if (pixels) {
tex->update(data_format, pixels);
@@ -295,7 +295,7 @@ GPUTexture *GPU_texture_create_compressed_2d(
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
if (data) {
size_t ofs = 0;
@@ -320,7 +320,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(const char *name, GPUVertBuf *vert)
bool success = tex->init_buffer(vert, tex_format);
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
return reinterpret_cast<GPUTexture *>(tex);
}
@@ -383,7 +383,7 @@ void *GPU_texture_read(GPUTexture *tex_, eGPUDataFormat data_format, int miplvl)
*/
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
{
- BLI_assert(data != NULL); /* Do not accept NULL as parameter. */
+ BLI_assert(data != nullptr); /* Do not accept NULL as parameter. */
reinterpret_cast<Texture *>(tex)->clear(data_format, data);
}
diff --git a/source/blender/gpu/intern/gpu_uniform_buffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc
index 2dea98f03ca..89c70c47e4a 100644
--- a/source/blender/gpu/intern/gpu_uniform_buffer.cc
+++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc
@@ -73,7 +73,7 @@ static eGPUType get_padded_gpu_type(LinkData *link)
GPUInput *input = (GPUInput *)link->data;
eGPUType gputype = input->type;
/* Unless the vec3 is followed by a float we need to treat it as a vec4. */
- if (gputype == GPU_VEC3 && (link->next != NULL) &&
+ if (gputype == GPU_VEC3 && (link->next != nullptr) &&
(((GPUInput *)link->next->data)->type != GPU_FLOAT)) {
gputype = GPU_VEC4;
}
@@ -106,7 +106,7 @@ static void buffer_from_list_inputs_sort(ListBase *inputs)
BLI_listbase_sort(inputs, inputs_cmp);
/* Creates a lookup table for the different types; */
- LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL};
+ LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {nullptr};
eGPUType cur_type = static_cast<eGPUType>(MAX_UBO_GPU_TYPE + 1);
LISTBASE_FOREACH (LinkData *, link, inputs) {
@@ -131,21 +131,21 @@ static void buffer_from_list_inputs_sort(ListBase *inputs)
}
/* If there is no GPU_VEC3 there is no need for alignment. */
- if (inputs_lookup[GPU_VEC3] == NULL) {
+ if (inputs_lookup[GPU_VEC3] == nullptr) {
return;
}
LinkData *link = inputs_lookup[GPU_VEC3];
- while (link != NULL && ((GPUInput *)link->data)->type == GPU_VEC3) {
+ while (link != nullptr && ((GPUInput *)link->data)->type == GPU_VEC3) {
LinkData *link_next = link->next;
/* If GPU_VEC3 is followed by nothing or a GPU_FLOAT, no need for alignment. */
- if ((link_next == NULL) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) {
+ if ((link_next == nullptr) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) {
break;
}
/* If there is a float, move it next to current vec3. */
- if (inputs_lookup[GPU_FLOAT] != NULL) {
+ if (inputs_lookup[GPU_FLOAT] != nullptr) {
LinkData *float_input = inputs_lookup[GPU_FLOAT];
inputs_lookup[GPU_FLOAT] = float_input->next;
@@ -195,7 +195,7 @@ GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const cha
{
UniformBuf *ubo = GPUBackend::get()->uniformbuf_alloc(size, name);
/* Direct init. */
- if (data != NULL) {
+ if (data != nullptr) {
ubo->update(data);
}
return wrap(ubo);
@@ -211,7 +211,7 @@ GPUUniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *nam
{
/* There is no point on creating an UBO if there is no arguments. */
if (BLI_listbase_is_empty(inputs)) {
- return NULL;
+ return nullptr;
}
buffer_from_list_inputs_sort(inputs);
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc
index be66d91b025..09b9eba9f95 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.cc
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc
@@ -191,7 +191,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len)
void GPU_vertbuf_data_len_set(GPUVertBuf *verts_, uint v_len)
{
VertBuf *verts = unwrap(verts_);
- BLI_assert(verts->data != NULL); /* Only for dynamic data. */
+ BLI_assert(verts->data != nullptr); /* Only for dynamic data. */
BLI_assert(v_len <= verts->vertex_alloc);
verts->vertex_len = v_len;
}
@@ -203,7 +203,7 @@ void GPU_vertbuf_attr_set(GPUVertBuf *verts_, uint a_idx, uint v_idx, const void
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(v_idx < verts->vertex_alloc);
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
memcpy(verts->data + a->offset + v_idx * format->stride, data, a->sz);
}
@@ -225,7 +225,7 @@ void GPU_vertbuf_vert_set(GPUVertBuf *verts_, uint v_idx, const void *data)
VertBuf *verts = unwrap(verts_);
const GPUVertFormat *format = &verts->format;
BLI_assert(v_idx < verts->vertex_alloc);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
memcpy(verts->data + v_idx * format->stride, data, format->stride);
}
@@ -236,7 +236,7 @@ void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts_, uint a_idx, uint stride, c
const GPUVertFormat *format = &verts->format;
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
const uint vertex_len = verts->vertex_len;
@@ -259,7 +259,7 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts_, uint a_idx, GPUVertBufRaw
const GPUVertFormat *format = &verts->format;
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
verts->flag &= ~GPU_VERTBUF_DATA_UPLOADED;
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc
index b81c2d69122..89486b73b05 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -62,11 +62,11 @@ GLVaoCache::~GLVaoCache()
void GLVaoCache::init()
{
- context_ = NULL;
- interface_ = NULL;
+ context_ = nullptr;
+ interface_ = nullptr;
is_dynamic_vao_count = false;
for (int i = 0; i < GPU_VAO_STATIC_LEN; i++) {
- static_vaos.interfaces[i] = NULL;
+ static_vaos.interfaces[i] = nullptr;
static_vaos.vao_ids[i] = 0;
}
vao_base_instance_ = 0;
@@ -93,7 +93,7 @@ void GLVaoCache::insert(const GLShaderInterface *interface, GLuint vao)
else {
/* Erase previous entries, they will be added back if drawn again. */
for (int i = 0; i < GPU_VAO_STATIC_LEN; i++) {
- if (static_vaos.interfaces[i] != NULL) {
+ if (static_vaos.interfaces[i] != nullptr) {
const_cast<GLShaderInterface *>(static_vaos.interfaces[i])->ref_remove(this);
context_->vao_free(static_vaos.vao_ids[i]);
}
@@ -143,7 +143,7 @@ void GLVaoCache::remove(const GLShaderInterface *interface)
if (interfaces[i] == interface) {
context_->vao_free(vaos[i]);
vaos[i] = 0;
- interfaces[i] = NULL;
+ interfaces[i] = nullptr;
break; /* cannot have duplicates */
}
}
@@ -157,7 +157,7 @@ void GLVaoCache::clear()
const GLShaderInterface **interfaces = (is_dynamic_vao_count) ? dynamic_vaos.interfaces :
static_vaos.interfaces;
/* Early out, nothing to free. */
- if (context_ == NULL) {
+ if (context_ == nullptr) {
return;
}
@@ -174,7 +174,7 @@ void GLVaoCache::clear()
}
for (int i = 0; i < count; i++) {
- if (interfaces[i] != NULL) {
+ if (interfaces[i] != nullptr) {
const_cast<GLShaderInterface *>(interfaces[i])->ref_remove(this);
}
}
@@ -213,7 +213,7 @@ void GLVaoCache::context_check()
BLI_assert(ctx);
if (context_ != ctx) {
- if (context_ != NULL) {
+ if (context_ != nullptr) {
/* IMPORTANT: Trying to draw a batch in multiple different context will trash the VAO cache.
* This has major performance impact and should be avoided in most cases. */
context_->vao_cache_unregister(this);
@@ -307,7 +307,7 @@ void GLBatch::bind(int i_first)
#if GPU_TRACK_INDEX_RANGE
/* Can be removed if GL 4.3 is required. */
- if (!GLContext::fixed_restart_index_support && (elem != NULL)) {
+ if (!GLContext::fixed_restart_index_support && (elem != nullptr)) {
glPrimitiveRestartIndex(this->elem_()->restart_index());
}
#endif
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 3737321ed90..4e45ff11fc7 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -152,8 +152,8 @@ void init_gl_callbacks()
SNPRINTF(msg, format, GLEW_VERSION_4_3 ? "OpenGL 4.3" : "KHR_debug extension");
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
- glDebugMessageCallback((GLDEBUGPROC)debug_callback, NULL);
- glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
+ glDebugMessageCallback((GLDEBUGPROC)debug_callback, nullptr);
+ glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_MARKER,
0,
@@ -164,8 +164,8 @@ void init_gl_callbacks()
else if (GLEW_ARB_debug_output) {
SNPRINTF(msg, format, "ARB_debug_output");
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
- glDebugMessageCallbackARB((GLDEBUGPROCARB)debug_callback, NULL);
- glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
+ glDebugMessageCallbackARB((GLDEBUGPROCARB)debug_callback, nullptr);
+ glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB,
GL_DEBUG_TYPE_OTHER_ARB,
0,
@@ -213,7 +213,7 @@ void check_gl_error(const char *info)
default:
char msg[256];
SNPRINTF(msg, "Unknown GL error: %x : %s", error, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
break;
}
}
@@ -250,7 +250,7 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing UBO bind at slot %d : %s > %s : %s", i, sh_name, ubo_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
@@ -262,7 +262,7 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing Texture bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
@@ -274,14 +274,14 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing Image bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
}
void raise_gl_error(const char *info)
{
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, info, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, info, nullptr);
}
/** \} */
diff --git a/source/blender/gpu/opengl/gl_drawlist.cc b/source/blender/gpu/opengl/gl_drawlist.cc
index b0a8af5b482..aecadc4d14a 100644
--- a/source/blender/gpu/opengl/gl_drawlist.cc
+++ b/source/blender/gpu/opengl/gl_drawlist.cc
@@ -65,13 +65,13 @@ typedef struct GLDrawCommandIndexed {
GLDrawList::GLDrawList(int length)
{
BLI_assert(length > 0);
- batch_ = NULL;
+ batch_ = nullptr;
buffer_id_ = 0;
command_len_ = 0;
command_offset_ = 0;
data_offset_ = 0;
data_size_ = 0;
- data_ = NULL;
+ data_ = nullptr;
if (GLContext::multi_draw_indirect_support) {
/* Alloc the biggest possible command list, which is indexed. */
@@ -92,8 +92,8 @@ void GLDrawList::init()
{
BLI_assert(GLContext::get());
BLI_assert(MDI_ENABLED);
- BLI_assert(data_ == NULL);
- batch_ = NULL;
+ BLI_assert(data_ == nullptr);
+ batch_ = nullptr;
command_len_ = 0;
if (buffer_id_ == 0) {
@@ -105,7 +105,7 @@ void GLDrawList::init()
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_);
/* If buffer is full, orphan buffer data and start fresh. */
// if (command_offset_ >= data_size_) {
- glBufferData(GL_DRAW_INDIRECT_BUFFER, buffer_size_, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_DRAW_INDIRECT_BUFFER, buffer_size_, nullptr, GL_DYNAMIC_DRAW);
data_offset_ = 0;
// }
/* Map the remaining range. */
@@ -123,7 +123,7 @@ void GLDrawList::append(GPUBatch *gpu_batch, int i_first, int i_count)
return;
}
- if (data_ == NULL) {
+ if (data_ == nullptr) {
this->init();
}
@@ -177,7 +177,7 @@ void GLDrawList::submit()
/* Something's wrong if we get here without MDI support. */
BLI_assert(MDI_ENABLED);
BLI_assert(data_);
- BLI_assert(GLContext::get()->shader != NULL);
+ BLI_assert(GLContext::get()->shader != nullptr);
/* Only do multi-draw indirect if doing more than 2 drawcall. This avoids the overhead of
* buffer mapping if scene is not very instance friendly. BUT we also need to take into
@@ -190,7 +190,7 @@ void GLDrawList::submit()
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_);
glFlushMappedBufferRange(GL_DRAW_INDIRECT_BUFFER, 0, command_offset_);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
- data_ = NULL; /* Unmapped */
+ data_ = nullptr; /* Unmapped */
data_offset_ += command_offset_;
batch_->bind(0);
@@ -227,7 +227,7 @@ void GLDrawList::submit()
/* Do not submit this buffer again. */
command_len_ = 0;
/* Avoid keeping reference to the batch. */
- batch_ = NULL;
+ batch_ = nullptr;
}
/** \} */
diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index 661b976771f..cbb332388dc 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -72,7 +72,7 @@ GLFrameBuffer::GLFrameBuffer(
GLFrameBuffer::~GLFrameBuffer()
{
- if (context_ == NULL) {
+ if (context_ == nullptr) {
return;
}
@@ -176,7 +176,7 @@ void GLFrameBuffer::update_attachments()
first_attachment = (attach.tex) ? type : first_attachment;
}
- if (attach.tex == NULL) {
+ if (attach.tex == nullptr) {
glFramebufferTexture(GL_FRAMEBUFFER, gl_attachment, 0, 0);
continue;
}
@@ -208,7 +208,7 @@ void GLFrameBuffer::update_attachments()
for (int i = ARRAY_SIZE(gl_attachments_) - 1; i >= 0; --i) {
GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0 + i;
GPUAttachment &attach = attachments_[type];
- if (attach.tex != NULL) {
+ if (attach.tex != nullptr) {
gl_tex = static_cast<GLTexture *>(unwrap(attach.tex))->tex_id_;
}
else if (gl_tex != 0) {
@@ -232,7 +232,7 @@ void GLFrameBuffer::update_attachments()
glDrawBuffers(ARRAY_SIZE(gl_attachments_), gl_attachments_);
if (G.debug & G_DEBUG_GPU) {
- BLI_assert(this->check(NULL));
+ BLI_assert(this->check(nullptr));
}
}
@@ -410,7 +410,7 @@ void GLFrameBuffer::clear_multi(const float (*clear_cols)[4])
* TODO(fclem): fix this insecurity? */
int type = GPU_FB_COLOR_ATTACHMENT0;
for (int i = 0; type < GPU_FB_MAX_ATTACHMENT; i++, type++) {
- if (attachments_[type].tex != NULL) {
+ if (attachments_[type].tex != nullptr) {
this->clear_attachment(GPU_FB_COLOR_ATTACHMENT0 + i, GPU_DATA_FLOAT, clear_cols[i]);
}
}
diff --git a/source/blender/gpu/opengl/gl_immediate.cc b/source/blender/gpu/opengl/gl_immediate.cc
index 4350902de73..63e3162944d 100644
--- a/source/blender/gpu/opengl/gl_immediate.cc
+++ b/source/blender/gpu/opengl/gl_immediate.cc
@@ -50,12 +50,12 @@ GLImmediate::GLImmediate()
buffer.buffer_size = DEFAULT_INTERNAL_BUFFER_SIZE;
glGenBuffers(1, &buffer.vbo_id);
glBindBuffer(GL_ARRAY_BUFFER, buffer.vbo_id);
- glBufferData(GL_ARRAY_BUFFER, buffer.buffer_size, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer.buffer_size, nullptr, GL_DYNAMIC_DRAW);
buffer_strict.buffer_size = DEFAULT_INTERNAL_BUFFER_SIZE;
glGenBuffers(1, &buffer_strict.vbo_id);
glBindBuffer(GL_ARRAY_BUFFER, buffer_strict.vbo_id);
- glBufferData(GL_ARRAY_BUFFER, buffer_strict.buffer_size, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer_strict.buffer_size, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
@@ -112,7 +112,7 @@ uchar *GLImmediate::begin()
}
else {
/* orphan this buffer & start with a fresh one */
- glBufferData(GL_ARRAY_BUFFER, buffer_size(), NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer_size(), nullptr, GL_DYNAMIC_DRAW);
buffer_offset() = 0;
}
@@ -129,7 +129,7 @@ uchar *GLImmediate::begin()
access |= GL_MAP_FLUSH_EXPLICIT_BIT;
}
void *data = glMapBufferRange(GL_ARRAY_BUFFER, buffer_offset(), bytes_needed, access);
- BLI_assert(data != NULL);
+ BLI_assert(data != nullptr);
bytes_mapped_ = bytes_needed;
return (uchar *)data;
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc
index 57b9cac3f83..cc5f83228d6 100644
--- a/source/blender/gpu/opengl/gl_shader.cc
+++ b/source/blender/gpu/opengl/gl_shader.cc
@@ -123,14 +123,14 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
/* Patch the shader code using the first source slot. */
sources[0] = glsl_patch_get();
- glShaderSource(shader, sources.size(), sources.data(), NULL);
+ glShaderSource(shader, sources.size(), sources.data(), nullptr);
glCompileShader(shader);
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (!status || (G.debug & G_DEBUG_GPU)) {
char log[5000] = "";
- glGetShaderInfoLog(shader, sizeof(log), NULL, log);
+ glGetShaderInfoLog(shader, sizeof(log), nullptr, log);
if (log[0] != '\0') {
switch (gl_stage) {
case GL_VERTEX_SHADER:
@@ -184,7 +184,7 @@ bool GLShader::finalize()
glGetProgramiv(shader_program_, GL_LINK_STATUS, &status);
if (!status) {
char log[5000];
- glGetProgramInfoLog(shader_program_, sizeof(log), NULL, log);
+ glGetProgramInfoLog(shader_program_, sizeof(log), nullptr, log);
Span<const char *> sources;
this->print_log(sources, log, "Linking", true);
return false;
@@ -409,7 +409,7 @@ void GLShader::vertformat_from_shader(GPUVertFormat *format) const
char name[256];
GLenum gl_type;
GLint size;
- glGetActiveAttrib(shader_program_, i, sizeof(name), NULL, &size, &gl_type, name);
+ glGetActiveAttrib(shader_program_, i, sizeof(name), nullptr, &size, &gl_type, name);
/* Ignore OpenGL names like `gl_BaseInstanceARB`, `gl_InstanceID` and `gl_VertexID`. */
if (glGetAttribLocation(shader_program_, name) == -1) {
diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc
index 2d55c222e9c..9533639b133 100644
--- a/source/blender/gpu/opengl/gl_shader_interface.cc
+++ b/source/blender/gpu/opengl/gl_shader_interface.cc
@@ -267,7 +267,7 @@ GLShaderInterface::GLShaderInterface(GLuint program)
for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
const ShaderInput *block = this->ubo_get(builtin_uniform_block_name(u));
- builtin_blocks_[u] = (block != NULL) ? block->binding : -1;
+ builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
}
MEM_freeN(uniforms_from_blocks);
@@ -285,7 +285,7 @@ GLShaderInterface::GLShaderInterface(GLuint program)
GLShaderInterface::~GLShaderInterface()
{
for (auto *ref : refs_) {
- if (ref != NULL) {
+ if (ref != nullptr) {
ref->remove(this);
}
}
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index 993bb56612c..021376aaea6 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -44,7 +44,7 @@ namespace blender::gpu {
GLTexture::GLTexture(const char *name) : Texture(name)
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
glGenTextures(1, &tex_id_);
}
@@ -55,7 +55,7 @@ GLTexture::~GLTexture()
GPU_framebuffer_free(framebuffer_);
}
GLContext *ctx = GLContext::get();
- if (ctx != NULL && is_bound_) {
+ if (ctx != nullptr && is_bound_) {
/* This avoid errors when the texture is still inside the bound texture array. */
ctx->state_manager->texture_unbind(this);
}
@@ -148,7 +148,7 @@ void GLTexture::ensure_mipmaps(int miplvl)
if (type_ == GPU_TEXTURE_CUBE) {
for (int i = 0; i < d; i++) {
GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
- glTexImage2D(target, mip, internal_format, w, h, 0, gl_format, gl_type, NULL);
+ glTexImage2D(target, mip, internal_format, w, h, 0, gl_format, gl_type, nullptr);
}
}
else if (format_flag_ & GPU_FORMAT_COMPRESSED) {
@@ -156,13 +156,13 @@ void GLTexture::ensure_mipmaps(int miplvl)
switch (dimensions) {
default:
case 1:
- glCompressedTexImage1D(target_, mip, internal_format, w, 0, size, NULL);
+ glCompressedTexImage1D(target_, mip, internal_format, w, 0, size, nullptr);
break;
case 2:
- glCompressedTexImage2D(target_, mip, internal_format, w, h, 0, size, NULL);
+ glCompressedTexImage2D(target_, mip, internal_format, w, h, 0, size, nullptr);
break;
case 3:
- glCompressedTexImage3D(target_, mip, internal_format, w, h, d, 0, size, NULL);
+ glCompressedTexImage3D(target_, mip, internal_format, w, h, d, 0, size, nullptr);
break;
}
}
@@ -170,13 +170,13 @@ void GLTexture::ensure_mipmaps(int miplvl)
switch (dimensions) {
default:
case 1:
- glTexImage1D(target_, mip, internal_format, w, 0, gl_format, gl_type, NULL);
+ glTexImage1D(target_, mip, internal_format, w, 0, gl_format, gl_type, nullptr);
break;
case 2:
- glTexImage2D(target_, mip, internal_format, w, h, 0, gl_format, gl_type, NULL);
+ glTexImage2D(target_, mip, internal_format, w, h, 0, gl_format, gl_type, nullptr);
break;
case 3:
- glTexImage3D(target_, mip, internal_format, w, h, d, 0, gl_format, gl_type, NULL);
+ glTexImage3D(target_, mip, internal_format, w, h, d, 0, gl_format, gl_type, nullptr);
break;
}
}
@@ -231,7 +231,7 @@ void GLTexture::update_sub(
int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data)
{
BLI_assert(validate_data_format(format_, type));
- BLI_assert(data != NULL);
+ BLI_assert(data != nullptr);
this->ensure_mipmaps(mip);
@@ -617,13 +617,13 @@ bool GLTexture::proxy_check(int mip)
switch (dimensions) {
default:
case 1:
- glCompressedTexImage1D(gl_proxy, mip, size[0], 0, gl_format, img_size, NULL);
+ glCompressedTexImage1D(gl_proxy, mip, size[0], 0, gl_format, img_size, nullptr);
break;
case 2:
- glCompressedTexImage2D(gl_proxy, mip, UNPACK2(size), 0, gl_format, img_size, NULL);
+ glCompressedTexImage2D(gl_proxy, mip, UNPACK2(size), 0, gl_format, img_size, nullptr);
break;
case 3:
- glCompressedTexImage3D(gl_proxy, mip, UNPACK3(size), 0, gl_format, img_size, NULL);
+ glCompressedTexImage3D(gl_proxy, mip, UNPACK3(size), 0, gl_format, img_size, nullptr);
break;
}
}
@@ -631,13 +631,13 @@ bool GLTexture::proxy_check(int mip)
switch (dimensions) {
default:
case 1:
- glTexImage1D(gl_proxy, mip, internal_format, size[0], 0, gl_format, gl_type, NULL);
+ glTexImage1D(gl_proxy, mip, internal_format, size[0], 0, gl_format, gl_type, nullptr);
break;
case 2:
- glTexImage2D(gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, NULL);
+ glTexImage2D(gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, nullptr);
break;
case 3:
- glTexImage3D(gl_proxy, mip, internal_format, UNPACK3(size), 0, gl_format, gl_type, NULL);
+ glTexImage3D(gl_proxy, mip, internal_format, UNPACK3(size), 0, gl_format, gl_type, nullptr);
break;
}
}
diff --git a/source/blender/gpu/opengl/gl_uniform_buffer.cc b/source/blender/gpu/opengl/gl_uniform_buffer.cc
index 7f404880092..ecb233f2e5a 100644
--- a/source/blender/gpu/opengl/gl_uniform_buffer.cc
+++ b/source/blender/gpu/opengl/gl_uniform_buffer.cc
@@ -61,7 +61,7 @@ void GLUniformBuf::init()
glGenBuffers(1, &ubo_id_);
glBindBuffer(GL_UNIFORM_BUFFER, ubo_id_);
- glBufferData(GL_UNIFORM_BUFFER, size_in_bytes_, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_UNIFORM_BUFFER, size_in_bytes_, nullptr, GL_DYNAMIC_DRAW);
debug::object_label(GL_UNIFORM_BUFFER, ubo_id_, name_);
}
@@ -97,7 +97,7 @@ void GLUniformBuf::bind(int slot)
this->init();
}
- if (data_ != NULL) {
+ if (data_ != nullptr) {
this->update(data_);
MEM_SAFE_FREE(data_);
}
diff --git a/source/blender/gpu/opengl/gl_vertex_array.cc b/source/blender/gpu/opengl/gl_vertex_array.cc
index 7585a327b3b..ea2770f099d 100644
--- a/source/blender/gpu/opengl/gl_vertex_array.cc
+++ b/source/blender/gpu/opengl/gl_vertex_array.cc
@@ -70,7 +70,7 @@ static uint16_t vbo_bind(const ShaderInterface *interface,
const char *name = GPU_vertformat_attr_name_get(format, a, n_idx);
const ShaderInput *input = interface->attr_get(name);
- if (input == NULL) {
+ if (input == nullptr) {
continue;
}
diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc
index 74640162a0b..a56d5269fde 100644
--- a/source/blender/gpu/opengl/gl_vertex_buffer.cc
+++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc
@@ -52,7 +52,7 @@ void GLVertBuf::release_data()
void GLVertBuf::duplicate_data(VertBuf *dst_)
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
GLVertBuf *src = this;
GLVertBuf *dst = static_cast<GLVertBuf *>(dst_);
@@ -61,7 +61,7 @@ void GLVertBuf::duplicate_data(VertBuf *dst_)
glGenBuffers(1, &dst->vbo_id_);
glBindBuffer(GL_COPY_WRITE_BUFFER, dst->vbo_id_);
- glBufferData(GL_COPY_WRITE_BUFFER, dst->vbo_size_, NULL, to_gl(dst->usage_));
+ glBufferData(GL_COPY_WRITE_BUFFER, dst->vbo_size_, nullptr, to_gl(dst->usage_));
glBindBuffer(GL_COPY_READ_BUFFER, src->vbo_id_);
@@ -82,7 +82,7 @@ void GLVertBuf::upload_data()
void GLVertBuf::bind()
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
if (vbo_id_ == 0) {
glGenBuffers(1, &vbo_id_);
@@ -93,7 +93,7 @@ void GLVertBuf::bind()
if (flag & GPU_VERTBUF_DATA_DIRTY) {
vbo_size_ = this->size_used_get();
/* Orphan the vbo to avoid sync then upload data. */
- glBufferData(GL_ARRAY_BUFFER, vbo_size_, NULL, to_gl(usage_));
+ glBufferData(GL_ARRAY_BUFFER, vbo_size_, nullptr, to_gl(usage_));
glBufferSubData(GL_ARRAY_BUFFER, 0, vbo_size_, data);
memory_usage += vbo_size_;