Refactor: Cycles: Add const keyword to more function parameters

Pull Request: https://projects.blender.org/blender/blender/pulls/132361
This commit is contained in:
Brecht Van Lommel
2025-01-01 18:15:54 +01:00
parent dd51c8660b
commit 57ff24cb99
389 changed files with 3464 additions and 2900 deletions
+35 -15
View File
@@ -17,7 +17,7 @@
CCL_NAMESPACE_BEGIN
static float precompute_ggx_E(float rough, float mu, float3 rand)
static float precompute_ggx_E(const float rough, const float mu, const float3 rand)
{
KernelGlobalsCPU kg;
@@ -52,7 +52,10 @@ static float precompute_ggx_E(float rough, float mu, float3 rand)
return 0.0f;
}
static float precompute_ggx_glass_E(float rough, float mu, float eta, float3 rand)
static float precompute_ggx_glass_E(const float rough,
const float mu,
const float eta,
const float3 rand)
{
KernelGlobalsCPU kg;
@@ -88,7 +91,7 @@ static float precompute_ggx_glass_E(float rough, float mu, float eta, float3 ran
}
static float precompute_ggx_gen_schlick_s(
float rough, float mu, float eta, float exponent, float3 rand)
const float rough, const float mu, const float eta, const float exponent, const float3 rand)
{
KernelGlobalsCPU kg;
@@ -135,7 +138,7 @@ static float precompute_ggx_gen_schlick_s(
return 0.0f;
}
inline float ior_parametrization(float z)
inline float ior_parametrization(const float z)
{
/* This parametrization ensures that the entire [1..inf] range of IORs is covered
* and that most precision is allocated to the common areas (1-2). */
@@ -152,39 +155,48 @@ static bool cycles_precompute(std::string name)
{
std::map<string, PrecomputeTerm> precompute_terms;
/* Overall albedo of the GGX microfacet BRDF, depending on cosI and roughness. */
precompute_terms["ggx_E"] = {1 << 23, 32, 32, 1, [](float rough, float mu, float, float3 rand) {
return precompute_ggx_E(rough, mu, rand);
}};
precompute_terms["ggx_E"] = {
1 << 23, 32, 32, 1, [](const float rough, const float mu, float, const float3 rand) {
return precompute_ggx_E(rough, mu, rand);
}};
/* Overall albedo of the GGX microfacet BRDF, averaged over cosI */
precompute_terms["ggx_Eavg"] = {
1 << 26, 32, 1, 1, [](float rough, float mu, float, float3 rand) {
1 << 26, 32, 1, 1, [](const float rough, const float mu, float, const float3 rand) {
return 2.0f * mu * precompute_ggx_E(rough, mu, rand);
}};
/* Overall albedo of the GGX microfacet BSDF with dielectric Fresnel,
* depending on cosI and roughness, for IOR>1. */
precompute_terms["ggx_glass_E"] = {
1 << 23, 16, 16, 16, [](float rough, float mu, float z, float3 rand) {
1 << 23,
16,
16,
16,
[](const float rough, const float mu, const float z, const float3 rand) {
const float ior = ior_parametrization(z);
return precompute_ggx_glass_E(rough, mu, ior, rand);
}};
/* Overall albedo of the GGX microfacet BSDF with dielectric Fresnel,
* averaged over cosI, for IOR>1. */
precompute_terms["ggx_glass_Eavg"] = {
1 << 26, 16, 1, 16, [](float rough, float mu, float z, float3 rand) {
1 << 26, 16, 1, 16, [](const float rough, const float mu, const float z, const float3 rand) {
const float ior = ior_parametrization(z);
return 2.0f * mu * precompute_ggx_glass_E(rough, mu, ior, rand);
}};
/* Overall albedo of the GGX microfacet BSDF with dielectric Fresnel,
* depending on cosI and roughness, for IOR<1. */
precompute_terms["ggx_glass_inv_E"] = {
1 << 23, 16, 16, 16, [](float rough, float mu, float z, float3 rand) {
1 << 23,
16,
16,
16,
[](const float rough, const float mu, const float z, const float3 rand) {
const float ior = ior_parametrization(z);
return precompute_ggx_glass_E(rough, mu, 1.0f / ior, rand);
}};
/* Overall albedo of the GGX microfacet BSDF with dielectric Fresnel,
* averaged over cosI, for IOR<1. */
precompute_terms["ggx_glass_inv_Eavg"] = {
1 << 26, 16, 1, 16, [](float rough, float mu, float z, float3 rand) {
1 << 26, 16, 1, 16, [](const float rough, const float mu, const float z, const float3 rand) {
const float ior = ior_parametrization(z);
return 2.0f * mu * precompute_ggx_glass_E(rough, mu, 1.0f / ior, rand);
}};
@@ -192,7 +204,11 @@ static bool cycles_precompute(std::string name)
/* Interpolation factor between F0 and F90 for the generalized Schlick Fresnel,
* depending on cosI and roughness, for IOR>1, using dielectric Fresnel mode. */
precompute_terms["ggx_gen_schlick_ior_s"] = {
1 << 20, 16, 16, 16, [](float rough, float mu, float z, float3 rand) {
1 << 20,
16,
16,
16,
[](const float rough, const float mu, const float z, const float3 rand) {
const float ior = ior_parametrization(z);
return precompute_ggx_gen_schlick_s(rough, mu, ior, -1.0f, rand);
}};
@@ -200,7 +216,11 @@ static bool cycles_precompute(std::string name)
/* Interpolation factor between F0 and F90 for the generalized Schlick Fresnel,
* depending on cosI and roughness, for IOR>1. */
precompute_terms["ggx_gen_schlick_s"] = {
1 << 20, 16, 16, 16, [](float rough, float mu, float z, float3 rand) {
1 << 20,
16,
16,
16,
[](const float rough, const float mu, const float z, const float3 rand) {
/* Remap 0..1 to 0..inf, with 0.5 mapping to 5 (the default value). */
const float exponent = 5.0f * ((1.0f - z) / z);
return precompute_ggx_gen_schlick_s(rough, mu, 1.0f, exponent, rand);
@@ -273,7 +293,7 @@ static bool cycles_precompute(std::string name)
CCL_NAMESPACE_END
int main(int argc, const char **argv)
int main(const int argc, const char **argv)
{
if (argc < 2) {
return 1;
+5 -5
View File
@@ -232,7 +232,7 @@ static void display()
display_info(options.session->progress);
}
static void motion(int x, int y, int button)
static void motion(const int x, const int y, int button)
{
if (options.interactive) {
Transform matrix = options.session->scene->camera->get_matrix();
@@ -261,7 +261,7 @@ static void motion(int x, int y, int button)
}
}
static void resize(int width, int height)
static void resize(const int width, const int height)
{
options.width = width;
options.height = height;
@@ -362,7 +362,7 @@ static void keyboard(unsigned char key)
}
#endif
static int files_parse(int argc, const char *argv[])
static int files_parse(const int argc, const char *argv[])
{
if (argc > 0) {
options.filepath = argv[0];
@@ -371,7 +371,7 @@ static int files_parse(int argc, const char *argv[])
return 0;
}
static void options_parse(int argc, const char **argv)
static void options_parse(const int argc, const char **argv)
{
options.width = 1024;
options.height = 512;
@@ -556,7 +556,7 @@ CCL_NAMESPACE_END
using namespace ccl;
int main(int argc, const char **argv)
int main(const int argc, const char **argv)
{
util_logging_init(argv[0]);
path_init();
+20 -20
View File
@@ -50,7 +50,7 @@ struct XMLReadState : public XMLReader {
/* Attribute Reading */
static bool xml_read_int(int *value, xml_node node, const char *name)
static bool xml_read_int(int *value, const xml_node node, const char *name)
{
const xml_attribute attr = node.attribute(name);
@@ -62,7 +62,7 @@ static bool xml_read_int(int *value, xml_node node, const char *name)
return false;
}
static bool xml_read_int_array(vector<int> &value, xml_node node, const char *name)
static bool xml_read_int_array(vector<int> &value, const xml_node node, const char *name)
{
const xml_attribute attr = node.attribute(name);
@@ -80,7 +80,7 @@ static bool xml_read_int_array(vector<int> &value, xml_node node, const char *na
return false;
}
static bool xml_read_float(float *value, xml_node node, const char *name)
static bool xml_read_float(float *value, const xml_node node, const char *name)
{
const xml_attribute attr = node.attribute(name);
@@ -92,7 +92,7 @@ static bool xml_read_float(float *value, xml_node node, const char *name)
return false;
}
static bool xml_read_float_array(vector<float> &value, xml_node node, const char *name)
static bool xml_read_float_array(vector<float> &value, const xml_node node, const char *name)
{
const xml_attribute attr = node.attribute(name);
@@ -110,7 +110,7 @@ static bool xml_read_float_array(vector<float> &value, xml_node node, const char
return false;
}
static bool xml_read_float3(float3 *value, xml_node node, const char *name)
static bool xml_read_float3(float3 *value, const xml_node node, const char *name)
{
vector<float> array;
@@ -122,7 +122,7 @@ static bool xml_read_float3(float3 *value, xml_node node, const char *name)
return false;
}
static bool xml_read_float3_array(vector<float3> &value, xml_node node, const char *name)
static bool xml_read_float3_array(vector<float3> &value, const xml_node node, const char *name)
{
vector<float> array;
@@ -137,7 +137,7 @@ static bool xml_read_float3_array(vector<float3> &value, xml_node node, const ch
return false;
}
static bool xml_read_float4(float4 *value, xml_node node, const char *name)
static bool xml_read_float4(float4 *value, const xml_node node, const char *name)
{
vector<float> array;
@@ -149,7 +149,7 @@ static bool xml_read_float4(float4 *value, xml_node node, const char *name)
return false;
}
static bool xml_read_string(string *str, xml_node node, const char *name)
static bool xml_read_string(string *str, const xml_node node, const char *name)
{
const xml_attribute attr = node.attribute(name);
@@ -161,7 +161,7 @@ static bool xml_read_string(string *str, xml_node node, const char *name)
return false;
}
static bool xml_equal_string(xml_node node, const char *name, const char *value)
static bool xml_equal_string(const xml_node node, const char *name, const char *value)
{
const xml_attribute attr = node.attribute(name);
@@ -174,7 +174,7 @@ static bool xml_equal_string(xml_node node, const char *name, const char *value)
/* Camera */
static void xml_read_camera(XMLReadState &state, xml_node node)
static void xml_read_camera(XMLReadState &state, const xml_node node)
{
Camera *cam = state.scene->camera;
@@ -197,7 +197,7 @@ static void xml_read_camera(XMLReadState &state, xml_node node)
/* Alembic */
#ifdef WITH_ALEMBIC
static void xml_read_alembic(XMLReadState &state, xml_node graph_node)
static void xml_read_alembic(XMLReadState &state, const xml_node graph_node)
{
AlembicProcedural *proc = state.scene->create_node<AlembicProcedural>();
xml_read_node(state, proc, graph_node);
@@ -220,7 +220,7 @@ static void xml_read_alembic(XMLReadState &state, xml_node graph_node)
/* Shader */
static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml_node graph_node)
{
xml_read_node(state, shader, graph_node);
@@ -384,7 +384,7 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node
shader->tag_update(state.scene);
}
static void xml_read_shader(XMLReadState &state, xml_node node)
static void xml_read_shader(XMLReadState &state, const xml_node node)
{
Shader *shader = new Shader();
xml_read_shader_graph(state, shader, node);
@@ -393,7 +393,7 @@ static void xml_read_shader(XMLReadState &state, xml_node node)
/* Background */
static void xml_read_background(XMLReadState &state, xml_node node)
static void xml_read_background(XMLReadState &state, const xml_node node)
{
/* Background Settings */
xml_read_node(state, state.scene->background, node);
@@ -427,7 +427,7 @@ static Mesh *xml_add_mesh(Scene *scene, const Transform &tfm, Object *object)
return mesh;
}
static void xml_read_mesh(const XMLReadState &state, xml_node node)
static void xml_read_mesh(const XMLReadState &state, const xml_node node)
{
/* add mesh */
Mesh *mesh = xml_add_mesh(state.scene, state.tfm, state.object);
@@ -647,7 +647,7 @@ static void xml_read_mesh(const XMLReadState &state, xml_node node)
/* Light */
static void xml_read_light(XMLReadState &state, xml_node node)
static void xml_read_light(XMLReadState &state, const xml_node node)
{
Light *light = new Light();
@@ -659,7 +659,7 @@ static void xml_read_light(XMLReadState &state, xml_node node)
/* Transform */
static void xml_read_transform(xml_node node, Transform &tfm)
static void xml_read_transform(const xml_node node, Transform &tfm)
{
if (node.attribute("matrix")) {
vector<float> matrix;
@@ -690,7 +690,7 @@ static void xml_read_transform(xml_node node, Transform &tfm)
/* State */
static void xml_read_state(XMLReadState &state, xml_node node)
static void xml_read_state(XMLReadState &state, const xml_node node)
{
/* Read shader */
string shadername;
@@ -743,7 +743,7 @@ static void xml_read_state(XMLReadState &state, xml_node node)
/* Object */
static void xml_read_object(XMLReadState &state, xml_node node)
static void xml_read_object(XMLReadState &state, const xml_node node)
{
Scene *scene = state.scene;
@@ -765,7 +765,7 @@ static void xml_read_object(XMLReadState &state, xml_node node)
static void xml_read_include(XMLReadState &state, const string &src);
static void xml_read_scene(XMLReadState &state, xml_node scene_node)
static void xml_read_scene(XMLReadState &state, const xml_node scene_node)
{
for (xml_node node = scene_node.first_child(); node; node = node.next_sibling()) {
if (string_iequals(node.name(), "film")) {
+3 -1
View File
@@ -33,7 +33,9 @@ void OpenGLDisplayDriver::next_tile_begin()
/* Assuming no tiles used in interactive display. */
}
bool OpenGLDisplayDriver::update_begin(const Params &params, int texture_width, int texture_height)
bool OpenGLDisplayDriver::update_begin(const Params &params,
const int texture_width,
const int texture_height)
{
/* Note that it's the responsibility of OpenGLDisplayDriver to ensure updating and drawing
* the texture does not happen at the same time. This is achieved indirectly.
+4 -2
View File
@@ -26,12 +26,14 @@ class OpenGLDisplayDriver : public DisplayDriver {
void clear() override;
void set_zoom(float zoom_x, float zoom_y);
void set_zoom(const float zoom_x, const float zoom_y);
protected:
void next_tile_begin() override;
bool update_begin(const Params &params, int texture_width, int texture_height) override;
bool update_begin(const Params &params,
const int texture_width,
const int texture_height) override;
void update_end() override;
half4 *map_texture_buffer() override;
+1 -1
View File
@@ -137,7 +137,7 @@ int OpenGLShader::get_tex_coord_attrib_location()
return tex_coord_attribute_location_;
}
void OpenGLShader::bind(int width, int height)
void OpenGLShader::bind(const int width, const int height)
{
create_shader_if_needed();
+1 -1
View File
@@ -21,7 +21,7 @@ class OpenGLShader {
int get_position_attrib_location();
int get_tex_coord_attrib_location();
void bind(int width, int height);
void bind(const int width, const int height);
void unbind();
protected:
+5 -5
View File
@@ -181,7 +181,7 @@ static void window_display()
window_opengl_context_disable();
}
static void window_reshape(int width, int height)
static void window_reshape(const int width, const int height)
{
if (V.width != width || V.height != height) {
if (V.resize) {
@@ -209,7 +209,7 @@ static bool window_keyboard(unsigned char key)
return false;
}
static void window_mouse(int button, int state, int x, int y)
static void window_mouse(const int button, const int state, const int x, int y)
{
if (button == SDL_BUTTON_LEFT) {
if (state == SDL_MOUSEBUTTONDOWN) {
@@ -233,7 +233,7 @@ static void window_mouse(int button, int state, int x, int y)
}
}
static void window_motion(int x, int y)
static void window_motion(const int x, const int y)
{
const int but = V.mouseBut0 ? 0 : 2;
const int distX = x - V.mouseX;
@@ -261,8 +261,8 @@ void window_opengl_context_disable()
}
void window_main_loop(const char *title,
int width,
int height,
const int width,
const int height,
WindowInitFunc initf,
WindowExitFunc exitf,
WindowResizeFunc resize,
+2 -2
View File
@@ -17,8 +17,8 @@ using WindowKeyboardFunc = void (*)(unsigned char);
using WindowMotionFunc = void (*)(int, int, int);
void window_main_loop(const char *title,
int width,
int height,
const int width,
const int height,
WindowInitFunc initf,
WindowExitFunc exitf,
WindowResizeFunc resize,
+1 -1
View File
@@ -14,7 +14,7 @@ void *CCL_python_module_init(void);
void CCL_init_logging(const char *argv0);
void CCL_start_debug_logging(void);
void CCL_logging_verbosity_set(int verbosity);
void CCL_logging_verbosity_set(const int verbosity);
#ifdef __cplusplus
}
+28 -22
View File
@@ -310,8 +310,8 @@ static Transform blender_camera_matrix(const Transform &tfm,
}
static void blender_camera_viewplane(BlenderCamera *bcam,
int width,
int height,
const int width,
const int height,
BoundBox2D *viewplane,
float *aspectratio,
float *sensor_size)
@@ -412,8 +412,8 @@ static void blender_camera_viewplane(BlenderCamera *bcam,
static void blender_camera_sync(Camera *cam,
BlenderCamera *bcam,
int width,
int height,
const int width,
const int height,
const char *viewname,
PointerRNA *cscene)
{
@@ -577,8 +577,8 @@ static MotionPosition blender_motion_blur_position_type_to_cycles(
void BlenderSync::sync_camera(BL::RenderSettings &b_render,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
const char *viewname)
{
BlenderCamera bcam(b_render);
@@ -647,8 +647,11 @@ void BlenderSync::sync_camera(BL::RenderSettings &b_render,
}
}
void BlenderSync::sync_camera_motion(
BL::RenderSettings &b_render, BL::Object &b_ob, int width, int height, float motion_time)
void BlenderSync::sync_camera_motion(BL::RenderSettings &b_render,
BL::Object &b_ob,
const int width,
const int height,
const float motion_time)
{
if (!b_ob) {
return;
@@ -711,8 +714,8 @@ static void blender_camera_view_subset(BL::RenderEngine &b_engine,
BL::Object &b_ob,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height,
const int width,
const int height,
BoundBox2D *view_box,
BoundBox2D *cam_box,
float *view_aspect);
@@ -722,8 +725,8 @@ static void blender_camera_from_view(BlenderCamera *bcam,
BL::Scene &b_scene,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height,
const int width,
const int height,
bool skip_panorama = false)
{
/* 3d view parameters */
@@ -809,8 +812,8 @@ static void blender_camera_view_subset(BL::RenderEngine &b_engine,
BL::Object &b_ob,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height,
const int width,
const int height,
BoundBox2D *view_box,
BoundBox2D *cam_box,
float *view_aspect)
@@ -848,8 +851,8 @@ static void blender_camera_border_subset(BL::RenderEngine &b_engine,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
BL::Object &b_ob,
int width,
int height,
const int width,
const int height,
const BoundBox2D &border,
BoundBox2D *result)
{
@@ -880,8 +883,8 @@ static void blender_camera_border(BlenderCamera *bcam,
BL::Scene &b_scene,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height)
const int width,
const int height)
{
bool is_camera_view;
@@ -950,8 +953,8 @@ static void blender_camera_border(BlenderCamera *bcam,
void BlenderSync::sync_view(BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height)
const int width,
const int height)
{
BL::RenderSettings b_render_settings(b_scene.render());
BlenderCamera bcam(b_render_settings);
@@ -975,8 +978,11 @@ void BlenderSync::sync_view(BL::SpaceView3D &b_v3d,
}
}
BufferParams BlenderSync::get_buffer_params(
BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height)
BufferParams BlenderSync::get_buffer_params(BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
Camera *cam,
const int width,
const int height)
{
BufferParams params;
bool use_border = false;
+18 -12
View File
@@ -29,7 +29,7 @@ ParticleCurveData::ParticleCurveData() = default;
ParticleCurveData::~ParticleCurveData() = default;
static float shaperadius(float shape, float root, float tip, float time)
static float shaperadius(const float shape, const float root, const float tip, const float time)
{
assert(time >= 0.0f);
assert(time <= 1.0f);
@@ -155,7 +155,7 @@ static bool ObtainCacheParticleUV(Hair *hair,
BL::Object *b_ob,
ParticleCurveData *CData,
bool background,
int uv_num)
const int uv_num)
{
if (!(hair && b_mesh && b_ob && CData)) {
return false;
@@ -225,7 +225,7 @@ static bool ObtainCacheParticleVcol(Hair *hair,
BL::Object *b_ob,
ParticleCurveData *CData,
bool background,
int vcol_num)
const int vcol_num)
{
if (!(hair && b_mesh && b_ob && CData)) {
return false;
@@ -391,7 +391,10 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa
}
}
static float4 CurveSegmentMotionCV(ParticleCurveData *CData, int sys, int curve, int curvekey)
static float4 CurveSegmentMotionCV(ParticleCurveData *CData,
const int sys,
const int curve,
const int curvekey)
{
const float3 ickey_loc = CData->curvekey_co[curvekey];
const float curve_time = CData->curvekey_time[curvekey];
@@ -412,7 +415,10 @@ static float4 CurveSegmentMotionCV(ParticleCurveData *CData, int sys, int curve,
return mP;
}
static float4 LerpCurveSegmentMotionCV(ParticleCurveData *CData, int sys, int curve, float step)
static float4 LerpCurveSegmentMotionCV(ParticleCurveData *CData,
const int sys,
const int curve,
const float step)
{
assert(step >= 0.0f);
assert(step <= 1.0f);
@@ -434,8 +440,8 @@ static float4 LerpCurveSegmentMotionCV(ParticleCurveData *CData, int sys, int cu
}
static void export_hair_motion_validate_attribute(Hair *hair,
int motion_step,
int num_motion_keys,
const int motion_step,
const int num_motion_keys,
bool have_motion)
{
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -462,7 +468,7 @@ static void export_hair_motion_validate_attribute(Hair *hair,
}
}
static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int motion_step)
static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, const int motion_step)
{
/* find attribute */
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -562,7 +568,7 @@ bool BlenderSync::object_has_particle_hair(BL::Object b_ob)
/* Old particle hair. */
void BlenderSync::sync_particle_hair(
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, int motion_step)
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, const int motion_step)
{
if (!b_ob_info.is_real_object_data()) {
return;
@@ -932,7 +938,7 @@ static void export_hair_curves(Scene *scene,
static void export_hair_curves_motion(Hair *hair,
const blender::bke::CurvesGeometry &b_curves,
int motion_step)
const int motion_step)
{
/* Find or add attribute. */
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -1005,7 +1011,7 @@ static void export_hair_curves_motion(Hair *hair,
}
/* Hair object. */
void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step)
void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, const int motion_step)
{
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
const bool need_motion = object_need_motion_attribute(b_ob_info, scene);
@@ -1078,7 +1084,7 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H
void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
BObjectInfo &b_ob_info,
Hair *hair,
int motion_step)
const int motion_step)
{
/* Skip if nothing exported. */
if (hair->num_keys() == 0) {
+6 -6
View File
@@ -62,7 +62,7 @@ static GPUShader *compile_fallback_shader()
return shader;
}
GPUShader *BlenderFallbackDisplayShader::bind(int width, int height)
GPUShader *BlenderFallbackDisplayShader::bind(const int width, const int height)
{
create_shader_if_needed();
@@ -474,8 +474,8 @@ void BlenderDisplayDriver::next_tile_begin()
}
bool BlenderDisplayDriver::update_begin(const Params &params,
int texture_width,
int texture_height)
const int texture_width,
const int texture_height)
{
/* Note that it's the responsibility of BlenderDisplayDriver to ensure updating and drawing
* the texture does not happen at the same time. This is achieved indirectly.
@@ -645,7 +645,7 @@ void BlenderDisplayDriver::clear()
need_clear_ = true;
}
void BlenderDisplayDriver::set_zoom(float zoom_x, float zoom_y)
void BlenderDisplayDriver::set_zoom(const float zoom_x, const float zoom_y)
{
zoom_ = make_float2(zoom_x, zoom_y);
}
@@ -655,8 +655,8 @@ void BlenderDisplayDriver::set_zoom(float zoom_x, float zoom_y)
*
* NOTE: The buffer needs to be bound. */
static void vertex_draw(const DisplayDriver::Params &params,
int texcoord_attribute,
int position_attribute)
const int texcoord_attribute,
const int position_attribute)
{
const int x = params.full_offset.x;
const int y = params.full_offset.y;
+7 -5
View File
@@ -30,7 +30,7 @@ class BlenderDisplayShader {
BlenderDisplayShader() = default;
virtual ~BlenderDisplayShader() = default;
virtual GPUShader *bind(int width, int height) = 0;
virtual GPUShader *bind(const int width, const int height) = 0;
virtual void unbind() = 0;
/* Get attribute location for position and texture coordinate respectively.
@@ -52,7 +52,7 @@ class BlenderDisplayShader {
* display space shader. */
class BlenderFallbackDisplayShader : public BlenderDisplayShader {
public:
GPUShader *bind(int width, int height) override;
GPUShader *bind(const int width, const int height) override;
void unbind() override;
protected:
@@ -74,7 +74,7 @@ class BlenderDisplaySpaceShader : public BlenderDisplayShader {
public:
BlenderDisplaySpaceShader(BL::RenderEngine &b_engine, BL::Scene &b_scene);
GPUShader *bind(int width, int height) override;
GPUShader *bind(const int width, const int height) override;
void unbind() override;
protected:
@@ -98,12 +98,14 @@ class BlenderDisplayDriver : public DisplayDriver {
void clear() override;
void set_zoom(float zoom_x, float zoom_y);
void set_zoom(const float zoom_x, const float zoom_y);
protected:
void next_tile_begin() override;
bool update_begin(const Params &params, int texture_width, int texture_height) override;
bool update_begin(const Params &params,
const int texture_width,
const int texture_height) override;
void update_end() override;
half4 *map_texture_buffer() override;
+1 -1
View File
@@ -188,7 +188,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
BObjectInfo &b_ob_info,
Object *object,
float motion_time,
const float motion_time,
bool use_particle_hair,
TaskPool *task_pool)
{
+1 -1
View File
@@ -15,7 +15,7 @@ CCL_NAMESPACE_BEGIN
void BlenderSync::sync_light(BL::Object &b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BObjectInfo &b_ob_info,
int random_id,
const int random_id,
Transform &tfm,
bool *use_portal)
{
+1 -1
View File
@@ -15,7 +15,7 @@ void CCL_start_debug_logging()
ccl::util_logging_start();
}
void CCL_logging_verbosity_set(int verbosity)
void CCL_logging_verbosity_set(const int verbosity)
{
ccl::util_logging_verbosity_set(verbosity);
}
+3 -3
View File
@@ -1049,8 +1049,8 @@ static void create_subd_mesh(Scene *scene,
const array<Node *> &used_shaders,
const bool need_motion,
const float motion_scale,
float dicing_rate,
int max_subdivisions)
const float dicing_rate,
const int max_subdivisions)
{
BL::Object b_ob = b_ob_info.real_object;
@@ -1192,7 +1192,7 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, M
void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
BObjectInfo &b_ob_info,
Mesh *mesh,
int motion_step)
const int motion_step)
{
/* Skip if no vertices were exported. */
const size_t numverts = mesh->get_verts().size();
+4 -4
View File
@@ -154,7 +154,7 @@ void BlenderSync::sync_object_motion_init(BL::Object &b_parent, BL::Object &b_ob
Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
BL::ViewLayer &b_view_layer,
BL::DepsgraphObjectInstance &b_instance,
float motion_time,
const float motion_time,
bool use_particle_hair,
bool show_lights,
BlenderObjectCulling &culling,
@@ -540,7 +540,7 @@ void BlenderSync::sync_procedural(BL::Object &b_ob,
void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
float motion_time)
const float motion_time)
{
/* Task pool for multithreaded geometry sync. */
TaskPool geom_task_pool;
@@ -671,8 +671,8 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
void **python_thread_state)
{
if (scene->need_motion() == Scene::MOTION_NONE) {
+2 -2
View File
@@ -79,7 +79,7 @@ bool BlenderObjectCulling::test(Scene *scene, BL::Object &b_ob, Transform &tfm)
/* TODO(sergey): Not really optimal, consider approaches based on k-DOP in order
* to reduce number of objects which are wrongly considered visible.
*/
bool BlenderObjectCulling::test_camera(Scene *scene, float3 bb[8])
bool BlenderObjectCulling::test_camera(Scene *scene, const float3 bb[8])
{
Camera *cam = scene->camera;
const ProjectionTransform &worldtondc = cam->worldtondc;
@@ -109,7 +109,7 @@ bool BlenderObjectCulling::test_camera(Scene *scene, float3 bb[8])
bb_max.x <= -camera_cull_margin_ || bb_max.y <= -camera_cull_margin_);
}
bool BlenderObjectCulling::test_distance(Scene *scene, float3 bb[8])
bool BlenderObjectCulling::test_distance(Scene *scene, const float3 bb[8])
{
const float3 camera_position = transform_get_column(&scene->camera->get_matrix(), 3);
float3 bb_min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX);
+2 -2
View File
@@ -19,8 +19,8 @@ class BlenderObjectCulling {
bool test(Scene *scene, BL::Object &b_ob, Transform &tfm);
private:
bool test_camera(Scene *scene, float3 bb[8]);
bool test_distance(Scene *scene, float3 bb[8]);
bool test_camera(Scene *scene, const float3 bb[8]);
bool test_distance(Scene *scene, const float3 bb[8]);
bool use_scene_camera_cull_;
bool use_camera_cull_;
+2 -2
View File
@@ -136,7 +136,7 @@ static void export_pointcloud(Scene *scene,
static void export_pointcloud_motion(PointCloud *pointcloud,
const ::PointCloud &b_pointcloud,
int motion_step)
const int motion_step)
{
/* Find or add attribute. */
Attribute *attr_mP = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -230,7 +230,7 @@ void BlenderSync::sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info
void BlenderSync::sync_pointcloud_motion(PointCloud *pointcloud,
BObjectInfo &b_ob_info,
int motion_step)
const int motion_step)
{
/* Skip if nothing exported. */
if (pointcloud->num_points() == 0) {
+3 -3
View File
@@ -74,8 +74,8 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
BL::BlendData &b_data,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
int height)
const int width,
const int height)
: session(nullptr),
scene(nullptr),
sync(nullptr),
@@ -899,7 +899,7 @@ void BlenderSession::draw(BL::SpaceImageEditor &space_image)
session->draw();
}
void BlenderSession::view_draw(int w, int h)
void BlenderSession::view_draw(const int w, const int h)
{
/* pause in redraw in case update is not being called due to final render */
session->set_pause(BlenderSync::get_session_pause(b_scene, background));
+2 -2
View File
@@ -33,7 +33,7 @@ class BlenderSession {
BL::BlendData &b_data,
BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
int width,
const int width,
int height);
~BlenderSession();
@@ -62,7 +62,7 @@ class BlenderSession {
/* drawing */
void draw(BL::SpaceImageEditor &space_image);
void view_draw(int w, int h);
void view_draw(const int w, const int h);
void tag_redraw();
void tag_update();
void get_status(string &status, string &substatus);
+1 -1
View File
@@ -59,7 +59,7 @@ static EmissionSampling get_emission_sampling(PointerRNA &ptr)
ptr, "emission_sampling", EMISSION_SAMPLING_NUM, EMISSION_SAMPLING_AUTO);
}
static int validate_enum_value(int value, int num_values, int default_value)
static int validate_enum_value(const int value, const int num_values, const int default_value)
{
if (value >= num_values) {
return default_value;
+2 -2
View File
@@ -258,8 +258,8 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
void **python_thread_state,
const DeviceInfo &denoise_device_info)
{
+35 -19
View File
@@ -58,8 +58,8 @@ class BlenderSync {
BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
void **python_thread_state,
const DeviceInfo &denoise_device_info);
void sync_view_layer(BL::ViewLayer &b_view_layer);
@@ -69,10 +69,13 @@ class BlenderSync {
const DeviceInfo &denoise_device_info);
void sync_camera(BL::RenderSettings &b_render,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
const char *viewname);
void sync_view(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height);
void sync_view(BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
const int width,
const int height);
int get_layer_samples()
{
return view_layer.samples;
@@ -94,8 +97,11 @@ class BlenderSync {
BL::Scene &b_scene,
bool background);
static bool get_session_pause(BL::Scene &b_scene, bool background);
static BufferParams get_buffer_params(
BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height);
static BufferParams get_buffer_params(BL::SpaceView3D &b_v3d,
BL::RegionView3D &b_rv3d,
Camera *cam,
const int width,
const int height);
static DenoiseParams get_denoise_params(BL::Scene &b_scene,
BL::ViewLayer &b_view_layer,
@@ -106,13 +112,15 @@ class BlenderSync {
/* sync */
void sync_lights(BL::Depsgraph &b_depsgraph, bool update_all);
void sync_materials(BL::Depsgraph &b_depsgraph, bool update_all);
void sync_objects(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, float motion_time = 0.0f);
void sync_objects(BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
const float motion_time = 0.0f);
void sync_motion(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
const int width,
const int height,
void **python_thread_state);
void sync_film(BL::ViewLayer &b_view_layer, BL::SpaceView3D &b_v3d);
void sync_view();
@@ -132,7 +140,7 @@ class BlenderSync {
Object *sync_object(BL::Depsgraph &b_depsgraph,
BL::ViewLayer &b_view_layer,
BL::DepsgraphObjectInstance &b_instance,
float motion_time,
const float motion_time,
bool use_particle_hair,
bool show_lights,
BlenderObjectCulling &culling,
@@ -162,18 +170,26 @@ class BlenderSync {
BObjectInfo &b_ob_info,
Hair *hair,
int motion_step);
void sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step = 0);
void sync_particle_hair(
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, int motion_step = 0);
void sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, const int motion_step = 0);
void sync_particle_hair(Hair *hair,
BL::Mesh &b_mesh,
BObjectInfo &b_ob_info,
bool motion,
const int motion_step = 0);
bool object_has_particle_hair(BL::Object b_ob);
/* Point Cloud */
void sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info);
void sync_pointcloud_motion(PointCloud *pointcloud, BObjectInfo &b_ob_info, int motion_step = 0);
void sync_pointcloud_motion(PointCloud *pointcloud,
BObjectInfo &b_ob_info,
const int motion_step = 0);
/* Camera */
void sync_camera_motion(
BL::RenderSettings &b_render, BL::Object &b_ob, int width, int height, float motion_time);
void sync_camera_motion(BL::RenderSettings &b_render,
BL::Object &b_ob,
const int width,
const int height,
const float motion_time);
/* Geometry */
Geometry *sync_geometry(BL::Depsgraph &b_depsgraph,
@@ -185,7 +201,7 @@ class BlenderSync {
void sync_geometry_motion(BL::Depsgraph &b_depsgraph,
BObjectInfo &b_ob_info,
Object *object,
float motion_time,
const float motion_time,
bool use_particle_hair,
TaskPool *task_pool);
@@ -193,7 +209,7 @@ class BlenderSync {
void sync_light(BL::Object &b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BObjectInfo &b_ob_info,
int random_id,
const int random_id,
Transform &tfm,
bool *use_portal);
void sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal);
+20 -14
View File
@@ -151,7 +151,7 @@ static inline void free_object_to_mesh(BL::BlendData & /*data*/,
static inline void colorramp_to_array(BL::ColorRamp &ramp,
array<float3> &ramp_color,
array<float> &ramp_alpha,
int size)
const int size)
{
const int full_size = size + 1;
ramp_color.resize(full_size);
@@ -173,7 +173,7 @@ static inline void curvemap_minmax_curve(/*const*/ BL::CurveMap &curve, float *m
}
static inline void curvemapping_minmax(/*const*/ BL::CurveMapping &cumap,
int num_curves,
const int num_curves,
float *min_x,
float *max_x)
{
@@ -186,7 +186,9 @@ static inline void curvemapping_minmax(/*const*/ BL::CurveMapping &cumap,
}
}
static inline void curvemapping_to_array(BL::CurveMapping &cumap, array<float> &data, int size)
static inline void curvemapping_to_array(BL::CurveMapping &cumap,
array<float> &data,
const int size)
{
cumap.update();
BL::CurveMap curve = cumap.curves[0];
@@ -200,7 +202,7 @@ static inline void curvemapping_to_array(BL::CurveMapping &cumap, array<float> &
static inline void curvemapping_float_to_array(BL::CurveMapping &cumap,
array<float> &data,
int size)
const int size)
{
float min = 0.0f;
float max = 1.0f;
@@ -224,7 +226,7 @@ static inline void curvemapping_float_to_array(BL::CurveMapping &cumap,
static inline void curvemapping_color_to_array(BL::CurveMapping &cumap,
array<float3> &data,
int size,
const int size,
bool rgb_curve)
{
float min_x = 0.0f;
@@ -303,7 +305,7 @@ static inline int render_resolution_y(BL::RenderSettings &b_render)
static inline string image_user_file_path(BL::BlendData &data,
BL::ImageUser &iuser,
BL::Image &ima,
int cfra)
const int cfra)
{
char filepath[1024];
iuser.tile(0);
@@ -319,19 +321,23 @@ static inline string image_user_file_path(BL::BlendData &data,
return string(filepath);
}
static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra)
static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, const int cfra)
{
BKE_image_user_frame_calc(
static_cast<Image *>(ima.ptr.data), static_cast<ImageUser *>(iuser.ptr.data), cfra);
return iuser.frame_current();
}
static inline unsigned char *image_get_pixels_for_frame(BL::Image &image, int frame, int tile)
static inline unsigned char *image_get_pixels_for_frame(BL::Image &image,
const int frame,
const int tile)
{
return BKE_image_get_pixels_for_frame(static_cast<Image *>(image.ptr.data), frame, tile);
}
static inline float *image_get_float_pixels_for_frame(BL::Image &image, int frame, int tile)
static inline float *image_get_float_pixels_for_frame(BL::Image &image,
const int frame,
const int tile)
{
return BKE_image_get_float_pixels_for_frame(static_cast<Image *>(image.ptr.data), frame, tile);
}
@@ -422,7 +428,7 @@ static inline float3 get_float3(PointerRNA &ptr, const char *name)
return f;
}
static inline void set_float3(PointerRNA &ptr, const char *name, float3 value)
static inline void set_float3(PointerRNA &ptr, const char *name, const float3 value)
{
RNA_float_set_array(&ptr, name, &value.x);
}
@@ -434,7 +440,7 @@ static inline float4 get_float4(PointerRNA &ptr, const char *name)
return f;
}
static inline void set_float4(PointerRNA &ptr, const char *name, float4 value)
static inline void set_float4(PointerRNA &ptr, const char *name, const float4 value)
{
RNA_float_set_array(&ptr, name, &value.x);
}
@@ -454,7 +460,7 @@ static inline float get_float(PointerRNA &ptr, const char *name)
return RNA_float_get(&ptr, name);
}
static inline void set_float(PointerRNA &ptr, const char *name, float value)
static inline void set_float(PointerRNA &ptr, const char *name, const float value)
{
RNA_float_set(&ptr, name, value);
}
@@ -464,7 +470,7 @@ static inline int get_int(PointerRNA &ptr, const char *name)
return RNA_int_get(&ptr, name);
}
static inline void set_int(PointerRNA &ptr, const char *name, int value)
static inline void set_int(PointerRNA &ptr, const char *name, const int value)
{
RNA_int_set(&ptr, name, value);
}
@@ -500,7 +506,7 @@ static inline string get_enum_identifier(PointerRNA &ptr, const char *name)
return string(identifier);
}
static inline void set_enum(PointerRNA &ptr, const char *name, int value)
static inline void set_enum(PointerRNA &ptr, const char *name, const int value)
{
RNA_enum_set(&ptr, name, value);
}
+1 -1
View File
@@ -170,7 +170,7 @@ class BlenderSmokeLoader : public ImageLoader {
};
static void sync_smoke_volume(
BL::Scene &b_scene, Scene *scene, BObjectInfo &b_ob_info, Volume *volume, float frame)
BL::Scene &b_scene, Scene *scene, BObjectInfo &b_ob_info, Volume *volume, const float frame)
{
if (!b_ob_info.is_real_object_data()) {
return;
+1 -1
View File
@@ -81,7 +81,7 @@ class BVHObjectBinning : public BVHRange {
}
/* compute the number of blocks occupied in one dimension. */
__forceinline int blocks(size_t a) const
__forceinline int blocks(const size_t a) const
{
return (int)((a + ((1LL << LOG_BLOCK_SIZE) - 1)) >> LOG_BLOCK_SIZE);
}
+19 -14
View File
@@ -57,7 +57,7 @@ BVHBuild::~BVHBuild() = default;
void BVHBuild::add_reference_triangles(BoundBox &root,
BoundBox &center,
Mesh *mesh,
int object_index)
const int object_index)
{
const PrimitiveType primitive_type = mesh->primitive_type();
const Attribute *attr_mP = nullptr;
@@ -144,7 +144,10 @@ void BVHBuild::add_reference_triangles(BoundBox &root,
}
}
void BVHBuild::add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair, int object_index)
void BVHBuild::add_reference_curves(BoundBox &root,
BoundBox &center,
Hair *hair,
const int object_index)
{
const Attribute *curve_attr_mP = nullptr;
if (hair->has_motion_blur()) {
@@ -259,7 +262,7 @@ void BVHBuild::add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair
void BVHBuild::add_reference_points(BoundBox &root,
BoundBox &center,
PointCloud *pointcloud,
int i)
const int i)
{
const Attribute *point_attr_mP = nullptr;
if (pointcloud->has_motion_blur()) {
@@ -354,7 +357,7 @@ void BVHBuild::add_reference_points(BoundBox &root,
void BVHBuild::add_reference_geometry(BoundBox &root,
BoundBox &center,
Geometry *geom,
int object_index)
const int object_index)
{
if (geom->is_mesh() || geom->is_volume()) {
Mesh *mesh = static_cast<Mesh *>(geom);
@@ -370,7 +373,7 @@ void BVHBuild::add_reference_geometry(BoundBox &root,
}
}
void BVHBuild::add_reference_object(BoundBox &root, BoundBox &center, Object *ob, int i)
void BVHBuild::add_reference_object(BoundBox &root, BoundBox &center, Object *ob, const int i)
{
references.push_back(BVHReference(ob->bounds, -1, i, 0));
root.grow(ob->bounds);
@@ -589,9 +592,9 @@ void BVHBuild::progress_update()
}
void BVHBuild::thread_build_node(InnerNode *inner,
int child,
const int child,
const BVHObjectBinning &range,
int level)
const int level)
{
if (progress.get_cancel()) {
return;
@@ -615,10 +618,10 @@ void BVHBuild::thread_build_node(InnerNode *inner,
}
void BVHBuild::thread_build_spatial_split_node(InnerNode *inner,
int child,
const int child,
const BVHRange &range,
vector<BVHReference> &references,
int level)
const int level)
{
if (progress.get_cancel()) {
return;
@@ -690,7 +693,7 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange &range,
}
/* multithreaded binning builder */
BVHNode *BVHBuild::build_node(const BVHObjectBinning &range, int level)
BVHNode *BVHBuild::build_node(const BVHObjectBinning &range, const int level)
{
const size_t size = range.size();
const float leafSAH = params.sah_primitive_cost * range.leafSAH;
@@ -779,7 +782,7 @@ BVHNode *BVHBuild::build_node(const BVHObjectBinning &range, int level)
/* multithreaded spatial split builder */
BVHNode *BVHBuild::build_node(const BVHRange &range,
vector<BVHReference> &references,
int level,
const int level,
BVHSpatialStorage *storage)
{
/* Update progress.
@@ -899,7 +902,9 @@ BVHNode *BVHBuild::build_node(const BVHRange &range,
/* Create Nodes */
BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start, int num)
BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref,
const int start,
const int num)
{
if (num == 0) {
const BoundBox bounds = BoundBox::empty;
@@ -1186,7 +1191,7 @@ BVHNode *BVHBuild::create_leaf_node(const BVHRange &range, const vector<BVHRefer
/* Tree Rotations */
void BVHBuild::rotate(BVHNode *node, int max_depth, int iterations)
void BVHBuild::rotate(BVHNode *node, const int max_depth, const int iterations)
{
/* In tested scenes, this resulted in slightly slower ray-tracing, so disabled
* it for now. could be implementation bug, or depend on the scene. */
@@ -1197,7 +1202,7 @@ void BVHBuild::rotate(BVHNode *node, int max_depth, int iterations)
}
}
void BVHBuild::rotate(BVHNode *node, int max_depth)
void BVHBuild::rotate(BVHNode *node, const int max_depth)
{
/* nothing to rotate if we reached a leaf node. */
if (node->is_leaf() || max_depth < 0) {
+21 -12
View File
@@ -56,30 +56,39 @@ class BVHBuild {
friend class BVHObjectBinning;
/* Adding references. */
void add_reference_triangles(BoundBox &root, BoundBox &center, Mesh *mesh, int object_index);
void add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair, int object_index);
void add_reference_points(BoundBox &root, BoundBox &center, PointCloud *pointcloud, int i);
void add_reference_geometry(BoundBox &root, BoundBox &center, Geometry *geom, int object_index);
void add_reference_object(BoundBox &root, BoundBox &center, Object *ob, int i);
void add_reference_triangles(BoundBox &root,
BoundBox &center,
Mesh *mesh,
const int object_index);
void add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair, const int object_index);
void add_reference_points(BoundBox &root, BoundBox &center, PointCloud *pointcloud, const int i);
void add_reference_geometry(BoundBox &root,
BoundBox &center,
Geometry *geom,
const int object_index);
void add_reference_object(BoundBox &root, BoundBox &center, Object *ob, const int i);
void add_references(BVHRange &root);
/* Building. */
BVHNode *build_node(const BVHRange &range,
vector<BVHReference> &references,
int level,
const int level,
BVHSpatialStorage *storage);
BVHNode *build_node(const BVHObjectBinning &range, int level);
BVHNode *build_node(const BVHObjectBinning &range, const int level);
BVHNode *create_leaf_node(const BVHRange &range, const vector<BVHReference> &references);
BVHNode *create_object_leaf_nodes(const BVHReference *ref, int start, int num);
BVHNode *create_object_leaf_nodes(const BVHReference *ref, const int start, const int num);
bool range_within_max_leaf_size(const BVHRange &range,
const vector<BVHReference> &references) const;
/* Threads. */
enum { THREAD_TASK_SIZE = 4096 };
void thread_build_node(InnerNode *inner, int child, const BVHObjectBinning &range, int level);
void thread_build_node(InnerNode *inner,
const int child,
const BVHObjectBinning &range,
const int level);
void thread_build_spatial_split_node(InnerNode *inner,
int child,
const int child,
const BVHRange &range,
vector<BVHReference> &references,
int level);
@@ -89,8 +98,8 @@ class BVHBuild {
void progress_update();
/* Tree rotations. */
void rotate(BVHNode *node, int max_depth);
void rotate(BVHNode *node, int max_depth, int iterations);
void rotate(BVHNode *node, const int max_depth);
void rotate(BVHNode *node, const int max_depth, const int iterations);
/* Objects and primitive references. */
vector<Object *> objects;
+5 -5
View File
@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
BVHStackEntry::BVHStackEntry(const BVHNode *n, int i) : node(n), idx(i) {}
BVHStackEntry::BVHStackEntry(const BVHNode *n, const int i) : node(n), idx(i) {}
int BVHStackEntry::encodeIdx() const
{
@@ -152,7 +152,7 @@ void BVH2::pack_aligned_inner(const BVHStackEntry &e,
e1.node->visibility);
}
void BVH2::pack_aligned_node(int idx,
void BVH2::pack_aligned_node(const int idx,
const BoundBox &b0,
const BoundBox &b1,
int c0,
@@ -199,7 +199,7 @@ void BVH2::pack_unaligned_inner(const BVHStackEntry &e,
e1.node->visibility);
}
void BVH2::pack_unaligned_node(int idx,
void BVH2::pack_unaligned_node(const int idx,
const Transform &aligned_space0,
const Transform &aligned_space1,
const BoundBox &b0,
@@ -312,7 +312,7 @@ void BVH2::refit_nodes()
refit_node(0, (pack.root_index == -1) ? true : false, bbox, visibility);
}
void BVH2::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility)
void BVH2::refit_node(const int idx, bool leaf, BoundBox &bbox, uint &visibility)
{
if (leaf) {
/* refit leaf node */
@@ -364,7 +364,7 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility)
/* Refitting */
void BVH2::refit_primitives(int start, int end, BoundBox &bbox, uint &visibility)
void BVH2::refit_primitives(const int start, const int end, BoundBox &bbox, uint &visibility)
{
/* Refit range of primitives. */
for (int prim = start; prim < end; prim++) {
+7 -7
View File
@@ -26,7 +26,7 @@ struct BVHStackEntry {
const BVHNode *node;
int idx;
BVHStackEntry(const BVHNode *n = nullptr, int i = 0);
BVHStackEntry(const BVHNode *n = nullptr, const int i = 0);
int encodeIdx() const;
};
@@ -60,7 +60,7 @@ class BVH2 : public BVH {
void pack_aligned_inner(const BVHStackEntry &e,
const BVHStackEntry &e0,
const BVHStackEntry &e1);
void pack_aligned_node(int idx,
void pack_aligned_node(const int idx,
const BoundBox &b0,
const BoundBox &b1,
int c0,
@@ -71,7 +71,7 @@ class BVH2 : public BVH {
void pack_unaligned_inner(const BVHStackEntry &e,
const BVHStackEntry &e0,
const BVHStackEntry &e1);
void pack_unaligned_node(int idx,
void pack_unaligned_node(const int idx,
const Transform &aligned_space0,
const Transform &aligned_space1,
const BoundBox &b0,
@@ -83,17 +83,17 @@ class BVH2 : public BVH {
/* refit */
void refit_nodes();
void refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility);
void refit_node(const int idx, bool leaf, BoundBox &bbox, uint &visibility);
/* Refit range of primitives. */
void refit_primitives(int start, int end, BoundBox &bbox, uint &visibility);
void refit_primitives(const int start, const int end, BoundBox &bbox, uint &visibility);
/* triangles and strands */
void pack_primitives();
void pack_triangle(int idx, float4 storage[3]);
void pack_triangle(const int idx, const float4 storage[3]);
/* merge instance BVH's */
void pack_instances(size_t nodes_size, size_t leaf_nodes_size);
void pack_instances(const size_t nodes_size, const size_t leaf_nodes_size);
};
CCL_NAMESPACE_END
+6 -6
View File
@@ -226,7 +226,7 @@ RTCError BVHEmbree::offload_scenes_to_gpu(const vector<RTCScene> &scenes)
}
# endif
void BVHEmbree::add_object(Object *ob, int i)
void BVHEmbree::add_object(Object *ob, const int i)
{
Geometry *geom = ob->get_geometry();
@@ -250,7 +250,7 @@ void BVHEmbree::add_object(Object *ob, int i)
}
}
void BVHEmbree::add_instance(Object *ob, int i)
void BVHEmbree::add_instance(Object *ob, const int i)
{
BVHEmbree *instance_bvh = (BVHEmbree *)(ob->get_geometry()->bvh);
assert(instance_bvh != nullptr);
@@ -296,7 +296,7 @@ void BVHEmbree::add_instance(Object *ob, int i)
rtcReleaseGeometry(geom_id);
}
void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i)
void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, const int i)
{
const size_t prim_offset = mesh->prim_offset;
@@ -435,7 +435,7 @@ void BVHEmbree::set_tri_vertex_buffer(RTCGeometry geom_id, const Mesh *mesh, con
* Packs the hair motion curve data control variables (CVs) into float4s as [x y z radius]
*/
template<typename T>
void pack_motion_verts(size_t num_curves,
void pack_motion_verts(const size_t num_curves,
const Hair *hair,
const T *verts,
const float *curve_radius,
@@ -575,7 +575,7 @@ void BVHEmbree::set_point_vertex_buffer(RTCGeometry geom_id,
}
}
void BVHEmbree::add_points(const Object *ob, const PointCloud *pointcloud, int i)
void BVHEmbree::add_points(const Object *ob, const PointCloud *pointcloud, const int i)
{
const size_t prim_offset = pointcloud->prim_offset;
@@ -611,7 +611,7 @@ void BVHEmbree::add_points(const Object *ob, const PointCloud *pointcloud, int i
rtcReleaseGeometry(geom_id);
}
void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i)
void BVHEmbree::add_curves(const Object *ob, const Hair *hair, const int i)
{
const size_t prim_offset = hair->curve_segment_offset;
+6 -5
View File
@@ -48,11 +48,12 @@ class BVHEmbree : public BVH {
const vector<Object *> &objects);
~BVHEmbree() override;
void add_object(Object *ob, int i);
void add_instance(Object *ob, int i);
void add_curves(const Object *ob, const Hair *hair, int i);
void add_points(const Object *ob, const PointCloud *pointcloud, int i);
void add_triangles(const Object *ob, const Mesh *mesh, int i);
protected:
void add_object(Object *ob, const int i);
void add_instance(Object *ob, const int i);
void add_curves(const Object *ob, const Hair *hair, const int i);
void add_points(const Object *ob, const PointCloud *pointcloud, const int i);
void add_triangles(const Object *ob, const Mesh *mesh, const int i);
private:
void set_tri_vertex_buffer(RTCGeometry geom_id, const Mesh *mesh, const bool update);
+3 -3
View File
@@ -103,7 +103,7 @@ void BVHNode::deleteSubtree()
delete this;
}
float BVHNode::computeSubtreeSAHCost(const BVHParams &p, float probability) const
float BVHNode::computeSubtreeSAHCost(const BVHParams &p, const float probability) const
{
float SAH = probability * p.cost(num_children(), num_triangles());
@@ -194,7 +194,7 @@ void BVHNode::dump_graph(const char *filename)
/* Inner Node */
void InnerNode::print(int depth) const
void InnerNode::print(const int depth) const
{
for (int i = 0; i < depth; i++) {
printf(" ");
@@ -210,7 +210,7 @@ void InnerNode::print(int depth) const
}
}
void LeafNode::print(int depth) const
void LeafNode::print(const int depth) const
{
for (int i = 0; i < depth; i++) {
printf(" ");
+7 -7
View File
@@ -38,12 +38,12 @@ class BVHNode {
virtual bool is_leaf() const = 0;
virtual int num_children() const = 0;
virtual BVHNode *get_child(int i) const = 0;
virtual BVHNode *get_child(const int i) const = 0;
virtual int num_triangles() const
{
return 0;
}
virtual void print(int depth = 0) const = 0;
virtual void print(const int depth = 0) const = 0;
void set_aligned_space(const Transform &aligned_space)
{
@@ -79,7 +79,7 @@ class BVHNode {
// Subtree functions
int getSubtreeSize(BVH_STAT stat = BVH_STAT_NODE_COUNT) const;
float computeSubtreeSAHCost(const BVHParams &p, float probability = 1.0f) const;
float computeSubtreeSAHCost(const BVHParams &p, const float probability = 1.0f) const;
void deleteSubtree();
uint update_visibility();
@@ -177,12 +177,12 @@ class InnerNode : public BVHNode {
{
return num_children_;
}
BVHNode *get_child(int i) const override
BVHNode *get_child(const int i) const override
{
assert(i >= 0 && i < num_children_);
return children[i];
}
void print(int depth) const override;
void print(const int depth) const override;
int num_children_;
BVHNode *children[kNumMaxChildren];
@@ -198,7 +198,7 @@ class InnerNode : public BVHNode {
class LeafNode : public BVHNode {
public:
LeafNode(const BoundBox &bounds, uint visibility, int lo, int hi)
LeafNode(const BoundBox &bounds, const uint visibility, const int lo, const int hi)
: BVHNode(bounds), lo(lo), hi(hi)
{
this->bounds = bounds;
@@ -223,7 +223,7 @@ class LeafNode : public BVHNode {
{
return hi - lo;
}
void print(int depth) const override;
void print(const int depth) const override;
int lo;
int hi;
+8 -8
View File
@@ -145,22 +145,22 @@ class BVHParams {
}
/* SAH costs */
__forceinline float cost(int num_nodes, int num_primitives) const
__forceinline float cost(const int num_nodes, const int num_primitives) const
{
return node_cost(num_nodes) + primitive_cost(num_primitives);
}
__forceinline float primitive_cost(int n) const
__forceinline float primitive_cost(const int n) const
{
return n * sah_primitive_cost;
}
__forceinline float node_cost(int n) const
__forceinline float node_cost(const int n) const
{
return n * sah_node_cost;
}
__forceinline bool small_enough_for_leaf(int size, int level)
__forceinline bool small_enough_for_leaf(const int size, const int level)
{
return (size <= min_leaf_size || level >= MAX_DEPTH);
}
@@ -189,9 +189,9 @@ class BVHReference {
__forceinline BVHReference() = default;
__forceinline BVHReference(const BoundBox &bounds_,
int prim_index_,
int prim_object_,
int prim_type,
const int prim_index_,
const int prim_object_,
const int prim_type,
float time_from = 0.0f,
float time_to = 1.0f)
: rbounds(bounds_), time_from_(time_from), time_to_(time_to)
@@ -261,7 +261,7 @@ class BVHRange {
rbounds.max.w = __int_as_float(size_);
}
__forceinline void set_start(int start_)
__forceinline void set_start(const int start_)
{
rbounds.min.w = __int_as_float(start_);
}
+4 -4
View File
@@ -23,7 +23,7 @@ struct BVHReferenceCompare {
const BVHUnaligned *unaligned_heuristic;
const Transform *aligned_space;
BVHReferenceCompare(int dim,
BVHReferenceCompare(const int dim,
const BVHUnaligned *unaligned_heuristic,
const Transform *aligned_space)
: dim(dim), unaligned_heuristic(unaligned_heuristic), aligned_space(aligned_space)
@@ -164,10 +164,10 @@ static void bvh_reference_sort_threaded(TaskPool *task_pool,
}
}
void bvh_reference_sort(int start,
int end,
void bvh_reference_sort(const int start,
const int end,
BVHReference *data,
int dim,
const int dim,
const BVHUnaligned *unaligned_heuristic,
const Transform *aligned_space)
{
+3 -3
View File
@@ -13,10 +13,10 @@ class BVHReference;
class BVHUnaligned;
struct Transform;
void bvh_reference_sort(int start,
int end,
void bvh_reference_sort(const int start,
const int end,
BVHReference *data,
int dim,
const int dim,
const BVHUnaligned *unaligned_heuristic = nullptr,
const Transform *aligned_space = nullptr);
+25 -22
View File
@@ -25,7 +25,7 @@ BVHObjectSplit::BVHObjectSplit(BVHBuild *builder,
BVHSpatialStorage *storage,
const BVHRange &range,
vector<BVHReference> &references,
float nodeSAH,
const float nodeSAH,
const BVHUnaligned *unaligned_heuristic,
const Transform *aligned_space)
: sah(FLT_MAX),
@@ -130,7 +130,7 @@ BVHSpatialSplit::BVHSpatialSplit(const BVHBuild &builder,
BVHSpatialStorage *storage,
const BVHRange &range,
vector<BVHReference> &references,
float nodeSAH,
const float nodeSAH,
const BVHUnaligned *unaligned_heuristic,
const Transform *aligned_space)
: sah(FLT_MAX),
@@ -343,9 +343,9 @@ void BVHSpatialSplit::split(BVHBuild *builder,
void BVHSpatialSplit::split_triangle_primitive(const Mesh *mesh,
const Transform *tfm,
int prim_index,
int dim,
float pos,
const int prim_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -382,10 +382,10 @@ void BVHSpatialSplit::split_triangle_primitive(const Mesh *mesh,
void BVHSpatialSplit::split_curve_primitive(const Hair *hair,
const Transform *tfm,
int prim_index,
int segment_index,
int dim,
float pos,
const int prim_index,
const int segment_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -433,9 +433,9 @@ void BVHSpatialSplit::split_curve_primitive(const Hair *hair,
void BVHSpatialSplit::split_point_primitive(const PointCloud *pointcloud,
const Transform *tfm,
int prim_index,
int dim,
float pos,
const int prim_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -460,8 +460,8 @@ void BVHSpatialSplit::split_point_primitive(const PointCloud *pointcloud,
void BVHSpatialSplit::split_triangle_reference(const BVHReference &ref,
const Mesh *mesh,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -470,8 +470,8 @@ void BVHSpatialSplit::split_triangle_reference(const BVHReference &ref,
void BVHSpatialSplit::split_curve_reference(const BVHReference &ref,
const Hair *hair,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -487,8 +487,8 @@ void BVHSpatialSplit::split_curve_reference(const BVHReference &ref,
void BVHSpatialSplit::split_point_reference(const BVHReference &ref,
const PointCloud *pointcloud,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
@@ -496,8 +496,11 @@ void BVHSpatialSplit::split_point_reference(const BVHReference &ref,
pointcloud, nullptr, ref.prim_index(), dim, pos, left_bounds, right_bounds);
}
void BVHSpatialSplit::split_object_reference(
const Object *object, int dim, float pos, BoundBox &left_bounds, BoundBox &right_bounds)
void BVHSpatialSplit::split_object_reference(const Object *object,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
Geometry *geom = object->get_geometry();
@@ -531,8 +534,8 @@ void BVHSpatialSplit::split_reference(const BVHBuild &builder,
BVHReference &left,
BVHReference &right,
const BVHReference &ref,
int dim,
float pos)
const int dim,
const float pos)
{
/* Initialize bounding-boxes. */
BoundBox left_bounds = BoundBox::empty;
+25 -22
View File
@@ -33,7 +33,7 @@ class BVHObjectSplit {
BVHSpatialStorage *storage,
const BVHRange &range,
vector<BVHReference> &references,
float nodeSAH,
const float nodeSAH,
const BVHUnaligned *unaligned_heuristic = nullptr,
const Transform *aligned_space = nullptr);
@@ -67,7 +67,7 @@ class BVHSpatialSplit {
BVHSpatialStorage *storage,
const BVHRange &range,
vector<BVHReference> &references,
float nodeSAH,
const float nodeSAH,
const BVHUnaligned *unaligned_heuristic = nullptr,
const Transform *aligned_space = nullptr);
@@ -77,7 +77,7 @@ class BVHSpatialSplit {
BVHReference &left,
BVHReference &right,
const BVHReference &ref,
int dim,
const int dim,
float pos);
protected:
@@ -94,24 +94,24 @@ class BVHSpatialSplit {
*/
void split_triangle_primitive(const Mesh *mesh,
const Transform *tfm,
int prim_index,
int dim,
float pos,
const int prim_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
void split_curve_primitive(const Hair *hair,
const Transform *tfm,
int prim_index,
int segment_index,
int dim,
float pos,
const int prim_index,
const int segment_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
void split_point_primitive(const PointCloud *pointcloud,
const Transform *tfm,
int prim_index,
int dim,
float pos,
const int prim_index,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
@@ -122,24 +122,27 @@ class BVHSpatialSplit {
*/
void split_triangle_reference(const BVHReference &ref,
const Mesh *mesh,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
void split_curve_reference(const BVHReference &ref,
const Hair *hair,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
void split_point_reference(const BVHReference &ref,
const PointCloud *pointcloud,
int dim,
float pos,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
void split_object_reference(
const Object *object, int dim, float pos, BoundBox &left_bounds, BoundBox &right_bounds);
void split_object_reference(const Object *object,
const int dim,
const float pos,
BoundBox &left_bounds,
BoundBox &right_bounds);
__forceinline BoundBox get_prim_bounds(const BVHReference &prim) const
{
@@ -179,7 +182,7 @@ class BVHMixedSplit {
BVHSpatialStorage *storage,
const BVHRange &range,
vector<BVHReference> &references,
int level,
const int level,
const BVHUnaligned *unaligned_heuristic = nullptr,
const Transform *aligned_space = nullptr)
{
+1 -1
View File
@@ -8,7 +8,7 @@
#include <zstd.h>
int main(int argc, const char **argv)
int main(const int argc, const char **argv)
{
if (argc < 3) {
return -1;
+2 -2
View File
@@ -178,12 +178,12 @@ void CPUDevice::mem_free(device_memory &mem)
}
}
device_ptr CPUDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/)
device_ptr CPUDevice::mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/)
{
return (device_ptr)(((char *)mem.device_pointer) + mem.memory_elements_size(offset));
}
void CPUDevice::const_copy_to(const char *name, void *host, size_t size)
void CPUDevice::const_copy_to(const char *name, void *host, const size_t size)
{
#ifdef WITH_EMBREE
if (strcmp(name, "data") == 0) {
+4 -3
View File
@@ -66,12 +66,13 @@ class CPUDevice : public Device {
void mem_alloc(device_memory &mem) override;
void mem_copy_to(device_memory &mem) override;
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
void mem_zero(device_memory &mem) override;
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
void const_copy_to(const char *name, void *host, size_t size) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
void global_alloc(device_memory &mem);
void global_free(device_memory &mem);
+14 -14
View File
@@ -56,29 +56,29 @@ class CPUKernels {
using AdaptiveSamplingConvergenceCheckFunction =
CPUKernelFunction<bool (*)(const KernelGlobalsCPU *kg,
ccl_global float *render_buffer,
int x,
int y,
float threshold,
int reset,
int offset,
const int x,
const int y,
const float threshold,
const int reset,
const int offset,
int stride)>;
using AdaptiveSamplingFilterXFunction =
CPUKernelFunction<void (*)(const KernelGlobalsCPU *kg,
ccl_global float *render_buffer,
int y,
int start_x,
int width,
int offset,
const int y,
const int start_x,
const int width,
const int offset,
int stride)>;
using AdaptiveSamplingFilterYFunction =
CPUKernelFunction<void (*)(const KernelGlobalsCPU *kg,
ccl_global float *render_buffer,
int x,
int start_y,
int height,
int offset,
const int x,
const int start_y,
const int height,
const int offset,
int stride)>;
AdaptiveSamplingConvergenceCheckFunction adaptive_sampling_convergence_check;
@@ -89,7 +89,7 @@ class CPUKernels {
/* Cryptomatte. */
using CryptomattePostprocessFunction = CPUKernelFunction<void (*)(
const KernelGlobalsCPU *kg, ccl_global float *render_buffer, int pixel_index)>;
const KernelGlobalsCPU *kg, ccl_global float *render_buffer, const int pixel_index)>;
CryptomattePostprocessFunction cryptomatte_postprocess;
+8 -7
View File
@@ -522,7 +522,7 @@ void CUDADevice::get_device_memory_info(size_t &total, size_t &free)
cuMemGetInfo(&free, &total);
}
bool CUDADevice::alloc_device(void *&device_pointer, size_t size)
bool CUDADevice::alloc_device(void *&device_pointer, const size_t size)
{
CUDAContextScope scope(this);
@@ -537,7 +537,7 @@ void CUDADevice::free_device(void *device_pointer)
cuda_assert(cuMemFree((CUdeviceptr)device_pointer));
}
bool CUDADevice::alloc_host(void *&shared_pointer, size_t size)
bool CUDADevice::alloc_host(void *&shared_pointer, const size_t size)
{
CUDAContextScope scope(this);
@@ -560,7 +560,7 @@ void CUDADevice::transform_host_pointer(void *&device_pointer, void *&shared_poi
cuda_assert(cuMemHostGetDevicePointer_v2((CUdeviceptr *)&device_pointer, shared_pointer, 0));
}
void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size)
void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, const size_t size)
{
const CUDAContextScope scope(this);
@@ -598,7 +598,8 @@ void CUDADevice::mem_copy_to(device_memory &mem)
}
}
void CUDADevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)
void CUDADevice::mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem)
{
if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
@@ -652,12 +653,12 @@ void CUDADevice::mem_free(device_memory &mem)
}
}
device_ptr CUDADevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/)
device_ptr CUDADevice::mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/)
{
return (device_ptr)(((char *)mem.device_pointer) + mem.memory_elements_size(offset));
}
void CUDADevice::const_copy_to(const char *name, void *host, size_t size)
void CUDADevice::const_copy_to(const char *name, void *host, const size_t size)
{
CUDAContextScope scope(this);
CUdeviceptr mem;
@@ -1008,7 +1009,7 @@ bool CUDADevice::get_device_attribute(CUdevice_attribute attribute, int *value)
return cuDeviceGetAttribute(value, attribute, cuDevice) == CUDA_SUCCESS;
}
int CUDADevice::get_device_default_attribute(CUdevice_attribute attribute, int default_value)
int CUDADevice::get_device_default_attribute(CUdevice_attribute attribute, const int default_value)
{
int value = 0;
if (!get_device_attribute(attribute, &value)) {
+4 -3
View File
@@ -74,13 +74,14 @@ class CUDADevice : public GPUDevice {
void mem_copy_to(device_memory &mem) override;
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
void mem_zero(device_memory &mem) override;
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
@@ -101,7 +102,7 @@ class CUDADevice : public GPUDevice {
protected:
bool get_device_attribute(CUdevice_attribute attribute, int *value);
int get_device_default_attribute(CUdevice_attribute attribute, int default_value);
int get_device_default_attribute(CUdevice_attribute attribute, const int default_value);
};
CCL_NAMESPACE_END
+6 -6
View File
@@ -212,7 +212,7 @@ vector<DeviceType> Device::available_types()
return types;
}
vector<DeviceInfo> Device::available_devices(uint mask)
vector<DeviceInfo> Device::available_devices(const uint mask)
{
/* Lazy initialize devices. On some platforms OpenCL or CUDA drivers can
* be broken and cause crashes when only trying to get device info, so
@@ -313,7 +313,7 @@ DeviceInfo Device::dummy_device(const string &error_msg)
return info;
}
string Device::device_capabilities(uint mask)
string Device::device_capabilities(const uint mask)
{
const thread_scoped_lock lock(device_mutex);
string capabilities;
@@ -375,7 +375,7 @@ string Device::device_capabilities(uint mask)
}
DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
int threads,
const int threads,
bool background)
{
assert(!subdevices.empty());
@@ -507,8 +507,8 @@ bool GPUDevice::load_texture_info()
return false;
}
void GPUDevice::init_host_memory(size_t preferred_texture_headroom,
size_t preferred_working_headroom)
void GPUDevice::init_host_memory(const size_t preferred_texture_headroom,
const size_t preferred_working_headroom)
{
/* Limit amount of host mapped memory, because allocating too much can
* cause system instability. Leave at least half or 4 GB of system
@@ -628,7 +628,7 @@ void GPUDevice::move_textures_to_host(size_t size, bool for_texture)
load_texture_info();
}
GPUDevice::Mem *GPUDevice::generic_alloc(device_memory &mem, size_t pitch_padding)
GPUDevice::Mem *GPUDevice::generic_alloc(device_memory &mem, const size_t pitch_padding)
{
void *device_pointer = nullptr;
const size_t size = mem.memory_size() + pitch_padding;
+15 -12
View File
@@ -173,7 +173,7 @@ class Device {
fprintf(stderr, "%s\n", error.c_str());
fflush(stderr);
}
virtual BVHLayoutMask get_bvh_layout_mask(uint kernel_features) const = 0;
virtual BVHLayoutMask get_bvh_layout_mask(const uint kernel_features) const = 0;
/* statistics */
Stats &stats;
@@ -181,7 +181,7 @@ class Device {
bool headless = true;
/* constant memory */
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
virtual void const_copy_to(const char *name, void *host, const size_t size) = 0;
/* load/compile kernels, must be called before adding tasks */
virtual bool load_kernels(uint /*kernel_features*/)
@@ -290,11 +290,11 @@ class Device {
static DeviceType type_from_string(const char *name);
static string string_from_type(DeviceType type);
static vector<DeviceType> available_types();
static vector<DeviceInfo> available_devices(uint device_type_mask = DEVICE_MASK_ALL);
static vector<DeviceInfo> available_devices(const uint device_type_mask = DEVICE_MASK_ALL);
static DeviceInfo dummy_device(const string &error_msg = "");
static string device_capabilities(uint device_type_mask = DEVICE_MASK_ALL);
static string device_capabilities(const uint device_type_mask = DEVICE_MASK_ALL);
static DeviceInfo get_multi_device(const vector<DeviceInfo> &subdevices,
int threads,
const int threads,
bool background);
/* Tag devices lists for update. */
@@ -310,7 +310,8 @@ class Device {
virtual void mem_alloc(device_memory &mem) = 0;
virtual void mem_copy_to(device_memory &mem) = 0;
virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) = 0;
virtual void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) = 0;
virtual void mem_zero(device_memory &mem) = 0;
virtual void mem_free(device_memory &mem) = 0;
@@ -377,24 +378,24 @@ class GPUDevice : public Device {
/* Simple counter which will try to track amount of used device memory */
size_t device_mem_in_use = 0;
virtual void init_host_memory(size_t preferred_texture_headroom = 0,
virtual void init_host_memory(const size_t preferred_texture_headroom = 0,
size_t preferred_working_headroom = 0);
virtual void move_textures_to_host(size_t size, bool for_texture);
virtual void move_textures_to_host(const size_t size, bool for_texture);
/* Allocation, deallocation and copy functions, with corresponding
* support of device/host allocations. */
virtual GPUDevice::Mem *generic_alloc(device_memory &mem, size_t pitch_padding = 0);
virtual GPUDevice::Mem *generic_alloc(device_memory &mem, const size_t pitch_padding = 0);
virtual void generic_free(device_memory &mem);
virtual void generic_copy_to(device_memory &mem);
/* total - amount of device memory, free - amount of available device memory */
virtual void get_device_memory_info(size_t &total, size_t &free) = 0;
virtual bool alloc_device(void *&device_pointer, size_t size) = 0;
virtual bool alloc_device(void *&device_pointer, const size_t size) = 0;
virtual void free_device(void *device_pointer) = 0;
virtual bool alloc_host(void *&shared_pointer, size_t size) = 0;
virtual bool alloc_host(void *&shared_pointer, const size_t size) = 0;
virtual void free_host(void *shared_pointer) = 0;
@@ -403,7 +404,9 @@ class GPUDevice : public Device {
* address transformation is possible and `false` otherwise. */
virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) = 0;
virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) = 0;
virtual void copy_host_to_device(void *device_pointer,
void *host_pointer,
const size_t size) = 0;
};
CCL_NAMESPACE_END
+4 -1
View File
@@ -73,7 +73,10 @@ bool device_hip_init()
#endif /* WITH_HIP_DYNLOAD */
}
Device *device_hip_create(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
Device *device_hip_create(const DeviceInfo &info,
Stats &stats,
Profiler &profiler,
const bool headless)
{
#ifdef WITH_HIPRT
if (info.use_hardware_raytracing) {
+9 -7
View File
@@ -484,7 +484,7 @@ void HIPDevice::get_device_memory_info(size_t &total, size_t &free)
hipMemGetInfo(&free, &total);
}
bool HIPDevice::alloc_device(void *&device_pointer, size_t size)
bool HIPDevice::alloc_device(void *&device_pointer, const size_t size)
{
HIPContextScope scope(this);
@@ -499,7 +499,7 @@ void HIPDevice::free_device(void *device_pointer)
hip_assert(hipFree((hipDeviceptr_t)device_pointer));
}
bool HIPDevice::alloc_host(void *&shared_pointer, size_t size)
bool HIPDevice::alloc_host(void *&shared_pointer, const size_t size)
{
HIPContextScope scope(this);
@@ -523,7 +523,7 @@ void HIPDevice::transform_host_pointer(void *&device_pointer, void *&shared_poin
hip_assert(hipHostGetDevicePointer((hipDeviceptr_t *)&device_pointer, shared_pointer, 0));
}
void HIPDevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size)
void HIPDevice::copy_host_to_device(void *device_pointer, void *host_pointer, const size_t size)
{
const HIPContextScope scope(this);
@@ -561,7 +561,8 @@ void HIPDevice::mem_copy_to(device_memory &mem)
}
}
void HIPDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)
void HIPDevice::mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem)
{
if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
@@ -615,12 +616,12 @@ void HIPDevice::mem_free(device_memory &mem)
}
}
device_ptr HIPDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/)
device_ptr HIPDevice::mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/)
{
return (device_ptr)(((char *)mem.device_pointer) + mem.memory_elements_size(offset));
}
void HIPDevice::const_copy_to(const char *name, void *host, size_t size)
void HIPDevice::const_copy_to(const char *name, void *host, const size_t size)
{
HIPContextScope scope(this);
hipDeviceptr_t mem;
@@ -973,7 +974,8 @@ bool HIPDevice::get_device_attribute(hipDeviceAttribute_t attribute, int *value)
return hipDeviceGetAttribute(value, attribute, hipDevice) == hipSuccess;
}
int HIPDevice::get_device_default_attribute(hipDeviceAttribute_t attribute, int default_value)
int HIPDevice::get_device_default_attribute(hipDeviceAttribute_t attribute,
const int default_value)
{
int value = 0;
if (!get_device_attribute(attribute, &value)) {
+4 -3
View File
@@ -72,13 +72,14 @@ class HIPDevice : public GPUDevice {
void mem_copy_to(device_memory &mem) override;
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
void mem_zero(device_memory &mem) override;
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
@@ -100,7 +101,7 @@ class HIPDevice : public GPUDevice {
protected:
bool get_device_attribute(hipDeviceAttribute_t attribute, int *value);
int get_device_default_attribute(hipDeviceAttribute_t attribute, int default_value);
int get_device_default_attribute(hipDeviceAttribute_t attribute, const int default_value);
};
CCL_NAMESPACE_END
+5 -2
View File
@@ -57,7 +57,10 @@ BVHLayoutMask HIPRTDevice::get_bvh_layout_mask(const uint /* kernel_features */)
return BVH_LAYOUT_HIPRT;
}
HIPRTDevice::HIPRTDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
HIPRTDevice::HIPRTDevice(const DeviceInfo &info,
Stats &stats,
Profiler &profiler,
const bool headless)
: HIPDevice(info, stats, profiler, headless),
hiprt_context(nullptr),
scene(nullptr),
@@ -377,7 +380,7 @@ bool HIPRTDevice::load_kernels(const uint kernel_features)
return (result == hipSuccess);
}
void HIPRTDevice::const_copy_to(const char *name, void *host, size_t size)
void HIPRTDevice::const_copy_to(const char *name, void *host, const size_t size)
{
HIPContextScope scope(this);
hipDeviceptr_t mem;
+5 -4
View File
@@ -39,7 +39,7 @@ device_memory::~device_memory()
assert(shared_counter == 0);
}
void *device_memory::host_alloc(size_t size)
void *device_memory::host_alloc(const size_t size)
{
if (!size) {
return nullptr;
@@ -86,7 +86,7 @@ void device_memory::device_copy_to()
}
}
void device_memory::device_copy_from(size_t y, size_t w, size_t h, size_t elem)
void device_memory::device_copy_from(const size_t y, const size_t w, size_t h, const size_t elem)
{
assert(type != MEM_TEXTURE && type != MEM_READ_ONLY && type != MEM_GLOBAL);
device->mem_copy_from(*this, y, w, h, elem);
@@ -105,7 +105,7 @@ bool device_memory::device_is_cpu()
}
void device_memory::swap_device(Device *new_device,
size_t new_device_size,
const size_t new_device_size,
device_ptr new_device_ptr)
{
original_device = device;
@@ -131,7 +131,8 @@ bool device_memory::is_resident(Device *sub_device) const
/* Device Sub `ptr`. */
device_sub_ptr::device_sub_ptr(device_memory &mem, size_t offset, size_t size) : device(mem.device)
device_sub_ptr::device_sub_ptr(device_memory &mem, const size_t offset, const size_t size)
: device(mem.device)
{
ptr = device->mem_alloc_sub_ptr(mem, offset, size);
}
+10 -10
View File
@@ -223,7 +223,7 @@ class device_memory {
{
return data_size * data_elements * datatype_size(data_type);
}
size_t memory_elements_size(int elements)
size_t memory_elements_size(const int elements)
{
return elements * data_elements * datatype_size(data_type);
}
@@ -250,7 +250,7 @@ class device_memory {
virtual ~device_memory();
void swap_device(Device *new_device, size_t new_device_size, device_ptr new_device_ptr);
void swap_device(Device *new_device, const size_t new_device_size, device_ptr new_device_ptr);
void restore_device();
bool is_resident(Device *sub_device) const;
@@ -281,14 +281,14 @@ class device_memory {
/* Host allocation on the device. All host_pointer memory should be
* allocated with these functions, for devices that support using
* the same pointer for host and device. */
void *host_alloc(size_t size);
void *host_alloc(const size_t size);
void host_free();
/* Device memory allocation and copying. */
void device_alloc();
void device_free();
void device_copy_to();
void device_copy_from(size_t y, size_t w, size_t h, size_t elem);
void device_copy_from(const size_t y, const size_t w, size_t h, const size_t elem);
void device_zero();
bool device_is_cpu();
@@ -321,7 +321,7 @@ template<typename T> class device_only_memory : public device_memory {
free();
}
void alloc_to_device(size_t num, bool shrink_to_fit = true)
void alloc_to_device(const size_t num, bool shrink_to_fit = true)
{
size_t new_size = num;
bool reallocate;
@@ -382,7 +382,7 @@ template<typename T> class device_vector : public device_memory {
}
/* Host memory allocation. */
T *alloc(size_t width, size_t height = 0, size_t depth = 0)
T *alloc(const size_t width, const size_t height = 0, const size_t depth = 0)
{
size_t new_size = size(width, height, depth);
@@ -404,7 +404,7 @@ template<typename T> class device_vector : public device_memory {
/* Host memory resize. Only use this if the original data needs to be
* preserved, it is faster to call alloc() if it can be discarded. */
T *resize(size_t width, size_t height = 0, size_t depth = 0)
T *resize(const size_t width, const size_t height = 0, const size_t depth = 0)
{
size_t new_size = size(width, height, depth);
@@ -549,7 +549,7 @@ template<typename T> class device_vector : public device_memory {
device_copy_from(0, data_width, (data_height == 0) ? 1 : data_height, sizeof(T));
}
void copy_from_device(size_t y, size_t w, size_t h)
void copy_from_device(const size_t y, const size_t w, size_t h)
{
device_copy_from(y, w, h, sizeof(T));
}
@@ -568,7 +568,7 @@ template<typename T> class device_vector : public device_memory {
}
protected:
size_t size(size_t width, size_t height, size_t depth)
size_t size(const size_t width, const size_t height, const size_t depth)
{
return width * ((height == 0) ? 1 : height) * ((depth == 0) ? 1 : depth);
}
@@ -585,7 +585,7 @@ template<typename T> class device_vector : public device_memory {
class device_sub_ptr {
public:
device_sub_ptr(device_memory &mem, size_t offset, size_t size);
device_sub_ptr(device_memory &mem, const size_t offset, const size_t size);
~device_sub_ptr();
device_ptr operator*() const
+2 -2
View File
@@ -55,7 +55,7 @@ struct BVHMetalBuildThrottler {
}
/* Block until we're safely able to wire the requested resources. */
void acquire(size_t bytes_to_be_wired)
void acquire(const size_t bytes_to_be_wired)
{
bool throttled = false;
while (true) {
@@ -89,7 +89,7 @@ struct BVHMetalBuildThrottler {
}
/* Notify of resources that have stopped being wired. */
void release(size_t bytes_just_unwired)
void release(const size_t bytes_just_unwired)
{
thread_scoped_lock lock(mutex);
wired_memory -= bytes_just_unwired;
+8 -7
View File
@@ -95,9 +95,9 @@ class MetalDevice : public Device {
static thread_mutex existing_devices_mutex;
static std::map<int, MetalDevice *> active_device_ids;
static bool is_device_cancelled(int device_id);
static bool is_device_cancelled(const int device_id);
static MetalDevice *get_device_by_ID(int device_idID,
static MetalDevice *get_device_by_ID(const int device_idID,
thread_scoped_lock &existing_devices_mutex_lock);
bool is_ready(string &status) const override;
@@ -144,12 +144,12 @@ class MetalDevice : public Device {
void optimize_for_scene(Scene *scene) override;
static void compile_and_load(int device_id, MetalPipelineType pso_type);
static void compile_and_load(const int device_id, MetalPipelineType pso_type);
/* ------------------------------------------------------------------ */
/* low-level memory management */
bool max_working_set_exceeded(size_t safety_margin = 8 * 1024 * 1024) const;
bool max_working_set_exceeded(const size_t safety_margin = 8 * 1024 * 1024) const;
MetalMem *generic_alloc(device_memory &mem);
@@ -165,15 +165,16 @@ class MetalDevice : public Device {
{
mem_copy_from(mem, -1, -1, -1, -1);
}
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
void mem_zero(device_memory &mem) override;
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
void const_copy_to(const char *name, void *host, size_t size) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
void global_alloc(device_memory &mem);
+8 -7
View File
@@ -29,7 +29,7 @@ std::map<int, MetalDevice *> MetalDevice::active_device_ids;
/* Thread-safe device access for async work. Calling code must pass an appropriately scoped lock
* to existing_devices_mutex to safeguard against destruction of the returned instance. */
MetalDevice *MetalDevice::get_device_by_ID(int ID,
MetalDevice *MetalDevice::get_device_by_ID(const int ID,
thread_scoped_lock & /*existing_devices_mutex_lock*/)
{
auto it = active_device_ids.find(ID);
@@ -39,7 +39,7 @@ MetalDevice *MetalDevice::get_device_by_ID(int ID,
return nullptr;
}
bool MetalDevice::is_device_cancelled(int ID)
bool MetalDevice::is_device_cancelled(const int ID)
{
thread_scoped_lock lock(existing_devices_mutex);
return get_device_by_ID(ID, lock) == nullptr;
@@ -495,7 +495,7 @@ void MetalDevice::refresh_source_and_kernels_md5(MetalPipelineType pso_type)
kernels_md5[pso_type] = md5.get_hex();
}
void MetalDevice::compile_and_load(int device_id, MetalPipelineType pso_type)
void MetalDevice::compile_and_load(const int device_id, MetalPipelineType pso_type)
{
@autoreleasepool {
/* Thread-safe front-end compilation. Typically the MSL->AIR compilation can take a few
@@ -663,7 +663,7 @@ void MetalDevice::erase_allocation(device_memory &mem)
}
}
bool MetalDevice::max_working_set_exceeded(size_t safety_margin) const
bool MetalDevice::max_working_set_exceeded(const size_t safety_margin) const
{
/* We're allowed to allocate beyond the safe working set size, but then if all resources are made
* resident we will get command buffer failures at render time. */
@@ -843,7 +843,8 @@ void MetalDevice::mem_copy_to(device_memory &mem)
}
}
void MetalDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)
void MetalDevice::mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem)
{
@autoreleasepool {
if (mem.host_pointer) {
@@ -1002,7 +1003,7 @@ void MetalDevice::optimize_for_scene(Scene *scene)
}
}
void MetalDevice::const_copy_to(const char *name, void *host, size_t size)
void MetalDevice::const_copy_to(const char *name, void *host, const size_t size)
{
if (strcmp(name, "data") == 0) {
assert(size == sizeof(KernelData));
@@ -1016,7 +1017,7 @@ void MetalDevice::const_copy_to(const char *name, void *host, size_t size)
}
auto update_launch_pointers =
[&](size_t offset, void *data, size_t data_size, size_t pointers_size) {
[&](size_t offset, void *data, const size_t data_size, const size_t pointers_size) {
memcpy((uint8_t *)&launch_params + offset, data, data_size);
MetalMem **mmem = (MetalMem **)data;
+4 -3
View File
@@ -97,7 +97,7 @@ class MultiDevice : public Device {
return error_msg;
}
BVHLayoutMask get_bvh_layout_mask(uint kernel_features) const override
BVHLayoutMask get_bvh_layout_mask(const uint kernel_features) const override
{
BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL;
BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE;
@@ -367,7 +367,8 @@ class MultiDevice : public Device {
stats.mem_alloc(mem.device_size - existing_size);
}
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override
{
device_ptr key = mem.device_pointer;
size_t i = 0, sub_h = h / devices.size();
@@ -440,7 +441,7 @@ class MultiDevice : public Device {
stats.mem_free(existing_size);
}
void const_copy_to(const char *name, void *host, size_t size) override
void const_copy_to(const char *name, void *host, const size_t size) override
{
for (SubDevice &sub : devices) {
sub.device->const_copy_to(name, host, size);
+1 -1
View File
@@ -97,7 +97,7 @@ Device *device_oneapi_create(const DeviceInfo &info,
#ifdef WITH_ONEAPI
static void device_iterator_cb(const char *id,
const char *name,
int num,
const int num,
bool hwrt_support,
bool oidn_support,
void *user_ptr)
+23 -15
View File
@@ -151,7 +151,7 @@ bool OneapiDevice::check_peer_access(Device * /*peer_device*/)
return false;
}
bool OneapiDevice::can_use_hardware_raytracing_for_features(uint requested_features) const
bool OneapiDevice::can_use_hardware_raytracing_for_features(const uint requested_features) const
{
/* MNEE and Ray-trace kernels work correctly with Hardware Ray-tracing starting with Embree 4.1.
*/
@@ -163,7 +163,7 @@ bool OneapiDevice::can_use_hardware_raytracing_for_features(uint requested_featu
# endif
}
BVHLayoutMask OneapiDevice::get_bvh_layout_mask(uint requested_features) const
BVHLayoutMask OneapiDevice::get_bvh_layout_mask(const uint requested_features) const
{
return (use_hardware_raytracing &&
can_use_hardware_raytracing_for_features(requested_features)) ?
@@ -309,7 +309,7 @@ void OneapiDevice::get_device_memory_info(size_t &total, size_t &free)
total = max_memory_on_device_;
}
bool OneapiDevice::alloc_device(void *&device_pointer, size_t size)
bool OneapiDevice::alloc_device(void *&device_pointer, const size_t size)
{
bool allocation_success = false;
device_pointer = usm_alloc_device(device_queue_, size);
@@ -335,7 +335,7 @@ void OneapiDevice::free_device(void *device_pointer)
usm_free(device_queue_, device_pointer);
}
bool OneapiDevice::alloc_host(void *&shared_pointer, size_t size)
bool OneapiDevice::alloc_host(void *&shared_pointer, const size_t size)
{
shared_pointer = usm_aligned_alloc_host(device_queue_, size, 64);
return shared_pointer != nullptr;
@@ -353,7 +353,7 @@ void OneapiDevice::transform_host_pointer(void *&device_pointer, void *&shared_p
device_pointer = shared_pointer;
}
void OneapiDevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size)
void OneapiDevice::copy_host_to_device(void *device_pointer, void *host_pointer, const size_t size)
{
usm_memcpy(device_queue_, device_pointer, host_pointer, size);
}
@@ -428,7 +428,8 @@ void OneapiDevice::mem_copy_to(device_memory &mem)
}
}
void OneapiDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)
void OneapiDevice::mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem)
{
if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
@@ -514,13 +515,15 @@ void OneapiDevice::mem_free(device_memory &mem)
}
}
device_ptr OneapiDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/)
device_ptr OneapiDevice::mem_alloc_sub_ptr(device_memory &mem,
const size_t offset,
size_t /*size*/)
{
return reinterpret_cast<device_ptr>(reinterpret_cast<char *>(mem.device_pointer) +
mem.memory_elements_size(offset));
}
void OneapiDevice::const_copy_to(const char *name, void *host, size_t size)
void OneapiDevice::const_copy_to(const char *name, void *host, const size_t size)
{
assert(name);
@@ -623,7 +626,7 @@ bool OneapiDevice::should_use_graphics_interop()
return false;
}
void *OneapiDevice::usm_aligned_alloc_host(size_t memory_size, size_t alignment)
void *OneapiDevice::usm_aligned_alloc_host(const size_t memory_size, const size_t alignment)
{
assert(device_queue_);
return usm_aligned_alloc_host(device_queue_, memory_size, alignment);
@@ -661,7 +664,7 @@ void OneapiDevice::check_usm(SyclQueue *queue_, const void *usm_ptr, bool allow_
}
bool OneapiDevice::create_queue(SyclQueue *&external_queue,
int device_index,
const int device_index,
void *embree_device_pointer)
{
bool finished_correct = true;
@@ -702,7 +705,9 @@ void OneapiDevice::free_queue(SyclQueue *queue_)
delete queue;
}
void *OneapiDevice::usm_aligned_alloc_host(SyclQueue *queue_, size_t memory_size, size_t alignment)
void *OneapiDevice::usm_aligned_alloc_host(SyclQueue *queue_,
size_t memory_size,
const size_t alignment)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
@@ -738,7 +743,7 @@ void OneapiDevice::usm_free(SyclQueue *queue_, void *usm_ptr)
sycl::free(usm_ptr, *queue);
}
bool OneapiDevice::usm_memcpy(SyclQueue *queue_, void *dest, void *src, size_t num_bytes)
bool OneapiDevice::usm_memcpy(SyclQueue *queue_, void *dest, void *src, const size_t num_bytes)
{
assert(queue_);
/* sycl::queue::memcpy may crash if the queue is in an invalid state due to previous
@@ -793,7 +798,7 @@ bool OneapiDevice::usm_memcpy(SyclQueue *queue_, void *dest, void *src, size_t n
bool OneapiDevice::usm_memset(SyclQueue *queue_,
void *usm_ptr,
unsigned char value,
size_t num_bytes)
const size_t num_bytes)
{
assert(queue_);
/* sycl::queue::memset may crash if the queue is in an invalid state due to previous
@@ -881,8 +886,11 @@ void OneapiDevice::set_global_memory(SyclQueue *queue_,
# undef KERNEL_DATA_ARRAY
}
bool OneapiDevice::enqueue_kernel(
KernelContext *kernel_context, int kernel, size_t global_size, size_t local_size, void **args)
bool OneapiDevice::enqueue_kernel(KernelContext *kernel_context,
const int kernel,
const size_t global_size,
const size_t local_size,
void **args)
{
return oneapi_enqueue_kernel(kernel_context,
kernel,
+12 -11
View File
@@ -74,7 +74,8 @@ class OneapiDevice : public GPUDevice {
void mem_copy_to(device_memory &mem) override;
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(
device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
void mem_copy_from(device_memory &mem)
{
@@ -85,7 +86,7 @@ class OneapiDevice : public GPUDevice {
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
@@ -104,7 +105,7 @@ class OneapiDevice : public GPUDevice {
/* NOTE(@nsirgien): Create this methods to avoid some compilation problems on Windows with host
* side compilation (MSVC). */
void *usm_aligned_alloc_host(size_t memory_size, size_t alignment);
void *usm_aligned_alloc_host(const size_t memory_size, const size_t alignment);
void usm_free(void *usm_ptr);
static char *device_capabilities();
@@ -120,9 +121,9 @@ class OneapiDevice : public GPUDevice {
const char *memory_name,
void *memory_device_pointer);
bool enqueue_kernel(KernelContext *kernel_context,
int kernel,
size_t global_size,
size_t local_size,
const int kernel,
const size_t global_size,
const size_t local_size,
void **args);
void get_adjusted_global_and_local_sizes(SyclQueue *queue,
const DeviceKernel kernel,
@@ -133,13 +134,13 @@ class OneapiDevice : public GPUDevice {
protected:
bool can_use_hardware_raytracing_for_features(const uint requested_features) const;
void check_usm(SyclQueue *queue, const void *usm_ptr, bool allow_host);
bool create_queue(SyclQueue *&external_queue, int device_index, void *embree_device);
bool create_queue(SyclQueue *&external_queue, const int device_index, void *embree_device);
void free_queue(SyclQueue *queue);
void *usm_aligned_alloc_host(SyclQueue *queue, size_t memory_size, size_t alignment);
void *usm_alloc_device(SyclQueue *queue, size_t memory_size);
void *usm_aligned_alloc_host(SyclQueue *queue, const size_t memory_size, const size_t alignment);
void *usm_alloc_device(SyclQueue *queue, const size_t memory_size);
void usm_free(SyclQueue *queue, void *usm_ptr);
bool usm_memcpy(SyclQueue *queue, void *dest, void *src, size_t num_bytes);
bool usm_memset(SyclQueue *queue, void *usm_ptr, unsigned char value, size_t num_bytes);
bool usm_memcpy(SyclQueue *queue, void *dest, void *src, const size_t num_bytes);
bool usm_memset(SyclQueue *queue, void *usm_ptr, unsigned char value, const size_t num_bytes);
};
CCL_NAMESPACE_END
+3 -3
View File
@@ -1018,7 +1018,7 @@ void *OptiXDevice::get_cpu_osl_memory()
bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh,
OptixBuildOperation operation,
const OptixBuildInput &build_input,
uint16_t num_motion_steps)
const uint16_t num_motion_steps)
{
/* Allocate and build acceleration structures only one at a time, to prevent parallel builds
* from running out of memory (since both original and compacted acceleration structure memory
@@ -1757,7 +1757,7 @@ void OptiXDevice::free_bvh_memory_delayed()
delayed_free_bvh_memory.free_memory();
}
void OptiXDevice::const_copy_to(const char *name, void *host, size_t size)
void OptiXDevice::const_copy_to(const char *name, void *host, const size_t size)
{
/* Set constant memory for CUDA module. */
CUDADevice::const_copy_to(name, host, size);
@@ -1784,7 +1784,7 @@ void OptiXDevice::const_copy_to(const char *name, void *host, size_t size)
# undef KERNEL_DATA_ARRAY
}
void OptiXDevice::update_launch_params(size_t offset, void *data, size_t data_size)
void OptiXDevice::update_launch_params(const size_t offset, void *data, const size_t data_size)
{
const CUDAContextScope scope(this);
+2 -2
View File
@@ -109,9 +109,9 @@ class OptiXDevice : public CUDADevice {
void release_bvh(BVH *bvh) override;
void free_bvh_memory_delayed();
void const_copy_to(const char *name, void *host, size_t size) override;
void const_copy_to(const char *name, void *host, const size_t size) override;
void update_launch_params(size_t offset, void *data, size_t data_size);
void update_launch_params(const size_t offset, void *data, const size_t data_size);
unique_ptr<DeviceQueue> gpu_queue_create() override;
+1 -1
View File
@@ -65,7 +65,7 @@ struct DeviceKernelArguments {
{
add(FLOAT32, value, sizeof(float));
}
void add(const Type type, const void *value, size_t size)
void add(const Type type, const void *value, const size_t size)
{
assert(count < MAX_ARGS);
+6 -6
View File
@@ -56,37 +56,37 @@ void Node::set(const SocketType &input, bool value)
set_if_different(input, value);
}
void Node::set(const SocketType &input, int value)
void Node::set(const SocketType &input, const int value)
{
assert((input.type == SocketType::INT || input.type == SocketType::ENUM));
set_if_different(input, value);
}
void Node::set(const SocketType &input, uint value)
void Node::set(const SocketType &input, const uint value)
{
assert(input.type == SocketType::UINT);
set_if_different(input, value);
}
void Node::set(const SocketType &input, uint64_t value)
void Node::set(const SocketType &input, const uint64_t value)
{
assert(input.type == SocketType::UINT64);
set_if_different(input, value);
}
void Node::set(const SocketType &input, float value)
void Node::set(const SocketType &input, const float value)
{
assert(input.type == SocketType::FLOAT);
set_if_different(input, value);
}
void Node::set(const SocketType &input, float2 value)
void Node::set(const SocketType &input, const float2 value)
{
assert(input.type == SocketType::POINT2);
set_if_different(input, value);
}
void Node::set(const SocketType &input, float3 value)
void Node::set(const SocketType &input, const float3 value)
{
assert(is_socket_float3(input));
set_if_different(input, value);
+6 -6
View File
@@ -94,12 +94,12 @@ struct Node {
/* set values */
void set(const SocketType &input, bool value);
void set(const SocketType &input, int value);
void set(const SocketType &input, uint value);
void set(const SocketType &input, uint64_t value);
void set(const SocketType &input, float value);
void set(const SocketType &input, float2 value);
void set(const SocketType &input, float3 value);
void set(const SocketType &input, const int value);
void set(const SocketType &input, const uint value);
void set(const SocketType &input, const uint64_t value);
void set(const SocketType &input, const float value);
void set(const SocketType &input, const float2 value);
void set(const SocketType &input, const float3 value);
void set(const SocketType &input, const char *value);
void set(const SocketType &input, ustring value);
void set(const SocketType &input, const Transform &value);
+2 -2
View File
@@ -18,7 +18,7 @@ struct NodeEnum {
{
return left.empty();
}
void insert(const char *x, int y)
void insert(const char *x, const int y)
{
const ustring ustr_x(x);
@@ -30,7 +30,7 @@ struct NodeEnum {
{
return left.find(x) != left.end();
}
bool exists(int y) const
bool exists(const int y) const
{
return right.find(y) != right.end();
}
+3 -3
View File
@@ -144,12 +144,12 @@ NodeType::~NodeType() = default;
void NodeType::register_input(ustring name,
ustring ui_name,
SocketType::Type type,
int struct_offset,
const int struct_offset,
const void *default_value,
const NodeEnum *enum_values,
const NodeType *node_type,
int flags,
int extra_flags)
const int flags,
const int extra_flags)
{
SocketType socket;
socket.name = name;
+1 -1
View File
@@ -105,7 +105,7 @@ struct NodeType {
void register_input(ustring name,
ustring ui_name,
SocketType::Type type,
int struct_offset,
const int struct_offset,
const void *default_value,
const NodeEnum *enum_values = nullptr,
const NodeType *node_type = nullptr,
+1 -1
View File
@@ -42,7 +42,7 @@ static void xml_read_float_array(T &value, xml_attribute attr)
}
}
void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node)
void xml_read_node(XMLReader &reader, Node *node, const xml_node xml_node)
{
const xml_attribute name_attr = xml_node.attribute("name");
if (name_attr) {
+2 -2
View File
@@ -18,8 +18,8 @@ struct XMLReader {
map<ustring, Node *> node_map;
};
void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node);
xml_node xml_write_node(Node *node, xml_node xml_root);
void xml_read_node(XMLReader &reader, Node *node, const xml_node xml_node);
xml_node xml_write_node(Node *node, const xml_node xml_root);
CCL_NAMESPACE_END
+1 -1
View File
@@ -14,7 +14,7 @@
HDCYCLES_NAMESPACE_OPEN_SCOPE
extern Transform convert_transform(const GfMatrix4d &matrix);
Transform convert_camera_transform(const GfMatrix4d &matrix, float metersPerUnit)
Transform convert_camera_transform(const GfMatrix4d &matrix, const float metersPerUnit)
{
Transform t = convert_transform(matrix);
// Flip Z axis
+3 -1
View File
@@ -22,7 +22,9 @@ class HdCyclesDisplayDriver final : public CCL_NS::DisplayDriver {
private:
void next_tile_begin() override;
bool update_begin(const Params &params, int texture_width, int texture_height) override;
bool update_begin(const Params &params,
const int texture_width,
const int texture_height) override;
void update_end() override;
void flush() override;
+1 -1
View File
@@ -47,7 +47,7 @@ template<typename Base, typename CyclesBase> class HdCyclesGeometry : public Bas
private:
void Initialize(PXR_NS::HdRenderParam *renderParam);
void InitializeInstance(int index);
void InitializeInstance(const int index);
PXR_NS::GfMatrix4d _geomTransform;
};
+8 -8
View File
@@ -127,31 +127,31 @@ void HdCyclesRenderBuffer::SetResource(const VtValue &resource)
namespace {
struct SimpleConversion {
static float convert(float value)
static float convert(const float value)
{
return value;
}
};
struct IdConversion {
static int32_t convert(float value)
static int32_t convert(const float value)
{
return static_cast<int32_t>(value) - 1;
}
};
struct UInt8Conversion {
static uint8_t convert(float value)
static uint8_t convert(const float value)
{
return static_cast<uint8_t>(value * 255.f);
}
};
struct SInt8Conversion {
static int8_t convert(float value)
static int8_t convert(const float value)
{
return static_cast<int8_t>(value * 127.f);
}
};
struct HalfConversion {
static half convert(float value)
static half convert(const float value)
{
return float_to_half_image(value);
}
@@ -160,10 +160,10 @@ struct HalfConversion {
template<typename SrcT, typename DstT, typename Convertor = SimpleConversion>
void writePixels(const SrcT *srcPtr,
const GfVec2i &srcSize,
int srcChannelCount,
const int srcChannelCount,
DstT *dstPtr,
const GfVec2i &dstSize,
int dstChannelCount,
const int dstChannelCount,
const Convertor &convertor = {})
{
const auto writeSize = GfVec2i(GfMin(srcSize[0], dstSize[0]), GfMin(srcSize[1], dstSize[1]));
@@ -185,7 +185,7 @@ void writePixels(const SrcT *srcPtr,
void HdCyclesRenderBuffer::WritePixels(const float *srcPixels,
const PXR_NS::GfVec2i &srcOffset,
const GfVec2i &srcDims,
int srcChannels,
const int srcChannels,
bool isId)
{
uint8_t *dstPixels = _data.data();
+1 -1
View File
@@ -68,7 +68,7 @@ class HdCyclesRenderBuffer final : public PXR_NS::HdRenderBuffer {
void WritePixels(const float *pixels,
const PXR_NS::GfVec2i &offset,
const PXR_NS::GfVec2i &dims,
int channels,
const int channels,
bool isId = false);
private:
+1 -1
View File
@@ -35,7 +35,7 @@ class HdCyclesSession final : public PXR_NS::HdRenderParam {
return _stageMetersPerUnit;
}
void SetStageMetersPerUnit(double stageMetersPerUnit)
void SetStageMetersPerUnit(const double stageMetersPerUnit)
{
_stageMetersPerUnit = stageMetersPerUnit;
}
@@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN
AdaptiveSampling::AdaptiveSampling() = default;
int AdaptiveSampling::align_samples(int start_sample, int num_samples) const
int AdaptiveSampling::align_samples(const int start_sample, const int num_samples) const
{
if (!use) {
return num_samples;
@@ -41,7 +41,7 @@ int AdaptiveSampling::align_samples(int start_sample, int num_samples) const
return min(num_samples_until_filter, num_samples);
}
bool AdaptiveSampling::need_filter(int sample) const
bool AdaptiveSampling::need_filter(const int sample) const
{
if (!use) {
return false;
+2 -2
View File
@@ -26,13 +26,13 @@ class AdaptiveSampling {
* if the number of samples is 1, then the path tracer will render samples [align_samples],
* if the number of samples is 2, then the path tracer will render samples [align_samples,
* align_samples + 1] and so on. */
int align_samples(int start_sample, int num_samples) const;
int align_samples(const int start_sample, const int num_samples) const;
/* Check whether adaptive sampling filter should happen at this sample.
* Returns false if the adaptive sampling is not use.
*
* `sample` is the 0-based index of sample. */
bool need_filter(int sample) const;
bool need_filter(const int sample) const;
bool use = false;
int adaptive_step = 0;
@@ -492,12 +492,12 @@ bool OIDNDenoiserGPU::denoise_run(const DenoiseContext &context, const DenoisePa
void OIDNDenoiserGPU::set_filter_pass(OIDNFilter filter,
const char *name,
device_ptr ptr,
int format,
int width,
int height,
size_t offset_in_bytes,
size_t pixel_stride_in_bytes,
size_t row_stride_in_bytes)
const int format,
const int width,
const int height,
const size_t offset_in_bytes,
const size_t pixel_stride_in_bytes,
const size_t row_stride_in_bytes)
{
# if defined(OIDN_DEVICE_METAL) && defined(WITH_METAL)
if (denoiser_device_->info.type == DEVICE_METAL) {
+5 -5
View File
@@ -55,11 +55,11 @@ class OIDNDenoiserGPU : public DenoiserGPU {
void set_filter_pass(OIDNFilter filter,
const char *name,
device_ptr ptr,
int format,
int width,
int height,
size_t offset_in_bytes,
size_t pixel_stride_in_bytes,
const int format,
const int width,
const int height,
const size_t offset_in_bytes,
const size_t pixel_stride_in_bytes,
size_t row_stride_in_bytes);
/* Delete all allocated OIDN objects. */
+2 -2
View File
@@ -89,12 +89,12 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser,
CUstream stream,
const OptixDenoiserParams *params,
CUdeviceptr denoiserState,
size_t denoiserStateSizeInBytes,
const size_t denoiserStateSizeInBytes,
const OptixDenoiserGuideLayer *guideLayer,
const OptixDenoiserLayer *layers,
unsigned int numLayers,
CUdeviceptr scratch,
size_t scratchSizeInBytes,
const size_t scratchSizeInBytes,
unsigned int overlapWindowSizeInPixels,
unsigned int tileWidth,
unsigned int tileHeight)
+5 -3
View File
@@ -27,7 +27,7 @@ PassAccessor::PassAccessInfo::PassAccessInfo(const BufferPass &pass)
* Pass destination.
*/
PassAccessor::Destination::Destination(float *pixels, int num_components)
PassAccessor::Destination::Destination(float *pixels, const int num_components)
: pixels(pixels), num_components(num_components)
{
}
@@ -48,7 +48,7 @@ PassAccessor::Destination::Destination(const PassType pass_type)
* Pass source.
*/
PassAccessor::Source::Source(const float *pixels, int num_components)
PassAccessor::Source::Source(const float *pixels, const int num_components)
: pixels(pixels), num_components(num_components)
{
}
@@ -57,7 +57,9 @@ PassAccessor::Source::Source(const float *pixels, int num_components)
* Pass accessor.
*/
PassAccessor::PassAccessor(const PassAccessInfo &pass_access_info, float exposure, int num_samples)
PassAccessor::PassAccessor(const PassAccessInfo &pass_access_info,
const float exposure,
const int num_samples)
: pass_access_info_(pass_access_info), exposure_(exposure), num_samples_(num_samples)
{
}
+5 -3
View File
@@ -44,7 +44,7 @@ class PassAccessor {
class Destination {
public:
Destination() = default;
Destination(float *pixels, int num_components);
Destination(float *pixels, const int num_components);
Destination(const PassType pass_type, half4 *pixels);
/* Destination will be initialized with the number of components which is native for the given
@@ -86,7 +86,7 @@ class PassAccessor {
class Source {
public:
Source() = default;
Source(const float *pixels, int num_components);
Source(const float *pixels, const int num_components);
/* CPU-side pointers. only usable by the `PassAccessorCPU`. */
const float *pixels = nullptr;
@@ -97,7 +97,9 @@ class PassAccessor {
int offset = 0;
};
PassAccessor(const PassAccessInfo &pass_access_info, float exposure, int num_samples);
PassAccessor(const PassAccessInfo &pass_access_info,
const float exposure,
const int num_samples);
virtual ~PassAccessor() = default;
@@ -12,8 +12,8 @@ CCL_NAMESPACE_BEGIN
PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue,
const PassAccessInfo &pass_access_info,
float exposure,
int num_samples)
const float exposure,
const int num_samples)
: PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
{
}
+1 -1
View File
@@ -17,7 +17,7 @@ class PassAccessorGPU : public PassAccessor {
public:
PassAccessorGPU(DeviceQueue *queue,
const PassAccessInfo &pass_access_info,
float exposure,
const float exposure,
int num_samples);
protected:
+1 -1
View File
@@ -304,7 +304,7 @@ void PathTrace::update_allocated_work_buffer_params()
});
}
static BufferParams scale_buffer_params(const BufferParams &params, int resolution_divider)
static BufferParams scale_buffer_params(const BufferParams &params, const int resolution_divider)
{
BufferParams scaled_params = params;
@@ -39,7 +39,7 @@ void PathTraceDisplay::mark_texture_updated()
* Update procedure.
*/
bool PathTraceDisplay::update_begin(int texture_width, int texture_height)
bool PathTraceDisplay::update_begin(const int texture_width, const int texture_height)
{
DCHECK(!update_state_.is_active);
@@ -91,8 +91,11 @@ int2 PathTraceDisplay::get_texture_size() const
* Texture update from CPU buffer.
*/
void PathTraceDisplay::copy_pixels_to_texture(
const half4 *rgba_pixels, int texture_x, int texture_y, int pixels_width, int pixels_height)
void PathTraceDisplay::copy_pixels_to_texture(const half4 *rgba_pixels,
const int texture_x,
const int texture_y,
const int pixels_width,
const int pixels_height)
{
DCHECK(update_state_.is_active);
@@ -47,7 +47,7 @@ class PathTraceDisplay {
* If false is returned then no update is possible, and no update_end() call is needed.
*
* The texture width and height denotes an actual resolution of the underlying render result. */
bool update_begin(int texture_width, int texture_height);
bool update_begin(const int texture_width, const int texture_height);
void update_end();
@@ -70,8 +70,11 @@ class PathTraceDisplay {
* for partial updates from different devices. In this case the caller will acquire the lock
* once, update all the slices and release
* the lock once. This will ensure that draw() will never use partially updated texture. */
void copy_pixels_to_texture(
const half4 *rgba_pixels, int texture_x, int texture_y, int pixels_width, int pixels_height);
void copy_pixels_to_texture(const half4 *rgba_pixels,
const int texture_x,
const int texture_y,
const int pixels_width,
const int pixels_height);
/* --------------------------------------------------------------------
* Texture buffer mapping.
+7 -4
View File
@@ -63,8 +63,8 @@ class PathTraceWork {
/* Render given number of samples as a synchronous blocking call.
* The samples are added to the render buffer associated with this work. */
virtual void render_samples(RenderStatistics &statistics,
int start_sample,
int samples_num,
const int start_sample,
const int samples_num,
int sample_offset) = 0;
/* Copy render result from this work to the corresponding place of the GPU display.
@@ -73,7 +73,9 @@ class PathTraceWork {
* noisy pass mode will be passed here when it is known that the buffer does not have denoised
* passes yet (because denoiser did not run). If the denoised pass is requested and denoiser is
* not used then this function will fall-back to the noisy pass instead. */
virtual void copy_to_display(PathTraceDisplay *display, PassMode pass_mode, int num_samples) = 0;
virtual void copy_to_display(PathTraceDisplay *display,
PassMode pass_mode,
const int num_samples) = 0;
virtual void destroy_gpu_resources(PathTraceDisplay *display) = 0;
@@ -120,7 +122,8 @@ class PathTraceWork {
/* Perform convergence test on the render buffer, and filter the convergence mask.
* Returns number of active pixels (the ones which did not converge yet). */
virtual int adaptive_sampling_converge_filter_count_active(float threshold, bool reset) = 0;
virtual int adaptive_sampling_converge_filter_count_active(const float threshold,
bool reset) = 0;
/* Run cryptomatte pass post-processing kernels. */
virtual void cryptomatte_postproces() = 0;
@@ -56,9 +56,9 @@ void PathTraceWorkCPU::init_execution()
}
void PathTraceWorkCPU::render_samples(RenderStatistics &statistics,
int start_sample,
int samples_num,
int sample_offset)
const int start_sample,
const int samples_num,
const int sample_offset)
{
const int64_t image_width = effective_buffer_params_.width;
const int64_t image_height = effective_buffer_params_.height;
@@ -163,7 +163,7 @@ void PathTraceWorkCPU::render_samples_full_pipeline(KernelGlobalsCPU *kernel_glo
void PathTraceWorkCPU::copy_to_display(PathTraceDisplay *display,
PassMode pass_mode,
int num_samples)
const int num_samples)
{
half4 *rgba_half = display->map_texture_buffer();
if (!rgba_half) {
@@ -211,7 +211,8 @@ bool PathTraceWorkCPU::zero_render_buffers()
return true;
}
int PathTraceWorkCPU::adaptive_sampling_converge_filter_count_active(float threshold, bool reset)
int PathTraceWorkCPU::adaptive_sampling_converge_filter_count_active(const float threshold,
bool reset)
{
const int full_x = effective_buffer_params_.full_x;
const int full_y = effective_buffer_params_.full_y;
@@ -36,18 +36,20 @@ class PathTraceWorkCPU : public PathTraceWork {
void init_execution() override;
void render_samples(RenderStatistics &statistics,
int start_sample,
int samples_num,
const int start_sample,
const int samples_num,
int sample_offset) override;
void copy_to_display(PathTraceDisplay *display, PassMode pass_mode, int num_samples) override;
void copy_to_display(PathTraceDisplay *display,
PassMode pass_mode,
const int num_samples) override;
void destroy_gpu_resources(PathTraceDisplay *display) override;
bool copy_render_buffers_from_device() override;
bool copy_render_buffers_to_device() override;
bool zero_render_buffers() override;
int adaptive_sampling_converge_filter_count_active(float threshold, bool reset) override;
int adaptive_sampling_converge_filter_count_active(const float threshold, bool reset) override;
void cryptomatte_postproces() override;
#ifdef WITH_PATH_GUIDING
@@ -337,9 +337,9 @@ void PathTraceWorkGPU::init_execution()
}
void PathTraceWorkGPU::render_samples(RenderStatistics &statistics,
int start_sample,
int samples_num,
int sample_offset)
const int start_sample,
const int samples_num,
const int sample_offset)
{
/* Limit number of states for the tile and rely on a greedy scheduling of tiles. This allows to
* add more work (because tiles are smaller, so there is higher chance that more paths will
@@ -965,7 +965,7 @@ bool PathTraceWorkGPU::should_use_graphics_interop()
void PathTraceWorkGPU::copy_to_display(PathTraceDisplay *display,
PassMode pass_mode,
int num_samples)
const int num_samples)
{
if (device_->have_error()) {
/* Don't attempt to update GPU display if the device has errors: the error state will make
@@ -993,7 +993,7 @@ void PathTraceWorkGPU::copy_to_display(PathTraceDisplay *display,
void PathTraceWorkGPU::copy_to_display_naive(PathTraceDisplay *display,
PassMode pass_mode,
int num_samples)
const int num_samples)
{
const int full_x = effective_buffer_params_.full_x;
const int full_y = effective_buffer_params_.full_y;
@@ -1034,7 +1034,7 @@ void PathTraceWorkGPU::copy_to_display_naive(PathTraceDisplay *display,
bool PathTraceWorkGPU::copy_to_display_interop(PathTraceDisplay *display,
PassMode pass_mode,
int num_samples)
const int num_samples)
{
if (!device_graphics_interop_) {
device_graphics_interop_ = queue_->graphics_interop_create();
@@ -1070,7 +1070,7 @@ void PathTraceWorkGPU::destroy_gpu_resources(PathTraceDisplay *display)
void PathTraceWorkGPU::get_render_tile_film_pixels(const PassAccessor::Destination &destination,
PassMode pass_mode,
int num_samples)
const int num_samples)
{
const KernelFilm &kfilm = device_scene_->data.film;
@@ -1084,7 +1084,8 @@ void PathTraceWorkGPU::get_render_tile_film_pixels(const PassAccessor::Destinati
pass_accessor.get_render_tile_pixels(buffers_.get(), effective_buffer_params_, destination);
}
int PathTraceWorkGPU::adaptive_sampling_converge_filter_count_active(float threshold, bool reset)
int PathTraceWorkGPU::adaptive_sampling_converge_filter_count_active(const float threshold,
bool reset)
{
const int num_active_pixels = adaptive_sampling_convergence_check_count_active(threshold, reset);
@@ -1097,7 +1098,8 @@ int PathTraceWorkGPU::adaptive_sampling_converge_filter_count_active(float thres
return num_active_pixels;
}
int PathTraceWorkGPU::adaptive_sampling_convergence_check_count_active(float threshold, bool reset)
int PathTraceWorkGPU::adaptive_sampling_convergence_check_count_active(const float threshold,
bool reset)
{
device_vector<uint> num_active_pixels(device_, "num_active_pixels", MEM_READ_WRITE);
num_active_pixels.alloc(1);
+11 -7
View File
@@ -33,18 +33,20 @@ class PathTraceWorkGPU : public PathTraceWork {
void init_execution() override;
void render_samples(RenderStatistics &statistics,
int start_sample,
int samples_num,
const int start_sample,
const int samples_num,
int sample_offset) override;
void copy_to_display(PathTraceDisplay *display, PassMode pass_mode, int num_samples) override;
void copy_to_display(PathTraceDisplay *display,
PassMode pass_mode,
const int num_samples) override;
void destroy_gpu_resources(PathTraceDisplay *display) override;
bool copy_render_buffers_from_device() override;
bool copy_render_buffers_to_device() override;
bool zero_render_buffers() override;
int adaptive_sampling_converge_filter_count_active(float threshold, bool reset) override;
int adaptive_sampling_converge_filter_count_active(const float threshold, bool reset) override;
void cryptomatte_postproces() override;
protected:
@@ -86,18 +88,20 @@ class PathTraceWorkGPU : public PathTraceWork {
/* Naive implementation of the `copy_to_display()` which performs film conversion on the
* device, then copies pixels to the host and pushes them to the `display`. */
void copy_to_display_naive(PathTraceDisplay *display, PassMode pass_mode, int num_samples);
void copy_to_display_naive(PathTraceDisplay *display, PassMode pass_mode, const int num_samples);
/* Implementation of `copy_to_display()` which uses driver's OpenGL/GPU interoperability
* functionality, avoiding copy of pixels to the host. */
bool copy_to_display_interop(PathTraceDisplay *display, PassMode pass_mode, int num_samples);
bool copy_to_display_interop(PathTraceDisplay *display,
PassMode pass_mode,
const int num_samples);
/* Synchronously run film conversion kernel and store display result in the given destination. */
void get_render_tile_film_pixels(const PassAccessor::Destination &destination,
PassMode pass_mode,
int num_samples);
int adaptive_sampling_convergence_check_count_active(float threshold, bool reset);
int adaptive_sampling_convergence_check_count_active(const float threshold, bool reset);
void enqueue_adaptive_sampling_filter_x();
void enqueue_adaptive_sampling_filter_y();
+22 -16
View File
@@ -66,7 +66,7 @@ bool RenderScheduler::is_adaptive_sampling_used() const
return adaptive_sampling_.use;
}
void RenderScheduler::set_start_sample(int start_sample)
void RenderScheduler::set_start_sample(const int start_sample)
{
start_sample_ = start_sample;
}
@@ -76,7 +76,7 @@ int RenderScheduler::get_start_sample() const
return start_sample_;
}
void RenderScheduler::set_num_samples(int num_samples)
void RenderScheduler::set_num_samples(const int num_samples)
{
num_samples_ = num_samples;
}
@@ -86,7 +86,7 @@ int RenderScheduler::get_num_samples() const
return num_samples_;
}
void RenderScheduler::set_sample_offset(int sample_offset)
void RenderScheduler::set_sample_offset(const int sample_offset)
{
sample_offset_ = sample_offset;
}
@@ -96,7 +96,7 @@ int RenderScheduler::get_sample_offset() const
return sample_offset_;
}
void RenderScheduler::set_time_limit(double time_limit)
void RenderScheduler::set_time_limit(const double time_limit)
{
time_limit_ = time_limit;
}
@@ -118,7 +118,9 @@ int RenderScheduler::get_num_rendered_samples() const
return state_.num_rendered_samples;
}
void RenderScheduler::reset(const BufferParams &buffer_params, int num_samples, int sample_offset)
void RenderScheduler::reset(const BufferParams &buffer_params,
const int num_samples,
const int sample_offset)
{
buffer_params_ = buffer_params;
@@ -453,7 +455,7 @@ void RenderScheduler::set_full_frame_render_work(RenderWork *render_work)
/* Knowing time which it took to complete a task at the current resolution divider approximate how
* long it would have taken to complete it at a final resolution. */
static double approximate_final_time(const RenderWork &render_work, double time)
static double approximate_final_time(const RenderWork &render_work, const double time)
{
if (render_work.resolution_divider == 1) {
return time;
@@ -480,7 +482,7 @@ void RenderScheduler::report_work_begin(const RenderWork &render_work)
}
void RenderScheduler::report_path_trace_time(const RenderWork &render_work,
double time,
const double time,
bool is_cancelled)
{
path_trace_time_.add_wall(time);
@@ -505,7 +507,8 @@ void RenderScheduler::report_path_trace_time(const RenderWork &render_work,
VLOG_WORK << "Average path tracing time: " << path_trace_time_.get_average() << " seconds.";
}
void RenderScheduler::report_path_trace_occupancy(const RenderWork &render_work, float occupancy)
void RenderScheduler::report_path_trace_occupancy(const RenderWork &render_work,
const float occupancy)
{
state_.occupancy_num_samples = render_work.path_trace.num_samples;
state_.occupancy = occupancy;
@@ -513,7 +516,7 @@ void RenderScheduler::report_path_trace_occupancy(const RenderWork &render_work,
}
void RenderScheduler::report_adaptive_filter_time(const RenderWork &render_work,
double time,
const double time,
bool is_cancelled)
{
adaptive_filter_time_.add_wall(time);
@@ -534,7 +537,7 @@ void RenderScheduler::report_adaptive_filter_time(const RenderWork &render_work,
<< " seconds.";
}
void RenderScheduler::report_denoise_time(const RenderWork &render_work, double time)
void RenderScheduler::report_denoise_time(const RenderWork &render_work, const double time)
{
denoise_time_.add_wall(time);
@@ -553,7 +556,7 @@ void RenderScheduler::report_denoise_time(const RenderWork &render_work, double
VLOG_WORK << "Average denoising time: " << denoise_time_.get_average() << " seconds.";
}
void RenderScheduler::report_display_update_time(const RenderWork &render_work, double time)
void RenderScheduler::report_display_update_time(const RenderWork &render_work, const double time)
{
display_update_time_.add_wall(time);
@@ -579,7 +582,7 @@ void RenderScheduler::report_display_update_time(const RenderWork &render_work,
}
void RenderScheduler::report_rebalance_time(const RenderWork &render_work,
double time,
const double time,
bool balance_changed)
{
rebalance_time_.add_wall(time);
@@ -934,7 +937,7 @@ int RenderScheduler::get_num_samples_to_path_trace() const
num_samples_to_render);
}
int RenderScheduler::get_num_samples_during_navigation(int resolution_divider) const
int RenderScheduler::get_num_samples_during_navigation(const int resolution_divider) const
{
/* Special trick for fast navigation: schedule multiple samples during fast navigation
* (which will prefer to use lower resolution to keep up with refresh rate). This gives more
@@ -1233,7 +1236,8 @@ void RenderScheduler::check_time_limit_reached()
* Utility functions.
*/
int RenderScheduler::calculate_resolution_divider_for_time(double desired_time, double actual_time)
int RenderScheduler::calculate_resolution_divider_for_time(const double desired_time,
const double actual_time)
{
const double ratio_between_times = actual_time / desired_time;
@@ -1255,7 +1259,7 @@ int RenderScheduler::calculate_resolution_divider_for_time(double desired_time,
return ceil_to_int(sqrt(navigation_samples * ratio_between_times));
}
int calculate_resolution_divider_for_resolution(int width, int height, int resolution)
int calculate_resolution_divider_for_resolution(int width, int height, const int resolution)
{
if (resolution == INT_MAX) {
return 1;
@@ -1272,7 +1276,9 @@ int calculate_resolution_divider_for_resolution(int width, int height, int resol
return resolution_divider;
}
int calculate_resolution_for_divider(int width, int height, int resolution_divider)
int calculate_resolution_for_divider(const int width,
const int height,
const int resolution_divider)
{
const int pixel_area = width * height;
const int resolution = lround(sqrt(pixel_area));
+27 -18
View File
@@ -108,21 +108,21 @@ class RenderScheduler {
/* Start sample for path tracing.
* The scheduler will schedule work using this sample as the first one. */
void set_start_sample(int start_sample);
void set_start_sample(const int start_sample);
int get_start_sample() const;
/* Number of samples to render, starting from start sample.
* The scheduler will schedule work in the range of
* [start_sample, start_sample + num_samples - 1], inclusively. */
void set_num_samples(int num_samples);
void set_num_samples(const int num_samples);
int get_num_samples() const;
void set_sample_offset(int sample_offset);
void set_sample_offset(const int sample_offset);
int get_sample_offset() const;
/* Time limit for the path tracing tasks, in minutes.
* Zero disables the limit. */
void set_time_limit(double time_limit);
void set_time_limit(const double time_limit);
double get_time_limit() const;
/* Get sample up to which rendering has been done.
@@ -145,7 +145,7 @@ class RenderScheduler {
/* Reset scheduler, indicating that rendering will happen from scratch.
* Resets current rendered state, as well as scheduling information. */
void reset(const BufferParams &buffer_params, int num_samples, int sample_offset);
void reset(const BufferParams &buffer_params, const int num_samples, const int sample_offset);
/* Reset scheduler upon switching to a next tile.
* Will keep the same number of samples and full-frame render parameters, but will reset progress
@@ -180,12 +180,16 @@ class RenderScheduler {
void report_work_begin(const RenderWork &render_work);
/* Report time (in seconds) which corresponding part of work took. */
void report_path_trace_time(const RenderWork &render_work, double time, bool is_cancelled);
void report_path_trace_occupancy(const RenderWork &render_work, float occupancy);
void report_adaptive_filter_time(const RenderWork &render_work, double time, bool is_cancelled);
void report_denoise_time(const RenderWork &render_work, double time);
void report_display_update_time(const RenderWork &render_work, double time);
void report_rebalance_time(const RenderWork &render_work, double time, bool balance_changed);
void report_path_trace_time(const RenderWork &render_work, const double time, bool is_cancelled);
void report_path_trace_occupancy(const RenderWork &render_work, const float occupancy);
void report_adaptive_filter_time(const RenderWork &render_work,
const double time,
bool is_cancelled);
void report_denoise_time(const RenderWork &render_work, const double time);
void report_display_update_time(const RenderWork &render_work, const double time);
void report_rebalance_time(const RenderWork &render_work,
const double time,
bool balance_changed);
/* Generate full multi-line report of the rendering process, including rendering parameters,
* times, and so on. */
@@ -228,7 +232,8 @@ class RenderScheduler {
* number of samples and later in the render, updates happen less often but device occupancy
* goes higher. */
double guess_display_update_interval_in_seconds() const;
double guess_display_update_interval_in_seconds_for_num_samples(int num_rendered_samples) const;
double guess_display_update_interval_in_seconds_for_num_samples(
const int num_rendered_samples) const;
double guess_display_update_interval_in_seconds_for_num_samples_no_limit(
int num_rendered_samples) const;
@@ -242,7 +247,7 @@ class RenderScheduler {
/* Calculate how many samples there are to be rendered for the very first path trace after reset.
*/
int get_num_samples_during_navigation(int resolution_divider) const;
int get_num_samples_during_navigation(const int resolution_divider) const;
/* Whether adaptive sampling convergence check and filter is to happen. */
bool work_need_adaptive_filter() const;
@@ -300,12 +305,12 @@ class RenderScheduler {
last_sample_time_ = 0.0;
}
void add_wall(double time)
void add_wall(const double time)
{
total_wall_time_ += time;
}
void add_average(double time, int num_measurements = 1)
void add_average(const double time, const int num_measurements = 1)
{
average_time_accumulator_ += time;
num_average_times_ += num_measurements;
@@ -467,15 +472,19 @@ class RenderScheduler {
* desired one. This call assumes linear dependency of render time from number of pixels
* (quadratic dependency from the resolution divider): resolution divider of 2 brings render time
* down by a factor of 4. */
int calculate_resolution_divider_for_time(double desired_time, double actual_time);
int calculate_resolution_divider_for_time(const double desired_time, const double actual_time);
/* If the number of samples per rendering progression should be limited because of path guiding
* being activated or is still inside its training phase */
int limit_samples_per_update_ = 0;
};
int calculate_resolution_divider_for_resolution(int width, int height, int resolution);
int calculate_resolution_divider_for_resolution(const int width,
const int height,
const int resolution);
int calculate_resolution_for_divider(int width, int height, int resolution_divider);
int calculate_resolution_for_divider(const int width,
const int height,
const int resolution_divider);
CCL_NAMESPACE_END
+2 -2
View File
@@ -18,7 +18,7 @@ std::ostream &operator<<(std::ostream &os, const TileSize &tile_size)
return os;
}
ccl_device_inline uint round_down_to_power_of_two(uint x)
ccl_device_inline uint round_down_to_power_of_two(const uint x)
{
if (is_power_of_two(x)) {
return x;
@@ -27,7 +27,7 @@ ccl_device_inline uint round_down_to_power_of_two(uint x)
return prev_power_of_two(x);
}
ccl_device_inline uint round_up_to_power_of_two(uint x)
ccl_device_inline uint round_up_to_power_of_two(const uint x)
{
if (is_power_of_two(x)) {
return x;

Some files were not shown because too many files have changed in this diff Show More