Cleanup: Various clang-tidy warnings in draw

Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
Brecht Van Lommel
2025-01-26 20:08:03 +01:00
parent 1eb1755e1f
commit 61eedabae9
55 changed files with 123 additions and 179 deletions

View File

@@ -12,8 +12,6 @@
#include "DNA_ID.h"
#include "DNA_ID_enums.h"
#include "DNA_camera_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_vec_types.h"
#include "DNA_view3d_types.h"
@@ -32,6 +30,7 @@
#include "COM_texture_pool.hh"
#include "GPU_context.hh"
#include "GPU_state.hh"
#include "GPU_texture.hh"
#include "draw_view_data.hh"

View File

@@ -26,8 +26,6 @@
#include "eevee_ambient_occlusion.hh"
#include "eevee_instance.hh"
#include "GPU_capabilities.hh"
namespace blender::eevee {
/* -------------------------------------------------------------------- */

View File

@@ -92,7 +92,7 @@ void Camera::sync()
int2 film_extent = inst_.film.film_extent_get();
int2 film_offset = inst_.film.film_offset_get();
/* Over-scan in film pixel. Not the same as `render_overscan_get`. */
int film_overscan = inst_.film.overscan_pixels_get(overscan_, film_extent);
int film_overscan = Film::overscan_pixels_get(overscan_, film_extent);
rcti film_rect;
BLI_rcti_init(&film_rect,

View File

@@ -8,6 +8,7 @@
* \ingroup eevee
*/
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "eevee_shader_shared.hh"

View File

@@ -3,8 +3,6 @@
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_cryptomatte.hh"
#include "GPU_material.hh"
#include "eevee_cryptomatte.hh"
#include "eevee_instance.hh"
#include "eevee_renderbuffers.hh"
@@ -13,10 +11,10 @@ namespace blender::eevee {
void Cryptomatte::begin_sync()
{
const eViewLayerEEVEEPassType enabled_passes = static_cast<eViewLayerEEVEEPassType>(
inst_.film.enabled_passes_get() &
(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET |
EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL));
const eViewLayerEEVEEPassType enabled_passes = (inst_.film.enabled_passes_get() &
(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT |
EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET |
EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL));
session_.reset();
object_layer_ = nullptr;

View File

@@ -2,8 +2,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_global.hh"
#include "eevee_instance.hh"
#include "eevee_hizbuffer.hh"

View File

@@ -21,13 +21,10 @@
#pragma once
#include "BLI_bitmap.h"
#include "BLI_vector.hh"
#include "DNA_light_types.h"
#include "eevee_camera.hh"
#include "eevee_sampling.hh"
#include "eevee_shader.hh"
#include "eevee_shader_shared.hh"
#include "eevee_sync.hh"
@@ -49,7 +46,6 @@ struct Light : public LightData, NonCopyable {
ShadowDirectional *directional = nullptr;
ShadowPunctual *punctual = nullptr;
public:
Light()
{
/* Avoid valgrind warning. */
@@ -96,7 +92,7 @@ struct Light : public LightData, NonCopyable {
const float3 &scale,
const float3 &z_axis,
float threshold,
bool do_jitter);
bool use_jitter);
float shape_radiance_get();
float point_radiance_get();
};

View File

@@ -31,7 +31,6 @@
#include "wm_window.hh"
#include "eevee_engine.h"
#include "eevee_instance.hh"
#include "eevee_lightcache.hh"
@@ -144,7 +143,7 @@ class LightBake {
/**
* Called from worker thread.
*/
void run(bool *stop = nullptr, bool *do_update = nullptr, float *progress = nullptr)
void run(const bool *stop = nullptr, bool *do_update = nullptr, float *progress = nullptr)
{
DEG_graph_relations_update(depsgraph_);
DEG_evaluate_on_framechange(depsgraph_, frame_);

View File

@@ -11,13 +11,10 @@
*/
#include "DNA_lightprobe_types.h"
#include "WM_api.hh"
#include "eevee_instance.hh"
#include "eevee_lightprobe.hh"
#include "draw_debug.hh"
#include <iostream>
namespace blender::eevee {

View File

@@ -241,16 +241,14 @@ void VolumeProbeModule::set_view(View & /*view*/)
if (_a.x != _b.x) {
return _a.x < _b.x;
}
else if (_a.y != _b.y) {
if (_a.y != _b.y) {
return _a.y < _b.y;
}
else if (_a.z != _b.z) {
if (_a.z != _b.z) {
return _a.z < _b.z;
}
else {
/* Fallback to memory address, since there's no good alternative. */
return a < b;
}
/* Fallback to memory address, since there's no good alternative. */
return a < b;
});
/* Insert grids in UBO in sorted order. */
@@ -1166,7 +1164,7 @@ void IrradianceBake::raylists_build()
using namespace blender::math;
float2 rand_uv = inst_.sampling.rng_2d_get(eSamplingDimension::SAMPLING_LENS_U);
const float3 ray_direction = inst_.sampling.sample_sphere(rand_uv);
const float3 ray_direction = Sampling::sample_sphere(rand_uv);
const float3 up = ray_direction;
const float3 forward = cross(up, normalize(orthogonal(up)));
const float4x4 viewinv = from_orthonormal_axes<float4x4>(float3(0.0f), forward, up);

View File

@@ -41,7 +41,7 @@ LookdevWorld::LookdevWorld()
rotate->custom1 = NODE_VECTOR_ROTATE_TYPE_AXIS_Z;
bNodeSocket *rotate_vector_in = bke::node_find_socket(rotate, SOCK_IN, "Vector");
angle_socket_ = static_cast<bNodeSocketValueFloat *>(
static_cast<void *>(bke::node_find_socket(rotate, SOCK_IN, "Angle")->default_value));
bke::node_find_socket(rotate, SOCK_IN, "Angle")->default_value);
bNodeSocket *rotate_out = bke::node_find_socket(rotate, SOCK_OUT, "Vector");
bNode *environment = bke::node_add_static_node(nullptr, ntree, SH_NODE_TEX_ENVIRONMENT);
@@ -54,7 +54,7 @@ LookdevWorld::LookdevWorld()
bNodeSocket *background_out = bke::node_find_socket(background, SOCK_OUT, "Background");
bNodeSocket *background_color_in = bke::node_find_socket(background, SOCK_IN, "Color");
intensity_socket_ = static_cast<bNodeSocketValueFloat *>(
static_cast<void *>(bke::node_find_socket(background, SOCK_IN, "Strength")->default_value));
bke::node_find_socket(background, SOCK_IN, "Strength")->default_value);
bNode *output = bke::node_add_static_node(nullptr, ntree, SH_NODE_OUTPUT_WORLD);
bNodeSocket *output_in = bke::node_find_socket(output, SOCK_IN, "Surface");
@@ -130,7 +130,7 @@ bool LookdevWorld::sync(const LookdevParameters &new_parameters)
LookdevModule::LookdevModule(Instance &inst) : inst_(inst) {}
LookdevModule::~LookdevModule() {}
LookdevModule::~LookdevModule() = default;
void LookdevModule::init(const rcti *visible_rect)
{
@@ -162,7 +162,7 @@ static eDRWLevelOfDetail calc_level_of_detail(const float viewport_scale)
if (res_scale > 0.7f) {
return DRW_LOD_HIGH;
}
else if (res_scale > 0.25f) {
if (res_scale > 0.25f) {
return DRW_LOD_MEDIUM;
}
return DRW_LOD_LOW;
@@ -199,7 +199,7 @@ void LookdevModule::sync()
const Camera &cam = inst_.camera;
float sphere_distance = cam.data_get().clip_near;
int2 display_extent = inst_.film.display_extent_get();
float pixel_radius = inst_.shadows.screen_pixel_radius(
float pixel_radius = ShadowModule::screen_pixel_radius(
cam.data_get().wininv, cam.is_perspective(), display_extent);
if (cam.is_perspective()) {
@@ -303,7 +303,7 @@ void LookdevModule::display()
/** \name Parameters
* \{ */
LookdevParameters::LookdevParameters() {}
LookdevParameters::LookdevParameters() = default;
LookdevParameters::LookdevParameters(const ::View3D *v3d)
{

View File

@@ -15,8 +15,6 @@
#include "NOD_shader.h"
#include "draw_cache.hh"
#include "eevee_instance.hh"
#include "eevee_material.hh"

View File

@@ -960,9 +960,7 @@ PassMain::Sub *DeferredPipeline::prepass_add(::Material *blender_mat,
if (!use_combined_lightprobe_eval && (blender_mat->blend_flag & MA_BL_SS_REFRACTION)) {
return refraction_layer_.prepass_add(blender_mat, gpumat, has_motion);
}
else {
return opaque_layer_.prepass_add(blender_mat, gpumat, has_motion);
}
return opaque_layer_.prepass_add(blender_mat, gpumat, has_motion);
}
PassMain::Sub *DeferredPipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat)
@@ -970,9 +968,7 @@ PassMain::Sub *DeferredPipeline::material_add(::Material *blender_mat, GPUMateri
if (!use_combined_lightprobe_eval && (blender_mat->blend_flag & MA_BL_SS_REFRACTION)) {
return refraction_layer_.material_add(blender_mat, gpumat);
}
else {
return opaque_layer_.material_add(blender_mat, gpumat);
}
return opaque_layer_.material_add(blender_mat, gpumat);
}
void DeferredPipeline::render(View &main_view,
@@ -1212,7 +1208,7 @@ std::optional<Bounds<float>> VolumePipeline::object_integration_range() const
bool VolumePipeline::use_hit_list() const
{
for (auto &layer : layers_) {
for (const auto &layer : layers_) {
if (layer->use_hit_list) {
return true;
}

View File

@@ -15,7 +15,6 @@
#include "BLI_math_bits.h"
#include "DRW_render.hh"
#include "draw_shader_shared.hh"
#include "eevee_lut.hh"
#include "eevee_raytrace.hh"
@@ -352,8 +351,8 @@ class DeferredPipeline {
void begin_sync();
void end_sync();
PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat, bool has_motion);
PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat, bool has_motion);
PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat);
void render(View &main_view,
View &render_view,
@@ -440,9 +439,9 @@ class VolumeLayer {
GPUMaterial *gpumat);
/* Return true if the given bounds overlaps any of the contained object in this layer. */
bool bounds_overlaps(const VolumeObjectBounds &object_aabb) const;
bool bounds_overlaps(const VolumeObjectBounds &object_bounds) const;
void add_object_bound(const VolumeObjectBounds &object_aabb);
void add_object_bound(const VolumeObjectBounds &object_bounds);
void sync();
void render(View &view, Texture &occupancy_tx);
@@ -476,7 +475,7 @@ class VolumePipeline {
bool has_scatter() const
{
for (auto &layer : layers_) {
for (const auto &layer : layers_) {
if (layer->has_scatter) {
return true;
}
@@ -485,7 +484,7 @@ class VolumePipeline {
}
bool has_absorption() const
{
for (auto &layer : layers_) {
for (const auto &layer : layers_) {
if (layer->has_absorption) {
return true;
}
@@ -517,8 +516,8 @@ class DeferredProbePipeline {
void begin_sync();
void end_sync();
PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat);
void render(View &view,
Framebuffer &prepass_fb,
@@ -557,8 +556,8 @@ class PlanarProbePipeline : DeferredLayerBase {
void begin_sync();
void end_sync();
PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat);
void render(View &view,
GPUTexture *depth_layer_tx,
@@ -664,7 +663,7 @@ class UtilityTexture : public Texture {
GPU_texture_update_mipmap(*this, 0, GPU_DATA_FLOAT, data.data());
}
~UtilityTexture(){};
~UtilityTexture() = default;
};
/** \} */
@@ -691,7 +690,6 @@ class PipelineModule {
UtilityTexture utility_tx;
PipelineInfoData &data;
public:
PipelineModule(Instance &inst, PipelineInfoData &data)
: background(inst),
world(inst),

View File

@@ -12,9 +12,6 @@
* Input needs to be jittered so that the filter converges to the right result.
*/
#include "BLI_rect.h"
#include "GPU_framebuffer.hh"
#include "GPU_texture.hh"
#include "DRW_render.hh"
@@ -109,9 +106,8 @@ void RenderBuffers::acquire(int2 extent)
cryptomatte_format = GPU_RGBA32F;
}
cryptomatte_tx.acquire(
pass_extent(static_cast<eViewLayerEEVEEPassType>(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT |
EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET |
EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)),
pass_extent((EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET |
EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)),
cryptomatte_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_WRITE);
}

View File

@@ -716,7 +716,7 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut
attr_load << (!codegen.attr_load.empty() ? codegen.attr_load : "");
attr_load << "}\n\n";
std::stringstream vert_gen, frag_gen, comp_gen;
std::stringstream vert_gen, frag_gen;
if (do_vertex_attrib_load) {
vert_gen << global_vars.str() << attr_load.str();

View File

@@ -1279,12 +1279,10 @@ static inline int light_local_tilemap_count(LightData light)
if (is_spot_light(light.type)) {
return (light_spot_data_get(light).spot_tan > tanf(M_PI / 4.0)) ? 5 : 1;
}
else if (is_area_light(light.type)) {
if (is_area_light(light.type)) {
return 5;
}
else {
return 6;
}
return 6;
}
/** \} */

View File

@@ -6,13 +6,11 @@
* \ingroup eevee
*/
#include "BLI_vector.hh"
#include <algorithm>
#include "eevee_instance.hh"
#include "eevee_subsurface.hh"
#include <iostream>
namespace blender::eevee {
/* -------------------------------------------------------------------- */
@@ -167,9 +165,7 @@ float SubsurfaceModule::burley_sample(float d, float x_rand)
}
r = r - f / f_;
if (r < 0.0) {
r = 0.0;
}
r = std::max<double>(r, 0.0);
}
return r * d;

View File

@@ -9,8 +9,6 @@
#include "BKE_lib_id.hh"
#include "BKE_node.hh"
#include "BKE_node_legacy_types.hh"
#include "BKE_world.h"
#include "BLI_math_rotation.h"
#include "DEG_depsgraph_query.hh"
#include "NOD_shader.h"

View File

@@ -495,7 +495,7 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(
pass.bind_ubo("gp_materials", ubo_mat);
pass.bind_texture("gpFillTexture", tex_fill);
pass.bind_texture("gpStrokeTexture", tex_stroke);
pass.push_constant("gpMaterialOffset", int(mat_ofs));
pass.push_constant("gpMaterialOffset", mat_ofs);
/* Since we don't use the sbuffer in GPv3, this is always 0. */
pass.push_constant("gpStrokeIndexOffset", 0.0f);
pass.push_constant("viewportSize", float2(DRW_viewport_size_get()));

View File

@@ -281,7 +281,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
grp.push_constant("targetPixelOffset", float2(ob_center));
grp.push_constant("accumOffset", float2(pixel_size[0], 0.0f));
int samp_count = (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1;
grp.push_constant("sampCount", int(use_antialiasing ? samp_count : 0));
grp.push_constant("sampCount", (use_antialiasing ? samp_count : 0));
grp.draw_procedural(GPU_PRIM_TRIS, 1, 3);
}
@@ -293,7 +293,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
grp.push_constant("targetPixelSize", float2(pixsize_uniform));
grp.push_constant("accumOffset", float2(0.0f, pixel_size[1]));
int samp_count = (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1;
grp.push_constant("sampCount", int(use_antialiasing ? samp_count : 0));
grp.push_constant("sampCount", (use_antialiasing ? samp_count : 0));
grp.draw_procedural(GPU_PRIM_TRIS, 1, 3);
}
}

View File

@@ -46,7 +46,7 @@ void ScreenSpaceDrawingMode::add_depth_shgroups(::Image *image, ImageUser *image
float4x4 image_mat = float4x4::identity();
ResourceHandle handle = instance_.manager->resource_handle(image_mat);
ImageUser tile_user = {0};
ImageUser tile_user = {nullptr};
if (image_user) {
tile_user = *image_user;
}
@@ -256,7 +256,7 @@ void ScreenSpaceDrawingMode::do_full_update_gpu_texture(TextureInfo &info,
const int texture_width = GPU_texture_width(info.texture);
const int texture_height = GPU_texture_height(info.texture);
IMB_initImBuf(&texture_buffer, texture_width, texture_height, 0, IB_rectfloat);
ImageUser tile_user = {0};
ImageUser tile_user = {nullptr};
if (image_user) {
tile_user = *image_user;
}

View File

@@ -1954,12 +1954,12 @@ namespace {
*
* See the functions below.
*/
static ArmatureBoneDrawStrategyOcta strat_octa;
static ArmatureBoneDrawStrategyLine strat_line;
static ArmatureBoneDrawStrategyBBone strat_b_bone;
static ArmatureBoneDrawStrategyEnvelope strat_envelope;
static ArmatureBoneDrawStrategyWire strat_wire;
static ArmatureBoneDrawStrategyEmpty strat_empty;
ArmatureBoneDrawStrategyOcta strat_octa;
ArmatureBoneDrawStrategyLine strat_line;
ArmatureBoneDrawStrategyBBone strat_b_bone;
ArmatureBoneDrawStrategyEnvelope strat_envelope;
ArmatureBoneDrawStrategyWire strat_wire;
ArmatureBoneDrawStrategyEmpty strat_empty;
}; // namespace
/**

View File

@@ -126,11 +126,9 @@ class Armatures : Overlay {
return std::make_unique<BoneInstanceBuf>(this->selection_type_, "CustomBoneWireStrip");
});
}
else {
return *custom_shape_wire.lookup_or_add_cb(geom, [this]() {
return std::make_unique<BoneInstanceBuf>(this->selection_type_, "CustomBoneWire");
});
}
return *custom_shape_wire.lookup_or_add_cb(geom, [this]() {
return std::make_unique<BoneInstanceBuf>(this->selection_type_, "CustomBoneWire");
});
}
BoneBuffers(const SelectionType selection_type) : selection_type_(selection_type){};
@@ -624,7 +622,6 @@ class Armatures : Overlay {
}
/* Public for the time of the Overlay Next port to avoid duplicated logic. */
public:
static void draw_armature_pose(Armatures::DrawContext *ctx);
static void draw_armature_edit(Armatures::DrawContext *ctx);

View File

@@ -82,9 +82,7 @@ static void OVERLAY_next_draw_scene(void *vedata)
static void OVERLAY_next_instance_free(void *instance_)
{
Instance *instance = (Instance *)instance_;
if (instance != nullptr) {
delete instance;
}
delete instance;
}
static void OVERLAY_next_engine_free()

View File

@@ -8,7 +8,9 @@
#pragma once
#include "overlay_next_private.hh"
#include "DNA_scene_types.h"
#include "BKE_image.hh"
namespace blender::draw::overlay {

View File

@@ -8,8 +8,7 @@
#pragma once
#include "ED_lattice.hh"
#include "draw_cache.hh"
#include "draw_cache_impl.hh"
#include "draw_common_c.hh"
#include "overlay_next_base.hh"

View File

@@ -12,7 +12,6 @@
#include "BKE_customdata.hh"
#include "BKE_editmesh.hh"
#include "BKE_global.hh"
#include "BKE_mask.h"
#include "BKE_mesh_types.hh"
#include "BKE_paint.hh"
@@ -21,10 +20,10 @@
#include "DNA_brush_types.h"
#include "DNA_mask_types.h"
#include "DNA_mesh_types.h"
#include "ED_image.hh"
#include "ED_view3d.hh"
#include "GPU_capabilities.hh"
#include "draw_cache.hh"
#include "draw_cache_impl.hh"
#include "draw_manager_text.hh"
#include "overlay_next_base.hh"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "BKE_paint.hh"
#include "BLI_string.h"
#include "DEG_depsgraph_query.hh"

View File

@@ -8,12 +8,15 @@
#pragma once
#include "BKE_material.hh"
#include "BKE_pointcache.h"
#include "DEG_depsgraph_query.hh"
#include "DNA_collection_types.h"
#include "DNA_material_types.h"
#include "DNA_particle_types.h"
#include "ED_particle.hh"
#include "draw_cache.hh"
#include "overlay_next_base.hh"
namespace blender::draw::overlay {

View File

@@ -985,7 +985,7 @@ ShapeCache::ShapeCache()
{
Vector<Vertex> verts;
for (const uint3 &tri : bone_box_solid_tris) {
for (const int i : IndexRange(tri.type_length)) {
for (const int i : IndexRange(uint3::type_length)) {
const int v = tri[i];
const float x = bone_box_verts[v][2];
const float y = bone_box_verts[v][0];

View File

@@ -11,13 +11,10 @@
#include "BLT_translation.hh"
#include "DNA_ID.h"
#include "DNA_vec_types.h"
#include "DRW_engine.hh"
#include "DRW_select_buffer.hh"
#include "draw_manager.hh"
#include "draw_manager_c.hh"
#include "draw_pass.hh"
#include "select_engine.hh"

View File

@@ -10,18 +10,14 @@
#include "BKE_editmesh.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "ED_view3d.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "DRW_select_buffer.hh"
#include "draw_cache_impl.hh"
#include "select_private.hh"

View File

@@ -145,14 +145,14 @@ static void select_cache_init(void *vedata)
auto &sub = inst.depth_only_ps.sub("DepthOnly");
sub.shader_set(sh->select_id_uniform);
sub.push_constant("retopologyOffset", retopology_offset);
sub.push_constant("select_id", int(0));
sub.push_constant("select_id", 0);
inst.depth_only = &sub;
}
if (retopology_occlusion) {
auto &sub = inst.depth_only_ps.sub("Occlusion");
sub.shader_set(sh->select_id_uniform);
sub.push_constant("retopologyOffset", 0.0f);
sub.push_constant("select_id", int(0));
sub.push_constant("select_id", 0);
inst.depth_occlude = &sub;
}
@@ -169,7 +169,7 @@ static void select_cache_init(void *vedata)
else {
auto &sub = inst.select_face_ps.sub("FaceNoSelect");
sub.shader_set(sh->select_id_uniform);
sub.push_constant("select_id", int(0));
sub.push_constant("select_id", 0);
sub.push_constant("retopologyOffset", retopology_offset);
inst.select_face_uniform = &sub;
}

View File

@@ -80,9 +80,7 @@ static void SELECT_next_draw_scene(void *vedata)
static void SELECT_next_instance_free(void *instance_)
{
Instance *instance = (Instance *)instance_;
if (instance != nullptr) {
delete instance;
}
delete instance;
}
static const DrawEngineDataSize SELECT_next_data_size = DRW_VIEWPORT_DATA_SIZE(SELECT_NextData);

View File

@@ -5,6 +5,7 @@
#include "workbench_private.hh"
#include "BLI_jitter_2d.h"
#include "BLI_math_geom.h"
#include "BLI_smaa_textures.h"
namespace blender::workbench {

View File

@@ -9,6 +9,7 @@
#include "BKE_volume.hh"
#include "BKE_volume_render.hh"
#include "BLI_math_geom.h"
#include "BLI_rand.h"
#include "DNA_fluid_types.h"
#include "DNA_modifier_types.h"

View File

@@ -416,7 +416,7 @@ class StorageVectorBuffer : public StorageArrayBuffer<T, len, false> {
public:
StorageVectorBuffer(const char *name = nullptr) : StorageArrayBuffer<T, len, false>(name){};
~StorageVectorBuffer(){};
~StorageVectorBuffer() = default;
/**
* Set item count to zero but does not free memory or resize the buffer.
@@ -1032,30 +1032,22 @@ class Texture : NonCopyable {
if (h == 0) {
return GPU_texture_create_1d(name_, w, mip_len, format, usage, data);
}
else if (cubemap) {
if (cubemap) {
if (layered) {
return GPU_texture_create_cube_array(name_, w, d, mip_len, format, usage, data);
}
else {
return GPU_texture_create_cube(name_, w, mip_len, format, usage, data);
}
return GPU_texture_create_cube(name_, w, mip_len, format, usage, data);
}
else if (d == 0) {
if (d == 0) {
if (layered) {
return GPU_texture_create_1d_array(name_, w, h, mip_len, format, usage, data);
}
else {
return GPU_texture_create_2d(name_, w, h, mip_len, format, usage, data);
}
return GPU_texture_create_2d(name_, w, h, mip_len, format, usage, data);
}
else {
if (layered) {
return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, usage, data);
}
else {
return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data);
}
if (layered) {
return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, usage, data);
}
return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data);
}
};

View File

@@ -25,7 +25,6 @@
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "BKE_material.hh"
#include "BKE_object.hh"
#include "GPU_batch.hh"

View File

@@ -11,6 +11,7 @@
#include "BLI_array.hh"
#include "BLI_array_utils.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_math_geom.h"
#include "BLI_task.hh"
#include "BLI_virtual_array.hh"
@@ -191,7 +192,7 @@ static void accumululate_material_counts_mesh(
}
return count;
},
std::plus<int>());
std::plus<>());
}
else {
all_tri_counts.local().first() = poly_to_tri_count(mr.faces_num, mr.corners_num);

View File

@@ -68,9 +68,9 @@ void DRW_volume_batch_cache_dirty_tag(Volume *volume, int mode);
void DRW_volume_batch_cache_validate(Volume *volume);
void DRW_volume_batch_cache_free(Volume *volume);
void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grase_pencil, int mode);
void DRW_grease_pencil_batch_cache_validate(GreasePencil *grase_pencil);
void DRW_grease_pencil_batch_cache_free(GreasePencil *grase_pencil);
void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode);
void DRW_grease_pencil_batch_cache_validate(GreasePencil *grease_pencil);
void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil);
/** \} */

View File

@@ -30,11 +30,10 @@
#include "GPU_compute.hh"
#include "GPU_index_buffer.hh"
#include "GPU_state.hh"
#include "GPU_uniform_buffer.hh"
#include "GPU_vertex_buffer.hh"
#include "opensubdiv_capi.hh"
#include "opensubdiv_capi_type.hh"
#include "opensubdiv_converter_capi.hh"
#include "opensubdiv_evaluator_capi.hh"
#ifdef WITH_OPENSUBDIV
# include "opensubdiv_evaluator.hh"

View File

@@ -80,7 +80,9 @@
#include "draw_common_c.hh"
#include "draw_manager_c.hh"
#include "draw_manager_profiling.hh"
#include "draw_manager_testing.hh"
#ifdef WITH_GPU_DRAW_TESTS
# include "draw_manager_testing.hh"
#endif
#include "draw_manager_text.hh"
#include "draw_shader.hh"
#include "draw_subdivision.hh"
@@ -625,7 +627,7 @@ void **DRW_duplidata_get(void *vedata)
return nullptr;
}
ViewportEngineData *ved = (ViewportEngineData *)vedata;
DRWRegisteredDrawEngine *engine_type = (DRWRegisteredDrawEngine *)ved->engine_type;
DRWRegisteredDrawEngine *engine_type = ved->engine_type;
return &DST.dupli_datas[engine_type->index];
}

View File

@@ -16,6 +16,7 @@
#include "GPU_capabilities.hh"
#include "GPU_material.hh"
#include "GPU_state.hh"
#include "WM_api.hh"
@@ -69,7 +70,7 @@ static DRWShaderCompiler &compiler_data()
return compiler_data_;
}
static void *drw_deferred_shader_compilation_exec(void *)
static void *drw_deferred_shader_compilation_exec(void * /*unused*/)
{
using namespace blender;

View File

@@ -10,6 +10,7 @@
*/
#include "BLI_map.hh"
#include "BLI_math_geom.h"
#include "BLI_math_vector_types.hh"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
@@ -146,7 +147,7 @@ class DrawCacheImpl : public DrawCache {
BitVector<> dirty_topology_;
public:
virtual ~DrawCacheImpl() override;
~DrawCacheImpl() override;
void tag_positions_changed(const IndexMask &node_mask) override;
void tag_visibility_changed(const IndexMask &node_mask) override;

View File

@@ -13,10 +13,13 @@
#include "GPU_compute.hh"
#include "GPU_debug.hh"
#include "draw_debug.hh"
#include "draw_shader.hh"
#include "draw_view.hh"
#ifdef _DEBUG
# include "draw_debug.hh"
#endif
namespace blender::draw {
std::atomic<uint32_t> View::global_sync_counter_ = 1;

View File

@@ -20,6 +20,7 @@
#include "GPU_immediate.hh"
#include "GPU_matrix.hh"
#include "GPU_shader.hh"
#include "GPU_state.hh"
#include "UI_resources.hh"
#include "UI_view2d.hh"

View File

@@ -277,7 +277,7 @@ ViewportEngineData *DRW_view_data_enabled_engine_iter_step(DRWEngineIterator *it
draw::Manager *DRW_manager_get()
{
BLI_assert(DST.view_data_active->manager);
return reinterpret_cast<draw::Manager *>(DST.view_data_active->manager);
return DST.view_data_active->manager;
}
draw::ObjectRef DRW_object_ref_get(Object *object)
@@ -291,7 +291,7 @@ void DRW_manager_begin_sync()
if (DST.view_data_active->manager == nullptr) {
return;
}
reinterpret_cast<draw::Manager *>(DST.view_data_active->manager)->begin_sync();
DST.view_data_active->manager->begin_sync();
}
void DRW_manager_end_sync()
@@ -299,5 +299,5 @@ void DRW_manager_end_sync()
if (DST.view_data_active->manager == nullptr) {
return;
}
reinterpret_cast<draw::Manager *>(DST.view_data_active->manager)->end_sync();
DST.view_data_active->manager->end_sync();
}

View File

@@ -279,12 +279,10 @@ PassType *volume_sub_pass_implementation(PassType &ps,
if (ob == nullptr) {
return volume_world_grids_init(ps, attrs);
}
else if (ob->type == OB_VOLUME) {
if (ob->type == OB_VOLUME) {
return volume_object_grids_init(ps, ob, attrs);
}
else {
return drw_volume_object_mesh_init(ps, scene, ob, attrs);
}
return drw_volume_object_mesh_init(ps, scene, ob, attrs);
}
PassMain::Sub *volume_sub_pass(PassMain::Sub &ps,

View File

@@ -8,6 +8,8 @@
#include "BKE_editmesh.hh"
#include "BLI_math_geom.h"
#include "GPU_index_buffer.hh"
#include "extract_mesh.hh"

View File

@@ -118,7 +118,7 @@ static void extract_edge_factor_bm(const MeshRenderData &mr, MutableSpan<T> vbo_
BMesh &bm = *mr.bm;
threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
for (const int face_index : range) {
const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
const BMFace &face = *BM_face_at_index(&bm, face_index);
const BMLoop *loop = BM_FACE_FIRST_LOOP(&face);
for ([[maybe_unused]] const int i : IndexRange(face.len)) {
const int index = BM_elem_index_get(loop);

View File

@@ -6,6 +6,7 @@
* \ingroup draw
*/
#include "BLI_math_geom.h"
#include "BLI_math_vector_types.hh"
#include "BKE_attribute.hh"

View File

@@ -6,10 +6,13 @@
* \ingroup draw
*/
#include <algorithm>
#include "MEM_guardedalloc.h"
#include "BLI_jitter_2d.h"
#include "BLI_map.hh"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_ordered_edge.hh"
@@ -176,9 +179,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, MutableSpan<float>
angle_fac = angle_fac * angle_fac * angle_fac;
angle_fac = 1.0f - angle_fac;
dist /= angle_fac;
if (dist < face_dists[index]) {
face_dists[index] = dist;
}
face_dists[index] = std::min(dist, face_dists[index]);
}
}
}
@@ -230,9 +231,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, MutableSpan<float>
angle_fac = angle_fac * angle_fac * angle_fac;
angle_fac = 1.0f - angle_fac;
hit.dist /= angle_fac;
if (hit.dist < face_dists[index]) {
face_dists[index] = hit.dist;
}
face_dists[index] = std::min(hit.dist, face_dists[index]);
}
}
}

View File

@@ -4,6 +4,7 @@
#include "testing/testing.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.hh"
#include "draw_cache.hh"

View File

@@ -4,20 +4,9 @@
#include "testing/testing.h"
#include "BKE_context.hh"
#include "BKE_idtype.hh"
#include "BKE_main.hh"
#include "BKE_node.hh"
#include "BKE_object.hh"
#include "BLI_vector.hh"
#include "RNA_define.hh"
#include "GPU_batch.hh"
#include "draw_shader.hh"
#include "draw_testing.hh"
#include "engines/eevee_next/eevee_instance.hh"
#include "engines/eevee_next/eevee_precompute.hh"
namespace blender::draw {
@@ -343,7 +332,7 @@ static void test_eevee_shadow_tag_update()
const uint lod5_len = SHADOW_TILEMAP_LOD5_LEN;
auto stringify_result = [&](uint start, uint len) -> std::string {
std::string result = "";
std::string result;
for (auto i : IndexRange(start, len)) {
result += (shadow_tile_unpack(tiles_data[i]).do_update) ? "x" : "-";
}
@@ -590,7 +579,7 @@ class TestDefrag {
pages_cached_data.read();
pages_infos_data.read();
std::string result = "";
std::string result;
int expect_cached_len = 0;
for (auto i : IndexRange(descriptor_offset, descriptor.size())) {
if (pages_cached_data[i % SHADOW_MAX_PAGE].y != -1) {
@@ -917,7 +906,7 @@ static void test_eevee_shadow_finalize()
{
uint *pixels = tilemap_tx.read<uint32_t>(GPU_DATA_UINT);
std::string result = "";
std::string result;
for (auto y : IndexRange(SHADOW_TILEMAP_RES)) {
for (auto x : IndexRange(SHADOW_TILEMAP_RES)) {
ShadowTileData tile = shadow_tile_unpack(pixels[y * SHADOW_TILEMAP_RES + x]);
@@ -967,7 +956,7 @@ static void test_eevee_shadow_finalize()
{
auto stringify_view = [](Span<uint> data) -> std::string {
std::string result = "";
std::string result;
for (auto x : data) {
result += (x == 0u) ? '-' : ((x == 0xFFFFFFFFu) ? 'x' : '0' + (x % 10));
}
@@ -1296,7 +1285,7 @@ static void test_eevee_shadow_tilemap_amend()
uint *pixels = tilemap_tx.read<uint32_t>(GPU_DATA_UINT);
auto stringify_tilemap = [&](int tilemap_index) -> std::string {
std::string result = "";
std::string result;
for (auto y : IndexRange(SHADOW_TILEMAP_RES)) {
for (auto x : IndexRange(SHADOW_TILEMAP_RES)) {
/* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */
@@ -1317,7 +1306,7 @@ static void test_eevee_shadow_tilemap_amend()
};
auto stringify_lod = [&](int tilemap_index) -> std::string {
std::string result = "";
std::string result;
for (auto y : IndexRange(SHADOW_TILEMAP_RES)) {
for (auto x : IndexRange(SHADOW_TILEMAP_RES)) {
/* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */
@@ -1338,7 +1327,7 @@ static void test_eevee_shadow_tilemap_amend()
};
auto stringify_offset = [&](int tilemap_index) -> std::string {
std::string result = "";
std::string result;
for (auto y : IndexRange(SHADOW_TILEMAP_RES)) {
for (auto x : IndexRange(SHADOW_TILEMAP_RES)) {
/* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */
@@ -1747,7 +1736,7 @@ static void test_eevee_shadow_page_mask_ex(int max_view_per_tilemap)
StringRefNull expected_lod5 = "-";
auto stringify_result = [&](uint start, uint len) -> std::string {
std::string result = "";
std::string result;
for (auto i : IndexRange(start, len)) {
result += (shadow_tile_unpack(tiles_data[i]).is_used) ? "x" : "-";
}
@@ -1755,7 +1744,7 @@ static void test_eevee_shadow_page_mask_ex(int max_view_per_tilemap)
};
auto empty_result = [&](uint len) -> std::string {
std::string result = "";
std::string result;
for ([[maybe_unused]] const int i : IndexRange(len)) {
result += "-";
}