From 57ff24cb99b1d6495e700ee67db730e6d98458c4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 1 Jan 2025 18:15:54 +0100 Subject: [PATCH] Refactor: Cycles: Add const keyword to more function parameters Pull Request: https://projects.blender.org/blender/blender/pulls/132361 --- intern/cycles/app/cycles_precompute.cpp | 50 ++- intern/cycles/app/cycles_standalone.cpp | 10 +- intern/cycles/app/cycles_xml.cpp | 40 +-- intern/cycles/app/opengl/display_driver.cpp | 4 +- intern/cycles/app/opengl/display_driver.h | 6 +- intern/cycles/app/opengl/shader.cpp | 2 +- intern/cycles/app/opengl/shader.h | 2 +- intern/cycles/app/opengl/window.cpp | 10 +- intern/cycles/app/opengl/window.h | 4 +- intern/cycles/blender/CCL_api.h | 2 +- intern/cycles/blender/camera.cpp | 50 +-- intern/cycles/blender/curves.cpp | 30 +- intern/cycles/blender/display_driver.cpp | 12 +- intern/cycles/blender/display_driver.h | 12 +- intern/cycles/blender/geometry.cpp | 2 +- intern/cycles/blender/light.cpp | 2 +- intern/cycles/blender/logging.cpp | 2 +- intern/cycles/blender/mesh.cpp | 6 +- intern/cycles/blender/object.cpp | 8 +- intern/cycles/blender/object_cull.cpp | 4 +- intern/cycles/blender/object_cull.h | 4 +- intern/cycles/blender/pointcloud.cpp | 4 +- intern/cycles/blender/session.cpp | 6 +- intern/cycles/blender/session.h | 4 +- intern/cycles/blender/shader.cpp | 2 +- intern/cycles/blender/sync.cpp | 4 +- intern/cycles/blender/sync.h | 54 ++-- intern/cycles/blender/util.h | 34 +- intern/cycles/blender/volume.cpp | 2 +- intern/cycles/bvh/binning.h | 2 +- intern/cycles/bvh/build.cpp | 33 +- intern/cycles/bvh/build.h | 33 +- intern/cycles/bvh/bvh2.cpp | 10 +- intern/cycles/bvh/bvh2.h | 14 +- intern/cycles/bvh/embree.cpp | 12 +- intern/cycles/bvh/embree.h | 11 +- intern/cycles/bvh/node.cpp | 6 +- intern/cycles/bvh/node.h | 14 +- intern/cycles/bvh/params.h | 16 +- intern/cycles/bvh/sort.cpp | 8 +- intern/cycles/bvh/sort.h | 6 +- intern/cycles/bvh/split.cpp | 47 +-- intern/cycles/bvh/split.h | 47 +-- intern/cycles/cmake/zstd_compress.cpp | 2 +- intern/cycles/device/cpu/device_impl.cpp | 4 +- intern/cycles/device/cpu/device_impl.h | 7 +- intern/cycles/device/cpu/kernel.h | 28 +- intern/cycles/device/cuda/device_impl.cpp | 15 +- intern/cycles/device/cuda/device_impl.h | 7 +- intern/cycles/device/device.cpp | 12 +- intern/cycles/device/device.h | 27 +- intern/cycles/device/hip/device.cpp | 5 +- intern/cycles/device/hip/device_impl.cpp | 16 +- intern/cycles/device/hip/device_impl.h | 7 +- intern/cycles/device/hiprt/device_impl.cpp | 7 +- intern/cycles/device/memory.cpp | 9 +- intern/cycles/device/memory.h | 20 +- intern/cycles/device/metal/bvh.mm | 4 +- intern/cycles/device/metal/device_impl.h | 15 +- intern/cycles/device/metal/device_impl.mm | 15 +- intern/cycles/device/multi/device.cpp | 7 +- intern/cycles/device/oneapi/device.cpp | 2 +- intern/cycles/device/oneapi/device_impl.cpp | 38 ++- intern/cycles/device/oneapi/device_impl.h | 23 +- intern/cycles/device/optix/device_impl.cpp | 6 +- intern/cycles/device/optix/device_impl.h | 4 +- intern/cycles/device/queue.h | 2 +- intern/cycles/graph/node.cpp | 12 +- intern/cycles/graph/node.h | 12 +- intern/cycles/graph/node_enum.h | 4 +- intern/cycles/graph/node_type.cpp | 6 +- intern/cycles/graph/node_type.h | 2 +- intern/cycles/graph/node_xml.cpp | 2 +- intern/cycles/graph/node_xml.h | 4 +- intern/cycles/hydra/camera.cpp | 2 +- intern/cycles/hydra/display_driver.h | 4 +- intern/cycles/hydra/geometry.h | 2 +- intern/cycles/hydra/render_buffer.cpp | 16 +- intern/cycles/hydra/render_buffer.h | 2 +- intern/cycles/hydra/session.h | 2 +- .../cycles/integrator/adaptive_sampling.cpp | 4 +- intern/cycles/integrator/adaptive_sampling.h | 4 +- .../cycles/integrator/denoiser_oidn_gpu.cpp | 12 +- intern/cycles/integrator/denoiser_oidn_gpu.h | 10 +- intern/cycles/integrator/denoiser_optix.cpp | 4 +- intern/cycles/integrator/pass_accessor.cpp | 8 +- intern/cycles/integrator/pass_accessor.h | 8 +- .../cycles/integrator/pass_accessor_gpu.cpp | 4 +- intern/cycles/integrator/pass_accessor_gpu.h | 2 +- intern/cycles/integrator/path_trace.cpp | 2 +- .../cycles/integrator/path_trace_display.cpp | 9 +- intern/cycles/integrator/path_trace_display.h | 9 +- intern/cycles/integrator/path_trace_work.h | 11 +- .../cycles/integrator/path_trace_work_cpu.cpp | 11 +- .../cycles/integrator/path_trace_work_cpu.h | 10 +- .../cycles/integrator/path_trace_work_gpu.cpp | 20 +- .../cycles/integrator/path_trace_work_gpu.h | 18 +- intern/cycles/integrator/render_scheduler.cpp | 38 ++- intern/cycles/integrator/render_scheduler.h | 45 +-- intern/cycles/integrator/tile.cpp | 4 +- intern/cycles/integrator/tile.h | 2 +- .../cycles/integrator/work_tile_scheduler.cpp | 10 +- .../cycles/integrator/work_tile_scheduler.h | 8 +- intern/cycles/kernel/bvh/bvh.h | 8 +- intern/cycles/kernel/bvh/local.h | 8 +- intern/cycles/kernel/bvh/nodes.h | 8 +- intern/cycles/kernel/camera/camera.h | 14 +- intern/cycles/kernel/camera/projection.h | 53 +-- intern/cycles/kernel/closure/alloc.h | 6 +- intern/cycles/kernel/closure/bsdf.h | 7 +- .../kernel/closure/bsdf_ashikhmin_shirley.h | 15 +- .../kernel/closure/bsdf_ashikhmin_velvet.h | 4 +- intern/cycles/kernel/closure/bsdf_diffuse.h | 12 +- .../cycles/kernel/closure/bsdf_diffuse_ramp.h | 8 +- intern/cycles/kernel/closure/bsdf_hair.h | 12 +- .../cycles/kernel/closure/bsdf_microfacet.h | 31 +- .../cycles/kernel/closure/bsdf_oren_nayar.h | 12 +- .../cycles/kernel/closure/bsdf_phong_ramp.h | 6 +- .../closure/bsdf_principled_hair_chiang.h | 38 ++- .../closure/bsdf_principled_hair_huang.h | 24 +- .../cycles/kernel/closure/bsdf_ray_portal.h | 4 +- intern/cycles/kernel/closure/bsdf_sheen.h | 6 +- intern/cycles/kernel/closure/bsdf_toon.h | 18 +- .../cycles/kernel/closure/bsdf_transparent.h | 6 +- intern/cycles/kernel/closure/bsdf_util.h | 35 +- intern/cycles/kernel/closure/bssrdf.h | 20 +- intern/cycles/kernel/closure/emissive.h | 7 +- intern/cycles/kernel/closure/volume.h | 8 +- intern/cycles/kernel/closure/volume_draine.h | 4 +- .../kernel/closure/volume_fournier_forand.h | 4 +- .../kernel/closure/volume_henyey_greenstein.h | 4 +- .../cycles/kernel/closure/volume_rayleigh.h | 4 +- intern/cycles/kernel/closure/volume_util.h | 44 +-- intern/cycles/kernel/device/cpu/bvh.h | 10 +- intern/cycles/kernel/device/cpu/globals.h | 2 +- intern/cycles/kernel/device/cpu/image.h | 122 +++---- intern/cycles/kernel/device/cpu/kernel.cpp | 5 +- intern/cycles/kernel/device/cpu/kernel.h | 7 +- intern/cycles/kernel/device/cpu/kernel_arch.h | 26 +- .../kernel/device/cpu/kernel_arch_impl.h | 34 +- intern/cycles/kernel/device/gpu/image.h | 48 +-- intern/cycles/kernel/device/gpu/kernel.h | 194 +++++------ .../cycles/kernel/device/gpu/work_stealing.h | 8 +- intern/cycles/kernel/device/hiprt/bvh.h | 8 +- intern/cycles/kernel/device/hiprt/common.h | 8 +- intern/cycles/kernel/device/metal/bvh.h | 26 +- .../kernel/device/metal/context_begin.h | 12 +- intern/cycles/kernel/device/oneapi/compat.h | 6 +- intern/cycles/kernel/device/oneapi/image.h | 37 ++- intern/cycles/kernel/device/oneapi/kernel.cpp | 8 +- intern/cycles/kernel/device/oneapi/kernel.h | 6 +- .../kernel/device/oneapi/kernel_templates.h | 4 +- intern/cycles/kernel/device/optix/bvh.h | 8 +- intern/cycles/kernel/film/adaptive_sampling.h | 32 +- .../cycles/kernel/film/cryptomatte_passes.h | 10 +- intern/cycles/kernel/film/data_passes.h | 6 +- intern/cycles/kernel/film/light_passes.h | 10 +- intern/cycles/kernel/film/read.h | 4 +- intern/cycles/kernel/film/write.h | 13 +- intern/cycles/kernel/geom/attribute.h | 12 +- intern/cycles/kernel/geom/curve_intersect.h | 8 +- intern/cycles/kernel/geom/motion_curve.h | 38 ++- intern/cycles/kernel/geom/motion_point.h | 9 +- intern/cycles/kernel/geom/motion_triangle.h | 77 +++-- .../kernel/geom/motion_triangle_intersect.h | 43 +-- intern/cycles/kernel/geom/object.h | 68 ++-- intern/cycles/kernel/geom/patch.h | 74 ++--- intern/cycles/kernel/geom/shader_data.h | 34 +- intern/cycles/kernel/geom/subd_triangle.h | 10 +- intern/cycles/kernel/geom/triangle.h | 24 +- .../cycles/kernel/geom/triangle_intersect.h | 32 +- intern/cycles/kernel/integrator/mnee.h | 21 +- .../cycles/kernel/integrator/shade_volume.h | 4 +- intern/cycles/kernel/integrator/state_util.h | 8 +- .../kernel/integrator/subsurface_disk.h | 4 +- .../integrator/subsurface_random_walk.h | 18 +- .../cycles/kernel/integrator/surface_shader.h | 7 +- .../cycles/kernel/integrator/volume_shader.h | 4 +- intern/cycles/kernel/light/area.h | 2 +- intern/cycles/kernel/light/background.h | 34 +- intern/cycles/kernel/light/common.h | 8 +- intern/cycles/kernel/light/light.h | 4 +- intern/cycles/kernel/light/sample.h | 6 +- intern/cycles/kernel/light/tree.h | 4 +- intern/cycles/kernel/light/triangle.h | 14 +- intern/cycles/kernel/osl/closures.cpp | 6 +- intern/cycles/kernel/osl/closures_setup.h | 124 +++---- intern/cycles/kernel/osl/osl.h | 6 +- intern/cycles/kernel/osl/services.cpp | 82 ++--- intern/cycles/kernel/osl/services.h | 60 ++-- intern/cycles/kernel/osl/services_gpu.h | 306 ++++++++++-------- intern/cycles/kernel/osl/types.h | 2 +- intern/cycles/kernel/sample/lcg.h | 2 +- intern/cycles/kernel/sample/mapping.h | 6 +- intern/cycles/kernel/sample/mis.h | 10 +- intern/cycles/kernel/sample/pattern.h | 30 +- intern/cycles/kernel/sample/sobol_burley.h | 8 +- intern/cycles/kernel/sample/tabulated_sobol.h | 12 +- intern/cycles/kernel/sample/util.h | 10 +- intern/cycles/kernel/svm/ao.h | 6 +- intern/cycles/kernel/svm/aov.h | 4 +- intern/cycles/kernel/svm/attribute.h | 8 +- intern/cycles/kernel/svm/bevel.h | 14 +- intern/cycles/kernel/svm/blackbody.h | 4 +- intern/cycles/kernel/svm/brick.h | 25 +- intern/cycles/kernel/svm/brightness.h | 7 +- intern/cycles/kernel/svm/bump.h | 4 +- intern/cycles/kernel/svm/camera.h | 6 +- intern/cycles/kernel/svm/checker.h | 2 +- intern/cycles/kernel/svm/clamp.h | 6 +- intern/cycles/kernel/svm/closure.h | 37 ++- intern/cycles/kernel/svm/color_util.h | 58 ++-- intern/cycles/kernel/svm/convert.h | 6 +- intern/cycles/kernel/svm/displace.h | 13 +- intern/cycles/kernel/svm/fractal_noise.h | 119 ++++--- intern/cycles/kernel/svm/fresnel.h | 8 +- intern/cycles/kernel/svm/gabor.h | 48 +-- intern/cycles/kernel/svm/gamma.h | 6 +- intern/cycles/kernel/svm/geometry.h | 28 +- intern/cycles/kernel/svm/gradient.h | 4 +- intern/cycles/kernel/svm/hsv.h | 2 +- intern/cycles/kernel/svm/ies.h | 2 +- intern/cycles/kernel/svm/image.h | 11 +- intern/cycles/kernel/svm/invert.h | 8 +- intern/cycles/kernel/svm/light_path.h | 8 +- intern/cycles/kernel/svm/magic.h | 12 +- intern/cycles/kernel/svm/map_range.h | 16 +- intern/cycles/kernel/svm/mapping.h | 14 +- intern/cycles/kernel/svm/mapping_util.h | 7 +- intern/cycles/kernel/svm/math.h | 12 +- intern/cycles/kernel/svm/math_util.h | 14 +- intern/cycles/kernel/svm/mix.h | 26 +- intern/cycles/kernel/svm/noise.h | 76 ++--- intern/cycles/kernel/svm/noisetex.h | 102 +++--- intern/cycles/kernel/svm/normal.h | 6 +- intern/cycles/kernel/svm/ramp.h | 39 ++- intern/cycles/kernel/svm/ramp_util.h | 6 +- intern/cycles/kernel/svm/sepcomb_color.h | 12 +- intern/cycles/kernel/svm/sepcomb_hsv.h | 12 +- intern/cycles/kernel/svm/sepcomb_vector.h | 12 +- intern/cycles/kernel/svm/sky.h | 53 +-- intern/cycles/kernel/svm/svm.h | 2 +- intern/cycles/kernel/svm/tex_coord.h | 16 +- intern/cycles/kernel/svm/value.h | 6 +- intern/cycles/kernel/svm/vector_rotate.h | 6 +- intern/cycles/kernel/svm/vector_transform.h | 2 +- intern/cycles/kernel/svm/vertex_color.h | 18 +- intern/cycles/kernel/svm/voronoi.h | 6 +- intern/cycles/kernel/svm/voxel.h | 7 +- intern/cycles/kernel/svm/wave.h | 17 +- intern/cycles/kernel/svm/wavelength.h | 4 +- intern/cycles/kernel/svm/white_noise.h | 6 +- intern/cycles/kernel/svm/wireframe.h | 6 +- intern/cycles/kernel/util/colorspace.h | 10 +- intern/cycles/kernel/util/differential.h | 16 +- intern/cycles/kernel/util/ies.h | 15 +- intern/cycles/kernel/util/lookup_table.h | 14 +- intern/cycles/kernel/util/nanovdb.h | 19 +- intern/cycles/scene/alembic.cpp | 8 +- intern/cycles/scene/alembic.h | 14 +- intern/cycles/scene/alembic_read.cpp | 16 +- intern/cycles/scene/attribute.cpp | 15 +- intern/cycles/scene/attribute.h | 12 +- intern/cycles/scene/camera.cpp | 12 +- intern/cycles/scene/camera.h | 10 +- intern/cycles/scene/colorspace.cpp | 10 +- intern/cycles/scene/colorspace.h | 4 +- intern/cycles/scene/constant_fold.cpp | 10 +- intern/cycles/scene/constant_fold.h | 10 +- intern/cycles/scene/curves.cpp | 2 +- intern/cycles/scene/curves.h | 2 +- intern/cycles/scene/film.cpp | 6 +- intern/cycles/scene/geometry.cpp | 6 +- intern/cycles/scene/geometry.h | 8 +- intern/cycles/scene/geometry_attributes.cpp | 17 +- intern/cycles/scene/geometry_bvh.cpp | 4 +- intern/cycles/scene/hair.cpp | 30 +- intern/cycles/scene/hair.h | 38 +-- intern/cycles/scene/image.cpp | 15 +- intern/cycles/scene/image.h | 14 +- intern/cycles/scene/image_sky.cpp | 10 +- intern/cycles/scene/image_sky.h | 8 +- intern/cycles/scene/image_vdb.cpp | 6 +- intern/cycles/scene/integrator.cpp | 2 +- intern/cycles/scene/integrator.h | 2 +- intern/cycles/scene/light.cpp | 14 +- intern/cycles/scene/light.h | 4 +- intern/cycles/scene/light_tree.cpp | 12 +- intern/cycles/scene/light_tree.h | 19 +- intern/cycles/scene/mesh.cpp | 37 ++- intern/cycles/scene/mesh.h | 42 +-- intern/cycles/scene/mesh_subdivision.cpp | 6 +- intern/cycles/scene/object.cpp | 6 +- intern/cycles/scene/object.h | 6 +- intern/cycles/scene/osl.cpp | 18 +- intern/cycles/scene/osl.h | 14 +- intern/cycles/scene/pointcloud.cpp | 16 +- intern/cycles/scene/pointcloud.h | 20 +- intern/cycles/scene/shader.cpp | 8 +- intern/cycles/scene/shader.h | 13 +- intern/cycles/scene/shader_graph.h | 6 +- intern/cycles/scene/shader_nodes.cpp | 36 ++- intern/cycles/scene/shader_nodes.h | 13 +- intern/cycles/scene/stats.cpp | 26 +- intern/cycles/scene/stats.h | 26 +- intern/cycles/scene/svm.cpp | 15 +- intern/cycles/scene/svm.h | 15 +- intern/cycles/scene/tables.cpp | 2 +- intern/cycles/scene/tabulated_sobol.cpp | 2 +- intern/cycles/scene/tabulated_sobol.h | 2 +- intern/cycles/scene/volume.cpp | 24 +- intern/cycles/session/denoising.cpp | 4 +- intern/cycles/session/denoising.h | 4 +- intern/cycles/session/display_driver.h | 2 +- intern/cycles/session/session.cpp | 6 +- intern/cycles/session/session.h | 6 +- intern/cycles/session/tile.cpp | 4 +- intern/cycles/session/tile.h | 4 +- intern/cycles/subd/dice.cpp | 20 +- intern/cycles/subd/dice.h | 20 +- intern/cycles/subd/patch.cpp | 9 +- intern/cycles/subd/patch.h | 6 +- intern/cycles/subd/patch_table.cpp | 8 +- intern/cycles/subd/patch_table.h | 4 +- intern/cycles/subd/split.cpp | 26 +- intern/cycles/subd/split.h | 23 +- intern/cycles/subd/subpatch.h | 18 +- .../test/render_graph_finalize_test.cpp | 8 +- intern/cycles/util/aligned_malloc.cpp | 2 +- intern/cycles/util/aligned_malloc.h | 2 +- intern/cycles/util/array.h | 14 +- intern/cycles/util/atomic.h | 27 +- intern/cycles/util/boundbox.h | 6 +- intern/cycles/util/color.h | 38 +-- intern/cycles/util/disjoint_set.h | 4 +- intern/cycles/util/guarded_allocator.cpp | 4 +- intern/cycles/util/guarded_allocator.h | 8 +- intern/cycles/util/half.h | 2 +- intern/cycles/util/hash.h | 69 ++-- intern/cycles/util/ies.cpp | 2 +- intern/cycles/util/image.h | 22 +- intern/cycles/util/log.cpp | 2 +- intern/cycles/util/log.h | 2 +- intern/cycles/util/math_base.h | 149 ++++----- intern/cycles/util/math_fast.h | 44 +-- intern/cycles/util/math_float2.h | 14 +- intern/cycles/util/math_float3.h | 55 ++-- intern/cycles/util/math_float4.h | 48 +-- intern/cycles/util/math_float8.h | 21 +- intern/cycles/util/math_int3.h | 8 +- intern/cycles/util/math_int4.h | 12 +- intern/cycles/util/math_int8.h | 12 +- intern/cycles/util/math_intersect.h | 54 ++-- intern/cycles/util/md5.cpp | 2 +- intern/cycles/util/md5.h | 2 +- intern/cycles/util/murmurhash.cpp | 8 +- intern/cycles/util/murmurhash.h | 4 +- intern/cycles/util/profiling.cpp | 6 +- intern/cycles/util/profiling.h | 8 +- intern/cycles/util/progress.h | 8 +- intern/cycles/util/projection.h | 46 +-- intern/cycles/util/rect.h | 16 +- intern/cycles/util/simd.h | 35 +- intern/cycles/util/stack_allocator.h | 4 +- intern/cycles/util/stats.h | 4 +- intern/cycles/util/string.h | 4 +- intern/cycles/util/task.cpp | 4 +- intern/cycles/util/task.h | 4 +- intern/cycles/util/time.cpp | 2 +- intern/cycles/util/time.h | 2 +- intern/cycles/util/transform.cpp | 4 +- intern/cycles/util/transform.h | 52 +-- intern/cycles/util/types_base.h | 10 +- intern/cycles/util/types_float2.h | 2 +- intern/cycles/util/types_float3.h | 10 +- intern/cycles/util/types_float4.h | 10 +- intern/cycles/util/types_float8.h | 12 +- intern/cycles/util/types_int2.h | 2 +- intern/cycles/util/types_int3.h | 6 +- intern/cycles/util/types_int4.h | 4 +- intern/cycles/util/types_int8.h | 5 +- intern/cycles/util/types_uchar2.h | 2 +- intern/cycles/util/types_uchar3.h | 2 +- intern/cycles/util/types_uchar4.h | 2 +- intern/cycles/util/types_uint2.h | 2 +- intern/cycles/util/types_uint3.h | 4 +- intern/cycles/util/types_uint4.h | 2 +- intern/cycles/util/windows.cpp | 2 +- intern/cycles/util/windows.h | 2 +- 389 files changed, 3464 insertions(+), 2900 deletions(-) diff --git a/intern/cycles/app/cycles_precompute.cpp b/intern/cycles/app/cycles_precompute.cpp index 6ba63e0b60c..e5b31771c4f 100644 --- a/intern/cycles/app/cycles_precompute.cpp +++ b/intern/cycles/app/cycles_precompute.cpp @@ -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 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; diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 1768b1e1d93..ca1c2ce6d5d 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -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(); diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 81d95b6bfc5..34e79fd3fa9 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -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 &value, xml_node node, const char *name) +static bool xml_read_int_array(vector &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 &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 &value, xml_node node, const char *name) +static bool xml_read_float_array(vector &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 &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 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 &value, xml_node node, const char *name) +static bool xml_read_float3_array(vector &value, const xml_node node, const char *name) { vector array; @@ -137,7 +137,7 @@ static bool xml_read_float3_array(vector &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 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(); 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 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")) { diff --git a/intern/cycles/app/opengl/display_driver.cpp b/intern/cycles/app/opengl/display_driver.cpp index 692dc22b9e5..0979f60d08d 100644 --- a/intern/cycles/app/opengl/display_driver.cpp +++ b/intern/cycles/app/opengl/display_driver.cpp @@ -33,7 +33,9 @@ void OpenGLDisplayDriver::next_tile_begin() /* Assuming no tiles used in interactive display. */ } -bool OpenGLDisplayDriver::update_begin(const Params ¶ms, int texture_width, int texture_height) +bool OpenGLDisplayDriver::update_begin(const Params ¶ms, + 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. diff --git a/intern/cycles/app/opengl/display_driver.h b/intern/cycles/app/opengl/display_driver.h index 96b7ad7d590..9f19c6d2bbf 100644 --- a/intern/cycles/app/opengl/display_driver.h +++ b/intern/cycles/app/opengl/display_driver.h @@ -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 ¶ms, int texture_width, int texture_height) override; + bool update_begin(const Params ¶ms, + const int texture_width, + const int texture_height) override; void update_end() override; half4 *map_texture_buffer() override; diff --git a/intern/cycles/app/opengl/shader.cpp b/intern/cycles/app/opengl/shader.cpp index bf1e9f9f81f..ab9b704cd78 100644 --- a/intern/cycles/app/opengl/shader.cpp +++ b/intern/cycles/app/opengl/shader.cpp @@ -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(); diff --git a/intern/cycles/app/opengl/shader.h b/intern/cycles/app/opengl/shader.h index 3f18d64fb03..df44e6e2473 100644 --- a/intern/cycles/app/opengl/shader.h +++ b/intern/cycles/app/opengl/shader.h @@ -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: diff --git a/intern/cycles/app/opengl/window.cpp b/intern/cycles/app/opengl/window.cpp index e0e771d5678..ebe034aa6c7 100644 --- a/intern/cycles/app/opengl/window.cpp +++ b/intern/cycles/app/opengl/window.cpp @@ -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, diff --git a/intern/cycles/app/opengl/window.h b/intern/cycles/app/opengl/window.h index 6ea827bcef0..6e041d4a5a4 100644 --- a/intern/cycles/app/opengl/window.h +++ b/intern/cycles/app/opengl/window.h @@ -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, diff --git a/intern/cycles/blender/CCL_api.h b/intern/cycles/blender/CCL_api.h index 9d6bd029dd6..8d66d5a8018 100644 --- a/intern/cycles/blender/CCL_api.h +++ b/intern/cycles/blender/CCL_api.h @@ -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 } diff --git a/intern/cycles/blender/camera.cpp b/intern/cycles/blender/camera.cpp index e19455cd392..25683ec4770 100644 --- a/intern/cycles/blender/camera.cpp +++ b/intern/cycles/blender/camera.cpp @@ -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; diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index db2f0cb0724..d16fc634fac 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -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) { diff --git a/intern/cycles/blender/display_driver.cpp b/intern/cycles/blender/display_driver.cpp index 22c3158e061..72b7cfde9e1 100644 --- a/intern/cycles/blender/display_driver.cpp +++ b/intern/cycles/blender/display_driver.cpp @@ -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 ¶ms, - 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 ¶ms, - 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; diff --git a/intern/cycles/blender/display_driver.h b/intern/cycles/blender/display_driver.h index b6f56d3aade..d62cf83e232 100644 --- a/intern/cycles/blender/display_driver.h +++ b/intern/cycles/blender/display_driver.h @@ -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 ¶ms, int texture_width, int texture_height) override; + bool update_begin(const Params ¶ms, + const int texture_width, + const int texture_height) override; void update_end() override; half4 *map_texture_buffer() override; diff --git a/intern/cycles/blender/geometry.cpp b/intern/cycles/blender/geometry.cpp index 612c66541d8..b79048d57af 100644 --- a/intern/cycles/blender/geometry.cpp +++ b/intern/cycles/blender/geometry.cpp @@ -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) { diff --git a/intern/cycles/blender/light.cpp b/intern/cycles/blender/light.cpp index b67053276ad..2ab51147af1 100644 --- a/intern/cycles/blender/light.cpp +++ b/intern/cycles/blender/light.cpp @@ -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) { diff --git a/intern/cycles/blender/logging.cpp b/intern/cycles/blender/logging.cpp index 91ac068ac79..bc6a7e106c8 100644 --- a/intern/cycles/blender/logging.cpp +++ b/intern/cycles/blender/logging.cpp @@ -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); } diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index 241f1b0ac43..66b0051d39a 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -1049,8 +1049,8 @@ static void create_subd_mesh(Scene *scene, const array &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(); diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index 9dc2dfad662..bdf3d0fe324 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -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) { diff --git a/intern/cycles/blender/object_cull.cpp b/intern/cycles/blender/object_cull.cpp index 2fb9b998708..aacd4890206 100644 --- a/intern/cycles/blender/object_cull.cpp +++ b/intern/cycles/blender/object_cull.cpp @@ -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); diff --git a/intern/cycles/blender/object_cull.h b/intern/cycles/blender/object_cull.h index 617d338cc9f..acd2de9b4fa 100644 --- a/intern/cycles/blender/object_cull.h +++ b/intern/cycles/blender/object_cull.h @@ -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_; diff --git a/intern/cycles/blender/pointcloud.cpp b/intern/cycles/blender/pointcloud.cpp index ba9f63a16f5..0af298097a3 100644 --- a/intern/cycles/blender/pointcloud.cpp +++ b/intern/cycles/blender/pointcloud.cpp @@ -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) { diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index ce8ccf187b8..bfabc3bd840 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -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)); diff --git a/intern/cycles/blender/session.h b/intern/cycles/blender/session.h index 6415dd03761..36cf6ba4121 100644 --- a/intern/cycles/blender/session.h +++ b/intern/cycles/blender/session.h @@ -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); diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp index 643f3935756..25a34a7685a 100644 --- a/intern/cycles/blender/shader.cpp +++ b/intern/cycles/blender/shader.cpp @@ -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; diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index fee4a71629c..542599a8b00 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -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) { diff --git a/intern/cycles/blender/sync.h b/intern/cycles/blender/sync.h index e5cd3ecadb1..2a3a5b9d666 100644 --- a/intern/cycles/blender/sync.h +++ b/intern/cycles/blender/sync.h @@ -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); diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h index b2339374a70..d98625c5831 100644 --- a/intern/cycles/blender/util.h +++ b/intern/cycles/blender/util.h @@ -151,7 +151,7 @@ static inline void free_object_to_mesh(BL::BlendData & /*data*/, static inline void colorramp_to_array(BL::ColorRamp &ramp, array &ramp_color, array &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 &data, int size) +static inline void curvemapping_to_array(BL::CurveMapping &cumap, + array &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 & static inline void curvemapping_float_to_array(BL::CurveMapping &cumap, array &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 &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(ima.ptr.data), static_cast(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.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.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); } diff --git a/intern/cycles/blender/volume.cpp b/intern/cycles/blender/volume.cpp index 7ae9df9b3e6..1eae6ed3ea4 100644 --- a/intern/cycles/blender/volume.cpp +++ b/intern/cycles/blender/volume.cpp @@ -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; diff --git a/intern/cycles/bvh/binning.h b/intern/cycles/bvh/binning.h index 38cbbd13e69..4f42cdfd7f4 100644 --- a/intern/cycles/bvh/binning.h +++ b/intern/cycles/bvh/binning.h @@ -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); } diff --git a/intern/cycles/bvh/build.cpp b/intern/cycles/bvh/build.cpp index 93f44bf4926..5116dbfb683 100644 --- a/intern/cycles/bvh/build.cpp +++ b/intern/cycles/bvh/build.cpp @@ -57,7 +57,7 @@ BVHBuild::~BVHBuild() = default; void BVHBuild::add_reference_triangles(BoundBox &root, BoundBox ¢er, 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 ¢er, Hair *hair, int object_index) +void BVHBuild::add_reference_curves(BoundBox &root, + BoundBox ¢er, + 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 ¢er, Hair *hair void BVHBuild::add_reference_points(BoundBox &root, BoundBox ¢er, 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 ¢er, Geometry *geom, - int object_index) + const int object_index) { if (geom->is_mesh() || geom->is_volume()) { Mesh *mesh = static_cast(geom); @@ -370,7 +373,7 @@ void BVHBuild::add_reference_geometry(BoundBox &root, } } -void BVHBuild::add_reference_object(BoundBox &root, BoundBox ¢er, Object *ob, int i) +void BVHBuild::add_reference_object(BoundBox &root, BoundBox ¢er, 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 &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 &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 vectoris_leaf() || max_depth < 0) { diff --git a/intern/cycles/bvh/build.h b/intern/cycles/bvh/build.h index f696e74f5b4..943489f7f84 100644 --- a/intern/cycles/bvh/build.h +++ b/intern/cycles/bvh/build.h @@ -56,30 +56,39 @@ class BVHBuild { friend class BVHObjectBinning; /* Adding references. */ - void add_reference_triangles(BoundBox &root, BoundBox ¢er, Mesh *mesh, int object_index); - void add_reference_curves(BoundBox &root, BoundBox ¢er, Hair *hair, int object_index); - void add_reference_points(BoundBox &root, BoundBox ¢er, PointCloud *pointcloud, int i); - void add_reference_geometry(BoundBox &root, BoundBox ¢er, Geometry *geom, int object_index); - void add_reference_object(BoundBox &root, BoundBox ¢er, Object *ob, int i); + void add_reference_triangles(BoundBox &root, + BoundBox ¢er, + Mesh *mesh, + const int object_index); + void add_reference_curves(BoundBox &root, BoundBox ¢er, Hair *hair, const int object_index); + void add_reference_points(BoundBox &root, BoundBox ¢er, PointCloud *pointcloud, const int i); + void add_reference_geometry(BoundBox &root, + BoundBox ¢er, + Geometry *geom, + const int object_index); + void add_reference_object(BoundBox &root, BoundBox ¢er, Object *ob, const int i); void add_references(BVHRange &root); /* Building. */ BVHNode *build_node(const BVHRange &range, vector &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 &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 &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 &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 objects; diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index a97b051a44e..494010f3402 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -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++) { diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index 18b006e4a07..c9ef084dd4e 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -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 diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 4e51e9262bb..9f561af2eef 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -226,7 +226,7 @@ RTCError BVHEmbree::offload_scenes_to_gpu(const vector &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 -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; diff --git a/intern/cycles/bvh/embree.h b/intern/cycles/bvh/embree.h index bedbbb78eca..ec04f8872be 100644 --- a/intern/cycles/bvh/embree.h +++ b/intern/cycles/bvh/embree.h @@ -48,11 +48,12 @@ class BVHEmbree : public BVH { const vector &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); diff --git a/intern/cycles/bvh/node.cpp b/intern/cycles/bvh/node.cpp index e45879ccb1a..450d7b16a19 100644 --- a/intern/cycles/bvh/node.cpp +++ b/intern/cycles/bvh/node.cpp @@ -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(" "); diff --git a/intern/cycles/bvh/node.h b/intern/cycles/bvh/node.h index c28579137a7..b7fa247c0e7 100644 --- a/intern/cycles/bvh/node.h +++ b/intern/cycles/bvh/node.h @@ -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; diff --git a/intern/cycles/bvh/params.h b/intern/cycles/bvh/params.h index db7918f835c..70638a70521 100644 --- a/intern/cycles/bvh/params.h +++ b/intern/cycles/bvh/params.h @@ -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_); } diff --git a/intern/cycles/bvh/sort.cpp b/intern/cycles/bvh/sort.cpp index d8d7c305a67..56b1983dd8f 100644 --- a/intern/cycles/bvh/sort.cpp +++ b/intern/cycles/bvh/sort.cpp @@ -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) { diff --git a/intern/cycles/bvh/sort.h b/intern/cycles/bvh/sort.h index edb7d80056b..15e4c547e53 100644 --- a/intern/cycles/bvh/sort.h +++ b/intern/cycles/bvh/sort.h @@ -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); diff --git a/intern/cycles/bvh/split.cpp b/intern/cycles/bvh/split.cpp index 022f688827c..b3009936492 100644 --- a/intern/cycles/bvh/split.cpp +++ b/intern/cycles/bvh/split.cpp @@ -25,7 +25,7 @@ BVHObjectSplit::BVHObjectSplit(BVHBuild *builder, BVHSpatialStorage *storage, const BVHRange &range, vector &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 &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; diff --git a/intern/cycles/bvh/split.h b/intern/cycles/bvh/split.h index b07727b0a3d..9c4ef3899d2 100644 --- a/intern/cycles/bvh/split.h +++ b/intern/cycles/bvh/split.h @@ -33,7 +33,7 @@ class BVHObjectSplit { BVHSpatialStorage *storage, const BVHRange &range, vector &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 &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 &references, - int level, + const int level, const BVHUnaligned *unaligned_heuristic = nullptr, const Transform *aligned_space = nullptr) { diff --git a/intern/cycles/cmake/zstd_compress.cpp b/intern/cycles/cmake/zstd_compress.cpp index b2e64568ea9..a1ada9fc239 100644 --- a/intern/cycles/cmake/zstd_compress.cpp +++ b/intern/cycles/cmake/zstd_compress.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, const char **argv) +int main(const int argc, const char **argv) { if (argc < 3) { return -1; diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index bea62e1e0ee..fef9dd27296 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -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) { diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index 56eb3ab08ee..f0e242af237 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -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); diff --git a/intern/cycles/device/cpu/kernel.h b/intern/cycles/device/cpu/kernel.h index 7dfc18d992a..6edca4eb724 100644 --- a/intern/cycles/device/cpu/kernel.h +++ b/intern/cycles/device/cpu/kernel.h @@ -56,29 +56,29 @@ class CPUKernels { using AdaptiveSamplingConvergenceCheckFunction = CPUKernelFunction; using AdaptiveSamplingFilterXFunction = CPUKernelFunction; using AdaptiveSamplingFilterYFunction = CPUKernelFunction; AdaptiveSamplingConvergenceCheckFunction adaptive_sampling_convergence_check; @@ -89,7 +89,7 @@ class CPUKernels { /* Cryptomatte. */ using CryptomattePostprocessFunction = CPUKernelFunction; + const KernelGlobalsCPU *kg, ccl_global float *render_buffer, const int pixel_index)>; CryptomattePostprocessFunction cryptomatte_postprocess; diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index fbbb4508e77..7b1004b8ac3 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -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)) { diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index a383f514608..eb7a7538c28 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -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 diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 87db3dd5b0f..7a00aa83048 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -212,7 +212,7 @@ vector Device::available_types() return types; } -vector Device::available_devices(uint mask) +vector 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 &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; diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 6d63b15e04d..85c0b48c392 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -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 available_types(); - static vector available_devices(uint device_type_mask = DEVICE_MASK_ALL); + static vector 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 &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 diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp index abfdaefa266..50b9e456c05 100644 --- a/intern/cycles/device/hip/device.cpp +++ b/intern/cycles/device/hip/device.cpp @@ -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) { diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index 715f6a7bcc1..fe88ed6d7ad 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -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)) { diff --git a/intern/cycles/device/hip/device_impl.h b/intern/cycles/device/hip/device_impl.h index 8f82311b421..007095554c7 100644 --- a/intern/cycles/device/hip/device_impl.h +++ b/intern/cycles/device/hip/device_impl.h @@ -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 diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp index 506edfe6d76..74de1779c5f 100644 --- a/intern/cycles/device/hiprt/device_impl.cpp +++ b/intern/cycles/device/hiprt/device_impl.cpp @@ -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; diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index 72ee26bf5ad..03d5c1126ab 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -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); } diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index dd96d997008..d267e1b39c4 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -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 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 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 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 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 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 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 diff --git a/intern/cycles/device/metal/bvh.mm b/intern/cycles/device/metal/bvh.mm index ac7127710cc..92e86d03dc3 100644 --- a/intern/cycles/device/metal/bvh.mm +++ b/intern/cycles/device/metal/bvh.mm @@ -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; diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 02eb03b7280..0f2f76793d5 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -95,9 +95,9 @@ class MetalDevice : public Device { static thread_mutex existing_devices_mutex; static std::map 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); diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index f9e779fa109..e7dc5ffd1e7 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -29,7 +29,7 @@ std::map 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; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index cedd808887f..b72424cad89 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -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); diff --git a/intern/cycles/device/oneapi/device.cpp b/intern/cycles/device/oneapi/device.cpp index dd363f3d168..60316ee8a1b 100644 --- a/intern/cycles/device/oneapi/device.cpp +++ b/intern/cycles/device/oneapi/device.cpp @@ -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) diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index 7c5a98c9eec..09487dd79fa 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -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(reinterpret_cast(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(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, diff --git a/intern/cycles/device/oneapi/device_impl.h b/intern/cycles/device/oneapi/device_impl.h index e32040450ec..c19482c5787 100644 --- a/intern/cycles/device/oneapi/device_impl.h +++ b/intern/cycles/device/oneapi/device_impl.h @@ -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 diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index f0826e6b75b..0a21ff20b00 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -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); diff --git a/intern/cycles/device/optix/device_impl.h b/intern/cycles/device/optix/device_impl.h index 8e5388667d1..9de13c0e0b9 100644 --- a/intern/cycles/device/optix/device_impl.h +++ b/intern/cycles/device/optix/device_impl.h @@ -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 gpu_queue_create() override; diff --git a/intern/cycles/device/queue.h b/intern/cycles/device/queue.h index af0c53d0083..ee611257360 100644 --- a/intern/cycles/device/queue.h +++ b/intern/cycles/device/queue.h @@ -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); diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index e2eebe918df..d215db30484 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -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); diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h index d055eabb5bb..60da9ecc364 100644 --- a/intern/cycles/graph/node.h +++ b/intern/cycles/graph/node.h @@ -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); diff --git a/intern/cycles/graph/node_enum.h b/intern/cycles/graph/node_enum.h index f68259bedb9..2468c8ce57a 100644 --- a/intern/cycles/graph/node_enum.h +++ b/intern/cycles/graph/node_enum.h @@ -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(); } diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp index 42476e73138..5ade312e48a 100644 --- a/intern/cycles/graph/node_type.cpp +++ b/intern/cycles/graph/node_type.cpp @@ -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; diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h index f6d942acccb..eb78ba64643 100644 --- a/intern/cycles/graph/node_type.h +++ b/intern/cycles/graph/node_type.h @@ -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, diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp index 26582020783..ac7270c815f 100644 --- a/intern/cycles/graph/node_xml.cpp +++ b/intern/cycles/graph/node_xml.cpp @@ -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) { diff --git a/intern/cycles/graph/node_xml.h b/intern/cycles/graph/node_xml.h index cebb736f5e5..8352e53f026 100644 --- a/intern/cycles/graph/node_xml.h +++ b/intern/cycles/graph/node_xml.h @@ -18,8 +18,8 @@ struct XMLReader { map 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 diff --git a/intern/cycles/hydra/camera.cpp b/intern/cycles/hydra/camera.cpp index 28a0206bcdb..d7aaa16fae3 100644 --- a/intern/cycles/hydra/camera.cpp +++ b/intern/cycles/hydra/camera.cpp @@ -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 diff --git a/intern/cycles/hydra/display_driver.h b/intern/cycles/hydra/display_driver.h index f864363b3da..b4b50bd61a6 100644 --- a/intern/cycles/hydra/display_driver.h +++ b/intern/cycles/hydra/display_driver.h @@ -22,7 +22,9 @@ class HdCyclesDisplayDriver final : public CCL_NS::DisplayDriver { private: void next_tile_begin() override; - bool update_begin(const Params ¶ms, int texture_width, int texture_height) override; + bool update_begin(const Params ¶ms, + const int texture_width, + const int texture_height) override; void update_end() override; void flush() override; diff --git a/intern/cycles/hydra/geometry.h b/intern/cycles/hydra/geometry.h index a991bf42b8a..00308f6b3e2 100644 --- a/intern/cycles/hydra/geometry.h +++ b/intern/cycles/hydra/geometry.h @@ -47,7 +47,7 @@ template class HdCyclesGeometry : public Bas private: void Initialize(PXR_NS::HdRenderParam *renderParam); - void InitializeInstance(int index); + void InitializeInstance(const int index); PXR_NS::GfMatrix4d _geomTransform; }; diff --git a/intern/cycles/hydra/render_buffer.cpp b/intern/cycles/hydra/render_buffer.cpp index abb374add82..afabf57f8bb 100644 --- a/intern/cycles/hydra/render_buffer.cpp +++ b/intern/cycles/hydra/render_buffer.cpp @@ -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(value) - 1; } }; struct UInt8Conversion { - static uint8_t convert(float value) + static uint8_t convert(const float value) { return static_cast(value * 255.f); } }; struct SInt8Conversion { - static int8_t convert(float value) + static int8_t convert(const float value) { return static_cast(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 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(); diff --git a/intern/cycles/hydra/render_buffer.h b/intern/cycles/hydra/render_buffer.h index ca432e178b1..3efb57cd4d1 100644 --- a/intern/cycles/hydra/render_buffer.h +++ b/intern/cycles/hydra/render_buffer.h @@ -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: diff --git a/intern/cycles/hydra/session.h b/intern/cycles/hydra/session.h index 8e4dec0748c..4c4e8ff66d9 100644 --- a/intern/cycles/hydra/session.h +++ b/intern/cycles/hydra/session.h @@ -35,7 +35,7 @@ class HdCyclesSession final : public PXR_NS::HdRenderParam { return _stageMetersPerUnit; } - void SetStageMetersPerUnit(double stageMetersPerUnit) + void SetStageMetersPerUnit(const double stageMetersPerUnit) { _stageMetersPerUnit = stageMetersPerUnit; } diff --git a/intern/cycles/integrator/adaptive_sampling.cpp b/intern/cycles/integrator/adaptive_sampling.cpp index f74c156d16c..c2252be0740 100644 --- a/intern/cycles/integrator/adaptive_sampling.cpp +++ b/intern/cycles/integrator/adaptive_sampling.cpp @@ -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; diff --git a/intern/cycles/integrator/adaptive_sampling.h b/intern/cycles/integrator/adaptive_sampling.h index e7f518b7f3e..1d5d65c5a82 100644 --- a/intern/cycles/integrator/adaptive_sampling.h +++ b/intern/cycles/integrator/adaptive_sampling.h @@ -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; diff --git a/intern/cycles/integrator/denoiser_oidn_gpu.cpp b/intern/cycles/integrator/denoiser_oidn_gpu.cpp index 8a087165cbe..1bd2cbb290c 100644 --- a/intern/cycles/integrator/denoiser_oidn_gpu.cpp +++ b/intern/cycles/integrator/denoiser_oidn_gpu.cpp @@ -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) { diff --git a/intern/cycles/integrator/denoiser_oidn_gpu.h b/intern/cycles/integrator/denoiser_oidn_gpu.h index 1b5903231b1..53393fe8c30 100644 --- a/intern/cycles/integrator/denoiser_oidn_gpu.h +++ b/intern/cycles/integrator/denoiser_oidn_gpu.h @@ -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. */ diff --git a/intern/cycles/integrator/denoiser_optix.cpp b/intern/cycles/integrator/denoiser_optix.cpp index 80184c839b3..c36a42d1840 100644 --- a/intern/cycles/integrator/denoiser_optix.cpp +++ b/intern/cycles/integrator/denoiser_optix.cpp @@ -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) diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp index e2f3631f552..49e016b2988 100644 --- a/intern/cycles/integrator/pass_accessor.cpp +++ b/intern/cycles/integrator/pass_accessor.cpp @@ -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) { } diff --git a/intern/cycles/integrator/pass_accessor.h b/intern/cycles/integrator/pass_accessor.h index 429976835aa..a91e5fe00aa 100644 --- a/intern/cycles/integrator/pass_accessor.h +++ b/intern/cycles/integrator/pass_accessor.h @@ -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; diff --git a/intern/cycles/integrator/pass_accessor_gpu.cpp b/intern/cycles/integrator/pass_accessor_gpu.cpp index 4a7ed18f567..45b0754e008 100644 --- a/intern/cycles/integrator/pass_accessor_gpu.cpp +++ b/intern/cycles/integrator/pass_accessor_gpu.cpp @@ -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) { } diff --git a/intern/cycles/integrator/pass_accessor_gpu.h b/intern/cycles/integrator/pass_accessor_gpu.h index 749b4323953..37e47e80cd8 100644 --- a/intern/cycles/integrator/pass_accessor_gpu.h +++ b/intern/cycles/integrator/pass_accessor_gpu.h @@ -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: diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp index 320fe515fcb..8c3b5ac2bf4 100644 --- a/intern/cycles/integrator/path_trace.cpp +++ b/intern/cycles/integrator/path_trace.cpp @@ -304,7 +304,7 @@ void PathTrace::update_allocated_work_buffer_params() }); } -static BufferParams scale_buffer_params(const BufferParams ¶ms, int resolution_divider) +static BufferParams scale_buffer_params(const BufferParams ¶ms, const int resolution_divider) { BufferParams scaled_params = params; diff --git a/intern/cycles/integrator/path_trace_display.cpp b/intern/cycles/integrator/path_trace_display.cpp index d6d3ee4595f..aaa7a0de8a7 100644 --- a/intern/cycles/integrator/path_trace_display.cpp +++ b/intern/cycles/integrator/path_trace_display.cpp @@ -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); diff --git a/intern/cycles/integrator/path_trace_display.h b/intern/cycles/integrator/path_trace_display.h index ca9a6544262..2110e1ae389 100644 --- a/intern/cycles/integrator/path_trace_display.h +++ b/intern/cycles/integrator/path_trace_display.h @@ -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. diff --git a/intern/cycles/integrator/path_trace_work.h b/intern/cycles/integrator/path_trace_work.h index 27470e8642b..9d9d1b43e49 100644 --- a/intern/cycles/integrator/path_trace_work.h +++ b/intern/cycles/integrator/path_trace_work.h @@ -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; diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp index 2f1fae445f0..30dd8adc81d 100644 --- a/intern/cycles/integrator/path_trace_work_cpu.cpp +++ b/intern/cycles/integrator/path_trace_work_cpu.cpp @@ -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; diff --git a/intern/cycles/integrator/path_trace_work_cpu.h b/intern/cycles/integrator/path_trace_work_cpu.h index 175f56a6fad..6f35be8cab4 100644 --- a/intern/cycles/integrator/path_trace_work_cpu.h +++ b/intern/cycles/integrator/path_trace_work_cpu.h @@ -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 diff --git a/intern/cycles/integrator/path_trace_work_gpu.cpp b/intern/cycles/integrator/path_trace_work_gpu.cpp index 0b8a9c1a3f4..0f4c8dc545d 100644 --- a/intern/cycles/integrator/path_trace_work_gpu.cpp +++ b/intern/cycles/integrator/path_trace_work_gpu.cpp @@ -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 num_active_pixels(device_, "num_active_pixels", MEM_READ_WRITE); num_active_pixels.alloc(1); diff --git a/intern/cycles/integrator/path_trace_work_gpu.h b/intern/cycles/integrator/path_trace_work_gpu.h index 88d5a439ac8..cad07776449 100644 --- a/intern/cycles/integrator/path_trace_work_gpu.h +++ b/intern/cycles/integrator/path_trace_work_gpu.h @@ -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(); diff --git a/intern/cycles/integrator/render_scheduler.cpp b/intern/cycles/integrator/render_scheduler.cpp index 2957d3e4252..a608a8d5100 100644 --- a/intern/cycles/integrator/render_scheduler.cpp +++ b/intern/cycles/integrator/render_scheduler.cpp @@ -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)); diff --git a/intern/cycles/integrator/render_scheduler.h b/intern/cycles/integrator/render_scheduler.h index 8b6819c28df..b12256726cc 100644 --- a/intern/cycles/integrator/render_scheduler.h +++ b/intern/cycles/integrator/render_scheduler.h @@ -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 diff --git a/intern/cycles/integrator/tile.cpp b/intern/cycles/integrator/tile.cpp index 1cefaf133eb..b6faabb4482 100644 --- a/intern/cycles/integrator/tile.cpp +++ b/intern/cycles/integrator/tile.cpp @@ -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; diff --git a/intern/cycles/integrator/tile.h b/intern/cycles/integrator/tile.h index dc56f540ea1..f45e80dcce0 100644 --- a/intern/cycles/integrator/tile.h +++ b/intern/cycles/integrator/tile.h @@ -13,7 +13,7 @@ CCL_NAMESPACE_BEGIN struct TileSize { TileSize() = default; - TileSize(int width, int height, int num_samples) + TileSize(const int width, const int height, const int num_samples) : width(width), height(height), num_samples(num_samples) { } diff --git a/intern/cycles/integrator/work_tile_scheduler.cpp b/intern/cycles/integrator/work_tile_scheduler.cpp index 74c3e5ea11f..7edc90e66ae 100644 --- a/intern/cycles/integrator/work_tile_scheduler.cpp +++ b/intern/cycles/integrator/work_tile_scheduler.cpp @@ -18,16 +18,16 @@ void WorkTileScheduler::set_accelerated_rt(bool accelerated_rt) accelerated_rt_ = accelerated_rt; } -void WorkTileScheduler::set_max_num_path_states(int max_num_path_states) +void WorkTileScheduler::set_max_num_path_states(const int max_num_path_states) { max_num_path_states_ = max_num_path_states; } void WorkTileScheduler::reset(const BufferParams &buffer_params, - int sample_start, - int samples_num, - int sample_offset, - float scrambling_distance) + const int sample_start, + const int samples_num, + const int sample_offset, + const float scrambling_distance) { /* Image buffer parameters. */ image_full_offset_px_.x = buffer_params.full_x; diff --git a/intern/cycles/integrator/work_tile_scheduler.h b/intern/cycles/integrator/work_tile_scheduler.h index 7df80817cab..04bff14a2ad 100644 --- a/intern/cycles/integrator/work_tile_scheduler.h +++ b/intern/cycles/integrator/work_tile_scheduler.h @@ -27,13 +27,13 @@ class WorkTileScheduler { * * Affects the scheduled work size: the work size will be as big as possible, but will not exceed * this number of states. */ - void set_max_num_path_states(int max_num_path_states); + void set_max_num_path_states(const int max_num_path_states); /* Scheduling will happen for pixels within a big tile denotes by its parameters. */ void reset(const BufferParams &buffer_params, - int sample_start, - int samples_num, - int sample_offset, + const int sample_start, + const int samples_num, + const int sample_offset, float scrambling_distance); /* Get work for a device. diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index 731a80538f0..78c050369d8 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -163,9 +163,9 @@ template ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { if (!intersection_ray_valid(ray)) { if (local_isect) { @@ -228,8 +228,8 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, IntegratorShadowState state, const ccl_private Ray *ray, - uint visibility, - uint max_hits, + const uint visibility, + const uint max_hits, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { diff --git a/intern/cycles/kernel/bvh/local.h b/intern/cycles/kernel/bvh/local.h index e42217b6423..74e6ac301a7 100644 --- a/intern/cycles/kernel/bvh/local.h +++ b/intern/cycles/kernel/bvh/local.h @@ -28,9 +28,9 @@ ccl_device_inline BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { /* todo: * - test if pushing distance on the stack helps (for non shadow rays) @@ -223,9 +223,9 @@ ccl_device_inline ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, local_isect, local_object, lcg_state, max_hits); } diff --git a/intern/cycles/kernel/bvh/nodes.h b/intern/cycles/kernel/bvh/nodes.h index 6d0ac621f69..c9792e9d95d 100644 --- a/intern/cycles/kernel/bvh/nodes.h +++ b/intern/cycles/kernel/bvh/nodes.h @@ -10,8 +10,8 @@ CCL_NAMESPACE_BEGIN // TODO(sergey): Look into avoid use of full Transform and use 3x3 matrix and // 3-vector which might be faster. ccl_device_forceinline Transform bvh_unaligned_node_fetch_space(KernelGlobals kg, - int node_addr, - int child) + const int node_addr, + const int child) { Transform space; const int child_addr = node_addr + child * 3; @@ -75,8 +75,8 @@ ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals kg, const float3 dir, const float tmin, const float tmax, - int node_addr, - int child, + const int node_addr, + const int child, float dist[2]) { Transform space = bvh_unaligned_node_fetch_space(kg, node_addr, child); diff --git a/intern/cycles/kernel/camera/camera.h b/intern/cycles/kernel/camera/camera.h index 904aec17444..01c8efcfb0e 100644 --- a/intern/cycles/kernel/camera/camera.h +++ b/intern/cycles/kernel/camera/camera.h @@ -231,8 +231,8 @@ ccl_device void camera_sample_orthographic(KernelGlobals kg, /* Panorama Camera */ ccl_device_inline float3 camera_panorama_direction(ccl_constant KernelCamera *cam, - float x, - float y) + const float x, + const float y) { const ProjectionTransform rastertocamera = cam->rastertocamera; const float3 Pcamera = transform_perspective(&rastertocamera, make_float3(x, y, 0.0f)); @@ -346,8 +346,8 @@ ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam, /* Common */ ccl_device_inline void camera_sample(KernelGlobals kg, - int x, - int y, + const int x, + const int y, const float2 filter_uv, const float time, const float2 lens_uv, @@ -418,7 +418,7 @@ ccl_device_inline float3 camera_position(KernelGlobals kg) return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); } -ccl_device_inline float camera_distance(KernelGlobals kg, float3 P) +ccl_device_inline float camera_distance(KernelGlobals kg, const float3 P) { const Transform cameratoworld = kernel_data.cam.cameratoworld; const float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); @@ -430,7 +430,7 @@ ccl_device_inline float camera_distance(KernelGlobals kg, float3 P) return len(P - camP); } -ccl_device_inline float camera_z_depth(KernelGlobals kg, float3 P) +ccl_device_inline float camera_z_depth(KernelGlobals kg, const float3 P) { if (kernel_data.cam.type != CAMERA_PANORAMA) { const Transform worldtocamera = kernel_data.cam.worldtocamera; @@ -441,7 +441,7 @@ ccl_device_inline float camera_z_depth(KernelGlobals kg, float3 P) return len(P - camP); } -ccl_device_inline float3 camera_direction_from_point(KernelGlobals kg, float3 P) +ccl_device_inline float3 camera_direction_from_point(KernelGlobals kg, const float3 P) { const Transform cameratoworld = kernel_data.cam.cameratoworld; diff --git a/intern/cycles/kernel/camera/projection.h b/intern/cycles/kernel/camera/projection.h index 26808327809..4305eec07ca 100644 --- a/intern/cycles/kernel/camera/projection.h +++ b/intern/cycles/kernel/camera/projection.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN /* Equirectangular coordinates <-> Cartesian direction */ -ccl_device float2 direction_to_equirectangular_range(float3 dir, float4 range) +ccl_device float2 direction_to_equirectangular_range(const float3 dir, const float4 range) { if (is_zero(dir)) { return zero_float2(); @@ -28,24 +28,26 @@ ccl_device float2 direction_to_equirectangular_range(float3 dir, float4 range) return make_float2(u, v); } -ccl_device float3 equirectangular_range_to_direction(float u, float v, float4 range) +ccl_device float3 equirectangular_range_to_direction(const float u, + const float v, + const float4 range) { const float phi = range.x * u + range.y; const float theta = range.z * v + range.w; return spherical_to_direction(theta, phi); } -ccl_device float2 direction_to_equirectangular(float3 dir) +ccl_device float2 direction_to_equirectangular(const float3 dir) { return direction_to_equirectangular_range(dir, make_float4(-M_2PI_F, M_PI_F, -M_PI_F, M_PI_F)); } -ccl_device float3 equirectangular_to_direction(float u, float v) +ccl_device float3 equirectangular_to_direction(const float u, const float v) { return equirectangular_range_to_direction(u, v, make_float4(-M_2PI_F, M_PI_F, -M_PI_F, M_PI_F)); } -ccl_device float2 direction_to_central_cylindrical(float3 dir, float4 range) +ccl_device float2 direction_to_central_cylindrical(const float3 dir, const float4 range) { const float z = dir.z / len(make_float2(dir.x, dir.y)); const float theta = atan2f(dir.y, dir.x); @@ -54,7 +56,9 @@ ccl_device float2 direction_to_central_cylindrical(float3 dir, float4 range) return make_float2(u, v); } -ccl_device float3 central_cylindrical_to_direction(float u, float v, float4 range) +ccl_device float3 central_cylindrical_to_direction(const float u, + const float v, + const float4 range) { const float theta = mix(range.x, range.y, u); const float z = mix(range.z, range.w, v); @@ -63,7 +67,10 @@ ccl_device float3 central_cylindrical_to_direction(float u, float v, float4 rang /* Fisheye <-> Cartesian direction */ -ccl_device_inline float3 fisheye_to_direction(float theta, float u, float v, float r) +ccl_device_inline float3 fisheye_to_direction(const float theta, + const float u, + float v, + const float r) { float phi = safe_acosf(safe_divide(u, r)); if (v < 0.0f) { @@ -73,7 +80,7 @@ ccl_device_inline float3 fisheye_to_direction(float theta, float u, float v, flo return make_float3(cosf(theta), -cosf(phi) * sinf(theta), sinf(phi) * sinf(theta)); } -ccl_device float2 direction_to_fisheye_equidistant(float3 dir, float fov) +ccl_device float2 direction_to_fisheye_equidistant(const float3 dir, const float fov) { const float r = atan2f(len(make_float2(dir.y, dir.z)), dir.x) / fov; const float2 uv = r * safe_normalize(make_float2(dir.y, dir.z)); @@ -96,7 +103,10 @@ ccl_device float3 fisheye_equidistant_to_direction(float u, float v, float fov) return fisheye_to_direction(theta, u, v, r); } -ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) +ccl_device float2 direction_to_fisheye_equisolid(const float3 dir, + const float lens, + const float width, + const float height) { const float theta = safe_acosf(dir.x); const float r = 2.0f * lens * sinf(theta * 0.5f); @@ -105,8 +115,8 @@ ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float w return make_float2(0.5f - uv.x / width, uv.y / height + 0.5f); } -ccl_device_inline float3 -fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) +ccl_device_inline float3 fisheye_equisolid_to_direction( + float u, float v, float lens, const float fov, const float width, const float height) { u = (u - 0.5f) * width; v = (v - 0.5f) * height; @@ -123,8 +133,13 @@ fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float wi return fisheye_to_direction(theta, u, v, r); } -ccl_device_inline float3 fisheye_lens_polynomial_to_direction( - float u, float v, float coeff0, float4 coeffs, float fov, float width, float height) +ccl_device_inline float3 fisheye_lens_polynomial_to_direction(float u, + float v, + float coeff0, + const float4 coeffs, + const float fov, + const float width, + const float height) { u = (u - 0.5f) * width; v = (v - 0.5f) * height; @@ -142,7 +157,7 @@ ccl_device_inline float3 fisheye_lens_polynomial_to_direction( } ccl_device float2 direction_to_fisheye_lens_polynomial( - float3 dir, float coeff0, float4 coeffs, float width, float height) + float3 dir, const float coeff0, const float4 coeffs, const float width, const float height) { const float theta = -safe_acosf(dir.x); @@ -183,7 +198,7 @@ ccl_device float2 direction_to_fisheye_lens_polynomial( /* Mirror Ball <-> Cartesion direction */ -ccl_device float3 mirrorball_to_direction(float u, float v) +ccl_device float3 mirrorball_to_direction(const float u, const float v) { /* point on sphere */ float3 dir; @@ -229,7 +244,7 @@ ccl_device float3 equiangular_cubemap_face_to_direction(float u, float v) return normalize(make_float3(1.0f, u, v)); } -ccl_device float2 direction_to_equiangular_cubemap_face(float3 dir) +ccl_device float2 direction_to_equiangular_cubemap_face(const float3 dir) { const float u = 0.5f - atan2f(dir.y, dir.x) * 2.0f / M_PI_F; const float v = atan2f(dir.z, dir.x) * 2.0f / M_PI_F + 0.5f; @@ -237,7 +252,9 @@ ccl_device float2 direction_to_equiangular_cubemap_face(float3 dir) return make_float2(u, v); } -ccl_device_inline float3 panorama_to_direction(ccl_constant KernelCamera *cam, float u, float v) +ccl_device_inline float3 panorama_to_direction(ccl_constant KernelCamera *cam, + const float u, + float v) { switch (cam->panorama_type) { case PANORAMA_EQUIRECTANGULAR: @@ -265,7 +282,7 @@ ccl_device_inline float3 panorama_to_direction(ccl_constant KernelCamera *cam, f } } -ccl_device_inline float2 direction_to_panorama(ccl_constant KernelCamera *cam, float3 dir) +ccl_device_inline float2 direction_to_panorama(ccl_constant KernelCamera *cam, const float3 dir) { switch (cam->panorama_type) { case PANORAMA_EQUIRECTANGULAR: diff --git a/intern/cycles/kernel/closure/alloc.h b/intern/cycles/kernel/closure/alloc.h index 30c186af038..8406528e397 100644 --- a/intern/cycles/kernel/closure/alloc.h +++ b/intern/cycles/kernel/closure/alloc.h @@ -9,7 +9,7 @@ CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure *closure_alloc(ccl_private ShaderData *sd, - int size, + const int size, ClosureType type, Spectrum weight) { @@ -30,7 +30,7 @@ ccl_device ccl_private ShaderClosure *closure_alloc(ccl_private ShaderData *sd, return sc; } -ccl_device ccl_private void *closure_alloc_extra(ccl_private ShaderData *sd, int size) +ccl_device ccl_private void *closure_alloc_extra(ccl_private ShaderData *sd, const int size) { /* Allocate extra space for closure that need more parameters. We allocate * in chunks of sizeof(ShaderClosure) starting from the end of the closure @@ -52,7 +52,7 @@ ccl_device ccl_private void *closure_alloc_extra(ccl_private ShaderData *sd, int } ccl_device_inline ccl_private ShaderClosure *bsdf_alloc(ccl_private ShaderData *sd, - int size, + const int size, Spectrum weight) { kernel_assert(isfinite_safe(weight)); diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index 0419801041c..d30816d3690 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -59,7 +59,10 @@ ccl_device_inline float bsdf_get_roughness_pass_squared(const ccl_private Shader /* An additional term to smooth illumination on grazing angles when using bump mapping. * Based on "Taming the Shadow Terminator" by Matt Jen-Yuan Chiang, * Yining Karl Li and Brent Burley. */ -ccl_device_inline float bump_shadowing_term(int shader_flag, float3 Ng, float3 N, float3 I) +ccl_device_inline float bump_shadowing_term(const int shader_flag, + float3 Ng, + const float3 N, + float3 I) { const float cosNI = dot(N, I); if (cosNI < 0.0f) { @@ -570,7 +573,7 @@ ccl_device_inline return eval; } -ccl_device void bsdf_blur(KernelGlobals kg, ccl_private ShaderClosure *sc, float roughness) +ccl_device void bsdf_blur(KernelGlobals kg, ccl_private ShaderClosure *sc, const float roughness) { /* TODO: do we want to blur volume closures? */ #if defined(__SVM__) || defined(__OSL__) diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h index dc414a51520..d5278d974d8 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h @@ -32,7 +32,7 @@ ccl_device int bsdf_ashikhmin_shirley_setup(ccl_private MicrofacetBsdf *bsdf) return SD_BSDF | SD_BSDF_HAS_EVAL; } -ccl_device void bsdf_ashikhmin_shirley_blur(ccl_private ShaderClosure *sc, float roughness) +ccl_device void bsdf_ashikhmin_shirley_blur(ccl_private ShaderClosure *sc, const float roughness) { ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)sc; @@ -40,7 +40,7 @@ ccl_device void bsdf_ashikhmin_shirley_blur(ccl_private ShaderClosure *sc, float bsdf->alpha_y = fmaxf(roughness, bsdf->alpha_y); } -ccl_device_inline float bsdf_ashikhmin_shirley_roughness_to_exponent(float roughness) +ccl_device_inline float bsdf_ashikhmin_shirley_roughness_to_exponent(const float roughness) { return 2.0f / (roughness * roughness) - 2.0f; } @@ -117,8 +117,11 @@ ccl_device_forceinline Spectrum bsdf_ashikhmin_shirley_eval(const ccl_private Sh return make_spectrum(out); } -ccl_device_inline void bsdf_ashikhmin_shirley_sample_first_quadrant( - float n_x, float n_y, const float2 rand, ccl_private float *phi, ccl_private float *cos_theta) +ccl_device_inline void bsdf_ashikhmin_shirley_sample_first_quadrant(float n_x, + const float n_y, + const float2 rand, + ccl_private float *phi, + ccl_private float *cos_theta) { *phi = atanf(sqrtf((n_x + 1.0f) / (n_y + 1.0f)) * tanf(M_PI_2_F * rand.x)); const float cos_phi = cosf(*phi); @@ -127,8 +130,8 @@ ccl_device_inline void bsdf_ashikhmin_shirley_sample_first_quadrant( } ccl_device int bsdf_ashikhmin_shirley_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h index 656bbd37c95..5686a5e3d61 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h @@ -77,8 +77,8 @@ ccl_device Spectrum bsdf_ashikhmin_velvet_eval(const ccl_private ShaderClosure * } ccl_device int bsdf_ashikhmin_velvet_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h index 49827d1caea..51e6238064c 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse.h @@ -41,9 +41,9 @@ ccl_device Spectrum bsdf_diffuse_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_diffuse_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) @@ -86,9 +86,9 @@ ccl_device Spectrum bsdf_translucent_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_translucent_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h index 4f5dea26ccf..730bfa840e9 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h @@ -46,7 +46,7 @@ ccl_device int bsdf_diffuse_ramp_setup(DiffuseRampBsdf *bsdf) return SD_BSDF | SD_BSDF_HAS_EVAL; } -ccl_device void bsdf_diffuse_ramp_blur(ccl_private ShaderClosure *sc, float roughness) {} +ccl_device void bsdf_diffuse_ramp_blur(ccl_private ShaderClosure *sc, const float roughness) {} ccl_device Spectrum bsdf_diffuse_ramp_eval(const ccl_private ShaderClosure *sc, const float3 wi, @@ -66,9 +66,9 @@ ccl_device Spectrum bsdf_diffuse_ramp_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_diffuse_ramp_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h index 7b10ec4bf4b..a1b4277f967 100644 --- a/intern/cycles/kernel/closure/bsdf_hair.h +++ b/intern/cycles/kernel/closure/bsdf_hair.h @@ -144,9 +144,9 @@ ccl_device Spectrum bsdf_hair_transmission_eval(const ccl_private ShaderClosure } ccl_device int bsdf_hair_reflection_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, @@ -199,9 +199,9 @@ ccl_device int bsdf_hair_reflection_sample(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_hair_transmission_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index 9862adc8f79..6a7a81104d0 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -462,7 +462,7 @@ ccl_device Spectrum bsdf_microfacet_estimate_albedo(KernelGlobals kg, * Eric Heitz, JCGT Vol. 3, No. 2, 2014. * https://jcgt.org/published/0003/02/03/ */ template -ccl_device_inline float bsdf_lambda_from_sqr_alpha_tan_n(float sqr_alpha_tan_n) +ccl_device_inline float bsdf_lambda_from_sqr_alpha_tan_n(const float sqr_alpha_tan_n) { if (m_type == MicrofacetType::GGX) { /* Equation 72. */ @@ -479,33 +479,36 @@ ccl_device_inline float bsdf_lambda_from_sqr_alpha_tan_n(float sqr_alpha_tan_n) return ((0.396f * a - 1.259f) * a + 1.0f) / ((2.181f * a + 3.535f) * a); } -template ccl_device_inline float bsdf_lambda(float alpha2, float cos_N) +template +ccl_device_inline float bsdf_lambda(const float alpha2, const float cos_N) { return bsdf_lambda_from_sqr_alpha_tan_n(alpha2 * fmaxf(1.0f / sqr(cos_N) - 1.0f, 0.0f)); } template -ccl_device_inline float bsdf_aniso_lambda(float alpha_x, float alpha_y, float3 V) +ccl_device_inline float bsdf_aniso_lambda(const float alpha_x, const float alpha_y, const float3 V) { const float sqr_alpha_tan_n = (sqr(alpha_x * V.x) + sqr(alpha_y * V.y)) / sqr(V.z); return bsdf_lambda_from_sqr_alpha_tan_n(sqr_alpha_tan_n); } /* Mono-directional shadowing-masking term. */ -template ccl_device_inline float bsdf_G(float alpha2, float cos_N) +template +ccl_device_inline float bsdf_G(const float alpha2, const float cos_N) { return 1.0f / (1.0f + bsdf_lambda(alpha2, cos_N)); } /* Combined shadowing-masking term. */ template -ccl_device_inline float bsdf_G(float alpha2, float cos_NI, float cos_NO) +ccl_device_inline float bsdf_G(const float alpha2, const float cos_NI, const float cos_NO) { return 1.0f / (1.0f + bsdf_lambda(alpha2, cos_NI) + bsdf_lambda(alpha2, cos_NO)); } /* Normal distribution function. */ -template ccl_device_inline float bsdf_D(float alpha2, float cos_NH) +template +ccl_device_inline float bsdf_D(const float alpha2, const float cos_NH) { const float cos_NH2 = min(sqr(cos_NH), 1.0f); const float one_minus_cos_NH2 = 1.0f - cos_NH2; @@ -518,7 +521,7 @@ template ccl_device_inline float bsdf_D(float alpha2, flo } template -ccl_device_inline float bsdf_aniso_D(float alpha_x, float alpha_y, float3 H) +ccl_device_inline float bsdf_aniso_D(const float alpha_x, const float alpha_y, float3 H) { H /= make_float3(alpha_x, alpha_y, 1.0f); @@ -635,8 +638,8 @@ ccl_device Spectrum bsdf_microfacet_eval(KernelGlobals kg, template ccl_device int bsdf_microfacet_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, @@ -965,7 +968,7 @@ ccl_device int bsdf_microfacet_ggx_glass_setup(ccl_private MicrofacetBsdf *bsdf) return SD_BSDF | SD_BSDF_HAS_TRANSMISSION | bsdf_microfacet_eval_flag(bsdf); } -ccl_device void bsdf_microfacet_blur(ccl_private ShaderClosure *sc, float roughness) +ccl_device void bsdf_microfacet_blur(ccl_private ShaderClosure *sc, const float roughness) { ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)sc; @@ -986,8 +989,8 @@ ccl_device Spectrum bsdf_microfacet_ggx_eval(KernelGlobals kg, ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, @@ -1052,8 +1055,8 @@ ccl_device Spectrum bsdf_microfacet_beckmann_eval(KernelGlobals kg, ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, diff --git a/intern/cycles/kernel/closure/bsdf_oren_nayar.h b/intern/cycles/kernel/closure/bsdf_oren_nayar.h index b1d948f56f0..3be5ae78d3f 100644 --- a/intern/cycles/kernel/closure/bsdf_oren_nayar.h +++ b/intern/cycles/kernel/closure/bsdf_oren_nayar.h @@ -39,9 +39,9 @@ ccl_device_inline float bsdf_oren_nayar_G(const float cosTheta) } ccl_device Spectrum bsdf_oren_nayar_get_intensity(const ccl_private ShaderClosure *sc, - float3 n, - float3 v, - float3 l) + const float3 n, + const float3 v, + const float3 l) { const ccl_private OrenNayarBsdf *bsdf = (const ccl_private OrenNayarBsdf *)sc; const float nl = max(dot(n, l), 0.0f); @@ -98,9 +98,9 @@ ccl_device Spectrum bsdf_oren_nayar_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_oren_nayar_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h index 57471c3e1f1..df3f46e69ce 100644 --- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h @@ -73,14 +73,14 @@ ccl_device Spectrum bsdf_phong_ramp_eval(const ccl_private ShaderClosure *sc, return zero_spectrum(); } -ccl_device_inline float phong_ramp_exponent_to_roughness(float exponent) +ccl_device_inline float phong_ramp_exponent_to_roughness(const float exponent) { return sqrt(1.0f / ((exponent + 2.0f) / 2.0f)); } ccl_device int bsdf_phong_ramp_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, diff --git a/intern/cycles/kernel/closure/bsdf_principled_hair_chiang.h b/intern/cycles/kernel/closure/bsdf_principled_hair_chiang.h index 53eedcc2e6a..4ac947faca6 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_hair_chiang.h +++ b/intern/cycles/kernel/closure/bsdf_principled_hair_chiang.h @@ -43,26 +43,26 @@ static_assert(sizeof(ShaderClosure) >= sizeof(ChiangHairBSDF), "ChiangHairBSDF i /* Gives the change in direction in the normal plane for the given angles and p-th-order * scattering. */ -ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t) +ccl_device_inline float delta_phi(const int p, const float gamma_o, const float gamma_t) { return 2.0f * p * gamma_t - 2.0f * gamma_o + p * M_PI_F; } /* Remaps the given angle to [-pi, pi]. */ -ccl_device_inline float wrap_angle(float a) +ccl_device_inline float wrap_angle(const float a) { return (a + M_PI_F) - M_2PI_F * floorf((a + M_PI_F) / M_2PI_F) - M_PI_F; } /* Logistic distribution function. */ -ccl_device_inline float logistic(float x, float s) +ccl_device_inline float logistic(const float x, const float s) { const float v = expf(-fabsf(x) / s); return v / (s * sqr(1.0f + v)); } /* Logistic cumulative density function. */ -ccl_device_inline float logistic_cdf(float x, float s) +ccl_device_inline float logistic_cdf(const float x, const float s) { const float arg = -x / s; /* expf() overflows if arg >= 89.0. */ @@ -94,7 +94,7 @@ ccl_device_inline float bessel_I0(float x) } /* Logarithm of the Bessel function of the first kind. */ -ccl_device_inline float log_bessel_I0(float x) +ccl_device_inline float log_bessel_I0(const float x) { if (x > 12.0f) { /* log(1/x) == -log(x) if x > 0. @@ -105,7 +105,7 @@ ccl_device_inline float log_bessel_I0(float x) } /* Logistic distribution limited to the interval [-pi, pi]. */ -ccl_device_inline float trimmed_logistic(float x, float s) +ccl_device_inline float trimmed_logistic(const float x, const float s) { /* The logistic distribution is symmetric and centered around zero, * so logistic_cdf(x, s) = 1 - logistic_cdf(-x, s). @@ -116,7 +116,7 @@ ccl_device_inline float trimmed_logistic(float x, float s) } /* Sampling function for the trimmed logistic function. */ -ccl_device_inline float sample_trimmed_logistic(float u, float s) +ccl_device_inline float sample_trimmed_logistic(const float u, const float s) { const float cdf_minuspi = logistic_cdf(-M_PI_F, s); const float x = -s * logf(1.0f / (u * (1.0f - 2.0f * cdf_minuspi) + cdf_minuspi) - 1.0f); @@ -125,7 +125,7 @@ ccl_device_inline float sample_trimmed_logistic(float u, float s) /* Azimuthal scattering function Np. */ ccl_device_inline float azimuthal_scattering( - float phi, int p, float s, float gamma_o, float gamma_t) + float phi, const int p, const float s, float gamma_o, const float gamma_t) { const float phi_o = wrap_angle(phi - delta_phi(p, gamma_o, gamma_t)); const float val = trimmed_logistic(phi_o, s); @@ -133,8 +133,11 @@ ccl_device_inline float azimuthal_scattering( } /* Longitudinal scattering function Mp. */ -ccl_device_inline float longitudinal_scattering( - float sin_theta_i, float cos_theta_i, float sin_theta_o, float cos_theta_o, float v) +ccl_device_inline float longitudinal_scattering(float sin_theta_i, + const float cos_theta_i, + const float sin_theta_o, + const float cos_theta_o, + const float v) { const float inv_v = 1.0f / v; const float cos_arg = cos_theta_i * cos_theta_o * inv_v; @@ -192,8 +195,11 @@ ccl_device int bsdf_hair_chiang_setup(ccl_private ShaderData *sd, ccl_private Ch #endif /* __HAIR__ */ /* Given the Fresnel term and transmittance, generate the attenuation terms for each bounce. */ -ccl_device_inline void hair_attenuation( - KernelGlobals kg, float f, Spectrum T, ccl_private Spectrum *Ap, ccl_private float *Ap_energy) +ccl_device_inline void hair_attenuation(KernelGlobals kg, + const float f, + Spectrum T, + ccl_private Spectrum *Ap, + ccl_private float *Ap_energy) { /* Primary specular (R). */ Ap[0] = make_spectrum(f); @@ -225,9 +231,9 @@ ccl_device_inline void hair_attenuation( } /* Update sin_theta_o and cos_theta_o to account for scale tilt for each bounce. */ -ccl_device_inline void hair_alpha_angles(float sin_theta_o, - float cos_theta_o, - float alpha, +ccl_device_inline void hair_alpha_angles(const float sin_theta_o, + const float cos_theta_o, + const float alpha, ccl_private float *angles) { const float sin_1alpha = sinf(alpha); @@ -447,7 +453,7 @@ ccl_device int bsdf_hair_chiang_sample(KernelGlobals kg, } /* Implements Filter Glossy by capping the effective roughness. */ -ccl_device void bsdf_hair_chiang_blur(ccl_private ShaderClosure *sc, float roughness) +ccl_device void bsdf_hair_chiang_blur(ccl_private ShaderClosure *sc, const float roughness) { ccl_private ChiangHairBSDF *bsdf = (ccl_private ChiangHairBSDF *)sc; diff --git a/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h b/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h index 08fb6b6afe3..1b0bb0a4aa5 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h +++ b/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h @@ -125,7 +125,7 @@ ccl_device_inline float2 dir_sph(const float3 w) } /* Conversion between `gamma` and `phi`. Notations see Figure 5 in the paper. */ -ccl_device_inline float to_phi(float gamma, float b) +ccl_device_inline float to_phi(const float gamma, const float b) { if (b == 1.0f) { return gamma; @@ -136,7 +136,7 @@ ccl_device_inline float to_phi(float gamma, float b) return atan2f(b * sin_gamma, cos_gamma); } -ccl_device_inline float to_gamma(float phi, float b) +ccl_device_inline float to_gamma(const float phi, const float b) { if (b == 1.0f) { return phi; @@ -157,7 +157,7 @@ ccl_device_inline float h_to_gamma(const float h_div_r, const float b, const flo /* Compute the coordinate on the ellipse, given `gamma` and the aspect ratio between the minor axis * and the major axis. */ -ccl_device_inline float2 to_point(float gamma, float b) +ccl_device_inline float2 to_point(const float gamma, const float b) { float sin_gamma; float cos_gamma; @@ -166,7 +166,7 @@ ccl_device_inline float2 to_point(float gamma, float b) } /* Compute the vector direction given by `theta` and `gamma`. */ -ccl_device_inline float3 sphg_dir(float theta, float gamma, float b) +ccl_device_inline float3 sphg_dir(const float theta, const float gamma, const float b) { float sin_theta; float cos_theta; @@ -191,7 +191,7 @@ ccl_device_inline float3 sphg_dir(float theta, float gamma, float b) return make_float3(sin_phi * cos_theta, sin_theta, cos_phi * cos_theta); } -ccl_device_inline float arc_length(float e2, float gamma) +ccl_device_inline float arc_length(const float e2, const float gamma) { return e2 == 0 ? 1.0f : sqrtf(1.0f - e2 * sqr(sinf(gamma))); } @@ -207,7 +207,7 @@ ccl_device_inline bool is_nearfield(const ccl_private HuangHairBSDF *bsdf) /* Set up the hair closure. */ ccl_device int bsdf_hair_huang_setup(ccl_private ShaderData *sd, ccl_private HuangHairBSDF *bsdf, - uint32_t path_flag) + const uint32_t path_flag) { bsdf->type = CLOSURE_BSDF_HAIR_HUANG_ID; @@ -279,9 +279,9 @@ ccl_device int bsdf_hair_huang_setup(ccl_private ShaderData *sd, /* Albedo correction, treat as glass. `rough` has already applied square root. */ ccl_device_forceinline float bsdf_hair_huang_energy_scale(KernelGlobals kg, - float mu, - float rough, - float ior) + const float mu, + const float rough, + const float ior) { const bool inv_table = (ior < 1.0f); const int ofs = inv_table ? kernel_data.tables.ggx_glass_inv_E : kernel_data.tables.ggx_glass_E; @@ -320,7 +320,7 @@ ccl_device_inline bool microfacet_visible(const float3 wi, } /* Combined shadowing-masking term divided by the shadowing-masking in the incoming direction. */ -ccl_device_inline float bsdf_Go(float alpha2, float cos_NI, float cos_NO) +ccl_device_inline float bsdf_Go(const float alpha2, const float cos_NI, const float cos_NO) { const float lambdaI = bsdf_lambda(alpha2, cos_NI); const float lambdaO = bsdf_lambda(alpha2, cos_NO); @@ -579,7 +579,7 @@ ccl_device Spectrum bsdf_hair_huang_eval_residual(KernelGlobals kg, ccl_device int bsdf_hair_huang_sample(const KernelGlobals kg, const ccl_private ShaderClosure *sc, ccl_private ShaderData *sd, - float3 rand, + const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, @@ -883,7 +883,7 @@ ccl_device Spectrum bsdf_hair_huang_eval(KernelGlobals kg, } /* Implements Filter Glossy by capping the effective roughness. */ -ccl_device void bsdf_hair_huang_blur(ccl_private ShaderClosure *sc, float roughness) +ccl_device void bsdf_hair_huang_blur(ccl_private ShaderClosure *sc, const float roughness) { ccl_private HuangHairBSDF *bsdf = (ccl_private HuangHairBSDF *)sc; diff --git a/intern/cycles/kernel/closure/bsdf_ray_portal.h b/intern/cycles/kernel/closure/bsdf_ray_portal.h index 75827e8ad47..a44e77d8b69 100644 --- a/intern/cycles/kernel/closure/bsdf_ray_portal.h +++ b/intern/cycles/kernel/closure/bsdf_ray_portal.h @@ -21,8 +21,8 @@ static_assert(sizeof(ShaderClosure) >= sizeof(RayPortalClosure), "RayPortalClosu ccl_device void bsdf_ray_portal_setup(ccl_private ShaderData *sd, const Spectrum weight, - uint32_t path_flag, - float3 position, + const uint32_t path_flag, + const float3 position, float3 direction) { /* Check cutoff weight. */ diff --git a/intern/cycles/kernel/closure/bsdf_sheen.h b/intern/cycles/kernel/closure/bsdf_sheen.h index 7b6f21d4303..bd0e1f0255b 100644 --- a/intern/cycles/kernel/closure/bsdf_sheen.h +++ b/intern/cycles/kernel/closure/bsdf_sheen.h @@ -84,9 +84,9 @@ ccl_device Spectrum bsdf_sheen_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_sheen_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h index 35d847dbb7f..9c542f11a2a 100644 --- a/intern/cycles/kernel/closure/bsdf_toon.h +++ b/intern/cycles/kernel/closure/bsdf_toon.h @@ -38,7 +38,9 @@ ccl_device int bsdf_diffuse_toon_setup(ccl_private ToonBsdf *bsdf) return bsdf_toon_setup_common(bsdf); } -ccl_device float bsdf_toon_get_intensity(float max_angle, float smooth, float angle) +ccl_device float bsdf_toon_get_intensity(const float max_angle, + const float smooth, + const float angle) { float is; @@ -55,7 +57,7 @@ ccl_device float bsdf_toon_get_intensity(float max_angle, float smooth, float an return is; } -ccl_device float bsdf_toon_get_sample_angle(float max_angle, float smooth) +ccl_device float bsdf_toon_get_sample_angle(const float max_angle, const float smooth) { return fminf(max_angle + smooth, M_PI_2_F); } @@ -86,9 +88,9 @@ ccl_device Spectrum bsdf_diffuse_toon_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_diffuse_toon_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) @@ -150,9 +152,9 @@ ccl_device Spectrum bsdf_glossy_toon_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_glossy_toon_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, - float2 rand, + const float3 Ng, + const float3 wi, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h index f3a069cb303..82f9109f622 100644 --- a/intern/cycles/kernel/closure/bsdf_transparent.h +++ b/intern/cycles/kernel/closure/bsdf_transparent.h @@ -15,7 +15,7 @@ CCL_NAMESPACE_BEGIN ccl_device void bsdf_transparent_setup(ccl_private ShaderData *sd, const Spectrum weight, - uint32_t path_flag) + const uint32_t path_flag) { /* Check cutoff weight. */ const float sample_weight = fabsf(average(weight)); @@ -71,8 +71,8 @@ ccl_device Spectrum bsdf_transparent_eval(const ccl_private ShaderClosure *sc, } ccl_device int bsdf_transparent_sample(const ccl_private ShaderClosure *sc, - float3 Ng, - float3 wi, + const float3 Ng, + const float3 wi, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h index 924d3a03294..baf232d1582 100644 --- a/intern/cycles/kernel/closure/bsdf_util.h +++ b/intern/cycles/kernel/closure/bsdf_util.h @@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN * Also returns the dot product of the refracted ray and the normal as `cos_theta_t`, as it is * used when computing the direction of the refracted ray. */ ccl_device float2 fresnel_dielectric_polarized(float cos_theta_i, - float eta, + const float eta, ccl_private float *r_cos_theta_t, ccl_private float2 *r_phi) { @@ -66,8 +66,8 @@ ccl_device float2 fresnel_dielectric_polarized(float cos_theta_i, } /* Compute fresnel reflectance for unpolarized light. */ -ccl_device_forceinline float fresnel_dielectric(float cos_theta_i, - float eta, +ccl_device_forceinline float fresnel_dielectric(const float cos_theta_i, + const float eta, ccl_private float *r_cos_theta_t) { return average(fresnel_dielectric_polarized(cos_theta_i, eta, r_cos_theta_t, nullptr)); @@ -83,7 +83,7 @@ ccl_device_inline float3 refract_angle(const float3 incident, return (inv_eta * dot(normal, incident) + cos_theta_t) * normal - inv_eta * incident; } -ccl_device float fresnel_dielectric_cos(float cosi, float eta) +ccl_device float fresnel_dielectric_cos(const float cosi, const float eta) { // compute fresnel reflectance without explicitly computing // the refracted direction @@ -98,7 +98,7 @@ ccl_device float fresnel_dielectric_cos(float cosi, float eta) return 1.0f; // TIR(no refracted component) } -ccl_device Spectrum fresnel_conductor(float cosi, const Spectrum eta, const Spectrum k) +ccl_device Spectrum fresnel_conductor(const float cosi, const Spectrum eta, const Spectrum k) { const Spectrum cosi2 = make_spectrum(cosi * cosi); const Spectrum one = make_spectrum(1.0f); @@ -110,18 +110,18 @@ ccl_device Spectrum fresnel_conductor(float cosi, const Spectrum eta, const Spec return (Rparl2 + Rperp2) * 0.5f; } -ccl_device float ior_from_F0(float f0) +ccl_device float ior_from_F0(const float f0) { const float sqrt_f0 = sqrtf(clamp(f0, 0.0f, 0.99f)); return (1.0f + sqrt_f0) / (1.0f - sqrt_f0); } -ccl_device float F0_from_ior(float ior) +ccl_device float F0_from_ior(const float ior) { return sqr((ior - 1.0f) / (ior + 1.0f)); } -ccl_device float schlick_fresnel(float u) +ccl_device float schlick_fresnel(const float u) { const float m = clamp(1.0f - u, 0.0f, 1.0f); const float m2 = m * m; @@ -129,9 +129,9 @@ ccl_device float schlick_fresnel(float u) } /* Calculate the fresnel color, which is a blend between white and the F0 color */ -ccl_device_forceinline Spectrum interpolate_fresnel_color(float3 L, - float3 H, - float ior, +ccl_device_forceinline Spectrum interpolate_fresnel_color(const float3 L, + const float3 H, + const float ior, Spectrum F0) { /* Compute the real Fresnel term and remap it from real_F0..1 to F0..1. @@ -148,7 +148,7 @@ ccl_device_forceinline Spectrum interpolate_fresnel_color(float3 L, /* If the shading normal results in specular reflection in the lower hemisphere, raise the shading * normal towards the geometry normal so that the specular reflection is just above the surface. * Only used for glossy materials. */ -ccl_device float3 ensure_valid_specular_reflection(float3 Ng, float3 I, float3 N) +ccl_device float3 ensure_valid_specular_reflection(const float3 Ng, const float3 I, float3 N) { const float3 R = 2 * dot(N, I) * N - I; @@ -225,7 +225,8 @@ ccl_device float3 ensure_valid_specular_reflection(float3 Ng, float3 I, float3 N /* Do not call #ensure_valid_specular_reflection if the primitive type is curve or if the geometry * normal and the shading normal is the same. */ -ccl_device float3 maybe_ensure_valid_specular_reflection(ccl_private ShaderData *sd, float3 N) +ccl_device float3 maybe_ensure_valid_specular_reflection(ccl_private ShaderData *sd, + const float3 N) { if ((sd->flag & SD_USE_BUMP_MAP_CORRECTION) == 0) { return N; @@ -288,7 +289,7 @@ ccl_device_inline Spectrum closure_layering_weight(const Spectrum layer_albedo, * transform and store them as a LUT that gets looked up here. * In practice, using the XYZ fit and converting the result from XYZ to RGB is easier. */ -ccl_device_inline Spectrum iridescence_lookup_sensitivity(float OPD, float shift) +ccl_device_inline Spectrum iridescence_lookup_sensitivity(const float OPD, const float shift) { const float phase = M_2PI_F * OPD * 1e-9f; const float3 val = make_float3(5.4856e-13f, 4.4201e-13f, 5.2481e-13f); @@ -300,8 +301,8 @@ ccl_device_inline Spectrum iridescence_lookup_sensitivity(float OPD, float shift return xyz / 1.0685e-7f; } -ccl_device_inline float3 -iridescence_airy_summation(float T121, float R12, float R23, float OPD, float phi) +ccl_device_inline float3 iridescence_airy_summation( + const float T121, const float R12, const float R23, const float OPD, const float phi) { if (R23 == 1.0f) { /* Shortcut for TIR on the bottom interface. */ @@ -328,7 +329,7 @@ ccl_device Spectrum fresnel_iridescence(KernelGlobals kg, float eta2, float eta3, float cos_theta_1, - float thickness, + const float thickness, ccl_private float *r_cos_theta_3) { /* For films below 30nm, the wave-optic-based Airy summation approach no longer applies, diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h index 8f793f32f77..6abe1f79e71 100644 --- a/intern/cycles/kernel/closure/bssrdf.h +++ b/intern/cycles/kernel/closure/bssrdf.h @@ -27,13 +27,13 @@ static_assert(sizeof(ShaderClosure) >= sizeof(Bssrdf), "Bssrdf is too large!"); /* Random Walk BSSRDF */ -ccl_device float bssrdf_dipole_compute_Rd(float alpha_prime, float fourthirdA) +ccl_device float bssrdf_dipole_compute_Rd(const float alpha_prime, const float fourthirdA) { const float s = sqrtf(3.0f * (1.0f - alpha_prime)); return 0.5f * alpha_prime * (1.0f + expf(-fourthirdA * s)) * expf(-s); } -ccl_device float bssrdf_dipole_compute_alpha_prime(float rd, float fourthirdA) +ccl_device float bssrdf_dipole_compute_alpha_prime(const float rd, const float fourthirdA) { /* Little Newton solver. */ if (rd < 1e-4f) { @@ -99,7 +99,7 @@ ccl_device void bssrdf_setup_radius(ccl_private Bssrdf *bssrdf, const ClosureTyp #define BURLEY_TRUNCATE 16.0f #define BURLEY_TRUNCATE_CDF 0.9963790093708328f // cdf(BURLEY_TRUNCATE) -ccl_device_inline float bssrdf_burley_fitting(float A) +ccl_device_inline float bssrdf_burley_fitting(const float A) { /* Diffuse surface transmission, equation (6). */ return 1.9f - A + 3.5f * (A - 0.8f) * (A - 0.8f); @@ -126,7 +126,7 @@ ccl_device void bssrdf_burley_setup(ccl_private Bssrdf *bssrdf) bssrdf->radius = l / s; } -ccl_device float bssrdf_burley_eval(const float d, float r) +ccl_device float bssrdf_burley_eval(const float d, const float r) { const float Rm = BURLEY_TRUNCATE * d; @@ -147,7 +147,7 @@ ccl_device float bssrdf_burley_eval(const float d, float r) return (exp_r_d + exp_r_3_d) / (4.0f * d); } -ccl_device float bssrdf_burley_pdf(const float d, float r) +ccl_device float bssrdf_burley_pdf(const float d, const float r) { if (r == 0.0f) { return 0.0f; @@ -160,7 +160,7 @@ ccl_device float bssrdf_burley_pdf(const float d, float r) * Returns scaled radius, meaning the result is to be scaled up by d. * Since there's no closed form solution we do Newton-Raphson method to find it. */ -ccl_device_forceinline float bssrdf_burley_root_find(float xi) +ccl_device_forceinline float bssrdf_burley_root_find(const float xi) { const float tolerance = 1e-6f; const int max_iteration_count = 10; @@ -195,7 +195,7 @@ ccl_device_forceinline float bssrdf_burley_root_find(float xi) } ccl_device void bssrdf_burley_sample(const float d, - float xi, + const float xi, ccl_private float *r, ccl_private float *h) { @@ -250,7 +250,7 @@ ccl_device void bssrdf_sample(const Spectrum radius, bssrdf_burley_sample(sampled_radius, xi, r, h); } -ccl_device_forceinline Spectrum bssrdf_eval(const Spectrum radius, float r) +ccl_device_forceinline Spectrum bssrdf_eval(const Spectrum radius, const float r) { Spectrum result; FOREACH_SPECTRUM_CHANNEL (i) { @@ -259,7 +259,7 @@ ccl_device_forceinline Spectrum bssrdf_eval(const Spectrum radius, float r) return result; } -ccl_device_forceinline float bssrdf_pdf(const Spectrum radius, float r) +ccl_device_forceinline float bssrdf_pdf(const Spectrum radius, const float r) { const Spectrum pdf = bssrdf_eval(radius, r); return reduce_add(pdf) / bssrdf_num_channels(radius); @@ -287,7 +287,7 @@ ccl_device_inline ccl_private Bssrdf *bssrdf_alloc(ccl_private ShaderData *sd, S ccl_device int bssrdf_setup(ccl_private ShaderData *sd, ccl_private Bssrdf *bssrdf, - int path_flag, + const int path_flag, ClosureType type) { /* Clamps protecting against bad/extreme and non physical values. */ diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h index 74e522158d9..bf2d4a336d9 100644 --- a/intern/cycles/kernel/closure/emissive.h +++ b/intern/cycles/kernel/closure/emissive.h @@ -46,8 +46,11 @@ ccl_device float emissive_pdf(const float3 Ng, const float3 wi) return (cosNI > 0.0f) ? 1.0f : 0.0f; } -ccl_device void emissive_sample( - const float3 Ng, float randu, float randv, ccl_private float3 *wi, ccl_private float *pdf) +ccl_device void emissive_sample(const float3 Ng, + const float randu, + const float randv, + ccl_private float3 *wi, + ccl_private float *pdf) { /* todo: not implemented and used yet */ } diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h index c68c55304e2..d753ca1480c 100644 --- a/intern/cycles/kernel/closure/volume.h +++ b/intern/cycles/kernel/closure/volume.h @@ -30,7 +30,7 @@ ccl_device void volume_extinction_setup(ccl_private ShaderData *sd, Spectrum wei ccl_device Spectrum volume_phase_eval(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float3 wo, + const float3 wo, ccl_private float *pdf) { switch (svc->type) { @@ -51,7 +51,7 @@ ccl_device Spectrum volume_phase_eval(const ccl_private ShaderData *sd, ccl_device int volume_phase_sample(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float2 rand, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) @@ -129,12 +129,12 @@ ccl_device float volume_phase_get_g(const ccl_private ShaderVolumeClosure *svc) * unnecessary work in volumes and subsurface scattering. */ #define VOLUME_THROUGHPUT_EPSILON 1e-6f -ccl_device Spectrum volume_color_transmittance(Spectrum sigma, float t) +ccl_device Spectrum volume_color_transmittance(Spectrum sigma, const float t) { return exp(-sigma * t); } -ccl_device float volume_channel_get(Spectrum value, int channel) +ccl_device float volume_channel_get(Spectrum value, const int channel) { return GET_SPECTRUM_CHANNEL(value, channel); } diff --git a/intern/cycles/kernel/closure/volume_draine.h b/intern/cycles/kernel/closure/volume_draine.h index b74d6fa29d8..dd9b5b2aac7 100644 --- a/intern/cycles/kernel/closure/volume_draine.h +++ b/intern/cycles/kernel/closure/volume_draine.h @@ -31,7 +31,7 @@ ccl_device int volume_draine_setup(ccl_private DraineVolume *volume) ccl_device Spectrum volume_draine_eval(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float3 wo, + const float3 wo, ccl_private float *pdf) { const ccl_private DraineVolume *volume = (const ccl_private DraineVolume *)svc; @@ -45,7 +45,7 @@ ccl_device Spectrum volume_draine_eval(const ccl_private ShaderData *sd, ccl_device int volume_draine_sample(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float2 rand, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/volume_fournier_forand.h b/intern/cycles/kernel/closure/volume_fournier_forand.h index 9d1929134f8..dce78de4032 100644 --- a/intern/cycles/kernel/closure/volume_fournier_forand.h +++ b/intern/cycles/kernel/closure/volume_fournier_forand.h @@ -40,7 +40,7 @@ ccl_device int volume_fournier_forand_setup(ccl_private FournierForandVolume *vo ccl_device Spectrum volume_fournier_forand_eval(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float3 wo, + const float3 wo, ccl_private float *pdf) { const ccl_private FournierForandVolume *volume = (const ccl_private FournierForandVolume *)svc; @@ -55,7 +55,7 @@ ccl_device Spectrum volume_fournier_forand_eval(const ccl_private ShaderData *sd ccl_device int volume_fournier_forand_sample(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float2 rand, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/volume_henyey_greenstein.h b/intern/cycles/kernel/closure/volume_henyey_greenstein.h index ff8567c7967..81c3e711b80 100644 --- a/intern/cycles/kernel/closure/volume_henyey_greenstein.h +++ b/intern/cycles/kernel/closure/volume_henyey_greenstein.h @@ -31,7 +31,7 @@ ccl_device int volume_henyey_greenstein_setup(ccl_private HenyeyGreensteinVolume ccl_device Spectrum volume_henyey_greenstein_eval(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float3 wo, + const float3 wo, ccl_private float *pdf) { const ccl_private HenyeyGreensteinVolume *volume = (const ccl_private HenyeyGreensteinVolume *) @@ -46,7 +46,7 @@ ccl_device Spectrum volume_henyey_greenstein_eval(const ccl_private ShaderData * ccl_device int volume_henyey_greenstein_sample(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, - float2 rand, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/volume_rayleigh.h b/intern/cycles/kernel/closure/volume_rayleigh.h index 6395b86bff8..0319e2675bb 100644 --- a/intern/cycles/kernel/closure/volume_rayleigh.h +++ b/intern/cycles/kernel/closure/volume_rayleigh.h @@ -25,7 +25,7 @@ ccl_device int volume_rayleigh_setup(ccl_private RayleighVolume *volume) } ccl_device Spectrum volume_rayleigh_eval(const ccl_private ShaderData *sd, - float3 wo, + const float3 wo, ccl_private float *pdf) { /* note that wi points towards the viewer */ @@ -36,7 +36,7 @@ ccl_device Spectrum volume_rayleigh_eval(const ccl_private ShaderData *sd, } ccl_device int volume_rayleigh_sample(const ccl_private ShaderData *sd, - float2 rand, + const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf) diff --git a/intern/cycles/kernel/closure/volume_util.h b/intern/cycles/kernel/closure/volume_util.h index 380d09ac7b2..8b18859d731 100644 --- a/intern/cycles/kernel/closure/volume_util.h +++ b/intern/cycles/kernel/closure/volume_util.h @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN /* Given a random number, sample a direction that makes an angle of theta with direction D. */ -ccl_device float3 phase_sample_direction(float3 D, float cos_theta, float rand) +ccl_device float3 phase_sample_direction(const float3 D, const float cos_theta, const float rand) { const float phi = M_2PI_F * rand; const float3 dir = spherical_cos_to_direction(cos_theta, phi); @@ -24,7 +24,7 @@ ccl_device float3 phase_sample_direction(float3 D, float cos_theta, float rand) /* Given cosine between rays, return probability density that a photon bounces * to that direction. The g parameter controls how different it is from the * uniform sphere. g=0 uniform diffuse-like, g=1 close to sharp single ray. */ -ccl_device float phase_henyey_greenstein(float cos_theta, float g) +ccl_device float phase_henyey_greenstein(const float cos_theta, const float g) { if (fabsf(g) < 1e-3f) { return M_1_4PI_F; @@ -33,9 +33,9 @@ ccl_device float phase_henyey_greenstein(float cos_theta, float g) return (1 - sqr(g)) / (M_4PI_F * fac * safe_sqrtf(fac)); } -ccl_device float3 phase_henyey_greenstein_sample(float3 D, - float g, - float2 rand, +ccl_device float3 phase_henyey_greenstein_sample(const float3 D, + const float g, + const float2 rand, ccl_private float *pdf) { float cos_theta = 1 - 2 * rand.x; @@ -52,12 +52,12 @@ ccl_device float3 phase_henyey_greenstein_sample(float3 D, /* Given cosine between rays, return probability density that a photon bounces to that direction * according to the constant Rayleigh phase function. * See https://doi.org/10.1364/JOSAA.28.002436 for details. */ -ccl_device float phase_rayleigh(float cos_theta) +ccl_device float phase_rayleigh(const float cos_theta) { return (0.1875f * M_1_PI_F) * (1.0f + sqr(cos_theta)); } -ccl_device float3 phase_rayleigh_sample(float3 D, float2 rand, ccl_private float *pdf) +ccl_device float3 phase_rayleigh_sample(const float3 D, const float2 rand, ccl_private float *pdf) { const float a = 2 - 4 * rand.x; /* Metal doesn't have cbrtf, but since we compute u - 1/u anyways, we can just as well @@ -76,7 +76,7 @@ ccl_device float3 phase_rayleigh_sample(float3 D, float2 rand, ccl_private float * function. alpha=0 reduces to HG function, g=0, alpha=1 reduces to Rayleigh function, alpha=1 * reduces to Cornette-Shanks function. * See https://doi.org/10.1086/379118 for details. */ -ccl_device float phase_draine(float cos_theta, float g, float alpha) +ccl_device float phase_draine(const float cos_theta, const float g, float alpha) { /* Check special cases. */ if (fabsf(g) < 1e-3f && alpha > 0.999f) { @@ -93,7 +93,7 @@ ccl_device float phase_draine(float cos_theta, float g, float alpha) } /* Adapted from the HLSL code provided in https://research.nvidia.com/labs/rtr/approximate-mie/ */ -ccl_device float phase_draine_sample_cos(float g, float alpha, float rand) +ccl_device float phase_draine_sample_cos(const float g, const float alpha, const float rand) { if (fabsf(g) < 1e-2f) { /* Special case to prevent division by zero. @@ -126,8 +126,8 @@ ccl_device float phase_draine_sample_cos(float g, float alpha, float rand) return (1 + g2 - 0.25f * sqr(sqrtf(T7) - sqrtf(T5))) / (2 * g); } -ccl_device float3 -phase_draine_sample(float3 D, float g, float alpha, float2 rand, ccl_private float *pdf) +ccl_device float3 phase_draine_sample( + const float3 D, const float g, float alpha, const float2 rand, ccl_private float *pdf) { /* Check special cases. */ if (fabsf(g) < 1e-3f && alpha > 0.999f) { @@ -143,13 +143,13 @@ phase_draine_sample(float3 D, float g, float alpha, float2 rand, ccl_private flo return phase_sample_direction(D, cos_theta, rand.y); } -ccl_device float phase_fournier_forand_delta(float n, float sin_htheta_sqr) +ccl_device float phase_fournier_forand_delta(const float n, const float sin_htheta_sqr) { const float u = 4 * sin_htheta_sqr; return u / (3 * sqr(n - 1)); } -ccl_device_inline float3 phase_fournier_forand_coeffs(float B, float IOR) +ccl_device_inline float3 phase_fournier_forand_coeffs(const float B, const float IOR) { const float d90 = phase_fournier_forand_delta(IOR, 0.5f); const float d180 = phase_fournier_forand_delta(IOR, 1.0f); @@ -162,8 +162,12 @@ ccl_device_inline float3 phase_fournier_forand_coeffs(float B, float IOR) * refraction and controls how much of the light is refracted. B is the particle backscatter * fraction, B = b_b / b. * See https://doi.org/10.1117/12.366488 for details. */ -ccl_device_inline float phase_fournier_forand_impl( - float cos_theta, float delta, float pow_delta_v, float v, float sin_htheta_sqr, float pf_coeff) +ccl_device_inline float phase_fournier_forand_impl(float cos_theta, + const float delta, + const float pow_delta_v, + const float v, + float sin_htheta_sqr, + const float pf_coeff) { const float m_delta = 1 - delta; const float m_pow_delta_v = 1 - pow_delta_v; @@ -183,7 +187,7 @@ ccl_device_inline float phase_fournier_forand_impl( return pf; } -ccl_device float phase_fournier_forand(float cos_theta, float3 coeffs) +ccl_device float phase_fournier_forand(const float cos_theta, const float3 coeffs) { if (fabsf(cos_theta) >= 1.0f) { return 0.0f; @@ -198,7 +202,7 @@ ccl_device float phase_fournier_forand(float cos_theta, float3 coeffs) return phase_fournier_forand_impl(cos_theta, delta, powf(delta, v), v, sin_htheta_sqr, pf_coeff); } -ccl_device float phase_fournier_forand_newton(float rand, float3 coeffs) +ccl_device float phase_fournier_forand_newton(const float rand, const float3 coeffs) { const float n = coeffs.x; const float v = coeffs.y; @@ -242,9 +246,9 @@ ccl_device float phase_fournier_forand_newton(float rand, float3 coeffs) return cos_theta; } -ccl_device float3 phase_fournier_forand_sample(float3 D, - float3 coeffs, - float2 rand, +ccl_device float3 phase_fournier_forand_sample(const float3 D, + const float3 coeffs, + const float2 rand, ccl_private float *pdf) { const float cos_theta = phase_fournier_forand_newton(rand.x, coeffs); diff --git a/intern/cycles/kernel/device/cpu/bvh.h b/intern/cycles/kernel/device/cpu/bvh.h index 29fc8d5b5ff..1b8c2c5422d 100644 --- a/intern/cycles/kernel/device/cpu/bvh.h +++ b/intern/cycles/kernel/device/cpu/bvh.h @@ -252,7 +252,7 @@ ccl_device_inline void kernel_embree_convert_sss_hit(KernelGlobals kg, const RTCRay *ray, const RTCHit *hit, Intersection *isect, - int object, + const int object, const intptr_t prim_offset) { isect->u = hit->u; @@ -760,9 +760,9 @@ ccl_device_intersect bool kernel_embree_intersect(KernelGlobals kg, ccl_device_intersect bool kernel_embree_intersect_local(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { const bool has_bvh = !(kernel_data_fetch(object_flag, local_object) & SD_OBJECT_TRANSFORM_APPLIED); @@ -850,8 +850,8 @@ ccl_device_intersect bool kernel_embree_intersect_local(KernelGlobals kg, ccl_device_intersect bool kernel_embree_intersect_shadow_all(KernelGlobals kg, IntegratorShadowState state, const ccl_private Ray *ray, - uint visibility, - uint max_hits, + const uint visibility, + const uint max_hits, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { diff --git a/intern/cycles/kernel/device/cpu/globals.h b/intern/cycles/kernel/device/cpu/globals.h index 2895a712e4a..62bd989054b 100644 --- a/intern/cycles/kernel/device/cpu/globals.h +++ b/intern/cycles/kernel/device/cpu/globals.h @@ -27,7 +27,7 @@ struct OSLShadingSystem; /* Array for kernel data, with size to be able to assert on invalid data access. */ template struct kernel_array { - const ccl_always_inline T &fetch(int index) const + const ccl_always_inline T &fetch(const int index) const { kernel_assert(index >= 0 && index < width); return data[index]; diff --git a/intern/cycles/kernel/device/cpu/image.h b/intern/cycles/kernel/device/cpu/image.h index 8edb5a9fdd3..f05a192daba 100644 --- a/intern/cycles/kernel/device/cpu/image.h +++ b/intern/cycles/kernel/device/cpu/image.h @@ -28,7 +28,7 @@ namespace { } \ (void)0 -ccl_device_inline float frac(float x, int *ix) +ccl_device_inline float frac(const float x, int *ix) { int i = float_to_int(x) - ((x < 0.0f) ? 1 : 0); *ix = i; @@ -47,23 +47,23 @@ template struct TextureInterpolator { } } - static ccl_always_inline float4 read(float4 r) + static ccl_always_inline float4 read(const float4 r) { return r; } - static ccl_always_inline float4 read(uchar4 r) + static ccl_always_inline float4 read(const uchar4 r) { const float f = 1.0f / 255.0f; return make_float4(r.x * f, r.y * f, r.z * f, r.w * f); } - static ccl_always_inline float read(uchar r) + static ccl_always_inline float read(const uchar r) { return r * (1.0f / 255.0f); } - static ccl_always_inline float read(float r) + static ccl_always_inline float read(const float r) { return r; } @@ -78,7 +78,7 @@ template struct TextureInterpolator { return half_to_float_image(r); } - static ccl_always_inline float read(uint16_t r) + static ccl_always_inline float read(const uint16_t r) { return r * (1.0f / 65535.0f); } @@ -91,14 +91,16 @@ template struct TextureInterpolator { /* Read 2D Texture Data * Does not check if data request is in bounds. */ - static ccl_always_inline OutT read(const TexT *data, int x, int y, int width, int height) + static ccl_always_inline OutT + read(const TexT *data, const int x, int y, const int width, const int height) { return read(data[y * width + x]); } /* Read 2D Texture Data Clip * Returns transparent black if data request is out of bounds. */ - static ccl_always_inline OutT read_clip(const TexT *data, int x, int y, int width, int height) + static ccl_always_inline OutT + read_clip(const TexT *data, const int x, int y, const int width, const int height) { if (x < 0 || x >= width || y < 0 || y >= height) { return zero(); @@ -108,16 +110,26 @@ template struct TextureInterpolator { /* Read 3D Texture Data * Does not check if data request is in bounds. */ - static ccl_always_inline OutT - read(const TexT *data, int x, int y, int z, int width, int height, int depth) + static ccl_always_inline OutT read(const TexT *data, + const int x, + int y, + const int z, + int width, + const int height, + const int depth) { return read(data[x + y * width + z * width * height]); } /* Read 3D Texture Data Clip * Returns transparent black if data request is out of bounds. */ - static ccl_always_inline OutT - read_clip(const TexT *data, int x, int y, int z, int width, int height, int depth) + static ccl_always_inline OutT read_clip(const TexT *data, + const int x, + int y, + const int z, + int width, + const int height, + const int depth) { if (x < 0 || x >= width || y < 0 || y >= height || z < 0 || z >= depth) { return zero(); @@ -128,18 +140,18 @@ template struct TextureInterpolator { /* Trilinear Interpolation */ static ccl_always_inline OutT trilinear_lookup(const TexT *data, - float tx, - float ty, - float tz, - int ix, - int iy, - int iz, - int nix, - int niy, - int niz, - int width, - int height, - int depth, + const float tx, + const float ty, + const float tz, + const int ix, + const int iy, + const int iz, + const int nix, + const int niy, + const int niz, + const int width, + const int height, + const int depth, OutT read(const TexT *, int, int, int, int, int, int)) { OutT r = (1.0f - tz) * (1.0f - ty) * (1.0f - tx) * @@ -158,15 +170,15 @@ template struct TextureInterpolator { /** Tricubic Interpolation */ static ccl_always_inline OutT tricubic_lookup(const TexT *data, - float tx, - float ty, - float tz, + const float tx, + const float ty, + const float tz, const int xc[4], const int yc[4], const int zc[4], - int width, - int height, - int depth, + const int width, + const int height, + const int depth, OutT read(const TexT *, int, int, int, int, int, int)) { float u[4], v[4], w[4]; @@ -192,7 +204,7 @@ template struct TextureInterpolator { #undef DATA } - static ccl_always_inline int wrap_periodic(int x, int width) + static ccl_always_inline int wrap_periodic(int x, const int width) { x %= width; if (x < 0) { @@ -201,12 +213,12 @@ template struct TextureInterpolator { return x; } - static ccl_always_inline int wrap_clamp(int x, int width) + static ccl_always_inline int wrap_clamp(const int x, const int width) { return clamp(x, 0, width - 1); } - static ccl_always_inline int wrap_mirror(int x, int width) + static ccl_always_inline int wrap_mirror(const int x, const int width) { const int m = abs(x + (x < 0)) % (2 * width); if (m >= width) { @@ -217,7 +229,7 @@ template struct TextureInterpolator { /* ******** 2D interpolation ******** */ - static ccl_always_inline OutT interp_closest(const TextureInfo &info, float x, float y) + static ccl_always_inline OutT interp_closest(const TextureInfo &info, const float x, float y) { const int width = info.width; const int height = info.height; @@ -252,7 +264,7 @@ template struct TextureInterpolator { return read(data, ix, iy, width, height); } - static ccl_always_inline OutT interp_linear(const TextureInfo &info, float x, float y) + static ccl_always_inline OutT interp_linear(const TextureInfo &info, const float x, float y) { const int width = info.width; const int height = info.height; @@ -306,7 +318,7 @@ template struct TextureInterpolator { ty * tx * read(data, nix, niy, width, height); } - static ccl_always_inline OutT interp_cubic(const TextureInfo &info, float x, float y) + static ccl_always_inline OutT interp_cubic(const TextureInfo &info, const float x, float y) { const int width = info.width; const int height = info.height; @@ -395,7 +407,7 @@ template struct TextureInterpolator { #undef DATA } - static ccl_always_inline OutT interp(const TextureInfo &info, float x, float y) + static ccl_always_inline OutT interp(const TextureInfo &info, const float x, float y) { switch (info.interpolation) { case INTERPOLATION_CLOSEST: @@ -410,9 +422,9 @@ template struct TextureInterpolator { /* ******** 3D interpolation ******** */ static ccl_always_inline OutT interp_3d_closest(const TextureInfo &info, - float x, - float y, - float z) + const float x, + const float y, + const float z) { const int width = info.width; const int height = info.height; @@ -455,9 +467,9 @@ template struct TextureInterpolator { } static ccl_always_inline OutT interp_3d_linear(const TextureInfo &info, - float x, - float y, - float z) + const float x, + const float y, + const float z) { const int width = info.width; const int height = info.height; @@ -567,7 +579,7 @@ template struct TextureInterpolator { static ccl_never_inline #endif OutT - interp_3d_cubic(const TextureInfo &info, float x, float y, float z) + interp_3d_cubic(const TextureInfo &info, const float x, float y, const float z) { int width = info.width; int height = info.height; @@ -674,8 +686,8 @@ template struct TextureInterpolator { return tricubic_lookup(data, tx, ty, tz, xc, yc, zc, width, height, depth, read); } - static ccl_always_inline OutT - interp_3d(const TextureInfo &info, float x, float y, float z, InterpolationType interp) + static ccl_always_inline OutT interp_3d( + const TextureInfo &info, const float x, float y, const float z, InterpolationType interp) { switch ((interp == INTERPOLATION_NONE) ? info.interpolation : interp) { case INTERPOLATION_CLOSEST: @@ -691,7 +703,7 @@ template struct TextureInterpolator { #ifdef WITH_NANOVDB template struct NanoVDBInterpolator { - static ccl_always_inline float read(float r) + static ccl_always_inline float read(const float r) { return r; } @@ -702,14 +714,16 @@ template struct NanoVDBInterpolator { } template - static ccl_always_inline OutT interp_3d_closest(const Acc &acc, float x, float y, float z) + static ccl_always_inline OutT + interp_3d_closest(const Acc &acc, const float x, float y, const float z) { const nanovdb::Coord coord((int32_t)floorf(x), (int32_t)floorf(y), (int32_t)floorf(z)); return read(acc.getValue(coord)); } template - static ccl_always_inline OutT interp_3d_linear(const Acc &acc, float x, float y, float z) + static ccl_always_inline OutT + interp_3d_linear(const Acc &acc, const float x, float y, const float z) { int ix, iy, iz; const float tx = frac(x - 0.5f, &ix); @@ -741,7 +755,7 @@ template struct NanoVDBInterpolator { static ccl_never_inline # endif OutT - interp_3d_cubic(const Acc &acc, float x, float y, float z) + interp_3d_cubic(const Acc &acc, const float x, float y, const float z) { int ix, iy, iz; int nix, niy, niz; @@ -790,8 +804,8 @@ template struct NanoVDBInterpolator { # undef DATA } - static ccl_always_inline OutT - interp_3d(const TextureInfo &info, float x, float y, float z, InterpolationType interp) + static ccl_always_inline OutT interp_3d( + const TextureInfo &info, const float x, float y, const float z, InterpolationType interp) { using namespace nanovdb; @@ -817,7 +831,7 @@ template struct NanoVDBInterpolator { #undef SET_CUBIC_SPLINE_WEIGHTS -ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y) +ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y) { const TextureInfo &info = kernel_data_fetch(texture_info, id); @@ -858,7 +872,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo } ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, - int id, + const int id, float3 P, InterpolationType interp) { diff --git a/intern/cycles/kernel/device/cpu/kernel.cpp b/intern/cycles/kernel/device/cpu/kernel.cpp index cddf90ac2ad..a5a025c8997 100644 --- a/intern/cycles/kernel/device/cpu/kernel.cpp +++ b/intern/cycles/kernel/device/cpu/kernel.cpp @@ -61,7 +61,10 @@ void kernel_const_copy(KernelGlobalsCPU *kg, const char *name, void *host, size_ } } -void kernel_global_memory_copy(KernelGlobalsCPU *kg, const char *name, void *mem, size_t size) +void kernel_global_memory_copy(KernelGlobalsCPU *kg, + const char *name, + void *mem, + const size_t size) { if (false) { } diff --git a/intern/cycles/kernel/device/cpu/kernel.h b/intern/cycles/kernel/device/cpu/kernel.h index 9f11feeb88c..4b5ae18af40 100644 --- a/intern/cycles/kernel/device/cpu/kernel.h +++ b/intern/cycles/kernel/device/cpu/kernel.h @@ -26,8 +26,11 @@ void kernel_globals_free(KernelGlobalsCPU *kg); void *kernel_osl_memory(const KernelGlobalsCPU *kg); bool kernel_osl_use(const KernelGlobalsCPU *kg); -void kernel_const_copy(KernelGlobalsCPU *kg, const char *name, void *host, size_t size); -void kernel_global_memory_copy(KernelGlobalsCPU *kg, const char *name, void *mem, size_t size); +void kernel_const_copy(KernelGlobalsCPU *kg, const char *name, void *host, const size_t size); +void kernel_global_memory_copy(KernelGlobalsCPU *kg, + const char *name, + void *mem, + const size_t size); #define KERNEL_ARCH cpu #include "kernel/device/cpu/kernel_arch.h" diff --git a/intern/cycles/kernel/device/cpu/kernel_arch.h b/intern/cycles/kernel/device/cpu/kernel_arch.h index e3759327f5d..700fab9f988 100644 --- a/intern/cycles/kernel/device/cpu/kernel_arch.h +++ b/intern/cycles/kernel/device/cpu/kernel_arch.h @@ -98,26 +98,26 @@ void KERNEL_FUNCTION_FULL_NAME(shader_eval_curve_shadow_transparency)( bool KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_convergence_check)( 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); void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_x)(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); void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_y)(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); /* -------------------------------------------------------------------- diff --git a/intern/cycles/kernel/device/cpu/kernel_arch_impl.h b/intern/cycles/kernel/device/cpu/kernel_arch_impl.h index bf8b5e006ee..80dd94f8d74 100644 --- a/intern/cycles/kernel/device/cpu/kernel_arch_impl.h +++ b/intern/cycles/kernel/device/cpu/kernel_arch_impl.h @@ -162,12 +162,12 @@ void KERNEL_FUNCTION_FULL_NAME(shader_eval_curve_shadow_transparency)( bool KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_convergence_check)( const KernelGlobalsCPU *kg, ccl_global float *render_buffer, - int x, - int y, - float threshold, - int reset, - int offset, - int stride) + const int x, + const int y, + const float threshold, + const int reset, + const int offset, + const int stride) { #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, adaptive_sampling_convergence_check); @@ -180,11 +180,11 @@ bool KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_convergence_check)( void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_x)(const KernelGlobalsCPU *kg, ccl_global float *render_buffer, - int y, - int start_x, - int width, - int offset, - int stride) + const int y, + const int start_x, + const int width, + const int offset, + const int stride) { #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, adaptive_sampling_filter_x); @@ -195,11 +195,11 @@ void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_x)(const KernelGlobalsCP void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_y)(const KernelGlobalsCPU *kg, ccl_global float *render_buffer, - int x, - int start_y, - int height, - int offset, - int stride) + const int x, + const int start_y, + const int height, + const int offset, + const int stride) { #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, adaptive_sampling_filter_y); @@ -214,7 +214,7 @@ void KERNEL_FUNCTION_FULL_NAME(adaptive_sampling_filter_y)(const KernelGlobalsCP void KERNEL_FUNCTION_FULL_NAME(cryptomatte_postprocess)(const KernelGlobalsCPU *kg, ccl_global float *render_buffer, - int pixel_index) + const int pixel_index) { #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, cryptomatte_postprocess); diff --git a/intern/cycles/kernel/device/gpu/image.h b/intern/cycles/kernel/device/gpu/image.h index 08e8cb479f8..d15b3b4c6ed 100644 --- a/intern/cycles/kernel/device/gpu/image.h +++ b/intern/cycles/kernel/device/gpu/image.h @@ -12,7 +12,7 @@ CCL_NAMESPACE_BEGIN # endif #endif -ccl_device_inline float frac(float x, ccl_private int *ix) +ccl_device_inline float frac(const float x, ccl_private int *ix) { int i = float_to_int(x) - ((x < 0.0f) ? 1 : 0); *ix = i; @@ -20,39 +20,39 @@ ccl_device_inline float frac(float x, ccl_private int *ix) } /* w0, w1, w2, and w3 are the four cubic B-spline basis functions. */ -ccl_device float cubic_w0(float a) +ccl_device float cubic_w0(const float a) { return (1.0f / 6.0f) * (a * (a * (-a + 3.0f) - 3.0f) + 1.0f); } -ccl_device float cubic_w1(float a) +ccl_device float cubic_w1(const float a) { return (1.0f / 6.0f) * (a * a * (3.0f * a - 6.0f) + 4.0f); } -ccl_device float cubic_w2(float a) +ccl_device float cubic_w2(const float a) { return (1.0f / 6.0f) * (a * (a * (-3.0f * a + 3.0f) + 3.0f) + 1.0f); } -ccl_device float cubic_w3(float a) +ccl_device float cubic_w3(const float a) { return (1.0f / 6.0f) * (a * a * a); } /* g0 and g1 are the two amplitude functions. */ -ccl_device float cubic_g0(float a) +ccl_device float cubic_g0(const float a) { return cubic_w0(a) + cubic_w1(a); } -ccl_device float cubic_g1(float a) +ccl_device float cubic_g1(const float a) { return cubic_w2(a) + cubic_w3(a); } /* h0 and h1 are the two offset functions */ -ccl_device float cubic_h0(float a) +ccl_device float cubic_h0(const float a) { return (cubic_w1(a) / cubic_g0(a)) - 1.0f; } -ccl_device float cubic_h1(float a) +ccl_device float cubic_h1(const float a) { return (cubic_w3(a) / cubic_g1(a)) + 1.0f; } @@ -132,8 +132,10 @@ kernel_tex_image_interp_tricubic(const ccl_global TextureInfo &info, float x, fl #ifdef WITH_NANOVDB template -ccl_device OutT -kernel_tex_image_interp_trilinear_nanovdb(ccl_private Acc &acc, float x, float y, float z) +ccl_device OutT kernel_tex_image_interp_trilinear_nanovdb(ccl_private Acc &acc, + const float x, + float y, + const float z) { int ix, iy, iz; const float tx = frac(x - 0.5f, &ix); @@ -158,8 +160,10 @@ kernel_tex_image_interp_trilinear_nanovdb(ccl_private Acc &acc, float x, float y } template -ccl_device OutT -kernel_tex_image_interp_tricubic_nanovdb(ccl_private Acc &acc, float x, float y, float z) +ccl_device OutT kernel_tex_image_interp_tricubic_nanovdb(ccl_private Acc &acc, + const float x, + const float y, + const float z) { int ix, iy, iz; int nix, niy, niz; @@ -220,12 +224,18 @@ kernel_tex_image_interp_tricubic_nanovdb(ccl_private Acc &acc, float x, float y, # if defined(__KERNEL_METAL__) template -__attribute__((noinline)) OutT kernel_tex_image_interp_nanovdb( - const ccl_global TextureInfo &info, float x, float y, float z, uint interpolation) +__attribute__((noinline)) OutT kernel_tex_image_interp_nanovdb(const ccl_global TextureInfo &info, + const float x, + const float y, + const float z, + const uint interpolation) # else template -ccl_device_noinline OutT kernel_tex_image_interp_nanovdb( - const ccl_global TextureInfo &info, float x, float y, float z, uint interpolation) +ccl_device_noinline OutT kernel_tex_image_interp_nanovdb(const ccl_global TextureInfo &info, + const float x, + const float y, + const float z, + const uint interpolation) # endif { using namespace nanovdb; @@ -250,7 +260,7 @@ ccl_device_noinline OutT kernel_tex_image_interp_nanovdb( } #endif -ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y) +ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y) { const ccl_global TextureInfo &info = kernel_data_fetch(texture_info, id); @@ -284,7 +294,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo } ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, - int id, + const int id, float3 P, InterpolationType interp) { diff --git a/intern/cycles/kernel/device/gpu/kernel.h b/intern/cycles/kernel/device/gpu/kernel.h index aa31cec3480..48f26abf886 100644 --- a/intern/cycles/kernel/device/gpu/kernel.h +++ b/intern/cycles/kernel/device/gpu/kernel.h @@ -59,7 +59,7 @@ */ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) - ccl_gpu_kernel_signature(integrator_reset, int num_states) + ccl_gpu_kernel_signature(integrator_reset, const int num_states) { const int state = ccl_gpu_global_id_x(); @@ -370,10 +370,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_queued_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int kernel_index) + const int kernel_index) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, path, queued_kernel) == kernel_index, int kernel_index); @@ -385,10 +385,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_queued_shadow_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int kernel_index) + const int kernel_index) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, shadow_path, queued_kernel) == kernel_index, int kernel_index); @@ -400,7 +400,7 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_active_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices) { @@ -412,10 +412,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_terminated_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int indices_offset) + const int indices_offset) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, path, queued_kernel) == 0); @@ -426,10 +426,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_terminated_shadow_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int indices_offset) + const int indices_offset) { ccl_gpu_kernel_lambda(INTEGRATOR_STATE(state, shadow_path, queued_kernel) == 0); @@ -440,13 +440,13 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_sorted_paths_array, - int num_states, - int num_states_limit, + const int num_states, + const int num_states_limit, ccl_global int *indices, ccl_global int *num_indices, ccl_global int *key_counter, ccl_global int *key_prefix_sum, - int kernel_index) + const int kernel_index) { ccl_gpu_kernel_lambda((INTEGRATOR_STATE(state, path, queued_kernel) == kernel_index) ? INTEGRATOR_STATE(state, path, shader_sort_key) : @@ -470,20 +470,20 @@ ccl_gpu_kernel_postfix #ifdef __KERNEL_ONEAPI__ ccl_gpu_kernel_threads(GPU_PARALLEL_SORT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_sort_bucket_pass, - int num_states, - int partition_size, - int num_states_limit, + const int num_states, + const int partition_size, + const int num_states_limit, ccl_global int *indices, - int kernel_index, + const int kernel_index, sycl::local_accessor &local_mem) #else ccl_gpu_kernel_threads(GPU_PARALLEL_SORT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_sort_bucket_pass, - int num_states, - int partition_size, - int num_states_limit, + const int num_states, + const int partition_size, + const int num_states_limit, ccl_global int *indices, - int kernel_index) + const int kernel_index) #endif { #if defined(__KERNEL_LOCAL_ATOMIC_SORT__) @@ -530,20 +530,20 @@ ccl_gpu_kernel_postfix #ifdef __KERNEL_ONEAPI__ ccl_gpu_kernel_threads(GPU_PARALLEL_SORT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_sort_write_pass, - int num_states, - int partition_size, - int num_states_limit, + const int num_states, + const int partition_size, + const int num_states_limit, ccl_global int *indices, - int kernel_index, + const int kernel_index, sycl::local_accessor &local_mem) #else ccl_gpu_kernel_threads(GPU_PARALLEL_SORT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_sort_write_pass, - int num_states, - int partition_size, - int num_states_limit, + const int num_states, + const int partition_size, + const int num_states_limit, ccl_global int *indices, - int kernel_index) + const int kernel_index) #endif { @@ -591,10 +591,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_compact_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int num_active_paths) + const int num_active_paths) { ccl_gpu_kernel_lambda((state >= num_active_paths) && (INTEGRATOR_STATE(state, path, queued_kernel) != 0), @@ -625,10 +625,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(integrator_compact_shadow_paths_array, - int num_states, + const int num_states, ccl_global int *indices, ccl_global int *num_indices, - int num_active_paths) + const int num_active_paths) { ccl_gpu_kernel_lambda((state >= num_active_paths) && (INTEGRATOR_STATE(state, shadow_path, queued_kernel) != 0), @@ -658,7 +658,7 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_postfix ccl_gpu_kernel_threads(GPU_PARALLEL_PREFIX_SUM_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature( - prefix_sum, ccl_global int *counter, ccl_global int *prefix_sum, int num_values) + prefix_sum, ccl_global int *counter, ccl_global int *prefix_sum, const int num_values) { gpu_parallel_prefix_sum(ccl_gpu_global_id_x(), counter, prefix_sum, num_values); } @@ -671,14 +671,14 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(adaptive_sampling_convergence_check, ccl_global float *render_buffer, - int sx, - int sy, - int sw, - int sh, - float threshold, - int reset, - int offset, - int stride, + const int sx, + const int sy, + const int sw, + const int sh, + const float threshold, + const int reset, + const int offset, + const int stride, ccl_global uint *num_active_pixels) { const int work_index = ccl_gpu_global_id_x(); @@ -704,12 +704,12 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(adaptive_sampling_filter_x, ccl_global float *render_buffer, - int sx, - int sy, - int sw, - int sh, - int offset, - int stride) + const int sx, + const int sy, + const int sw, + const int sh, + const int offset, + const int stride) { const int y = ccl_gpu_global_id_x(); @@ -723,12 +723,12 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(adaptive_sampling_filter_y, ccl_global float *render_buffer, - int sx, - int sy, - int sw, - int sh, - int offset, - int stride) + const int sx, + const int sy, + const int sw, + const int sh, + const int offset, + const int stride) { const int x = ccl_gpu_global_id_x(); @@ -746,7 +746,7 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(cryptomatte_postprocess, ccl_global float *render_buffer, - int num_pixels) + const int num_pixels) { const int pixel_index = ccl_gpu_global_id_x(); @@ -962,14 +962,14 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(filter_color_preprocess, ccl_global float *render_buffer, - int full_x, - int full_y, - int width, - int height, - int offset, - int stride, - int pass_stride, - int pass_denoised) + const int full_x, + const int full_y, + const int width, + const int height, + const int offset, + const int stride, + const int pass_stride, + const int pass_denoised) { const int work_index = ccl_gpu_global_id_x(); const int y = work_index / width; @@ -992,23 +992,23 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(filter_guiding_preprocess, ccl_global float *guiding_buffer, - int guiding_pass_stride, - int guiding_pass_albedo, - int guiding_pass_normal, - int guiding_pass_flow, + const int guiding_pass_stride, + const int guiding_pass_albedo, + const int guiding_pass_normal, + const int guiding_pass_flow, const ccl_global float *render_buffer, - int render_offset, - int render_stride, - int render_pass_stride, - int render_pass_sample_count, - int render_pass_denoising_albedo, - int render_pass_denoising_normal, - int render_pass_motion, - int full_x, - int full_y, - int width, - int height, - int num_samples) + const int render_offset, + const int render_stride, + const int render_pass_stride, + const int render_pass_sample_count, + const int render_pass_denoising_albedo, + const int render_pass_denoising_normal, + const int render_pass_motion, + const int full_x, + const int full_y, + const int width, + const int height, + const int num_samples) { const int work_index = ccl_gpu_global_id_x(); const int y = work_index / width; @@ -1072,10 +1072,10 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(filter_guiding_set_fake_albedo, ccl_global float *guiding_buffer, - int guiding_pass_stride, - int guiding_pass_albedo, - int width, - int height) + const int guiding_pass_stride, + const int guiding_pass_albedo, + const int width, + const int height) { kernel_assert(guiding_pass_albedo != PASS_UNUSED); @@ -1101,19 +1101,19 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(filter_color_postprocess, ccl_global float *render_buffer, - int full_x, - int full_y, - int width, - int height, - int offset, - int stride, - int pass_stride, - int num_samples, - int pass_noisy, - int pass_denoised, - int pass_sample_count, - int num_components, - int use_compositing) + const int full_x, + const int full_y, + const int width, + const int height, + const int offset, + const int stride, + const int pass_stride, + const int num_samples, + const int pass_noisy, + const int pass_denoised, + const int pass_sample_count, + const int num_components, + const int use_compositing) { const int work_index = ccl_gpu_global_id_x(); const int y = work_index / width; @@ -1164,7 +1164,7 @@ ccl_gpu_kernel_postfix ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(integrator_shadow_catcher_count_possible_splits, - int num_states, + const int num_states, ccl_global uint *num_possible_splits) { const int state = ccl_gpu_global_id_x(); diff --git a/intern/cycles/kernel/device/gpu/work_stealing.h b/intern/cycles/kernel/device/gpu/work_stealing.h index b892650677b..ab3d25fa4ef 100644 --- a/intern/cycles/kernel/device/gpu/work_stealing.h +++ b/intern/cycles/kernel/device/gpu/work_stealing.h @@ -12,7 +12,7 @@ CCL_NAMESPACE_BEGIN /* Map global work index to tile, pixel X/Y and sample. */ ccl_device_inline void get_work_pixel(const ccl_global KernelWorkTile *tile, - uint global_work_index, + const uint global_work_index, ccl_private uint *x, ccl_private uint *y, ccl_private uint *sample) @@ -21,7 +21,7 @@ ccl_device_inline void get_work_pixel(const ccl_global KernelWorkTile *tile, if (kernel_data.integrator.scrambling_distance < 0.9f) { /* Keep threads for the same sample together. */ - uint tile_pixels = tile->w * tile->h; + const uint tile_pixels = tile->w * tile->h; sample_offset = global_work_index / tile_pixels; pixel_offset = global_work_index - sample_offset * tile_pixels; } @@ -32,8 +32,8 @@ ccl_device_inline void get_work_pixel(const ccl_global KernelWorkTile *tile, pixel_offset = global_work_index / tile->num_samples; } - uint y_offset = pixel_offset / tile->w; - uint x_offset = pixel_offset - y_offset * tile->w; + const uint y_offset = pixel_offset / tile->w; + const uint x_offset = pixel_offset - y_offset * tile->w; *x = tile->x + x_offset; *y = tile->y + y_offset; diff --git a/intern/cycles/kernel/device/hiprt/bvh.h b/intern/cycles/kernel/device/hiprt/bvh.h index 8e634036408..9f5bc69caa7 100644 --- a/intern/cycles/kernel/device/hiprt/bvh.h +++ b/intern/cycles/kernel/device/hiprt/bvh.h @@ -77,9 +77,9 @@ template ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { if (!scene_intersect_valid(ray)) { if (local_isect) { @@ -145,8 +145,8 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, IntegratorShadowState state, const ccl_private Ray *ray, - uint visibility, - uint max_hits, + const uint visibility, + const uint max_hits, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { diff --git a/intern/cycles/kernel/device/hiprt/common.h b/intern/cycles/kernel/device/hiprt/common.h index ab0c396ad4f..18c6c47b435 100644 --- a/intern/cycles/kernel/device/hiprt/common.h +++ b/intern/cycles/kernel/device/hiprt/common.h @@ -656,8 +656,8 @@ ccl_device_inline bool volume_intersection_filter(const hiprtRay &ray, return false; } -HIPRT_DEVICE bool intersectFunc(uint geomType, - uint rayType, +HIPRT_DEVICE bool intersectFunc(const uint geomType, + const uint rayType, const hiprtFuncTableHeader &tableHeader, const hiprtRay &ray, void *payload, @@ -685,8 +685,8 @@ HIPRT_DEVICE bool intersectFunc(uint geomType, return false; } -HIPRT_DEVICE bool filterFunc(uint geomType, - uint rayType, +HIPRT_DEVICE bool filterFunc(const uint geomType, + const uint rayType, const hiprtFuncTableHeader &tableHeader, const hiprtRay &ray, void *payload, diff --git a/intern/cycles/kernel/device/metal/bvh.h b/intern/cycles/kernel/device/metal/bvh.h index 0330ac5bef1..978337578f8 100644 --- a/intern/cycles/kernel/device/metal/bvh.h +++ b/intern/cycles/kernel/device/metal/bvh.h @@ -61,8 +61,13 @@ struct MetalRTIntersectionShadowAllPayload { }; #ifdef __HAIR__ -ccl_device_forceinline bool curve_ribbon_accept( - KernelGlobals kg, float u, float t, const ccl_private Ray *ray, int object, int prim, int type) +ccl_device_forceinline bool curve_ribbon_accept(KernelGlobals kg, + const float u, + float t, + const ccl_private Ray *ray, + const int object, + const int prim, + const int type) { KernelCurve kcurve = kernel_data_fetch(curves, prim); @@ -97,8 +102,13 @@ ccl_device_forceinline bool curve_ribbon_accept( return t * len(ray_D) > avoidance_factor * r; } -ccl_device_forceinline float curve_ribbon_v( - KernelGlobals kg, float u, float t, const ccl_private Ray *ray, int object, int prim, int type) +ccl_device_forceinline float curve_ribbon_v(KernelGlobals kg, + const float u, + float t, + const ccl_private Ray *ray, + const int object, + const int prim, + const int type) { # if defined(__METALRT_MOTION__) float time = ray->time; @@ -307,9 +317,9 @@ template ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { uint primitive_id_offset = kernel_data_fetch(object_prim_offset, local_object); @@ -455,8 +465,8 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, IntegratorShadowState state, const ccl_private Ray *ray, - uint visibility, - uint max_hits, + const uint visibility, + const uint max_hits, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { diff --git a/intern/cycles/kernel/device/metal/context_begin.h b/intern/cycles/kernel/device/metal/context_begin.h index 2e3c0a78592..cb3e59a3b49 100644 --- a/intern/cycles/kernel/device/metal/context_begin.h +++ b/intern/cycles/kernel/device/metal/context_begin.h @@ -29,13 +29,13 @@ class MetalKernelContext { template inline __attribute__((__always_inline__)) - T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const { + T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, const float x, float y) const { kernel_assert(0); return 0; } template inline __attribute__((__always_inline__)) - T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const { + T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, const float x, float y, const float z) const { kernel_assert(0); return 0; } @@ -43,14 +43,14 @@ class MetalKernelContext { // texture2d template<> inline __attribute__((__always_inline__)) - float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const { + float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, const float x, float y) const { const uint tid(tex); const uint sid(tex >> 32); return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y)); } template<> inline __attribute__((__always_inline__)) - float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const { + float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, const float x, float y) const { const uint tid(tex); const uint sid(tex >> 32); return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y)).x; @@ -59,14 +59,14 @@ class MetalKernelContext { // texture3d template<> inline __attribute__((__always_inline__)) - float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const { + float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, const float x, float y, const float z) const { const uint tid(tex); const uint sid(tex >> 32); return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z)); } template<> inline __attribute__((__always_inline__)) - float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const { + float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, const float x, float y, const float z) const { const uint tid(tex); const uint sid(tex >> 32); return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z)).x; diff --git a/intern/cycles/kernel/device/oneapi/compat.h b/intern/cycles/kernel/device/oneapi/compat.h index f74fbbb09da..c0fd17c7af7 100644 --- a/intern/cycles/kernel/device/oneapi/compat.h +++ b/intern/cycles/kernel/device/oneapi/compat.h @@ -193,15 +193,15 @@ ccl_device_forceinline float __uint_as_float(unsigned int x) { return sycl::bit_cast(x); } -ccl_device_forceinline unsigned int __float_as_uint(float x) +ccl_device_forceinline unsigned int __float_as_uint(const float x) { return sycl::bit_cast(x); } -ccl_device_forceinline float __int_as_float(int x) +ccl_device_forceinline float __int_as_float(const int x) { return sycl::bit_cast(x); } -ccl_device_forceinline int __float_as_int(float x) +ccl_device_forceinline int __float_as_int(const float x) { return sycl::bit_cast(x); } diff --git a/intern/cycles/kernel/device/oneapi/image.h b/intern/cycles/kernel/device/oneapi/image.h index 4098db1f95c..e4fbaf5b50a 100644 --- a/intern/cycles/kernel/device/oneapi/image.h +++ b/intern/cycles/kernel/device/oneapi/image.h @@ -7,7 +7,7 @@ CCL_NAMESPACE_BEGIN /* For oneAPI implementation we do manual lookup and interpolation. */ /* TODO: share implementation with ../cpu/image.h. */ -template ccl_device_forceinline T tex_fetch(const TextureInfo &info, int index) +template ccl_device_forceinline T tex_fetch(const TextureInfo &info, const int index) { return reinterpret_cast(info.data)[index]; } @@ -21,12 +21,12 @@ ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width) return x; } -ccl_device_inline int svm_image_texture_wrap_clamp(int x, int width) +ccl_device_inline int svm_image_texture_wrap_clamp(const int x, const int width) { return clamp(x, 0, width - 1); } -ccl_device_inline int svm_image_texture_wrap_mirror(int x, int width) +ccl_device_inline int svm_image_texture_wrap_mirror(const int x, const int width) { const int m = abs(x + (x < 0)) % (2 * width); if (m >= width) { @@ -35,7 +35,10 @@ ccl_device_inline int svm_image_texture_wrap_mirror(int x, int width) return m; } -ccl_device_inline float4 svm_image_texture_read(const TextureInfo &info, int x, int y, int z) +ccl_device_inline float4 svm_image_texture_read(const TextureInfo &info, + const int x, + int y, + const int z) { const int data_offset = x + info.width * y + info.width * info.height * z; const int texture_type = info.data_type; @@ -81,7 +84,7 @@ ccl_device_inline float4 svm_image_texture_read(const TextureInfo &info, int x, return make_float4(f, f, f, 1.0f); } -ccl_device_inline float4 svm_image_texture_read_2d(int id, int x, int y) +ccl_device_inline float4 svm_image_texture_read_2d(const int id, int x, int y) { const TextureInfo &info = kernel_data_fetch(texture_info, id); @@ -107,7 +110,7 @@ ccl_device_inline float4 svm_image_texture_read_2d(int id, int x, int y) return svm_image_texture_read(info, x, y, 0); } -ccl_device_inline float4 svm_image_texture_read_3d(int id, int x, int y, int z) +ccl_device_inline float4 svm_image_texture_read_3d(const int id, int x, int y, int z) { const TextureInfo &info = kernel_data_fetch(texture_info, id); @@ -136,7 +139,7 @@ ccl_device_inline float4 svm_image_texture_read_3d(int id, int x, int y, int z) return svm_image_texture_read(info, x, y, z); } -static float svm_image_texture_frac(float x, int *ix) +static float svm_image_texture_frac(const float x, int *ix) { int i = float_to_int(x) - ((x < 0.0f) ? 1 : 0); *ix = i; @@ -152,7 +155,7 @@ static float svm_image_texture_frac(float x, int *ix) } \ (void)0 -ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y) +ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, float x, float y) { const TextureInfo &info = kernel_data_fetch(texture_info, id); @@ -200,7 +203,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo #ifdef WITH_NANOVDB template struct NanoVDBInterpolator { - static ccl_always_inline float read(float r) + static ccl_always_inline float read(const float r) { return r; } @@ -211,14 +214,16 @@ template struct NanoVDBInterpolator { } template - static ccl_always_inline OutT interp_3d_closest(const Acc &acc, float x, float y, float z) + static ccl_always_inline OutT + interp_3d_closest(const Acc &acc, const float x, float y, const float z) { const nanovdb::Coord coord(int32_t(rintf(x)), int32_t(rintf(y)), int32_t(rintf(z))); return read(acc.getValue(coord)); } template - static ccl_always_inline OutT interp_3d_linear(const Acc &acc, float x, float y, float z) + static ccl_always_inline OutT + interp_3d_linear(const Acc &acc, const float x, float y, const float z) { int ix, iy, iz; const float tx = svm_image_texture_frac(x - 0.5f, &ix); @@ -244,7 +249,8 @@ template struct NanoVDBInterpolator { /* Tricubic b-spline interpolation. */ template - static ccl_always_inline OutT interp_3d_cubic(const Acc &acc, float x, float y, float z) + static ccl_always_inline OutT + interp_3d_cubic(const Acc &acc, const float x, float y, const float z) { int ix, iy, iz; int nix, niy, niz; @@ -294,7 +300,7 @@ template struct NanoVDBInterpolator { } static ccl_always_inline OutT - interp_3d(const TextureInfo &info, float x, float y, float z, int interp) + interp_3d(const TextureInfo &info, const float x, float y, const float z, const int interp) { using namespace nanovdb; @@ -318,7 +324,10 @@ template struct NanoVDBInterpolator { }; #endif /* WITH_NANOVDB */ -ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, int id, float3 P, int interp) +ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, + const int id, + float3 P, + const int interp) { const TextureInfo &info = kernel_data_fetch(texture_info, id); diff --git a/intern/cycles/kernel/device/oneapi/kernel.cpp b/intern/cycles/kernel/device/oneapi/kernel.cpp index 0c0aa8d3c1b..fc0fa5b8f0f 100644 --- a/intern/cycles/kernel/device/oneapi/kernel.cpp +++ b/intern/cycles/kernel/device/oneapi/kernel.cpp @@ -133,7 +133,7 @@ bool oneapi_run_test_kernel(SyclQueue *queue_) return is_computation_correct; } -bool oneapi_zero_memory_on_device(SyclQueue *queue_, void *device_pointer, size_t num_bytes) +bool oneapi_zero_memory_on_device(SyclQueue *queue_, void *device_pointer, const size_t num_bytes) { assert(queue_); sycl::queue *queue = reinterpret_cast(queue_); @@ -318,9 +318,9 @@ bool oneapi_load_kernels(SyclQueue *queue_, } bool oneapi_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, const uint kernel_features, bool use_hardware_raytracing, void **args) diff --git a/intern/cycles/kernel/device/oneapi/kernel.h b/intern/cycles/kernel/device/oneapi/kernel.h index 387b62bffe8..8c7c4791f94 100644 --- a/intern/cycles/kernel/device/oneapi/kernel.h +++ b/intern/cycles/kernel/device/oneapi/kernel.h @@ -50,9 +50,9 @@ CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_zero_memory_on_device(SyclQueue *queue_, CYCLES_KERNEL_ONEAPI_EXPORT void oneapi_set_error_cb(OneAPIErrorCallback cb, void *user_ptr); CYCLES_KERNEL_ONEAPI_EXPORT size_t oneapi_suggested_gpu_kernel_size(const DeviceKernel kernel); CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_enqueue_kernel(KernelContext *context, - int kernel, - size_t global_size, - size_t local_size, + const int kernel, + const size_t global_size, + const size_t local_size, const unsigned int kernel_features, bool use_hardware_raytracing, void **args); diff --git a/intern/cycles/kernel/device/oneapi/kernel_templates.h b/intern/cycles/kernel/device/oneapi/kernel_templates.h index 6912c39c67e..ad6b725e155 100644 --- a/intern/cycles/kernel/device/oneapi/kernel_templates.h +++ b/intern/cycles/kernel/device/oneapi/kernel_templates.h @@ -15,8 +15,8 @@ template void oneapi_call( KernelGlobalsGPU *kg, sycl::handler &cgh, - size_t global_size, - size_t local_size, + const size_t global_size, + const size_t local_size, void **args, void (*func)(const KernelGlobalsGPU *, size_t, size_t, sycl::handler &, T0, T1, T2)) { diff --git a/intern/cycles/kernel/device/optix/bvh.h b/intern/cycles/kernel/device/optix/bvh.h index b9aea0d42c7..51cef89ad8b 100644 --- a/intern/cycles/kernel/device/optix/bvh.h +++ b/intern/cycles/kernel/device/optix/bvh.h @@ -536,9 +536,9 @@ template ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, const ccl_private Ray *ray, ccl_private LocalIntersection *local_isect, - int local_object, + const int local_object, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { uint p0 = pointer_pack_to_uint_0(lcg_state); uint p1 = pointer_pack_to_uint_1(lcg_state); @@ -583,8 +583,8 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg, ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg, IntegratorShadowState state, const ccl_private Ray *ray, - uint visibility, - uint max_hits, + const uint visibility, + const uint max_hits, ccl_private uint *num_recorded_hits, ccl_private float *throughput) { diff --git a/intern/cycles/kernel/film/adaptive_sampling.h b/intern/cycles/kernel/film/adaptive_sampling.h index 5fff37ed513..07b9e68d659 100644 --- a/intern/cycles/kernel/film/adaptive_sampling.h +++ b/intern/cycles/kernel/film/adaptive_sampling.h @@ -28,12 +28,12 @@ ccl_device_forceinline bool film_need_sample_pixel(KernelGlobals kg, ccl_device bool film_adaptive_sampling_convergence_check(KernelGlobals kg, ccl_global float *render_buffer, - int x, - int y, - float threshold, - int reset, - int offset, - int stride) + const int x, + const int y, + const float threshold, + const int reset, + const int offset, + const int stride) { kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); kernel_assert(kernel_data.film.pass_sample_count != PASS_UNUSED); @@ -94,11 +94,11 @@ ccl_device bool film_adaptive_sampling_convergence_check(KernelGlobals kg, ccl_device void film_adaptive_sampling_filter_x(KernelGlobals kg, ccl_global float *render_buffer, - int y, - int start_x, - int width, - int offset, - int stride) + const int y, + const int start_x, + const int width, + const int offset, + const int stride) { kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); @@ -127,11 +127,11 @@ ccl_device void film_adaptive_sampling_filter_x(KernelGlobals kg, ccl_device void film_adaptive_sampling_filter_y(KernelGlobals kg, ccl_global float *render_buffer, - int x, - int start_y, - int height, - int offset, - int stride) + const int x, + const int start_y, + const int height, + const int offset, + const int stride) { kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); diff --git a/intern/cycles/kernel/film/cryptomatte_passes.h b/intern/cycles/kernel/film/cryptomatte_passes.h index a777563a566..5ed12a6161e 100644 --- a/intern/cycles/kernel/film/cryptomatte_passes.h +++ b/intern/cycles/kernel/film/cryptomatte_passes.h @@ -17,9 +17,9 @@ struct CryptoPassBufferElement { }; ccl_device_inline void film_write_cryptomatte_slots(ccl_global float *buffer, - int num_slots, - float id, - float weight) + const int num_slots, + const float id, + const float weight) { kernel_assert(id != ID_NONE); if (weight == 0.0f) { @@ -63,7 +63,7 @@ ccl_device_inline void film_write_cryptomatte_slots(ccl_global float *buffer, } } -ccl_device_inline void film_sort_cryptomatte_slots(ccl_global float *buffer, int num_slots) +ccl_device_inline void film_sort_cryptomatte_slots(ccl_global float *buffer, const int num_slots) { ccl_global CryptoPassBufferElement *id_buffer = (ccl_global CryptoPassBufferElement *)buffer; for (int slot = 1; slot < num_slots; ++slot) { @@ -84,7 +84,7 @@ ccl_device_inline void film_sort_cryptomatte_slots(ccl_global float *buffer, int /* post-sorting for Cryptomatte */ ccl_device_inline void film_cryptomatte_post(KernelGlobals kg, ccl_global float *render_buffer, - int pixel_index) + const int pixel_index) { const int pass_stride = kernel_data.film.pass_stride; const uint64_t render_buffer_offset = (uint64_t)pixel_index * pass_stride; diff --git a/intern/cycles/kernel/film/data_passes.h b/intern/cycles/kernel/film/data_passes.h index 708f2979a7b..454a043bc1b 100644 --- a/intern/cycles/kernel/film/data_passes.h +++ b/intern/cycles/kernel/film/data_passes.h @@ -16,9 +16,9 @@ CCL_NAMESPACE_BEGIN ccl_device_inline size_t film_write_cryptomatte_pass(ccl_global float *ccl_restrict buffer, - size_t depth, - float id, - float matte_weight) + const size_t depth, + const float id, + const float matte_weight) { film_write_cryptomatte_slots(buffer, depth * 2, id, matte_weight); return depth * 4; diff --git a/intern/cycles/kernel/film/light_passes.h b/intern/cycles/kernel/film/light_passes.h index a739cec6f90..0e2ce2bcc20 100644 --- a/intern/cycles/kernel/film/light_passes.h +++ b/intern/cycles/kernel/film/light_passes.h @@ -83,7 +83,7 @@ ccl_device_inline bool bsdf_eval_is_zero(ccl_private BsdfEval *eval) return is_zero(eval->sum); } -ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, float value) +ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, const float value) { eval->diffuse *= value; eval->glossy *= value; @@ -123,7 +123,9 @@ ccl_device_inline Spectrum bsdf_eval_pass_glossy_weight(const ccl_private BsdfEv * to render buffers instead of using per-thread memory, and to avoid the * impact of clamping on other contributions. */ -ccl_device_forceinline void film_clamp_light(KernelGlobals kg, ccl_private Spectrum *L, int bounce) +ccl_device_forceinline void film_clamp_light(KernelGlobals kg, + ccl_private Spectrum *L, + const int bounce) { #ifdef __KERNEL_DEBUG_NAN__ if (!isfinite_safe(*L)) { @@ -156,8 +158,8 @@ ccl_device_forceinline void film_clamp_light(KernelGlobals kg, ccl_private Spect ccl_device_inline int film_write_sample(KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer, - int sample, - int sample_offset) + const int sample, + const int sample_offset) { if (kernel_data.film.pass_sample_count == PASS_UNUSED) { return sample; diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h index 0fbf06244f7..5d57db9e6e3 100644 --- a/intern/cycles/kernel/film/read.h +++ b/intern/cycles/kernel/film/read.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN /* The input buffer contains transparency = 1 - alpha, this converts it to * alpha. Also clamp since alpha might end up outside of 0..1 due to Russian * roulette. */ -ccl_device_forceinline float film_transparency_to_alpha(float transparency) +ccl_device_forceinline float film_transparency_to_alpha(const float transparency) { return saturatef(1.0f - transparency); } @@ -389,7 +389,7 @@ ccl_device_inline float3 film_calculate_shadow_catcher_denoised( return pixel; } -ccl_device_inline float3 safe_divide_shadow_catcher(float3 a, float3 b) +ccl_device_inline float3 safe_divide_shadow_catcher(const float3 a, const float3 b) { float x; float y; diff --git a/intern/cycles/kernel/film/write.h b/intern/cycles/kernel/film/write.h index 2d0ff3f1558..d7e1922563c 100644 --- a/intern/cycles/kernel/film/write.h +++ b/intern/cycles/kernel/film/write.h @@ -40,7 +40,8 @@ ccl_device_forceinline ccl_global float *film_pass_pixel_render_buffer_shadow( /* Accumulate in passes. */ -ccl_device_inline void film_write_pass_float(ccl_global float *ccl_restrict buffer, float value) +ccl_device_inline void film_write_pass_float(ccl_global float *ccl_restrict buffer, + const float value) { #ifdef __ATOMIC_PASS_WRITE__ atomic_add_and_fetch_float(buffer, value); @@ -49,7 +50,8 @@ ccl_device_inline void film_write_pass_float(ccl_global float *ccl_restrict buff #endif } -ccl_device_inline void film_write_pass_float3(ccl_global float *ccl_restrict buffer, float3 value) +ccl_device_inline void film_write_pass_float3(ccl_global float *ccl_restrict buffer, + const float3 value) { #ifdef __ATOMIC_PASS_WRITE__ ccl_global float *buf_x = buffer + 0; @@ -72,7 +74,8 @@ ccl_device_inline void film_write_pass_spectrum(ccl_global float *ccl_restrict b film_write_pass_float3(buffer, spectrum_to_rgb(value)); } -ccl_device_inline void film_write_pass_float4(ccl_global float *ccl_restrict buffer, float4 value) +ccl_device_inline void film_write_pass_float4(ccl_global float *ccl_restrict buffer, + const float4 value) { #ifdef __ATOMIC_PASS_WRITE__ ccl_global float *buf_x = buffer + 0; @@ -96,13 +99,13 @@ ccl_device_inline void film_write_pass_float4(ccl_global float *ccl_restrict buf * to this pixel and no atomics are needed. */ ccl_device_inline void film_overwrite_pass_float(ccl_global float *ccl_restrict buffer, - float value) + const float value) { *buffer = value; } ccl_device_inline void film_overwrite_pass_float3(ccl_global float *ccl_restrict buffer, - float3 value) + const float3 value) { buffer[0] = value.x; buffer[1] = value.y; diff --git a/intern/cycles/kernel/geom/attribute.h b/intern/cycles/kernel/geom/attribute.h index 33d6bbb8010..aabe1f7a07b 100644 --- a/intern/cycles/kernel/geom/attribute.h +++ b/intern/cycles/kernel/geom/attribute.h @@ -20,12 +20,12 @@ CCL_NAMESPACE_BEGIN /* Patch index for triangle, -1 if not subdivision triangle */ -ccl_device_inline uint subd_triangle_patch(KernelGlobals kg, int prim) +ccl_device_inline uint subd_triangle_patch(KernelGlobals kg, const int prim) { return (prim != PRIM_NONE) ? kernel_data_fetch(tri_patch, prim) : ~0; } -ccl_device_inline uint attribute_primitive_type(KernelGlobals kg, int prim, int type) +ccl_device_inline uint attribute_primitive_type(KernelGlobals kg, const int prim, const int type) { if ((type & PRIMITIVE_TRIANGLE) && subd_triangle_patch(kg, prim) != ~0) { return ATTR_PRIM_SUBD; @@ -42,13 +42,13 @@ ccl_device_inline AttributeDescriptor attribute_not_found() /* Find attribute based on ID */ -ccl_device_inline uint object_attribute_map_offset(KernelGlobals kg, int object) +ccl_device_inline uint object_attribute_map_offset(KernelGlobals kg, const int object) { return kernel_data_fetch(objects, object).attribute_map_offset; } -ccl_device_inline AttributeDescriptor -find_attribute(KernelGlobals kg, int object, int prim, int type, uint64_t id) +ccl_device_inline AttributeDescriptor find_attribute( + KernelGlobals kg, const int object, const int prim, const int type, const uint64_t id) { if (object == OBJECT_NONE) { return attribute_not_found(); @@ -93,7 +93,7 @@ find_attribute(KernelGlobals kg, int object, int prim, int type, uint64_t id) ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, - uint64_t id) + const uint64_t id) { return find_attribute(kg, sd->object, sd->prim, sd->type, id); } diff --git a/intern/cycles/kernel/geom/curve_intersect.h b/intern/cycles/kernel/geom/curve_intersect.h index 2803ccdaf7f..fd61dd008a0 100644 --- a/intern/cycles/kernel/geom/curve_intersect.h +++ b/intern/cycles/kernel/geom/curve_intersect.h @@ -640,10 +640,10 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals kg, const float3 ray_D, const float tmin, const float tmax, - int object, - int prim, - float time, - int type) + const int object, + const int prim, + const float time, + const int type) { const bool is_motion = (type & PRIMITIVE_MOTION); diff --git a/intern/cycles/kernel/geom/motion_curve.h b/intern/cycles/kernel/geom/motion_curve.h index 4eae070f164..47035d129a3 100644 --- a/intern/cycles/kernel/geom/motion_curve.h +++ b/intern/cycles/kernel/geom/motion_curve.h @@ -23,11 +23,11 @@ CCL_NAMESPACE_BEGIN ccl_device_inline void motion_curve_keys_for_step_linear(KernelGlobals kg, int offset, - int numverts, - int numsteps, + const int numverts, + const int numsteps, int step, - int k0, - int k1, + const int k0, + const int k1, float4 keys[2]) { if (step == numsteps) { @@ -49,8 +49,12 @@ ccl_device_inline void motion_curve_keys_for_step_linear(KernelGlobals kg, } /* return 2 curve key locations */ -ccl_device_inline void motion_curve_keys_linear( - KernelGlobals kg, int object, float time, int k0, int k1, float4 keys[2]) +ccl_device_inline void motion_curve_keys_linear(KernelGlobals kg, + const int object, + const float time, + const int k0, + const int k1, + float4 keys[2]) { /* get motion info */ const int numsteps = kernel_data_fetch(objects, object).numsteps; @@ -78,13 +82,13 @@ ccl_device_inline void motion_curve_keys_linear( ccl_device_inline void motion_curve_keys_for_step(KernelGlobals kg, int offset, - int numverts, - int numsteps, + const int numverts, + const int numsteps, int step, - int k0, - int k1, - int k2, - int k3, + const int k0, + const int k1, + const int k2, + const int k3, float4 keys[4]) { if (step == numsteps) { @@ -110,8 +114,14 @@ ccl_device_inline void motion_curve_keys_for_step(KernelGlobals kg, } /* return 2 curve key locations */ -ccl_device_inline void motion_curve_keys( - KernelGlobals kg, int object, float time, int k0, int k1, int k2, int k3, float4 keys[4]) +ccl_device_inline void motion_curve_keys(KernelGlobals kg, + const int object, + const float time, + const int k0, + const int k1, + const int k2, + const int k3, + float4 keys[4]) { /* get motion info */ const int numsteps = kernel_data_fetch(objects, object).numsteps; diff --git a/intern/cycles/kernel/geom/motion_point.h b/intern/cycles/kernel/geom/motion_point.h index 29d0a016543..af778fa3db6 100644 --- a/intern/cycles/kernel/geom/motion_point.h +++ b/intern/cycles/kernel/geom/motion_point.h @@ -21,8 +21,8 @@ CCL_NAMESPACE_BEGIN #ifdef __POINTCLOUD__ -ccl_device_inline float4 -motion_point_for_step(KernelGlobals kg, int offset, int numverts, int numsteps, int step, int prim) +ccl_device_inline float4 motion_point_for_step( + KernelGlobals kg, int offset, const int numverts, const int numsteps, int step, const int prim) { if (step == numsteps) { /* center step: regular key location */ @@ -39,7 +39,10 @@ motion_point_for_step(KernelGlobals kg, int offset, int numverts, int numsteps, } /* return 2 point key locations */ -ccl_device_inline float4 motion_point(KernelGlobals kg, int object, int prim, float time) +ccl_device_inline float4 motion_point(KernelGlobals kg, + const int object, + const int prim, + const float time) { /* get motion info */ const int numsteps = kernel_data_fetch(objects, object).numsteps; diff --git a/intern/cycles/kernel/geom/motion_triangle.h b/intern/cycles/kernel/geom/motion_triangle.h index 5a35ba235f5..e408bc8c7ca 100644 --- a/intern/cycles/kernel/geom/motion_triangle.h +++ b/intern/cycles/kernel/geom/motion_triangle.h @@ -22,10 +22,10 @@ CCL_NAMESPACE_BEGIN /* Time interpolation of vertex positions and normals */ ccl_device_inline void motion_triangle_verts_for_step(KernelGlobals kg, - uint3 tri_vindex, + const uint3 tri_vindex, int offset, - int numverts, - int numsteps, + const int numverts, + const int numsteps, int step, float3 verts[3]) { @@ -50,10 +50,10 @@ ccl_device_inline void motion_triangle_verts_for_step(KernelGlobals kg, } ccl_device_inline void motion_triangle_normals_for_step(KernelGlobals kg, - uint3 tri_vindex, + const uint3 tri_vindex, int offset, - int numverts, - int numsteps, + const int numverts, + const int numsteps, int step, float3 normals[3]) { @@ -78,9 +78,9 @@ ccl_device_inline void motion_triangle_normals_for_step(KernelGlobals kg, } ccl_device_inline void motion_triangle_compute_info(KernelGlobals kg, - int object, - float time, - int prim, + const int object, + const float time, + const int prim, ccl_private uint3 *tri_vindex, ccl_private int *numsteps, ccl_private int *step, @@ -99,12 +99,12 @@ ccl_device_inline void motion_triangle_compute_info(KernelGlobals kg, } ccl_device_inline void motion_triangle_vertices(KernelGlobals kg, - int object, - uint3 tri_vindex, - int numsteps, - int numverts, - int step, - float t, + const int object, + const uint3 tri_vindex, + const int numsteps, + const int numverts, + const int step, + const float t, float3 verts[3]) { /* Find attribute. */ @@ -123,7 +123,7 @@ ccl_device_inline void motion_triangle_vertices(KernelGlobals kg, } ccl_device_inline void motion_triangle_vertices( - KernelGlobals kg, int object, int prim, float time, float3 verts[3]) + KernelGlobals kg, const int object, const int prim, const float time, float3 verts[3]) { int numsteps; int step; @@ -136,12 +136,12 @@ ccl_device_inline void motion_triangle_vertices( } ccl_device_inline void motion_triangle_normals(KernelGlobals kg, - int object, - uint3 tri_vindex, - int numsteps, - int numverts, - int step, - float t, + const int object, + const uint3 tri_vindex, + const int numsteps, + const int numverts, + const int step, + const float t, float3 normals[3]) { /* Find attribute. */ @@ -160,8 +160,12 @@ ccl_device_inline void motion_triangle_normals(KernelGlobals kg, normals[2] = normalize((1.0f - t) * normals[2] + t * next_normals[2]); } -ccl_device_inline void motion_triangle_vertices_and_normals( - KernelGlobals kg, int object, int prim, float time, float3 verts[3], float3 normals[3]) +ccl_device_inline void motion_triangle_vertices_and_normals(KernelGlobals kg, + const int object, + const int prim, + const float time, + float3 verts[3], + float3 normals[3]) { int numsteps; int step; @@ -175,14 +179,14 @@ ccl_device_inline void motion_triangle_vertices_and_normals( } ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, - float3 Ng, - int object, - uint3 tri_vindex, - int numsteps, - int step, - float t, - float u, - float v) + const float3 Ng, + const int object, + const uint3 tri_vindex, + const int numsteps, + const int step, + const float t, + const float u, + const float v) { float3 normals[3]; const int numverts = kernel_data_fetch(objects, object).numverts; @@ -195,8 +199,13 @@ ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, return is_zero(N) ? Ng : N; } -ccl_device_inline float3 motion_triangle_smooth_normal( - KernelGlobals kg, float3 Ng, int object, int prim, float u, float v, float time) +ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, + const float3 Ng, + const int object, + const int prim, + const float u, + float v, + const float time) { int numsteps; int step; diff --git a/intern/cycles/kernel/geom/motion_triangle_intersect.h b/intern/cycles/kernel/geom/motion_triangle_intersect.h index d22cd3cc25a..96d842fc753 100644 --- a/intern/cycles/kernel/geom/motion_triangle_intersect.h +++ b/intern/cycles/kernel/geom/motion_triangle_intersect.h @@ -30,8 +30,11 @@ CCL_NAMESPACE_BEGIN /** * Use the barycentric coordinates to get the intersection location */ -ccl_device_inline float3 motion_triangle_point_from_uv( - KernelGlobals kg, ccl_private ShaderData *sd, const float u, const float v, float3 verts[3]) +ccl_device_inline float3 motion_triangle_point_from_uv(KernelGlobals kg, + ccl_private ShaderData *sd, + const float u, + const float v, + const float3 verts[3]) { /* This appears to give slightly better precision than interpolating with w = (1 - u - v). */ float3 P = verts[0] + u * (verts[1] - verts[0]) + v * (verts[2] - verts[0]); @@ -50,15 +53,15 @@ ccl_device_inline float3 motion_triangle_point_from_uv( ccl_device_inline bool motion_triangle_intersect(KernelGlobals kg, ccl_private Intersection *isect, - float3 P, - float3 dir, - float tmin, - float tmax, - float time, - uint visibility, - int object, - int prim, - int prim_addr) + const float3 P, + const float3 dir, + const float tmin, + const float tmax, + const float time, + const uint visibility, + const int object, + const int prim, + const int prim_addr) { /* Get vertex locations for intersection. */ float3 verts[3]; @@ -95,16 +98,16 @@ ccl_device_inline bool motion_triangle_intersect(KernelGlobals kg, #ifdef __BVH_LOCAL__ ccl_device_inline bool motion_triangle_intersect_local(KernelGlobals kg, ccl_private LocalIntersection *local_isect, - float3 P, - float3 dir, - float time, - int object, - int prim, - int prim_addr, - float tmin, - float tmax, + const float3 P, + const float3 dir, + const float time, + const int object, + const int prim, + const int prim_addr, + const float tmin, + const float tmax, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { /* Get vertex locations for intersection. */ float3 verts[3]; diff --git a/intern/cycles/kernel/geom/object.h b/intern/cycles/kernel/geom/object.h index 9e5c8d8fba8..7ef19a1c04c 100644 --- a/intern/cycles/kernel/geom/object.h +++ b/intern/cycles/kernel/geom/object.h @@ -31,7 +31,7 @@ enum ObjectVectorTransform { OBJECT_PASS_MOTION_PRE = 0, OBJECT_PASS_MOTION_POST /* Object to world space transformation */ ccl_device_inline Transform object_fetch_transform(KernelGlobals kg, - int object, + const int object, enum ObjectTransform type) { if (type == OBJECT_INVERSE_TRANSFORM) { @@ -42,7 +42,7 @@ ccl_device_inline Transform object_fetch_transform(KernelGlobals kg, /* Lamp to world space transformation */ -ccl_device_inline Transform lamp_fetch_transform(KernelGlobals kg, int lamp, bool inverse) +ccl_device_inline Transform lamp_fetch_transform(KernelGlobals kg, const int lamp, bool inverse) { if (inverse) { return kernel_data_fetch(lights, lamp).itfm; @@ -53,7 +53,7 @@ ccl_device_inline Transform lamp_fetch_transform(KernelGlobals kg, int lamp, boo /* Object to world space transformation for motion vectors */ ccl_device_inline Transform object_fetch_motion_pass_transform(KernelGlobals kg, - int object, + const int object, enum ObjectVectorTransform type) { const int offset = object * OBJECT_MOTION_PASS_SIZE + (int)type; @@ -63,7 +63,9 @@ ccl_device_inline Transform object_fetch_motion_pass_transform(KernelGlobals kg, /* Motion blurred object transformations */ #ifdef __OBJECT_MOTION__ -ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals kg, int object, float time) +ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals kg, + const int object, + const float time) { const uint motion_offset = kernel_data_fetch(objects, object).motion_offset; const ccl_global DecomposedTransform *motion = &kernel_data_fetch(object_motion, motion_offset); @@ -77,8 +79,8 @@ ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals kg, int #endif /* __OBJECT_MOTION__ */ ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals kg, - int object, - float time, + const int object, + const float time, ccl_private Transform *itfm) { #ifdef __OBJECT_MOTION__ @@ -270,7 +272,7 @@ ccl_device_inline float3 object_location(KernelGlobals kg, const ccl_private Sha /* Color of the object */ -ccl_device_inline float3 object_color(KernelGlobals kg, int object) +ccl_device_inline float3 object_color(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return make_float3(0.0f, 0.0f, 0.0f); @@ -282,7 +284,7 @@ ccl_device_inline float3 object_color(KernelGlobals kg, int object) /* Alpha of the object */ -ccl_device_inline float object_alpha(KernelGlobals kg, int object) +ccl_device_inline float object_alpha(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0.0f; @@ -293,7 +295,7 @@ ccl_device_inline float object_alpha(KernelGlobals kg, int object) /* Pass ID number of object */ -ccl_device_inline float object_pass_id(KernelGlobals kg, int object) +ccl_device_inline float object_pass_id(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0.0f; @@ -304,7 +306,7 @@ ccl_device_inline float object_pass_id(KernelGlobals kg, int object) /* Light-group of lamp. */ -ccl_device_inline int lamp_lightgroup(KernelGlobals kg, int lamp) +ccl_device_inline int lamp_lightgroup(KernelGlobals kg, const int lamp) { if (lamp == LAMP_NONE) { return LIGHTGROUP_NONE; @@ -315,7 +317,7 @@ ccl_device_inline int lamp_lightgroup(KernelGlobals kg, int lamp) /* Light-group of object. */ -ccl_device_inline int object_lightgroup(KernelGlobals kg, int object) +ccl_device_inline int object_lightgroup(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return LIGHTGROUP_NONE; @@ -326,7 +328,7 @@ ccl_device_inline int object_lightgroup(KernelGlobals kg, int object) /* Per lamp random number for shader variation */ -ccl_device_inline float lamp_random_number(KernelGlobals kg, int lamp) +ccl_device_inline float lamp_random_number(KernelGlobals kg, const int lamp) { if (lamp == LAMP_NONE) { return 0.0f; @@ -337,7 +339,7 @@ ccl_device_inline float lamp_random_number(KernelGlobals kg, int lamp) /* Per object random number for shader variation */ -ccl_device_inline float object_random_number(KernelGlobals kg, int object) +ccl_device_inline float object_random_number(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0.0f; @@ -348,7 +350,7 @@ ccl_device_inline float object_random_number(KernelGlobals kg, int object) /* Particle ID from which this object was generated */ -ccl_device_inline int object_particle_id(KernelGlobals kg, int object) +ccl_device_inline int object_particle_id(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0; @@ -359,7 +361,7 @@ ccl_device_inline int object_particle_id(KernelGlobals kg, int object) /* Generated texture coordinate on surface from where object was instanced */ -ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, int object) +ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return make_float3(0.0f, 0.0f, 0.0f); @@ -372,7 +374,7 @@ ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, int object) /* UV texture coordinate on surface from where object was instanced */ -ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, int object) +ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return make_float3(0.0f, 0.0f, 0.0f); @@ -384,7 +386,7 @@ ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, int object) /* Offset to an objects patch map */ -ccl_device_inline uint object_patch_map_offset(KernelGlobals kg, int object) +ccl_device_inline uint object_patch_map_offset(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0; @@ -395,7 +397,7 @@ ccl_device_inline uint object_patch_map_offset(KernelGlobals kg, int object) /* Volume step size */ -ccl_device_inline float object_volume_density(KernelGlobals kg, int object) +ccl_device_inline float object_volume_density(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 1.0f; @@ -404,7 +406,7 @@ ccl_device_inline float object_volume_density(KernelGlobals kg, int object) return kernel_data_fetch(objects, object).volume_density; } -ccl_device_inline float object_volume_step_size(KernelGlobals kg, int object) +ccl_device_inline float object_volume_step_size(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return kernel_data.background.volume_step_size; @@ -422,7 +424,7 @@ ccl_device int shader_pass_id(KernelGlobals kg, const ccl_private ShaderData *sd /* Cryptomatte ID */ -ccl_device_inline float object_cryptomatte_id(KernelGlobals kg, int object) +ccl_device_inline float object_cryptomatte_id(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0.0f; @@ -431,7 +433,7 @@ ccl_device_inline float object_cryptomatte_id(KernelGlobals kg, int object) return kernel_data_fetch(objects, object).cryptomatte_object; } -ccl_device_inline float object_cryptomatte_asset_id(KernelGlobals kg, int object) +ccl_device_inline float object_cryptomatte_asset_id(KernelGlobals kg, const int object) { if (object == OBJECT_NONE) { return 0; @@ -442,49 +444,49 @@ ccl_device_inline float object_cryptomatte_asset_id(KernelGlobals kg, int object /* Particle data from which object was instanced */ -ccl_device_inline uint particle_index(KernelGlobals kg, int particle) +ccl_device_inline uint particle_index(KernelGlobals kg, const int particle) { return kernel_data_fetch(particles, particle).index; } -ccl_device float particle_age(KernelGlobals kg, int particle) +ccl_device float particle_age(KernelGlobals kg, const int particle) { return kernel_data_fetch(particles, particle).age; } -ccl_device float particle_lifetime(KernelGlobals kg, int particle) +ccl_device float particle_lifetime(KernelGlobals kg, const int particle) { return kernel_data_fetch(particles, particle).lifetime; } -ccl_device float particle_size(KernelGlobals kg, int particle) +ccl_device float particle_size(KernelGlobals kg, const int particle) { return kernel_data_fetch(particles, particle).size; } -ccl_device float4 particle_rotation(KernelGlobals kg, int particle) +ccl_device float4 particle_rotation(KernelGlobals kg, const int particle) { return kernel_data_fetch(particles, particle).rotation; } -ccl_device float3 particle_location(KernelGlobals kg, int particle) +ccl_device float3 particle_location(KernelGlobals kg, const int particle) { return make_float3(kernel_data_fetch(particles, particle).location); } -ccl_device float3 particle_velocity(KernelGlobals kg, int particle) +ccl_device float3 particle_velocity(KernelGlobals kg, const int particle) { return make_float3(kernel_data_fetch(particles, particle).velocity); } -ccl_device float3 particle_angular_velocity(KernelGlobals kg, int particle) +ccl_device float3 particle_angular_velocity(KernelGlobals kg, const int particle) { return make_float3(kernel_data_fetch(particles, particle).angular_velocity); } /* Object intersection in BVH */ -ccl_device_inline float3 bvh_clamp_direction(float3 dir) +ccl_device_inline float3 bvh_clamp_direction(const float3 dir) { const float ooeps = 8.271806E-25f; return make_float3((fabsf(dir.x) > ooeps) ? dir.x : copysignf(ooeps, dir.x), @@ -492,7 +494,7 @@ ccl_device_inline float3 bvh_clamp_direction(float3 dir) (fabsf(dir.z) > ooeps) ? dir.z : copysignf(ooeps, dir.z)); } -ccl_device_inline float3 bvh_inverse_direction(float3 dir) +ccl_device_inline float3 bvh_inverse_direction(const float3 dir) { return rcp(dir); } @@ -500,7 +502,7 @@ ccl_device_inline float3 bvh_inverse_direction(float3 dir) /* Transform ray into object space to enter static object in BVH */ ccl_device_inline void bvh_instance_push(KernelGlobals kg, - int object, + const int object, const ccl_private Ray *ray, ccl_private float3 *P, ccl_private float3 *dir, @@ -518,7 +520,7 @@ ccl_device_inline void bvh_instance_push(KernelGlobals kg, /* Transform ray into object space to enter motion blurred object in BVH */ ccl_device_inline void bvh_instance_motion_push(KernelGlobals kg, - int object, + const int object, const ccl_private Ray *ray, ccl_private float3 *P, ccl_private float3 *dir, diff --git a/intern/cycles/kernel/geom/patch.h b/intern/cycles/kernel/geom/patch.h index ba3804bd93b..1dae611968d 100644 --- a/intern/cycles/kernel/geom/patch.h +++ b/intern/cycles/kernel/geom/patch.h @@ -20,7 +20,7 @@ struct PatchHandle { int array_index, patch_index, vert_index; }; -ccl_device_inline int patch_map_resolve_quadrant(float median, +ccl_device_inline int patch_map_resolve_quadrant(const float median, ccl_private float *u, ccl_private float *v) { @@ -52,7 +52,7 @@ ccl_device_inline int patch_map_resolve_quadrant(float median, /* retrieve PatchHandle from patch coords */ ccl_device_inline PatchHandle -patch_map_find_patch(KernelGlobals kg, int object, int patch, float u, float v) +patch_map_find_patch(KernelGlobals kg, const int object, const int patch, float u, float v) { PatchHandle handle; @@ -97,7 +97,7 @@ patch_map_find_patch(KernelGlobals kg, int object, int patch, float u, float v) return handle; } -ccl_device_inline void patch_eval_bspline_weights(float t, +ccl_device_inline void patch_eval_bspline_weights(const float t, ccl_private float *point, ccl_private float *deriv) { @@ -119,7 +119,7 @@ ccl_device_inline void patch_eval_bspline_weights(float t, deriv[3] = 0.5f * t2; } -ccl_device_inline void patch_eval_adjust_boundary_weights(uint bits, +ccl_device_inline void patch_eval_adjust_boundary_weights(const uint bits, ccl_private float *s, ccl_private float *t) { @@ -150,12 +150,12 @@ ccl_device_inline void patch_eval_adjust_boundary_weights(uint bits, } } -ccl_device_inline int patch_eval_depth(uint patch_bits) +ccl_device_inline int patch_eval_depth(const uint patch_bits) { return (patch_bits & 0xf); } -ccl_device_inline float patch_eval_param_fraction(uint patch_bits) +ccl_device_inline float patch_eval_param_fraction(const uint patch_bits) { const bool non_quad_root = (patch_bits >> 4) & 0x1; const int depth = patch_eval_depth(patch_bits); @@ -166,7 +166,7 @@ ccl_device_inline float patch_eval_param_fraction(uint patch_bits) return 1.0f / (float)(1 << depth); } -ccl_device_inline void patch_eval_normalize_coords(uint patch_bits, +ccl_device_inline void patch_eval_normalize_coords(const uint patch_bits, ccl_private float *u, ccl_private float *v) { @@ -247,11 +247,11 @@ ccl_device_inline void patch_eval_basis(KernelGlobals kg, /* generic function for evaluating indices and weights from patch coords */ ccl_device_inline int patch_eval_control_verts(KernelGlobals kg, - int object, - int patch, - float u, - float v, - int channel, + const int object, + const int patch, + const float u, + const float v, + const int channel, int indices[PATCH_MAX_CONTROL_VERTS], float weights[PATCH_MAX_CONTROL_VERTS], float weights_du[PATCH_MAX_CONTROL_VERTS], @@ -270,11 +270,11 @@ ccl_device_inline int patch_eval_control_verts(KernelGlobals kg, ccl_device float patch_eval_float(KernelGlobals kg, const ccl_private ShaderData *sd, - int offset, - int patch, - float u, - float v, - int channel, + const int offset, + const int patch, + const float u, + const float v, + const int channel, ccl_private float *du, ccl_private float *dv) { @@ -311,11 +311,11 @@ ccl_device float patch_eval_float(KernelGlobals kg, ccl_device float2 patch_eval_float2(KernelGlobals kg, const ccl_private ShaderData *sd, - int offset, - int patch, - float u, - float v, - int channel, + const int offset, + const int patch, + const float u, + const float v, + const int channel, ccl_private float2 *du, ccl_private float2 *dv) { @@ -352,11 +352,11 @@ ccl_device float2 patch_eval_float2(KernelGlobals kg, ccl_device float3 patch_eval_float3(KernelGlobals kg, const ccl_private ShaderData *sd, - int offset, - int patch, - float u, - float v, - int channel, + const int offset, + const int patch, + const float u, + const float v, + const int channel, ccl_private float3 *du, ccl_private float3 *dv) { @@ -393,11 +393,11 @@ ccl_device float3 patch_eval_float3(KernelGlobals kg, ccl_device float4 patch_eval_float4(KernelGlobals kg, const ccl_private ShaderData *sd, - int offset, - int patch, - float u, - float v, - int channel, + const int offset, + const int patch, + const float u, + const float v, + const int channel, ccl_private float4 *du, ccl_private float4 *dv) { @@ -434,11 +434,11 @@ ccl_device float4 patch_eval_float4(KernelGlobals kg, ccl_device float4 patch_eval_uchar4(KernelGlobals kg, const ccl_private ShaderData *sd, - int offset, - int patch, - float u, - float v, - int channel, + const int offset, + const int patch, + const float u, + const float v, + const int channel, ccl_private float4 *du, ccl_private float4 *dv) { diff --git a/intern/cycles/kernel/geom/shader_data.h b/intern/cycles/kernel/geom/shader_data.h index 6549ff30a00..9738e6aad1a 100644 --- a/intern/cycles/kernel/geom/shader_data.h +++ b/intern/cycles/kernel/geom/shader_data.h @@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN ccl_device void shader_setup_object_transforms(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, - float time) + const float time) { #ifdef __OBJECT_MOTION__ if (sd->object_flag & SD_OBJECT_MOTION) { @@ -132,15 +132,15 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals kg, const float3 P, const float3 Ng, const float3 I, - int shader, - int object, - int prim, - float u, - float v, - float t, - float time, + const int shader, + const int object, + const int prim, + const float u, + const float v, + const float t, + const float time, bool object_space, - int lamp) + const int lamp) { /* vectors */ sd->P = P; @@ -250,10 +250,10 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals kg, ccl_device void shader_setup_from_displace(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, - int object, - int prim, - float u, - float v) + const int object, + const int prim, + const float u, + const float v) { float3 P; float3 Ng; @@ -286,10 +286,10 @@ ccl_device void shader_setup_from_displace(KernelGlobals kg, #ifdef __HAIR__ ccl_device void shader_setup_from_curve(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, - int object, - int prim, - int segment, - float u) + const int object, + const int prim, + const int segment, + const float u) { /* Primitive */ sd->type = PRIMITIVE_PACK_SEGMENT(PRIMITIVE_CURVE_THICK, segment); diff --git a/intern/cycles/kernel/geom/subd_triangle.h b/intern/cycles/kernel/geom/subd_triangle.h index a417fab5536..7f1d2fddfb1 100644 --- a/intern/cycles/kernel/geom/subd_triangle.h +++ b/intern/cycles/kernel/geom/subd_triangle.h @@ -29,7 +29,7 @@ ccl_device_inline void subd_triangle_patch_uv(KernelGlobals kg, /* Vertex indices of patch */ -ccl_device_inline uint4 subd_triangle_patch_indices(KernelGlobals kg, int patch) +ccl_device_inline uint4 subd_triangle_patch_indices(KernelGlobals kg, const int patch) { uint4 indices; @@ -43,21 +43,23 @@ ccl_device_inline uint4 subd_triangle_patch_indices(KernelGlobals kg, int patch) /* Originating face for patch */ -ccl_device_inline uint subd_triangle_patch_face(KernelGlobals kg, int patch) +ccl_device_inline uint subd_triangle_patch_face(KernelGlobals kg, const int patch) { return kernel_data_fetch(patches, patch + 4); } /* Number of corners on originating face */ -ccl_device_inline uint subd_triangle_patch_num_corners(KernelGlobals kg, int patch) +ccl_device_inline uint subd_triangle_patch_num_corners(KernelGlobals kg, const int patch) { return kernel_data_fetch(patches, patch + 5) & 0xffff; } /* Indices of the four corners that are used by the patch */ -ccl_device_inline void subd_triangle_patch_corners(KernelGlobals kg, int patch, int corners[4]) +ccl_device_inline void subd_triangle_patch_corners(KernelGlobals kg, + const int patch, + int corners[4]) { uint4 data; diff --git a/intern/cycles/kernel/geom/triangle.h b/intern/cycles/kernel/geom/triangle.h index 0177c23e098..c2903647006 100644 --- a/intern/cycles/kernel/geom/triangle.h +++ b/intern/cycles/kernel/geom/triangle.h @@ -36,10 +36,10 @@ ccl_device_inline float3 triangle_normal(KernelGlobals kg, ccl_private ShaderDat /* Point and normal on triangle. */ ccl_device_inline void triangle_point_normal(KernelGlobals kg, - int object, - int prim, - float u, - float v, + const int object, + const int prim, + const float u, + const float v, ccl_private float3 *P, ccl_private float3 *Ng, ccl_private int *shader) @@ -68,7 +68,7 @@ ccl_device_inline void triangle_point_normal(KernelGlobals kg, /* Triangle vertex locations */ -ccl_device_inline void triangle_vertices(KernelGlobals kg, int prim, float3 P[3]) +ccl_device_inline void triangle_vertices(KernelGlobals kg, const int prim, float3 P[3]) { const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); P[0] = kernel_data_fetch(tri_verts, tri_vindex.x); @@ -79,7 +79,7 @@ ccl_device_inline void triangle_vertices(KernelGlobals kg, int prim, float3 P[3] /* Triangle vertex locations and vertex normals */ ccl_device_inline void triangle_vertices_and_normals(KernelGlobals kg, - int prim, + const int prim, float3 P[3], float3 N[3]) { @@ -96,7 +96,7 @@ ccl_device_inline void triangle_vertices_and_normals(KernelGlobals kg, /* Interpolate smooth vertex normal from vertices */ ccl_device_inline float3 -triangle_smooth_normal(KernelGlobals kg, float3 Ng, int prim, float u, float v) +triangle_smooth_normal(KernelGlobals kg, const float3 Ng, const int prim, const float u, float v) { /* load triangle vertices */ const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); @@ -110,8 +110,12 @@ triangle_smooth_normal(KernelGlobals kg, float3 Ng, int prim, float u, float v) return is_zero(N) ? Ng : N; } -ccl_device_inline float3 triangle_smooth_normal_unnormalized( - KernelGlobals kg, const ccl_private ShaderData *sd, float3 Ng, int prim, float u, float v) +ccl_device_inline float3 triangle_smooth_normal_unnormalized(KernelGlobals kg, + const ccl_private ShaderData *sd, + const float3 Ng, + const int prim, + const float u, + float v) { /* load triangle vertices */ const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); @@ -135,7 +139,7 @@ ccl_device_inline float3 triangle_smooth_normal_unnormalized( /* Ray differentials on triangle */ ccl_device_inline void triangle_dPdudv(KernelGlobals kg, - int prim, + const int prim, ccl_private float3 *dPdu, ccl_private float3 *dPdv) { diff --git a/intern/cycles/kernel/geom/triangle_intersect.h b/intern/cycles/kernel/geom/triangle_intersect.h index c201ecb0cea..3d33d44a414 100644 --- a/intern/cycles/kernel/geom/triangle_intersect.h +++ b/intern/cycles/kernel/geom/triangle_intersect.h @@ -23,14 +23,14 @@ CCL_NAMESPACE_BEGIN ccl_device_inline bool triangle_intersect(KernelGlobals kg, ccl_private Intersection *isect, - float3 P, - float3 dir, - float tmin, - float tmax, - uint visibility, - int object, - int prim, - int prim_addr) + const float3 P, + const float3 dir, + const float tmin, + const float tmax, + const uint visibility, + const int object, + const int prim, + const int prim_addr) { const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); const float3 tri_a = kernel_data_fetch(tri_verts, tri_vindex.x); @@ -69,15 +69,15 @@ ccl_device_inline bool triangle_intersect(KernelGlobals kg, #ifdef __BVH_LOCAL__ ccl_device_inline bool triangle_intersect_local(KernelGlobals kg, ccl_private LocalIntersection *local_isect, - float3 P, - float3 dir, - int object, - int prim, - int prim_addr, - float tmin, - float tmax, + const float3 P, + const float3 dir, + const int object, + const int prim, + const int prim_addr, + const float tmin, + const float tmax, ccl_private uint *lcg_state, - int max_hits) + const int max_hits) { const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); const float3 tri_a = kernel_data_fetch(tri_verts, tri_vindex.x); diff --git a/intern/cycles/kernel/integrator/mnee.h b/intern/cycles/kernel/integrator/mnee.h index 0dd776362ce..f58623d7da4 100644 --- a/intern/cycles/kernel/integrator/mnee.h +++ b/intern/cycles/kernel/integrator/mnee.h @@ -254,7 +254,7 @@ __attribute__((noinline)) ccl_device_forceinline #endif bool mnee_compute_constraint_derivatives( - int vertex_count, + const int vertex_count, ccl_private ManifoldVertex *vertices, const ccl_private float3 &surface_sample_pos, const bool light_fixed_direction, @@ -373,7 +373,7 @@ bool mnee_compute_constraint_derivatives( * to use for specular manifold walk * (See for example http://faculty.washington.edu/finlayso/ebook/algebraic/advanced/LUtri.htm * for block tridiagonal matrix based linear system solve) */ -ccl_device_forceinline bool mnee_solve_matrix_h_to_x(int vertex_count, +ccl_device_forceinline bool mnee_solve_matrix_h_to_x(const int vertex_count, ccl_private ManifoldVertex *vertices, ccl_private float2 *dx) { @@ -413,7 +413,7 @@ ccl_device_forceinline bool mnee_newton_solver(KernelGlobals kg, ccl_private ShaderData *sd_vtx, const ccl_private LightSample *ls, const bool light_fixed_direction, - int vertex_count, + const int vertex_count, ccl_private ManifoldVertex *vertices) { float2 dx[MNEE_MAX_CAUSTIC_CASTERS]; @@ -582,8 +582,11 @@ ccl_device_forceinline bool mnee_newton_solver(KernelGlobals kg, } /* Sample bsdf in half-vector measure. */ -ccl_device_forceinline float2 -mnee_sample_bsdf_dh(ClosureType type, float alpha_x, float alpha_y, float sample_u, float sample_v) +ccl_device_forceinline float2 mnee_sample_bsdf_dh(ClosureType type, + const float alpha_x, + const float alpha_y, + const float sample_u, + const float sample_v) { float alpha2; float cos_phi; @@ -626,8 +629,8 @@ mnee_sample_bsdf_dh(ClosureType type, float alpha_x, float alpha_y, float sample * specular chain above: this allows us to simplify the bsdf weight */ ccl_device_forceinline Spectrum mnee_eval_bsdf_contribution(KernelGlobals kg, ccl_private ShaderClosure *closure, - float3 wi, - float3 wo) + const float3 wi, + const float3 wo) { ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)closure; @@ -669,7 +672,7 @@ ccl_device_forceinline Spectrum mnee_eval_bsdf_contribution(KernelGlobals kg, ccl_device_forceinline bool mnee_compute_transfer_matrix(const ccl_private ShaderData *sd, const ccl_private LightSample *ls, const bool light_fixed_direction, - int vertex_count, + const int vertex_count, ccl_private ManifoldVertex *vertices, ccl_private float *dx1_dxlight, ccl_private float *dh_dx) @@ -800,7 +803,7 @@ ccl_device_forceinline bool mnee_path_contribution(KernelGlobals kg, ccl_private ShaderData *sd_mnee, ccl_private LightSample *ls, const bool light_fixed_direction, - int vertex_count, + const int vertex_count, ccl_private ManifoldVertex *vertices, ccl_private BsdfEval *throughput) { diff --git a/intern/cycles/kernel/integrator/shade_volume.h b/intern/cycles/kernel/integrator/shade_volume.h index 61fb6d967fd..50aa60d5fcd 100644 --- a/intern/cycles/kernel/integrator/shade_volume.h +++ b/intern/cycles/kernel/integrator/shade_volume.h @@ -356,9 +356,9 @@ ccl_device_inline bool volume_equiangular_valid_ray_segment(KernelGlobals kg, /* Emission */ ccl_device Spectrum volume_emission_integrate(ccl_private VolumeShaderCoefficients *coeff, - int closure_flag, + const int closure_flag, Spectrum transmittance, - float t) + const float t) { /* integral E * exp(-sigma_t * t) from 0 to t = E * (1 - exp(-sigma_t * t))/sigma_t * this goes to E * t as sigma_t goes to zero diff --git a/intern/cycles/kernel/integrator/state_util.h b/intern/cycles/kernel/integrator/state_util.h index c19437a745b..2a5c7c636d8 100644 --- a/intern/cycles/kernel/integrator/state_util.h +++ b/intern/cycles/kernel/integrator/state_util.h @@ -174,7 +174,7 @@ ccl_device_forceinline void integrator_state_read_isect( #ifdef __VOLUME__ ccl_device_forceinline VolumeStack integrator_state_read_volume_stack(ConstIntegratorState state, - int i) + const int i) { VolumeStack entry = {INTEGRATOR_STATE_ARRAY(state, volume_stack, i, object), INTEGRATOR_STATE_ARRAY(state, volume_stack, i, shader)}; @@ -182,7 +182,7 @@ ccl_device_forceinline VolumeStack integrator_state_read_volume_stack(ConstInteg } ccl_device_forceinline void integrator_state_write_volume_stack(IntegratorState state, - int i, + const int i, VolumeStack entry) { INTEGRATOR_STATE_ARRAY_WRITE(state, volume_stack, i, object) = entry.object; @@ -235,7 +235,7 @@ ccl_device_forceinline void integrator_state_copy_volume_stack(KernelGlobals kg, } ccl_device_forceinline VolumeStack -integrator_state_read_shadow_volume_stack(ConstIntegratorShadowState state, int i) +integrator_state_read_shadow_volume_stack(ConstIntegratorShadowState state, const int i) { VolumeStack entry = {INTEGRATOR_STATE_ARRAY(state, shadow_volume_stack, i, object), INTEGRATOR_STATE_ARRAY(state, shadow_volume_stack, i, shader)}; @@ -251,7 +251,7 @@ ccl_device_forceinline bool integrator_state_shadow_volume_stack_is_empty( } ccl_device_forceinline void integrator_state_write_shadow_volume_stack(IntegratorShadowState state, - int i, + const int i, VolumeStack entry) { INTEGRATOR_STATE_ARRAY_WRITE(state, shadow_volume_stack, i, object) = entry.object; diff --git a/intern/cycles/kernel/integrator/subsurface_disk.h b/intern/cycles/kernel/integrator/subsurface_disk.h index fd04b3b750d..a4388ed96f4 100644 --- a/intern/cycles/kernel/integrator/subsurface_disk.h +++ b/intern/cycles/kernel/integrator/subsurface_disk.h @@ -23,7 +23,9 @@ CCL_NAMESPACE_BEGIN * http://library.imageworks.com/pdfs/imageworks-library-BSSRDF-sampling.pdf */ -ccl_device_inline Spectrum subsurface_disk_eval(const Spectrum radius, float disk_r, float r) +ccl_device_inline Spectrum subsurface_disk_eval(const Spectrum radius, + const float disk_r, + const float r) { const Spectrum eval = bssrdf_eval(radius, r); const float pdf = bssrdf_pdf(radius, disk_r); diff --git a/intern/cycles/kernel/integrator/subsurface_random_walk.h b/intern/cycles/kernel/integrator/subsurface_random_walk.h index 49115eb2deb..2d3db49dd87 100644 --- a/intern/cycles/kernel/integrator/subsurface_random_walk.h +++ b/intern/cycles/kernel/integrator/subsurface_random_walk.h @@ -28,7 +28,7 @@ CCL_NAMESPACE_BEGIN ccl_device void subsurface_random_walk_remap(const float albedo, const float d, - float g, + const float g, ccl_private float *sigma_t, ccl_private float *alpha) { @@ -120,13 +120,17 @@ ccl_device void subsurface_random_walk_coefficients(const Spectrum albedo, * https://iliyan.com/publications/RenderingCourse2020 */ -ccl_device_forceinline float eval_phase_dwivedi(float v, float phase_log, float cos_theta) +ccl_device_forceinline float eval_phase_dwivedi(const float v, + const float phase_log, + const float cos_theta) { /* Eq. 9 from [2] using precomputed log((v + 1) / (v - 1)) */ return 1.0f / ((v - cos_theta) * phase_log); } -ccl_device_forceinline float sample_phase_dwivedi(float v, float phase_log, float rand) +ccl_device_forceinline float sample_phase_dwivedi(const float v, + const float phase_log, + const float rand) { /* Based on Eq. 10 from [2]: `v - (v + 1) * pow((v - 1) / (v + 1), rand)` * Since we're already pre-computing `phase_log = log((v + 1) / (v - 1))` for the evaluation, @@ -134,13 +138,15 @@ ccl_device_forceinline float sample_phase_dwivedi(float v, float phase_log, floa return v - (v + 1.0f) * expf(-rand * phase_log); } -ccl_device_forceinline float diffusion_length_dwivedi(float alpha) +ccl_device_forceinline float diffusion_length_dwivedi(const float alpha) { /* Eq. 67 from [3] */ return 1.0f / sqrtf(1.0f - powf(alpha, 2.44294f - 0.0215813f * alpha + 0.578637f / alpha)); } -ccl_device_forceinline float3 direction_from_cosine(float3 D, float cos_theta, float randv) +ccl_device_forceinline float3 direction_from_cosine(const float3 D, + const float cos_theta, + const float randv) { const float phi = M_2PI_F * randv; const float3 dir = spherical_cos_to_direction(cos_theta, phi); @@ -152,7 +158,7 @@ ccl_device_forceinline float3 direction_from_cosine(float3 D, float cos_theta, f } ccl_device_forceinline Spectrum subsurface_random_walk_pdf(Spectrum sigma_t, - float t, + const float t, bool hit, ccl_private Spectrum *transmittance) { diff --git a/intern/cycles/kernel/integrator/surface_shader.h b/intern/cycles/kernel/integrator/surface_shader.h index a15db1e82cf..f2b5ac293c6 100644 --- a/intern/cycles/kernel/integrator/surface_shader.h +++ b/intern/cycles/kernel/integrator/surface_shader.h @@ -231,7 +231,8 @@ ccl_device_inline void surface_shader_validate_bsdf_sample(const KernelGlobals k } #endif -ccl_device_forceinline bool _surface_shader_exclude(ClosureType type, uint light_shader_flags) +ccl_device_forceinline bool _surface_shader_exclude(ClosureType type, + const uint light_shader_flags) { if (!(light_shader_flags & SHADER_EXCLUDE_ANY)) { return false; @@ -1072,7 +1073,7 @@ ccl_device float3 surface_shader_bssrdf_normal(const ccl_private ShaderData *sd) /* Constant emission optimization */ ccl_device bool surface_shader_constant_emission(KernelGlobals kg, - int shader, + const int shader, ccl_private Spectrum *eval) { const int shader_index = shader & SHADER_MASK; @@ -1155,7 +1156,7 @@ ccl_device void surface_shader_eval(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *ccl_restrict sd, ccl_global float *ccl_restrict buffer, - uint32_t path_flag, + const uint32_t path_flag, bool use_caustics_storage = false) { /* If path is being terminated, we are tracing a shadow ray or evaluating diff --git a/intern/cycles/kernel/integrator/volume_shader.h b/intern/cycles/kernel/integrator/volume_shader.h index a86e026e1c4..9bc93a660a6 100644 --- a/intern/cycles/kernel/integrator/volume_shader.h +++ b/intern/cycles/kernel/integrator/volume_shader.h @@ -336,7 +336,7 @@ ccl_device int volume_shader_phase_sample(KernelGlobals kg, const ccl_private ShaderData *sd, const ccl_private ShaderVolumePhases *phases, const ccl_private ShaderVolumeClosure *svc, - float2 rand_phase, + const float2 rand_phase, ccl_private BsdfEval *phase_eval, ccl_private float3 *wo, ccl_private float *pdf, @@ -425,7 +425,7 @@ ccl_device_inline void volume_shader_motion_blur(KernelGlobals kg, /* Volume Evaluation */ -template +template ccl_device_inline bool volume_shader_eval_entry(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *ccl_restrict sd, diff --git a/intern/cycles/kernel/light/area.h b/intern/cycles/kernel/light/area.h index febcde1725b..4a118f50cb2 100644 --- a/intern/cycles/kernel/light/area.h +++ b/intern/cycles/kernel/light/area.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN * Carlos Urena et al. * * NOTE: light_p is modified when sample_coord is true. */ -ccl_device_inline float area_light_rect_sample(float3 P, +ccl_device_inline float area_light_rect_sample(const float3 P, ccl_private float3 *light_p, const float3 axis_u, const float len_u, diff --git a/intern/cycles/kernel/light/background.h b/intern/cycles/kernel/light/background.h index a2b5c1380d2..e3bec5011bc 100644 --- a/intern/cycles/kernel/light/background.h +++ b/intern/cycles/kernel/light/background.h @@ -17,7 +17,9 @@ CCL_NAMESPACE_BEGIN /* Background Light */ -ccl_device float3 background_map_sample(KernelGlobals kg, float2 rand, ccl_private float *pdf) +ccl_device float3 background_map_sample(KernelGlobals kg, + const float2 rand, + ccl_private float *pdf) { /* for the following, the CDF values are actually a pair of floats, with the * function value as X and the actual CDF as Y. The last entry's function @@ -104,7 +106,7 @@ ccl_device float3 background_map_sample(KernelGlobals kg, float2 rand, ccl_priva /* TODO(sergey): Same as above, after the release we should consider using * 'noinline' for all devices. */ -ccl_device float background_map_pdf(KernelGlobals kg, float3 direction) +ccl_device float background_map_pdf(KernelGlobals kg, const float3 direction) { const float2 uv = direction_to_equirectangular(direction); const int res_x = kernel_data.background.map_res_x; @@ -139,8 +141,11 @@ ccl_device float background_map_pdf(KernelGlobals kg, float3 direction) return (cdf_u.x * cdf_v.x) / denom; } -ccl_device_inline bool background_portal_data_fetch_and_check_side( - KernelGlobals kg, float3 P, int index, ccl_private float3 *lightpos, ccl_private float3 *dir) +ccl_device_inline bool background_portal_data_fetch_and_check_side(KernelGlobals kg, + const float3 P, + const int index, + ccl_private float3 *lightpos, + ccl_private float3 *dir) { const int portal = kernel_data.integrator.portal_offset + index; const ccl_global KernelLight *klight = &kernel_data_fetch(lights, portal); @@ -156,8 +161,11 @@ ccl_device_inline bool background_portal_data_fetch_and_check_side( return false; } -ccl_device_inline float background_portal_pdf( - KernelGlobals kg, float3 P, float3 direction, int ignore_portal, ccl_private bool *is_possible) +ccl_device_inline float background_portal_pdf(KernelGlobals kg, + const float3 P, + float3 direction, + const int ignore_portal, + ccl_private bool *is_possible) { float portal_pdf = 0.0f; @@ -227,7 +235,7 @@ ccl_device_inline float background_portal_pdf( return (num_possible > 0) ? portal_pdf / num_possible : 0.0f; } -ccl_device int background_num_possible_portals(KernelGlobals kg, float3 P) +ccl_device int background_num_possible_portals(KernelGlobals kg, const float3 P) { int num_possible_portals = 0; for (int p = 0; p < kernel_data.integrator.num_portals; p++) { @@ -241,9 +249,9 @@ ccl_device int background_num_possible_portals(KernelGlobals kg, float3 P) } ccl_device float3 background_portal_sample(KernelGlobals kg, - float3 P, + const float3 P, float2 rand, - int num_possible, + const int num_possible, ccl_private int *sampled_portal, ccl_private float *pdf) { @@ -297,7 +305,7 @@ ccl_device float3 background_portal_sample(KernelGlobals kg, } ccl_device_inline float3 background_sun_sample(KernelGlobals kg, - float2 rand, + const float2 rand, ccl_private float *pdf) { const float3 N = make_float3(kernel_data.background.sun); @@ -306,7 +314,7 @@ ccl_device_inline float3 background_sun_sample(KernelGlobals kg, return sample_uniform_cone(N, one_minus_cos(angle), rand, &unused, pdf); } -ccl_device_inline float background_sun_pdf(KernelGlobals kg, float3 D) +ccl_device_inline float background_sun_pdf(KernelGlobals kg, const float3 D) { const float3 N = make_float3(kernel_data.background.sun); const float angle = kernel_data.background.sun.w; @@ -314,7 +322,7 @@ ccl_device_inline float background_sun_pdf(KernelGlobals kg, float3 D) } ccl_device_inline float3 background_light_sample(KernelGlobals kg, - float3 P, + const float3 P, float2 rand, ccl_private float *pdf) { @@ -416,7 +424,7 @@ ccl_device_inline float3 background_light_sample(KernelGlobals kg, return D; } -ccl_device float background_light_pdf(KernelGlobals kg, float3 P, float3 direction) +ccl_device float background_light_pdf(KernelGlobals kg, const float3 P, float3 direction) { float portal_method_pdf = kernel_data.background.portal_weight; float sun_method_pdf = kernel_data.background.sun_weight; diff --git a/intern/cycles/kernel/light/common.h b/intern/cycles/kernel/light/common.h index 2d24296a3b4..84d6623852a 100644 --- a/intern/cycles/kernel/light/common.h +++ b/intern/cycles/kernel/light/common.h @@ -32,18 +32,18 @@ struct LightSample { /* Utilities */ -ccl_device_inline float3 ellipse_sample(float3 ru, float3 rv, float2 rand) +ccl_device_inline float3 ellipse_sample(const float3 ru, const float3 rv, const float2 rand) { const float2 uv = sample_uniform_disk(rand); return ru * uv.x + rv * uv.y; } -ccl_device_inline float3 rectangle_sample(float3 ru, float3 rv, float2 rand) +ccl_device_inline float3 rectangle_sample(const float3 ru, const float3 rv, const float2 rand) { return ru * (2.0f * rand.x - 1.0f) + rv * (2.0f * rand.y - 1.0f); } -ccl_device float3 disk_light_sample(float3 n, float2 rand) +ccl_device float3 disk_light_sample(const float3 n, const float2 rand) { float3 ru; float3 rv; @@ -53,7 +53,7 @@ ccl_device float3 disk_light_sample(float3 n, float2 rand) return ellipse_sample(ru, rv, rand); } -ccl_device float light_pdf_area_to_solid_angle(const float3 Ng, const float3 I, float t) +ccl_device float light_pdf_area_to_solid_angle(const float3 Ng, const float3 I, const float t) { const float cos_pi = dot(Ng, I); diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index 215521c34cd..bc5653c7276 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -20,7 +20,9 @@ CCL_NAMESPACE_BEGIN /* Light info. */ -ccl_device_inline bool light_select_reached_max_bounces(KernelGlobals kg, int index, int bounce) +ccl_device_inline bool light_select_reached_max_bounces(KernelGlobals kg, + const int index, + const int bounce) { return (bounce > kernel_data_fetch(lights, index).max_bounces); } diff --git a/intern/cycles/kernel/light/sample.h b/intern/cycles/kernel/light/sample.h index bce0645319c..fe55b60bea2 100644 --- a/intern/cycles/kernel/light/sample.h +++ b/intern/cycles/kernel/light/sample.h @@ -25,7 +25,7 @@ light_sample_shader_eval(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *ccl_restrict emission_sd, ccl_private LightSample *ccl_restrict ls, - float time) + const float time) { /* setup shading at emitter */ Spectrum eval = zero_spectrum(); @@ -118,7 +118,7 @@ ccl_device_inline bool light_sample_terminate(KernelGlobals kg, * point. */ ccl_device_inline float3 shadow_ray_smooth_surface_offset( - KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, float3 Ng) + KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, const float3 Ng) { float3 V[3]; float3 N[3]; @@ -175,7 +175,7 @@ ccl_device_inline float3 shadow_ray_smooth_surface_offset( ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, - float3 L, + const float3 L, ccl_private bool *r_skip_self) { float3 P = sd->P; diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index c28c69a10fd..274438e1e38 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -385,7 +385,7 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg, const float3 N_or_D, const float t, const bool has_transmission, - int emitter_index, + const int emitter_index, ccl_private float &max_importance, ccl_private float &min_importance) { @@ -910,7 +910,7 @@ ccl_device float light_tree_pdf(KernelGlobals kg, * pdf from there. Otherwise compute from the current shading point. */ ccl_device_inline float light_tree_pdf(KernelGlobals kg, float3 P, - float3 N, + const float3 N, const float dt, const int path_flag, const int emitter_object, diff --git a/intern/cycles/kernel/light/triangle.h b/intern/cycles/kernel/light/triangle.h index 77fa7e799b0..f690882bd24 100644 --- a/intern/cycles/kernel/light/triangle.h +++ b/intern/cycles/kernel/light/triangle.h @@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN /* returns true if the triangle is has motion blur or an instancing transform applied */ ccl_device_inline bool triangle_world_space_vertices( - KernelGlobals kg, int object, int prim, float time, float3 V[3]) + KernelGlobals kg, const int object, const int prim, const float time, float3 V[3]) { bool has_motion = false; const int object_flag = kernel_data_fetch(object_flag, object); @@ -47,7 +47,9 @@ ccl_device_inline bool triangle_world_space_vertices( return has_motion; } -ccl_device_inline float triangle_light_pdf_area_sampling(const float3 Ng, const float3 I, float t) +ccl_device_inline float triangle_light_pdf_area_sampling(const float3 Ng, + const float3 I, + const float t) { const float cos_pi = fabsf(dot(Ng, I)); @@ -60,7 +62,7 @@ ccl_device_inline float triangle_light_pdf_area_sampling(const float3 Ng, const ccl_device_forceinline float triangle_light_pdf(KernelGlobals kg, const ccl_private ShaderData *sd, - float t) + const float t) { /* A naive heuristic to decide between costly solid angle sampling * and simple area sampling, comparing the distance to the triangle plane @@ -124,10 +126,10 @@ ccl_device_forceinline float triangle_light_pdf(KernelGlobals kg, template ccl_device_forceinline bool triangle_light_sample(KernelGlobals kg, - int prim, - int object, + const int prim, + const int object, const float2 rand, - float time, + const float time, ccl_private LightSample *ls, const float3 P) { diff --git a/intern/cycles/kernel/osl/closures.cpp b/intern/cycles/kernel/osl/closures.cpp index 191e94057e1..4463280d38a 100644 --- a/intern/cycles/kernel/osl/closures.cpp +++ b/intern/cycles/kernel/osl/closures.cpp @@ -79,7 +79,7 @@ template<> void osl_eval_nodes(const KernelGlobalsCPU *kg, const void *state, ShaderData *sd, - uint32_t path_flag) + const uint32_t path_flag) { /* setup shader globals from shader data */ OSLThreadData *tdata = kg->osl_tdata; @@ -209,7 +209,7 @@ template<> void osl_eval_nodes(const KernelGlobalsCPU *kg, const void *state, ShaderData *sd, - uint32_t path_flag) + const uint32_t path_flag) { /* setup shader globals from shader data */ OSLThreadData *tdata = kg->osl_tdata; @@ -262,7 +262,7 @@ template<> void osl_eval_nodes(const KernelGlobalsCPU *kg, const void *state, ShaderData *sd, - uint32_t path_flag) + const uint32_t path_flag) { /* setup shader globals from shader data */ OSLThreadData *tdata = kg->osl_tdata; diff --git a/intern/cycles/kernel/osl/closures_setup.h b/intern/cycles/kernel/osl/closures_setup.h index af21008877d..195a6b325af 100644 --- a/intern/cycles/kernel/osl/closures_setup.h +++ b/intern/cycles/kernel/osl/closures_setup.h @@ -50,8 +50,8 @@ ccl_device_forceinline void osl_zero_albedo(float3 *layer_albedo) ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, const ccl_private ShaderData *sd, - uint32_t path_flag, - int scattering) + const uint32_t path_flag, + const int scattering) { /* Caustic options */ if ((scattering & LABEL_GLOSSY) && (path_flag & PATH_RAY_DIFFUSE)) { @@ -81,8 +81,8 @@ ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, ccl_device void osl_closure_diffuse_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private DiffuseClosure *closure, float3 *layer_albedo) { @@ -104,8 +104,8 @@ ccl_device void osl_closure_diffuse_setup(KernelGlobals kg, /* Deprecated form, will be removed in OSL 2.0. */ ccl_device void osl_closure_oren_nayar_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private OrenNayarClosure *closure, float3 *layer_albedo) { @@ -128,8 +128,8 @@ ccl_device void osl_closure_oren_nayar_setup(KernelGlobals kg, ccl_device void osl_closure_oren_nayar_diffuse_bsdf_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private OrenNayarDiffuseBSDFClosure *closure, float3 *layer_albedo) { @@ -151,8 +151,8 @@ ccl_device void osl_closure_oren_nayar_diffuse_bsdf_setup( ccl_device void osl_closure_translucent_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private TranslucentClosure *closure, float3 *layer_albedo) { @@ -173,8 +173,8 @@ ccl_device void osl_closure_translucent_setup(KernelGlobals kg, ccl_device void osl_closure_reflection_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private ReflectionClosure *closure, float3 *layer_albedo) { @@ -196,8 +196,8 @@ ccl_device void osl_closure_reflection_setup(KernelGlobals kg, ccl_device void osl_closure_refraction_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private RefractionClosure *closure, float3 *layer_albedo) { @@ -220,8 +220,8 @@ ccl_device void osl_closure_refraction_setup(KernelGlobals kg, ccl_device void osl_closure_transparent_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private TransparentClosure *closure, float3 *layer_albedo) { @@ -230,8 +230,8 @@ ccl_device void osl_closure_transparent_setup(KernelGlobals kg, ccl_device void osl_closure_ray_portal_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private RayPortalBSDFClosure *closure, float3 *layer_albedo) { @@ -242,8 +242,8 @@ ccl_device void osl_closure_ray_portal_bsdf_setup(KernelGlobals kg, /* MaterialX closures */ ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private DielectricBSDFClosure *closure, float3 *layer_albedo) { @@ -321,8 +321,8 @@ ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg, ccl_device void osl_closure_conductor_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private ConductorBSDFClosure *closure, float3 *layer_albedo) { @@ -368,8 +368,8 @@ ccl_device void osl_closure_conductor_bsdf_setup(KernelGlobals kg, ccl_device void osl_closure_generalized_schlick_bsdf_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private GeneralizedSchlickBSDFClosure *closure, float3 *layer_albedo) { @@ -474,8 +474,8 @@ ccl_device void osl_closure_generalized_schlick_bsdf_setup( ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private MicrofacetClosure *closure, float3 *layer_albedo) { @@ -547,8 +547,8 @@ ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, ccl_device void osl_closure_microfacet_f82_tint_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private MicrofacetF82TintClosure *closure, float3 *layer_albedo) { @@ -594,8 +594,8 @@ ccl_device void osl_closure_microfacet_f82_tint_setup( ccl_device void osl_closure_microfacet_multi_ggx_glass_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private MicrofacetMultiGGXGlassClosure *closure, float3 *layer_albedo) { @@ -626,8 +626,8 @@ ccl_device void osl_closure_microfacet_multi_ggx_glass_setup( ccl_device void osl_closure_microfacet_multi_ggx_aniso_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private MicrofacetMultiGGXClosure *closure, float3 *layer_albedo) { @@ -663,8 +663,8 @@ ccl_device void osl_closure_microfacet_multi_ggx_aniso_setup( ccl_device void osl_closure_ashikhmin_velvet_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private AshikhminVelvetClosure *closure, float3 *layer_albedo) { @@ -688,8 +688,8 @@ ccl_device void osl_closure_ashikhmin_velvet_setup( ccl_device void osl_closure_sheen_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private SheenClosure *closure, float3 *layer_albedo) { @@ -721,8 +721,8 @@ ccl_device void osl_closure_sheen_setup(KernelGlobals kg, ccl_device void osl_closure_diffuse_toon_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private DiffuseToonClosure *closure, float3 *layer_albedo) { @@ -745,8 +745,8 @@ ccl_device void osl_closure_diffuse_toon_setup(KernelGlobals kg, ccl_device void osl_closure_glossy_toon_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private GlossyToonClosure *closure, float3 *layer_albedo) { @@ -794,7 +794,7 @@ ccl_device void osl_closure_emission_setup(KernelGlobals kg, ccl_device void osl_closure_background_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t /*path_flag*/, - float3 weight, + const float3 weight, const ccl_private GenericBackgroundClosure *closure, float3 *layer_albedo) { @@ -809,7 +809,7 @@ ccl_device void osl_closure_background_setup(KernelGlobals kg, ccl_device void osl_closure_holdout_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t /*path_flag*/, - float3 weight, + const float3 weight, const ccl_private HoldoutClosure *closure, float3 *layer_albedo) { @@ -820,7 +820,7 @@ ccl_device void osl_closure_holdout_setup(KernelGlobals kg, ccl_device void osl_closure_diffuse_ramp_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t /*path_flag*/, - float3 weight, + const float3 weight, const ccl_private DiffuseRampClosure *closure, float3 *layer_albedo) { @@ -848,7 +848,7 @@ ccl_device void osl_closure_diffuse_ramp_setup(KernelGlobals kg, ccl_device void osl_closure_phong_ramp_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t /*path_flag*/, - float3 weight, + const float3 weight, const ccl_private PhongRampClosure *closure, float3 *layer_albedo) { @@ -875,8 +875,8 @@ ccl_device void osl_closure_phong_ramp_setup(KernelGlobals kg, ccl_device void osl_closure_bssrdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private BSSRDFClosure *closure, float3 *layer_albedo) { @@ -916,8 +916,8 @@ ccl_device void osl_closure_bssrdf_setup(KernelGlobals kg, ccl_device void osl_closure_hair_reflection_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private HairReflectionClosure *closure, float3 *layer_albedo) { @@ -943,8 +943,8 @@ ccl_device void osl_closure_hair_reflection_setup(KernelGlobals kg, ccl_device void osl_closure_hair_transmission_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private HairTransmissionClosure *closure, float3 *layer_albedo) { @@ -969,8 +969,8 @@ ccl_device void osl_closure_hair_transmission_setup( ccl_device void osl_closure_hair_chiang_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private ChiangHairClosure *closure, float3 *layer_albedo) { @@ -999,8 +999,8 @@ ccl_device void osl_closure_hair_chiang_setup(KernelGlobals kg, ccl_device void osl_closure_hair_huang_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private HuangHairClosure *closure, float3 *layer_albedo) { @@ -1060,7 +1060,7 @@ ccl_device void osl_closure_hair_huang_setup(KernelGlobals kg, ccl_device void osl_closure_absorption_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, float3 weight, const ccl_private VolumeAbsorptionClosure *closure, float3 *layer_albedo) @@ -1071,7 +1071,7 @@ ccl_device void osl_closure_absorption_setup(KernelGlobals kg, ccl_device void osl_closure_henyey_greenstein_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, float3 weight, const ccl_private VolumeHenyeyGreensteinClosure *closure, float3 *layer_albedo) @@ -1093,8 +1093,8 @@ ccl_device void osl_closure_henyey_greenstein_setup( ccl_device void osl_closure_fournier_forand_setup( KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private VolumeFournierForandClosure *closure, float3 *layer_albedo) { @@ -1111,8 +1111,8 @@ ccl_device void osl_closure_fournier_forand_setup( ccl_device void osl_closure_draine_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private VolumeDraineClosure *closure, float3 *layer_albedo) { @@ -1132,8 +1132,8 @@ ccl_device void osl_closure_draine_setup(KernelGlobals kg, ccl_device void osl_closure_rayleigh_setup(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, - float3 weight, + const uint32_t path_flag, + const float3 weight, const ccl_private VolumeRayleighClosure *closure, float3 *layer_albedo) { diff --git a/intern/cycles/kernel/osl/osl.h b/intern/cycles/kernel/osl/osl.h index e6739ba9b25..7f634f1b660 100644 --- a/intern/cycles/kernel/osl/osl.h +++ b/intern/cycles/kernel/osl/osl.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN ccl_device_inline void shaderdata_to_shaderglobals(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, ccl_private ShaderGlobals *globals) { const differential3 dP = differential_from_compact(sd->Ng, sd->dP); @@ -69,7 +69,7 @@ ccl_device_inline void shaderdata_to_shaderglobals(KernelGlobals kg, ccl_device void flatten_closure_tree(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, const ccl_private OSLClosure *closure) { int stack_size = 0; @@ -183,7 +183,7 @@ template ccl_device_inline void osl_eval_nodes(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *sd, - uint32_t path_flag) + const uint32_t path_flag) { ShaderGlobals globals; shaderdata_to_shaderglobals(kg, sd, path_flag, &globals); diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index d607f1f6b22..e733178aba0 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -116,7 +116,7 @@ ustring OSLRenderServices::u_empty; ImageManager *OSLRenderServices::image_manager = nullptr; -OSLRenderServices::OSLRenderServices(OSL::TextureSystem *texture_system, int device_type) +OSLRenderServices::OSLRenderServices(OSL::TextureSystem *texture_system, const int device_type) : OSL::RendererServices(texture_system), device_type_(device_type) { } @@ -142,7 +142,7 @@ int OSLRenderServices::supports(string_view feature) const bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, - float time) + const float time) { /* this is only used for shader and object space, we don't really have * a concept of shader space, so we just use object space for both. */ @@ -182,7 +182,7 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, - float time) + const float time) { /* this is only used for shader and object space, we don't really have * a concept of shader space, so we just use object space for both. */ @@ -222,7 +222,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSLUStringHash from, - float time) + const float time) { ShaderData *sd = (ShaderData *)(sg->renderstate); const KernelGlobalsCPU *kg = sd->osl_globals; @@ -254,7 +254,7 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSLUStringHash to, - float time) + const float time) { ShaderData *sd = (ShaderData *)(sg->renderstate); const KernelGlobalsCPU *kg = sd->osl_globals; @@ -396,15 +396,15 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object, - TypeDesc type, + const TypeDesc type, OSLUStringHash name, - int index, + const int index, void *val) { return false; } -static bool set_attribute_float2(float2 f[3], TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float2(const float2 f[3], TypeDesc type, bool derivatives, void *val) { if (type == TypeFloatArray4) { float *fval = (float *)val; @@ -460,7 +460,7 @@ static bool set_attribute_float2(float2 f[3], TypeDesc type, bool derivatives, v return false; } -static bool set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float3(const float3 f[3], TypeDesc type, bool derivatives, void *val) { if (type == TypeFloatArray4) { float *fval = (float *)val; @@ -516,7 +516,7 @@ static bool set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, v return false; } -static bool set_attribute_float3(float3 f, TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float3(const float3 f, const TypeDesc type, bool derivatives, void *val) { float3 fv[3]; @@ -535,7 +535,7 @@ static bool set_attribute_float3(float3 f, TypeDesc type, bool derivatives, void * this for the correct operation of the Attribute node. */ -static bool set_attribute_float4(float4 f[3], TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float4(const float4 f[3], TypeDesc type, bool derivatives, void *val) { float *fval = (float *)val; if (type == TypeFloatArray4) { @@ -640,7 +640,7 @@ static bool set_attribute_float(const float f[3], TypeDesc type, bool derivative return false; } -static bool set_attribute_float(float f, TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float(const float f, const TypeDesc type, bool derivatives, void *val) { float fv[3]; @@ -651,7 +651,7 @@ static bool set_attribute_float(float f, TypeDesc type, bool derivatives, void * return set_attribute_float(fv, type, derivatives, val); } -static bool set_attribute_int(int i, TypeDesc type, bool derivatives, void *val) +static bool set_attribute_int(const int i, const TypeDesc type, bool derivatives, void *val) { if (type.basetype == TypeDesc::INT && type.aggregate == TypeDesc::SCALAR && type.arraylen == 0) { int *ival = (int *)val; @@ -668,7 +668,7 @@ static bool set_attribute_int(int i, TypeDesc type, bool derivatives, void *val) return false; } -static bool set_attribute_string(ustring str, TypeDesc type, bool derivatives, void *val) +static bool set_attribute_string(ustring str, const TypeDesc type, bool derivatives, void *val) { if (type.basetype == TypeDesc::STRING && type.aggregate == TypeDesc::SCALAR && type.arraylen == 0) @@ -687,7 +687,7 @@ static bool set_attribute_string(ustring str, TypeDesc type, bool derivatives, v return false; } -static bool set_attribute_float3_3(float3 P[3], TypeDesc type, bool derivatives, void *val) +static bool set_attribute_float3_3(const float3 P[3], TypeDesc type, bool derivatives, void *val) { if (type.vecsemantics == TypeDesc::POINT && type.arraylen >= 3) { float *fval = (float *)val; @@ -717,7 +717,7 @@ static bool set_attribute_float3_3(float3 P[3], TypeDesc type, bool derivatives, return false; } -static bool set_attribute_matrix(const Transform &tfm, TypeDesc type, void *val) +static bool set_attribute_matrix(const Transform &tfm, const TypeDesc type, void *val) { if (type == TypeMatrix) { copy_matrix(*(OSL::Matrix44 *)val, tfm); @@ -806,7 +806,7 @@ static bool get_object_attribute(const KernelGlobalsCPU *kg, bool OSLRenderServices::get_object_standard_attribute(const KernelGlobalsCPU *kg, ShaderData *sd, OSLUStringHash name, - TypeDesc type, + const TypeDesc type, bool derivatives, void *val) { @@ -982,7 +982,7 @@ bool OSLRenderServices::get_object_standard_attribute(const KernelGlobalsCPU *kg bool OSLRenderServices::get_background_attribute(const KernelGlobalsCPU *kg, ShaderData *sd, OSLUStringHash name, - TypeDesc type, + const TypeDesc type, bool derivatives, void *val) { @@ -1071,7 +1071,7 @@ bool OSLRenderServices::get_background_attribute(const KernelGlobalsCPU *kg, bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object_name, - TypeDesc type, + const TypeDesc type, OSLUStringHash name, void *val) { @@ -1086,7 +1086,7 @@ bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg, bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, OSLUStringHash object_name, - TypeDesc type, + const TypeDesc type, OSLUStringHash name, void *val) { @@ -1119,7 +1119,7 @@ bool OSLRenderServices::get_attribute(ShaderData *sd, } bool OSLRenderServices::get_userdata( - bool derivatives, OSLUStringHash name, TypeDesc type, OSL::ShaderGlobals *sg, void *val) + bool derivatives, OSLUStringHash name, const TypeDesc type, OSL::ShaderGlobals *sg, void *val) { return false; /* disabled by lockgeom */ } @@ -1233,11 +1233,11 @@ bool OSLRenderServices::texture(OSLUStringHash filename, OSL::ShaderGlobals *sg, float s, float t, - float dsdx, - float dtdx, - float dsdy, - float dtdy, - int nchannels, + const float dsdx, + const float dtdx, + const float dsdy, + const float dtdy, + const int nchannels, float *result, float *dresultds, float *dresultdt, @@ -1420,7 +1420,7 @@ bool OSLRenderServices::texture3d(OSLUStringHash filename, const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy, const OSL::Vec3 &dPdz, - int nchannels, + const int nchannels, float *result, float *dresultds, float *dresultdt, @@ -1533,7 +1533,7 @@ bool OSLRenderServices::environment(OSLUStringHash filename, const OSL::Vec3 &R, const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, - int nchannels, + const int nchannels, float *result, float *dresultds, float *dresultdt, @@ -1590,9 +1590,9 @@ bool OSLRenderServices::get_texture_info(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::ShaderGlobals * /*sg*/, - int subimage, + const int subimage, OSLUStringHash dataname, - TypeDesc datatype, + const TypeDesc datatype, void *data, OSLUStringHash * /*errormessage*/) #elif OSL_LIBRARY_VERSION_CODE >= 11100 @@ -1600,18 +1600,18 @@ bool OSLRenderServices::get_texture_info(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::ShadingContext *, - int subimage, + const int subimage, OSLUStringHash dataname, - TypeDesc datatype, + const TypeDesc datatype, void *data, OSLUStringHash *) #else bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *, OSLUStringHash filename, TextureHandle *texture_handle, - int subimage, + const int subimage, OSLUStringHash dataname, - TypeDesc datatype, + const TypeDesc datatype, void *data) #endif { @@ -1638,12 +1638,12 @@ bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *, int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 ¢er, - float radius, - int max_points, + const float radius, + const int max_points, bool sort, size_t *out_indices, float *out_distances, - int derivs_offset) + const int derivs_offset) { return 0; } @@ -1651,9 +1651,9 @@ int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals *sg, int OSLRenderServices::pointcloud_get(OSL::ShaderGlobals *sg, OSLUStringHash filename, size_t *indices, - int count, + const int count, OSLUStringHash attr_name, - TypeDesc attr_type, + const TypeDesc attr_type, void *out_data) { return 0; @@ -1662,7 +1662,7 @@ int OSLRenderServices::pointcloud_get(OSL::ShaderGlobals *sg, bool OSLRenderServices::pointcloud_write(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 &pos, - int nattribs, + const int nattribs, const OSLUStringRep *names, const TypeDesc *types, const void **data) @@ -1742,7 +1742,7 @@ bool OSLRenderServices::trace(TraceOpt &options, bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, OSLUStringHash source, OSLUStringHash name, - TypeDesc type, + const TypeDesc type, void *val, bool derivatives) { diff --git a/intern/cycles/kernel/osl/services.h b/intern/cycles/kernel/osl/services.h index 25cf98c07e6..0b063d894d0 100644 --- a/intern/cycles/kernel/osl/services.h +++ b/intern/cycles/kernel/osl/services.h @@ -52,7 +52,7 @@ struct OSLTextureHandle : public OIIO::RefCnt { OSLTextureHandle(Type type, const vector &svm_slots) : type(type), svm_slots(svm_slots) {} - OSLTextureHandle(Type type = OIIO, int svm_slot = -1) + OSLTextureHandle(Type type = OIIO, const int svm_slot = -1) : OSLTextureHandle(type, {make_int4(0, svm_slot, -1, -1)}) { } @@ -78,7 +78,7 @@ using OSLTextureHandleMap = OIIO::unordered_map_concurrent= 11100 @@ -261,31 +261,31 @@ class OSLRenderServices : public OSL::RendererServices { TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::ShadingContext *shading_context, - int subimage, + const int subimage, OSLUStringHash dataname, - TypeDesc datatype, + const TypeDesc datatype, void *data, OSLUStringHash *errormessage) override; #else bool get_texture_info(OSL::ShaderGlobals *sg, OSLUStringHash filename, TextureHandle *texture_handle, - int subimage, + const int subimage, OSLUStringHash dataname, - TypeDesc datatype, + const TypeDesc datatype, void *data) override; #endif static bool get_background_attribute(const KernelGlobalsCPU *kg, ShaderData *sd, OSLUStringHash name, - TypeDesc type, + const TypeDesc type, bool derivatives, void *val); static bool get_object_standard_attribute(const KernelGlobalsCPU *kg, ShaderData *sd, OSLUStringHash name, - TypeDesc type, + const TypeDesc type, bool derivatives, void *val); diff --git a/intern/cycles/kernel/osl/services_gpu.h b/intern/cycles/kernel/osl/services_gpu.h index efc60d2e253..b20a3e72e02 100644 --- a/intern/cycles/kernel/osl/services_gpu.h +++ b/intern/cycles/kernel/osl/services_gpu.h @@ -172,7 +172,7 @@ ccl_device_extern ccl_private OSLClosure *osl_mul_closure_color(ccl_private Shad ccl_device_extern ccl_private OSLClosure *osl_mul_closure_float(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, - float weight) + const float weight) { if (weight == 0.0f || !a) { return nullptr; @@ -229,7 +229,7 @@ ccl_device_extern ccl_private OSLClosure *osl_add_closure_closure(ccl_private Sh } ccl_device_extern ccl_private OSLClosure *osl_allocate_closure_component( - ccl_private ShaderGlobals *sg, int id, int size) + ccl_private ShaderGlobals *sg, const int id, const int size) { ccl_private ShaderData *const sd = static_cast(sg->renderstate); @@ -249,7 +249,7 @@ ccl_device_extern ccl_private OSLClosure *osl_allocate_closure_component( } ccl_device_extern ccl_private OSLClosure *osl_allocate_weighted_closure_component( - ccl_private ShaderGlobals *sg, int id, int size, const ccl_private float3 *weight) + ccl_private ShaderGlobals *sg, const int id, const int size, const ccl_private float3 *weight) { ccl_private ShaderData *const sd = static_cast(sg->renderstate); @@ -278,14 +278,14 @@ ccl_device_extern void osl_warning(ccl_private ShaderGlobals *sg, const char *fo { } -ccl_device_extern uint osl_range_check(int indexvalue, - int length, +ccl_device_extern uint osl_range_check(const int indexvalue, + const int length, DeviceString symname, ccl_private ShaderGlobals *sg, DeviceString sourcefile, - int sourceline, + const int sourceline, DeviceString groupname, - int layer, + const int layer, DeviceString layername, DeviceString shadername) { @@ -298,14 +298,14 @@ ccl_device_extern uint osl_range_check(int indexvalue, return result; } -ccl_device_extern uint osl_range_check_err(int indexvalue, - int length, +ccl_device_extern uint osl_range_check_err(const int indexvalue, + const int length, DeviceString symname, ccl_private ShaderGlobals *sg, DeviceString sourcefile, - int sourceline, + const int sourceline, DeviceString groupname, - int layer, + const int layer, DeviceString layername, DeviceString shadername) { @@ -325,7 +325,7 @@ ccl_device_extern uint osl_range_check_err(int indexvalue, ccl_device_extern void osl_blackbody_vf(ccl_private ShaderGlobals *sg, ccl_private float3 *result, - float temperature) + const float temperature) { float3 color_rgb = rec709_to_rgb(nullptr, svm_math_blackbody_color_rec709(temperature)); color_rgb = max(color_rgb, zero_float3()); @@ -334,7 +334,7 @@ ccl_device_extern void osl_blackbody_vf(ccl_private ShaderGlobals *sg, ccl_device_extern void osl_wavelength_color_vf(ccl_private ShaderGlobals *sg, ccl_private float3 *result, - float lambda_nm) + const float lambda_nm) { float3 color = xyz_to_rgb(nullptr, svm_math_wavelength_color_xyz(lambda_nm)); color *= 1.0f / 2.52f; // Empirical scale from lg to make all comps <= 1 @@ -381,7 +381,7 @@ ccl_device_extern bool osl_transformc(ccl_private ShaderGlobals *sg, ccl_private float3 *c_in, int c_in_derivs, ccl_private float3 *c_out, - int c_out_derivs, + const int c_out_derivs, DeviceString from, DeviceString to) { @@ -514,7 +514,9 @@ ccl_device_extern void osl_mul_mmm(ccl_private float *res, copy_matrix(res, tfm_a * tfm_b); } -ccl_device_extern void osl_mul_mmf(ccl_private float *res, const ccl_private float *a, float b) +ccl_device_extern void osl_mul_mmf(ccl_private float *res, + const ccl_private float *a, + const float b) { for (int i = 0; i < 16; ++i) { res[i] = a[i] * b; @@ -530,14 +532,18 @@ ccl_device_extern void osl_div_mmm(ccl_private float *res, copy_matrix(res, tfm_a * projection_inverse(tfm_b)); } -ccl_device_extern void osl_div_mmf(ccl_private float *res, const ccl_private float *a, float b) +ccl_device_extern void osl_div_mmf(ccl_private float *res, + const ccl_private float *a, + const float b) { for (int i = 0; i < 16; ++i) { res[i] = a[i] / b; } } -ccl_device_extern void osl_div_mfm(ccl_private float *res, float a, const ccl_private float *b) +ccl_device_extern void osl_div_mfm(ccl_private float *res, + const float a, + const ccl_private float *b) { const ProjectionTransform tfm_b = make_projection(b); copy_matrix(res, projection_inverse(tfm_b)); @@ -546,7 +552,7 @@ ccl_device_extern void osl_div_mfm(ccl_private float *res, float a, const ccl_pr } } -ccl_device_extern void osl_div_m_ff(ccl_private float *res, float a, float b) +ccl_device_extern void osl_div_m_ff(ccl_private float *res, const float a, float b) { float f = (b == 0) ? 0.0f : (a / b); copy_matrix(res, projection_identity()); @@ -725,10 +731,10 @@ ccl_device_extern bool osl_transform_triple(ccl_private ShaderGlobals *sg, ccl_private float3 *p_in, int p_in_derivs, ccl_private float3 *p_out, - int p_out_derivs, + const int p_out_derivs, DeviceString from, DeviceString to, - int vectype) + const int vectype) { if (!p_out_derivs) { p_in_derivs = false; @@ -793,12 +799,12 @@ ccl_device_extern bool osl_transform_triple(ccl_private ShaderGlobals *sg, ccl_device_extern bool osl_transform_triple_nonlinear(ccl_private ShaderGlobals *sg, ccl_private float3 *p_in, - int p_in_derivs, + const int p_in_derivs, ccl_private float3 *p_out, - int p_out_derivs, + const int p_out_derivs, DeviceString from, DeviceString to, - int vectype) + const int vectype) { return osl_transform_triple(sg, p_in, p_in_derivs, p_out, p_out_derivs, from, to, vectype); } @@ -819,7 +825,7 @@ ccl_device_extern float osl_determinant_fm(ccl_private const float *m) typedef long long TypeDesc; ccl_device_inline bool set_attribute_float(ccl_private float fval[3], - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -865,8 +871,8 @@ ccl_device_inline bool set_attribute_float(ccl_private float fval[3], return false; } -ccl_device_inline bool set_attribute_float(float f, - TypeDesc type, +ccl_device_inline bool set_attribute_float(const float f, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -879,7 +885,7 @@ ccl_device_inline bool set_attribute_float(float f, return set_attribute_float(fv, type, derivatives, val); } ccl_device_inline bool set_attribute_float2(ccl_private float2 fval[3], - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -926,7 +932,7 @@ ccl_device_inline bool set_attribute_float2(ccl_private float2 fval[3], return false; } ccl_device_inline bool set_attribute_float3(ccl_private float3 fval[3], - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -964,8 +970,8 @@ ccl_device_inline bool set_attribute_float3(ccl_private float3 fval[3], return false; } -ccl_device_inline bool set_attribute_float3(float3 f, - TypeDesc type, +ccl_device_inline bool set_attribute_float3(const float3 f, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -978,7 +984,7 @@ ccl_device_inline bool set_attribute_float3(float3 f, return set_attribute_float3(fv, type, derivatives, val); } ccl_device_inline bool set_attribute_float4(ccl_private float4 fval[3], - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -1017,7 +1023,7 @@ ccl_device_inline bool set_attribute_float4(ccl_private float4 fval[3], return false; } ccl_device_inline bool set_attribute_matrix(const ccl_private Transform &tfm, - TypeDesc type, + const TypeDesc type, ccl_private void *val) { const unsigned char type_basetype = type & 0xF; @@ -1034,7 +1040,7 @@ ccl_device_inline bool set_attribute_matrix(const ccl_private Transform &tfm, ccl_device_inline bool get_background_attribute(KernelGlobals kg, ccl_private ShaderData *sd, DeviceString name, - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -1050,7 +1056,7 @@ ccl_device_inline bool get_background_attribute(KernelGlobals kg, ccl_device_inline bool get_object_attribute(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -1109,7 +1115,7 @@ ccl_device_inline bool get_object_attribute(KernelGlobals kg, ccl_device_inline bool get_object_standard_attribute(KernelGlobals kg, ccl_private ShaderData *sd, DeviceString name, - TypeDesc type, + const TypeDesc type, bool derivatives, ccl_private void *val) { @@ -1273,12 +1279,12 @@ ccl_device_inline bool get_object_standard_attribute(KernelGlobals kg, } ccl_device_extern bool osl_get_attribute(ccl_private ShaderGlobals *sg, - int derivatives, + const int derivatives, DeviceString object_name, DeviceString name, - int array_lookup, - int index, - TypeDesc type, + const int array_lookup, + const int index, + const TypeDesc type, ccl_private void *res) { KernelGlobals kg = nullptr; @@ -1306,13 +1312,13 @@ ccl_device_extern bool osl_get_attribute(ccl_private ShaderGlobals *sg, ccl_device_extern bool osl_bind_interpolated_param(ccl_private ShaderGlobals *sg, DeviceString name, long long type, - int userdata_has_derivs, + const int userdata_has_derivs, ccl_private void *userdata_data, - int symbol_has_derivs, + const int symbol_has_derivs, ccl_private void *symbol_data, - int symbol_data_size, + const int symbol_data_size, ccl_private void *userdata_initialized, - int userdata_index) + const int userdata_index) { return false; } @@ -1320,17 +1326,17 @@ ccl_device_extern bool osl_bind_interpolated_param(ccl_private ShaderGlobals *sg /* Noise */ -ccl_device_extern uint osl_hash_ii(int x) +ccl_device_extern uint osl_hash_ii(const int x) { return hash_uint(x); } -ccl_device_extern uint osl_hash_if(float x) +ccl_device_extern uint osl_hash_if(const float x) { return hash_uint(__float_as_uint(x)); } -ccl_device_extern uint osl_hash_iff(float x, float y) +ccl_device_extern uint osl_hash_iff(const float x, const float y) { return hash_uint2(__float_as_uint(x), __float_as_uint(y)); } @@ -1340,7 +1346,7 @@ ccl_device_extern uint osl_hash_iv(const ccl_private float3 *v) return hash_uint3(__float_as_uint(v->x), __float_as_uint(v->y), __float_as_uint(v->z)); } -ccl_device_extern uint osl_hash_ivf(const ccl_private float3 *v, float w) +ccl_device_extern uint osl_hash_ivf(const ccl_private float3 *v, const float w) { return hash_uint4( __float_as_uint(v->x), __float_as_uint(v->y), __float_as_uint(v->z), __float_as_uint(w)); @@ -1352,12 +1358,12 @@ ccl_device_extern OSLNoiseOptions *osl_get_noise_options(ccl_private ShaderGloba } ccl_device_extern void osl_noiseparams_set_anisotropic(ccl_private OSLNoiseOptions *opt, - int anisotropic) + const int anisotropic) { } ccl_device_extern void osl_noiseparams_set_do_filter(ccl_private OSLNoiseOptions *opt, - int do_filter) + const int do_filter) { } @@ -1367,21 +1373,21 @@ ccl_device_extern void osl_noiseparams_set_direction(ccl_private OSLNoiseOptions } ccl_device_extern void osl_noiseparams_set_bandwidth(ccl_private OSLNoiseOptions *opt, - float bandwidth) + const float bandwidth) { } ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions *opt, - float impulses) + const float impulses) { } #define OSL_NOISE_IMPL(name, op) \ - ccl_device_extern float name##_ff(float x) \ + ccl_device_extern float name##_ff(const float x) \ { \ return op##_1d(x); \ } \ - ccl_device_extern float name##_fff(float x, float y) \ + ccl_device_extern float name##_fff(const float x, const float y) \ { \ return op##_2d(make_float2(x, y)); \ } \ @@ -1389,11 +1395,11 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions { \ return op##_3d(*v); \ } \ - ccl_device_extern float name##_fvf(ccl_private const float3 *v, float w) \ + ccl_device_extern float name##_fvf(ccl_private const float3 *v, const float w) \ { \ return op##_4d(make_float4(v->x, v->y, v->z, w)); \ } \ - ccl_device_extern void name##_vf(ccl_private float3 *res, float x) \ + ccl_device_extern void name##_vf(ccl_private float3 *res, const float x) \ { \ /* TODO: This is not correct. Really need to change the hash function inside the noise \ * function to spit out a vector instead of a scalar. */ \ @@ -1402,7 +1408,7 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions res->y = n; \ res->z = n; \ } \ - ccl_device_extern void name##_vff(ccl_private float3 *res, float x, float y) \ + ccl_device_extern void name##_vff(ccl_private float3 *res, const float x, float y) \ { \ const float n = name##_fff(x, y); \ res->x = n; \ @@ -1417,7 +1423,7 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions res->z = n; \ } \ ccl_device_extern void name##_vvf( \ - ccl_private float3 *res, ccl_private const float3 *v, float w) \ + ccl_private float3 *res, ccl_private const float3 *v, const float w) \ { \ const float n = name##_fvf(v, w); \ res->x = n; \ @@ -1431,14 +1437,14 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions res[2] = name##_ff(x[2]); \ } \ ccl_device_extern void name##_dfdff( \ - ccl_private float *res, ccl_private const float *x, float y) \ + ccl_private float *res, ccl_private const float *x, const float y) \ { \ res[0] = name##_fff(x[0], y); \ res[1] = name##_fff(x[1], y); \ res[2] = name##_fff(x[2], y); \ } \ ccl_device_extern void name##_dffdf( \ - ccl_private float *res, float x, ccl_private const float *y) \ + ccl_private float *res, const float x, ccl_private const float *y) \ { \ res[0] = name##_fff(x, y[0]); \ res[1] = name##_fff(x, y[1]); \ @@ -1458,7 +1464,7 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions res[2] = name##_fv(&v[2]); \ } \ ccl_device_extern void name##_dfdvf( \ - ccl_private float *res, ccl_private const float3 *v, float w) \ + ccl_private float *res, ccl_private const float3 *v, const float w) \ { \ res[0] = name##_fvf(&v[0], w); \ res[1] = name##_fvf(&v[1], w); \ @@ -1485,14 +1491,14 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions name##_vf(&res[2], x[2]); \ } \ ccl_device_extern void name##_dvdff( \ - ccl_private float3 *res, ccl_private const float *x, float y) \ + ccl_private float3 *res, ccl_private const float *x, const float y) \ { \ name##_vff(&res[0], x[0], y); \ name##_vff(&res[1], x[1], y); \ name##_vff(&res[2], x[2], y); \ } \ ccl_device_extern void name##_dvfdf( \ - ccl_private float3 *res, float x, ccl_private const float *y) \ + ccl_private float3 *res, const float x, ccl_private const float *y) \ { \ name##_vff(&res[0], x, y[0]); \ name##_vff(&res[1], x, y[1]); \ @@ -1512,7 +1518,7 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions name##_vv(&res[2], &v[2]); \ } \ ccl_device_extern void name##_dvdvf( \ - ccl_private float3 *res, ccl_private const float3 *v, float w) \ + ccl_private float3 *res, ccl_private const float3 *v, const float w) \ { \ name##_vvf(&res[0], &v[0], w); \ name##_vvf(&res[1], &v[1], w); \ @@ -1533,25 +1539,25 @@ ccl_device_extern void osl_noiseparams_set_impulses(ccl_private OSLNoiseOptions name##_vvf(&res[2], &v[2], w[2]); \ } -ccl_device_forceinline float hashnoise_1d(float p) +ccl_device_forceinline float hashnoise_1d(const float p) { const uint x = __float_as_uint(p); return hash_uint(x) / static_cast(~0u); } -ccl_device_forceinline float hashnoise_2d(float2 p) +ccl_device_forceinline float hashnoise_2d(const float2 p) { const uint x = __float_as_uint(p.x); const uint y = __float_as_uint(p.y); return hash_uint2(x, y) / static_cast(~0u); } -ccl_device_forceinline float hashnoise_3d(float3 p) +ccl_device_forceinline float hashnoise_3d(const float3 p) { const uint x = __float_as_uint(p.x); const uint y = __float_as_uint(p.y); const uint z = __float_as_uint(p.z); return hash_uint3(x, y, z) / static_cast(~0u); } -ccl_device_forceinline float hashnoise_4d(float4 p) +ccl_device_forceinline float hashnoise_4d(const float4 p) { const uint x = __float_as_uint(p.x); const uint y = __float_as_uint(p.y); @@ -1574,41 +1580,81 @@ ccl_device_extern ccl_private OSLTextureOptions *osl_get_texture_options( } ccl_device_extern void osl_texture_set_firstchannel(ccl_private OSLTextureOptions *opt, - int firstchannel) + const int firstchannel) { } -ccl_device_extern void osl_texture_set_swrap_code(ccl_private OSLTextureOptions *opt, int mode) {} +ccl_device_extern void osl_texture_set_swrap_code(ccl_private OSLTextureOptions *opt, + const int mode) +{ +} -ccl_device_extern void osl_texture_set_twrap_code(ccl_private OSLTextureOptions *opt, int mode) {} +ccl_device_extern void osl_texture_set_twrap_code(ccl_private OSLTextureOptions *opt, + const int mode) +{ +} -ccl_device_extern void osl_texture_set_rwrap_code(ccl_private OSLTextureOptions *opt, int mode) {} +ccl_device_extern void osl_texture_set_rwrap_code(ccl_private OSLTextureOptions *opt, + const int mode) +{ +} -ccl_device_extern void osl_texture_set_stwrap_code(ccl_private OSLTextureOptions *opt, int mode) {} +ccl_device_extern void osl_texture_set_stwrap_code(ccl_private OSLTextureOptions *opt, + const int mode) +{ +} -ccl_device_extern void osl_texture_set_sblur(ccl_private OSLTextureOptions *opt, float blur) {} +ccl_device_extern void osl_texture_set_sblur(ccl_private OSLTextureOptions *opt, const float blur) +{ +} -ccl_device_extern void osl_texture_set_tblur(ccl_private OSLTextureOptions *opt, float blur) {} +ccl_device_extern void osl_texture_set_tblur(ccl_private OSLTextureOptions *opt, const float blur) +{ +} -ccl_device_extern void osl_texture_set_rblur(ccl_private OSLTextureOptions *opt, float blur) {} +ccl_device_extern void osl_texture_set_rblur(ccl_private OSLTextureOptions *opt, const float blur) +{ +} -ccl_device_extern void osl_texture_set_stblur(ccl_private OSLTextureOptions *opt, float blur) {} +ccl_device_extern void osl_texture_set_stblur(ccl_private OSLTextureOptions *opt, const float blur) +{ +} -ccl_device_extern void osl_texture_set_swidth(ccl_private OSLTextureOptions *opt, float width) {} +ccl_device_extern void osl_texture_set_swidth(ccl_private OSLTextureOptions *opt, + const float width) +{ +} -ccl_device_extern void osl_texture_set_twidth(ccl_private OSLTextureOptions *opt, float width) {} +ccl_device_extern void osl_texture_set_twidth(ccl_private OSLTextureOptions *opt, + const float width) +{ +} -ccl_device_extern void osl_texture_set_rwidth(ccl_private OSLTextureOptions *opt, float width) {} +ccl_device_extern void osl_texture_set_rwidth(ccl_private OSLTextureOptions *opt, + const float width) +{ +} -ccl_device_extern void osl_texture_set_stwidth(ccl_private OSLTextureOptions *opt, float width) {} +ccl_device_extern void osl_texture_set_stwidth(ccl_private OSLTextureOptions *opt, + const float width) +{ +} -ccl_device_extern void osl_texture_set_fill(ccl_private OSLTextureOptions *opt, float fill) {} +ccl_device_extern void osl_texture_set_fill(ccl_private OSLTextureOptions *opt, const float fill) +{ +} -ccl_device_extern void osl_texture_set_time(ccl_private OSLTextureOptions *opt, float time) {} +ccl_device_extern void osl_texture_set_time(ccl_private OSLTextureOptions *opt, const float time) +{ +} -ccl_device_extern void osl_texture_set_interp_code(ccl_private OSLTextureOptions *opt, int mode) {} +ccl_device_extern void osl_texture_set_interp_code(ccl_private OSLTextureOptions *opt, + const int mode) +{ +} -ccl_device_extern void osl_texture_set_subimage(ccl_private OSLTextureOptions *opt, int subimage) +ccl_device_extern void osl_texture_set_subimage(ccl_private OSLTextureOptions *opt, + const int subimage) { } @@ -1618,8 +1664,8 @@ ccl_device_extern void osl_texture_set_missingcolor_arena(ccl_private OSLTexture } ccl_device_extern void osl_texture_set_missingcolor_alpha(ccl_private OSLTextureOptions *opt, - int nchannels, - float alpha) + const int nchannels, + const float alpha) { } @@ -1627,13 +1673,13 @@ ccl_device_extern bool osl_texture(ccl_private ShaderGlobals *sg, DeviceString filename, ccl_private void *texture_handle, ccl_private OSLTextureOptions *opt, - float s, - float t, - float dsdx, - float dtdx, - float dsdy, - float dtdy, - int nchannels, + const float s, + const float t, + const float dsdx, + const float dtdx, + const float dsdy, + const float dtdy, + const int nchannels, ccl_private float *result, ccl_private float *dresultdx, ccl_private float *dresultdy, @@ -1682,7 +1728,7 @@ ccl_device_extern bool osl_texture3d(ccl_private ShaderGlobals *sg, const ccl_private float3 *dPdx, const ccl_private float3 *dPdy, const ccl_private float3 *dPdz, - int nchannels, + const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, @@ -1724,7 +1770,7 @@ ccl_device_extern bool osl_environment(ccl_private ShaderGlobals *sg, const ccl_private float3 *R, const ccl_private float3 *dRdx, const ccl_private float3 *dRdy, - int nchannels, + const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, @@ -1753,9 +1799,9 @@ ccl_device_extern bool osl_get_textureinfo(ccl_private ShaderGlobals *sg, DeviceString filename, ccl_private void *texture_handle, DeviceString dataname, - int basetype, - int arraylen, - int aggegrate, + const int basetype, + const int arraylen, + const int aggegrate, ccl_private void *data, ccl_private void *errormessage) { @@ -1765,12 +1811,12 @@ ccl_device_extern bool osl_get_textureinfo(ccl_private ShaderGlobals *sg, ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, DeviceString filename, ccl_private void *texture_handle, - float s, - float t, + const float s, + const float t, DeviceString dataname, - int basetype, - int arraylen, - int aggegrate, + const int basetype, + const int arraylen, + const int aggegrate, ccl_private void *data, ccl_private void *errormessage) { @@ -1781,17 +1827,17 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, /* Standard library */ #define OSL_OP_IMPL_II(name, op) \ - ccl_device_extern int name##_ii(int a) \ + ccl_device_extern int name##_ii(const int a) \ { \ return op(a); \ } #define OSL_OP_IMPL_IF(name, op) \ - ccl_device_extern int name##_if(float a) \ + ccl_device_extern int name##_if(const float a) \ { \ return op(a); \ } #define OSL_OP_IMPL_FF(name, op) \ - ccl_device_extern float name##_ff(float a) \ + ccl_device_extern float name##_ff(const float a) \ { \ return op(a); \ } @@ -1844,12 +1890,12 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_III(name, op) \ - ccl_device_extern int name##_iii(int a, int b) \ + ccl_device_extern int name##_iii(const int a, const int b) \ { \ return op(a, b); \ } #define OSL_OP_IMPL_FFF(name, op) \ - ccl_device_extern float name##_fff(float a, float b) \ + ccl_device_extern float name##_fff(const float a, const float b) \ { \ return op(a, b); \ } @@ -1860,7 +1906,7 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_DFFDF(name, op) \ ccl_device_extern void name##_dffdf( \ - ccl_private float *res, float a, ccl_private const float *b) \ + ccl_private float *res, const float a, ccl_private const float *b) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a, b[i]); \ @@ -1868,7 +1914,7 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_DFDFF(name, op) \ ccl_device_extern void name##_dfdff( \ - ccl_private float *res, ccl_private const float *a, float b) \ + ccl_private float *res, ccl_private const float *a, const float b) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a[i], b); \ @@ -1908,7 +1954,7 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_VVF_(name, op) \ ccl_device_extern void name##_vvf( \ - ccl_private float3 *res, ccl_private const float3 *a, float b) \ + ccl_private float3 *res, ccl_private const float3 *a, const float b) \ { \ res->x = op(a->x, b); \ res->y = op(a->y, b); \ @@ -1940,7 +1986,7 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_DVDVF_(name, op) \ ccl_device_extern void name##_dvdvf( \ - ccl_private float3 *res, ccl_private const float3 *a, float b) \ + ccl_private float3 *res, ccl_private const float3 *a, const float b) \ { \ for (int i = 0; i < 3; ++i) { \ res[i].x = op(a[i].x, b); \ @@ -2014,13 +2060,13 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_FFFF(name, op) \ - ccl_device_extern float name##_ffff(float a, float b, float c) \ + ccl_device_extern float name##_ffff(const float a, const float b, float c) \ { \ return op(a, b, c); \ } #define OSL_OP_IMPL_DFFFDF(name, op) \ ccl_device_extern void name##_dfffdf( \ - ccl_private float *res, float a, float b, ccl_private const float *c) \ + ccl_private float *res, const float a, float b, ccl_private const float *c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a, b, c[i]); \ @@ -2028,15 +2074,17 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, } #define OSL_OP_IMPL_DFFDFF(name, op) \ ccl_device_extern void name##_dffdff( \ - ccl_private float *res, float a, ccl_private const float *b, float c) \ + ccl_private float *res, const float a, ccl_private const float *b, const float c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a, b[i], c); \ } \ } #define OSL_OP_IMPL_DFFDFDF(name, op) \ - ccl_device_extern void name##_dffdfdf( \ - ccl_private float *res, float a, ccl_private const float *b, ccl_private const float *c) \ + ccl_device_extern void name##_dffdfdf(ccl_private float *res, \ + const float a, \ + ccl_private const float *b, \ + ccl_private const float *c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a, b[i], c[i]); \ @@ -2045,23 +2093,27 @@ ccl_device_extern bool osl_get_textureinfo_st(ccl_private ShaderGlobals *sg, #define OSL_OP_IMPL_DFDFFF(name, op) \ ccl_device_extern void name##_dfdfff( \ - ccl_private float *res, ccl_private const float *a, float b, float c) \ + ccl_private float *res, ccl_private const float *a, const float b, float c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a[i], b, c); \ } \ } #define OSL_OP_IMPL_DFDFFDF(name, op) \ - ccl_device_extern void name##_dfdffdf( \ - ccl_private float *res, ccl_private const float *a, float b, ccl_private const float *c) \ + ccl_device_extern void name##_dfdffdf(ccl_private float *res, \ + ccl_private const float *a, \ + const float b, \ + ccl_private const float *c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a[i], b, c[i]); \ } \ } #define OSL_OP_IMPL_DFDFDFF(name, op) \ - ccl_device_extern void name##_dfdfdff( \ - ccl_private float *res, ccl_private const float *a, ccl_private const float *b, float c) \ + ccl_device_extern void name##_dfdfdff(ccl_private float *res, \ + ccl_private const float *a, \ + ccl_private const float *b, \ + const float c) \ { \ for (int i = 0; i < 3; ++i) { \ res[i] = op(a[i], b[i], c); \ @@ -2105,11 +2157,11 @@ OSL_OP_IMPL_XX(osl_cosh, coshf) OSL_OP_IMPL_XX(osl_sinh, sinhf) OSL_OP_IMPL_XX(osl_tanh, tanhf) -ccl_device_forceinline int safe_divide(int a, int b) +ccl_device_forceinline int safe_divide(const int a, const int b) { return (b != 0) ? a / b : 0; } -ccl_device_forceinline int safe_modulo(int a, int b) +ccl_device_forceinline int safe_modulo(const int a, const int b) { return (b != 0) ? a % b : 0; } @@ -2118,7 +2170,7 @@ OSL_OP_IMPL_III(osl_safe_div, safe_divide) OSL_OP_IMPL_FFF(osl_safe_div, safe_divide) OSL_OP_IMPL_III(osl_safe_mod, safe_modulo) -ccl_device_extern void osl_sincos_fff(float a, ccl_private float *b, ccl_private float *c) +ccl_device_extern void osl_sincos_fff(const float a, ccl_private float *b, ccl_private float *c) { sincos(a, b, c); } @@ -2216,7 +2268,7 @@ OSL_OP_IMPL_VV_(osl_round, roundf) OSL_OP_IMPL_FF(osl_trunc, truncf) OSL_OP_IMPL_VV_(osl_trunc, truncf) -ccl_device_forceinline float step_impl(float edge, float x) +ccl_device_forceinline float step_impl(const float edge, const float x) { return x < edge ? 0.0f : 1.0f; } @@ -2295,7 +2347,7 @@ ccl_device_extern void osl_filterwidth_vdv(ccl_private float *res, const ccl_pri } } -ccl_device_extern bool osl_raytype_bit(ccl_private ShaderGlobals *sg, int bit) +ccl_device_extern bool osl_raytype_bit(ccl_private ShaderGlobals *sg, const int bit) { return (sg->raytype & bit) != 0; } diff --git a/intern/cycles/kernel/osl/types.h b/intern/cycles/kernel/osl/types.h index f7724a4667f..d81833a5582 100644 --- a/intern/cycles/kernel/osl/types.h +++ b/intern/cycles/kernel/osl/types.h @@ -22,7 +22,7 @@ using DeviceString = ustring; using DeviceString = const char *; #endif -ccl_device_inline DeviceString make_string(const char *str, size_t hash) +ccl_device_inline DeviceString make_string(const char *str, const size_t hash) { #if defined(__KERNEL_GPU__) (void)str; diff --git a/intern/cycles/kernel/sample/lcg.h b/intern/cycles/kernel/sample/lcg.h index 08c0561e65f..39fde424835 100644 --- a/intern/cycles/kernel/sample/lcg.h +++ b/intern/cycles/kernel/sample/lcg.h @@ -26,7 +26,7 @@ template ccl_device float lcg_step_float(T rng) return (float)*rng * (1.0f / (float)0xFFFFFFFF); } -ccl_device uint lcg_init(uint seed) +ccl_device uint lcg_init(const uint seed) { uint rng = seed; lcg_step_uint(&rng); diff --git a/intern/cycles/kernel/sample/mapping.h b/intern/cycles/kernel/sample/mapping.h index 921561a996d..3b494bc059a 100644 --- a/intern/cycles/kernel/sample/mapping.h +++ b/intern/cycles/kernel/sample/mapping.h @@ -65,7 +65,7 @@ ccl_device void make_orthonormals_safe_tangent(const float3 N, /* sample direction with cosine weighted distributed in hemisphere */ ccl_device_inline void sample_cos_hemisphere(const float3 N, - float2 rand_in, + const float2 rand_in, ccl_private float3 *wo, ccl_private float *pdf) { @@ -104,7 +104,7 @@ ccl_device_inline void sample_uniform_hemisphere(const float3 N, *pdf = M_1_2PI_F; } -ccl_device_inline float pdf_uniform_cone(const float3 N, float3 D, float angle) +ccl_device_inline float pdf_uniform_cone(const float3 N, const float3 D, const float angle) { const float z = precise_angle(N, D); if (z < angle) { @@ -181,7 +181,7 @@ ccl_device float3 sample_uniform_sphere(const float2 rand) } /* sample point in unit polygon with given number of corners and rotation */ -ccl_device float2 regular_polygon_sample(float corners, float rotation, const float2 rand) +ccl_device float2 regular_polygon_sample(const float corners, float rotation, const float2 rand) { float u = rand.x; float v = rand.y; diff --git a/intern/cycles/kernel/sample/mis.h b/intern/cycles/kernel/sample/mis.h index e7dde1efda9..eb48036221f 100644 --- a/intern/cycles/kernel/sample/mis.h +++ b/intern/cycles/kernel/sample/mis.h @@ -13,27 +13,27 @@ CCL_NAMESPACE_BEGIN /* Multiple importance sampling utilities. */ -ccl_device float balance_heuristic(float a, float b) +ccl_device float balance_heuristic(const float a, const float b) { return (a) / (a + b); } -ccl_device float balance_heuristic_3(float a, float b, float c) +ccl_device float balance_heuristic_3(const float a, const float b, float c) { return (a) / (a + b + c); } -ccl_device float power_heuristic(float a, float b) +ccl_device float power_heuristic(const float a, const float b) { return (a * a) / (a * a + b * b); } -ccl_device float power_heuristic_3(float a, float b, float c) +ccl_device float power_heuristic_3(const float a, const float b, float c) { return (a * a) / (a * a + b * b + c * c); } -ccl_device float max_heuristic(float a, float b) +ccl_device float max_heuristic(const float a, const float b) { return (a > b) ? 1.0f : 0.0f; } diff --git a/intern/cycles/kernel/sample/pattern.h b/intern/cycles/kernel/sample/pattern.h index 70f329218eb..287a190adfa 100644 --- a/intern/cycles/kernel/sample/pattern.h +++ b/intern/cycles/kernel/sample/pattern.h @@ -31,7 +31,9 @@ CCL_NAMESPACE_BEGIN * x,y over x,z. */ -ccl_device_forceinline uint3 blue_noise_indexing(KernelGlobals kg, uint pixel_index, uint sample) +ccl_device_forceinline uint3 blue_noise_indexing(KernelGlobals kg, + uint pixel_index, + const uint sample) { if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) { /* One sequence per pixel, using the length mask optimization. */ @@ -62,9 +64,9 @@ ccl_device_forceinline uint3 blue_noise_indexing(KernelGlobals kg, uint pixel_in } ccl_device_forceinline float path_rng_1D(KernelGlobals kg, - uint rng_pixel, - uint sample, - int dimension) + const uint rng_pixel, + const uint sample, + const int dimension) { #ifdef __DEBUG_CORRELATION__ return (float)drand48(); @@ -79,9 +81,9 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals kg, } ccl_device_forceinline float2 path_rng_2D(KernelGlobals kg, - uint rng_pixel, - int sample, - int dimension) + const uint rng_pixel, + const int sample, + const int dimension) { #ifdef __DEBUG_CORRELATION__ return make_float2((float)drand48(), (float)drand48()); @@ -96,9 +98,9 @@ ccl_device_forceinline float2 path_rng_2D(KernelGlobals kg, } ccl_device_forceinline float3 path_rng_3D(KernelGlobals kg, - uint rng_pixel, - int sample, - int dimension) + const uint rng_pixel, + const int sample, + const int dimension) { #ifdef __DEBUG_CORRELATION__ return make_float3((float)drand48(), (float)drand48(), (float)drand48()); @@ -113,9 +115,9 @@ ccl_device_forceinline float3 path_rng_3D(KernelGlobals kg, } ccl_device_forceinline float4 path_rng_4D(KernelGlobals kg, - uint rng_pixel, - int sample, - int dimension) + const uint rng_pixel, + const int sample, + const int dimension) { #ifdef __DEBUG_CORRELATION__ return make_float4((float)drand48(), (float)drand48(), (float)drand48(), (float)drand48()); @@ -163,7 +165,7 @@ ccl_device_inline uint path_rng_pixel_init(KernelGlobals kg, * Splits samples into two different classes, A and B, which can be * compared for variance estimation. */ -ccl_device_inline bool sample_is_class_A(int pattern, int sample) +ccl_device_inline bool sample_is_class_A(const int pattern, const int sample) { #if 0 if (!(pattern == SAMPLING_PATTERN_TABULATED_SOBOL || pattern == SAMPLING_PATTERN_SOBOL_BURLEY)) { diff --git a/intern/cycles/kernel/sample/sobol_burley.h b/intern/cycles/kernel/sample/sobol_burley.h index 6ab60c57714..5d50d901d9c 100644 --- a/intern/cycles/kernel/sample/sobol_burley.h +++ b/intern/cycles/kernel/sample/sobol_burley.h @@ -99,7 +99,7 @@ ccl_device_forceinline float sobol_burley(uint rev_bit_index, ccl_device float sobol_burley_sample_1D(uint index, const uint dimension, uint seed, - uint shuffled_index_mask) + const uint shuffled_index_mask) { /* Include the dimension in the seed, so we get decorrelated * sequences for different dimensions via shuffling. */ @@ -126,7 +126,7 @@ ccl_device float sobol_burley_sample_1D(uint index, ccl_device float2 sobol_burley_sample_2D(uint index, const uint dimension_set, uint seed, - uint shuffled_index_mask) + const uint shuffled_index_mask) { /* Include the dimension set in the seed, so we get decorrelated * sequences for different dimension sets via shuffling. */ @@ -154,7 +154,7 @@ ccl_device float2 sobol_burley_sample_2D(uint index, ccl_device float3 sobol_burley_sample_3D(uint index, const uint dimension_set, uint seed, - uint shuffled_index_mask) + const uint shuffled_index_mask) { /* Include the dimension set in the seed, so we get decorrelated * sequences for different dimension sets via shuffling. */ @@ -183,7 +183,7 @@ ccl_device float3 sobol_burley_sample_3D(uint index, ccl_device float4 sobol_burley_sample_4D(uint index, const uint dimension_set, uint seed, - uint shuffled_index_mask) + const uint shuffled_index_mask) { /* Include the dimension set in the seed, so we get decorrelated * sequences for different dimension sets via shuffling. */ diff --git a/intern/cycles/kernel/sample/tabulated_sobol.h b/intern/cycles/kernel/sample/tabulated_sobol.h index d3597cfc029..1874d623d5a 100644 --- a/intern/cycles/kernel/sample/tabulated_sobol.h +++ b/intern/cycles/kernel/sample/tabulated_sobol.h @@ -13,8 +13,8 @@ CCL_NAMESPACE_BEGIN ccl_device uint tabulated_sobol_shuffled_sample_index(KernelGlobals kg, uint sample, - uint dimension, - uint seed) + const uint dimension, + const uint seed) { const uint sample_count = kernel_data.integrator.tabulated_sobol_sequence_size; @@ -34,7 +34,7 @@ ccl_device uint tabulated_sobol_shuffled_sample_index(KernelGlobals kg, } ccl_device float tabulated_sobol_sample_1D(KernelGlobals kg, - uint sample, + const uint sample, const uint rng_hash, const uint dimension) { @@ -62,7 +62,7 @@ ccl_device float tabulated_sobol_sample_1D(KernelGlobals kg, } ccl_device float2 tabulated_sobol_sample_2D(KernelGlobals kg, - uint sample, + const uint sample, const uint rng_hash, const uint dimension) { @@ -95,7 +95,7 @@ ccl_device float2 tabulated_sobol_sample_2D(KernelGlobals kg, } ccl_device float3 tabulated_sobol_sample_3D(KernelGlobals kg, - uint sample, + const uint sample, const uint rng_hash, const uint dimension) { @@ -133,7 +133,7 @@ ccl_device float3 tabulated_sobol_sample_3D(KernelGlobals kg, } ccl_device float4 tabulated_sobol_sample_4D(KernelGlobals kg, - uint sample, + const uint sample, const uint rng_hash, const uint dimension) { diff --git a/intern/cycles/kernel/sample/util.h b/intern/cycles/kernel/sample/util.h index 79e9b337ecf..c724538a788 100644 --- a/intern/cycles/kernel/sample/util.h +++ b/intern/cycles/kernel/sample/util.h @@ -15,7 +15,7 @@ CCL_NAMESPACE_BEGIN * This is equivalent to the Laine-Karras permutation, but much higher * quality. See https://psychopath.io/post/2021_01_30_building_a_better_lk_hash */ -ccl_device_inline uint reversed_bit_owen(uint n, uint seed) +ccl_device_inline uint reversed_bit_owen(uint n, const uint seed) { n ^= n * 0x3d20adea; n += seed; @@ -32,7 +32,7 @@ ccl_device_inline uint reversed_bit_owen(uint n, uint seed) * See https://psychopath.io/post/2022_08_14_a_fast_hash_for_base_4_owen_scrambling */ -ccl_device_inline uint reversed_bit_owen_base4(uint n, uint seed) +ccl_device_inline uint reversed_bit_owen_base4(uint n, const uint seed) { n ^= n * 0x3d20adea; n ^= (n >> 1) & (n << 1) & 0x55555555; @@ -48,7 +48,7 @@ ccl_device_inline uint reversed_bit_owen_base4(uint n, uint seed) /* * Performs base-2 Owen scrambling on an unsigned integer. */ -ccl_device_inline uint nested_uniform_scramble(uint i, uint seed) +ccl_device_inline uint nested_uniform_scramble(const uint i, const uint seed) { return reverse_integer_bits(reversed_bit_owen(reverse_integer_bits(i), seed)); } @@ -56,7 +56,7 @@ ccl_device_inline uint nested_uniform_scramble(uint i, uint seed) /* * Performs base-4 Owen scrambling on an unsigned integer. */ -ccl_device_inline uint nested_uniform_scramble_base4(uint i, uint seed) +ccl_device_inline uint nested_uniform_scramble_base4(const uint i, const uint seed) { return reverse_integer_bits(reversed_bit_owen_base4(reverse_integer_bits(i), seed)); } @@ -71,7 +71,7 @@ ccl_device_inline uint expand_bits(uint x) return x; } -ccl_device_inline uint morton2d(uint x, uint y) +ccl_device_inline uint morton2d(const uint x, const uint y) { return (expand_bits(x) << 1) | expand_bits(y); } diff --git a/intern/cycles/kernel/svm/ao.h b/intern/cycles/kernel/svm/ao.h index 7614326fb05..483ccb75916 100644 --- a/intern/cycles/kernel/svm/ao.h +++ b/intern/cycles/kernel/svm/ao.h @@ -28,8 +28,8 @@ ccl_device float svm_ao( ccl_private ShaderData *sd, float3 N, float max_dist, - int num_samples, - int flags) + const int num_samples, + const int flags) { if (flags & NODE_AO_GLOBAL_RADIUS) { max_dist = kernel_data.integrator.ao_bounces_distance; @@ -106,7 +106,7 @@ ccl_device_noinline ConstIntegratorGenericState state, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint flags; uint dist_offset; diff --git a/intern/cycles/kernel/svm/aov.h b/intern/cycles/kernel/svm/aov.h index 6b9f0ca1d45..788afcbdb9f 100644 --- a/intern/cycles/kernel/svm/aov.h +++ b/intern/cycles/kernel/svm/aov.h @@ -24,7 +24,7 @@ ccl_device void svm_node_aov_color(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node, + const uint4 node, ccl_global float *render_buffer) { IF_KERNEL_NODES_FEATURE(AOV) @@ -39,7 +39,7 @@ ccl_device void svm_node_aov_value(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node, + const uint4 node, ccl_global float *render_buffer) { IF_KERNEL_NODES_FEATURE(AOV) diff --git a/intern/cycles/kernel/svm/attribute.h b/intern/cycles/kernel/svm/attribute.h index 8a49b1c14b7..be4066e2d10 100644 --- a/intern/cycles/kernel/svm/attribute.h +++ b/intern/cycles/kernel/svm/attribute.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN ccl_device AttributeDescriptor svm_node_attr_init(KernelGlobals kg, ccl_private ShaderData *sd, - uint4 node, + const uint4 node, ccl_private NodeAttributeOutputType *type, ccl_private uint *out_offset) { @@ -52,7 +52,7 @@ template ccl_device_noinline void svm_node_attr(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; uint out_offset = 0; @@ -170,7 +170,7 @@ ccl_device_forceinline float3 svm_node_bump_P_dy(const ccl_private ShaderData *s ccl_device_noinline void svm_node_attr_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; uint out_offset = 0; @@ -268,7 +268,7 @@ ccl_device_noinline void svm_node_attr_bump_dx(KernelGlobals kg, ccl_device_noinline void svm_node_attr_bump_dy(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; uint out_offset = 0; diff --git a/intern/cycles/kernel/svm/bevel.h b/intern/cycles/kernel/svm/bevel.h index 7811d5aec4b..f82937cfa3a 100644 --- a/intern/cycles/kernel/svm/bevel.h +++ b/intern/cycles/kernel/svm/bevel.h @@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN * far as I can tell has no closed form solution. So we get an iterative solution * instead with newton-raphson. */ -ccl_device float svm_bevel_cubic_eval(const float radius, float r) +ccl_device float svm_bevel_cubic_eval(const float radius, const float r) { const float Rm = radius; @@ -41,13 +41,13 @@ ccl_device float svm_bevel_cubic_eval(const float radius, float r) return (10.0f * num) / (Rm5 * M_PI_F); } -ccl_device float svm_bevel_cubic_pdf(const float radius, float r) +ccl_device float svm_bevel_cubic_pdf(const float radius, const float r) { return svm_bevel_cubic_eval(radius, r); } /* solve 10x^2 - 20x^3 + 15x^4 - 4x^5 - xi == 0 */ -ccl_device_forceinline float svm_bevel_cubic_quintic_root_find(float xi) +ccl_device_forceinline float svm_bevel_cubic_quintic_root_find(const float xi) { /* newton-raphson iteration, usually succeeds in 2-4 iterations, except * outside 0.02 ... 0.98 where it can go up to 10, so overall performance @@ -76,7 +76,7 @@ ccl_device_forceinline float svm_bevel_cubic_quintic_root_find(float xi) } ccl_device void svm_bevel_cubic_sample(const float radius, - float xi, + const float xi, ccl_private float *r, ccl_private float *h) { @@ -104,8 +104,8 @@ ccl_device float3 svm_bevel( KernelGlobals kg, ConstIntegratorState state, ccl_private ShaderData *sd, - float radius, - int num_samples) + const float radius, + const int num_samples) { /* Early out if no sampling needed. */ if (radius <= 0.0f || num_samples < 1 || sd->object == OBJECT_NONE) { @@ -300,7 +300,7 @@ ccl_device_noinline ConstIntegratorGenericState state, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint num_samples; uint radius_offset; diff --git a/intern/cycles/kernel/svm/blackbody.h b/intern/cycles/kernel/svm/blackbody.h index d74e26dc293..445bcbb0fe4 100644 --- a/intern/cycles/kernel/svm/blackbody.h +++ b/intern/cycles/kernel/svm/blackbody.h @@ -21,8 +21,8 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_blackbody(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint temperature_offset, - uint col_offset) + const uint temperature_offset, + const uint col_offset) { /* Input */ const float temperature = stack_load_float(stack, temperature_offset); diff --git a/intern/cycles/kernel/svm/brick.h b/intern/cycles/kernel/svm/brick.h index d0c784c5c96..486c78ee511 100644 --- a/intern/cycles/kernel/svm/brick.h +++ b/intern/cycles/kernel/svm/brick.h @@ -19,16 +19,16 @@ ccl_device_inline float brick_noise(uint n) /* fast integer noise */ return 0.5f * ((float)nn / 1073741824.0f); } -ccl_device_noinline_cpu float2 svm_brick(float3 p, - float mortar_size, - float mortar_smooth, - float bias, +ccl_device_noinline_cpu float2 svm_brick(const float3 p, + const float mortar_size, + const float mortar_smooth, + const float bias, float brick_width, - float row_height, - float offset_amount, - int offset_frequency, - float squash_amount, - int squash_frequency) + const float row_height, + const float offset_amount, + const int offset_frequency, + const float squash_amount, + const int squash_frequency) { int bricknum; int rownum; @@ -66,8 +66,11 @@ ccl_device_noinline_cpu float2 svm_brick(float3 p, return make_float2(tint, mortar); } -ccl_device_noinline int svm_node_tex_brick( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_tex_brick(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { const uint4 node2 = read_node(kg, &offset); const uint4 node3 = read_node(kg, &offset); diff --git a/intern/cycles/kernel/svm/brightness.h b/intern/cycles/kernel/svm/brightness.h index fed0bd36b1d..024fd30ce9b 100644 --- a/intern/cycles/kernel/svm/brightness.h +++ b/intern/cycles/kernel/svm/brightness.h @@ -9,8 +9,11 @@ CCL_NAMESPACE_BEGIN -ccl_device_noinline void svm_node_brightness( - ccl_private ShaderData *sd, ccl_private float *stack, uint in_color, uint out_color, uint node) +ccl_device_noinline void svm_node_brightness(ccl_private ShaderData *sd, + ccl_private float *stack, + const uint in_color, + const uint out_color, + const uint node) { uint bright_offset; uint contrast_offset; diff --git a/intern/cycles/kernel/svm/bump.h b/intern/cycles/kernel/svm/bump.h index 81fbbcde2d3..77c45f7126a 100644 --- a/intern/cycles/kernel/svm/bump.h +++ b/intern/cycles/kernel/svm/bump.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_enter_bump_eval(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint offset) + const uint offset) { /* save state */ stack_store_float3(stack, offset + 0, sd->P); @@ -50,7 +50,7 @@ ccl_device_noinline void svm_node_enter_bump_eval(KernelGlobals kg, ccl_device_noinline void svm_node_leave_bump_eval(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint offset) + const uint offset) { /* restore state */ sd->P = stack_load_float3(stack, offset + 0); diff --git a/intern/cycles/kernel/svm/camera.h b/intern/cycles/kernel/svm/camera.h index be2c6bbc150..ffb8159c273 100644 --- a/intern/cycles/kernel/svm/camera.h +++ b/intern/cycles/kernel/svm/camera.h @@ -13,9 +13,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_camera(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint out_vector, - uint out_zdepth, - uint out_distance) + const uint out_vector, + const uint out_zdepth, + const uint out_distance) { float distance; float zdepth; diff --git a/intern/cycles/kernel/svm/checker.h b/intern/cycles/kernel/svm/checker.h index c9ae6ef25a4..e002d53abd1 100644 --- a/intern/cycles/kernel/svm/checker.h +++ b/intern/cycles/kernel/svm/checker.h @@ -27,7 +27,7 @@ ccl_device float svm_checker(float3 p) ccl_device_noinline void svm_node_tex_checker(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint co_offset; uint color1_offset; diff --git a/intern/cycles/kernel/svm/clamp.h b/intern/cycles/kernel/svm/clamp.h index 9113998e941..eadb2f256cf 100644 --- a/intern/cycles/kernel/svm/clamp.h +++ b/intern/cycles/kernel/svm/clamp.h @@ -13,9 +13,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_clamp(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint value_stack_offset, - uint parameters_stack_offsets, - uint result_stack_offset, + const uint value_stack_offset, + const uint parameters_stack_offsets, + const uint result_stack_offset, int offset) { uint min_stack_offset; diff --git a/intern/cycles/kernel/svm/closure.h b/intern/cycles/kernel/svm/closure.h index ea9ca0ea317..e331161fd55 100644 --- a/intern/cycles/kernel/svm/closure.h +++ b/intern/cycles/kernel/svm/closure.h @@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN /* Closure Nodes */ -ccl_device_inline int svm_node_closure_bsdf_skip(KernelGlobals kg, int offset, uint type) +ccl_device_inline int svm_node_closure_bsdf_skip(KernelGlobals kg, int offset, const uint type) { if (type == CLOSURE_BSDF_PRINCIPLED_ID) { /* Read all principled BSDF extra data to get the right offset. */ @@ -48,8 +48,8 @@ ccl_device ccl_private ShaderData *sd, ccl_private float *stack, Spectrum closure_weight, - uint4 node, - uint32_t path_flag, + const uint4 node, + const uint32_t path_flag, int offset) { uint type; @@ -1055,7 +1055,7 @@ ccl_device_noinline void svm_node_closure_volume(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, Spectrum closure_weight, - uint4 node) + const uint4 node) { #ifdef __VOLUME__ /* Only sum extinction for volumes, variable is shared with surface transparency. */ @@ -1164,9 +1164,9 @@ template ccl_device_noinline int svm_node_principled_volume(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - Spectrum closure_weight, - uint4 node, - uint32_t path_flag, + const Spectrum closure_weight, + const uint4 node, + const uint32_t path_flag, int offset) { #ifdef __VOLUME__ @@ -1295,7 +1295,7 @@ ccl_device_noinline void svm_node_closure_emission(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, Spectrum closure_weight, - uint4 node) + const uint4 node) { const uint mix_weight_offset = node.y; Spectrum weight = closure_weight; @@ -1320,7 +1320,7 @@ ccl_device_noinline void svm_node_closure_emission(KernelGlobals kg, ccl_device_noinline void svm_node_closure_background(ccl_private ShaderData *sd, ccl_private float *stack, Spectrum closure_weight, - uint4 node) + const uint4 node) { const uint mix_weight_offset = node.y; Spectrum weight = closure_weight; @@ -1341,7 +1341,7 @@ ccl_device_noinline void svm_node_closure_background(ccl_private ShaderData *sd, ccl_device_noinline void svm_node_closure_holdout(ccl_private ShaderData *sd, ccl_private float *stack, Spectrum closure_weight, - uint4 node) + const uint4 node) { const uint mix_weight_offset = node.y; @@ -1363,8 +1363,11 @@ ccl_device_noinline void svm_node_closure_holdout(ccl_private ShaderData *sd, /* Closure Nodes */ -ccl_device void svm_node_closure_set_weight( - ccl_private ShaderData *sd, ccl_private Spectrum *closure_weight, uint r, uint g, uint b) +ccl_device void svm_node_closure_set_weight(ccl_private ShaderData *sd, + ccl_private Spectrum *closure_weight, + const uint r, + uint g, + const uint b) { *closure_weight = rgb_to_spectrum( make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b))); @@ -1373,7 +1376,7 @@ ccl_device void svm_node_closure_set_weight( ccl_device void svm_node_closure_weight(ccl_private ShaderData *sd, ccl_private float *stack, ccl_private Spectrum *closure_weight, - uint weight_offset) + const uint weight_offset) { *closure_weight = rgb_to_spectrum(stack_load_float3(stack, weight_offset)); } @@ -1382,7 +1385,7 @@ ccl_device_noinline void svm_node_emission_weight(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, ccl_private Spectrum *closure_weight, - uint4 node) + const uint4 node) { const uint color_offset = node.y; const uint strength_offset = node.z; @@ -1393,7 +1396,7 @@ ccl_device_noinline void svm_node_emission_weight(KernelGlobals kg, ccl_device_noinline void svm_node_mix_closure(ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { /* fetch weight from blend input, previous mix closures, * and write to stack to be used by closure nodes later */ @@ -1424,8 +1427,8 @@ ccl_device_noinline void svm_node_mix_closure(ccl_private ShaderData *sd, ccl_device void svm_node_set_normal(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint in_direction, - uint out_normal) + const uint in_direction, + const uint out_normal) { const float3 normal = stack_load_float3(stack, in_direction); sd->N = normal; diff --git a/intern/cycles/kernel/svm/color_util.h b/intern/cycles/kernel/svm/color_util.h index 0d2cc894d98..586b9e8bcd9 100644 --- a/intern/cycles/kernel/svm/color_util.h +++ b/intern/cycles/kernel/svm/color_util.h @@ -10,22 +10,22 @@ CCL_NAMESPACE_BEGIN -ccl_device float3 svm_mix_blend(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_blend(const float t, const float3 col1, const float3 col2) { return interp(col1, col2, t); } -ccl_device float3 svm_mix_add(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_add(const float t, const float3 col1, const float3 col2) { return interp(col1, col1 + col2, t); } -ccl_device float3 svm_mix_mul(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_mul(const float t, const float3 col1, const float3 col2) { return interp(col1, col1 * col2, t); } -ccl_device float3 svm_mix_screen(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_screen(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; const float3 one = make_float3(1.0f, 1.0f, 1.0f); @@ -34,7 +34,7 @@ ccl_device float3 svm_mix_screen(float t, float3 col1, float3 col2) return one - (tm3 + t * (one - col2)) * (one - col1); } -ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_overlay(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; @@ -64,12 +64,12 @@ ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_sub(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_sub(const float t, const float3 col1, const float3 col2) { return interp(col1, col1 - col2, t); } -ccl_device float3 svm_mix_div(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_div(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; @@ -88,27 +88,27 @@ ccl_device float3 svm_mix_div(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_diff(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_diff(const float t, const float3 col1, const float3 col2) { return interp(col1, fabs(col1 - col2), t); } -ccl_device float3 svm_mix_exclusion(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_exclusion(const float t, const float3 col1, const float3 col2) { return max(interp(col1, col1 + col2 - 2.0f * col1 * col2, t), zero_float3()); } -ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_dark(const float t, const float3 col1, const float3 col2) { return interp(col1, min(col1, col2), t); } -ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_light(const float t, const float3 col1, const float3 col2) { return interp(col1, max(col1, col2), t); } -ccl_device float3 svm_mix_dodge(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_dodge(const float t, const float3 col1, const float3 col2) { float3 outcol = col1; @@ -161,7 +161,7 @@ ccl_device float3 svm_mix_dodge(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_burn(const float t, const float3 col1, const float3 col2) { float tmp; const float tm = 1.0f - t; @@ -222,7 +222,7 @@ ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_hue(const float t, const float3 col1, const float3 col2) { float3 outcol = col1; @@ -239,7 +239,7 @@ ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_sat(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_sat(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; @@ -257,7 +257,7 @@ ccl_device float3 svm_mix_sat(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_val(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_val(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; @@ -269,7 +269,7 @@ ccl_device float3 svm_mix_val(float t, float3 col1, float3 col2) return hsv_to_rgb(hsv); } -ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_color(const float t, const float3 col1, const float3 col2) { float3 outcol = col1; const float3 hsv2 = rgb_to_hsv(col2); @@ -286,7 +286,7 @@ ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2) return outcol; } -ccl_device float3 svm_mix_soft(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_soft(const float t, const float3 col1, const float3 col2) { const float tm = 1.0f - t; @@ -296,17 +296,20 @@ ccl_device float3 svm_mix_soft(float t, float3 col1, float3 col2) return tm * col1 + t * ((one - col1) * col2 * col1 + col1 * scr); } -ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_linear(const float t, const float3 col1, const float3 col2) { return col1 + t * (2.0f * col2 + make_float3(-1.0f, -1.0f, -1.0f)); } -ccl_device float3 svm_mix_clamp(float3 col) +ccl_device float3 svm_mix_clamp(const float3 col) { return saturate(col); } -ccl_device_noinline_cpu float3 svm_mix(NodeMix type, float t, float3 c1, float3 c2) +ccl_device_noinline_cpu float3 svm_mix(NodeMix type, + const float t, + const float3 c1, + const float3 c2) { switch (type) { case NODE_MIX_BLEND: @@ -354,13 +357,18 @@ ccl_device_noinline_cpu float3 svm_mix(NodeMix type, float t, float3 c1, float3 return make_float3(0.0f, 0.0f, 0.0f); } -ccl_device_noinline_cpu float3 svm_mix_clamped_factor(NodeMix type, float t, float3 c1, float3 c2) +ccl_device_noinline_cpu float3 svm_mix_clamped_factor(NodeMix type, + const float t, + const float3 c1, + const float3 c2) { const float fac = saturatef(t); return svm_mix(type, fac, c1, c2); } -ccl_device_inline float3 svm_brightness_contrast(float3 color, float brightness, float contrast) +ccl_device_inline float3 svm_brightness_contrast(float3 color, + const float brightness, + const float contrast) { const float a = 1.0f + contrast; const float b = brightness - contrast * 0.5f; @@ -372,7 +380,7 @@ ccl_device_inline float3 svm_brightness_contrast(float3 color, float brightness, return color; } -ccl_device float3 svm_combine_color(NodeCombSepColorType type, float3 color) +ccl_device float3 svm_combine_color(NodeCombSepColorType type, const float3 color) { switch (type) { case NODE_COMBSEP_COLOR_HSV: @@ -385,7 +393,7 @@ ccl_device float3 svm_combine_color(NodeCombSepColorType type, float3 color) } } -ccl_device float3 svm_separate_color(NodeCombSepColorType type, float3 color) +ccl_device float3 svm_separate_color(NodeCombSepColorType type, const float3 color) { switch (type) { case NODE_COMBSEP_COLOR_HSV: diff --git a/intern/cycles/kernel/svm/convert.h b/intern/cycles/kernel/svm/convert.h index 4943a0cb71b..7cc0b16a81d 100644 --- a/intern/cycles/kernel/svm/convert.h +++ b/intern/cycles/kernel/svm/convert.h @@ -15,9 +15,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_convert(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint from, - uint to) + const uint type, + const uint from, + const uint to) { switch ((NodeConvert)type) { case NODE_CONVERT_FI: { diff --git a/intern/cycles/kernel/svm/displace.h b/intern/cycles/kernel/svm/displace.h index 81adef9d15a..fb0ac09cae3 100644 --- a/intern/cycles/kernel/svm/displace.h +++ b/intern/cycles/kernel/svm/displace.h @@ -19,7 +19,7 @@ template ccl_device_noinline void svm_node_set_bump(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint out_offset; uint bump_state_offset; @@ -113,7 +113,7 @@ template ccl_device void svm_node_set_displacement(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint fac_offset) + const uint fac_offset) { IF_KERNEL_NODES_FEATURE(BUMP) { @@ -126,7 +126,7 @@ template ccl_device_noinline void svm_node_displacement(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { IF_KERNEL_NODES_FEATURE(BUMP) { @@ -165,8 +165,11 @@ ccl_device_noinline void svm_node_displacement(KernelGlobals kg, } template -ccl_device_noinline int svm_node_vector_displacement( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_vector_displacement(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { const uint4 data_node = read_node(kg, &offset); uint vector_offset; diff --git a/intern/cycles/kernel/svm/fractal_noise.h b/intern/cycles/kernel/svm/fractal_noise.h index bb6fee25006..ced8e5630d7 100644 --- a/intern/cycles/kernel/svm/fractal_noise.h +++ b/intern/cycles/kernel/svm/fractal_noise.h @@ -11,7 +11,7 @@ CCL_NAMESPACE_BEGIN /* Fractal Brownian motion. */ ccl_device_noinline float noise_fbm( - float p, float detail, float roughness, float lacunarity, bool normalize) + float p, const float detail, const float roughness, const float lacunarity, bool normalize) { float fscale = 1.0f; float amp = 1.0f; @@ -36,7 +36,7 @@ ccl_device_noinline float noise_fbm( } ccl_device_noinline float noise_fbm( - float2 p, float detail, float roughness, float lacunarity, bool normalize) + float2 p, const float detail, const float roughness, const float lacunarity, bool normalize) { float fscale = 1.0f; float amp = 1.0f; @@ -61,7 +61,7 @@ ccl_device_noinline float noise_fbm( } ccl_device_noinline float noise_fbm( - float3 p, float detail, float roughness, float lacunarity, bool normalize) + float3 p, const float detail, const float roughness, const float lacunarity, bool normalize) { float fscale = 1.0f; float amp = 1.0f; @@ -86,7 +86,7 @@ ccl_device_noinline float noise_fbm( } ccl_device_noinline float noise_fbm( - float4 p, float detail, float roughness, float lacunarity, bool normalize) + float4 p, const float detail, const float roughness, const float lacunarity, bool normalize) { float fscale = 1.0f; float amp = 1.0f; @@ -113,9 +113,9 @@ ccl_device_noinline float noise_fbm( /* Multifractal */ ccl_device_noinline float noise_multi_fractal(float p, - float detail, - float roughness, - float lacunarity) + const float detail, + const float roughness, + const float lacunarity) { float value = 1.0f; float pwr = 1.0f; @@ -135,9 +135,9 @@ ccl_device_noinline float noise_multi_fractal(float p, } ccl_device_noinline float noise_multi_fractal(float2 p, - float detail, - float roughness, - float lacunarity) + const float detail, + const float roughness, + const float lacunarity) { float value = 1.0f; float pwr = 1.0f; @@ -157,9 +157,9 @@ ccl_device_noinline float noise_multi_fractal(float2 p, } ccl_device_noinline float noise_multi_fractal(float3 p, - float detail, - float roughness, - float lacunarity) + const float detail, + const float roughness, + const float lacunarity) { float value = 1.0f; float pwr = 1.0f; @@ -179,9 +179,9 @@ ccl_device_noinline float noise_multi_fractal(float3 p, } ccl_device_noinline float noise_multi_fractal(float4 p, - float detail, - float roughness, - float lacunarity) + const float detail, + const float roughness, + const float lacunarity) { float value = 1.0f; float pwr = 1.0f; @@ -203,7 +203,7 @@ ccl_device_noinline float noise_multi_fractal(float4 p, /* Heterogeneous Terrain */ ccl_device_noinline float noise_hetero_terrain( - float p, float detail, float roughness, float lacunarity, float offset) + float p, const float detail, const float roughness, const float lacunarity, const float offset) { float pwr = roughness; @@ -227,8 +227,11 @@ ccl_device_noinline float noise_hetero_terrain( return value; } -ccl_device_noinline float noise_hetero_terrain( - float2 p, float detail, float roughness, float lacunarity, float offset) +ccl_device_noinline float noise_hetero_terrain(float2 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset) { float pwr = roughness; @@ -252,8 +255,11 @@ ccl_device_noinline float noise_hetero_terrain( return value; } -ccl_device_noinline float noise_hetero_terrain( - float3 p, float detail, float roughness, float lacunarity, float offset) +ccl_device_noinline float noise_hetero_terrain(float3 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset) { float pwr = roughness; @@ -277,8 +283,11 @@ ccl_device_noinline float noise_hetero_terrain( return value; } -ccl_device_noinline float noise_hetero_terrain( - float4 p, float detail, float roughness, float lacunarity, float offset) +ccl_device_noinline float noise_hetero_terrain(float4 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset) { float pwr = roughness; @@ -304,8 +313,12 @@ ccl_device_noinline float noise_hetero_terrain( /* Hybrid Additive/Multiplicative Multifractal Terrain */ -ccl_device_noinline float noise_hybrid_multi_fractal( - float p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_hybrid_multi_fractal(float p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = 1.0f; float value = 0.0f; @@ -331,8 +344,12 @@ ccl_device_noinline float noise_hybrid_multi_fractal( return value; } -ccl_device_noinline float noise_hybrid_multi_fractal( - float2 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_hybrid_multi_fractal(float2 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = 1.0f; float value = 0.0f; @@ -358,8 +375,12 @@ ccl_device_noinline float noise_hybrid_multi_fractal( return value; } -ccl_device_noinline float noise_hybrid_multi_fractal( - float3 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_hybrid_multi_fractal(float3 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = 1.0f; float value = 0.0f; @@ -385,8 +406,12 @@ ccl_device_noinline float noise_hybrid_multi_fractal( return value; } -ccl_device_noinline float noise_hybrid_multi_fractal( - float4 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_hybrid_multi_fractal(float4 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = 1.0f; float value = 0.0f; @@ -414,8 +439,12 @@ ccl_device_noinline float noise_hybrid_multi_fractal( /* Ridged Multifractal Terrain */ -ccl_device_noinline float noise_ridged_multi_fractal( - float p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_ridged_multi_fractal(float p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = roughness; @@ -437,8 +466,12 @@ ccl_device_noinline float noise_ridged_multi_fractal( return value; } -ccl_device_noinline float noise_ridged_multi_fractal( - float2 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_ridged_multi_fractal(float2 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = roughness; @@ -460,8 +493,12 @@ ccl_device_noinline float noise_ridged_multi_fractal( return value; } -ccl_device_noinline float noise_ridged_multi_fractal( - float3 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_ridged_multi_fractal(float3 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = roughness; @@ -483,8 +520,12 @@ ccl_device_noinline float noise_ridged_multi_fractal( return value; } -ccl_device_noinline float noise_ridged_multi_fractal( - float4 p, float detail, float roughness, float lacunarity, float offset, float gain) +ccl_device_noinline float noise_ridged_multi_fractal(float4 p, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain) { float pwr = roughness; diff --git a/intern/cycles/kernel/svm/fresnel.h b/intern/cycles/kernel/svm/fresnel.h index 13bf3656902..9e6b746a9b0 100644 --- a/intern/cycles/kernel/svm/fresnel.h +++ b/intern/cycles/kernel/svm/fresnel.h @@ -14,9 +14,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_fresnel(ccl_private ShaderData *sd, ccl_private float *stack, - uint ior_offset, - uint ior_value, - uint node) + const uint ior_offset, + const uint ior_value, + const uint node) { uint normal_offset; uint out_offset; @@ -38,7 +38,7 @@ ccl_device_noinline void svm_node_fresnel(ccl_private ShaderData *sd, ccl_device_noinline void svm_node_layer_weight(ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { const uint blend_offset = node.y; const uint blend_value = node.z; diff --git a/intern/cycles/kernel/svm/gabor.h b/intern/cycles/kernel/svm/gabor.h index 09878f844c5..e61614d27a1 100644 --- a/intern/cycles/kernel/svm/gabor.h +++ b/intern/cycles/kernel/svm/gabor.h @@ -59,7 +59,9 @@ CCL_NAMESPACE_BEGIN * real part of the phasor, we use the sine part instead, that is, the imaginary part of the * phasor, as suggested by Tavernier's paper in "Section 3.3. Instance stationarity and * normalization", to ensure a zero mean, which should help with normalization. */ -ccl_device float2 compute_2d_gabor_kernel(float2 position, float frequency, float orientation) +ccl_device float2 compute_2d_gabor_kernel(const float2 position, + const float frequency, + const float orientation) { const float distance_squared = dot(position, position); const float hann_window = 0.5f + 0.5f * cosf(M_PI_F * distance_squared); @@ -109,8 +111,11 @@ ccl_device float compute_2d_gabor_standard_deviation() * noise while it is random for isotropic noise. The original Gabor noise paper mentions that the * weights should be uniformly distributed in the [-1, 1] range, however, Tavernier's paper showed * that using a Bernoulli distribution yields better results, so that is what we do. */ -ccl_device float2 compute_2d_gabor_noise_cell( - float2 cell, float2 position, float frequency, float isotropy, float base_orientation) +ccl_device float2 compute_2d_gabor_noise_cell(float2 cell, + const float2 position, + const float frequency, + const float isotropy, + const float base_orientation) { float2 noise = make_float2(0.0f, 0.0f); @@ -147,10 +152,10 @@ ccl_device float2 compute_2d_gabor_noise_cell( /* Computes the Gabor noise value by dividing the space into a grid and evaluating the Gabor noise * in the space of each cell of the 3x3 cell neighborhood. */ -ccl_device float2 compute_2d_gabor_noise(float2 coordinates, - float frequency, - float isotropy, - float base_orientation) +ccl_device float2 compute_2d_gabor_noise(const float2 coordinates, + const float frequency, + const float isotropy, + const float base_orientation) { const float2 cell_position = floor(coordinates); const float2 local_position = coordinates - cell_position; @@ -173,7 +178,9 @@ ccl_device float2 compute_2d_gabor_noise(float2 coordinates, * (6) in the original Gabor noise paper computes the frequency vector using (cos(w_0), sin(w_0)), * which we also do in the 2D variant, however, for 3D, the orientation is already a unit frequency * vector, so we just need to scale it by the frequency value. */ -ccl_device float2 compute_3d_gabor_kernel(float3 position, float frequency, float3 orientation) +ccl_device float2 compute_3d_gabor_kernel(const float3 position, + const float frequency, + const float3 orientation) { const float distance_squared = dot(position, position); const float hann_window = 0.5f + 0.5f * cosf(M_PI_F * distance_squared); @@ -198,7 +205,9 @@ ccl_device float compute_3d_gabor_standard_deviation() /* Computes the orientation of the Gabor kernel such that it is constant for anisotropic * noise while it is random for isotropic noise. We randomize in spherical coordinates for a * uniform distribution. */ -ccl_device float3 compute_3d_orientation(float3 orientation, float isotropy, float4 seed) +ccl_device float3 compute_3d_orientation(const float3 orientation, + const float isotropy, + const float4 seed) { /* Return the base orientation in case we are completely anisotropic. */ if (isotropy == 0.0f) { @@ -222,8 +231,11 @@ ccl_device float3 compute_3d_orientation(float3 orientation, float isotropy, flo return spherical_to_direction(inclination, azimuth); } -ccl_device float2 compute_3d_gabor_noise_cell( - float3 cell, float3 position, float frequency, float isotropy, float3 base_orientation) +ccl_device float2 compute_3d_gabor_noise_cell(float3 cell, + const float3 position, + const float frequency, + const float isotropy, + const float3 base_orientation) { float2 noise = make_float2(0.0f, 0.0f); @@ -255,10 +267,10 @@ ccl_device float2 compute_3d_gabor_noise_cell( } /* Identical to compute_2d_gabor_noise but works in the 3D neighborhood of the noise. */ -ccl_device float2 compute_3d_gabor_noise(float3 coordinates, - float frequency, - float isotropy, - float3 base_orientation) +ccl_device float2 compute_3d_gabor_noise(const float3 coordinates, + const float frequency, + const float isotropy, + const float3 base_orientation) { const float3 cell_position = floor(coordinates); const float3 local_position = coordinates - cell_position; @@ -282,9 +294,9 @@ ccl_device float2 compute_3d_gabor_noise(float3 coordinates, ccl_device_noinline int svm_node_tex_gabor(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint stack_offsets_1, - uint stack_offsets_2, + const uint type, + const uint stack_offsets_1, + const uint stack_offsets_2, int offset) { uint coordinates_stack_offset; diff --git a/intern/cycles/kernel/svm/gamma.h b/intern/cycles/kernel/svm/gamma.h index 063e2410663..a14f0cb0881 100644 --- a/intern/cycles/kernel/svm/gamma.h +++ b/intern/cycles/kernel/svm/gamma.h @@ -11,9 +11,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_gamma(ccl_private ShaderData *sd, ccl_private float *stack, - uint in_gamma, - uint in_color, - uint out_color) + const uint in_gamma, + const uint in_color, + const uint out_color) { float3 color = stack_load_float3(stack, in_color); const float gamma = stack_load_float(stack, in_gamma); diff --git a/intern/cycles/kernel/svm/geometry.h b/intern/cycles/kernel/svm/geometry.h index 6e2c2f12666..5d04ad66d20 100644 --- a/intern/cycles/kernel/svm/geometry.h +++ b/intern/cycles/kernel/svm/geometry.h @@ -19,8 +19,8 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_geometry(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { float3 data; @@ -55,8 +55,8 @@ ccl_device_noinline void svm_node_geometry(KernelGlobals kg, ccl_device_noinline void svm_node_geometry_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -82,8 +82,8 @@ ccl_device_noinline void svm_node_geometry_bump_dx(KernelGlobals kg, ccl_device_noinline void svm_node_geometry_bump_dy(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -111,8 +111,8 @@ ccl_device_noinline void svm_node_geometry_bump_dy(KernelGlobals kg, ccl_device_noinline void svm_node_object_info(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { float data; @@ -156,8 +156,8 @@ ccl_device_noinline void svm_node_object_info(KernelGlobals kg, ccl_device_noinline void svm_node_particle_info(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { switch ((NodeParticleInfo)type) { case NODE_INFO_PAR_INDEX: { @@ -218,8 +218,8 @@ ccl_device_noinline void svm_node_particle_info(KernelGlobals kg, ccl_device_noinline void svm_node_hair_info(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { float data; float3 data3; @@ -257,8 +257,8 @@ ccl_device_noinline void svm_node_hair_info(KernelGlobals kg, ccl_device_noinline void svm_node_point_info(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset) + const uint type, + const uint out_offset) { switch ((NodePointInfo)type) { case NODE_INFO_POINT_POSITION: diff --git a/intern/cycles/kernel/svm/gradient.h b/intern/cycles/kernel/svm/gradient.h index c08b19ee268..a3a84ad2b36 100644 --- a/intern/cycles/kernel/svm/gradient.h +++ b/intern/cycles/kernel/svm/gradient.h @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN /* Gradient */ -ccl_device float svm_gradient(float3 p, NodeGradientType type) +ccl_device float svm_gradient(const float3 p, NodeGradientType type) { float x; float y; @@ -57,7 +57,7 @@ ccl_device float svm_gradient(float3 p, NodeGradientType type) ccl_device_noinline void svm_node_tex_gradient(ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint type; uint co_offset; diff --git a/intern/cycles/kernel/svm/hsv.h b/intern/cycles/kernel/svm/hsv.h index 10177c52724..70e5c2052e3 100644 --- a/intern/cycles/kernel/svm/hsv.h +++ b/intern/cycles/kernel/svm/hsv.h @@ -13,7 +13,7 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_hsv(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint in_color_offset; uint fac_offset; diff --git a/intern/cycles/kernel/svm/ies.h b/intern/cycles/kernel/svm/ies.h index 397e5b9f14a..5cb51496a42 100644 --- a/intern/cycles/kernel/svm/ies.h +++ b/intern/cycles/kernel/svm/ies.h @@ -13,7 +13,7 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_ies(KernelGlobals kg, ccl_private ShaderData * /*sd*/, ccl_private float *stack, - uint4 node) + const uint4 node) { uint vector_offset; uint strength_offset; diff --git a/intern/cycles/kernel/svm/image.h b/intern/cycles/kernel/svm/image.h index 885c5183cad..e351051f902 100644 --- a/intern/cycles/kernel/svm/image.h +++ b/intern/cycles/kernel/svm/image.h @@ -17,7 +17,8 @@ CCL_NAMESPACE_BEGIN -ccl_device float4 svm_image_texture(KernelGlobals kg, int id, float x, float y, uint flags) +ccl_device float4 +svm_image_texture(KernelGlobals kg, const int id, const float x, float y, const uint flags) { if (id == -1) { return make_float4( @@ -40,7 +41,7 @@ ccl_device float4 svm_image_texture(KernelGlobals kg, int id, float x, float y, } /* Remap coordinate from 0..1 box to -1..-1 */ -ccl_device_inline float3 texco_remap_square(float3 co) +ccl_device_inline float3 texco_remap_square(const float3 co) { return (co - make_float3(0.5f, 0.5f, 0.5f)) * 2.0f; } @@ -48,7 +49,7 @@ ccl_device_inline float3 texco_remap_square(float3 co) ccl_device_noinline int svm_node_tex_image(KernelGlobals kg, ccl_private ShaderData * /*sd*/, ccl_private float *stack, - uint4 node, + const uint4 node, int offset) { uint co_offset; @@ -129,7 +130,7 @@ ccl_device_noinline int svm_node_tex_image(KernelGlobals kg, ccl_device_noinline void svm_node_tex_image_box(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { /* get object space normal */ float3 N = sd->N; @@ -236,7 +237,7 @@ ccl_device_noinline void svm_node_tex_image_box(KernelGlobals kg, ccl_device_noinline void svm_node_tex_environment(KernelGlobals kg, ccl_private ShaderData * /*sd*/, ccl_private float *stack, - uint4 node) + const uint4 node) { const uint id = node.y; uint co_offset; diff --git a/intern/cycles/kernel/svm/invert.h b/intern/cycles/kernel/svm/invert.h index e76d7059ae5..58fa852d7a1 100644 --- a/intern/cycles/kernel/svm/invert.h +++ b/intern/cycles/kernel/svm/invert.h @@ -8,16 +8,16 @@ CCL_NAMESPACE_BEGIN -ccl_device float invert(float color, float factor) +ccl_device float invert(const float color, const float factor) { return factor * (1.0f - color) + (1.0f - factor) * color; } ccl_device_noinline void svm_node_invert(ccl_private ShaderData *sd, ccl_private float *stack, - uint in_fac, - uint in_color, - uint out_color) + const uint in_fac, + const uint in_color, + const uint out_color) { const float factor = stack_load_float(stack, in_fac); float3 color = stack_load_float3(stack, in_color); diff --git a/intern/cycles/kernel/svm/light_path.h b/intern/cycles/kernel/svm/light_path.h index f81c854e9a0..ebc88f01ca6 100644 --- a/intern/cycles/kernel/svm/light_path.h +++ b/intern/cycles/kernel/svm/light_path.h @@ -15,9 +15,9 @@ ccl_device_noinline void svm_node_light_path(KernelGlobals kg, ConstIntegratorGenericState state, const ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint out_offset, - uint32_t path_flag) + const uint type, + const uint out_offset, + const uint32_t path_flag) { float info = 0.0f; @@ -102,7 +102,7 @@ ccl_device_noinline void svm_node_light_path(KernelGlobals kg, ccl_device_noinline void svm_node_light_falloff(ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint strength_offset; uint out_offset; diff --git a/intern/cycles/kernel/svm/magic.h b/intern/cycles/kernel/svm/magic.h index 742eb3f2cc4..2d124e68e97 100644 --- a/intern/cycles/kernel/svm/magic.h +++ b/intern/cycles/kernel/svm/magic.h @@ -10,7 +10,10 @@ CCL_NAMESPACE_BEGIN /* Magic */ -ccl_device_noinline_cpu float3 svm_magic(float3 p, float scale, int n, float distortion) +ccl_device_noinline_cpu float3 svm_magic(const float3 p, + const float scale, + const int n, + float distortion) { /* * Prevent NaNs due to input p @@ -95,8 +98,11 @@ ccl_device_noinline_cpu float3 svm_magic(float3 p, float scale, int n, float dis return make_float3(0.5f - x, 0.5f - y, 0.5f - z); } -ccl_device_noinline int svm_node_tex_magic( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_tex_magic(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { uint depth; uint scale_offset; diff --git a/intern/cycles/kernel/svm/map_range.h b/intern/cycles/kernel/svm/map_range.h index c0dbe231c7a..673049cf21a 100644 --- a/intern/cycles/kernel/svm/map_range.h +++ b/intern/cycles/kernel/svm/map_range.h @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN /* Map Range Node */ -ccl_device_inline float smootherstep(float edge0, float edge1, float x) +ccl_device_inline float smootherstep(const float edge0, const float edge1, float x) { x = clamp(safe_divide((x - edge0), (edge1 - edge0)), 0.0f, 1.0f); return x * x * x * (x * (x * 6.0f - 15.0f) + 10.0f); @@ -19,9 +19,9 @@ ccl_device_inline float smootherstep(float edge0, float edge1, float x) ccl_device_noinline int svm_node_map_range(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint value_stack_offset, - uint parameters_stack_offsets, - uint results_stack_offsets, + const uint value_stack_offset, + const uint parameters_stack_offsets, + const uint results_stack_offsets, int offset) { uint from_min_stack_offset; @@ -86,10 +86,10 @@ ccl_device_noinline int svm_node_map_range(KernelGlobals kg, ccl_device_noinline int svm_node_vector_map_range(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint value_stack_offset, - uint parameters_stack_offsets, - uint results_stack_offsets, - int offset) + const uint value_stack_offset, + const uint parameters_stack_offsets, + const uint results_stack_offsets, + const int offset) { uint from_min_stack_offset; uint from_max_stack_offset; diff --git a/intern/cycles/kernel/svm/mapping.h b/intern/cycles/kernel/svm/mapping.h index 64fda37ba28..6dcd1c90d25 100644 --- a/intern/cycles/kernel/svm/mapping.h +++ b/intern/cycles/kernel/svm/mapping.h @@ -14,9 +14,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_mapping(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint inputs_stack_offsets, - uint result_stack_offset) + const uint type, + const uint inputs_stack_offsets, + const uint result_stack_offset) { uint vector_stack_offset; uint location_stack_offset; @@ -42,8 +42,8 @@ ccl_device_noinline void svm_node_mapping(KernelGlobals kg, ccl_device_noinline int svm_node_texture_mapping(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint vec_offset, - uint out_offset, + const uint vec_offset, + const uint out_offset, int offset) { const float3 v = stack_load_float3(stack, vec_offset); @@ -61,8 +61,8 @@ ccl_device_noinline int svm_node_texture_mapping(KernelGlobals kg, ccl_device_noinline int svm_node_min_max(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint vec_offset, - uint out_offset, + const uint vec_offset, + const uint out_offset, int offset) { const float3 v = stack_load_float3(stack, vec_offset); diff --git a/intern/cycles/kernel/svm/mapping_util.h b/intern/cycles/kernel/svm/mapping_util.h index a9cdca6a71c..7ea74ff8f9a 100644 --- a/intern/cycles/kernel/svm/mapping_util.h +++ b/intern/cycles/kernel/svm/mapping_util.h @@ -12,8 +12,11 @@ CCL_NAMESPACE_BEGIN -ccl_device float3 -svm_mapping(NodeMappingType type, float3 vector, float3 location, float3 rotation, float3 scale) +ccl_device float3 svm_mapping(NodeMappingType type, + const float3 vector, + const float3 location, + const float3 rotation, + const float3 scale) { const Transform rotationTransform = euler_to_transform(rotation); switch (type) { diff --git a/intern/cycles/kernel/svm/math.h b/intern/cycles/kernel/svm/math.h index bb53a6ac739..e9b5f9decdd 100644 --- a/intern/cycles/kernel/svm/math.h +++ b/intern/cycles/kernel/svm/math.h @@ -12,9 +12,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_math(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint inputs_stack_offsets, - uint result_stack_offset) + const uint type, + const uint inputs_stack_offsets, + const uint result_stack_offset) { uint a_stack_offset; uint b_stack_offset; @@ -32,9 +32,9 @@ ccl_device_noinline void svm_node_math(KernelGlobals kg, ccl_device_noinline int svm_node_vector_math(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint type, - uint inputs_stack_offsets, - uint outputs_stack_offsets, + const uint type, + const uint inputs_stack_offsets, + const uint outputs_stack_offsets, int offset) { uint value_stack_offset; diff --git a/intern/cycles/kernel/svm/math_util.h b/intern/cycles/kernel/svm/math_util.h index df26373e974..a7091f31eea 100644 --- a/intern/cycles/kernel/svm/math_util.h +++ b/intern/cycles/kernel/svm/math_util.h @@ -15,9 +15,9 @@ CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math(ccl_private float *value, ccl_private float3 *vector, NodeVectorMathType type, - float3 a, - float3 b, - float3 c, + const float3 a, + const float3 b, + const float3 c, float param1) { switch (type) { @@ -108,7 +108,7 @@ ccl_device void svm_vector_math(ccl_private float *value, } } -ccl_device float svm_math(NodeMathType type, float a, float b, float c) +ccl_device float svm_math(NodeMathType type, const float a, float b, const float c) { switch (type) { case NODE_MATH_ADD: @@ -198,7 +198,7 @@ ccl_device float svm_math(NodeMathType type, float a, float b, float c) } } -ccl_device float3 svm_math_blackbody_color_rec709(float t) +ccl_device float3 svm_math_blackbody_color_rec709(const float t) { /* Calculate color in range 800..12000 using an approximation * a/x+bx+c for R and G and ((at + b)t + c)t + d) for B. @@ -232,7 +232,7 @@ ccl_device float3 svm_math_blackbody_color_rec709(float t) ((b[0] * t + b[1]) * t + b[2]) * t + b[3]); } -ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma) +ccl_device_inline float3 svm_math_gamma_color(float3 color, const float gamma) { if (gamma == 0.0f) { return make_float3(1.0f, 1.0f, 1.0f); @@ -251,7 +251,7 @@ ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma) return color; } -ccl_device float3 svm_math_wavelength_color_xyz(float lambda_nm) +ccl_device float3 svm_math_wavelength_color_xyz(const float lambda_nm) { float ii = (lambda_nm - 380.0f) * (1.0f / 5.0f); // scaled 0..80 const int i = float_to_int(ii); diff --git a/intern/cycles/kernel/svm/mix.h b/intern/cycles/kernel/svm/mix.h index 33a9d565d6d..61f5bc0a2f4 100644 --- a/intern/cycles/kernel/svm/mix.h +++ b/intern/cycles/kernel/svm/mix.h @@ -14,9 +14,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_mix(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint fac_offset, - uint c1_offset, - uint c2_offset, + const uint fac_offset, + const uint c1_offset, + const uint c2_offset, int offset) { /* read extra data */ @@ -33,9 +33,9 @@ ccl_device_noinline int svm_node_mix(KernelGlobals kg, ccl_device_noinline void svm_node_mix_color(ccl_private ShaderData *sd, ccl_private float *stack, - uint options, - uint input_offset, - uint result_offset) + const uint options, + const uint input_offset, + const uint result_offset) { uint use_clamp; uint blend_type; @@ -62,9 +62,9 @@ ccl_device_noinline void svm_node_mix_color(ccl_private ShaderData *sd, ccl_device_noinline void svm_node_mix_float(ccl_private ShaderData *sd, ccl_private float *stack, - uint use_clamp, - uint input_offset, - uint result_offset) + const uint use_clamp, + const uint input_offset, + const uint result_offset) { uint fac_in_stack_offset; uint a_in_stack_offset; @@ -85,8 +85,8 @@ ccl_device_noinline void svm_node_mix_float(ccl_private ShaderData *sd, ccl_device_noinline void svm_node_mix_vector(ccl_private ShaderData *sd, ccl_private float *stack, - uint input_offset, - uint result_offset) + const uint input_offset, + const uint result_offset) { uint use_clamp; uint fac_in_stack_offset; @@ -107,8 +107,8 @@ ccl_device_noinline void svm_node_mix_vector(ccl_private ShaderData *sd, ccl_device_noinline void svm_node_mix_vector_non_uniform(ccl_private ShaderData *sd, ccl_private float *stack, - uint input_offset, - uint result_offset) + const uint input_offset, + const uint result_offset) { uint use_clamp; uint fac_in_stack_offset; diff --git a/intern/cycles/kernel/svm/noise.h b/intern/cycles/kernel/svm/noise.h index b0dd3449287..6b772874eda 100644 --- a/intern/cycles/kernel/svm/noise.h +++ b/intern/cycles/kernel/svm/noise.h @@ -15,24 +15,24 @@ CCL_NAMESPACE_BEGIN /* **** Perlin Noise **** */ -ccl_device float fade(float t) +ccl_device float fade(const float t) { return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f); } -ccl_device_inline float negate_if(float val, int condition) +ccl_device_inline float negate_if(const float val, const int condition) { return (condition) ? -val : val; } -ccl_device float grad1(int hash, float x) +ccl_device float grad1(const int hash, const float x) { const int h = hash & 15; const float g = 1 + (h & 7); return negate_if(g, h & 8) * x; } -ccl_device_noinline_cpu float perlin_1d(float x) +ccl_device_noinline_cpu float perlin_1d(const float x) { int X; const float fx = floorfrac(x, &X); @@ -61,7 +61,8 @@ ccl_device_noinline_cpu float perlin_1d(float x) * v0 v1 * */ -ccl_device float bi_mix(float v0, float v1, float v2, float v3, float x, float y) +ccl_device float bi_mix( + const float v0, const float v1, const float v2, const float v3, const float x, float y) { float x1 = 1.0f - x; return (1.0f - y) * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x); @@ -85,7 +86,7 @@ ccl_device float bi_mix(float v0, float v1, float v2, float v3, float x, float y * @ + + + + + + @ * v0 v1 */ -ccl_device float tri_mix(float v0, +ccl_device float tri_mix(const float v0, float v1, float v2, float v3, @@ -93,9 +94,9 @@ ccl_device float tri_mix(float v0, float v5, float v6, float v7, - float x, - float y, - float z) + const float x, + const float y, + const float z) { float x1 = 1.0f - x; float y1 = 1.0f - y; @@ -104,7 +105,7 @@ ccl_device float tri_mix(float v0, z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x)); } -ccl_device float quad_mix(float v0, +ccl_device float quad_mix(const float v0, float v1, float v2, float v3, @@ -120,17 +121,17 @@ ccl_device float quad_mix(float v0, float v13, float v14, float v15, - float x, - float y, - float z, - float w) + const float x, + const float y, + const float z, + const float w) { return mix(tri_mix(v0, v1, v2, v3, v4, v5, v6, v7, x, y, z), tri_mix(v8, v9, v10, v11, v12, v13, v14, v15, x, y, z), w); } -ccl_device float grad2(int hash, float x, float y) +ccl_device float grad2(const int hash, const float x, float y) { int h = hash & 7; float u = h < 4 ? x : y; @@ -138,7 +139,7 @@ ccl_device float grad2(int hash, float x, float y) return negate_if(u, h & 1) + negate_if(v, h & 2); } -ccl_device float grad3(int hash, float x, float y, float z) +ccl_device float grad3(const int hash, const float x, float y, const float z) { int h = hash & 15; float u = h < 8 ? x : y; @@ -147,7 +148,7 @@ ccl_device float grad3(int hash, float x, float y, float z) return negate_if(u, h & 1) + negate_if(v, h & 2); } -ccl_device float grad4(int hash, float x, float y, float z, float w) +ccl_device float grad4(const int hash, const float x, float y, const float z, float w) { int h = hash & 31; float u = h < 24 ? x : y; @@ -156,7 +157,7 @@ ccl_device float grad4(int hash, float x, float y, float z, float w) return negate_if(u, h & 1) + negate_if(v, h & 2) + negate_if(s, h & 4); } -ccl_device_noinline_cpu float perlin_2d(float x, float y) +ccl_device_noinline_cpu float perlin_2d(const float x, const float y) { int X; int Y; @@ -177,7 +178,7 @@ ccl_device_noinline_cpu float perlin_2d(float x, float y) return r; } -ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) +ccl_device_noinline_cpu float perlin_3d(const float x, const float y, float z) { int X; int Y; @@ -205,7 +206,7 @@ ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) return r; } -ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) +ccl_device_noinline_cpu float perlin_4d(const float x, const float y, float z, const float w) { int X; int Y; @@ -275,7 +276,7 @@ ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) * v0 v2 g0 * */ -ccl_device_inline float4 bi_mix(float4 p, float4 f) +ccl_device_inline float4 bi_mix(const float4 p, const float4 f) { const float4 g = mix(p, shuffle<2, 3, 2, 3>(p), shuffle<0>(f)); return mix(g, shuffle<1>(g), shuffle<1>(f)); @@ -311,7 +312,7 @@ ccl_device_inline float4 grad(const int4 hash, const float4 x, const float4 y) * |__________________________| * */ -ccl_device_noinline_cpu float perlin_2d(float x, float y) +ccl_device_noinline_cpu float perlin_2d(const float x, const float y) { int4 XY; const float4 fxy = floorfrac(make_float4(x, y, 0.0f, 0.0f), &XY); @@ -365,7 +366,7 @@ ccl_device_noinline_cpu float perlin_2d(float x, float y) * @ + + + + + + @ @ * v0 v4 s0 */ -ccl_device_inline float4 tri_mix(float4 p, float4 q, float4 f) +ccl_device_inline float4 tri_mix(const float4 p, const float4 q, float4 f) { const float4 s = mix(p, q, shuffle<0>(f)); const float4 g = mix(s, shuffle<2, 3, 2, 3>(s), shuffle<1>(f)); @@ -404,7 +405,8 @@ grad(const int4 hash, const float4 x, const float4 y, const float4 z, const floa * between two trilinear interpolations. * */ -ccl_device_inline float4 quad_mix(float4 p, float4 q, float4 r, float4 s, float4 f) +ccl_device_inline float4 +quad_mix(const float4 p, const float4 q, float4 r, const float4 s, float4 f) { return mix(tri_mix(p, q, f), tri_mix(r, s, f), shuffle<3>(f)); } @@ -428,7 +430,7 @@ ccl_device_inline float4 quad_mix(float4 p, float4 q, float4 r, float4 s, float4 * v7 (1, 1, 1) * */ -ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) +ccl_device_noinline_cpu float perlin_3d(const float x, const float y, float z) { int4 XYZ; const float4 fxyz = floorfrac(make_float4(x, y, z, 0.0f), &XYZ); @@ -482,7 +484,7 @@ ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) * v15 (1, 1, 1, 1) * */ -ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) +ccl_device_noinline_cpu float perlin_4d(const float x, const float y, float z, const float w) { int4 XYZW; const float4 fxyzw = floorfrac(make_float4(x, y, z, w), &XYZW); @@ -543,7 +545,7 @@ grad(const vint8 hash, const vfloat8 x, const vfloat8 y, const vfloat8 z, const * low and high float4 from s. * */ -ccl_device_inline float4 quad_mix(vfloat8 p, vfloat8 q, float4 f) +ccl_device_inline float4 quad_mix(vfloat8 p, vfloat8 q, const float4 f) { float4 fv = shuffle<3>(f); vfloat8 s = mix(p, q, make_vfloat8(fv, fv)); @@ -566,7 +568,7 @@ ccl_device_inline float4 quad_mix(vfloat8 p, vfloat8 q, float4 f) * |__________________________| * */ -ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) +ccl_device_noinline_cpu float perlin_3d(const float x, const float y, float z) { int4 XYZ; float4 fxyz = floorfrac(make_float4(x, y, z, 0.0f), &XYZ); @@ -618,7 +620,7 @@ ccl_device_noinline_cpu float perlin_3d(float x, float y, float z) * v15 (1, 1, 1, 1) * */ -ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) +ccl_device_noinline_cpu float perlin_4d(const float x, const float y, float z, const float w) { int4 XYZW; float4 fxyzw = floorfrac(make_float4(x, y, z, w), &XYZW); @@ -664,22 +666,22 @@ ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) * The scale values were computed experimentally by the OSL developers. */ -ccl_device_inline float noise_scale1(float result) +ccl_device_inline float noise_scale1(const float result) { return 0.2500f * result; } -ccl_device_inline float noise_scale2(float result) +ccl_device_inline float noise_scale2(const float result) { return 0.6616f * result; } -ccl_device_inline float noise_scale3(float result) +ccl_device_inline float noise_scale3(const float result) { return 0.9820f * result; } -ccl_device_inline float noise_scale4(float result) +ccl_device_inline float noise_scale4(const float result) { return 0.8344f * result; } @@ -697,7 +699,7 @@ ccl_device_inline float snoise_1d(float p) return noise_scale1(perlin_1d(p)); } -ccl_device_inline float noise_1d(float p) +ccl_device_inline float noise_1d(const float p) { return 0.5f * snoise_1d(p) + 0.5f; } @@ -714,7 +716,7 @@ ccl_device_inline float snoise_2d(float2 p) return noise_scale2(perlin_2d(p.x, p.y)); } -ccl_device_inline float noise_2d(float2 p) +ccl_device_inline float noise_2d(const float2 p) { return 0.5f * snoise_2d(p) + 0.5f; } @@ -732,7 +734,7 @@ ccl_device_inline float snoise_3d(float3 p) return noise_scale3(perlin_3d(p.x, p.y, p.z)); } -ccl_device_inline float noise_3d(float3 p) +ccl_device_inline float noise_3d(const float3 p) { return 0.5f * snoise_3d(p) + 0.5f; } @@ -751,7 +753,7 @@ ccl_device_inline float snoise_4d(float4 p) return noise_scale4(perlin_4d(p.x, p.y, p.z, p.w)); } -ccl_device_inline float noise_4d(float4 p) +ccl_device_inline float noise_4d(const float4 p) { return 0.5f * snoise_4d(p) + 0.5f; } diff --git a/intern/cycles/kernel/svm/noisetex.h b/intern/cycles/kernel/svm/noisetex.h index 0574af13eb6..65bd0b0b6ad 100644 --- a/intern/cycles/kernel/svm/noisetex.h +++ b/intern/cycles/kernel/svm/noisetex.h @@ -17,25 +17,25 @@ CCL_NAMESPACE_BEGIN * OSL only support float hashes. */ -ccl_device_inline float random_float_offset(float seed) +ccl_device_inline float random_float_offset(const float seed) { return 100.0f + hash_float_to_float(seed) * 100.0f; } -ccl_device_inline float2 random_float2_offset(float seed) +ccl_device_inline float2 random_float2_offset(const float seed) { return make_float2(100.0f + hash_float2_to_float(make_float2(seed, 0.0f)) * 100.0f, 100.0f + hash_float2_to_float(make_float2(seed, 1.0f)) * 100.0f); } -ccl_device_inline float3 random_float3_offset(float seed) +ccl_device_inline float3 random_float3_offset(const float seed) { return make_float3(100.0f + hash_float2_to_float(make_float2(seed, 0.0f)) * 100.0f, 100.0f + hash_float2_to_float(make_float2(seed, 1.0f)) * 100.0f, 100.0f + hash_float2_to_float(make_float2(seed, 2.0f)) * 100.0f); } -ccl_device_inline float4 random_float4_offset(float seed) +ccl_device_inline float4 random_float4_offset(const float seed) { return make_float4(100.0f + hash_float2_to_float(make_float2(seed, 0.0f)) * 100.0f, 100.0f + hash_float2_to_float(make_float2(seed, 1.0f)) * 100.0f, @@ -45,12 +45,12 @@ ccl_device_inline float4 random_float4_offset(float seed) template ccl_device float noise_select(T p, - float detail, - float roughness, - float lacunarity, - float offset, - float gain, - int type, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain, + const int type, bool normalize) { switch ((NodeNoiseType)type) { @@ -76,14 +76,14 @@ ccl_device float noise_select(T p, } } -ccl_device void noise_texture_1d(float co, - float detail, - float roughness, - float lacunarity, - float offset, - float gain, - float distortion, - int type, +ccl_device void noise_texture_1d(const float co, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain, + const float distortion, + const int type, bool normalize, bool color_is_needed, ccl_private float *value, @@ -116,16 +116,16 @@ ccl_device void noise_texture_1d(float co, } } -ccl_device void noise_texture_2d(float2 co, - float detail, - float roughness, - float lacunarity, - float offset, - float gain, - float distortion, - int type, - bool normalize, - bool color_is_needed, +ccl_device void noise_texture_2d(const float2 co, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain, + const float distortion, + const int type, + const bool normalize, + const bool color_is_needed, ccl_private float *value, ccl_private float3 *color) { @@ -157,16 +157,16 @@ ccl_device void noise_texture_2d(float2 co, } } -ccl_device void noise_texture_3d(float3 co, - float detail, - float roughness, - float lacunarity, - float offset, - float gain, - float distortion, - int type, - bool normalize, - bool color_is_needed, +ccl_device void noise_texture_3d(const float3 co, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain, + const float distortion, + const int type, + const bool normalize, + const bool color_is_needed, ccl_private float *value, ccl_private float3 *color) { @@ -199,16 +199,16 @@ ccl_device void noise_texture_3d(float3 co, } } -ccl_device void noise_texture_4d(float4 co, - float detail, - float roughness, - float lacunarity, - float offset, - float gain, - float distortion, - int type, - bool normalize, - bool color_is_needed, +ccl_device void noise_texture_4d(const float4 co, + const float detail, + const float roughness, + const float lacunarity, + const float offset, + const float gain, + const float distortion, + const int type, + const bool normalize, + const bool color_is_needed, ccl_private float *value, ccl_private float3 *color) { @@ -245,9 +245,9 @@ ccl_device void noise_texture_4d(float4 co, ccl_device_noinline int svm_node_tex_noise(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint offsets1, - uint offsets2, - uint offsets3, + const uint offsets1, + const uint offsets2, + const uint offsets3, int node_offset) { uint vector_stack_offset; diff --git a/intern/cycles/kernel/svm/normal.h b/intern/cycles/kernel/svm/normal.h index 2e1e20b9f08..5079ebb9a21 100644 --- a/intern/cycles/kernel/svm/normal.h +++ b/intern/cycles/kernel/svm/normal.h @@ -11,9 +11,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_normal(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint in_normal_offset, - uint out_normal_offset, - uint out_dot_offset, + const uint in_normal_offset, + const uint out_normal_offset, + const uint out_dot_offset, int offset) { /* read extra data */ diff --git a/intern/cycles/kernel/svm/ramp.h b/intern/cycles/kernel/svm/ramp.h index 2f4608f8d6a..d27f780d2ff 100644 --- a/intern/cycles/kernel/svm/ramp.h +++ b/intern/cycles/kernel/svm/ramp.h @@ -10,14 +10,18 @@ CCL_NAMESPACE_BEGIN /* NOTE: svm_ramp.h, svm_ramp_util.h and node_ramp_util.h must stay consistent */ -ccl_device_inline float fetch_float(KernelGlobals kg, int offset) +ccl_device_inline float fetch_float(KernelGlobals kg, const int offset) { const uint4 node = kernel_data_fetch(svm_nodes, offset); return __uint_as_float(node.x); } -ccl_device_inline float float_ramp_lookup( - KernelGlobals kg, int offset, float f, bool interpolate, bool extrapolate, int table_size) +ccl_device_inline float float_ramp_lookup(KernelGlobals kg, + const int offset, + float f, + bool interpolate, + bool extrapolate, + const int table_size) { if ((f < 0.0f || f > 1.0f) && extrapolate) { float t0; @@ -50,8 +54,12 @@ ccl_device_inline float float_ramp_lookup( return a; } -ccl_device_inline float4 rgb_ramp_lookup( - KernelGlobals kg, int offset, float f, bool interpolate, bool extrapolate, int table_size) +ccl_device_inline float4 rgb_ramp_lookup(KernelGlobals kg, + const int offset, + float f, + bool interpolate, + bool extrapolate, + const int table_size) { if ((f < 0.0f || f > 1.0f) && extrapolate) { float4 t0; @@ -84,8 +92,11 @@ ccl_device_inline float4 rgb_ramp_lookup( return a; } -ccl_device_noinline int svm_node_rgb_ramp( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_rgb_ramp(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { uint fac_offset; uint color_offset; @@ -110,8 +121,11 @@ ccl_device_noinline int svm_node_rgb_ramp( return offset; } -ccl_device_noinline int svm_node_curves( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_curves(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { uint fac_offset; uint color_offset; @@ -140,8 +154,11 @@ ccl_device_noinline int svm_node_curves( return offset; } -ccl_device_noinline int svm_node_curve( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_curve(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { uint fac_offset; uint value_in_offset; diff --git a/intern/cycles/kernel/svm/ramp_util.h b/intern/cycles/kernel/svm/ramp_util.h index 8d883900f79..280b84376a5 100644 --- a/intern/cycles/kernel/svm/ramp_util.h +++ b/intern/cycles/kernel/svm/ramp_util.h @@ -11,8 +11,8 @@ CCL_NAMESPACE_BEGIN /* NOTE: svm_ramp.h, svm_ramp_util.h and node_ramp_util.h must stay consistent */ -ccl_device_inline float3 -rgb_ramp_lookup(const float3 *ramp, float f, bool interpolate, bool extrapolate, int table_size) +ccl_device_inline float3 rgb_ramp_lookup( + const float3 *ramp, float f, bool interpolate, bool extrapolate, const int table_size) { if ((f < 0.0f || f > 1.0f) && extrapolate) { float3 t0; @@ -45,7 +45,7 @@ rgb_ramp_lookup(const float3 *ramp, float f, bool interpolate, bool extrapolate, } ccl_device float float_ramp_lookup( - const float *ramp, float f, bool interpolate, bool extrapolate, int table_size) + const float *ramp, float f, bool interpolate, bool extrapolate, const int table_size) { if ((f < 0.0f || f > 1.0f) && extrapolate) { float t0; diff --git a/intern/cycles/kernel/svm/sepcomb_color.h b/intern/cycles/kernel/svm/sepcomb_color.h index 210bd36b532..925323c2311 100644 --- a/intern/cycles/kernel/svm/sepcomb_color.h +++ b/intern/cycles/kernel/svm/sepcomb_color.h @@ -12,9 +12,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_combine_color(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint color_type, - uint inputs_stack_offsets, - uint result_stack_offset) + const uint color_type, + const uint inputs_stack_offsets, + const uint result_stack_offset) { uint red_stack_offset; uint green_stack_offset; @@ -37,9 +37,9 @@ ccl_device_noinline void svm_node_combine_color(KernelGlobals kg, ccl_device_noinline void svm_node_separate_color(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint color_type, - uint input_stack_offset, - uint results_stack_offsets) + const uint color_type, + const uint input_stack_offset, + const uint results_stack_offsets) { float3 color = stack_load_float3(stack, input_stack_offset); diff --git a/intern/cycles/kernel/svm/sepcomb_hsv.h b/intern/cycles/kernel/svm/sepcomb_hsv.h index a4bd4b1e18b..ae65b55e8eb 100644 --- a/intern/cycles/kernel/svm/sepcomb_hsv.h +++ b/intern/cycles/kernel/svm/sepcomb_hsv.h @@ -13,9 +13,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_combine_hsv(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint hue_in, - uint saturation_in, - uint value_in, + const uint hue_in, + const uint saturation_in, + const uint value_in, int offset) { const uint4 node1 = read_node(kg, &offset); @@ -37,9 +37,9 @@ ccl_device_noinline int svm_node_combine_hsv(KernelGlobals kg, ccl_device_noinline int svm_node_separate_hsv(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint color_in, - uint hue_out, - uint saturation_out, + const uint color_in, + const uint hue_out, + const uint saturation_out, int offset) { const uint4 node1 = read_node(kg, &offset); diff --git a/intern/cycles/kernel/svm/sepcomb_vector.h b/intern/cycles/kernel/svm/sepcomb_vector.h index 27046ad0f7b..9a3782cc4a3 100644 --- a/intern/cycles/kernel/svm/sepcomb_vector.h +++ b/intern/cycles/kernel/svm/sepcomb_vector.h @@ -12,9 +12,9 @@ CCL_NAMESPACE_BEGIN ccl_device void svm_node_combine_vector(ccl_private ShaderData *sd, ccl_private float *stack, - uint in_offset, - uint vector_index, - uint out_offset) + const uint in_offset, + const uint vector_index, + const uint out_offset) { const float vector = stack_load_float(stack, in_offset); @@ -25,9 +25,9 @@ ccl_device void svm_node_combine_vector(ccl_private ShaderData *sd, ccl_device void svm_node_separate_vector(ccl_private ShaderData *sd, ccl_private float *stack, - uint ivector_offset, - uint vector_index, - uint out_offset) + const uint ivector_offset, + const uint vector_index, + const uint out_offset) { const float3 vector = stack_load_float3(stack, ivector_offset); diff --git a/intern/cycles/kernel/svm/sky.h b/intern/cycles/kernel/svm/sky.h index 9fe0bffee1f..afa5b6473ef 100644 --- a/intern/cycles/kernel/svm/sky.h +++ b/intern/cycles/kernel/svm/sky.h @@ -16,7 +16,10 @@ CCL_NAMESPACE_BEGIN /* Sky texture */ -ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi) +ccl_device float sky_angle_between(const float thetav, + const float phiv, + const float theta, + const float phi) { const float cospsi = sinf(thetav) * sinf(theta) * cosf(phi - phiv) + cosf(thetav) * cosf(theta); return safe_acosf(cospsi); @@ -26,7 +29,9 @@ ccl_device float sky_angle_between(float thetav, float phiv, float theta, float * "A Practical Analytic Model for Daylight" * A. J. Preetham, Peter Shirley, Brian Smits */ -ccl_device float sky_perez_function(const ccl_private float *lam, float theta, float gamma) +ccl_device float sky_perez_function(const ccl_private float *lam, + const float theta, + const float gamma) { const float ctheta = cosf(theta); const float cgamma = cosf(gamma); @@ -36,12 +41,12 @@ ccl_device float sky_perez_function(const ccl_private float *lam, float theta, f } ccl_device float3 sky_radiance_preetham(KernelGlobals kg, - float3 dir, - float sunphi, - float suntheta, - float radiance_x, - float radiance_y, - float radiance_z, + const float3 dir, + const float sunphi, + const float suntheta, + const float radiance_x, + const float radiance_y, + const float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z) @@ -72,8 +77,8 @@ ccl_device float3 sky_radiance_preetham(KernelGlobals kg, * Lukas Hosek, Alexander Wilkie */ ccl_device float sky_radiance_internal(const ccl_private float *configuration, - float theta, - float gamma) + const float theta, + const float gamma) { const float ctheta = cosf(theta); const float cgamma = cosf(gamma); @@ -91,12 +96,12 @@ ccl_device float sky_radiance_internal(const ccl_private float *configuration, } ccl_device float3 sky_radiance_hosek(KernelGlobals kg, - float3 dir, - float sunphi, - float suntheta, - float radiance_x, - float radiance_y, - float radiance_z, + const float3 dir, + const float sunphi, + const float suntheta, + const float radiance_x, + const float radiance_y, + const float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z) @@ -122,18 +127,18 @@ ccl_device float3 sky_radiance_hosek(KernelGlobals kg, } /* Nishita improved sky model */ -ccl_device float3 geographical_to_direction(float lat, float lon) +ccl_device float3 geographical_to_direction(const float lat, const float lon) { return spherical_to_direction(lat - M_PI_2_F, lon - M_PI_2_F); } ccl_device float3 sky_radiance_nishita(KernelGlobals kg, - float3 dir, - uint32_t path_flag, - float3 pixel_bottom, - float3 pixel_top, + const float3 dir, + const uint32_t path_flag, + const float3 pixel_bottom, + const float3 pixel_top, const ccl_private float *nishita_data, - uint texture_id) + const uint texture_id) { /* definitions */ const float sun_elevation = nishita_data[0]; @@ -208,9 +213,9 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals kg, ccl_device_noinline int svm_node_tex_sky(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, ccl_private float *stack, - uint4 node, + const uint4 node, int offset) { /* Load data */ diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 997705cbc01..d806ee84bcf 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -101,7 +101,7 @@ ccl_device void svm_eval_nodes(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *sd, ccl_global float *render_buffer, - uint32_t path_flag) + const uint32_t path_flag) { float stack[SVM_STACK_SIZE]; Spectrum closure_weight; diff --git a/intern/cycles/kernel/svm/tex_coord.h b/intern/cycles/kernel/svm/tex_coord.h index d4ac8c8456e..279190fd77e 100644 --- a/intern/cycles/kernel/svm/tex_coord.h +++ b/intern/cycles/kernel/svm/tex_coord.h @@ -18,9 +18,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_tex_coord(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, ccl_private float *stack, - uint4 node, + const uint4 node, int offset) { float3 data = zero_float3(); @@ -107,9 +107,9 @@ ccl_device_noinline int svm_node_tex_coord(KernelGlobals kg, ccl_device_noinline int svm_node_tex_coord_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, ccl_private float *stack, - uint4 node, + const uint4 node, int offset) { #ifdef __RAY_DIFFERENTIALS__ @@ -200,9 +200,9 @@ ccl_device_noinline int svm_node_tex_coord_bump_dx(KernelGlobals kg, ccl_device_noinline int svm_node_tex_coord_bump_dy(KernelGlobals kg, ccl_private ShaderData *sd, - uint32_t path_flag, + const uint32_t path_flag, ccl_private float *stack, - uint4 node, + const uint4 node, int offset) { #ifdef __RAY_DIFFERENTIALS__ @@ -294,7 +294,7 @@ ccl_device_noinline int svm_node_tex_coord_bump_dy(KernelGlobals kg, ccl_device_noinline void svm_node_normal_map(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint color_offset; uint strength_offset; @@ -400,7 +400,7 @@ ccl_device_noinline void svm_node_normal_map(KernelGlobals kg, ccl_device_noinline void svm_node_tangent(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint tangent_offset; uint direction_type; diff --git a/intern/cycles/kernel/svm/value.h b/intern/cycles/kernel/svm/value.h index c22b38e66d0..4ecdf543ac7 100644 --- a/intern/cycles/kernel/svm/value.h +++ b/intern/cycles/kernel/svm/value.h @@ -13,8 +13,8 @@ CCL_NAMESPACE_BEGIN ccl_device void svm_node_value_f(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint ivalue, - uint out_offset) + const uint ivalue, + const uint out_offset) { stack_store_float(stack, out_offset, __uint_as_float(ivalue)); } @@ -22,7 +22,7 @@ ccl_device void svm_node_value_f(KernelGlobals kg, ccl_device int svm_node_value_v(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint out_offset, + const uint out_offset, int offset) { /* read extra data */ diff --git a/intern/cycles/kernel/svm/vector_rotate.h b/intern/cycles/kernel/svm/vector_rotate.h index d03c185b5af..c59910f1a75 100644 --- a/intern/cycles/kernel/svm/vector_rotate.h +++ b/intern/cycles/kernel/svm/vector_rotate.h @@ -12,9 +12,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_vector_rotate(ccl_private ShaderData *sd, ccl_private float *stack, - uint input_stack_offsets, - uint axis_stack_offsets, - uint result_stack_offset) + const uint input_stack_offsets, + const uint axis_stack_offsets, + const uint result_stack_offset) { uint type; uint vector_stack_offset; diff --git a/intern/cycles/kernel/svm/vector_transform.h b/intern/cycles/kernel/svm/vector_transform.h index 93221c8ce8f..ec8039a51c2 100644 --- a/intern/cycles/kernel/svm/vector_transform.h +++ b/intern/cycles/kernel/svm/vector_transform.h @@ -14,7 +14,7 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { uint itype; uint ifrom; diff --git a/intern/cycles/kernel/svm/vertex_color.h b/intern/cycles/kernel/svm/vertex_color.h index e2811575094..83780604dbc 100644 --- a/intern/cycles/kernel/svm/vertex_color.h +++ b/intern/cycles/kernel/svm/vertex_color.h @@ -13,9 +13,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_vertex_color(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint layer_id, - uint color_offset, - uint alpha_offset) + const uint layer_id, + const uint color_offset, + const uint alpha_offset) { const AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id); if (descriptor.offset != ATTR_STD_NOT_FOUND) { @@ -41,9 +41,9 @@ ccl_device_noinline void svm_node_vertex_color(KernelGlobals kg, ccl_device_noinline void svm_node_vertex_color_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint layer_id, - uint color_offset, - uint alpha_offset) + const uint layer_id, + const uint color_offset, + const uint alpha_offset) { const AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id); if (descriptor.offset != ATTR_STD_NOT_FOUND) { @@ -71,9 +71,9 @@ ccl_device_noinline void svm_node_vertex_color_bump_dx(KernelGlobals kg, ccl_device_noinline void svm_node_vertex_color_bump_dy(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint layer_id, - uint color_offset, - uint alpha_offset) + const uint layer_id, + const uint color_offset, + const uint alpha_offset) { const AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id); if (descriptor.offset != ATTR_STD_NOT_FOUND) { diff --git a/intern/cycles/kernel/svm/voronoi.h b/intern/cycles/kernel/svm/voronoi.h index 859158d85b3..b33516c1e97 100644 --- a/intern/cycles/kernel/svm/voronoi.h +++ b/intern/cycles/kernel/svm/voronoi.h @@ -1033,9 +1033,9 @@ template ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint dimensions, - uint feature, - uint metric, + const uint dimensions, + const uint feature, + const uint metric, int offset) { /* Read node defaults and stack offsets. */ diff --git a/intern/cycles/kernel/svm/voxel.h b/intern/cycles/kernel/svm/voxel.h index ad88f7e5189..374c8f98892 100644 --- a/intern/cycles/kernel/svm/voxel.h +++ b/intern/cycles/kernel/svm/voxel.h @@ -13,8 +13,11 @@ CCL_NAMESPACE_BEGIN * sampler. */ template -ccl_device_noinline int svm_node_tex_voxel( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_tex_voxel(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { uint co_offset; uint density_out_offset; diff --git a/intern/cycles/kernel/svm/wave.h b/intern/cycles/kernel/svm/wave.h index 256fe38cfb4..a49ce69f377 100644 --- a/intern/cycles/kernel/svm/wave.h +++ b/intern/cycles/kernel/svm/wave.h @@ -16,11 +16,11 @@ ccl_device_noinline_cpu float svm_wave(NodeWaveType type, NodeWaveRingsDirection rings_dir, NodeWaveProfile profile, float3 p, - float distortion, - float detail, - float dscale, - float droughness, - float phase) + const float distortion, + const float detail, + const float dscale, + const float droughness, + const float phase) { /* Prevent precision issues on unit coordinates. */ p = (p + 0.000001f) * 0.999999f; @@ -75,8 +75,11 @@ ccl_device_noinline_cpu float svm_wave(NodeWaveType type, return fabsf(n - floorf(n + 0.5f)) * 2.0f; } -ccl_device_noinline int svm_node_tex_wave( - KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset) +ccl_device_noinline int svm_node_tex_wave(KernelGlobals kg, + ccl_private ShaderData *sd, + ccl_private float *stack, + const uint4 node, + int offset) { const uint4 node2 = read_node(kg, &offset); const uint4 node3 = read_node(kg, &offset); diff --git a/intern/cycles/kernel/svm/wavelength.h b/intern/cycles/kernel/svm/wavelength.h index d9f04c7bc71..8fc230d9a88 100644 --- a/intern/cycles/kernel/svm/wavelength.h +++ b/intern/cycles/kernel/svm/wavelength.h @@ -19,8 +19,8 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_wavelength(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint wavelength, - uint color_out) + const uint wavelength, + const uint color_out) { const float lambda_nm = stack_load_float(stack, wavelength); diff --git a/intern/cycles/kernel/svm/white_noise.h b/intern/cycles/kernel/svm/white_noise.h index eb71c7bbb5d..2742f68bc97 100644 --- a/intern/cycles/kernel/svm/white_noise.h +++ b/intern/cycles/kernel/svm/white_noise.h @@ -12,9 +12,9 @@ CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_tex_white_noise(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint dimensions, - uint inputs_stack_offsets, - uint outputs_stack_offsets) + const uint dimensions, + const uint inputs_stack_offsets, + const uint outputs_stack_offsets) { uint vector_stack_offset; uint w_stack_offset; diff --git a/intern/cycles/kernel/svm/wireframe.h b/intern/cycles/kernel/svm/wireframe.h index 2a0faa97b81..1710d4f3434 100644 --- a/intern/cycles/kernel/svm/wireframe.h +++ b/intern/cycles/kernel/svm/wireframe.h @@ -20,8 +20,8 @@ CCL_NAMESPACE_BEGIN ccl_device_inline float wireframe(KernelGlobals kg, ccl_private ShaderData *sd, const differential3 dP, - float size, - int pixel_size, + const float size, + const int pixel_size, ccl_private float3 *P) { #if defined(__HAIR__) || defined(__POINTCLOUD__) @@ -81,7 +81,7 @@ ccl_device_inline float wireframe(KernelGlobals kg, ccl_device_noinline void svm_node_wireframe(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, - uint4 node) + const uint4 node) { const uint in_size = node.y; const uint out_fac = node.z; diff --git a/intern/cycles/kernel/util/colorspace.h b/intern/cycles/kernel/util/colorspace.h index b1d64e94fd7..c792cf42aad 100644 --- a/intern/cycles/kernel/util/colorspace.h +++ b/intern/cycles/kernel/util/colorspace.h @@ -10,19 +10,19 @@ CCL_NAMESPACE_BEGIN -ccl_device float3 xyz_to_rgb(KernelGlobals kg, float3 xyz) +ccl_device float3 xyz_to_rgb(KernelGlobals kg, const float3 xyz) { return make_float3(dot(make_float3(kernel_data.film.xyz_to_r), xyz), dot(make_float3(kernel_data.film.xyz_to_g), xyz), dot(make_float3(kernel_data.film.xyz_to_b), xyz)); } -ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, float3 xyz) +ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, const float3 xyz) { return max(xyz_to_rgb(kg, xyz), zero_float3()); } -ccl_device float3 rec709_to_rgb(KernelGlobals kg, float3 rec709) +ccl_device float3 rec709_to_rgb(KernelGlobals kg, const float3 rec709) { return (kernel_data.film.is_rec709) ? rec709 : @@ -31,12 +31,12 @@ ccl_device float3 rec709_to_rgb(KernelGlobals kg, float3 rec709) dot(make_float3(kernel_data.film.rec709_to_b), rec709)); } -ccl_device float linear_rgb_to_gray(KernelGlobals kg, float3 c) +ccl_device float linear_rgb_to_gray(KernelGlobals kg, const float3 c) { return dot(c, make_float3(kernel_data.film.rgb_to_y)); } -ccl_device_inline Spectrum rgb_to_spectrum(float3 rgb) +ccl_device_inline Spectrum rgb_to_spectrum(const float3 rgb) { return rgb; } diff --git a/intern/cycles/kernel/util/differential.h b/intern/cycles/kernel/util/differential.h index 88451119f4d..61338c2a08c 100644 --- a/intern/cycles/kernel/util/differential.h +++ b/intern/cycles/kernel/util/differential.h @@ -12,10 +12,10 @@ CCL_NAMESPACE_BEGIN ccl_device void differential_transfer(ccl_private differential3 *surface_dP, const differential3 ray_dP, - float3 ray_D, + const float3 ray_D, const differential3 ray_dD, - float3 surface_Ng, - float ray_t) + const float3 surface_Ng, + const float ray_t) { /* ray differential transfer through homogeneous medium, to * compute dPdx/dy at a shading point from the incoming ray */ @@ -42,7 +42,7 @@ ccl_device void differential_dudv(ccl_private differential *du, float3 dPdu, float3 dPdv, differential3 dP, - float3 Ng) + const float3 Ng) { /* now we have dPdx/dy from the ray differential transfer, and dPdu/dv * from the primitive, we can compute dudx/dy and dvdx/dy. these are @@ -152,10 +152,10 @@ ccl_device_forceinline differential3 differential_from_compact(const float3 D, c ccl_device void differential_dudv_compact(ccl_private differential *du, ccl_private differential *dv, - float3 dPdu, - float3 dPdv, - float dP, - float3 Ng) + const float3 dPdu, + const float3 dPdv, + const float dP, + const float3 Ng) { /* TODO: can we speed this up? */ differential_dudv(du, dv, dPdu, dPdv, differential_from_compact(Ng, dP), Ng); diff --git a/intern/cycles/kernel/util/ies.h b/intern/cycles/kernel/util/ies.h index 1aadf4417fc..ee09e526162 100644 --- a/intern/cycles/kernel/util/ies.h +++ b/intern/cycles/kernel/util/ies.h @@ -11,13 +11,13 @@ CCL_NAMESPACE_BEGIN /* IES Light */ ccl_device_inline float interpolate_ies_vertical(KernelGlobals kg, - int ofs, + const int ofs, const bool wrap_vlow, const bool wrap_vhigh, - int v, - int v_num, - float v_frac, - int h) + const int v, + const int v_num, + const float v_frac, + const int h) { /* Since lookups are performed in spherical coordinates, clamping the coordinates at the low end * of v (corresponding to the north pole) would result in artifacts. The proper way of dealing @@ -48,7 +48,10 @@ ccl_device_inline float interpolate_ies_vertical(KernelGlobals kg, return cubic_interp(a, b, c, d, v_frac); } -ccl_device_inline float kernel_ies_interp(KernelGlobals kg, int slot, float h_angle, float v_angle) +ccl_device_inline float kernel_ies_interp(KernelGlobals kg, + const int slot, + const float h_angle, + const float v_angle) { /* Find offset of the IES data in the table. */ int ofs = __float_as_int(kernel_data_fetch(ies, slot)); diff --git a/intern/cycles/kernel/util/lookup_table.h b/intern/cycles/kernel/util/lookup_table.h index 65ee209e313..f0eb5c7e95f 100644 --- a/intern/cycles/kernel/util/lookup_table.h +++ b/intern/cycles/kernel/util/lookup_table.h @@ -11,7 +11,7 @@ CCL_NAMESPACE_BEGIN /* Interpolated lookup table access */ -ccl_device float lookup_table_read(KernelGlobals kg, float x, int offset, int size) +ccl_device float lookup_table_read(KernelGlobals kg, float x, const int offset, const int size) { x = saturatef(x) * (size - 1); @@ -29,7 +29,7 @@ ccl_device float lookup_table_read(KernelGlobals kg, float x, int offset, int si } ccl_device float lookup_table_read_2D( - KernelGlobals kg, float x, float y, int offset, int xsize, int ysize) + KernelGlobals kg, const float x, float y, const int offset, const int xsize, const int ysize) { y = saturatef(y) * (ysize - 1); @@ -46,8 +46,14 @@ ccl_device float lookup_table_read_2D( return (1.0f - t) * data0 + t * data1; } -ccl_device float lookup_table_read_3D( - KernelGlobals kg, float x, float y, float z, int offset, int xsize, int ysize, int zsize) +ccl_device float lookup_table_read_3D(KernelGlobals kg, + const float x, + float y, + float z, + const int offset, + const int xsize, + const int ysize, + const int zsize) { z = saturatef(z) * (zsize - 1); diff --git a/intern/cycles/kernel/util/nanovdb.h b/intern/cycles/kernel/util/nanovdb.h index 2f6f1a96197..e8cbf97f2f6 100644 --- a/intern/cycles/kernel/util/nanovdb.h +++ b/intern/cycles/kernel/util/nanovdb.h @@ -51,7 +51,7 @@ template struct Mask { ccl_static_constexpr uint32_t WORD_COUNT = SIZE >> 6; uint64_t mWords[WORD_COUNT]; - ccl_device_inline_method bool isOff(uint32_t n) const ccl_global + ccl_device_inline_method bool isOff(const uint32_t n) const ccl_global { return 0 == (mWords[n >> 6] & (uint64_t(1) << (n & 63))); } @@ -164,7 +164,7 @@ template struct alignas(NANOVDB_DATA_ALIGNMENT) RootNode { /* InternalNode */ -template +template struct alignas(NANOVDB_DATA_ALIGNMENT) InternalNode { using ValueType = typename ChildT::ValueType; using BuildType = typename ChildT::BuildType; @@ -186,7 +186,7 @@ struct alignas(NANOVDB_DATA_ALIGNMENT) InternalNode { alignas(32) Tile mTable[1u << (3 * Log2Dim)]; - const ccl_device_inline_method ccl_global ChildT *getChild(uint32_t n) const ccl_global + const ccl_device_inline_method ccl_global ChildT *getChild(const uint32_t n) const ccl_global { return PtrAdd(this, mTable[n].child); } @@ -207,7 +207,7 @@ struct alignas(NANOVDB_DATA_ALIGNMENT) InternalNode { /* LeafData */ -template struct alignas(NANOVDB_DATA_ALIGNMENT) LeafData { +template struct alignas(NANOVDB_DATA_ALIGNMENT) LeafData { using ValueType = ValueT; using BuildType = ValueT; @@ -222,7 +222,7 @@ template struct alignas(NANOVDB_DATA_ALIGNMEN float mStdDevi; alignas(32) ValueType mValues[1u << 3 * LOG2DIM]; - ccl_device_inline_method ValueType getValue(uint32_t i) const ccl_global + ccl_device_inline_method ValueType getValue(const uint32_t i) const ccl_global { return mValues[i]; } @@ -252,7 +252,7 @@ template struct alignas(NANOVDB_DATA_ALIGNMENT) LeafData base; alignas(32) uint16_t mCode[1u << 3 * LOG2DIM]; - ccl_device_inline_method float getValue(uint32_t i) const ccl_global + ccl_device_inline_method float getValue(const uint32_t i) const ccl_global { return mCode[i] * base.mQuantum + base.mMinimum; } @@ -268,7 +268,7 @@ template struct alignas(NANOVDB_DATA_ALIGNMENT) LeafData base; - ccl_device_inline_method float getValue(uint32_t i) const ccl_global + ccl_device_inline_method float getValue(const uint32_t i) const ccl_global { const int b = base.mFlags >> 5; uint32_t code = reinterpret_cast(this + 1)[i >> (5 - b)]; @@ -280,7 +280,8 @@ template struct alignas(NANOVDB_DATA_ALIGNMENT) LeafData struct alignas(NANOVDB_DATA_ALIGNMENT) LeafNode { +template +struct alignas(NANOVDB_DATA_ALIGNMENT) LeafNode { using DataType = LeafData; using ValueType = typename DataType::ValueType; using BuildType = typename DataType::BuildType; @@ -299,7 +300,7 @@ template struct alignas(NANOVDB_DATA_ALIG return ((ijk.x & MASK) << (2 * LOG2DIM)) | ((ijk.y & MASK) << LOG2DIM) | (ijk.z & MASK); } - ccl_device_inline_method ValueType getValue(uint32_t offset) const ccl_global + ccl_device_inline_method ValueType getValue(const uint32_t offset) const ccl_global { return data.getValue(offset); } diff --git a/intern/cycles/scene/alembic.cpp b/intern/cycles/scene/alembic.cpp index 6bc383b5891..84fbd5c8558 100644 --- a/intern/cycles/scene/alembic.cpp +++ b/intern/cycles/scene/alembic.cpp @@ -245,7 +245,7 @@ size_t CachedData::memory_used() const return mem_used; } -static M44d convert_yup_zup(const M44d &mtx, float scale_mult) +static M44d convert_yup_zup(const M44d &mtx, const float scale_mult) { V3d scale; V3d shear; @@ -416,7 +416,7 @@ static void concatenate_xform_samples(const MatrixSampleMap &parent_samples, } } -static Transform make_transform(const M44d &a, float scale) +static Transform make_transform(const M44d &a, const float scale) { M44d m = convert_yup_zup(a, scale); Transform trans; @@ -724,7 +724,9 @@ AttributeRequestSet AlembicObject::get_requested_attributes() /* Update existing attributes and remove any attribute not in the cached_data, those attributes * were added by Cycles (e.g. face normals) */ -static void update_attributes(AttributeSet &attributes, CachedData &cached_data, double frame_time) +static void update_attributes(AttributeSet &attributes, + CachedData &cached_data, + const double frame_time) { set cached_attributes; diff --git a/intern/cycles/scene/alembic.h b/intern/cycles/scene/alembic.h index 35979deb9e8..364535daf8f 100644 --- a/intern/cycles/scene/alembic.h +++ b/intern/cycles/scene/alembic.h @@ -153,7 +153,7 @@ template class DataStore { /* Get the data for the specified time. * Return nullptr if there is no data or if the data for this time was already loaded. */ - CacheLookupResult data_for_time(double time) + CacheLookupResult data_for_time(const double time) { if (size() == 0) { return CacheLookupResult::no_data_found_for_time(); @@ -178,7 +178,7 @@ template class DataStore { /* get the data for the specified time, but do not check if the data was already loaded for this * time return nullptr if there is no data */ - CacheLookupResult data_for_time_no_check(double time) + CacheLookupResult data_for_time_no_check(const double time) { if (size() == 0) { return CacheLookupResult::no_data_found_for_time(); @@ -208,13 +208,13 @@ template class DataStore { data.push_back(data_); } - void reuse_data_for_last_time(double time) + void reuse_data_for_last_time(const double time) { const TimeIndexPair &data_index = index_data_map.back(); index_data_map.push_back({time, data_index.source_time, data_index.index}); } - void add_no_data(double time) + void add_no_data(const double time) { index_data_map.push_back({time, time, -1ul}); } @@ -243,7 +243,7 @@ template class DataStore { /* Copy the data for the specified time to the node's socket. If there is no * data for this time or it was already loaded, do nothing. */ - void copy_to_socket(double time, Node *node, const SocketType *socket) + void copy_to_socket(const double time, Node *node, const SocketType *socket) { CacheLookupResult result = data_for_time(time); @@ -273,7 +273,7 @@ template class DataStore { } private: - const TimeIndexPair &get_index_for_time(double time) const + const TimeIndexPair &get_index_for_time(const double time) const { std::pair index_pair; index_pair = time_sampling.getNearIndex(time, index_data_map.size()); @@ -445,7 +445,7 @@ class AlembicObject : public Node { CachedData cached_data_; - void setup_transform_cache(CachedData &cached_data, float scale); + void setup_transform_cache(CachedData &cached_data, const float scale); AttributeRequestSet get_requested_attributes(); }; diff --git a/intern/cycles/scene/alembic_read.cpp b/intern/cycles/scene/alembic_read.cpp index 0b3047db047..3a92bbce1ba 100644 --- a/intern/cycles/scene/alembic_read.cpp +++ b/intern/cycles/scene/alembic_read.cpp @@ -25,7 +25,7 @@ static float3 make_float3_from_yup(const V3f &v) /* get the sample times to load data for the given the start and end frame of the procedural */ static set get_relevant_sample_times(AlembicProcedural *proc, const TimeSampling &time_sampling, - size_t num_samples) + const size_t num_samples) { set result; @@ -90,7 +90,7 @@ static void read_data_loop(AlembicProcedural *proc, /* Compute the vertex normals in case none are present in the IPolyMeshSchema, this is mostly used * to avoid computing them in the GeometryManager in order to speed up data updates. */ -static void compute_vertex_normals(CachedData &cache, double current_time) +static void compute_vertex_normals(CachedData &cache, const double current_time) { if (cache.vertices.size() == 0) { return; @@ -139,7 +139,7 @@ static void compute_vertex_normals(CachedData &cache, double current_time) static void add_normals(const Int32ArraySamplePtr face_indices, const IN3fGeomParam &normals, - double time, + const double time, CachedData &cached_data) { switch (normals.getScope()) { @@ -219,7 +219,9 @@ static void add_normals(const Int32ArraySamplePtr face_indices, } } -static void add_positions(const P3fArraySamplePtr positions, double time, CachedData &cached_data) +static void add_positions(const P3fArraySamplePtr positions, + const double time, + CachedData &cached_data) { if (!positions) { return; @@ -238,7 +240,7 @@ static void add_positions(const P3fArraySamplePtr positions, double time, Cached static void add_triangles(const Int32ArraySamplePtr face_counts, const Int32ArraySamplePtr face_indices, - double time, + const double time, CachedData &cached_data, const array &polygon_to_shader) { @@ -751,7 +753,7 @@ static void process_attribute(CachedData &cache, CachedData::CachedAttribute &attribute, GeometryScope scope, const typename ITypedGeomParam::Sample &sample, - double time) + const double time) { using abc_type = typename TRAIT::value_type; using cycles_type = typename value_type_converter::cycles_type; @@ -819,7 +821,7 @@ static void process_uvs(CachedData &cache, CachedData::CachedAttribute &attribute, GeometryScope scope, const IV2fGeomParam::Sample &sample, - double time) + const double time) { if (scope != kFacevaryingScope && scope != kVaryingScope && scope != kVertexScope) { return; diff --git a/intern/cycles/scene/attribute.cpp b/intern/cycles/scene/attribute.cpp index 8755181ea98..2461d90d4ee 100644 --- a/intern/cycles/scene/attribute.cpp +++ b/intern/cycles/scene/attribute.cpp @@ -15,8 +15,11 @@ CCL_NAMESPACE_BEGIN /* Attribute */ -Attribute::Attribute( - ustring name, TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim) +Attribute::Attribute(ustring name, + const TypeDesc type, + AttributeElement element, + Geometry *geom, + AttributePrimitive prim) : name(name), std(ATTR_STD_NONE), type(type), element(element), flags(0), modified(true) { /* string and matrix not supported! */ @@ -54,7 +57,7 @@ void Attribute::resize(Geometry *geom, AttributePrimitive prim, bool reserve_onl } } -void Attribute::resize(size_t num_elements) +void Attribute::resize(const size_t num_elements) { if (element != ATTR_ELEMENT_VOXEL) { buffer.resize(num_elements * data_sizeof(), 0); @@ -283,7 +286,7 @@ size_t Attribute::buffer_size(Geometry *geom, AttributePrimitive prim) const return element_size(geom, prim) * data_sizeof(); } -bool Attribute::same_storage(TypeDesc a, TypeDesc b) +bool Attribute::same_storage(const TypeDesc a, const TypeDesc b) { if (a == b) { return true; @@ -302,7 +305,7 @@ void Attribute::zero_data(void *dst) memset(dst, 0, data_sizeof()); } -void Attribute::add_with_weight(void *dst, void *src, float weight) +void Attribute::add_with_weight(void *dst, void *src, const float weight) { if (element == ATTR_ELEMENT_CORNER_BYTE) { for (int i = 0; i < 4; i++) { @@ -474,7 +477,7 @@ AttributeSet::AttributeSet(Geometry *geometry, AttributePrimitive prim) AttributeSet::~AttributeSet() = default; -Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement element) +Attribute *AttributeSet::add(ustring name, const TypeDesc type, AttributeElement element) { Attribute *attr = find(name); diff --git a/intern/cycles/scene/attribute.h b/intern/cycles/scene/attribute.h index 143e5e167d2..db1fe3ae5e3 100644 --- a/intern/cycles/scene/attribute.h +++ b/intern/cycles/scene/attribute.h @@ -54,7 +54,7 @@ class Attribute { bool modified; Attribute(ustring name, - TypeDesc type, + const TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim); @@ -63,9 +63,9 @@ class Attribute { Attribute &operator=(const Attribute &other) = delete; ~Attribute(); - void set(ustring name, TypeDesc type, AttributeElement element); + void set(ustring name, const TypeDesc type, AttributeElement element); void resize(Geometry *geom, AttributePrimitive prim, bool reserve_only); - void resize(size_t num_elements); + void resize(const size_t num_elements); size_t data_sizeof() const; size_t element_size(Geometry *geom, AttributePrimitive prim) const; @@ -149,7 +149,7 @@ class Attribute { } void zero_data(void *dst); - void add_with_weight(void *dst, void *src, float weight); + void add_with_weight(void *dst, void *src, const float weight); void add(const float &f); void add(const float2 &f); @@ -160,7 +160,7 @@ class Attribute { void set_data_from(Attribute &&other); - static bool same_storage(TypeDesc a, TypeDesc b); + static bool same_storage(const TypeDesc a, const TypeDesc b); static const char *standard_name(AttributeStandard std); static AttributeStandard name_standard(const char *name); @@ -185,7 +185,7 @@ class AttributeSet { AttributeSet(AttributeSet &&) = default; ~AttributeSet(); - Attribute *add(ustring name, TypeDesc type, AttributeElement element); + Attribute *add(ustring name, const TypeDesc type, AttributeElement element); Attribute *find(ustring name) const; void remove(ustring name); diff --git a/intern/cycles/scene/camera.cpp b/intern/cycles/scene/camera.cpp index 19c82d980e3..d0386273699 100644 --- a/intern/cycles/scene/camera.cpp +++ b/intern/cycles/scene/camera.cpp @@ -504,7 +504,7 @@ void Camera::device_update(Device * /*device*/, DeviceScene *dscene, Scene *scen SHUTTER_TABLE_SIZE, 0.0f, 1.0f, - [this](float x) { return shutter_curve_eval(x, shutter_curve); }, + [this](const float x) { return shutter_curve_eval(x, shutter_curve); }, false, shutter_table); shutter_table_offset = scene->lookup_tables->add_table(dscene, shutter_table); @@ -568,7 +568,7 @@ void Camera::device_free(Device * /*device*/, DeviceScene *dscene, Scene *scene) dscene->camera_motion.free(); } -float3 Camera::transform_raster_to_world(float raster_x, float raster_y) +float3 Camera::transform_raster_to_world(const float raster_x, const float raster_y) { float3 D; float3 P; @@ -673,7 +673,7 @@ BoundBox Camera::viewplane_bounds_get() return bounds; } -float Camera::world_to_raster_size(float3 P) +float Camera::world_to_raster_size(const float3 P) { float res = 1.0f; @@ -824,7 +824,7 @@ bool Camera::use_motion() const return motion.size() > 1; } -void Camera::set_screen_size(int width_, int height_) +void Camera::set_screen_size(const int width_, int height_) { if (width_ != width || height_ != height) { width = width_; @@ -833,12 +833,12 @@ void Camera::set_screen_size(int width_, int height_) } } -float Camera::motion_time(int step) const +float Camera::motion_time(const int step) const { return (use_motion()) ? 2.0f * step / (motion.size() - 1) - 1.0f : 0.0f; } -int Camera::motion_step(float time) const +int Camera::motion_step(const float time) const { if (use_motion()) { for (int step = 0; step < motion.size(); step++) { diff --git a/intern/cycles/scene/camera.h b/intern/cycles/scene/camera.h index c87142f1e4c..ff36fbbba10 100644 --- a/intern/cycles/scene/camera.h +++ b/intern/cycles/scene/camera.h @@ -202,18 +202,18 @@ class Camera : public Node { BoundBox viewplane_bounds_get(); /* Calculates the width of a pixel at point in world space. */ - float world_to_raster_size(float3 P); + float world_to_raster_size(const float3 P); /* Motion blur. */ - float motion_time(int step) const; - int motion_step(float time) const; + float motion_time(const int step) const; + int motion_step(const float time) const; bool use_motion() const; - void set_screen_size(int width_, int height_); + void set_screen_size(const int width_, int height_); private: /* Private utility functions. */ - float3 transform_raster_to_world(float raster_x, float raster_y); + float3 transform_raster_to_world(const float raster_x, const float raster_y); }; CCL_NAMESPACE_END diff --git a/intern/cycles/scene/colorspace.cpp b/intern/cycles/scene/colorspace.cpp index 6fe8a564bec..226d410213e 100644 --- a/intern/cycles/scene/colorspace.cpp +++ b/intern/cycles/scene/colorspace.cpp @@ -271,7 +271,7 @@ template inline float4 cast_to_float4(T *data) util_image_cast_to_float(data[3])); } -template inline void cast_from_float4(T *data, float4 value) +template inline void cast_from_float4(T *data, const float4 value) { data[0] = util_image_cast_from_float(value.x); data[1] = util_image_cast_from_float(value.y); @@ -283,7 +283,7 @@ template inline void cast_from_float4(T *data, float4 value) template inline void processor_apply_pixels_rgba(const OCIO::Processor *processor, T *pixels, - size_t num_pixels) + const size_t num_pixels) { /* TODO: implement faster version for when we know the conversion * is a simple matrix transform between linear spaces. In that case @@ -334,7 +334,7 @@ inline void processor_apply_pixels_rgba(const OCIO::Processor *processor, template inline void processor_apply_pixels_grayscale(const OCIO::Processor *processor, T *pixels, - size_t num_pixels) + const size_t num_pixels) { const OCIO::ConstCPUProcessorRcPtr device_processor = processor->getDefaultCPUProcessor(); @@ -378,7 +378,7 @@ inline void processor_apply_pixels_grayscale(const OCIO::Processor *processor, template void ColorSpaceManager::to_scene_linear( - ustring colorspace, T *pixels, size_t num_pixels, bool is_rgba, bool compress_as_srgb) + ustring colorspace, T *pixels, const size_t num_pixels, bool is_rgba, bool compress_as_srgb) { #ifdef WITH_OCIO const OCIO::Processor *processor = (const OCIO::Processor *)get_processor(colorspace); @@ -416,7 +416,7 @@ void ColorSpaceManager::to_scene_linear( void ColorSpaceManager::to_scene_linear(ColorSpaceProcessor *processor_, float *pixel, - int channels) + const int channels) { #ifdef WITH_OCIO const OCIO::Processor *processor = (const OCIO::Processor *)processor_; diff --git a/intern/cycles/scene/colorspace.h b/intern/cycles/scene/colorspace.h index 4cc2893b882..9d6c6479a0f 100644 --- a/intern/cycles/scene/colorspace.h +++ b/intern/cycles/scene/colorspace.h @@ -31,13 +31,13 @@ class ColorSpaceManager { * rendering. Must be a colorspace returned from detect_known_colorspace. */ template static void to_scene_linear( - ustring colorspace, T *pixels, size_t num_pixels, bool is_rgba, bool compress_as_srgb); + ustring colorspace, T *pixels, const size_t num_pixels, bool is_rgba, bool compress_as_srgb); /* Efficiently convert pixels to scene linear colorspace at render time, * for OSL where the image texture cache contains original pixels. The * handle is valid for the lifetime of the application. */ static ColorSpaceProcessor *get_processor(ustring colorspace); - static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, int channels); + static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, const int channels); /* Clear memory when the application exits. Invalidates all processors. */ static void free_memory(); diff --git a/intern/cycles/scene/constant_fold.cpp b/intern/cycles/scene/constant_fold.cpp index 96fb286686d..235a9a1613c 100644 --- a/intern/cycles/scene/constant_fold.cpp +++ b/intern/cycles/scene/constant_fold.cpp @@ -28,7 +28,7 @@ bool ConstantFolder::all_inputs_constant() const return true; } -void ConstantFolder::make_constant(float value) const +void ConstantFolder::make_constant(const float value) const { VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value << ")."; @@ -41,7 +41,7 @@ void ConstantFolder::make_constant(float value) const graph->disconnect(output); } -void ConstantFolder::make_constant(float3 value) const +void ConstantFolder::make_constant(const float3 value) const { VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant " << value << "."; @@ -54,7 +54,7 @@ void ConstantFolder::make_constant(float3 value) const graph->disconnect(output); } -void ConstantFolder::make_constant(int value) const +void ConstantFolder::make_constant(const int value) const { VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value << ")."; @@ -67,12 +67,12 @@ void ConstantFolder::make_constant(int value) const graph->disconnect(output); } -void ConstantFolder::make_constant_clamp(float value, bool clamp) const +void ConstantFolder::make_constant_clamp(const float value, bool clamp) const { make_constant(clamp ? saturatef(value) : value); } -void ConstantFolder::make_constant_clamp(float3 value, bool clamp) const +void ConstantFolder::make_constant_clamp(float3 value, const bool clamp) const { if (clamp) { value.x = saturatef(value.x); diff --git a/intern/cycles/scene/constant_fold.h b/intern/cycles/scene/constant_fold.h index 2c7b967ec52..4dd7503bab5 100644 --- a/intern/cycles/scene/constant_fold.h +++ b/intern/cycles/scene/constant_fold.h @@ -28,11 +28,11 @@ class ConstantFolder { bool all_inputs_constant() const; /* Constant folding helpers */ - void make_constant(float value) const; - void make_constant(float3 value) const; - void make_constant(int value) const; - void make_constant_clamp(float value, bool clamp) const; - void make_constant_clamp(float3 value, bool clamp) const; + void make_constant(const float value) const; + void make_constant(const float3 value) const; + void make_constant(const int value) const; + void make_constant_clamp(const float value, bool clamp) const; + void make_constant_clamp(const float3 value, bool clamp) const; void make_zero() const; void make_one() const; diff --git a/intern/cycles/scene/curves.cpp b/intern/cycles/scene/curves.cpp index 849ea98ab80..0b1620112b3 100644 --- a/intern/cycles/scene/curves.cpp +++ b/intern/cycles/scene/curves.cpp @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN /* Curve functions */ -void curvebounds(float *lower, float *upper, float3 *p, int dim) +void curvebounds(float *lower, float *upper, float3 *p, const int dim) { float *p0 = &p[0].x; float *p1 = &p[1].x; diff --git a/intern/cycles/scene/curves.h b/intern/cycles/scene/curves.h index 65100aacb4a..2d572636b85 100644 --- a/intern/cycles/scene/curves.h +++ b/intern/cycles/scene/curves.h @@ -14,7 +14,7 @@ class DeviceScene; class Progress; class Scene; -void curvebounds(float *lower, float *upper, float3 *p, int dim); +void curvebounds(float *lower, float *upper, float3 *p, const int dim); class ParticleCurveData { diff --git a/intern/cycles/scene/film.cpp b/intern/cycles/scene/film.cpp index 1b69a5e13ac..e5dd23daf9f 100644 --- a/intern/cycles/scene/film.cpp +++ b/intern/cycles/scene/film.cpp @@ -29,13 +29,13 @@ static float filter_func_box(float /*v*/, float /*width*/) return 1.0f; } -static float filter_func_gaussian(float v, float width) +static float filter_func_gaussian(float v, const float width) { v *= 6.0f / width; return expf(-2.0f * v * v); } -static float filter_func_blackman_harris(float v, float width) +static float filter_func_blackman_harris(float v, const float width) { v = M_2PI_F * (v / width + 0.5f); return 0.35875f - 0.48829f * cosf(v) + 0.14128f * cosf(2.0f * v) - 0.01168f * cosf(3.0f * v); @@ -77,7 +77,7 @@ static vector filter_table(FilterType type, float width) FILTER_TABLE_SIZE, 0.0f, width * 0.5f, - [filter_func, width](float x) { return filter_func(x, width); }, + [filter_func, width](const float x) { return filter_func(x, width); }, true, filter_table); diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index d516e3ed90d..fd023c1d2bf 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -84,12 +84,12 @@ void Geometry::clear(bool preserve_shaders) tag_modified(); } -float Geometry::motion_time(int step) const +float Geometry::motion_time(const int step) const { return (motion_steps > 1) ? 2.0f * step / (motion_steps - 1) - 1.0f : 0.0f; } -int Geometry::motion_step(float time) const +int Geometry::motion_step(const float time) const { if (motion_steps > 1) { int attr_step = 0; @@ -1109,7 +1109,7 @@ void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool forc #endif } -void GeometryManager::tag_update(Scene *scene, uint32_t flag) +void GeometryManager::tag_update(Scene *scene, const uint32_t flag) { update_flags |= flag; diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index bf69f3b6616..595da7eaee5 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -134,15 +134,15 @@ class Geometry : public Node { /* Convert between normalized -1..1 motion time and index in the * VERTEX_MOTION attribute. */ - float motion_time(int step) const; - int motion_step(float time) const; + float motion_time(const int step) const; + int motion_step(const float time) const; /* BVH */ void compute_bvh(Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, - size_t n, + const size_t n, size_t total); virtual PrimitiveType primitive_type() const = 0; @@ -238,7 +238,7 @@ class GeometryManager { void device_free(Device *device, DeviceScene *dscene, bool force_free); /* Updates */ - void tag_update(Scene *scene, uint32_t flag); + void tag_update(Scene *scene, const uint32_t flag); bool need_update() const; diff --git a/intern/cycles/scene/geometry_attributes.cpp b/intern/cycles/scene/geometry_attributes.cpp index 560824d00dc..b1d8b1926c9 100644 --- a/intern/cycles/scene/geometry_attributes.cpp +++ b/intern/cycles/scene/geometry_attributes.cpp @@ -85,9 +85,9 @@ bool Geometry::has_voxel_attributes() const /* Generate a normal attribute map entry from an attribute descriptor. */ static void emit_attribute_map_entry(AttributeMap *attr_map, - size_t index, - uint64_t id, - TypeDesc type, + const size_t index, + const uint64_t id, + const TypeDesc type, const AttributeDescriptor &desc) { attr_map[index].id = id; @@ -119,9 +119,9 @@ static void emit_attribute_map_entry(AttributeMap *attr_map, /* Generate an attribute map end marker, optionally including a link to another map. * Links are used to connect object attribute maps to mesh attribute maps. */ static void emit_attribute_map_terminator(AttributeMap *attr_map, - size_t index, + const size_t index, bool chain, - uint chain_link) + const uint chain_link) { for (int j = 0; j < ATTR_PRIM_TYPES; j++) { attr_map[index + j].id = ATTR_STD_NONE; @@ -133,8 +133,11 @@ static void emit_attribute_map_terminator(AttributeMap *attr_map, } /* Generate all necessary attribute map entries from the attribute request. */ -static void emit_attribute_mapping( - AttributeMap *attr_map, size_t index, uint64_t id, AttributeRequest &req, Geometry *geom) +static void emit_attribute_mapping(AttributeMap *attr_map, + const size_t index, + const uint64_t id, + AttributeRequest &req, + Geometry *geom) { emit_attribute_map_entry(attr_map, index, id, req.type, req.desc); diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 10d76107127..702140e0719 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -26,8 +26,8 @@ void Geometry::compute_bvh(Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, - size_t n, - size_t total) + const size_t n, + const size_t total) { if (progress->get_cancel()) { return; diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp index bb08bcd5561..d3d3aaa53b0 100644 --- a/intern/cycles/scene/hair.cpp +++ b/intern/cycles/scene/hair.cpp @@ -97,7 +97,7 @@ void Hair::Curve::bounds_grow(const int k, bounds.grow(upper, mr); } -void Hair::Curve::bounds_grow(float4 keys[4], BoundBox &bounds) const +void Hair::Curve::bounds_grow(const float4 keys[4], BoundBox &bounds) const { float3 P[4] = { make_float3(keys[0]), @@ -122,9 +122,9 @@ void Hair::Curve::bounds_grow(float4 keys[4], BoundBox &bounds) const void Hair::Curve::motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - float time, + const size_t num_curve_keys, + const size_t num_steps, + const float time, size_t k0, size_t k1, float4 r_keys[2]) const @@ -148,9 +148,9 @@ void Hair::Curve::motion_keys(const float3 *curve_keys, void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - float time, + const size_t num_curve_keys, + const size_t num_steps, + const float time, size_t k0, size_t k1, size_t k2, @@ -196,8 +196,8 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, void Hair::Curve::keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, + const size_t num_curve_keys, + const size_t num_steps, size_t step, size_t k0, size_t k1, @@ -231,8 +231,8 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys, void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, + const size_t num_curve_keys, + const size_t num_steps, size_t step, size_t k0, size_t k1, @@ -298,7 +298,7 @@ Hair::Hair() : Geometry(get_node_type(), Geometry::HAIR) Hair::~Hair() = default; -void Hair::resize_curves(int numcurves, int numkeys) +void Hair::resize_curves(const int numcurves, const int numkeys) { curve_keys.resize(numkeys); curve_radius.resize(numkeys); @@ -308,7 +308,7 @@ void Hair::resize_curves(int numcurves, int numkeys) attributes.resize(); } -void Hair::reserve_curves(int numcurves, int numkeys) +void Hair::reserve_curves(const int numcurves, const int numkeys) { curve_keys.reserve(numkeys); curve_radius.reserve(numkeys); @@ -330,7 +330,7 @@ void Hair::clear(bool preserve_shaders) attributes.clear(); } -void Hair::add_curve_key(float3 co, float radius) +void Hair::add_curve_key(const float3 co, const float radius) { curve_keys.push_back_reserved(co); curve_radius.push_back_reserved(radius); @@ -339,7 +339,7 @@ void Hair::add_curve_key(float3 co, float radius) tag_curve_radius_modified(); } -void Hair::add_curve(int first_key, int shader) +void Hair::add_curve(const int first_key, const int shader) { curve_first_key.push_back_reserved(first_key); curve_shader.push_back_reserved(shader); diff --git a/intern/cycles/scene/hair.h b/intern/cycles/scene/hair.h index e385be300ff..ebf53109519 100644 --- a/intern/cycles/scene/hair.h +++ b/intern/cycles/scene/hair.h @@ -29,8 +29,8 @@ class Hair : public Geometry { const float *curve_radius, BoundBox &bounds) const; void bounds_grow(const int k, const float4 *keys, BoundBox &bounds) const; - void bounds_grow(float4 keys[4], BoundBox &bounds) const; - void bounds_grow(float3 keys[4], BoundBox &bounds) const; + void bounds_grow(const float4 keys[4], BoundBox &bounds) const; + void bounds_grow(const float3 keys[4], BoundBox &bounds) const; void bounds_grow(const int k, const float3 *curve_keys, const float *curve_radius, @@ -40,18 +40,18 @@ class Hair : public Geometry { void motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - float time, + const size_t num_curve_keys, + const size_t num_steps, + const float time, size_t k0, size_t k1, float4 r_keys[2]) const; void cardinal_motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - float time, + const size_t num_curve_keys, + const size_t num_steps, + const float time, size_t k0, size_t k1, size_t k2, @@ -61,18 +61,18 @@ class Hair : public Geometry { void keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - size_t step, + const size_t num_curve_keys, + const size_t num_steps, + const size_t step, size_t k0, size_t k1, float4 r_keys[2]) const; void cardinal_keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, - size_t num_curve_keys, - size_t num_steps, - size_t step, + const size_t num_curve_keys, + const size_t num_steps, + const size_t step, size_t k0, size_t k1, size_t k2, @@ -97,10 +97,10 @@ class Hair : public Geometry { /* Geometry */ void clear(bool preserve_shaders = false) override; - void resize_curves(int numcurves, int numkeys); - void reserve_curves(int numcurves, int numkeys); - void add_curve_key(float3 co, float radius); - void add_curve(int first_key, int shader); + void resize_curves(const int numcurves, const int numkeys); + void reserve_curves(const int numcurves, const int numkeys); + void add_curve_key(const float3 co, const float radius); + void add_curve(const int first_key, const int shader); void copy_center_to_motion_step(const int motion_step); @@ -108,7 +108,7 @@ class Hair : public Geometry { void apply_transform(const Transform &tfm, const bool apply_to_motion) override; /* Curves */ - Curve get_curve(size_t i) const + Curve get_curve(const size_t i) const { const int first = curve_first_key[i]; const int next_first = (i + 1 < curve_first_key.size()) ? curve_first_key[i + 1] : diff --git a/intern/cycles/scene/image.cpp b/intern/cycles/scene/image.cpp index b0a0bfb57fe..f3a73a22765 100644 --- a/intern/cycles/scene/image.cpp +++ b/intern/cycles/scene/image.cpp @@ -321,7 +321,7 @@ void ImageManager::set_osl_texture_system(void *texture_system) osl_texture_system = texture_system; } -bool ImageManager::set_animation_frame_update(int frame) +bool ImageManager::set_animation_frame_update(const int frame) { if (frame != animation_frame) { const thread_scoped_lock device_lock(images_mutex); @@ -477,7 +477,7 @@ size_t ImageManager::add_image_slot(ImageLoader *loader, return slot; } -void ImageManager::add_image_user(size_t slot) +void ImageManager::add_image_user(const size_t slot) { const thread_scoped_lock device_lock(images_mutex); Image *image = images[slot]; @@ -486,7 +486,7 @@ void ImageManager::add_image_user(size_t slot) image->users++; } -void ImageManager::remove_image_user(size_t slot) +void ImageManager::remove_image_user(const size_t slot) { const thread_scoped_lock device_lock(images_mutex); Image *image = images[slot]; @@ -513,7 +513,7 @@ static bool image_associate_alpha(ImageManager::Image *img) } template -bool ImageManager::file_load_image(Image *img, int texture_limit) +bool ImageManager::file_load_image(Image *img, const int texture_limit) { /* Ignore empty images. */ if (!(img->metadata.channels > 0)) { @@ -672,7 +672,10 @@ bool ImageManager::file_load_image(Image *img, int texture_limit) return true; } -void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, Progress &progress) +void ImageManager::device_load_image(Device *device, + Scene *scene, + const size_t slot, + Progress &progress) { if (progress.get_cancel()) { return; @@ -868,7 +871,7 @@ void ImageManager::device_update(Device *device, Scene *scene, Progress &progres void ImageManager::device_update_slot(Device *device, Scene *scene, - size_t slot, + const size_t slot, Progress &progress) { Image *img = images[slot]; diff --git a/intern/cycles/scene/image.h b/intern/cycles/scene/image.h index eab1e887fd5..cc185aa49cd 100644 --- a/intern/cycles/scene/image.h +++ b/intern/cycles/scene/image.h @@ -170,14 +170,14 @@ class ImageManager { ImageHandle add_image(const vector &loaders, const ImageParams ¶ms); void device_update(Device *device, Scene *scene, Progress &progress); - void device_update_slot(Device *device, Scene *scene, size_t slot, Progress &progress); + void device_update_slot(Device *device, Scene *scene, const size_t slot, Progress &progress); void device_free(Device *device); void device_load_builtin(Device *device, Scene *scene, Progress &progress); void device_free_builtin(Device *device); void set_osl_texture_system(void *texture_system); - bool set_animation_frame_update(int frame); + bool set_animation_frame_update(const int frame); void collect_statistics(RenderStats *stats); @@ -215,16 +215,16 @@ class ImageManager { void *osl_texture_system; size_t add_image_slot(ImageLoader *loader, const ImageParams ¶ms, const bool builtin); - void add_image_user(size_t slot); - void remove_image_user(size_t slot); + void add_image_user(const size_t slot); + void remove_image_user(const size_t slot); void load_image_metadata(Image *img); template - bool file_load_image(Image *img, int texture_limit); + bool file_load_image(Image *img, const int texture_limit); - void device_load_image(Device *device, Scene *scene, size_t slot, Progress &progress); - void device_free_image(Device *device, size_t slot); + void device_load_image(Device *device, Scene *scene, const size_t slot, Progress &progress); + void device_free_image(Device *device, const size_t slot); friend class ImageHandle; }; diff --git a/intern/cycles/scene/image_sky.cpp b/intern/cycles/scene/image_sky.cpp index 97e41a466cc..18d590f3cc0 100644 --- a/intern/cycles/scene/image_sky.cpp +++ b/intern/cycles/scene/image_sky.cpp @@ -10,11 +10,11 @@ CCL_NAMESPACE_BEGIN -SkyLoader::SkyLoader(float sun_elevation, - float altitude, - float air_density, - float dust_density, - float ozone_density) +SkyLoader::SkyLoader(const float sun_elevation, + const float altitude, + const float air_density, + const float dust_density, + const float ozone_density) : sun_elevation(sun_elevation), altitude(altitude), air_density(air_density), diff --git a/intern/cycles/scene/image_sky.h b/intern/cycles/scene/image_sky.h index dc0b41166ce..209f843f2d2 100644 --- a/intern/cycles/scene/image_sky.h +++ b/intern/cycles/scene/image_sky.h @@ -15,10 +15,10 @@ class SkyLoader : public ImageLoader { float ozone_density; public: - SkyLoader(float sun_elevation, - float altitude, - float air_density, - float dust_density, + SkyLoader(const float sun_elevation, + const float altitude, + const float air_density, + const float dust_density, float ozone_density); ~SkyLoader() override; diff --git a/intern/cycles/scene/image_vdb.cpp b/intern/cycles/scene/image_vdb.cpp index a98bb0208ed..64d8bbb0600 100644 --- a/intern/cycles/scene/image_vdb.cpp +++ b/intern/cycles/scene/image_vdb.cpp @@ -27,7 +27,7 @@ CCL_NAMESPACE_BEGIN struct NumChannelsOp { int num_channels = 0; - template + template bool operator()(const openvdb::GridBase::ConstPtr & /*unused*/) { num_channels = channels; @@ -39,7 +39,7 @@ struct ToDenseOp { openvdb::CoordBBox bbox; void *pixels; - template + template bool operator()(const openvdb::GridBase::ConstPtr &grid) { openvdb::tools::Dense dense(bbox, @@ -54,7 +54,7 @@ struct ToNanoOp { nanovdb::GridHandle<> nanogrid; int precision; - template + template bool operator()(const openvdb::GridBase::ConstPtr &grid) { if constexpr (!std::is_same_v) { diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index f375efaa1bd..06c3a64d102 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -342,7 +342,7 @@ void Integrator::device_free(Device * /*unused*/, DeviceScene *dscene, bool forc dscene->sample_pattern_lut.free_if_need_realloc(force_free); } -void Integrator::tag_update(Scene *scene, uint32_t flag) +void Integrator::tag_update(Scene *scene, const uint32_t flag) { if (flag & UPDATE_ALL) { tag_modified(); diff --git a/intern/cycles/scene/integrator.h b/intern/cycles/scene/integrator.h index 685eead4c72..e29311e077e 100644 --- a/intern/cycles/scene/integrator.h +++ b/intern/cycles/scene/integrator.h @@ -116,7 +116,7 @@ class Integrator : public Node { void device_update(Device *device, DeviceScene *dscene, Scene *scene); void device_free(Device *device, DeviceScene *dscene, bool force_free = false); - void tag_update(Scene *scene, uint32_t flag); + void tag_update(Scene *scene, const uint32_t flag); uint get_kernel_features() const; diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 047071459d9..27297ebc04f 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -28,8 +28,8 @@ CCL_NAMESPACE_BEGIN static void shade_background_pixels(Device *device, DeviceScene *dscene, - int width, - int height, + const int width, + const int height, vector &pixels, Progress &progress) { @@ -902,8 +902,12 @@ void LightManager::device_update_tree(Device * /*unused*/, dscene->triangle_to_tree.copy_to_device(); } -static void background_cdf( - int start, int end, int res_x, int res_y, const vector *pixels, float2 *cond_cdf) +static void background_cdf(int start, + const int end, + const int res_x, + const int res_y, + const vector *pixels, + float2 *cond_cdf) { const int cdf_width = res_x + 1; /* Conditional CDFs (rows, U direction). */ @@ -1543,7 +1547,7 @@ int LightManager::add_ies(const string &content) return slot; } -void LightManager::remove_ies(int slot) +void LightManager::remove_ies(const int slot) { const thread_scoped_lock ies_lock(ies_mutex); diff --git a/intern/cycles/scene/light.h b/intern/cycles/scene/light.h index abae510a299..7a3d6c6946e 100644 --- a/intern/cycles/scene/light.h +++ b/intern/cycles/scene/light.h @@ -122,12 +122,12 @@ class LightManager { /* IES texture management */ int add_ies(const string &content); int add_ies_from_file(const string &filename); - void remove_ies(int slot); + void remove_ies(const int slot); void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_free(Device *device, DeviceScene *dscene, const bool free_background = true); - void tag_update(Scene *scene, uint32_t flag); + void tag_update(Scene *scene, const uint32_t flag); bool need_update() const; diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index 368931df005..eaaf7a2e823 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -76,15 +76,15 @@ OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds return OrientationBounds({new_axis, theta_o, theta_e}); } -LightTreeEmitter::LightTreeEmitter(Object *object, int object_id) : object_id(object_id) +LightTreeEmitter::LightTreeEmitter(Object *object, const int object_id) : object_id(object_id) { centroid = object->bounds.center(); light_set_membership = object->get_light_set_membership(); } LightTreeEmitter::LightTreeEmitter(Scene *scene, - int prim_id, - int object_id, + const int prim_id, + const int object_id, bool need_transformation) : prim_id(prim_id), object_id(object_id) { @@ -252,7 +252,7 @@ static void sort_leaf(const int start, const int end, LightTreeEmitter *emitters } } -bool LightTree::triangle_usable_as_light(Mesh *mesh, int prim_id) +bool LightTree::triangle_usable_as_light(Mesh *mesh, const int prim_id) { const int shader_index = mesh->get_shader()[prim_id]; if (shader_index < mesh->get_used_shaders().size()) { @@ -264,7 +264,7 @@ bool LightTree::triangle_usable_as_light(Mesh *mesh, int prim_id) return false; } -void LightTree::add_mesh(Scene *scene, Mesh *mesh, int object_id) +void LightTree::add_mesh(Scene *scene, Mesh *mesh, const int object_id) { const size_t mesh_num_triangles = mesh->num_triangles(); for (size_t i = 0; i < mesh_num_triangles; i++) { @@ -277,7 +277,7 @@ void LightTree::add_mesh(Scene *scene, Mesh *mesh, int object_id) LightTree::LightTree(Scene *scene, DeviceScene *dscene, Progress &progress, - uint max_lights_in_leaf) + const uint max_lights_in_leaf) : progress_(progress), max_lights_in_leaf_(max_lights_in_leaf) { KernelIntegrator *kintegrator = &dscene->data.integrator; diff --git a/intern/cycles/scene/light_tree.h b/intern/cycles/scene/light_tree.h index 5410baea2fd..d0168ebbf65 100644 --- a/intern/cycles/scene/light_tree.h +++ b/intern/cycles/scene/light_tree.h @@ -189,8 +189,11 @@ struct LightTreeEmitter { LightTreeMeasure measure; - LightTreeEmitter(Object *object, int object_id); /* Mesh emitter. */ - LightTreeEmitter(Scene *scene, int prim_id, int object_id, bool need_transformation = false); + LightTreeEmitter(Object *object, const int object_id); /* Mesh emitter. */ + LightTreeEmitter(Scene *scene, + const int prim_id, + const int object_id, + bool need_transformation = false); __forceinline bool is_mesh() const { @@ -402,7 +405,7 @@ class LightTree { right = 1, }; - LightTree(Scene *scene, DeviceScene *dscene, Progress &progress, uint max_lights_in_leaf); + LightTree(Scene *scene, DeviceScene *dscene, Progress &progress, const uint max_lights_in_leaf); /* Returns a pointer to the root node. */ LightTreeNode *build(Scene *scene, DeviceScene *dscene); @@ -432,10 +435,10 @@ class LightTree { void recursive_build(Child child, LightTreeNode *inner, - int start, - int end, + const int start, + const int end, LightTreeEmitter *emitters, - uint bit_trail, + const uint bit_trail, int depth); bool should_split(LightTreeEmitter *emitters, @@ -447,10 +450,10 @@ class LightTree { int &split_dim); /* Check whether the light tree can use this triangle as light-emissive. */ - bool triangle_usable_as_light(Mesh *mesh, int prim_id); + bool triangle_usable_as_light(Mesh *mesh, const int prim_id); /* Add all the emissive triangles of a mesh to the light tree. */ - void add_mesh(Scene *scene, Mesh *mesh, int object_id); + void add_mesh(Scene *scene, Mesh *mesh, const int object_id); }; CCL_NAMESPACE_END diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp index 3858d7b1aa0..972a198da20 100644 --- a/intern/cycles/scene/mesh.cpp +++ b/intern/cycles/scene/mesh.cpp @@ -33,9 +33,9 @@ void Mesh::Triangle::bounds_grow(const float3 *verts, BoundBox &bounds) const void Mesh::Triangle::motion_verts(const float3 *verts, const float3 *vert_steps, - size_t num_verts, - size_t num_steps, - float time, + const size_t num_verts, + const size_t num_steps, + const float time, float3 r_verts[3]) const { /* Figure out which steps we need to fetch and their interpolation factor. */ @@ -55,8 +55,8 @@ void Mesh::Triangle::motion_verts(const float3 *verts, void Mesh::Triangle::verts_for_step(const float3 *verts, const float3 *vert_steps, - size_t num_verts, - size_t num_steps, + const size_t num_verts, + const size_t num_steps, size_t step, float3 r_verts[3]) const { @@ -200,7 +200,7 @@ Mesh::~Mesh() delete subd_params; } -void Mesh::resize_mesh(int numverts, int numtris) +void Mesh::resize_mesh(const int numverts, const int numtris) { verts.resize(numverts); triangles.resize(numtris * 3); @@ -215,7 +215,7 @@ void Mesh::resize_mesh(int numverts, int numtris) attributes.resize(); } -void Mesh::reserve_mesh(int numverts, int numtris) +void Mesh::reserve_mesh(const int numverts, const int numtris) { /* reserve space to add verts and triangles later */ verts.reserve(numverts); @@ -231,7 +231,7 @@ void Mesh::reserve_mesh(int numverts, int numtris) attributes.resize(true); } -void Mesh::resize_subd_faces(int numfaces, int num_ngons_, int numcorners) +void Mesh::resize_subd_faces(const int numfaces, const int num_ngons_, int numcorners) { subd_start_corner.resize(numfaces); subd_num_corners.resize(numfaces); @@ -245,7 +245,7 @@ void Mesh::resize_subd_faces(int numfaces, int num_ngons_, int numcorners) subd_attributes.resize(); } -void Mesh::reserve_subd_faces(int numfaces, int num_ngons_, int numcorners) +void Mesh::reserve_subd_faces(const int numfaces, const int num_ngons_, int numcorners) { subd_start_corner.reserve(numfaces); subd_num_corners.reserve(numfaces); @@ -259,7 +259,7 @@ void Mesh::reserve_subd_faces(int numfaces, int num_ngons_, int numcorners) subd_attributes.resize(true); } -void Mesh::reserve_subd_creases(size_t num_creases) +void Mesh::reserve_subd_creases(const size_t num_creases) { subd_creases_edge.reserve(num_creases * 2); subd_creases_weight.reserve(num_creases); @@ -315,7 +315,7 @@ void Mesh::clear(bool preserve_shaders) clear(preserve_shaders, false); } -void Mesh::add_vertex(float3 P) +void Mesh::add_vertex(const float3 P) { verts.push_back_reserved(P); tag_verts_modified(); @@ -326,7 +326,7 @@ void Mesh::add_vertex(float3 P) } } -void Mesh::add_vertex_slow(float3 P) +void Mesh::add_vertex_slow(const float3 P) { verts.push_back_slow(P); tag_verts_modified(); @@ -337,7 +337,7 @@ void Mesh::add_vertex_slow(float3 P) } } -void Mesh::add_triangle(int v0, int v1, int v2, int shader_, bool smooth_) +void Mesh::add_triangle(const int v0, const int v1, const int v2, const int shader_, bool smooth_) { triangles.push_back_reserved(v0); triangles.push_back_reserved(v1); @@ -355,7 +355,10 @@ void Mesh::add_triangle(int v0, int v1, int v2, int shader_, bool smooth_) } } -void Mesh::add_subd_face(const int *corners, int num_corners, int shader_, bool smooth_) +void Mesh::add_subd_face(const int *corners, + const int num_corners, + const int shader_, + bool smooth_) { const int start_corner = subd_face_corners.size(); @@ -385,7 +388,7 @@ void Mesh::add_subd_face(const int *corners, int num_corners, int shader_, bool tag_subd_ptex_offset_modified(); } -Mesh::SubdFace Mesh::get_subd_face(size_t index) const +Mesh::SubdFace Mesh::get_subd_face(const size_t index) const { Mesh::SubdFace s; s.shader = subd_shader[index]; @@ -396,7 +399,7 @@ Mesh::SubdFace Mesh::get_subd_face(size_t index) const return s; } -void Mesh::add_edge_crease(int v0, int v1, float weight) +void Mesh::add_edge_crease(const int v0, const int v1, const float weight) { subd_creases_edge.push_back_slow(v0); subd_creases_edge.push_back_slow(v1); @@ -407,7 +410,7 @@ void Mesh::add_edge_crease(int v0, int v1, float weight) tag_subd_creases_weight_modified(); } -void Mesh::add_vertex_crease(int v, float weight) +void Mesh::add_vertex_crease(const int v, const float weight) { subd_vert_creases.push_back_slow(v); subd_vert_creases_weight.push_back_slow(weight); diff --git a/intern/cycles/scene/mesh.h b/intern/cycles/scene/mesh.h index a0f04a55069..7aacb6116fd 100644 --- a/intern/cycles/scene/mesh.h +++ b/intern/cycles/scene/mesh.h @@ -50,16 +50,16 @@ class Mesh : public Geometry { void motion_verts(const float3 *verts, const float3 *vert_steps, - size_t num_verts, - size_t num_steps, - float time, + const size_t num_verts, + const size_t num_steps, + const float time, float3 r_verts[3]) const; void verts_for_step(const float3 *verts, const float3 *vert_steps, - size_t num_verts, - size_t num_steps, - size_t step, + const size_t num_verts, + const size_t num_steps, + const size_t step, float3 r_verts[3]) const; float3 compute_normal(const float3 *verts) const; @@ -67,7 +67,7 @@ class Mesh : public Geometry { bool valid(const float3 *verts) const; }; - Triangle get_triangle(size_t i) const + Triangle get_triangle(const size_t i) const { Triangle tri = {{triangles[i * 3 + 0], triangles[i * 3 + 1], triangles[i * 3 + 2]}}; return tri; @@ -102,7 +102,7 @@ class Mesh : public Geometry { float crease; }; - SubdEdgeCrease get_subd_crease(size_t i) const + SubdEdgeCrease get_subd_crease(const size_t i) const { SubdEdgeCrease s; s.v[0] = subd_creases_edge[i * 2]; @@ -186,19 +186,19 @@ class Mesh : public Geometry { Mesh(); ~Mesh() override; - void resize_mesh(int numverts, int numtris); - void reserve_mesh(int numverts, int numtris); - void resize_subd_faces(int numfaces, int num_ngons, int numcorners); - void reserve_subd_faces(int numfaces, int num_ngons, int numcorners); - void reserve_subd_creases(size_t num_creases); + void resize_mesh(const int numverts, const int numtris); + void reserve_mesh(const int numverts, const int numtris); + void resize_subd_faces(const int numfaces, const int num_ngons, const int numcorners); + void reserve_subd_faces(const int numfaces, const int num_ngons, const int numcorners); + void reserve_subd_creases(const size_t num_creases); void clear_non_sockets(); void clear(bool preserve_shaders = false) override; - void add_vertex(float3 P); - void add_vertex_slow(float3 P); - void add_triangle(int v0, int v1, int v2, int shader, bool smooth); - void add_subd_face(const int *corners, int num_corners, int shader_, bool smooth_); - void add_edge_crease(int v0, int v1, float weight); - void add_vertex_crease(int v, float weight); + void add_vertex(const float3 P); + void add_vertex_slow(const float3 P); + void add_triangle(const int v0, const int v1, const int v2, const int shader, bool smooth); + void add_subd_face(const int *corners, const int num_corners, const int shader_, bool smooth_); + void add_edge_crease(const int v0, const int v1, const float weight); + void add_vertex_crease(const int v, const float weight); void copy_center_to_motion_step(const int motion_step); @@ -222,7 +222,7 @@ class Mesh : public Geometry { void tessellate(DiagSplit *split); - SubdFace get_subd_face(size_t index) const; + SubdFace get_subd_face(const size_t index) const; SubdParams *get_subd_params(); @@ -231,7 +231,7 @@ class Mesh : public Geometry { return num_subd_faces; } - void set_num_subd_faces(size_t num_subd_faces_) + void set_num_subd_faces(const size_t num_subd_faces_) { num_subd_faces = num_subd_faces_; } diff --git a/intern/cycles/scene/mesh_subdivision.cpp b/intern/cycles/scene/mesh_subdivision.cpp index bc9f7d8622c..c3175fb37f7 100644 --- a/intern/cycles/scene/mesh_subdivision.cpp +++ b/intern/cycles/scene/mesh_subdivision.cpp @@ -152,13 +152,13 @@ template struct OsdValue { memset(&value, 0, sizeof(T)); } - void AddWithWeight(const OsdValue &src, float weight) + void AddWithWeight(const OsdValue &src, const float weight) { value += src.value * weight; } }; -template<> void OsdValue::AddWithWeight(const OsdValue &src, float weight) +template<> void OsdValue::AddWithWeight(const OsdValue &src, const float weight) { for (int i = 0; i < 4; i++) { value[i] += (uchar)(src.value[i] * weight); @@ -347,7 +347,7 @@ struct OsdPatch : Patch { OsdPatch() = default; OsdPatch(OsdData *data) : osd_data(data) {} - void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) override + void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) override { const Far::PatchTable::PatchHandle *handle = osd_data->patch_map->FindPatch( patch_index, (double)u, (double)v); diff --git a/intern/cycles/scene/object.cpp b/intern/cycles/scene/object.cpp index bb2721fbe0d..39b0e111975 100644 --- a/intern/cycles/scene/object.cpp +++ b/intern/cycles/scene/object.cpp @@ -252,12 +252,12 @@ bool Object::use_motion() const return (motion.size() > 1); } -float Object::motion_time(int step) const +float Object::motion_time(const int step) const { return (use_motion()) ? 2.0f * step / (motion.size() - 1) - 1.0f : 0.0f; } -int Object::motion_step(float time) const +int Object::motion_step(const float time) const { if (use_motion()) { for (size_t step = 0; step < motion.size(); step++) { @@ -1081,7 +1081,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P } } -void ObjectManager::tag_update(Scene *scene, uint32_t flag) +void ObjectManager::tag_update(Scene *scene, const uint32_t flag) { update_flags |= flag; diff --git a/intern/cycles/scene/object.h b/intern/cycles/scene/object.h index 895afafd4ea..ae0648d0904 100644 --- a/intern/cycles/scene/object.h +++ b/intern/cycles/scene/object.h @@ -88,8 +88,8 @@ class Object : public Node { /* Convert between normalized -1..1 motion time and index * in the motion array. */ bool use_motion() const; - float motion_time(int step) const; - int motion_step(float time) const; + float motion_time(const int step) const; + int motion_step(const float time) const; void update_motion(); /* Maximum number of motion steps supported (due to Embree). */ @@ -173,7 +173,7 @@ class ObjectManager { void device_free(Device *device, DeviceScene *dscene, bool force_free); - void tag_update(Scene *scene, uint32_t flag); + void tag_update(Scene *scene, const uint32_t flag); bool need_update() const; diff --git a/intern/cycles/scene/osl.cpp b/intern/cycles/scene/osl.cpp index 1fa20f24a9d..302f2348179 100644 --- a/intern/cycles/scene/osl.cpp +++ b/intern/cycles/scene/osl.cpp @@ -437,7 +437,7 @@ bool OSLShaderManager::osl_query(OSL::OSLQuery &query, const string &filepath) return query.open(filepath, searchpath); } -static string shader_filepath_hash(const string &filepath, uint64_t modified_time) +static string shader_filepath_hash(const string &filepath, const uint64_t modified_time) { /* compute a hash from filepath and modified time to detect changes */ MD5Hash md5; @@ -956,7 +956,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath) } } -static TypeDesc array_typedesc(TypeDesc typedesc, int arraylength) +static TypeDesc array_typedesc(const TypeDesc typedesc, const int arraylength) { return TypeDesc((TypeDesc::BASETYPE)typedesc.basetype, (TypeDesc::AGGREGATE)typedesc.aggregate, @@ -1123,32 +1123,32 @@ void OSLCompiler::parameter(ShaderNode *node, const char *name) } } -void OSLCompiler::parameter(const char *name, float f) +void OSLCompiler::parameter(const char *name, const float f) { ss->Parameter(*current_group, name, TypeFloat, &f); } -void OSLCompiler::parameter_color(const char *name, float3 f) +void OSLCompiler::parameter_color(const char *name, const float3 f) { ss->Parameter(*current_group, name, TypeColor, &f); } -void OSLCompiler::parameter_point(const char *name, float3 f) +void OSLCompiler::parameter_point(const char *name, const float3 f) { ss->Parameter(*current_group, name, TypePoint, &f); } -void OSLCompiler::parameter_normal(const char *name, float3 f) +void OSLCompiler::parameter_normal(const char *name, const float3 f) { ss->Parameter(*current_group, name, TypeNormal, &f); } -void OSLCompiler::parameter_vector(const char *name, float3 f) +void OSLCompiler::parameter_vector(const char *name, const float3 f) { ss->Parameter(*current_group, name, TypeVector, &f); } -void OSLCompiler::parameter(const char *name, int f) +void OSLCompiler::parameter(const char *name, const int f) { ss->Parameter(*current_group, name, TypeInt, &f); } @@ -1413,7 +1413,7 @@ void OSLCompiler::parameter_texture(const char *name, const ImageHandle &handle) parameter(name, filename); } -void OSLCompiler::parameter_texture_ies(const char *name, int svm_slot) +void OSLCompiler::parameter_texture_ies(const char *name, const int svm_slot) { /* IES light textures stored in SVM. */ const ustring filename(string_printf("@svm%d", texture_shared_unique_id++).c_str()); diff --git a/intern/cycles/scene/osl.h b/intern/cycles/scene/osl.h index 004e475ac34..78bfe6c4a3c 100644 --- a/intern/cycles/scene/osl.h +++ b/intern/cycles/scene/osl.h @@ -128,12 +128,12 @@ class OSLCompiler { void parameter(ShaderNode *node, const char *name); - void parameter(const char *name, float f); - void parameter_color(const char *name, float3 f); - void parameter_vector(const char *name, float3 f); - void parameter_normal(const char *name, float3 f); - void parameter_point(const char *name, float3 f); - void parameter(const char *name, int f); + void parameter(const char *name, const float f); + void parameter_color(const char *name, const float3 f); + void parameter_vector(const char *name, const float3 f); + void parameter_normal(const char *name, const float3 f); + void parameter_point(const char *name, const float3 f); + void parameter(const char *name, const int f); void parameter(const char *name, const char *s); void parameter(const char *name, ustring str); void parameter(const char *name, const Transform &tfm); @@ -145,7 +145,7 @@ class OSLCompiler { void parameter_texture(const char *name, ustring filename, ustring colorspace); void parameter_texture(const char *name, const ImageHandle &handle); - void parameter_texture_ies(const char *name, int svm_slot); + void parameter_texture_ies(const char *name, const int svm_slot); ShaderType output_type() { diff --git a/intern/cycles/scene/pointcloud.cpp b/intern/cycles/scene/pointcloud.cpp index be1e317ba76..2eab02541fa 100644 --- a/intern/cycles/scene/pointcloud.cpp +++ b/intern/cycles/scene/pointcloud.cpp @@ -35,9 +35,9 @@ void PointCloud::Point::bounds_grow(const float4 &point, BoundBox &bounds) const float4 PointCloud::Point::motion_key(const float3 *points, const float *radius, const float4 *point_steps, - size_t num_points, - size_t num_steps, - float time, + const size_t num_points, + const size_t num_steps, + const float time, size_t p) const { /* Figure out which steps we need to fetch and their @@ -57,8 +57,8 @@ float4 PointCloud::Point::motion_key(const float3 *points, float4 PointCloud::Point::point_for_step(const float3 *points, const float *radius, const float4 *point_steps, - size_t num_points, - size_t num_steps, + const size_t num_points, + const size_t num_steps, size_t step, size_t p) const { @@ -93,7 +93,7 @@ PointCloud::PointCloud() : Geometry(node_type, Geometry::POINTCLOUD) {} PointCloud::~PointCloud() = default; -void PointCloud::resize(int numpoints) +void PointCloud::resize(const int numpoints) { points.resize(numpoints); radius.resize(numpoints); @@ -105,7 +105,7 @@ void PointCloud::resize(int numpoints) tag_shader_modified(); } -void PointCloud::reserve(int numpoints) +void PointCloud::reserve(const int numpoints) { points.reserve(numpoints); radius.reserve(numpoints); @@ -127,7 +127,7 @@ void PointCloud::clear(const bool preserve_shaders) tag_shader_modified(); } -void PointCloud::add_point(float3 co, float r, int shader_index) +void PointCloud::add_point(const float3 co, const float r, const int shader_index) { points.push_back_reserved(co); radius.push_back_reserved(r); diff --git a/intern/cycles/scene/pointcloud.h b/intern/cycles/scene/pointcloud.h index 62148305b56..f50c33b83f6 100644 --- a/intern/cycles/scene/pointcloud.h +++ b/intern/cycles/scene/pointcloud.h @@ -26,16 +26,16 @@ class PointCloud : public Geometry { float4 motion_key(const float3 *points, const float *radius, const float4 *point_steps, - size_t num_points, - size_t num_steps, - float time, + const size_t num_points, + const size_t num_steps, + const float time, size_t p) const; float4 point_for_step(const float3 *points, const float *radius, const float4 *point_steps, - size_t num_points, - size_t num_steps, - size_t step, + const size_t num_points, + const size_t num_steps, + const size_t step, size_t p) const; }; @@ -50,9 +50,9 @@ class PointCloud : public Geometry { /* Geometry */ void clear(const bool preserve_shaders = false) override; - void resize(int numpoints); - void reserve(int numpoints); - void add_point(float3 co, float radius, int shader = 0); + void resize(const int numpoints); + void reserve(const int numpoints); + void add_point(const float3 co, const float radius, const int shader = 0); void copy_center_to_motion_step(const int motion_step); @@ -60,7 +60,7 @@ class PointCloud : public Geometry { void apply_transform(const Transform &tfm, const bool apply_to_motion) override; /* Points */ - Point get_point(int i) const + Point get_point(const int i) const { Point point = {i}; return point; diff --git a/intern/cycles/scene/shader.cpp b/intern/cycles/scene/shader.cpp index c53351a4d9a..57d6285dc84 100644 --- a/intern/cycles/scene/shader.cpp +++ b/intern/cycles/scene/shader.cpp @@ -432,7 +432,7 @@ ShaderManager::ShaderManager() ShaderManager::~ShaderManager() = default; -ShaderManager *ShaderManager::create(int shadingsystem, Device *device) +ShaderManager *ShaderManager::create(const int shadingsystem, Device *device) { ShaderManager *manager; @@ -804,12 +804,12 @@ void ShaderManager::free_memory() ColorSpaceManager::free_memory(); } -float ShaderManager::linear_rgb_to_gray(float3 c) +float ShaderManager::linear_rgb_to_gray(const float3 c) { return dot(c, rgb_to_y); } -float3 ShaderManager::rec709_to_scene_linear(float3 c) +float3 ShaderManager::rec709_to_scene_linear(const float3 c) { return to_local(c, rec709_to_r, rec709_to_g, rec709_to_b); } @@ -972,7 +972,7 @@ void ShaderManager::init_xyz_transforms() size_t ShaderManager::ensure_bsdf_table_impl(DeviceScene *dscene, Scene *scene, const float *table, - size_t n) + const size_t n) { /* Since the BSDF tables are static arrays, we can use their address to identify them. */ if (!(bsdf_tables.count(table))) { diff --git a/intern/cycles/scene/shader.h b/intern/cycles/scene/shader.h index 7fe6fe51551..d75a8765ac5 100644 --- a/intern/cycles/scene/shader.h +++ b/intern/cycles/scene/shader.h @@ -176,7 +176,7 @@ class ShaderManager { UPDATE_NONE = 0u, }; - static ShaderManager *create(int shadingsystem, Device *device); + static ShaderManager *create(const int shadingsystem, Device *device); virtual ~ShaderManager(); virtual void reset(Scene *scene) = 0; @@ -213,12 +213,12 @@ class ShaderManager { static void free_memory(); - float linear_rgb_to_gray(float3 c); - float3 rec709_to_scene_linear(float3 c); + float linear_rgb_to_gray(const float3 c); + float3 rec709_to_scene_linear(const float3 c); string get_cryptomatte_materials(Scene *scene); - void tag_update(Scene *scene, uint32_t flag); + void tag_update(Scene *scene, const uint32_t flag); bool need_update() const; @@ -241,7 +241,10 @@ class ShaderManager { { return ensure_bsdf_table_impl(dscene, scene, table, n); } - size_t ensure_bsdf_table_impl(DeviceScene *dscene, Scene *scene, const float *table, size_t n); + size_t ensure_bsdf_table_impl(DeviceScene *dscene, + Scene *scene, + const float *table, + const size_t n); uint get_graph_kernel_features(ShaderGraph *graph); diff --git a/intern/cycles/scene/shader_graph.h b/intern/cycles/scene/shader_graph.h index 3b80b72b3a7..2e994c3906e 100644 --- a/intern/cycles/scene/shader_graph.h +++ b/intern/cycles/scene/shader_graph.h @@ -85,15 +85,15 @@ class ShaderInput { return socket_type.type; } - void set(float f) + void set(const float f) { ((Node *)parent)->set(socket_type, f); } - void set(float3 f) + void set(const float3 f) { ((Node *)parent)->set(socket_type, f); } - void set(int f) + void set(const int f) { ((Node *)parent)->set(socket_type, f); } diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index 3f2c781d58f..59834ab7b1b 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -150,7 +150,7 @@ bool TextureMapping::skip() return true; } -void TextureMapping::compile(SVMCompiler &compiler, int offset_in, int offset_out) +void TextureMapping::compile(SVMCompiler &compiler, const int offset_in, const int offset_out) { compiler.add_node(NODE_TEXTURE_MAPPING, offset_in, offset_out); @@ -189,7 +189,9 @@ int TextureMapping::compile_begin(SVMCompiler &compiler, ShaderInput *vector_in) return compiler.stack_assign(vector_in); } -void TextureMapping::compile_end(SVMCompiler &compiler, ShaderInput *vector_in, int vector_offset) +void TextureMapping::compile_end(SVMCompiler &compiler, + ShaderInput *vector_in, + const int vector_offset) { if (!skip()) { compiler.stack_clear_offset(vector_in->type(), vector_offset); @@ -628,7 +630,7 @@ void EnvironmentTextureNode::compile(OSLCompiler &compiler) /* Sky Texture */ -static float2 sky_spherical_coordinates(float3 dir) +static float2 sky_spherical_coordinates(const float3 dir) { return make_float2(acosf(dir.z), atan2f(dir.x, dir.y)); } @@ -643,13 +645,15 @@ struct SunSky { }; /* Preetham model */ -static float sky_perez_function(const float lam[6], float theta, float gamma) +static float sky_perez_function(const float lam[6], float theta, const float gamma) { return (1.0f + lam[0] * expf(lam[1] / cosf(theta))) * (1.0f + lam[2] * expf(lam[3] * gamma) + lam[4] * cosf(gamma) * cosf(gamma)); } -static void sky_texture_precompute_preetham(SunSky *sunsky, float3 dir, float turbidity) +static void sky_texture_precompute_preetham(SunSky *sunsky, + const float3 dir, + const float turbidity) { /* * We re-use the SunSky struct of the new model, to avoid extra variables @@ -713,9 +717,9 @@ static void sky_texture_precompute_preetham(SunSky *sunsky, float3 dir, float tu /* Hosek / Wilkie */ static void sky_texture_precompute_hosek(SunSky *sunsky, - float3 dir, + const float3 dir, float turbidity, - float ground_albedo) + const float ground_albedo) { /* Calculate Sun Direction and save coordinates */ const float2 spherical = sky_spherical_coordinates(dir); @@ -755,13 +759,13 @@ static void sky_texture_precompute_hosek(SunSky *sunsky, /* Nishita improved */ static void sky_texture_precompute_nishita(SunSky *sunsky, bool sun_disc, - float sun_size, - float sun_intensity, - float sun_elevation, - float sun_rotation, - float altitude, - float air_density, - float dust_density) + const float sun_size, + const float sun_intensity, + const float sun_elevation, + const float sun_rotation, + const float altitude, + const float air_density, + const float dust_density) { /* sample 2 sun pixels */ float pixel_bottom[3]; @@ -7071,7 +7075,7 @@ void CurvesNode::constant_fold(const ConstantFolder &folder, ShaderInput *value_ } void CurvesNode::compile(SVMCompiler &compiler, - int type, + const int type, ShaderInput *value_in, ShaderOutput *value_out) { @@ -7400,7 +7404,7 @@ ShaderNode *OSLNode::clone(ShaderGraph *graph) const return OSLNode::create(graph, this->inputs.size(), this); } -OSLNode *OSLNode::create(ShaderGraph *graph, size_t num_inputs, const OSLNode *from) +OSLNode *OSLNode::create(ShaderGraph *graph, const size_t num_inputs, const OSLNode *from) { /* allocate space for the node itself and parameters, aligned to 16 bytes * assuming that's the most parameter types need */ diff --git a/intern/cycles/scene/shader_nodes.h b/intern/cycles/scene/shader_nodes.h index a5ba6929ed8..bf8623ac908 100644 --- a/intern/cycles/scene/shader_nodes.h +++ b/intern/cycles/scene/shader_nodes.h @@ -25,12 +25,12 @@ class TextureMapping { TextureMapping(); Transform compute_transform(); bool skip(); - void compile(SVMCompiler &compiler, int offset_in, int offset_out); + void compile(SVMCompiler &compiler, const int offset_in, const int offset_out); int compile(SVMCompiler &compiler, ShaderInput *vector_in); void compile(OSLCompiler &compiler); int compile_begin(SVMCompiler &compiler, ShaderInput *vector_in); - void compile_end(SVMCompiler &compiler, ShaderInput *vector_in, int vector_offset); + void compile_end(SVMCompiler &compiler, ShaderInput *vector_in, const int vector_offset); float3 translation; float3 rotation; @@ -1502,7 +1502,10 @@ class CurvesNode : public ShaderNode { protected: using ShaderNode::constant_fold; void constant_fold(const ConstantFolder &folder, ShaderInput *value_in); - void compile(SVMCompiler &compiler, int type, ShaderInput *value_in, ShaderOutput *value_out); + void compile(SVMCompiler &compiler, + const int type, + ShaderInput *value_in, + ShaderOutput *value_out); void compile(OSLCompiler &compiler, const char *name); }; @@ -1550,7 +1553,9 @@ class SetNormalNode : public ShaderNode { class OSLNode final : public ShaderNode { public: - static OSLNode *create(ShaderGraph *graph, size_t num_inputs, const OSLNode *from = nullptr); + static OSLNode *create(ShaderGraph *graph, + const size_t num_inputs, + const OSLNode *from = nullptr); ~OSLNode() override; static void operator delete(void *ptr) diff --git a/intern/cycles/scene/stats.cpp b/intern/cycles/scene/stats.cpp index dfdfa9d43f6..4413879b5e6 100644 --- a/intern/cycles/scene/stats.cpp +++ b/intern/cycles/scene/stats.cpp @@ -43,11 +43,11 @@ bool namedSampleCountPairComparator(const NamedSampleCountPair &a, const NamedSa NamedSizeEntry::NamedSizeEntry() : size(0) {} -NamedSizeEntry::NamedSizeEntry(const string &name, size_t size) : name(name), size(size) {} +NamedSizeEntry::NamedSizeEntry(const string &name, const size_t size) : name(name), size(size) {} NamedTimeEntry::NamedTimeEntry() : time(0) {} -NamedTimeEntry::NamedTimeEntry(const string &name, double time) : name(name), time(time) {} +NamedTimeEntry::NamedTimeEntry(const string &name, const double time) : name(name), time(time) {} /* Named size statistics. */ @@ -59,7 +59,7 @@ void NamedSizeStats::add_entry(const NamedSizeEntry &entry) entries.push_back(entry); } -string NamedSizeStats::full_report(int indent_level) +string NamedSizeStats::full_report(const int indent_level) { const string indent(indent_level * kIndentNumSpaces, ' '); const string double_indent = indent + indent; @@ -79,7 +79,7 @@ string NamedSizeStats::full_report(int indent_level) return result; } -string NamedTimeStats::full_report(int indent_level) +string NamedTimeStats::full_report(const int indent_level) { const string indent(indent_level * kIndentNumSpaces, ' '); const string double_indent = indent + indent; @@ -97,7 +97,7 @@ string NamedTimeStats::full_report(int indent_level) NamedNestedSampleStats::NamedNestedSampleStats() : self_samples(0), sum_samples(0) {} -NamedNestedSampleStats::NamedNestedSampleStats(const string &name, uint64_t samples) +NamedNestedSampleStats::NamedNestedSampleStats(const string &name, const uint64_t samples) : name(name), self_samples(samples), sum_samples(samples) { } @@ -117,7 +117,7 @@ void NamedNestedSampleStats::update_sum() } } -string NamedNestedSampleStats::full_report(int indent_level, uint64_t total_samples) +string NamedNestedSampleStats::full_report(const int indent_level, uint64_t total_samples) { update_sum(); @@ -148,14 +148,16 @@ string NamedNestedSampleStats::full_report(int indent_level, uint64_t total_samp /* Named sample count pairs. */ -NamedSampleCountPair::NamedSampleCountPair(const ustring &name, uint64_t samples, uint64_t hits) +NamedSampleCountPair::NamedSampleCountPair(const ustring &name, + const uint64_t samples, + const uint64_t hits) : name(name), samples(samples), hits(hits) { } NamedSampleCountStats::NamedSampleCountStats() = default; -void NamedSampleCountStats::add(const ustring &name, uint64_t samples, uint64_t hits) +void NamedSampleCountStats::add(const ustring &name, const uint64_t samples, const uint64_t hits) { const entry_map::iterator entry = entries.find(name); if (entry != entries.end()) { @@ -166,7 +168,7 @@ void NamedSampleCountStats::add(const ustring &name, uint64_t samples, uint64_t entries.emplace(name, NamedSampleCountPair(name, samples, hits)); } -string NamedSampleCountStats::full_report(int indent_level) +string NamedSampleCountStats::full_report(const int indent_level) { const string indent(indent_level * kIndentNumSpaces, ' '); @@ -203,7 +205,7 @@ string NamedSampleCountStats::full_report(int indent_level) MeshStats::MeshStats() = default; -string MeshStats::full_report(int indent_level) +string MeshStats::full_report(const int indent_level) { const string indent(indent_level * kIndentNumSpaces, ' '); string result; @@ -215,7 +217,7 @@ string MeshStats::full_report(int indent_level) ImageStats::ImageStats() = default; -string ImageStats::full_report(int indent_level) +string ImageStats::full_report(const int indent_level) { const string indent(indent_level * kIndentNumSpaces, ' '); string result; @@ -303,7 +305,7 @@ string RenderStats::full_report() NamedTimeStats::NamedTimeStats() : total_time(0.0) {} -string UpdateTimeStats::full_report(int indent_level) +string UpdateTimeStats::full_report(const int indent_level) { return times.full_report(indent_level + 1); } diff --git a/intern/cycles/scene/stats.h b/intern/cycles/scene/stats.h index a7cdac0c8c4..da74f3b8ad6 100644 --- a/intern/cycles/scene/stats.h +++ b/intern/cycles/scene/stats.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN class NamedSizeEntry { public: NamedSizeEntry(); - NamedSizeEntry(const string &name, size_t size); + NamedSizeEntry(const string &name, const size_t size); string name; size_t size; @@ -30,7 +30,7 @@ class NamedSizeEntry { class NamedTimeEntry { public: NamedTimeEntry(); - NamedTimeEntry(const string &name, double time); + NamedTimeEntry(const string &name, const double time); string name; double time; @@ -48,7 +48,7 @@ class NamedSizeStats { void add_entry(const NamedSizeEntry &entry); /* Generate full human-readable report. */ - string full_report(int indent_level = 0); + string full_report(const int indent_level = 0); /* Total size of all entries. */ size_t total_size; @@ -71,7 +71,7 @@ class NamedTimeStats { } /* Generate full human-readable report. */ - string full_report(int indent_level = 0); + string full_report(const int indent_level = 0); /* Total time of all entries. */ double total_time; @@ -91,14 +91,14 @@ class NamedTimeStats { class NamedNestedSampleStats { public: NamedNestedSampleStats(); - NamedNestedSampleStats(const string &name, uint64_t samples); + NamedNestedSampleStats(const string &name, const uint64_t samples); - NamedNestedSampleStats &add_entry(const string &name, uint64_t samples); + NamedNestedSampleStats &add_entry(const string &name, const uint64_t samples); /* Updates sum_samples recursively. */ void update_sum(); - string full_report(int indent_level = 0, uint64_t total_samples = 0); + string full_report(const int indent_level = 0, const uint64_t total_samples = 0); string name; @@ -114,7 +114,7 @@ class NamedNestedSampleStats { * This allows to estimate the time spent per item. */ class NamedSampleCountPair { public: - NamedSampleCountPair(const ustring &name, uint64_t samples, uint64_t hits); + NamedSampleCountPair(const ustring &name, const uint64_t samples, const uint64_t hits); ustring name; uint64_t samples; @@ -126,8 +126,8 @@ class NamedSampleCountStats { public: NamedSampleCountStats(); - string full_report(int indent_level = 0); - void add(const ustring &name, uint64_t samples, uint64_t hits); + string full_report(const int indent_level = 0); + void add(const ustring &name, const uint64_t samples, const uint64_t hits); using entry_map = unordered_map; entry_map entries; @@ -139,7 +139,7 @@ class MeshStats { MeshStats(); /* Generate full human-readable report. */ - string full_report(int indent_level = 0); + string full_report(const int indent_level = 0); /* Input geometry statistics, this is what is coming as an input to render * from. say, Blender. This does not include runtime or engine specific @@ -154,7 +154,7 @@ class ImageStats { ImageStats(); /* Generate full human-readable report. */ - string full_report(int indent_level = 0); + string full_report(const int indent_level = 0); NamedSizeStats textures; }; @@ -182,7 +182,7 @@ class RenderStats { class UpdateTimeStats { public: /* Generate full human-readable report. */ - string full_report(int indent_level = 0); + string full_report(const int indent_level = 0); NamedTimeStats times; }; diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index f027c4c3d89..de45a396332 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -194,7 +194,7 @@ int SVMCompiler::stack_size(SocketType::Type type) return size; } -int SVMCompiler::stack_find_offset(int size) +int SVMCompiler::stack_find_offset(const int size) { int offset = -1; @@ -234,7 +234,7 @@ int SVMCompiler::stack_find_offset(SocketType::Type type) return stack_find_offset(stack_size(type)); } -void SVMCompiler::stack_clear_offset(SocketType::Type type, int offset) +void SVMCompiler::stack_clear_offset(SocketType::Type type, const int offset) { const int size = stack_size(type); @@ -375,7 +375,7 @@ void SVMCompiler::stack_clear_temporary(ShaderNode *node) } } -uint SVMCompiler::encode_uchar4(uint x, uint y, uint z, uint w) +uint SVMCompiler::encode_uchar4(const uint x, const uint y, uint z, const uint w) { assert(x <= 255); assert(y <= 255); @@ -385,12 +385,12 @@ uint SVMCompiler::encode_uchar4(uint x, uint y, uint z, uint w) return (x) | (y << 8) | (z << 16) | (w << 24); } -void SVMCompiler::add_node(int a, int b, int c, int d) +void SVMCompiler::add_node(const int a, const int b, int c, const int d) { current_svm_nodes.push_back_slow(make_int4(a, b, c, d)); } -void SVMCompiler::add_node(ShaderNodeType type, int a, int b, int c) +void SVMCompiler::add_node(ShaderNodeType type, const int a, int b, const int c) { svm_node_types_used[type] = true; current_svm_nodes.push_back_slow(make_int4(type, a, b, c)); @@ -871,7 +871,10 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty } } -void SVMCompiler::compile(Shader *shader, array &svm_nodes, int index, Summary *summary) +void SVMCompiler::compile(Shader *shader, + array &svm_nodes, + const int index, + Summary *summary) { svm_node_types_used[NODE_SHADER_JUMP] = true; svm_nodes.push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0)); diff --git a/intern/cycles/scene/svm.h b/intern/cycles/scene/svm.h index 29685cee748..ac584389fee 100644 --- a/intern/cycles/scene/svm.h +++ b/intern/cycles/scene/svm.h @@ -79,26 +79,29 @@ class SVMCompiler { }; SVMCompiler(Scene *scene); - void compile(Shader *shader, array &svm_nodes, int index, Summary *summary = nullptr); + void compile(Shader *shader, + array &svm_nodes, + const int index, + Summary *summary = nullptr); int stack_assign(ShaderOutput *output); int stack_assign(ShaderInput *input); bool is_linked(ShaderInput *input); int stack_assign_if_linked(ShaderInput *input); int stack_assign_if_linked(ShaderOutput *output); - int stack_find_offset(int size); + int stack_find_offset(const int size); int stack_find_offset(SocketType::Type type); - void stack_clear_offset(SocketType::Type type, int offset); + void stack_clear_offset(SocketType::Type type, const int offset); void stack_link(ShaderInput *input, ShaderOutput *output); - void add_node(ShaderNodeType type, int a = 0, int b = 0, int c = 0); - void add_node(int a = 0, int b = 0, int c = 0, int d = 0); + void add_node(ShaderNodeType type, const int a = 0, const int b = 0, const int c = 0); + void add_node(const int a = 0, const int b = 0, const int c = 0, const int d = 0); void add_node(ShaderNodeType type, const float3 &f); void add_node(const float4 &f); uint attribute(ustring name); uint attribute(AttributeStandard std); uint attribute_standard(ustring name); - uint encode_uchar4(uint x, uint y = 0, uint z = 0, uint w = 0); + uint encode_uchar4(const uint x, const uint y = 0, const uint z = 0, const uint w = 0); uint closure_mix_weight_offset() { return mix_weight_offset; diff --git a/intern/cycles/scene/tables.cpp b/intern/cycles/scene/tables.cpp index f7605f9939f..d88a3f57006 100644 --- a/intern/cycles/scene/tables.cpp +++ b/intern/cycles/scene/tables.cpp @@ -55,7 +55,7 @@ bool LookupTables::need_update() const return need_update_; } -static size_t round_up_to_multiple(size_t size, size_t chunk) +static size_t round_up_to_multiple(const size_t size, const size_t chunk) { return ((size + chunk - 1) / chunk) * chunk; } diff --git a/intern/cycles/scene/tabulated_sobol.cpp b/intern/cycles/scene/tabulated_sobol.cpp index cff847b15ff..b39e26363f9 100644 --- a/intern/cycles/scene/tabulated_sobol.cpp +++ b/intern/cycles/scene/tabulated_sobol.cpp @@ -11,7 +11,7 @@ CCL_NAMESPACE_BEGIN -void tabulated_sobol_generate_4D(float4 points[], int size, int rng_seed) +void tabulated_sobol_generate_4D(float4 points[], const int size, const int rng_seed) { /* Xor values for generating the (4D) Owen-scrambled Sobol sequence. * These permute the order we visit the strata in, which is what diff --git a/intern/cycles/scene/tabulated_sobol.h b/intern/cycles/scene/tabulated_sobol.h index 3ab7b330bb4..d9f6a6796c6 100644 --- a/intern/cycles/scene/tabulated_sobol.h +++ b/intern/cycles/scene/tabulated_sobol.h @@ -8,6 +8,6 @@ CCL_NAMESPACE_BEGIN -void tabulated_sobol_generate_4D(float4 points[], int size, int rng_seed); +void tabulated_sobol_generate_4D(float4 points[], const int size, const int rng_seed); CCL_NAMESPACE_END diff --git a/intern/cycles/scene/volume.cpp b/intern/cycles/scene/volume.cpp index 60f4ba76db7..0825bb8e764 100644 --- a/intern/cycles/scene/volume.cpp +++ b/intern/cycles/scene/volume.cpp @@ -92,9 +92,9 @@ const float3 quads_normals[6] = { make_float3(0.0f, 0.0f, 1.0f), }; -static int add_vertex(int3 v, +static int add_vertex(const int3 v, vector &vertices, - int3 res, + const int3 res, unordered_map &used_verts) { const size_t vert_key = v.x + v.y * (res.x + 1) + v.z * (res.x + 1) * (res.y + 1); @@ -110,12 +110,12 @@ static int add_vertex(int3 v, return vertex_offset; } -static void create_quad(int3 corners[8], +static void create_quad(const int3 corners[8], vector &vertices, vector &quads, - int3 res, + const int3 res, unordered_map &used_verts, - int face_index) + const int face_index) { QuadData quad; quad.v0 = add_vertex(corners[quads_indices[face_index][0]], vertices, res, used_verts); @@ -150,10 +150,10 @@ class VolumeMeshBuilder { VolumeMeshBuilder(); #ifdef WITH_OPENVDB - void add_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, float volume_clipping); + void add_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, const float volume_clipping); #endif - void add_padding(int pad_size); + void add_padding(const int pad_size); void create_mesh(vector &vertices, vector &indices, @@ -174,7 +174,7 @@ class VolumeMeshBuilder { #ifdef WITH_OPENVDB template - void merge_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, float volume_clipping) + void merge_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, const float volume_clipping) { typename GridType::ConstPtr typed_grid = openvdb::gridConstPtrCast(grid); @@ -205,7 +205,7 @@ VolumeMeshBuilder::VolumeMeshBuilder() #ifdef WITH_OPENVDB void VolumeMeshBuilder::add_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, - float volume_clipping) + const float volume_clipping) { /* set the transform of our grid from the first one */ if (first_grid) { @@ -257,7 +257,7 @@ void VolumeMeshBuilder::add_grid(openvdb::GridBase::ConstPtr grid, } #endif -void VolumeMeshBuilder::add_padding(int pad_size) +void VolumeMeshBuilder::add_padding(const int pad_size) { #ifdef WITH_OPENVDB openvdb::tools::dilateActiveValues( @@ -439,7 +439,7 @@ bool VolumeMeshBuilder::empty_grid() const #ifdef WITH_OPENVDB template static openvdb::GridBase::ConstPtr openvdb_grid_from_device_texture(device_texture *image_memory, - float volume_clipping, + const float volume_clipping, Transform transform_3d) { using ValueType = typename GridType::ValueType; @@ -500,7 +500,7 @@ static openvdb::GridBase::ConstPtr openvdb_grid_from_device_texture(device_textu } static int estimate_required_velocity_padding(openvdb::GridBase::ConstPtr grid, - float velocity_scale) + const float velocity_scale) { /* TODO: we may need to also find outliers and clamp them to avoid adding too much padding. */ openvdb::math::Extrema extrema; diff --git a/intern/cycles/session/denoising.cpp b/intern/cycles/session/denoising.cpp index 377583bdba9..77c00689029 100644 --- a/intern/cycles/session/denoising.cpp +++ b/intern/cycles/session/denoising.cpp @@ -160,7 +160,7 @@ bool DenoiseImageLayer::match_channels(const std::vector &channelnames, /* Denoise Task */ -DenoiseTask::DenoiseTask(Device *device, DenoiserPipeline *denoiser, int frame) +DenoiseTask::DenoiseTask(Device *device, DenoiserPipeline *denoiser, const int frame) : denoiser(denoiser), device(device), frame(frame), current_layer(0), buffers(device) { } @@ -172,7 +172,7 @@ DenoiseTask::~DenoiseTask() /* Denoiser Operations */ -bool DenoiseTask::load_input_pixels(int layer) +bool DenoiseTask::load_input_pixels(const int layer) { /* Load center image */ const DenoiseImageLayer &image_layer = image.layers[layer]; diff --git a/intern/cycles/session/denoising.h b/intern/cycles/session/denoising.h index 8058a7781b2..48241c6f387 100644 --- a/intern/cycles/session/denoising.h +++ b/intern/cycles/session/denoising.h @@ -141,7 +141,7 @@ class DenoiseImage { class DenoiseTask { public: - DenoiseTask(Device *device, DenoiserPipeline *denoiser, int frame); + DenoiseTask(Device *device, DenoiserPipeline *denoiser, const int frame); ~DenoiseTask(); /* Task stages */ @@ -167,7 +167,7 @@ class DenoiseTask { RenderBuffers buffers; /* Task handling */ - bool load_input_pixels(int layer); + bool load_input_pixels(const int layer); }; CCL_NAMESPACE_END diff --git a/intern/cycles/session/display_driver.h b/intern/cycles/session/display_driver.h index d23f976cdf1..05e184fb318 100644 --- a/intern/cycles/session/display_driver.h +++ b/intern/cycles/session/display_driver.h @@ -67,7 +67,7 @@ class DisplayDriver { * account progressive resolution changes, which may be equal to or smaller than the params.size. * For efficiency, changes in this resolution should be handled without re-allocating resources, * but rather by using a subset of the full resolution buffer. */ - virtual bool update_begin(const Params ¶ms, int width, int height) = 0; + virtual bool update_begin(const Params ¶ms, const int width, const int height) = 0; virtual void update_end() = 0; /* Optionally flush outstanding display commands before ending the render loop. */ diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp index e897e2a2d56..4500925fb9f 100644 --- a/intern/cycles/session/session.cpp +++ b/intern/cycles/session/session.cpp @@ -578,7 +578,7 @@ void Session::reset(const SessionParams &session_params, const BufferParams &buf pause_cond_.notify_all(); } -void Session::set_samples(int samples) +void Session::set_samples(const int samples) { if (samples == params.samples) { return; @@ -594,7 +594,7 @@ void Session::set_samples(int samples) pause_cond_.notify_all(); } -void Session::set_time_limit(double time_limit) +void Session::set_time_limit(const double time_limit) { if (time_limit == params.time_limit) { return; @@ -676,7 +676,7 @@ void Session::wait() } } -bool Session::update_scene(int width, int height) +bool Session::update_scene(const int width, const int height) { /* Update camera if dimensions changed for progressive render. the camera * knows nothing about progressive or cropped rendering, it just gets the diff --git a/intern/cycles/session/session.h b/intern/cycles/session/session.h index af3b908b92b..ed0aea2d139 100644 --- a/intern/cycles/session/session.h +++ b/intern/cycles/session/session.h @@ -138,8 +138,8 @@ class Session { void set_pause(bool pause); - void set_samples(int samples); - void set_time_limit(double time_limit); + void set_samples(const int samples); + void set_time_limit(const double time_limit); void set_output_driver(unique_ptr driver); void set_display_driver(unique_ptr driver); @@ -200,7 +200,7 @@ class Session { void run_main_render_loop(); - bool update_scene(int width, int height); + bool update_scene(const int width, const int height); void update_status_time(bool show_pause = false, bool show_done = false); diff --git a/intern/cycles/session/tile.cpp b/intern/cycles/session/tile.cpp index 2ed8c0c203c..540306d6ad2 100644 --- a/intern/cycles/session/tile.cpp +++ b/intern/cycles/session/tile.cpp @@ -332,7 +332,7 @@ int TileManager::compute_render_tile_size(const int suggested_tile_size) const return min(computed_tile_size, MAX_TILE_SIZE); } -void TileManager::reset_scheduling(const BufferParams ¶ms, int2 tile_size) +void TileManager::reset_scheduling(const BufferParams ¶ms, const int2 tile_size) { VLOG_WORK << "Using tile size of " << tile_size; @@ -404,7 +404,7 @@ bool TileManager::next() return true; } -Tile TileManager::get_tile_for_index(int index) const +Tile TileManager::get_tile_for_index(const int index) const { /* TODO(sergey): Consider using hilbert spiral, or. maybe, even configurable. Not sure this * brings a lot of value since this is only applicable to BIG tiles. */ diff --git a/intern/cycles/session/tile.h b/intern/cycles/session/tile.h index 00b992ff7e7..66e38b7cb0d 100644 --- a/intern/cycles/session/tile.h +++ b/intern/cycles/session/tile.h @@ -54,7 +54,7 @@ class TileManager { * Only touches scheduling-related state of the tile manager. */ /* TODO(sergey): Consider using tile area instead of exact size to help dealing with extreme * cases of stretched renders. */ - void reset_scheduling(const BufferParams ¶ms, int2 tile_size); + void reset_scheduling(const BufferParams ¶ms, const int2 tile_size); /* Update for the known buffer passes and scene parameters. * Will store all parameters needed for buffers access outside of the scene graph. */ @@ -122,7 +122,7 @@ class TileManager { protected: /* Get tile configuration for its index. * The tile index must be within [0, state_.tile_state_). */ - Tile get_tile_for_index(int index) const; + Tile get_tile_for_index(const int index) const; bool open_tile_output(); bool close_tile_output(); diff --git a/intern/cycles/subd/dice.cpp b/intern/cycles/subd/dice.cpp index 0d94249943c..436798fae06 100644 --- a/intern/cycles/subd/dice.cpp +++ b/intern/cycles/subd/dice.cpp @@ -26,7 +26,7 @@ EdgeDice::EdgeDice(const SubdParams ¶ms_) : params(params_) } } -void EdgeDice::reserve(int num_verts, int num_triangles) +void EdgeDice::reserve(const int num_verts, const int num_triangles) { Mesh *mesh = params.mesh; @@ -44,7 +44,7 @@ void EdgeDice::reserve(int num_verts, int num_triangles) params.mesh->num_subd_verts += num_verts; } -void EdgeDice::set_vert(Patch *patch, int index, float2 uv) +void EdgeDice::set_vert(Patch *patch, const int index, const float2 uv) { float3 P; float3 N; @@ -58,7 +58,7 @@ void EdgeDice::set_vert(Patch *patch, int index, float2 uv) params.mesh->vert_patch_uv[index + vert_offset] = make_float2(uv.x, uv.y); } -void EdgeDice::add_triangle(Patch *patch, int v0, int v1, int v2) +void EdgeDice::add_triangle(Patch *patch, const int v0, const int v1, const int v2) { Mesh *mesh = params.mesh; @@ -68,7 +68,7 @@ void EdgeDice::add_triangle(Patch *patch, int v0, int v1, int v2) tri_offset++; } -void EdgeDice::stitch_triangles(Subpatch &sub, int edge) +void EdgeDice::stitch_triangles(Subpatch &sub, const int edge) { int Mu = max(sub.edge_u0.T, sub.edge_u1.T); int Mv = max(sub.edge_v0.T, sub.edge_v1.T); @@ -124,7 +124,7 @@ void EdgeDice::stitch_triangles(Subpatch &sub, int edge) QuadDice::QuadDice(const SubdParams ¶ms_) : EdgeDice(params_) {} -float2 QuadDice::map_uv(Subpatch &sub, float u, float v) +float2 QuadDice::map_uv(Subpatch &sub, const float u, float v) { /* map UV from subpatch to patch parametric coordinates */ const float2 d0 = interp(sub.c00, sub.c01, v); @@ -132,7 +132,7 @@ float2 QuadDice::map_uv(Subpatch &sub, float u, float v) return interp(d0, d1, u); } -float3 QuadDice::eval_projected(Subpatch &sub, float u, float v) +float3 QuadDice::eval_projected(Subpatch &sub, const float u, float v) { const float2 uv = map_uv(sub, u, v); float3 P; @@ -145,12 +145,12 @@ float3 QuadDice::eval_projected(Subpatch &sub, float u, float v) return P; } -void QuadDice::set_vert(Subpatch &sub, int index, float u, float v) +void QuadDice::set_vert(Subpatch &sub, const int index, const float u, float v) { EdgeDice::set_vert(sub.patch, index, map_uv(sub, u, v)); } -void QuadDice::set_side(Subpatch &sub, int edge) +void QuadDice::set_side(Subpatch &sub, const int edge) { const int t = sub.edges[edge].T; @@ -189,7 +189,7 @@ float QuadDice::quad_area(const float3 &a, const float3 &b, const float3 &c, con return triangle_area(a, b, d) + triangle_area(a, d, c); } -float QuadDice::scale_factor(Subpatch &sub, int Mu, int Mv) +float QuadDice::scale_factor(Subpatch &sub, const int Mu, const int Mv) { /* estimate area as 4x largest of 4 quads */ float3 P[3][3]; @@ -220,7 +220,7 @@ float QuadDice::scale_factor(Subpatch &sub, int Mu, int Mv) return S; } -void QuadDice::add_grid(Subpatch &sub, int Mu, int Mv, int offset) +void QuadDice::add_grid(Subpatch &sub, const int Mu, const int Mv, const int offset) { /* create inner grid */ const float du = 1.0f / (float)Mu; diff --git a/intern/cycles/subd/dice.h b/intern/cycles/subd/dice.h index fb7b258f2c1..7f5e519344a 100644 --- a/intern/cycles/subd/dice.h +++ b/intern/cycles/subd/dice.h @@ -55,12 +55,12 @@ class EdgeDice { explicit EdgeDice(const SubdParams ¶ms); - void reserve(int num_verts, int num_triangles); + void reserve(const int num_verts, const int num_triangles); - void set_vert(Patch *patch, int index, float2 uv); - void add_triangle(Patch *patch, int v0, int v1, int v2); + void set_vert(Patch *patch, const int index, const float2 uv); + void add_triangle(Patch *patch, const int v0, const int v1, const int v2); - void stitch_triangles(Subpatch &sub, int edge); + void stitch_triangles(Subpatch &sub, const int edge); }; /* Quad EdgeDice */ @@ -69,17 +69,17 @@ class QuadDice : public EdgeDice { public: explicit QuadDice(const SubdParams ¶ms); - float3 eval_projected(Subpatch &sub, float u, float v); + float3 eval_projected(Subpatch &sub, const float u, float v); - float2 map_uv(Subpatch &sub, float u, float v); - void set_vert(Subpatch &sub, int index, float u, float v); + float2 map_uv(Subpatch &sub, const float u, float v); + void set_vert(Subpatch &sub, const int index, const float u, float v); - void add_grid(Subpatch &sub, int Mu, int Mv, int offset); + void add_grid(Subpatch &sub, const int Mu, const int Mv, const int offset); - void set_side(Subpatch &sub, int edge); + void set_side(Subpatch &sub, const int edge); float quad_area(const float3 &a, const float3 &b, const float3 &c, const float3 &d); - float scale_factor(Subpatch &sub, int Mu, int Mv); + float scale_factor(Subpatch &sub, const int Mu, const int Mv); void dice(Subpatch &sub); }; diff --git a/intern/cycles/subd/patch.cpp b/intern/cycles/subd/patch.cpp index 034e76673a3..f22fbdba360 100644 --- a/intern/cycles/subd/patch.cpp +++ b/intern/cycles/subd/patch.cpp @@ -13,7 +13,7 @@ CCL_NAMESPACE_BEGIN /* De Casteljau Evaluation */ -static void decasteljau_cubic(float3 *P, float3 *dt, float t, const float3 cp[4]) +static void decasteljau_cubic(float3 *P, float3 *dt, const float t, const float3 cp[4]) { float3 d0 = cp[0] + t * (cp[1] - cp[0]); float3 d1 = cp[1] + t * (cp[2] - cp[1]); @@ -29,7 +29,7 @@ static void decasteljau_cubic(float3 *P, float3 *dt, float t, const float3 cp[4] } static void decasteljau_bicubic( - float3 *P, float3 *du, float3 *dv, const float3 cp[16], float u, float v) + float3 *P, float3 *du, float3 *dv, const float3 cp[16], float u, const float v) { float3 ucp[4]; float3 utn[4]; @@ -49,7 +49,8 @@ static void decasteljau_bicubic( /* Linear Quad Patch */ -void LinearQuadPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) +void LinearQuadPatch::eval( + float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) { const float3 d0 = interp(hull[0], hull[1], u); const float3 d1 = interp(hull[2], hull[3], u); @@ -80,7 +81,7 @@ BoundBox LinearQuadPatch::bound() /* Bicubic Patch */ -void BicubicPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) +void BicubicPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) { if (N) { float3 dPdu_; diff --git a/intern/cycles/subd/patch.h b/intern/cycles/subd/patch.h index 8b65840bf38..2d32a086d14 100644 --- a/intern/cycles/subd/patch.h +++ b/intern/cycles/subd/patch.h @@ -15,7 +15,7 @@ class Patch { virtual ~Patch() = default; - virtual void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) = 0; + virtual void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) = 0; int patch_index = 0; int shader = 0; @@ -29,7 +29,7 @@ class LinearQuadPatch : public Patch { float3 hull[4]; float3 normals[4]; - void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) override; + void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) override; BoundBox bound(); }; @@ -39,7 +39,7 @@ class BicubicPatch : public Patch { public: float3 hull[16]; - void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v) override; + void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, const float u, float v) override; BoundBox bound(); }; diff --git a/intern/cycles/subd/patch_table.cpp b/intern/cycles/subd/patch_table.cpp index 90d0f447f68..ee8a26cdd57 100644 --- a/intern/cycles/subd/patch_table.cpp +++ b/intern/cycles/subd/patch_table.cpp @@ -25,7 +25,7 @@ using namespace OpenSubdiv; struct PatchMapQuadNode { /* sets all the children to point to the patch of index */ - void set_child(int index) + void set_child(const int index) { for (int i = 0; i < 4; i++) { children[i] = index | PATCH_MAP_NODE_IS_SET | PATCH_MAP_NODE_IS_LEAF; @@ -33,7 +33,7 @@ struct PatchMapQuadNode { } /* sets the child in quadrant to point to the node or patch of the given index */ - void set_child(unsigned char quadrant, int index, bool is_leaf = true) + void set_child(unsigned char quadrant, const int index, bool is_leaf = true) { assert(quadrant < 4); children[quadrant] = index | PATCH_MAP_NODE_IS_SET | (is_leaf ? PATCH_MAP_NODE_IS_LEAF : 0); @@ -174,7 +174,7 @@ size_t PackedPatchTable::total_size() num_patches * (PATCH_PARAM_SIZE + PATCH_HANDLE_SIZE) + num_nodes * PATCH_NODE_SIZE; } -void PackedPatchTable::pack(Far::PatchTable *patch_table, int offset) +void PackedPatchTable::pack(Far::PatchTable *patch_table, const int offset) { num_arrays = 0; num_patches = 0; @@ -236,7 +236,7 @@ void PackedPatchTable::pack(Far::PatchTable *patch_table, int offset) #endif } -void PackedPatchTable::copy_adjusting_offsets(uint *dest, int doffset) +void PackedPatchTable::copy_adjusting_offsets(uint *dest, const int doffset) { uint *src = table.data(); diff --git a/intern/cycles/subd/patch_table.h b/intern/cycles/subd/patch_table.h index d44cce12eae..b744ef405ff 100644 --- a/intern/cycles/subd/patch_table.h +++ b/intern/cycles/subd/patch_table.h @@ -44,8 +44,8 @@ struct PackedPatchTable { /* calculated size from num_* members */ size_t total_size(); - void pack(Far::PatchTable *patch_table, int offset = 0); - void copy_adjusting_offsets(uint *dest, int doffset); + void pack(Far::PatchTable *patch_table, const int offset = 0); + void copy_adjusting_offsets(uint *dest, const int doffset); }; CCL_NAMESPACE_END diff --git a/intern/cycles/subd/split.cpp b/intern/cycles/subd/split.cpp index 915c4ffcd17..9227de34708 100644 --- a/intern/cycles/subd/split.cpp +++ b/intern/cycles/subd/split.cpp @@ -27,7 +27,7 @@ enum { DiagSplit::DiagSplit(const SubdParams ¶ms_) : params(params_) {} -float3 DiagSplit::to_world(Patch *patch, float2 uv) +float3 DiagSplit::to_world(Patch *patch, const float2 uv) { float3 P; @@ -46,7 +46,7 @@ static void order_float2(float2 &a, float2 &b) } } -int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend, bool recursive_resolve) +int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend, const bool recursive_resolve) { order_float2(Pstart, Pend); /* May not be necessary, but better to be safe. */ @@ -99,7 +99,7 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend, bool recursive_resolv } void DiagSplit::partition_edge( - Patch *patch, float2 *P, int *t0, int *t1, float2 Pstart, float2 Pend, int t) + Patch *patch, float2 *P, int *t0, int *t1, const float2 Pstart, const float2 Pend, const int t) { if (t == DSPLIT_NON_UNIFORM) { *P = (Pstart + Pend) * 0.5f; @@ -116,7 +116,7 @@ void DiagSplit::partition_edge( } } -void DiagSplit::limit_edge_factor(int &T, Patch *patch, float2 Pstart, float2 Pend) +void DiagSplit::limit_edge_factor(int &T, Patch *patch, const float2 Pstart, const float2 Pend) { const int max_t = 1 << params.max_level; int max_t_for_edge = int(max_t * len(Pstart - Pend)); @@ -147,7 +147,7 @@ void DiagSplit::resolve_edge_factors(Subpatch &sub) } } -void DiagSplit::split(Subpatch &sub, int depth) +void DiagSplit::split(Subpatch &sub, const int depth) { if (depth > 32) { /* We should never get here, but just in case end recursion safely. */ @@ -322,7 +322,7 @@ void DiagSplit::split(Subpatch &sub, int depth) } } -int DiagSplit::alloc_verts(int n) +int DiagSplit::alloc_verts(const int n) { const int a = num_alloced_verts; num_alloced_verts += n; @@ -335,7 +335,7 @@ Edge *DiagSplit::alloc_edge() return &edges.back(); } -void DiagSplit::split_patches(Patch *patches, size_t patches_byte_stride) +void DiagSplit::split_patches(Patch *patches, const size_t patches_byte_stride) { int patch_index = 0; @@ -365,7 +365,7 @@ void DiagSplit::split_patches(Patch *patches, size_t patches_byte_stride) static Edge *create_edge_from_corner(DiagSplit *split, const Mesh *mesh, const Mesh::SubdFace &face, - int corner, + const int corner, bool &reversed, int v0, int v1) @@ -435,12 +435,12 @@ void DiagSplit::split_quad(const Mesh::SubdFace &face, Patch *patch) static Edge *create_split_edge_from_corner(DiagSplit *split, const Mesh *mesh, const Mesh::SubdFace &face, - int corner, - int side, + const int corner, + const int side, bool &reversed, int v0, int v1, - int vc) + const int vc) { Edge *edge = split->alloc_edge(); @@ -478,7 +478,9 @@ static Edge *create_split_edge_from_corner(DiagSplit *split, return edge; } -void DiagSplit::split_ngon(const Mesh::SubdFace &face, Patch *patches, size_t patches_byte_stride) +void DiagSplit::split_ngon(const Mesh::SubdFace &face, + Patch *patches, + const size_t patches_byte_stride) { Edge *prev_edge_u0 = nullptr; Edge *first_edge_v0 = nullptr; diff --git a/intern/cycles/subd/split.h b/intern/cycles/subd/split.h index bb872376698..54aacc76227 100644 --- a/intern/cycles/subd/split.h +++ b/intern/cycles/subd/split.h @@ -30,29 +30,34 @@ class DiagSplit { /* `deque` is used so that element pointers remain valid when size is changed. */ deque edges; - float3 to_world(Patch *patch, float2 uv); - int T(Patch *patch, float2 Pstart, float2 Pend, bool recursive_resolve = false); + float3 to_world(Patch *patch, const float2 uv); + int T(Patch *patch, const float2 Pstart, const float2 Pend, bool recursive_resolve = false); - void limit_edge_factor(int &T, Patch *patch, float2 Pstart, float2 Pend); + void limit_edge_factor(int &T, Patch *patch, const float2 Pstart, const float2 Pend); void resolve_edge_factors(Subpatch &sub); - void partition_edge( - Patch *patch, float2 *P, int *t0, int *t1, float2 Pstart, float2 Pend, int t); + void partition_edge(Patch *patch, + float2 *P, + int *t0, + int *t1, + const float2 Pstart, + const float2 Pend, + const int t); - void split(Subpatch &sub, int depth = 0); + void split(Subpatch &sub, const int depth = 0); int num_alloced_verts = 0; - int alloc_verts(int n); /* Returns start index of new verts. */ + int alloc_verts(const int n); /* Returns start index of new verts. */ public: Edge *alloc_edge(); explicit DiagSplit(const SubdParams ¶ms); - void split_patches(Patch *patches, size_t patches_byte_stride); + void split_patches(Patch *patches, const size_t patches_byte_stride); void split_quad(const Mesh::SubdFace &face, Patch *patch); - void split_ngon(const Mesh::SubdFace &face, Patch *patches, size_t patches_byte_stride); + void split_ngon(const Mesh::SubdFace &face, Patch *patches, const size_t patches_byte_stride); void post_split(); }; diff --git a/intern/cycles/subd/subpatch.h b/intern/cycles/subd/subpatch.h index 919bfdd983e..f7c0d5cbdab 100644 --- a/intern/cycles/subd/subpatch.h +++ b/intern/cycles/subd/subpatch.h @@ -25,7 +25,7 @@ class Subpatch { struct Edge *edge; - int get_vert_along_edge(int n) const; + int get_vert_along_edge(const int n) const; }; /* @@ -62,7 +62,7 @@ class Subpatch { { } - Subpatch(Patch *patch, float2 c00, float2 c01, float2 c11, float2 c10) + Subpatch(Patch *patch, const float2 c00, const float2 c01, const float2 c11, const float2 c10) : patch(patch), c00(c00), c01(c01), c11(c11), c10(c10) { } @@ -90,9 +90,9 @@ class Subpatch { return inner_triangles + edge_triangles; } - int get_vert_along_edge(int e, int n) const; + int get_vert_along_edge(const int e, const int n) const; - int get_vert_along_grid_edge(int edge, int n) const + int get_vert_along_grid_edge(const int edge, const int n) const { int Mu = fmax(edge_u0.T, edge_u1.T); int Mv = fmax(edge_v0.T, edge_v1.T); @@ -149,7 +149,7 @@ struct Edge { Edge() = default; - int get_vert_along_edge(int n) const + int get_vert_along_edge(const int n) const { assert(n >= 0 && n <= T); @@ -164,9 +164,11 @@ struct Edge { } }; -inline int Subpatch::edge_t::get_vert_along_edge(int n) const +inline int Subpatch::edge_t::get_vert_along_edge(const int n_relative) const { - assert(n >= 0 && n <= T); + assert(n_relative >= 0 && n_relative <= T); + + int n = n_relative; if (!indices_decrease_along_edge && !sub_edges_created_in_reverse_order) { n = offset + n; @@ -184,7 +186,7 @@ inline int Subpatch::edge_t::get_vert_along_edge(int n) const return edge->get_vert_along_edge(n); } -inline int Subpatch::get_vert_along_edge(int edge, int n) const +inline int Subpatch::get_vert_along_edge(const int edge, const int n) const { return edges[edge].get_vert_along_edge(n); } diff --git a/intern/cycles/test/render_graph_finalize_test.cpp b/intern/cycles/test/render_graph_finalize_test.cpp index 064ce80dc5f..94dff0c0ef3 100644 --- a/intern/cycles/test/render_graph_finalize_test.cpp +++ b/intern/cycles/test/render_graph_finalize_test.cpp @@ -631,7 +631,7 @@ TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_1) */ static void build_mix_partial_test_graph(ShaderGraphBuilder &builder, NodeMix type, - float3 constval) + const float3 constval) { builder .add_attribute("Attribute") @@ -1022,7 +1022,7 @@ TEST_F(RenderGraph, constant_fold_math_clamp) */ static void build_math_partial_test_graph(ShaderGraphBuilder &builder, NodeMathType type, - float constval) + const float constval) { builder .add_attribute("Attribute") @@ -1192,7 +1192,7 @@ TEST_F(RenderGraph, constant_fold_vector_math) */ static void build_vecmath_partial_test_graph(ShaderGraphBuilder &builder, NodeVectorMathType type, - float3 constval) + const float3 constval) { builder .add_attribute("Attribute") @@ -1289,7 +1289,7 @@ TEST_F(RenderGraph, constant_fold_bump_no_input) graph.finalize(scene); } -template void init_test_curve(array &buffer, T start, T end, int steps) +template void init_test_curve(array &buffer, T start, T end, const int steps) { buffer.resize(steps); diff --git a/intern/cycles/util/aligned_malloc.cpp b/intern/cycles/util/aligned_malloc.cpp index 67f56b7aec7..b206c00157c 100644 --- a/intern/cycles/util/aligned_malloc.cpp +++ b/intern/cycles/util/aligned_malloc.cpp @@ -31,7 +31,7 @@ CCL_NAMESPACE_BEGIN -void *util_aligned_malloc(size_t size, int alignment) +void *util_aligned_malloc(const size_t size, const int alignment) { #ifdef WITH_BLENDER_GUARDEDALLOC return MEM_mallocN_aligned(size, alignment, "Cycles Aligned Alloc"); diff --git a/intern/cycles/util/aligned_malloc.h b/intern/cycles/util/aligned_malloc.h index cded043f83a..fbb9f4aa16b 100644 --- a/intern/cycles/util/aligned_malloc.h +++ b/intern/cycles/util/aligned_malloc.h @@ -12,7 +12,7 @@ CCL_NAMESPACE_BEGIN #define MIN_ALIGNMENT_CPU_DATA_TYPES 16 // NOLINT /* Allocate block of size bytes at least aligned to a given value. */ -void *util_aligned_malloc(size_t size, int alignment); +void *util_aligned_malloc(const size_t size, const int alignment); /* Free memory allocated by util_aligned_malloc. */ void util_aligned_free(void *ptr); diff --git a/intern/cycles/util/array.h b/intern/cycles/util/array.h index c948e2dbcb8..bf37dc227a1 100644 --- a/intern/cycles/util/array.h +++ b/intern/cycles/util/array.h @@ -20,11 +20,11 @@ CCL_NAMESPACE_BEGIN * - if this is used, we are not tempted to use inefficient operations * - aligned allocation for CPU native data types */ -template class array { +template class array { public: array() : data_(nullptr), datasize_(0), capacity_(0) {} - explicit array(size_t newsize) + explicit array(const size_t newsize) { if (newsize == 0) { data_ = nullptr; @@ -131,7 +131,7 @@ template class arra return ptr; } - T *resize(size_t newsize) + T *resize(const size_t newsize) { if (newsize == 0) { clear(); @@ -156,7 +156,7 @@ template class arra return data_; } - T *resize(size_t newsize, const T &value) + T *resize(const size_t newsize, const T &value) { size_t oldsize = size(); resize(newsize); @@ -224,7 +224,7 @@ template class arra return data_ + datasize_; } - void reserve(size_t newcapacity) + void reserve(const size_t newcapacity) { if (newcapacity > capacity_) { T *newdata = mem_allocate(newcapacity); @@ -268,7 +268,7 @@ template class arra } protected: - T *mem_allocate(size_t N) + T *mem_allocate(const size_t N) { if (N == 0) { return nullptr; @@ -283,7 +283,7 @@ template class arra return mem; } - void mem_free(T *mem, size_t N) + void mem_free(T *mem, const size_t N) { if (mem != nullptr) { util_guarded_mem_free(sizeof(T) * N); diff --git a/intern/cycles/util/atomic.h b/intern/cycles/util/atomic.h index 561da568b16..1a41f0d9237 100644 --- a/intern/cycles/util/atomic.h +++ b/intern/cycles/util/atomic.h @@ -82,12 +82,12 @@ ccl_device_inline float atomic_add_and_fetch_float(volatile ccl_global float *_s # endif } -template ccl_device_inline uint32_t atomic_fetch_and_add_uint32(device T *p, int x) +template ccl_device_inline uint32_t atomic_fetch_and_add_uint32(device T *p, const int x) { return atomic_fetch_add_explicit((device atomic_uint *)p, x, memory_order_relaxed); } -template ccl_device_inline uint32_t atomic_fetch_and_sub_uint32(device T *p, int x) +template ccl_device_inline uint32_t atomic_fetch_and_sub_uint32(device T *p, const int x) { return atomic_fetch_sub_explicit((device atomic_uint *)p, x, memory_order_relaxed); } @@ -102,17 +102,19 @@ template ccl_device_inline uint32_t atomic_fetch_and_dec_uint32(device return atomic_fetch_sub_explicit((device atomic_uint *)p, 1, memory_order_relaxed); } -template ccl_device_inline uint32_t atomic_fetch_and_or_uint32(device T *p, int x) +template ccl_device_inline uint32_t atomic_fetch_and_or_uint32(device T *p, const int x) { return atomic_fetch_or_explicit((device atomic_uint *)p, x, memory_order_relaxed); } -template ccl_device_inline uint32_t atomic_fetch_and_add_uint32(threadgroup T *p, int x) +template +ccl_device_inline uint32_t atomic_fetch_and_add_uint32(threadgroup T *p, const int x) { return atomic_fetch_add_explicit((threadgroup atomic_uint *)p, x, memory_order_relaxed); } -template ccl_device_inline uint32_t atomic_fetch_and_sub_uint32(threadgroup T *p, int x) +template +ccl_device_inline uint32_t atomic_fetch_and_sub_uint32(threadgroup T *p, const int x) { return atomic_fetch_sub_explicit((threadgroup atomic_uint *)p, x, memory_order_relaxed); } @@ -127,7 +129,8 @@ template ccl_device_inline uint32_t atomic_fetch_and_dec_uint32(threadg return atomic_fetch_sub_explicit((threadgroup atomic_uint *)p, 1, memory_order_relaxed); } -template ccl_device_inline uint32_t atomic_fetch_and_or_uint32(threadgroup T *p, int x) +template +ccl_device_inline uint32_t atomic_fetch_and_or_uint32(threadgroup T *p, const int x) { return atomic_fetch_or_explicit((threadgroup atomic_uint *)p, x, memory_order_relaxed); } @@ -171,7 +174,7 @@ ccl_device_inline float atomic_compare_and_swap_float(volatile ccl_global float # ifdef __KERNEL_ONEAPI__ -ccl_device_inline float atomic_add_and_fetch_float(ccl_global float *p, float x) +ccl_device_inline float atomic_add_and_fetch_float(ccl_global float *p, const float x) { sycl::atomic_ref (1.0f - 0.5f / 255.0f)) ? 255 : (uchar)((255.0f * val) + 0.5f))); // NOLINT } -ccl_device float byte_to_float(uchar val) +ccl_device float byte_to_float(const uchar val) { return val * (1.0f / 255.0f); } -ccl_device uchar4 color_float_to_byte(float3 c) +ccl_device uchar4 color_float_to_byte(const float3 c) { uchar r; uchar g; @@ -34,7 +34,7 @@ ccl_device uchar4 color_float_to_byte(float3 c) return make_uchar4(r, g, b, 0); } -ccl_device uchar4 color_float4_to_uchar4(float4 c) +ccl_device uchar4 color_float4_to_uchar4(const float4 c) { uchar r; uchar g; @@ -49,18 +49,18 @@ ccl_device uchar4 color_float4_to_uchar4(float4 c) return make_uchar4(r, g, b, a); } -ccl_device_inline float3 color_byte_to_float(uchar4 c) +ccl_device_inline float3 color_byte_to_float(const uchar4 c) { return make_float3(c.x * (1.0f / 255.0f), c.y * (1.0f / 255.0f), c.z * (1.0f / 255.0f)); } -ccl_device_inline float4 color_uchar4_to_float4(uchar4 c) +ccl_device_inline float4 color_uchar4_to_float4(const uchar4 c) { return make_float4( c.x * (1.0f / 255.0f), c.y * (1.0f / 255.0f), c.z * (1.0f / 255.0f), c.w * (1.0f / 255.0f)); } -ccl_device float color_srgb_to_linear(float c) +ccl_device float color_srgb_to_linear(const float c) { if (c < 0.04045f) { return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f); @@ -68,7 +68,7 @@ ccl_device float color_srgb_to_linear(float c) return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f); } -ccl_device float color_linear_to_srgb(float c) +ccl_device float color_linear_to_srgb(const float c) { if (c < 0.0031308f) { return (c < 0.0f) ? 0.0f : c * 12.92f; @@ -76,7 +76,7 @@ ccl_device float color_linear_to_srgb(float c) return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f; } -ccl_device float3 rgb_to_hsv(float3 rgb) +ccl_device float3 rgb_to_hsv(const float3 rgb) { float cmax; float cmin; @@ -127,7 +127,7 @@ ccl_device float3 rgb_to_hsv(float3 rgb) return make_float3(h, s, v); } -ccl_device float3 hsv_to_rgb(float3 hsv) +ccl_device float3 hsv_to_rgb(const float3 hsv) { float i; float f; @@ -182,7 +182,7 @@ ccl_device float3 hsv_to_rgb(float3 hsv) return rgb; } -ccl_device float3 rgb_to_hsl(float3 rgb) +ccl_device float3 rgb_to_hsl(const float3 rgb) { float cmax; float cmin; @@ -215,7 +215,7 @@ ccl_device float3 rgb_to_hsl(float3 rgb) return make_float3(h, s, l); } -ccl_device float3 hsl_to_rgb(float3 hsl) +ccl_device float3 hsl_to_rgb(const float3 hsl) { float nr; float ng; @@ -242,7 +242,7 @@ ccl_device float3 hsl_to_rgb(float3 hsl) return make_float3((nr - 0.5f) * chroma + l, (ng - 0.5f) * chroma + l, (nb - 0.5f) * chroma + l); } -ccl_device float3 xyY_to_xyz(float x, float y, float Y) +ccl_device float3 xyY_to_xyz(const float x, const float y, float Y) { float X; float Z; @@ -326,25 +326,25 @@ ccl_device float4 color_srgb_to_linear_sse2(const float4 &c) } #endif /* __KERNEL_SSE2__ */ -ccl_device float3 color_srgb_to_linear_v3(float3 c) +ccl_device float3 color_srgb_to_linear_v3(const float3 c) { return make_float3( color_srgb_to_linear(c.x), color_srgb_to_linear(c.y), color_srgb_to_linear(c.z)); } -ccl_device float3 color_linear_to_srgb_v3(float3 c) +ccl_device float3 color_linear_to_srgb_v3(const float3 c) { return make_float3( color_linear_to_srgb(c.x), color_linear_to_srgb(c.y), color_linear_to_srgb(c.z)); } -ccl_device float4 color_linear_to_srgb_v4(float4 c) +ccl_device float4 color_linear_to_srgb_v4(const float4 c) { return make_float4( color_linear_to_srgb(c.x), color_linear_to_srgb(c.y), color_linear_to_srgb(c.z), c.w); } -ccl_device float4 color_srgb_to_linear_v4(float4 c) +ccl_device float4 color_srgb_to_linear_v4(const float4 c) { #ifdef __KERNEL_SSE2__ float4 r = c; @@ -366,7 +366,7 @@ ccl_device float3 color_highlight_compress(float3 color, ccl_private float3 *var return log(color); } -ccl_device float3 color_highlight_uncompress(float3 color) +ccl_device float3 color_highlight_uncompress(const float3 color) { return exp(color) - one_float3(); } @@ -396,7 +396,7 @@ ccl_device_inline Spectrum safe_divide_color(Spectrum a, Spectrum b, const float return a; } -ccl_device_inline float3 safe_divide_even_color(float3 a, float3 b) +ccl_device_inline float3 safe_divide_even_color(const float3 a, const float3 b) { float x; float y; diff --git a/intern/cycles/util/disjoint_set.h b/intern/cycles/util/disjoint_set.h index 17d6a215a10..bd4afd3d424 100644 --- a/intern/cycles/util/disjoint_set.h +++ b/intern/cycles/util/disjoint_set.h @@ -15,7 +15,7 @@ class DisjointSet { array ranks; public: - DisjointSet(size_t size) : parents(size), ranks(size) + DisjointSet(const size_t size) : parents(size), ranks(size) { for (size_t i = 0; i < size; i++) { parents[i] = i; @@ -37,7 +37,7 @@ class DisjointSet { return root; } - void join(size_t x, size_t y) + void join(const size_t x, const size_t y) { size_t x_root = find(x); size_t y_root = find(y); diff --git a/intern/cycles/util/guarded_allocator.cpp b/intern/cycles/util/guarded_allocator.cpp index 950c8419e98..f64d39ff986 100644 --- a/intern/cycles/util/guarded_allocator.cpp +++ b/intern/cycles/util/guarded_allocator.cpp @@ -11,12 +11,12 @@ static Stats global_stats(Stats::static_init); /* Internal API. */ -void util_guarded_mem_alloc(size_t n) +void util_guarded_mem_alloc(const size_t n) { global_stats.mem_alloc(n); } -void util_guarded_mem_free(size_t n) +void util_guarded_mem_free(const size_t n) { global_stats.mem_free(n); } diff --git a/intern/cycles/util/guarded_allocator.h b/intern/cycles/util/guarded_allocator.h index b489aa6a9d0..cb20211a3d5 100644 --- a/intern/cycles/util/guarded_allocator.h +++ b/intern/cycles/util/guarded_allocator.h @@ -14,8 +14,8 @@ CCL_NAMESPACE_BEGIN /* Internal use only. */ -void util_guarded_mem_alloc(size_t n); -void util_guarded_mem_free(size_t n); +void util_guarded_mem_alloc(const size_t n); +void util_guarded_mem_free(const size_t n); /* Guarded allocator for the use with STL. */ template class GuardedAllocator { @@ -31,7 +31,7 @@ template class GuardedAllocator { GuardedAllocator() = default; GuardedAllocator(const GuardedAllocator & /*unused*/) = default; - T *allocate(size_t n, const void *hint = nullptr) + T *allocate(const size_t n, const void *hint = nullptr) { (void)hint; size_t size = n * sizeof(T); @@ -56,7 +56,7 @@ template class GuardedAllocator { return mem; } - void deallocate(T *p, size_t n) + void deallocate(T *p, const size_t n) { util_guarded_mem_free(n * sizeof(T)); if (p != nullptr) { diff --git a/intern/cycles/util/half.h b/intern/cycles/util/half.h index bcfc609b30c..397fe8b3b43 100644 --- a/intern/cycles/util/half.h +++ b/intern/cycles/util/half.h @@ -67,7 +67,7 @@ struct half4 { * Simplified float to half for fast sampling on processor without a native * instruction, and eliminating any NaN and inf values. */ -ccl_device_inline half float_to_half_image(float f) +ccl_device_inline half float_to_half_image(const float f) { #if defined(__KERNEL_METAL__) || defined(__KERNEL_ONEAPI__) return half(min(f, 65504.0f)); diff --git a/intern/cycles/util/hash.h b/intern/cycles/util/hash.h index b6d1163789a..27f59210b34 100644 --- a/intern/cycles/util/hash.h +++ b/intern/cycles/util/hash.h @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN /* [0, uint_max] -> [0.0, 1.0) */ -ccl_device_forceinline float uint_to_float_excl(uint n) +ccl_device_forceinline float uint_to_float_excl(const uint n) { /* NOTE: we divide by 4294967808 instead of 2^32 because the latter * leads to a [0.0, 1.0] mapping instead of [0.0, 1.0) due to floating @@ -21,7 +21,7 @@ ccl_device_forceinline float uint_to_float_excl(uint n) } /* [0, uint_max] -> [0.0, 1.0] */ -ccl_device_forceinline float uint_to_float_incl(uint n) +ccl_device_forceinline float uint_to_float_incl(const uint n) { return (float)n * (1.0f / (float)0xFFFFFFFFu); } @@ -74,7 +74,7 @@ ccl_device_forceinline float uint_to_float_incl(uint n) } \ ((void)0) -ccl_device_inline uint hash_uint(uint kx) +ccl_device_inline uint hash_uint(const uint kx) { uint a; uint b; @@ -87,7 +87,7 @@ ccl_device_inline uint hash_uint(uint kx) return c; } -ccl_device_inline uint hash_uint2(uint kx, uint ky) +ccl_device_inline uint hash_uint2(const uint kx, const uint ky) { uint a; uint b; @@ -101,7 +101,7 @@ ccl_device_inline uint hash_uint2(uint kx, uint ky) return c; } -ccl_device_inline uint hash_uint3(uint kx, uint ky, uint kz) +ccl_device_inline uint hash_uint3(const uint kx, const uint ky, const uint kz) { uint a; uint b; @@ -116,7 +116,7 @@ ccl_device_inline uint hash_uint3(uint kx, uint ky, uint kz) return c; } -ccl_device_inline uint hash_uint4(uint kx, uint ky, uint kz, uint kw) +ccl_device_inline uint hash_uint4(const uint kx, const uint ky, const uint kz, const uint kw) { uint a; uint b; @@ -140,44 +140,47 @@ ccl_device_inline uint hash_uint4(uint kx, uint ky, uint kz, uint kw) /* Hashing uint or uint[234] into a float in the range [0, 1]. */ -ccl_device_inline float hash_uint_to_float(uint kx) +ccl_device_inline float hash_uint_to_float(const uint kx) { return uint_to_float_incl(hash_uint(kx)); } -ccl_device_inline float hash_uint2_to_float(uint kx, uint ky) +ccl_device_inline float hash_uint2_to_float(const uint kx, const uint ky) { return uint_to_float_incl(hash_uint2(kx, ky)); } -ccl_device_inline float hash_uint3_to_float(uint kx, uint ky, uint kz) +ccl_device_inline float hash_uint3_to_float(const uint kx, const uint ky, const uint kz) { return uint_to_float_incl(hash_uint3(kx, ky, kz)); } -ccl_device_inline float hash_uint4_to_float(uint kx, uint ky, uint kz, uint kw) +ccl_device_inline float hash_uint4_to_float(const uint kx, + const uint ky, + const uint kz, + const uint kw) { return uint_to_float_incl(hash_uint4(kx, ky, kz, kw)); } /* Hashing float or float[234] into a float in the range [0, 1]. */ -ccl_device_inline float hash_float_to_float(float k) +ccl_device_inline float hash_float_to_float(const float k) { return hash_uint_to_float(__float_as_uint(k)); } -ccl_device_inline float hash_float2_to_float(float2 k) +ccl_device_inline float hash_float2_to_float(const float2 k) { return hash_uint2_to_float(__float_as_uint(k.x), __float_as_uint(k.y)); } -ccl_device_inline float hash_float3_to_float(float3 k) +ccl_device_inline float hash_float3_to_float(const float3 k) { return hash_uint3_to_float(__float_as_uint(k.x), __float_as_uint(k.y), __float_as_uint(k.z)); } -ccl_device_inline float hash_float4_to_float(float4 k) +ccl_device_inline float hash_float4_to_float(const float4 k) { return hash_uint4_to_float( __float_as_uint(k.x), __float_as_uint(k.y), __float_as_uint(k.z), __float_as_uint(k.w)); @@ -185,19 +188,19 @@ ccl_device_inline float hash_float4_to_float(float4 k) /* Hashing float[234] into float[234] of components in the range [0, 1]. */ -ccl_device_inline float2 hash_float2_to_float2(float2 k) +ccl_device_inline float2 hash_float2_to_float2(const float2 k) { return make_float2(hash_float2_to_float(k), hash_float3_to_float(make_float3(k.x, k.y, 1.0))); } -ccl_device_inline float3 hash_float3_to_float3(float3 k) +ccl_device_inline float3 hash_float3_to_float3(const float3 k) { return make_float3(hash_float3_to_float(k), hash_float4_to_float(make_float4(k.x, k.y, k.z, 1.0)), hash_float4_to_float(make_float4(k.x, k.y, k.z, 2.0))); } -ccl_device_inline float4 hash_float4_to_float4(float4 k) +ccl_device_inline float4 hash_float4_to_float4(const float4 k) { return make_float4(hash_float4_to_float(k), hash_float4_to_float(make_float4(k.w, k.x, k.y, k.z)), @@ -207,21 +210,21 @@ ccl_device_inline float4 hash_float4_to_float4(float4 k) /* Hashing float or float[234] into float3 of components in range [0, 1]. */ -ccl_device_inline float3 hash_float_to_float3(float k) +ccl_device_inline float3 hash_float_to_float3(const float k) { return make_float3(hash_float_to_float(k), hash_float2_to_float(make_float2(k, 1.0)), hash_float2_to_float(make_float2(k, 2.0))); } -ccl_device_inline float3 hash_float2_to_float3(float2 k) +ccl_device_inline float3 hash_float2_to_float3(const float2 k) { return make_float3(hash_float2_to_float(k), hash_float3_to_float(make_float3(k.x, k.y, 1.0)), hash_float3_to_float(make_float3(k.x, k.y, 2.0))); } -ccl_device_inline float3 hash_float4_to_float3(float4 k) +ccl_device_inline float3 hash_float4_to_float3(const float4 k) { return make_float3(hash_float4_to_float(k), hash_float4_to_float(make_float4(k.z, k.x, k.w, k.y)), @@ -230,18 +233,18 @@ ccl_device_inline float3 hash_float4_to_float3(float4 k) /* Hashing float or float[234] into float2 of components in range [0, 1]. */ -ccl_device_inline float2 hash_float_to_float2(float k) +ccl_device_inline float2 hash_float_to_float2(const float k) { return make_float2(hash_float_to_float(k), hash_float2_to_float(make_float2(k, 1.0))); } -ccl_device_inline float2 hash_float3_to_float2(float3 k) +ccl_device_inline float2 hash_float3_to_float2(const float3 k) { return make_float2(hash_float3_to_float(make_float3(k.x, k.y, k.z)), hash_float3_to_float(make_float3(k.z, k.x, k.y))); } -ccl_device_inline float2 hash_float4_to_float2(float4 k) +ccl_device_inline float2 hash_float4_to_float2(const float4 k) { return make_float2(hash_float4_to_float(make_float4(k.x, k.y, k.z, k.w)), hash_float4_to_float(make_float4(k.z, k.x, k.w, k.y))); @@ -292,7 +295,7 @@ ccl_device_inline float2 hash_float4_to_float2(float4 k) c -= rot(b, 24); \ } -ccl_device_inline int4 hash_int4(int4 kx) +ccl_device_inline int4 hash_int4(const int4 kx) { int4 a; int4 b; @@ -305,7 +308,7 @@ ccl_device_inline int4 hash_int4(int4 kx) return c; } -ccl_device_inline int4 hash_int4_2(int4 kx, int4 ky) +ccl_device_inline int4 hash_int4_2(const int4 kx, const int4 ky) { int4 a; int4 b; @@ -319,7 +322,7 @@ ccl_device_inline int4 hash_int4_2(int4 kx, int4 ky) return c; } -ccl_device_inline int4 hash_int4_3(int4 kx, int4 ky, int4 kz) +ccl_device_inline int4 hash_int4_3(const int4 kx, const int4 ky, const int4 kz) { int4 a; int4 b; @@ -334,7 +337,7 @@ ccl_device_inline int4 hash_int4_3(int4 kx, int4 ky, int4 kz) return c; } -ccl_device_inline int4 hash_int4_4(int4 kx, int4 ky, int4 kz, int4 kw) +ccl_device_inline int4 hash_int4_4(const int4 kx, const int4 ky, const int4 kz, const int4 kw) { int4 a; int4 b; @@ -433,7 +436,7 @@ ccl_device_inline uint hash_hp_uint(uint i) } /* Seedable version of hash_hp_uint() above. */ -ccl_device_inline uint hash_hp_seeded_uint(uint i, uint seed) +ccl_device_inline uint hash_hp_seeded_uint(const uint i, uint seed) { // Manipulate the seed so it doesn't interact poorly with n when they // are both e.g. incrementing. This isn't fool-proof, but is good @@ -444,13 +447,13 @@ ccl_device_inline uint hash_hp_seeded_uint(uint i, uint seed) } /* Outputs [0.0, 1.0). */ -ccl_device_inline float hash_hp_float(uint i) +ccl_device_inline float hash_hp_float(const uint i) { return uint_to_float_excl(hash_hp_uint(i)); } /* Outputs [0.0, 1.0). */ -ccl_device_inline float hash_hp_seeded_float(uint i, uint seed) +ccl_device_inline float hash_hp_seeded_float(const uint i, const uint seed) { return uint_to_float_excl(hash_hp_seeded_uint(i, seed)); } @@ -464,7 +467,7 @@ ccl_device_inline float hash_hp_seeded_float(uint i, uint seed) * https://www.burtleburtle.net/bob/hash/integer.html */ -ccl_device_inline uint hash_wang_seeded_uint(uint i, uint seed) +ccl_device_inline uint hash_wang_seeded_uint(uint i, const uint seed) { i = (i ^ 61) ^ seed; i += i << 3; @@ -474,7 +477,7 @@ ccl_device_inline uint hash_wang_seeded_uint(uint i, uint seed) } /* Outputs [0.0, 1.0). */ -ccl_device_inline float hash_wang_seeded_float(uint i, uint seed) +ccl_device_inline float hash_wang_seeded_float(const uint i, const uint seed) { return uint_to_float_excl(hash_wang_seeded_uint(i, seed)); } @@ -498,7 +501,7 @@ ccl_device_inline float hash_wang_seeded_float(uint i, uint seed) * See https://andrew-helmer.github.io/permute/ for details on how this * works. */ -ccl_device_inline uint hash_shuffle_uint(uint i, uint length, uint seed) +ccl_device_inline uint hash_shuffle_uint(uint i, const uint length, const uint seed) { i = i % length; const uint mask = (1 << (32 - count_leading_zeros(length - 1))) - 1; diff --git a/intern/cycles/util/ies.cpp b/intern/cycles/util/ies.cpp index 4da33f7f242..5f7ddee4713 100644 --- a/intern/cycles/util/ies.cpp +++ b/intern/cycles/util/ies.cpp @@ -200,7 +200,7 @@ bool IESFile::parse(const string &ies) return !parser.has_error(); } -static bool angle_close(float a, float b) +static bool angle_close(const float a, const float b) { return fabsf(a - b) < 1e-4f; } diff --git a/intern/cycles/util/image.h b/intern/cycles/util/image.h index 3e56b3b6211..bf46ccfd09a 100644 --- a/intern/cycles/util/image.h +++ b/intern/cycles/util/image.h @@ -32,15 +32,15 @@ void util_image_resize_pixels(const vector &input_pixels, /* Cast input pixel from unknown storage to float. */ template inline float util_image_cast_to_float(T value); -template<> inline float util_image_cast_to_float(float value) +template<> inline float util_image_cast_to_float(const float value) { return value; } -template<> inline float util_image_cast_to_float(uchar value) +template<> inline float util_image_cast_to_float(const uchar value) { return (float)value / 255.0f; } -template<> inline float util_image_cast_to_float(uint16_t value) +template<> inline float util_image_cast_to_float(const uint16_t value) { return (float)value / 65535.0f; } @@ -50,13 +50,13 @@ template<> inline float util_image_cast_to_float(half value) } /* Cast float value to output pixel type. */ -template inline T util_image_cast_from_float(float value); +template inline T util_image_cast_from_float(const float value); -template<> inline float util_image_cast_from_float(float value) +template<> inline float util_image_cast_from_float(const float value) { return value; } -template<> inline uchar util_image_cast_from_float(float value) +template<> inline uchar util_image_cast_from_float(const float value) { if (value < 0.0f) { return 0; @@ -66,7 +66,7 @@ template<> inline uchar util_image_cast_from_float(float value) } return (uchar)((255.0f * value) + 0.5f); // NOLINT } -template<> inline uint16_t util_image_cast_from_float(float value) +template<> inline uint16_t util_image_cast_from_float(const float value) { if (value < 0.0f) { return 0; @@ -76,7 +76,7 @@ template<> inline uint16_t util_image_cast_from_float(float value) } return (uint16_t)((65535.0f * value) + 0.5f); // NOLINT } -template<> inline half util_image_cast_from_float(float value) +template<> inline half util_image_cast_from_float(const float value) { return float_to_half_image(value); } @@ -84,15 +84,15 @@ template<> inline half util_image_cast_from_float(float value) /* Multiply image pixels in native data format. */ template inline T util_image_multiply_native(T a, T b); -template<> inline float util_image_multiply_native(float a, float b) +template<> inline float util_image_multiply_native(const float a, const float b) { return a * b; } -template<> inline uchar util_image_multiply_native(uchar a, uchar b) +template<> inline uchar util_image_multiply_native(const uchar a, const uchar b) { return ((uint32_t)a * (uint32_t)b) / 255; } -template<> inline uint16_t util_image_multiply_native(uint16_t a, uint16_t b) +template<> inline uint16_t util_image_multiply_native(const uint16_t a, const uint16_t b) { return ((uint32_t)a * (uint32_t)b) / 65535; } diff --git a/intern/cycles/util/log.cpp b/intern/cycles/util/log.cpp index abb6ca4d07d..8fb42b59881 100644 --- a/intern/cycles/util/log.cpp +++ b/intern/cycles/util/log.cpp @@ -57,7 +57,7 @@ void util_logging_start() #endif } -void util_logging_verbosity_set(int verbosity) +void util_logging_verbosity_set(const int verbosity) { #ifdef WITH_CYCLES_LOGGING using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption; diff --git a/intern/cycles/util/log.h b/intern/cycles/util/log.h index 6cb35aef468..20a2f919f40 100644 --- a/intern/cycles/util/log.h +++ b/intern/cycles/util/log.h @@ -85,7 +85,7 @@ struct float3; void util_logging_init(const char *argv0); void util_logging_start(); -void util_logging_verbosity_set(int verbosity); +void util_logging_verbosity_set(const int verbosity); std::ostream &operator<<(std::ostream &os, const int2 &value); std::ostream &operator<<(std::ostream &os, const float3 &value); diff --git a/intern/cycles/util/math_base.h b/intern/cycles/util/math_base.h index 736acc31b1d..02d4e56d1e9 100644 --- a/intern/cycles/util/math_base.h +++ b/intern/cycles/util/math_base.h @@ -89,12 +89,12 @@ CCL_NAMESPACE_BEGIN #if !defined(__HIP__) && !defined(__KERNEL_ONEAPI__) # ifdef _WIN32 -ccl_device_inline float fmaxf(float a, float b) +ccl_device_inline float fmaxf(const float a, const float b) { return (a > b) ? a : b; } -ccl_device_inline float fminf(float a, float b) +ccl_device_inline float fminf(const float a, const float b) { return (a < b) ? a : b; } @@ -112,37 +112,37 @@ using std::sqrt; # define isnan(x) sycl::isnan((x)) # endif -ccl_device_inline int abs(int x) +ccl_device_inline int abs(const int x) { return (x > 0) ? x : -x; } -ccl_device_inline int max(int a, int b) +ccl_device_inline int max(const int a, const int b) { return (a > b) ? a : b; } -ccl_device_inline int min(int a, int b) +ccl_device_inline int min(const int a, const int b) { return (a < b) ? a : b; } -ccl_device_inline uint32_t max(uint32_t a, uint32_t b) +ccl_device_inline uint32_t max(const uint32_t a, const uint32_t b) { return (a > b) ? a : b; } -ccl_device_inline uint32_t min(uint32_t a, uint32_t b) +ccl_device_inline uint32_t min(const uint32_t a, const uint32_t b) { return (a < b) ? a : b; } -ccl_device_inline uint64_t max(uint64_t a, uint64_t b) +ccl_device_inline uint64_t max(const uint64_t a, const uint64_t b) { return (a > b) ? a : b; } -ccl_device_inline uint64_t min(uint64_t a, uint64_t b) +ccl_device_inline uint64_t min(const uint64_t a, const uint64_t b) { return (a < b) ? a : b; } @@ -166,22 +166,22 @@ ccl_device_inline typename std::enable_if_t, T> min(T return (a < b) ? a : b; } -ccl_device_inline float max(float a, float b) +ccl_device_inline float max(const float a, const float b) { return (a > b) ? a : b; } -ccl_device_inline float min(float a, float b) +ccl_device_inline float min(const float a, const float b) { return (a < b) ? a : b; } -ccl_device_inline double max(double a, double b) +ccl_device_inline double max(const double a, const double b) { return (a > b) ? a : b; } -ccl_device_inline double min(double a, double b) +ccl_device_inline double min(const double a, const double b) { return (a < b) ? a : b; } @@ -203,12 +203,12 @@ template ccl_device_inline T max4(const T &a, const T &b, const T &c } #endif /* __KERNEL_GPU__ */ -ccl_device_inline float min4(float a, float b, float c, float d) +ccl_device_inline float min4(const float a, const float b, float c, const float d) { return min(min(a, b), min(c, d)); } -ccl_device_inline float max4(float a, float b, float c, float d) +ccl_device_inline float max4(const float a, const float b, float c, const float d) { return max(max(a, b), max(c, d)); } @@ -216,7 +216,7 @@ ccl_device_inline float max4(float a, float b, float c, float d) #if !defined(__KERNEL_METAL__) && !defined(__KERNEL_ONEAPI__) /* Int/Float conversion */ -ccl_device_inline int as_int(uint i) +ccl_device_inline int as_int(const uint i) { union { uint ui; @@ -226,7 +226,7 @@ ccl_device_inline int as_int(uint i) return u.i; } -ccl_device_inline uint as_uint(int i) +ccl_device_inline uint as_uint(const int i) { union { uint ui; @@ -236,7 +236,7 @@ ccl_device_inline uint as_uint(int i) return u.ui; } -ccl_device_inline uint as_uint(float f) +ccl_device_inline uint as_uint(const float f) { union { uint i; @@ -247,7 +247,7 @@ ccl_device_inline uint as_uint(float f) } # ifndef __HIP__ -ccl_device_inline int __float_as_int(float f) +ccl_device_inline int __float_as_int(const float f) { union { int i; @@ -257,7 +257,7 @@ ccl_device_inline int __float_as_int(float f) return u.i; } -ccl_device_inline float __int_as_float(int i) +ccl_device_inline float __int_as_float(const int i) { union { int i; @@ -267,7 +267,7 @@ ccl_device_inline float __int_as_float(int i) return u.f; } -ccl_device_inline uint __float_as_uint(float f) +ccl_device_inline uint __float_as_uint(const float f) { union { uint i; @@ -277,7 +277,7 @@ ccl_device_inline uint __float_as_uint(float f) return u.i; } -ccl_device_inline float __uint_as_float(uint i) +ccl_device_inline float __uint_as_float(const uint i) { union { uint i; @@ -291,12 +291,12 @@ ccl_device_inline float __uint_as_float(uint i) #endif /* !defined(__KERNEL_METAL__) */ #if defined(__KERNEL_METAL__) -ccl_device_forceinline bool isnan_safe(float f) +ccl_device_forceinline bool isnan_safe(const float f) { return isnan(f); } -ccl_device_forceinline bool isfinite_safe(float f) +ccl_device_forceinline bool isfinite_safe(const float f) { return isfinite(f); } @@ -332,13 +332,13 @@ ccl_device_inline uint uint16_unpack_from_uint_1(const uint i) } /* Versions of functions which are safe for fast math. */ -ccl_device_inline bool isnan_safe(float f) +ccl_device_inline bool isnan_safe(const float f) { const unsigned int x = __float_as_uint(f); return (x << 1) > 0xff000000u; } -ccl_device_inline bool isfinite_safe(float f) +ccl_device_inline bool isfinite_safe(const float f) { /* By IEEE 754 rule, 2*Inf equals Inf */ const unsigned int x = __float_as_uint(f); @@ -346,28 +346,28 @@ ccl_device_inline bool isfinite_safe(float f) } #endif -ccl_device_inline float ensure_finite(float v) +ccl_device_inline float ensure_finite(const float v) { return isfinite_safe(v) ? v : 0.0f; } #if !defined(__KERNEL_METAL__) -ccl_device_inline int clamp(int a, int mn, int mx) +ccl_device_inline int clamp(const int a, const int mn, const int mx) { return min(max(a, mn), mx); } -ccl_device_inline float clamp(float a, float mn, float mx) +ccl_device_inline float clamp(const float a, const float mn, const float mx) { return min(max(a, mn), mx); } -ccl_device_inline float mix(float a, float b, float t) +ccl_device_inline float mix(const float a, const float b, float t) { return a + t * (b - a); } -ccl_device_inline float smoothstep(float edge0, float edge1, float x) +ccl_device_inline float smoothstep(const float edge0, const float edge1, const float x) { float result; if (x < edge0) { @@ -386,57 +386,57 @@ ccl_device_inline float smoothstep(float edge0, float edge1, float x) #endif /* !defined(__KERNEL_METAL__) */ #if defined(__KERNEL_CUDA__) -ccl_device_inline float saturatef(float a) +ccl_device_inline float saturatef(const float a) { return __saturatef(a); } #elif !defined(__KERNEL_METAL__) -ccl_device_inline float saturatef(float a) +ccl_device_inline float saturatef(const float a) { return clamp(a, 0.0f, 1.0f); } #endif /* __KERNEL_CUDA__ */ -ccl_device_inline int float_to_int(float f) +ccl_device_inline int float_to_int(const float f) { return (int)f; } -ccl_device_inline int floor_to_int(float f) +ccl_device_inline int floor_to_int(const float f) { return float_to_int(floorf(f)); } -ccl_device_inline float floorfrac(float x, ccl_private int *i) +ccl_device_inline float floorfrac(const float x, ccl_private int *i) { const float f = floorf(x); *i = float_to_int(f); return x - f; } -ccl_device_inline int ceil_to_int(float f) +ccl_device_inline int ceil_to_int(const float f) { return float_to_int(ceilf(f)); } -ccl_device_inline float fractf(float x) +ccl_device_inline float fractf(const float x) { return x - floorf(x); } /* Adapted from `godot-engine` math_funcs.h. */ -ccl_device_inline float wrapf(float value, float max, float min) +ccl_device_inline float wrapf(const float value, const float max, const float min) { const float range = max - min; return (range != 0.0f) ? value - (range * floorf((value - min) / range)) : min; } -ccl_device_inline float pingpongf(float a, float b) +ccl_device_inline float pingpongf(const float a, const float b) { return (b != 0.0f) ? fabsf(fractf((a - b) / (b * 2.0f)) * b * 2.0f - b) : 0.0f; } -ccl_device_inline float smoothminf(float a, float b, float k) +ccl_device_inline float smoothminf(const float a, const float b, float k) { if (k != 0.0f) { const float h = fmaxf(k - fabsf(a - b), 0.0f) / k; @@ -445,12 +445,12 @@ ccl_device_inline float smoothminf(float a, float b, float k) return fminf(a, b); } -ccl_device_inline float signf(float f) +ccl_device_inline float signf(const float f) { return (f < 0.0f) ? -1.0f : 1.0f; } -ccl_device_inline float nonzerof(float f, float eps) +ccl_device_inline float nonzerof(const float f, const float eps) { if (fabsf(f) < eps) { return signf(f) * eps; @@ -467,7 +467,7 @@ ccl_device_inline float compatible_atan2(const float y, const float x) } /* `signum` function testing for zero. Matches GLSL and OSL functions. */ -ccl_device_inline float compatible_signf(float f) +ccl_device_inline float compatible_signf(const float f) { if (f == 0.0f) { return 0.0f; @@ -475,7 +475,7 @@ ccl_device_inline float compatible_signf(float f) return signf(f); } -ccl_device_inline float smoothstepf(float f) +ccl_device_inline float smoothstepf(const float f) { if (f <= 0.0f) { return 0.0f; @@ -487,18 +487,18 @@ ccl_device_inline float smoothstepf(float f) return (3.0f * ff - 2.0f * ff * f); } -ccl_device_inline int mod(int x, int m) +ccl_device_inline int mod(const int x, const int m) { return (x % m + m) % m; } -ccl_device_inline float inverse_lerp(float a, float b, float x) +ccl_device_inline float inverse_lerp(const float a, const float b, float x) { return (x - a) / (b - a); } /* Cubic interpolation between b and c, a and d are the previous and next point. */ -ccl_device_inline float cubic_interp(float a, float b, float c, float d, float x) +ccl_device_inline float cubic_interp(const float a, const float b, float c, const float d, float x) { return 0.5f * (((d + 3.0f * (b - c) - a) * x + (2.0f * a - 5.0f * b + 4.0f * c - d)) * x + @@ -509,12 +509,12 @@ ccl_device_inline float cubic_interp(float a, float b, float c, float d, float x /* NaN-safe math ops */ -ccl_device_inline float safe_sqrtf(float f) +ccl_device_inline float safe_sqrtf(const float f) { return sqrtf(max(f, 0.0f)); } -ccl_device_inline float inversesqrtf(float f) +ccl_device_inline float inversesqrtf(const float f) { #if defined(__KERNEL_METAL__) return (f > 0.0f) ? rsqrt(f) : 0.0f; @@ -523,17 +523,17 @@ ccl_device_inline float inversesqrtf(float f) #endif } -ccl_device float safe_asinf(float a) +ccl_device float safe_asinf(const float a) { return asinf(clamp(a, -1.0f, 1.0f)); } -ccl_device float safe_acosf(float a) +ccl_device float safe_acosf(const float a) { return acosf(clamp(a, -1.0f, 1.0f)); } -ccl_device float compatible_powf(float x, float y) +ccl_device float compatible_powf(const float x, const float y) { #ifdef __KERNEL_GPU__ if (y == 0.0f) /* x^0 -> 1, including 0^0 */ @@ -552,7 +552,7 @@ ccl_device float compatible_powf(float x, float y) return powf(x, y); } -ccl_device float safe_powf(float a, float b) +ccl_device float safe_powf(const float a, const float b) { if (UNLIKELY(a < 0.0f && b != float_to_int(b))) { return 0.0f; @@ -561,12 +561,12 @@ ccl_device float safe_powf(float a, float b) return compatible_powf(a, b); } -ccl_device float safe_divide(float a, float b) +ccl_device float safe_divide(const float a, const float b) { return (b != 0.0f) ? a / b : 0.0f; } -ccl_device float safe_logf(float a, float b) +ccl_device float safe_logf(const float a, const float b) { if (UNLIKELY(a <= 0.0f || b <= 0.0f)) { return 0.0f; @@ -575,17 +575,17 @@ ccl_device float safe_logf(float a, float b) return safe_divide(logf(a), logf(b)); } -ccl_device float safe_modulo(float a, float b) +ccl_device float safe_modulo(const float a, const float b) { return (b != 0.0f) ? fmodf(a, b) : 0.0f; } -ccl_device float safe_floored_modulo(float a, float b) +ccl_device float safe_floored_modulo(const float a, const float b) { return (b != 0.0f) ? a - floorf(a / b) * b : 0.0f; } -ccl_device_inline float sqr(float a) +ccl_device_inline float sqr(const float a) { return a * a; } @@ -612,18 +612,18 @@ ccl_device_inline float one_minus_cos(const float angle) return angle > 0.02f ? 1.0f - cosf(angle) : 0.5f * sqr(angle); } -ccl_device_inline float pow20(float a) +ccl_device_inline float pow20(const float a) { return sqr(sqr(sqr(sqr(a)) * a)); } -ccl_device_inline float pow22(float a) +ccl_device_inline float pow22(const float a) { return sqr(a * sqr(sqr(sqr(a)) * a)); } #ifdef __KERNEL_METAL__ -ccl_device_inline float lgammaf(float x) +ccl_device_inline float lgammaf(const float x) { /* Nemes, GergÅ‘ (2010), "New asymptotic expansion for the Gamma function", Archiv der Mathematik */ @@ -636,29 +636,29 @@ ccl_device_inline float lgammaf(float x) } #endif -ccl_device_inline float beta(float x, float y) +ccl_device_inline float beta(const float x, const float y) { return expf(lgammaf(x) + lgammaf(y) - lgammaf(x + y)); } -ccl_device_inline float xor_signmask(float x, int y) +ccl_device_inline float xor_signmask(const float x, const int y) { return __int_as_float(__float_as_int(x) ^ y); } -ccl_device float bits_to_01(uint bits) +ccl_device float bits_to_01(const uint bits) { return bits * (1.0f / (float)0xFFFFFFFF); } #if !defined(__KERNEL_GPU__) # if defined(__GNUC__) -ccl_device_inline uint popcount(uint x) +ccl_device_inline uint popcount(const uint x) { return __builtin_popcount(x); } # else -ccl_device_inline uint popcount(uint x) +ccl_device_inline uint popcount(const uint x) { /* TODO(Stefan): pop-count intrinsic for Windows with fallback for older CPUs. */ uint i = x; @@ -677,7 +677,7 @@ ccl_device_inline uint popcount(uint x) # define popcount(x) __popc(x) #endif -ccl_device_inline uint count_leading_zeros(uint x) +ccl_device_inline uint count_leading_zeros(const uint x) { #if defined(__KERNEL_CUDA__) || defined(__KERNEL_OPTIX__) || defined(__KERNEL_HIP__) return __clz(x); @@ -697,7 +697,7 @@ ccl_device_inline uint count_leading_zeros(uint x) #endif } -ccl_device_inline uint count_trailing_zeros(uint x) +ccl_device_inline uint count_trailing_zeros(const uint x) { #if defined(__KERNEL_CUDA__) || defined(__KERNEL_OPTIX__) || defined(__KERNEL_HIP__) return (__ffs(x) - 1); @@ -717,7 +717,7 @@ ccl_device_inline uint count_trailing_zeros(uint x) #endif } -ccl_device_inline uint find_first_set(uint x) +ccl_device_inline uint find_first_set(const uint x) { #if defined(__KERNEL_CUDA__) || defined(__KERNEL_OPTIX__) || defined(__KERNEL_HIP__) return __ffs(x); @@ -739,7 +739,10 @@ ccl_device_inline uint find_first_set(uint x) * https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ */ -ccl_device_inline bool compare_floats(float a, float b, float abs_diff, int ulp_diff) +ccl_device_inline bool compare_floats(const float a, + const float b, + float abs_diff, + const int ulp_diff) { if (fabsf(a - b) < abs_diff) { return true; @@ -753,13 +756,13 @@ ccl_device_inline bool compare_floats(float a, float b, float abs_diff, int ulp_ } /* Return value which is greater than the given one and is a power of two. */ -ccl_device_inline uint next_power_of_two(uint x) +ccl_device_inline uint next_power_of_two(const uint x) { return x == 0 ? 1 : 1 << (32 - count_leading_zeros(x)); } /* Return value which is lower than the given one and is a power of two. */ -ccl_device_inline uint prev_power_of_two(uint x) +ccl_device_inline uint prev_power_of_two(const uint x) { return x < 2 ? x : 1 << (31 - count_leading_zeros(x - 1)); } diff --git a/intern/cycles/util/math_fast.h b/intern/cycles/util/math_fast.h index 88a920878a7..035e91f758e 100644 --- a/intern/cycles/util/math_fast.h +++ b/intern/cycles/util/math_fast.h @@ -65,7 +65,7 @@ ccl_device_inline float4 madd4(const float4 a, const float4 b, const float4 c) */ /* Round to nearest integer, returning as an int. */ -ccl_device_inline int fast_rint(float x) +ccl_device_inline int fast_rint(const float x) { /* used by sin/cos/tan range reduction. */ #ifdef __KERNEL_SSE42__ @@ -215,7 +215,7 @@ ccl_device float fast_tanf(float x) * * Adapted from http://devmaster.net/posts/9648/fast-and-accurate-sine-cosine#comment-76773 */ -ccl_device float fast_sinpif(float x) +ccl_device float fast_sinpif(const float x) { /* Fast trick to strip the integral part off, so our domain is [-1, 1]. */ const float z = x - ((x + 25165824.0f) - 25165824.0f); @@ -251,12 +251,12 @@ ccl_device float fast_sinpif(float x) } /* Fast approximate cos(x*M_PI) with ~0.1% absolute error. */ -ccl_device_inline float fast_cospif(float x) +ccl_device_inline float fast_cospif(const float x) { return fast_sinpif(x + 0.5f); } -ccl_device float fast_acosf(float x) +ccl_device float fast_acosf(const float x) { const float f = fabsf(x); /* clamp and crush denormals. */ @@ -273,7 +273,7 @@ ccl_device float fast_acosf(float x) return x < 0 ? M_PI_F - a : a; } -ccl_device float fast_asinf(float x) +ccl_device float fast_asinf(const float x) { /* Based on acosf approximation above. * Max error is 4.51133e-05 (ULPS are higher because we are consistently off @@ -287,7 +287,7 @@ ccl_device float fast_asinf(float x) return copysignf(a, x); } -ccl_device float fast_atanf(float x) +ccl_device float fast_atanf(const float x) { const float a = fabsf(x); const float k = a > 1.0f ? 1 / a : a; @@ -306,7 +306,7 @@ ccl_device float fast_atanf(float x) return copysignf(r, x); } -ccl_device float fast_atan2f(float y, float x) +ccl_device float fast_atan2f(const float y, const float x) { /* Based on atan approximation above. * @@ -336,7 +336,7 @@ ccl_device float fast_atan2f(float y, float x) } /* Same as precise_angle, but using fast_atan2f. Still much better that acos(dot(a, b)). */ -ccl_device_inline float vector_angle(float3 a, float3 b) +ccl_device_inline float vector_angle(const float3 a, const float3 b) { return 2.0f * fast_atan2f(len(a - b), len(a + b)); } @@ -371,7 +371,7 @@ ccl_device float fast_log2f(float x) return ((f4 * hi) + (f * lo)) + exponent; } -ccl_device_inline float fast_logf(float x) +ccl_device_inline float fast_logf(const float x) { /* Examined 2130706432 values of logf on [1.17549435e-38,3.40282347e+38]: * 0.313865375 avg ULP diff, 5148137 max ULP, 7.62939e-06 max error. @@ -379,7 +379,7 @@ ccl_device_inline float fast_logf(float x) return fast_log2f(x) * M_LN2_F; } -ccl_device_inline float fast_log10(float x) +ccl_device_inline float fast_log10(const float x) { /* Examined 2130706432 values of log10f on [1.17549435e-38,3.40282347e+38]: * 0.631237033 avg ULP diff, 4471615 max ULP, 3.8147e-06 max error. @@ -423,7 +423,7 @@ ccl_device float fast_exp2f(float x) return __uint_as_float(__float_as_uint(r) + ((unsigned)m << 23)); } -ccl_device_inline float fast_expf(float x) +ccl_device_inline float fast_expf(const float x) { /* Examined 2237485550 values of exp on [-87.3300018,87.3300018]: * 2.6666452 avg ULP diff, 230 max ULP. @@ -451,18 +451,18 @@ ccl_device float4 fast_exp2f4(float4 x) return __int4_as_float4(__float4_as_int4(r) + (m << 23)); } -ccl_device_inline float4 fast_expf4(float4 x) +ccl_device_inline float4 fast_expf4(const float4 x) { return fast_exp2f4(x / M_LN2_F); } #else -ccl_device_inline float4 fast_expf4(float4 x) +ccl_device_inline float4 fast_expf4(const float4 x) { return make_float4(fast_expf(x.x), fast_expf(x.y), fast_expf(x.z), fast_expf(x.w)); } #endif -ccl_device_inline float fast_exp10(float x) +ccl_device_inline float fast_exp10(const float x) { /* Examined 2217701018 values of exp10 on [-37.9290009,37.9290009]: * 2.71732409 avg ULP diff, 232 max ULP. @@ -479,7 +479,7 @@ ccl_device_inline float fast_expm1f(float x) return fast_expf(x) - 1.0f; } -ccl_device float fast_sinhf(float x) +ccl_device float fast_sinhf(const float x) { float a = fabsf(x); if (a > 1.0f) { @@ -499,7 +499,7 @@ ccl_device float fast_sinhf(float x) return copysignf(r, x); } -ccl_device_inline float fast_coshf(float x) +ccl_device_inline float fast_coshf(const float x) { /* Examined 2237485550 values of cosh on [-87.3300018,87.3300018]: * 1.78256726 avg ULP diff, 178 max ULP. @@ -508,7 +508,7 @@ ccl_device_inline float fast_coshf(float x) return 0.5f * e + 0.5f / e; } -ccl_device_inline float fast_tanhf(float x) +ccl_device_inline float fast_tanhf(const float x) { /* Examined 4278190080 values of tanh on [-3.40282347e+38,3.40282347e+38]: * 3.12924e-06 max error. @@ -518,7 +518,7 @@ ccl_device_inline float fast_tanhf(float x) return copysignf(1.0f - 2.0f / (1.0f + e), x); } -ccl_device float fast_safe_powf(float x, float y) +ccl_device float fast_safe_powf(const float x, const float y) { if (y == 0) { return 1.0f; /* x^1=1 */ @@ -560,7 +560,7 @@ ccl_device float fast_safe_powf(float x, float y) * bsdf_microfacet.h. */ -ccl_device_inline float fast_erff(float x) +ccl_device_inline float fast_erff(const float x) { /* Examined 1082130433 values of erff on [0,4]: 1.93715e-06 max error. */ /* Abramowitz and Stegun, 7.1.28. */ @@ -584,7 +584,7 @@ ccl_device_inline float fast_erff(float x) return copysignf(1.0f - 1.0f / v, x); } -ccl_device_inline float fast_erfcf(float x) +ccl_device_inline float fast_erfcf(const float x) { /* Examined 2164260866 values of erfcf on [-4,4]: 1.90735e-06 max error. * @@ -595,7 +595,7 @@ ccl_device_inline float fast_erfcf(float x) return 1.0f - fast_erff(x); } -ccl_device_inline float fast_ierff(float x) +ccl_device_inline float fast_ierff(const float x) { /* From: Approximating the `erfinv` function by Mike Giles. */ /* To avoid trouble at the limit, clamp input to 1-epsilon. */ @@ -630,7 +630,7 @@ ccl_device_inline float fast_ierff(float x) } /* Fast inverse cube root for positive x, with two Newton iterations to improve accuracy. */ -ccl_device_inline float fast_inv_cbrtf(float x) +ccl_device_inline float fast_inv_cbrtf(const float x) { util_assert(x >= 0.0f); diff --git a/intern/cycles/util/math_float2.h b/intern/cycles/util/math_float2.h index 9b4c09f2b7d..850c1958ab7 100644 --- a/intern/cycles/util/math_float2.h +++ b/intern/cycles/util/math_float2.h @@ -31,7 +31,7 @@ ccl_device_inline float2 operator*(const float2 a, const float2 b) return make_float2(a.x * b.x, a.y * b.y); } -ccl_device_inline float2 operator*(const float2 a, float f) +ccl_device_inline float2 operator*(const float2 a, const float f) { return make_float2(a.x * f, a.y * f); } @@ -46,7 +46,7 @@ ccl_device_inline float2 operator/(float f, const float2 a) return make_float2(f / a.x, f / a.y); } -ccl_device_inline float2 operator/(const float2 a, float f) +ccl_device_inline float2 operator/(const float2 a, const float f) { const float invf = 1.0f / f; return make_float2(a.x * invf, a.y * invf); @@ -87,7 +87,7 @@ ccl_device_inline float2 operator*=(float2 &a, const float2 b) return a = a * b; } -ccl_device_inline float2 operator*=(float2 &a, float f) +ccl_device_inline float2 operator*=(float2 &a, const float f) { return a = a * f; } @@ -97,7 +97,7 @@ ccl_device_inline float2 operator/=(float2 &a, const float2 b) return a = a / b; } -ccl_device_inline float2 operator/=(float2 &a, float f) +ccl_device_inline float2 operator/=(float2 &a, const float f) { const float invf = 1.0f / f; return a = a * invf; @@ -221,12 +221,12 @@ ccl_device_inline float2 as_float2(const float4 &a) return make_float2(a.x, a.y); } -ccl_device_inline float2 interp(const float2 a, const float2 b, float t) +ccl_device_inline float2 interp(const float2 a, const float2 b, const float t) { return a + t * (b - a); } -ccl_device_inline float2 mix(const float2 a, const float2 b, float t) +ccl_device_inline float2 mix(const float2 a, const float2 b, const float t) { return a + t * (b - a); } @@ -239,7 +239,7 @@ ccl_device_inline float2 floor(const float2 a) #endif /* !__KERNEL_METAL__ */ /* Consistent name for this would be pow, but HIP compiler crashes in name mangling. */ -ccl_device_inline float2 power(float2 v, float e) +ccl_device_inline float2 power(const float2 v, const float e) { return make_float2(powf(v.x, e), powf(v.y, e)); } diff --git a/intern/cycles/util/math_float3.h b/intern/cycles/util/math_float3.h index e3706b6e6f3..8e904c768db 100644 --- a/intern/cycles/util/math_float3.h +++ b/intern/cycles/util/math_float3.h @@ -28,7 +28,7 @@ ccl_device_inline float3 one_float3() #if defined(__KERNEL_METAL__) -ccl_device_inline float3 rcp(float3 a) +ccl_device_inline float3 rcp(const float3 a) { return make_float3(1.0f / a.x, 1.0f / a.y, 1.0f / a.z); } @@ -142,7 +142,7 @@ ccl_device_inline float3 operator*=(float3 &a, const float3 b) return a = a * b; } -ccl_device_inline float3 operator*=(float3 &a, float f) +ccl_device_inline float3 operator*=(float3 &a, const float f) { return a = a * f; } @@ -152,7 +152,7 @@ ccl_device_inline float3 operator/=(float3 &a, const float3 b) return a = a / b; } -ccl_device_inline float3 operator/=(float3 &a, float f) +ccl_device_inline float3 operator/=(float3 &a, const float f) { const float invf = 1.0f / f; return a = a * invf; @@ -166,7 +166,7 @@ ccl_device_inline packed_float3 operator*=(packed_float3 &a, const float3 b) return a; } -ccl_device_inline packed_float3 operator*=(packed_float3 &a, float f) +ccl_device_inline packed_float3 operator*=(packed_float3 &a, const float f) { a = float3(a) * f; return a; @@ -178,7 +178,7 @@ ccl_device_inline packed_float3 operator/=(packed_float3 &a, const float3 b) return a; } -ccl_device_inline packed_float3 operator/=(packed_float3 &a, float f) +ccl_device_inline packed_float3 operator/=(packed_float3 &a, const float f) { a = float3(a) / f; return a; @@ -228,12 +228,12 @@ ccl_device_inline float len(const float3 a) #endif } -ccl_device_inline float reduce_min(float3 a) +ccl_device_inline float reduce_min(const float3 a) { return min(min(a.x, a.y), a.z); } -ccl_device_inline float reduce_max(float3 a) +ccl_device_inline float reduce_max(const float3 a) { return max(max(a.x, a.y), a.z); } @@ -342,7 +342,7 @@ ccl_device_inline float3 ceil(const float3 a) # endif } -ccl_device_inline float3 mix(const float3 a, const float3 b, float t) +ccl_device_inline float3 mix(const float3 a, const float3 b, const float t) { return a + t * (b - a); } @@ -357,22 +357,22 @@ ccl_device_inline float3 rcp(const float3 a) # endif } -ccl_device_inline float3 saturate(float3 a) +ccl_device_inline float3 saturate(const float3 a) { return make_float3(saturatef(a.x), saturatef(a.y), saturatef(a.z)); } -ccl_device_inline float3 exp(float3 v) +ccl_device_inline float3 exp(const float3 v) { return make_float3(expf(v.x), expf(v.y), expf(v.z)); } -ccl_device_inline float3 log(float3 v) +ccl_device_inline float3 log(const float3 v) { return make_float3(logf(v.x), logf(v.y), logf(v.z)); } -ccl_device_inline float3 cos(float3 v) +ccl_device_inline float3 cos(const float3 v) { return make_float3(cosf(v.x), cosf(v.y), cosf(v.z)); } @@ -442,12 +442,12 @@ ccl_device_inline float3 safe_divide(const float3 a, const float b) return (b != 0.0f) ? a / b : zero_float3(); } -ccl_device_inline float3 interp(float3 a, float3 b, float t) +ccl_device_inline float3 interp(const float3 a, const float3 b, const float t) { return a + t * (b - a); } -ccl_device_inline float3 sqr(float3 a) +ccl_device_inline float3 sqr(const float3 a) { return a * a; } @@ -487,28 +487,29 @@ ccl_device_inline bool isequal(const float3 a, const float3 b) } /* Consistent name for this would be pow, but HIP compiler crashes in name mangling. */ -ccl_device_inline float3 power(float3 v, float e) +ccl_device_inline float3 power(const float3 v, const float e) { return make_float3(powf(v.x, e), powf(v.y, e), powf(v.z, e)); } -ccl_device_inline bool isfinite_safe(float3 v) +ccl_device_inline bool isfinite_safe(const float3 v) { return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z); } -ccl_device_inline float3 ensure_finite(float3 v) +ccl_device_inline float3 ensure_finite(const float3 v) { - if (!isfinite_safe(v.x)) { - v.x = 0.0f; + float3 r = v; + if (!isfinite_safe(r.x)) { + r.x = 0.0f; } - if (!isfinite_safe(v.y)) { - v.y = 0.0f; + if (!isfinite_safe(r.y)) { + r.y = 0.0f; } - if (!isfinite_safe(v.z)) { - v.z = 0.0f; + if (!isfinite_safe(r.z)) { + r.z = 0.0f; } - return v; + return r; } /* Triangle */ @@ -552,7 +553,7 @@ ccl_device_inline void make_orthonormals(const float3 N, /* Rotation of point around axis and angle */ -ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle) +ccl_device_inline float3 rotate_around_axis(const float3 p, const float3 axis, const float angle) { const float costheta = cosf(angle); const float sintheta = sinf(angle); @@ -578,13 +579,13 @@ ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle) * which are avoided by this method. * Based on "Mangled Angles" from https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf */ -ccl_device_inline float precise_angle(float3 a, float3 b) +ccl_device_inline float precise_angle(const float3 a, const float3 b) { return 2.0f * atan2f(len(a - b), len(a + b)); } /* Tangent of the angle between vectors a and b. */ -ccl_device_inline float tan_angle(float3 a, float3 b) +ccl_device_inline float tan_angle(const float3 a, const float3 b) { return len(cross(a, b)) / dot(a, b); } diff --git a/intern/cycles/util/math_float4.h b/intern/cycles/util/math_float4.h index 38b4a395d56..dbeb4a55ca5 100644 --- a/intern/cycles/util/math_float4.h +++ b/intern/cycles/util/math_float4.h @@ -54,7 +54,7 @@ ccl_device_inline float4 operator*(const float4 a, const float4 b) # endif } -ccl_device_inline float4 operator*(const float4 a, float f) +ccl_device_inline float4 operator*(const float4 a, const float f) { # if defined(__KERNEL_SSE__) return a * make_float4(f); @@ -68,7 +68,7 @@ ccl_device_inline float4 operator*(float f, const float4 a) return a * f; } -ccl_device_inline float4 operator/(const float4 a, float f) +ccl_device_inline float4 operator/(const float4 a, const float f) { return a * (1.0f / f); } @@ -125,7 +125,7 @@ ccl_device_inline float4 operator*=(float4 &a, const float4 b) return a = a * b; } -ccl_device_inline float4 operator*=(float4 &a, float f) +ccl_device_inline float4 operator*=(float4 &a, const float f) { return a = a * f; } @@ -135,7 +135,7 @@ ccl_device_inline float4 operator/=(float4 &a, const float4 b) return a = a / b; } -ccl_device_inline float4 operator/=(float4 &a, float f) +ccl_device_inline float4 operator/=(float4 &a, const float f) { return a = a / f; } @@ -243,7 +243,8 @@ ccl_device_inline float4 msub(const float4 a, const float4 b, const float4 c) } #ifdef __KERNEL_SSE__ -template __forceinline float4 shuffle(const float4 a) +template +__forceinline float4 shuffle(const float4 a) { # ifdef __KERNEL_NEON__ return float4(shuffle_neon(a.m128)); @@ -275,7 +276,7 @@ template<> __forceinline float4 shuffle<1, 1, 3, 3>(const float4 a) } # endif /* __KERNEL_SSE3__ */ -template +template __forceinline float4 shuffle(const float4 a, const float4 b) { # ifdef __KERNEL_NEON__ @@ -501,7 +502,7 @@ ccl_device_inline float4 floorfrac(const float4 x, ccl_private int4 *i) # endif } -ccl_device_inline float4 mix(const float4 a, const float4 b, float t) +ccl_device_inline float4 mix(const float4 a, const float4 b, const float t) { return a + t * (b - a); } @@ -516,12 +517,12 @@ ccl_device_inline float4 saturate(const float4 a) return make_float4(saturatef(a.x), saturatef(a.y), saturatef(a.z), saturatef(a.w)); } -ccl_device_inline float4 exp(float4 v) +ccl_device_inline float4 exp(const float4 v) { return make_float4(expf(v.x), expf(v.y), expf(v.z), expf(v.z)); } -ccl_device_inline float4 log(float4 v) +ccl_device_inline float4 log(const float4 v) { return make_float4(logf(v.x), logf(v.y), logf(v.z), logf(v.z)); } @@ -583,37 +584,38 @@ ccl_device_inline float4 safe_divide(const float4 a, const float4 b) (b.w != 0.0f) ? a.w / b.w : 0.0f); } -ccl_device_inline bool isfinite_safe(float4 v) +ccl_device_inline bool isfinite_safe(const float4 v) { return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z) && isfinite_safe(v.w); } -ccl_device_inline float4 ensure_finite(float4 v) +ccl_device_inline float4 ensure_finite(const float4 v) { - if (!isfinite_safe(v.x)) { - v.x = 0.0f; + float4 r = v; + if (!isfinite_safe(r.x)) { + r.x = 0.0f; } - if (!isfinite_safe(v.y)) { - v.y = 0.0f; + if (!isfinite_safe(r.y)) { + r.y = 0.0f; } - if (!isfinite_safe(v.z)) { - v.z = 0.0f; + if (!isfinite_safe(r.z)) { + r.z = 0.0f; } - if (!isfinite_safe(v.w)) { - v.w = 0.0f; + if (!isfinite_safe(r.w)) { + r.w = 0.0f; } - return v; + return r; } /* Consistent name for this would be pow, but HIP compiler crashes in name mangling. */ -ccl_device_inline float4 power(float4 v, float e) +ccl_device_inline float4 power(const float4 v, const float e) { return make_float4(powf(v.x, e), powf(v.y, e), powf(v.z, e), powf(v.w, e)); } #if !defined(__KERNEL_METAL__) && !defined(__KERNEL_ONEAPI__) /* Int/Float conversion */ -ccl_device_inline int4 __float4_as_int4(float4 f) +ccl_device_inline int4 __float4_as_int4(const float4 f) { # ifdef __KERNEL_SSE__ return int4(_mm_castps_si128(f.m128)); @@ -623,7 +625,7 @@ ccl_device_inline int4 __float4_as_int4(float4 f) # endif } -ccl_device_inline float4 __int4_as_float4(int4 i) +ccl_device_inline float4 __int4_as_float4(const int4 i) { # ifdef __KERNEL_SSE__ return float4(_mm_castsi128_ps(i.m128)); diff --git a/intern/cycles/util/math_float8.h b/intern/cycles/util/math_float8.h index a91cf538e3b..7e767eaadb7 100644 --- a/intern/cycles/util/math_float8.h +++ b/intern/cycles/util/math_float8.h @@ -130,12 +130,12 @@ ccl_device_inline vfloat8 operator*=(vfloat8 a, const vfloat8 b) return a = a * b; } -ccl_device_inline vfloat8 operator*=(vfloat8 a, float f) +ccl_device_inline vfloat8 operator*=(vfloat8 a, const float f) { return a = a * f; } -ccl_device_inline vfloat8 operator/=(vfloat8 a, float f) +ccl_device_inline vfloat8 operator/=(vfloat8 a, const float f) { return a = a / f; } @@ -295,7 +295,7 @@ ccl_device_inline vfloat8 fabs(const vfloat8 a) #endif } -ccl_device_inline vfloat8 mix(const vfloat8 a, const vfloat8 b, float t) +ccl_device_inline vfloat8 mix(const vfloat8 a, const vfloat8 b, const float t) { return a + t * (b - a); } @@ -333,7 +333,7 @@ ccl_device_inline float dot(const vfloat8 a, const vfloat8 b) #endif } -ccl_device_inline vfloat8 pow(vfloat8 v, float e) +ccl_device_inline vfloat8 pow(vfloat8 v, const float e) { return make_vfloat8(powf(v.a, e), powf(v.b, e), @@ -431,7 +431,14 @@ ccl_device_forceinline float4 high(const vfloat8 a) # endif } -template +template ccl_device_forceinline vfloat8 shuffle(const vfloat8 a) { # ifdef __KERNEL_AVX__ @@ -441,7 +448,7 @@ ccl_device_forceinline vfloat8 shuffle(const vfloat8 a) # endif } -template +template ccl_device_forceinline vfloat8 shuffle(const vfloat8 a, const vfloat8 b) { # ifdef __KERNEL_AVX__ @@ -452,7 +459,7 @@ ccl_device_forceinline vfloat8 shuffle(const vfloat8 a, const vfloat8 b) # endif } -template +template ccl_device_forceinline vfloat8 shuffle(const vfloat8 a) { return shuffle(a, a); diff --git a/intern/cycles/util/math_int3.h b/intern/cycles/util/math_int3.h index 31cb26f1e8e..7c1b9ef0a1d 100644 --- a/intern/cycles/util/math_int3.h +++ b/intern/cycles/util/math_int3.h @@ -9,7 +9,7 @@ CCL_NAMESPACE_BEGIN #if !defined(__KERNEL_METAL__) -ccl_device_inline int3 min(int3 a, int3 b) +ccl_device_inline int3 min(const int3 a, const int3 b) { # if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) return int3(_mm_min_epi32(a.m128, b.m128)); @@ -18,7 +18,7 @@ ccl_device_inline int3 min(int3 a, int3 b) # endif } -ccl_device_inline int3 max(int3 a, int3 b) +ccl_device_inline int3 max(const int3 a, const int3 b) { # if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) return int3(_mm_max_epi32(a.m128, b.m128)); @@ -27,7 +27,7 @@ ccl_device_inline int3 max(int3 a, int3 b) # endif } -ccl_device_inline int3 clamp(const int3 a, int mn, int mx) +ccl_device_inline int3 clamp(const int3 a, const int mn, const int mx) { # ifdef __KERNEL_SSE__ return min(max(a, make_int3(mn)), make_int3(mx)); @@ -36,7 +36,7 @@ ccl_device_inline int3 clamp(const int3 a, int mn, int mx) # endif } -ccl_device_inline int3 clamp(const int3 a, int3 &mn, int mx) +ccl_device_inline int3 clamp(const int3 a, int3 &mn, const int mx) { # ifdef __KERNEL_SSE__ return min(max(a, mn), make_int3(mx)); diff --git a/intern/cycles/util/math_int4.h b/intern/cycles/util/math_int4.h index 2d9ce8e9c98..90de2848cb4 100644 --- a/intern/cycles/util/math_int4.h +++ b/intern/cycles/util/math_int4.h @@ -39,7 +39,7 @@ ccl_device_inline int4 operator-=(int4 &a, const int4 b) return a = a - b; } -ccl_device_inline int4 operator>>(const int4 a, int i) +ccl_device_inline int4 operator>>(const int4 a, const int i) { # ifdef __KERNEL_SSE__ return int4(_mm_srai_epi32(a.m128, i)); @@ -48,7 +48,7 @@ ccl_device_inline int4 operator>>(const int4 a, int i) # endif } -ccl_device_inline int4 operator<<(const int4 a, int i) +ccl_device_inline int4 operator<<(const int4 a, const int i) { # ifdef __KERNEL_SSE__ return int4(_mm_slli_epi32(a.m128, i)); @@ -199,7 +199,7 @@ ccl_device_forceinline int4 srl(const int4 a, const int32_t b) } # endif -ccl_device_inline int4 min(int4 a, int4 b) +ccl_device_inline int4 min(const int4 a, const int4 b) { # if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) return int4(_mm_min_epi32(a.m128, b.m128)); @@ -208,7 +208,7 @@ ccl_device_inline int4 min(int4 a, int4 b) # endif } -ccl_device_inline int4 max(int4 a, int4 b) +ccl_device_inline int4 max(const int4 a, const int4 b) { # if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) return int4(_mm_max_epi32(a.m128, b.m128)); @@ -258,7 +258,7 @@ ccl_device_forceinline int4 andnot(const int4 a, const int4 b) return int4(_mm_andnot_si128(a.m128, b.m128)); } -template +template ccl_device_forceinline int4 shuffle(const int4 a) { # ifdef __KERNEL_NEON__ @@ -269,7 +269,7 @@ ccl_device_forceinline int4 shuffle(const int4 a) # endif } -template +template ccl_device_forceinline int4 shuffle(const int4 a, const int4 b) { # ifdef __KERNEL_NEON__ diff --git a/intern/cycles/util/math_int8.h b/intern/cycles/util/math_int8.h index a23709a15ba..144d28de2c7 100644 --- a/intern/cycles/util/math_int8.h +++ b/intern/cycles/util/math_int8.h @@ -42,7 +42,7 @@ ccl_device_inline vint8 operator-=(vint8 &a, const vint8 b) return a = a - b; } -ccl_device_inline vint8 operator>>(const vint8 a, int i) +ccl_device_inline vint8 operator>>(const vint8 a, const int i) { # ifdef __KERNEL_AVX__ return vint8(_mm256_srai_epi32(a.m256, i)); @@ -52,7 +52,7 @@ ccl_device_inline vint8 operator>>(const vint8 a, int i) # endif } -ccl_device_inline vint8 operator<<(const vint8 a, int i) +ccl_device_inline vint8 operator<<(const vint8 a, const int i) { # ifdef __KERNEL_AVX__ return vint8(_mm256_slli_epi32(a.m256, i)); @@ -310,25 +310,25 @@ template const ccl_device_forceinline vint8 shuffle(const vint8 a) _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i, i, i, i)))); } -template const ccl_device_forceinline vint8 shuffle(const vint8 a) +template const ccl_device_forceinline vint8 shuffle(const vint8 a) { return vint8(_mm256_permute2f128_si256(a, a, (i1 << 4) | (i0 << 0))); } -template +template const ccl_device_forceinline vint8 shuffle(const vint8 a, const vint8 b) { return vint8(_mm256_permute2f128_si256(a, b, (i1 << 4) | (i0 << 0))); } -template +template const ccl_device_forceinline vint8 shuffle(const vint8 a) { return vint8( _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i3, i2, i1, i0)))); } -template +template const ccl_device_forceinline vint8 shuffle(const vint8 a, const vint8 b) { return vint8(_mm256_castps_si256(_mm256_shuffle_ps( diff --git a/intern/cycles/util/math_intersect.h b/intern/cycles/util/math_intersect.h index 55395435823..328f1559ca4 100644 --- a/intern/cycles/util/math_intersect.h +++ b/intern/cycles/util/math_intersect.h @@ -12,12 +12,12 @@ CCL_NAMESPACE_BEGIN /* Ray Intersection */ -ccl_device bool ray_sphere_intersect(float3 ray_P, - float3 ray_D, - float ray_tmin, - float ray_tmax, - float3 sphere_P, - float sphere_radius, +ccl_device bool ray_sphere_intersect(const float3 ray_P, + const float3 ray_D, + const float ray_tmin, + const float ray_tmax, + const float3 sphere_P, + const float sphere_radius, ccl_private float3 *isect_P, ccl_private float *isect_t) { @@ -50,12 +50,12 @@ ccl_device bool ray_sphere_intersect(float3 ray_P, return false; } -ccl_device bool ray_aligned_disk_intersect(float3 ray_P, - float3 ray_D, - float ray_tmin, - float ray_tmax, - float3 disk_P, - float disk_radius, +ccl_device bool ray_aligned_disk_intersect(const float3 ray_P, + const float3 ray_D, + const float ray_tmin, + const float ray_tmax, + const float3 disk_P, + const float disk_radius, ccl_private float3 *isect_P, ccl_private float *isect_t) { @@ -81,13 +81,13 @@ ccl_device bool ray_aligned_disk_intersect(float3 ray_P, return true; } -ccl_device bool ray_disk_intersect(float3 ray_P, - float3 ray_D, - float ray_tmin, - float ray_tmax, - float3 disk_P, - float3 disk_N, - float disk_radius, +ccl_device bool ray_disk_intersect(const float3 ray_P, + const float3 ray_D, + const float ray_tmin, + const float ray_tmax, + const float3 disk_P, + const float3 disk_N, + const float disk_radius, ccl_private float3 *isect_P, ccl_private float *isect_t) { @@ -257,14 +257,14 @@ ccl_device_forceinline bool ray_triangle_intersect_self(const float3 ray_P, * If ellipse is true, hits outside the ellipse that's enclosed by the * quad are rejected. */ -ccl_device bool ray_quad_intersect(float3 ray_P, - float3 ray_D, - float ray_tmin, - float ray_tmax, - float3 quad_P, - float3 inv_quad_u, - float3 inv_quad_v, - float3 quad_n, +ccl_device bool ray_quad_intersect(const float3 ray_P, + const float3 ray_D, + const float ray_tmin, + const float ray_tmax, + const float3 quad_P, + const float3 inv_quad_u, + const float3 inv_quad_v, + const float3 quad_n, ccl_private float3 *isect_P, ccl_private float *isect_t, ccl_private float *isect_u, diff --git a/intern/cycles/util/md5.cpp b/intern/cycles/util/md5.cpp index 47119973dbd..be389c117f8 100644 --- a/intern/cycles/util/md5.cpp +++ b/intern/cycles/util/md5.cpp @@ -257,7 +257,7 @@ MD5Hash::MD5Hash() MD5Hash::~MD5Hash() = default; -void MD5Hash::append(const uint8_t *data, int nbytes) +void MD5Hash::append(const uint8_t *data, const int nbytes) { const uint8_t *p = data; int left = nbytes; diff --git a/intern/cycles/util/md5.h b/intern/cycles/util/md5.h index d80251e32cd..7135a7c23d0 100644 --- a/intern/cycles/util/md5.h +++ b/intern/cycles/util/md5.h @@ -21,7 +21,7 @@ class MD5Hash { MD5Hash(); ~MD5Hash(); - void append(const uint8_t *data, int nbytes); + void append(const uint8_t *data, const int nbytes); void append(const string &str); bool append_file(const string &filepath); string get_hex(); diff --git a/intern/cycles/util/murmurhash.cpp b/intern/cycles/util/murmurhash.cpp index 0872d98f621..60e70696118 100644 --- a/intern/cycles/util/murmurhash.cpp +++ b/intern/cycles/util/murmurhash.cpp @@ -19,7 +19,7 @@ # define ROTL64(x, y) _rotl64(x, y) # define BIG_CONSTANT(x) (x) #else -ccl_device_inline uint32_t rotl32(uint32_t x, int8_t r) +ccl_device_inline uint32_t rotl32(const uint32_t x, int8_t r) { return (x << r) | (x >> (32 - r)); } @@ -31,7 +31,7 @@ CCL_NAMESPACE_BEGIN /* Block read - if your platform needs to do endian-swapping or can only * handle aligned reads, do the conversion here. */ -ccl_device_inline uint32_t mm_hash_getblock32(const uint32_t *p, int i) +ccl_device_inline uint32_t mm_hash_getblock32(const uint32_t *p, const int i) { return p[i]; } @@ -47,7 +47,7 @@ ccl_device_inline uint32_t mm_hash_fmix32(uint32_t h) return h; } -uint32_t util_murmur_hash3(const void *key, int len, uint32_t seed) +uint32_t util_murmur_hash3(const void *key, const int len, const uint32_t seed) { const uint8_t *data = (const uint8_t *)key; const int nblocks = len / 4; @@ -99,7 +99,7 @@ uint32_t util_murmur_hash3(const void *key, int len, uint32_t seed) } /* This is taken from the cryptomatte specification 1.0 */ -float util_hash_to_float(uint32_t hash) +float util_hash_to_float(const uint32_t hash) { const uint32_t mantissa = hash & ((1 << 23) - 1); uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); diff --git a/intern/cycles/util/murmurhash.h b/intern/cycles/util/murmurhash.h index 1d85b4f1180..1d09ed23460 100644 --- a/intern/cycles/util/murmurhash.h +++ b/intern/cycles/util/murmurhash.h @@ -8,7 +8,7 @@ CCL_NAMESPACE_BEGIN -uint32_t util_murmur_hash3(const void *key, int len, uint32_t seed); -float util_hash_to_float(uint32_t hash); +uint32_t util_murmur_hash3(const void *key, const int len, const uint32_t seed); +float util_hash_to_float(const uint32_t hash); CCL_NAMESPACE_END diff --git a/intern/cycles/util/profiling.cpp b/intern/cycles/util/profiling.cpp index a5b59fdea74..651dc7d741d 100644 --- a/intern/cycles/util/profiling.cpp +++ b/intern/cycles/util/profiling.cpp @@ -52,7 +52,7 @@ void Profiler::run() } } -void Profiler::reset(int num_shaders, int num_objects) +void Profiler::reset(const int num_shaders, const int num_objects) { const bool running = (worker != nullptr); if (running) { @@ -135,7 +135,7 @@ uint64_t Profiler::get_event(ProfilingEvent event) return event_samples[event]; } -bool Profiler::get_shader(int shader, uint64_t &samples, uint64_t &hits) +bool Profiler::get_shader(const int shader, uint64_t &samples, uint64_t &hits) { assert(worker == nullptr); if (shader_samples[shader] == 0) { @@ -146,7 +146,7 @@ bool Profiler::get_shader(int shader, uint64_t &samples, uint64_t &hits) return true; } -bool Profiler::get_object(int object, uint64_t &samples, uint64_t &hits) +bool Profiler::get_object(const int object, uint64_t &samples, uint64_t &hits) { assert(worker == nullptr); if (object_samples[object] == 0) { diff --git a/intern/cycles/util/profiling.h b/intern/cycles/util/profiling.h index 4758d61a92c..277134ac53b 100644 --- a/intern/cycles/util/profiling.h +++ b/intern/cycles/util/profiling.h @@ -72,7 +72,7 @@ class Profiler { Profiler(); ~Profiler(); - void reset(int num_shaders, int num_objects); + void reset(const int num_shaders, const int num_objects); void start(); void stop(); @@ -81,8 +81,8 @@ class Profiler { void remove_state(ProfilingState *state); uint64_t get_event(ProfilingEvent event); - bool get_shader(int shader, uint64_t &samples, uint64_t &hits); - bool get_object(int object, uint64_t &samples, uint64_t &hits); + bool get_shader(const int shader, uint64_t &samples, uint64_t &hits); + bool get_object(const int object, uint64_t &samples, uint64_t &hits); bool active() const; @@ -146,7 +146,7 @@ class ProfilingWithShaderHelper : public ProfilingHelper { state->shader = -1; } - void set_shader(int object, int shader) + void set_shader(const int object, const int shader) { if (state->active) { state->shader = shader; diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 82aaf674694..5d2b9155ef7 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -133,7 +133,7 @@ class Progress { render_start_time = time_dt(); } - void set_time_limit(double time_limit_) + void set_time_limit(const double time_limit_) { const thread_scoped_lock lock(progress_mutex); @@ -175,7 +175,7 @@ class Progress { denoised_tiles = 0; } - void set_total_pixel_samples(uint64_t total_pixel_samples_) + void set_total_pixel_samples(const uint64_t total_pixel_samples_) { const thread_scoped_lock lock(progress_mutex); @@ -197,7 +197,7 @@ class Progress { return 0.0; } - void add_samples(uint64_t pixel_samples_, int tile_sample) + void add_samples(const uint64_t pixel_samples_, int tile_sample) { const thread_scoped_lock lock(progress_mutex); @@ -205,7 +205,7 @@ class Progress { current_tile_sample = tile_sample; } - void add_samples_update(uint64_t pixel_samples_, int tile_sample) + void add_samples_update(const uint64_t pixel_samples_, int tile_sample) { add_samples(pixel_samples_, tile_sample); set_update(); diff --git a/intern/cycles/util/projection.h b/intern/cycles/util/projection.h index f0f844c2ee6..2a43dba1bb6 100644 --- a/intern/cycles/util/projection.h +++ b/intern/cycles/util/projection.h @@ -8,7 +8,7 @@ CCL_NAMESPACE_BEGIN -ccl_device float2 direction_to_spherical(float3 dir) +ccl_device float2 direction_to_spherical(const float3 dir) { const float theta = safe_acosf(dir.z); const float phi = atan2f(dir.y, dir.x); @@ -16,18 +16,18 @@ ccl_device float2 direction_to_spherical(float3 dir) return make_float2(theta, phi); } -ccl_device float3 spherical_to_direction(float theta, float phi) +ccl_device float3 spherical_to_direction(const float theta, const float phi) { return make_float3(sinf(theta) * cosf(phi), sinf(theta) * sinf(phi), cosf(theta)); } -ccl_device float3 spherical_cos_to_direction(float cos_theta, float phi) +ccl_device float3 spherical_cos_to_direction(const float cos_theta, const float phi) { const float sin_theta = sin_from_cos(cos_theta); return make_float3(sin_theta * cosf(phi), sin_theta * sinf(phi), cos_theta); } -ccl_device_inline float2 polar_to_cartesian(float r, float phi) +ccl_device_inline float2 polar_to_cartesian(const float r, const float phi) { return make_float2(r * cosf(phi), r * sinf(phi)); } @@ -111,22 +111,22 @@ ccl_device_inline float3 transform_perspective_direction(const ccl_private Proje return c; } -ccl_device_inline ProjectionTransform make_projection(float a, - float b, - float c, - float d, - float e, - float f, - float g, - float h, - float i, - float j, - float k, - float l, - float m, - float n, - float o, - float p) +ccl_device_inline ProjectionTransform make_projection(const float a, + const float b, + const float c, + const float d, + const float e, + const float f, + const float g, + const float h, + const float i, + const float j, + const float k, + const float l, + const float m, + const float n, + const float o, + const float p) { ProjectionTransform t; @@ -257,7 +257,9 @@ ccl_device_inline void print_projection(const char *label, const ProjectionTrans printf("\n"); } -ccl_device_inline ProjectionTransform projection_perspective(float fov, float n, float f) +ccl_device_inline ProjectionTransform projection_perspective(const float fov, + const float n, + float f) { const ProjectionTransform persp = make_projection( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, f / (f - n), -f * n / (f - n), 0, 0, 1, 0); @@ -269,7 +271,7 @@ ccl_device_inline ProjectionTransform projection_perspective(float fov, float n, return scale * persp; } -ccl_device_inline ProjectionTransform projection_orthographic(float znear, float zfar) +ccl_device_inline ProjectionTransform projection_orthographic(const float znear, const float zfar) { const Transform t = transform_scale(1.0f, 1.0f, 1.0f / (zfar - znear)); diff --git a/intern/cycles/util/rect.h b/intern/cycles/util/rect.h index d5c73303635..40eb5c5376c 100644 --- a/intern/cycles/util/rect.h +++ b/intern/cycles/util/rect.h @@ -12,29 +12,29 @@ CCL_NAMESPACE_BEGIN /* Rectangles are represented as a int4 containing the coordinates of the lower-left and * upper-right corners in the order (x0, y0, x1, y1). */ -ccl_device_inline int4 rect_from_shape(int x0, int y0, int w, int h) +ccl_device_inline int4 rect_from_shape(const int x0, const int y0, const int w, int h) { return make_int4(x0, y0, x0 + w, y0 + h); } -ccl_device_inline int4 rect_expand(int4 rect, int d) +ccl_device_inline int4 rect_expand(const int4 rect, const int d) { return make_int4(rect.x - d, rect.y - d, rect.z + d, rect.w + d); } /* Returns the intersection of two rects. */ -ccl_device_inline int4 rect_clip(int4 a, int4 b) +ccl_device_inline int4 rect_clip(const int4 a, const int4 b) { return make_int4(max(a.x, b.x), max(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); } -ccl_device_inline bool rect_is_valid(int4 rect) +ccl_device_inline bool rect_is_valid(const int4 rect) { return (rect.z > rect.x) && (rect.w > rect.y); } /* Returns the local row-major index of the pixel inside the rect. */ -ccl_device_inline int coord_to_local_index(int4 rect, int x, int y) +ccl_device_inline int coord_to_local_index(const int4 rect, const int x, int y) { const int w = rect.z - rect.x; return (y - rect.y) * w + (x - rect.x); @@ -42,8 +42,8 @@ ccl_device_inline int coord_to_local_index(int4 rect, int x, int y) /* Finds the coordinates of a pixel given by its row-major index in the rect, * and returns whether the pixel is inside it. */ -ccl_device_inline bool local_index_to_coord(int4 rect, - int idx, +ccl_device_inline bool local_index_to_coord(const int4 rect, + const int idx, ccl_private int *x, ccl_private int *y) { @@ -53,7 +53,7 @@ ccl_device_inline bool local_index_to_coord(int4 rect, return (*y < rect.w); } -ccl_device_inline int rect_size(int4 rect) +ccl_device_inline int rect_size(const int4 rect) { return (rect.z - rect.x) * (rect.w - rect.y); } diff --git a/intern/cycles/util/simd.h b/intern/cycles/util/simd.h index fd6ce4b2ee9..a6c8438b585 100644 --- a/intern/cycles/util/simd.h +++ b/intern/cycles/util/simd.h @@ -126,7 +126,7 @@ static struct StepTy { #endif #if (defined(__aarch64__) || defined(_M_ARM64)) && !defined(_MM_SET_FLUSH_ZERO_MODE) -__forceinline int set_fz(uint32_t flag) +__forceinline int set_fz(const uint32_t flag) { uint64_t old_fpcr; uint64_t new_fpcr; @@ -136,7 +136,7 @@ __forceinline int set_fz(uint32_t flag) __get_fpcr(old_fpcr); return old_fpcr == new_fpcr; } -__forceinline int get_fz(uint32_t flag) +__forceinline int get_fz(const uint32_t flag) { uint64_t cur_fpcr; __get_fpcr(cur_fpcr); @@ -146,7 +146,8 @@ __forceinline int get_fz(uint32_t flag) /* Utilities used by Neon */ #if defined(__KERNEL_NEON__) -template type shuffle_neon(const type &a) +template +type shuffle_neon(const type &a) { if (i0 == i1 && i0 == i2 && i0 == i3) { return type(vdupq_laneq_s32(int32x4_t(a), i0)); @@ -171,7 +172,7 @@ template type shuffle_neon(const typ return type(vqtbl1q_s8(int8x16_t(a), *(uint8x16_t *)tbl)); } -template +template type shuffle_neon(const type &a, const type &b) { if (&a == &b) { @@ -242,7 +243,7 @@ type shuffle_neon(const type &a, const type &b) #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__clang__) /* Intrinsic functions on Windows. */ -__forceinline uint32_t __bsf(uint32_t v) +__forceinline uint32_t __bsf(const uint32_t v) { # if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); @@ -253,21 +254,21 @@ __forceinline uint32_t __bsf(uint32_t v) # endif } -__forceinline uint32_t __bsr(uint32_t v) +__forceinline uint32_t __bsr(const uint32_t v) { unsigned long r = 0; _BitScanReverse(&r, v); return r; } -__forceinline uint32_t __btc(uint32_t v, uint32_t i) +__forceinline uint32_t __btc(const uint32_t v, const uint32_t i) { long r = v; _bittestandcomplement(&r, i); return r; } -__forceinline uint32_t bitscan(uint32_t v) +__forceinline uint32_t bitscan(const uint32_t v) { # if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); @@ -278,7 +279,7 @@ __forceinline uint32_t bitscan(uint32_t v) # if defined(__KERNEL_64_BIT__) -__forceinline uint64_t __bsf(uint64_t v) +__forceinline uint64_t __bsf(const uint64_t v) { # if defined(__KERNEL_AVX2__) return _tzcnt_u64(v); @@ -289,21 +290,21 @@ __forceinline uint64_t __bsf(uint64_t v) # endif } -__forceinline uint64_t __bsr(uint64_t v) +__forceinline uint64_t __bsr(const uint64_t v) { unsigned long r = 0; _BitScanReverse64(&r, v); return r; } -__forceinline uint64_t __btc(uint64_t v, uint64_t i) +__forceinline uint64_t __btc(const uint64_t v, const uint64_t i) { uint64_t r = v; _bittestandcomplement64((__int64 *)&r, i); return r; } -__forceinline uint64_t bitscan(uint64_t v) +__forceinline uint64_t bitscan(const uint64_t v) { # if defined(__KERNEL_AVX2__) # if defined(__KERNEL_64_BIT__) @@ -335,7 +336,7 @@ __forceinline uint32_t __bsr(const uint32_t v) return r; } -__forceinline uint32_t __btc(const uint32_t v, uint32_t i) +__forceinline uint32_t __btc(const uint32_t v, const uint32_t i) { uint32_t r = 0; asm("btc %1,%0" : "=r"(r) : "r"(i), "0"(v) : "flags"); @@ -366,7 +367,7 @@ __forceinline uint64_t __btc(const uint64_t v, const uint64_t i) return r; } -__forceinline uint32_t bitscan(uint32_t v) +__forceinline uint32_t bitscan(const uint32_t v) { # if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); @@ -377,7 +378,7 @@ __forceinline uint32_t bitscan(uint32_t v) # if (defined(__KERNEL_64_BIT__) || defined(__APPLE__)) && \ !(defined(__ILP32__) && defined(__x86_64__)) -__forceinline uint64_t bitscan(uint64_t v) +__forceinline uint64_t bitscan(const uint64_t v) { # if defined(__KERNEL_AVX2__) # if defined(__KERNEL_64_BIT__) @@ -445,7 +446,7 @@ __forceinline uint64_t __btc(const uint64_t x, const uint32_t bit) return x & (~mask); } -__forceinline uint32_t bitscan(uint32_t value) +__forceinline uint32_t bitscan(const uint32_t value) { assert(value != 0); uint32_t bit = 0; @@ -455,7 +456,7 @@ __forceinline uint32_t bitscan(uint32_t value) return bit; } -__forceinline uint64_t bitscan(uint64_t value) +__forceinline uint64_t bitscan(const uint64_t value) { assert(value != 0); uint64_t bit = 0; diff --git a/intern/cycles/util/stack_allocator.h b/intern/cycles/util/stack_allocator.h index c489545379c..57f64417542 100644 --- a/intern/cycles/util/stack_allocator.h +++ b/intern/cycles/util/stack_allocator.h @@ -36,7 +36,7 @@ template class ccl_try_align(16) StackAllocator /* Memory allocation/deallocation. */ - T *allocate(size_t n, const void *hint = nullptr) + T *allocate(const size_t n, const void *hint = nullptr) { (void)hint; if (n == 0) { @@ -61,7 +61,7 @@ template class ccl_try_align(16) StackAllocator return mem; } - void deallocate(T * p, size_t n) + void deallocate(T * p, const size_t n) { if (p == nullptr) { return; diff --git a/intern/cycles/util/stats.h b/intern/cycles/util/stats.h index 23e01acd688..2fccc1f8476 100644 --- a/intern/cycles/util/stats.h +++ b/intern/cycles/util/stats.h @@ -15,13 +15,13 @@ class Stats { Stats() : mem_used(0), mem_peak(0) {} explicit Stats(static_init_t /*unused*/) {} - void mem_alloc(size_t size) + void mem_alloc(const size_t size) { atomic_add_and_fetch_z(&mem_used, size); atomic_fetch_and_update_max_z(&mem_peak, mem_used); } - void mem_free(size_t size) + void mem_free(const size_t size) { assert(mem_used >= size); atomic_sub_and_fetch_z(&mem_used, size); diff --git a/intern/cycles/util/string.h b/intern/cycles/util/string.h index 441505f1b68..7bb36bc7ac7 100644 --- a/intern/cycles/util/string.h +++ b/intern/cycles/util/string.h @@ -62,8 +62,8 @@ string string_to_ansi(const string &str); #endif /* Make a string from a size in bytes in human readable form. */ -string string_human_readable_size(size_t size); +string string_human_readable_size(const size_t size); /* Make a string from a unit-less quantity in human readable form. */ -string string_human_readable_number(size_t num); +string string_human_readable_number(const size_t num); CCL_NAMESPACE_END diff --git a/intern/cycles/util/task.cpp b/intern/cycles/util/task.cpp index 7498c3aa969..d791473db73 100644 --- a/intern/cycles/util/task.cpp +++ b/intern/cycles/util/task.cpp @@ -57,7 +57,7 @@ int TaskScheduler::users = 0; int TaskScheduler::active_num_threads = 0; tbb::global_control *TaskScheduler::global_control = nullptr; -void TaskScheduler::init(int num_threads) +void TaskScheduler::init(const int num_threads) { const thread_scoped_lock lock(mutex); /* Multiple cycles instances can use this task scheduler, sharing the same @@ -163,7 +163,7 @@ bool DedicatedTaskPool::canceled() return do_cancel; } -void DedicatedTaskPool::num_decrease(int done) +void DedicatedTaskPool::num_decrease(const int done) { const thread_scoped_lock num_lock(num_mutex); num -= done; diff --git a/intern/cycles/util/task.h b/intern/cycles/util/task.h index f907604bfe2..5afa95a595d 100644 --- a/intern/cycles/util/task.h +++ b/intern/cycles/util/task.h @@ -69,7 +69,7 @@ class TaskPool { */ class TaskScheduler { public: - static void init(int num_threads = 0); + static void init(const int num_threads = 0); static void exit(); static void free_memory(); @@ -106,7 +106,7 @@ class DedicatedTaskPool { bool canceled(); /* for worker thread, test if canceled */ protected: - void num_decrease(int done); + void num_decrease(const int done); void num_increase(); void thread_run(); diff --git a/intern/cycles/util/time.cpp b/intern/cycles/util/time.cpp index 758ef3dc263..685a8b82143 100644 --- a/intern/cycles/util/time.cpp +++ b/intern/cycles/util/time.cpp @@ -30,7 +30,7 @@ double time_dt() return (double)counter / (double)frequency; } -void time_sleep(double t) +void time_sleep(const double t) { Sleep((int)(t * 1000)); } diff --git a/intern/cycles/util/time.h b/intern/cycles/util/time.h index c9cfe2b843a..04e06832e13 100644 --- a/intern/cycles/util/time.h +++ b/intern/cycles/util/time.h @@ -16,7 +16,7 @@ double time_dt(); /* Sleep for the specified number of seconds. */ -void time_sleep(double t); +void time_sleep(const double t); /* Scoped timer. */ diff --git a/intern/cycles/util/transform.cpp b/intern/cycles/util/transform.cpp index 7c846b1f0c1..3e993735aed 100644 --- a/intern/cycles/util/transform.cpp +++ b/intern/cycles/util/transform.cpp @@ -152,7 +152,9 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf #endif } -void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, size_t size) +void transform_motion_decompose(DecomposedTransform *decomp, + const Transform *motion, + const size_t size) { /* Decompose and correct rotation. */ for (size_t i = 0; i < size; i++) { diff --git a/intern/cycles/util/transform.h b/intern/cycles/util/transform.h index 68c1c15d3ee..fcde90a15bd 100644 --- a/intern/cycles/util/transform.h +++ b/intern/cycles/util/transform.h @@ -123,18 +123,18 @@ ccl_device_inline float3 transform_direction_transposed(const ccl_private Transf return make_float3(dot(x, a), dot(y, a), dot(z, a)); } -ccl_device_inline Transform make_transform(float a, - float b, - float c, - float d, - float e, - float f, - float g, - float h, - float i, - float j, - float k, - float l) +ccl_device_inline Transform make_transform(const float a, + const float b, + const float c, + const float d, + const float e, + const float f, + const float g, + const float h, + const float i, + const float j, + const float k, + const float l) { Transform t; @@ -192,7 +192,7 @@ ccl_device_inline Transform euler_to_transform(const float3 euler) } /* Constructs a coordinate frame from a normalized normal. */ -ccl_device_inline Transform make_transform_frame(float3 N) +ccl_device_inline Transform make_transform_frame(const float3 N) { const float3 dx0 = cross(make_float3(1.0f, 0.0f, 0.0f), N); const float3 dx1 = cross(make_float3(0.0f, 1.0f, 0.0f), N); @@ -234,27 +234,27 @@ ccl_device_inline void print_transform(const char *label, const Transform &t) printf("\n"); } -ccl_device_inline Transform transform_translate(float3 t) +ccl_device_inline Transform transform_translate(const float3 t) { return make_transform(1, 0, 0, t.x, 0, 1, 0, t.y, 0, 0, 1, t.z); } -ccl_device_inline Transform transform_translate(float x, float y, float z) +ccl_device_inline Transform transform_translate(const float x, const float y, float z) { return transform_translate(make_float3(x, y, z)); } -ccl_device_inline Transform transform_scale(float3 s) +ccl_device_inline Transform transform_scale(const float3 s) { return make_transform(s.x, 0, 0, 0, 0, s.y, 0, 0, 0, 0, s.z, 0); } -ccl_device_inline Transform transform_scale(float x, float y, float z) +ccl_device_inline Transform transform_scale(const float x, const float y, float z) { return transform_scale(make_float3(x, y, z)); } -ccl_device_inline Transform transform_rotate(float angle, float3 axis) +ccl_device_inline Transform transform_rotate(const float angle, float3 axis) { const float s = sinf(angle); const float c = cosf(angle); @@ -279,7 +279,7 @@ ccl_device_inline Transform transform_rotate(float angle, float3 axis) } /* Euler is assumed to be in XYZ order. */ -ccl_device_inline Transform transform_euler(float3 euler) +ccl_device_inline Transform transform_euler(const float3 euler) { return transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f)) * transform_rotate(euler.y, make_float3(0.0f, 1.0f, 0.0f)) * @@ -316,12 +316,12 @@ ccl_device_inline bool transform_equal_threshold(const Transform &A, return true; } -ccl_device_inline float3 transform_get_column(const Transform *t, int column) +ccl_device_inline float3 transform_get_column(const Transform *t, const int column) { return make_float3(t->x[column], t->y[column], t->z[column]); } -ccl_device_inline void transform_set_column(Transform *t, int column, float3 value) +ccl_device_inline void transform_set_column(Transform *t, const int column, const float3 value) { t->x[column] = value.x; t->y[column] = value.y; @@ -382,7 +382,7 @@ ccl_device_inline Transform transform_empty() /* Motion Transform */ -ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) +ccl_device_inline float4 quat_interpolate(const float4 q1, const float4 q2, const float t) { /* Optix and MetalRT are using linear interpolation to interpolate motion transformations. */ #if defined(__KERNEL_GPU_RAYTRACING__) @@ -561,8 +561,8 @@ ccl_device_inline void transform_compose(ccl_private Transform *tfm, /* Interpolate from array of decomposed transforms. */ ccl_device void transform_motion_array_interpolate(ccl_private Transform *tfm, const ccl_global DecomposedTransform *motion, - uint numsteps, - float time) + const uint numsteps, + const float time) { /* Figure out which steps we need to interpolate. */ const int maxstep = numsteps - 1; @@ -604,7 +604,9 @@ ccl_device_inline bool operator==(const DecomposedTransform &A, const Decomposed } float4 transform_to_quat(const Transform &tfm); -void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, size_t size); +void transform_motion_decompose(DecomposedTransform *decomp, + const Transform *motion, + const size_t size); Transform transform_from_viewplane(BoundBox2D &viewplane); #endif diff --git a/intern/cycles/util/types_base.h b/intern/cycles/util/types_base.h index af57498d1e2..cbc50971c58 100644 --- a/intern/cycles/util/types_base.h +++ b/intern/cycles/util/types_base.h @@ -44,27 +44,27 @@ using ushort = unsigned short; using device_ptr = uint64_t; #endif /* __KERNEL_GPU__ */ -ccl_device_inline size_t align_up(size_t offset, size_t alignment) +ccl_device_inline size_t align_up(const size_t offset, const size_t alignment) { return (offset + alignment - 1) & ~(alignment - 1); } -ccl_device_inline size_t divide_up(size_t x, size_t y) +ccl_device_inline size_t divide_up(const size_t x, const size_t y) { return (x + y - 1) / y; } -ccl_device_inline size_t round_up(size_t x, size_t multiple) +ccl_device_inline size_t round_up(const size_t x, const size_t multiple) { return ((x + multiple - 1) / multiple) * multiple; } -ccl_device_inline size_t round_down(size_t x, size_t multiple) +ccl_device_inline size_t round_down(const size_t x, const size_t multiple) { return (x / multiple) * multiple; } -ccl_device_inline bool is_power_of_two(size_t x) +ccl_device_inline bool is_power_of_two(const size_t x) { return (x & (x - 1)) == 0; } diff --git a/intern/cycles/util/types_float2.h b/intern/cycles/util/types_float2.h index 1c9328aa198..02fef4e2104 100644 --- a/intern/cycles/util/types_float2.h +++ b/intern/cycles/util/types_float2.h @@ -34,7 +34,7 @@ __forceinline float &float2::operator[](int i) } # endif -ccl_device_inline float2 make_float2(float x, float y) +ccl_device_inline float2 make_float2(const float x, const float y) { float2 a = {x, y}; return a; diff --git a/intern/cycles/util/types_float3.h b/intern/cycles/util/types_float3.h index 5f94bf0a175..c4686456738 100644 --- a/intern/cycles/util/types_float3.h +++ b/intern/cycles/util/types_float3.h @@ -73,7 +73,7 @@ struct ccl_try_align(16) float3 # endif }; -ccl_device_inline float3 make_float3(float x, float y, float z) +ccl_device_inline float3 make_float3(const float x, const float y, float z) { # if defined(__KERNEL_GPU__) return {x, y, z}; @@ -86,7 +86,7 @@ ccl_device_inline float3 make_float3(float x, float y, float z) #endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ -ccl_device_inline float3 make_float3(float f) +ccl_device_inline float3 make_float3(const float f) { #if defined(__KERNEL_GPU__) return make_float3(f, f, f); @@ -97,12 +97,12 @@ ccl_device_inline float3 make_float3(float f) #endif } -ccl_device_inline float3 make_float3(float2 a) +ccl_device_inline float3 make_float3(const float2 a) { return make_float3(a.x, a.y, 0.0f); } -ccl_device_inline float3 make_float3(float2 a, float b) +ccl_device_inline float3 make_float3(const float2 a, const float b) { return make_float3(a.x, a.y, b); } @@ -117,7 +117,7 @@ ccl_device_inline void print_float3(const ccl_private char *label, const float3 #endif } -ccl_device_inline float2 make_float2(float3 a) +ccl_device_inline float2 make_float2(const float3 a) { return make_float2(a.x, a.y); } diff --git a/intern/cycles/util/types_float4.h b/intern/cycles/util/types_float4.h index e00593501a2..b4fb8cbcf03 100644 --- a/intern/cycles/util/types_float4.h +++ b/intern/cycles/util/types_float4.h @@ -62,7 +62,7 @@ struct ccl_try_align(16) float4 # endif }; -ccl_device_inline float4 make_float4(float x, float y, float z, float w) +ccl_device_inline float4 make_float4(const float x, const float y, float z, const float w) { # ifdef __KERNEL_SSE__ return float4(_mm_set_ps(w, z, y, x)); @@ -73,7 +73,7 @@ ccl_device_inline float4 make_float4(float x, float y, float z, float w) #endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ -ccl_device_inline float4 make_float4(float f) +ccl_device_inline float4 make_float4(const float f) { #ifdef __KERNEL_SSE__ return float4(_mm_set1_ps(f)); @@ -82,12 +82,12 @@ ccl_device_inline float4 make_float4(float f) #endif } -ccl_device_inline float4 make_float4(float3 a, float b) +ccl_device_inline float4 make_float4(const float3 a, const float b) { return make_float4(a.x, a.y, a.z, b); } -ccl_device_inline float4 make_float4(float3 a) +ccl_device_inline float4 make_float4(const float3 a) { return make_float4(a.x, a.y, a.z, 1.0f); } @@ -101,7 +101,7 @@ ccl_device_inline float4 make_float4(const int4 i) #endif } -ccl_device_inline float3 make_float3(float4 a) +ccl_device_inline float3 make_float3(const float4 a) { return make_float3(a.x, a.y, a.z); } diff --git a/intern/cycles/util/types_float8.h b/intern/cycles/util/types_float8.h index 5f89a2d29a9..3aa0749b83e 100644 --- a/intern/cycles/util/types_float8.h +++ b/intern/cycles/util/types_float8.h @@ -69,7 +69,7 @@ struct ccl_try_align(32) vfloat8 #endif }; -ccl_device_inline vfloat8 make_vfloat8(float f) +ccl_device_inline vfloat8 make_vfloat8(const float f) { #ifdef __KERNEL_AVX__ vfloat8 r(_mm256_set1_ps(f)); @@ -79,8 +79,14 @@ ccl_device_inline vfloat8 make_vfloat8(float f) return r; } -ccl_device_inline vfloat8 -make_vfloat8(float a, float b, float c, float d, float e, float f, float g, float h) +ccl_device_inline vfloat8 make_vfloat8(const float a, + const float b, + float c, + const float d, + float e, + const float f, + float g, + const float h) { #ifdef __KERNEL_AVX__ vfloat8 r(_mm256_setr_ps(a, b, c, d, e, f, g, h)); diff --git a/intern/cycles/util/types_int2.h b/intern/cycles/util/types_int2.h index 1661b3cf1d7..45bd653f817 100644 --- a/intern/cycles/util/types_int2.h +++ b/intern/cycles/util/types_int2.h @@ -29,7 +29,7 @@ struct int2 { # endif }; -ccl_device_inline int2 make_int2(int x, int y) +ccl_device_inline int2 make_int2(const int x, const int y) { int2 a = {x, y}; return a; diff --git a/intern/cycles/util/types_int3.h b/intern/cycles/util/types_int3.h index d220b9ab8a9..745c7de4e46 100644 --- a/intern/cycles/util/types_int3.h +++ b/intern/cycles/util/types_int3.h @@ -65,7 +65,7 @@ struct ccl_try_align(16) int3 # endif }; -ccl_device_inline int3 make_int3(int x, int y, int z) +ccl_device_inline int3 make_int3(const int x, const int y, int z) { # if defined(__KERNEL_GPU__) return {x, y, z}; @@ -78,7 +78,7 @@ ccl_device_inline int3 make_int3(int x, int y, int z) #endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ -ccl_device_inline int3 make_int3(int i) +ccl_device_inline int3 make_int3(const int i) { #if defined(__KERNEL_GPU__) return make_int3(i, i, i); @@ -144,7 +144,7 @@ struct packed_int3 { static_assert(sizeof(packed_int3) == 12, "packed_int3 expected to be exactly 12 bytes"); #endif -ccl_device_inline packed_int3 make_packed_int3(int x, int y, int z) +ccl_device_inline packed_int3 make_packed_int3(const int x, const int y, int z) { packed_int3 a = {x, y, z}; return a; diff --git a/intern/cycles/util/types_int4.h b/intern/cycles/util/types_int4.h index 5debf18aa56..a5604ee9c32 100644 --- a/intern/cycles/util/types_int4.h +++ b/intern/cycles/util/types_int4.h @@ -58,7 +58,7 @@ struct ccl_try_align(16) int4 # endif }; -ccl_device_inline int4 make_int4(int x, int y, int z, int w) +ccl_device_inline int4 make_int4(const int x, const int y, int z, const int w) { # ifdef __KERNEL_SSE__ return int4(_mm_set_epi32(w, z, y, x)); @@ -68,7 +68,7 @@ ccl_device_inline int4 make_int4(int x, int y, int z, int w) } #endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ -ccl_device_inline int4 make_int4(int i) +ccl_device_inline int4 make_int4(const int i) { #ifdef __KERNEL_SSE__ return int4(_mm_set1_epi32(i)); diff --git a/intern/cycles/util/types_int8.h b/intern/cycles/util/types_int8.h index 229daa7c98c..d8d09ba7710 100644 --- a/intern/cycles/util/types_int8.h +++ b/intern/cycles/util/types_int8.h @@ -63,7 +63,8 @@ struct ccl_try_align(32) vint8 #endif }; -ccl_device_inline vint8 make_vint8(int a, int b, int c, int d, int e, int f, int g, int h) +ccl_device_inline vint8 +make_vint8(const int a, const int b, int c, const int d, int e, const int f, int g, const int h) { #ifdef __KERNEL_AVX__ return vint8(_mm256_set_epi32(h, g, f, e, d, c, b, a)); @@ -72,7 +73,7 @@ ccl_device_inline vint8 make_vint8(int a, int b, int c, int d, int e, int f, int #endif } -ccl_device_inline vint8 make_vint8(int i) +ccl_device_inline vint8 make_vint8(const int i) { #ifdef __KERNEL_AVX__ return vint8(_mm256_set1_epi32(i)); diff --git a/intern/cycles/util/types_uchar2.h b/intern/cycles/util/types_uchar2.h index 324dde59ad7..7d6b683724a 100644 --- a/intern/cycles/util/types_uchar2.h +++ b/intern/cycles/util/types_uchar2.h @@ -29,7 +29,7 @@ struct uchar2 { # endif }; -ccl_device_inline uchar2 make_uchar2(uchar x, uchar y) +ccl_device_inline uchar2 make_uchar2(const uchar x, const uchar y) { uchar2 a = {x, y}; return a; diff --git a/intern/cycles/util/types_uchar3.h b/intern/cycles/util/types_uchar3.h index 183628b134f..9058da80238 100644 --- a/intern/cycles/util/types_uchar3.h +++ b/intern/cycles/util/types_uchar3.h @@ -29,7 +29,7 @@ struct uchar3 { # endif }; -ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z) +ccl_device_inline uchar3 make_uchar3(const uchar x, const uchar y, uchar z) { uchar3 a = {x, y, z}; return a; diff --git a/intern/cycles/util/types_uchar4.h b/intern/cycles/util/types_uchar4.h index 7d2e7fc8042..4bd52cfe201 100644 --- a/intern/cycles/util/types_uchar4.h +++ b/intern/cycles/util/types_uchar4.h @@ -29,7 +29,7 @@ struct uchar4 { # endif }; -ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w) +ccl_device_inline uchar4 make_uchar4(const uchar x, const uchar y, uchar z, const uchar w) { uchar4 a = {x, y, z, w}; return a; diff --git a/intern/cycles/util/types_uint2.h b/intern/cycles/util/types_uint2.h index b8edfc2eefe..e0a53856144 100644 --- a/intern/cycles/util/types_uint2.h +++ b/intern/cycles/util/types_uint2.h @@ -27,7 +27,7 @@ struct uint2 { # endif }; -ccl_device_inline uint2 make_uint2(uint x, uint y) +ccl_device_inline uint2 make_uint2(const uint x, const uint y) { uint2 a = {x, y}; return a; diff --git a/intern/cycles/util/types_uint3.h b/intern/cycles/util/types_uint3.h index 0eec36d826b..c78d2f00c19 100644 --- a/intern/cycles/util/types_uint3.h +++ b/intern/cycles/util/types_uint3.h @@ -27,7 +27,7 @@ struct uint3 { # endif }; -ccl_device_inline uint3 make_uint3(uint x, uint y, uint z) +ccl_device_inline uint3 make_uint3(const uint x, const uint y, uint z) { uint3 a = {x, y, z}; return a; @@ -82,7 +82,7 @@ struct packed_uint3 { static_assert(sizeof(packed_uint3) == 12, "packed_uint3 expected to be exactly 12 bytes"); #endif -ccl_device_inline packed_uint3 make_packed_uint3(uint x, uint y, uint z) +ccl_device_inline packed_uint3 make_packed_uint3(const uint x, const uint y, uint z) { packed_uint3 a = {x, y, z}; return a; diff --git a/intern/cycles/util/types_uint4.h b/intern/cycles/util/types_uint4.h index 01e3bbe9487..19700969f6c 100644 --- a/intern/cycles/util/types_uint4.h +++ b/intern/cycles/util/types_uint4.h @@ -27,7 +27,7 @@ struct uint4 { # endif }; -ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w) +ccl_device_inline uint4 make_uint4(const uint x, const uint y, uint z, const uint w) { uint4 a = {x, y, z, w}; return a; diff --git a/intern/cycles/util/windows.cpp b/intern/cycles/util/windows.cpp index 6fabbee52c5..fca526f4d1a 100644 --- a/intern/cycles/util/windows.cpp +++ b/intern/cycles/util/windows.cpp @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN -bool system_windows_version_at_least(int major, int build) +bool system_windows_version_at_least(const int major, const int build) { #ifdef _WIN32 HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll"); diff --git a/intern/cycles/util/windows.h b/intern/cycles/util/windows.h index 17cf03a4cd7..b3b33716414 100644 --- a/intern/cycles/util/windows.h +++ b/intern/cycles/util/windows.h @@ -22,6 +22,6 @@ CCL_NAMESPACE_BEGIN -bool system_windows_version_at_least(int major, int build); +bool system_windows_version_at_least(const int major, const int build); CCL_NAMESPACE_END