diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-11-06 19:49:09 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-11-06 20:08:25 +0300 |
commit | 16732def37c5a66f3ea28dbe247b09cc6bca6677 (patch) | |
tree | 5d14f5c920a1411e336bd80b12becbb3f73de19a /source/blender/gpu/intern | |
parent | 88926375a0e4e45f72c87b9e487c060ddd3c9216 (diff) |
Cleanup: Clang-Tidy modernize-use-nullptr
Replace `NULL` with `nullptr` in C++ code.
No functional changes.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.cc | 20 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_context.cc | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.cc | 30 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate.cc | 18 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_index_buffer.cc | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_matrix.cc | 16 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.cc | 24 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.cc | 16 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_uniform_buffer.cc | 16 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_buffer.cc | 10 |
10 files changed, 83 insertions, 83 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; |