From ff1883307f12a8b734bfcf87b01743dc73afae75 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 17 Jun 2022 17:16:37 +0200 Subject: Cleanup: renaming and consistency for kernel data * Rename "texture" to "data array". This has not used textures for a long time, there are just global memory arrays now. (On old CUDA GPUs there was a cache for textures but not global memory, so we used to put all data in textures.) * For CUDA and HIP, put globals in KernelParams struct like other devices. * Drop __ prefix for data array names, no possibility for naming conflict now that these are in a struct. --- intern/cycles/kernel/integrator/init_from_bake.h | 4 ++-- intern/cycles/kernel/integrator/intersect_closest.h | 14 +++++++------- intern/cycles/kernel/integrator/mnee.h | 12 ++++++------ intern/cycles/kernel/integrator/shade_background.h | 4 ++-- intern/cycles/kernel/integrator/shade_surface.h | 2 +- intern/cycles/kernel/integrator/shader_eval.h | 16 ++++++++-------- intern/cycles/kernel/integrator/subsurface.h | 4 ++-- intern/cycles/kernel/integrator/subsurface_disk.h | 2 +- intern/cycles/kernel/integrator/volume_stack.h | 6 +++--- 9 files changed, 32 insertions(+), 32 deletions(-) (limited to 'intern/cycles/kernel/integrator') diff --git a/intern/cycles/kernel/integrator/init_from_bake.h b/intern/cycles/kernel/integrator/init_from_bake.h index 0db4241b6e3..7d53bf479bf 100644 --- a/intern/cycles/kernel/integrator/init_from_bake.h +++ b/intern/cycles/kernel/integrator/init_from_bake.h @@ -160,7 +160,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg, int shader; triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader); - const int object_flag = kernel_tex_fetch(__object_flag, object); + const int object_flag = kernel_data_fetch(object_flag, object); if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); P = transform_point_auto(&tfm, P); @@ -193,7 +193,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg, } const int shader_index = shader & SHADER_MASK; - const int shader_flags = kernel_tex_fetch(__shaders, shader_index).flags; + const int shader_flags = kernel_data_fetch(shaders, shader_index).flags; /* Fast path for position and normal passes not affected by shaders. */ if (kernel_data.film.pass_position != PASS_UNUSED) { diff --git a/intern/cycles/kernel/integrator/intersect_closest.h b/intern/cycles/kernel/integrator/intersect_closest.h index 2dfac44b414..621aa05f46b 100644 --- a/intern/cycles/kernel/integrator/intersect_closest.h +++ b/intern/cycles/kernel/integrator/intersect_closest.h @@ -122,7 +122,7 @@ ccl_device_forceinline void integrator_split_shadow_catcher( /* Continue with shading shadow catcher surface. */ const int shader = intersection_get_shader(kg, isect); - const int flags = kernel_tex_fetch(__shaders, shader).flags; + const int flags = kernel_data_fetch(shaders, shader).flags; const bool use_caustics = kernel_data.integrator.use_caustics && (object_flags & SD_OBJECT_CAUSTICS); const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE); @@ -149,7 +149,7 @@ ccl_device_forceinline void integrator_intersect_next_kernel_after_shadow_catche integrator_state_read_isect(kg, state, &isect); const int shader = intersection_get_shader(kg, &isect); - const int flags = kernel_tex_fetch(__shaders, shader).flags; + const int flags = kernel_data_fetch(shaders, shader).flags; const int object_flags = intersection_get_object_flags(kg, &isect); const bool use_caustics = kernel_data.integrator.use_caustics && (object_flags & SD_OBJECT_CAUSTICS); @@ -203,7 +203,7 @@ ccl_device_forceinline void integrator_intersect_next_kernel( if (!integrator_state_volume_stack_is_empty(kg, state)) { const bool hit_surface = hit && !(isect->type & PRIMITIVE_LAMP); const int shader = (hit_surface) ? intersection_get_shader(kg, isect) : SHADER_NONE; - const int flags = (hit_surface) ? kernel_tex_fetch(__shaders, shader).flags : 0; + const int flags = (hit_surface) ? kernel_data_fetch(shaders, shader).flags : 0; if (!integrator_intersect_terminate(kg, state, flags)) { INTEGRATOR_PATH_NEXT(current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_VOLUME); @@ -223,7 +223,7 @@ ccl_device_forceinline void integrator_intersect_next_kernel( else { /* Hit a surface, continue with surface kernel unless terminated. */ const int shader = intersection_get_shader(kg, isect); - const int flags = kernel_tex_fetch(__shaders, shader).flags; + const int flags = kernel_data_fetch(shaders, shader).flags; if (!integrator_intersect_terminate(kg, state, flags)) { const int object_flags = intersection_get_object_flags(kg, isect); @@ -279,7 +279,7 @@ ccl_device_forceinline void integrator_intersect_next_kernel_after_volume( else { /* Hit a surface, continue with surface kernel unless terminated. */ const int shader = intersection_get_shader(kg, isect); - const int flags = kernel_tex_fetch(__shaders, shader).flags; + const int flags = kernel_data_fetch(shaders, shader).flags; const int object_flags = intersection_get_object_flags(kg, isect); const bool use_caustics = kernel_data.integrator.use_caustics && (object_flags & SD_OBJECT_CAUSTICS); @@ -332,7 +332,7 @@ ccl_device void integrator_intersect_closest(KernelGlobals kg, ray.t = kernel_data.integrator.ao_bounces_distance; if (last_isect_object != OBJECT_NONE) { - const float object_ao_distance = kernel_tex_fetch(__objects, last_isect_object).ao_distance; + const float object_ao_distance = kernel_data_fetch(objects, last_isect_object).ao_distance; if (object_ao_distance != 0.0f) { ray.t = object_ao_distance; } @@ -366,7 +366,7 @@ ccl_device void integrator_intersect_closest(KernelGlobals kg, bool from_caustic_caster = false; bool from_caustic_receiver = false; if (!(path_flag & PATH_RAY_CAMERA) && last_isect_object != OBJECT_NONE) { - const int object_flags = kernel_tex_fetch(__object_flag, last_isect_object); + const int object_flags = kernel_data_fetch(object_flag, last_isect_object); from_caustic_receiver = (object_flags & SD_OBJECT_CAUSTICS_RECEIVER); from_caustic_caster = (object_flags & SD_OBJECT_CAUSTICS_CASTER); } diff --git a/intern/cycles/kernel/integrator/mnee.h b/intern/cycles/kernel/integrator/mnee.h index ad83f82d091..75d30a0aeff 100644 --- a/intern/cycles/kernel/integrator/mnee.h +++ b/intern/cycles/kernel/integrator/mnee.h @@ -115,7 +115,7 @@ ccl_device_forceinline void mnee_update_light_sample(KernelGlobals kg, { /* correct light sample position/direction and pdf * NOTE: preserve pdf in area measure */ - const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, ls->lamp); + const ccl_global KernelLight *klight = &kernel_data_fetch(lights, ls->lamp); if (ls->type == LIGHT_POINT || ls->type == LIGHT_SPOT) { ls->D = normalize_len(ls->P - P, &ls->t); @@ -154,12 +154,12 @@ ccl_device_forceinline void mnee_setup_manifold_vertex(KernelGlobals kg, ccl_private const Intersection *isect, ccl_private ShaderData *sd_vtx) { - sd_vtx->object = (isect->object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, isect->prim) : + sd_vtx->object = (isect->object == OBJECT_NONE) ? kernel_data_fetch(prim_object, isect->prim) : isect->object; sd_vtx->type = isect->type; sd_vtx->flag = 0; - sd_vtx->object_flag = kernel_tex_fetch(__object_flag, sd_vtx->object); + sd_vtx->object_flag = kernel_data_fetch(object_flag, sd_vtx->object); /* Matrices and time. */ shader_setup_object_transforms(kg, sd_vtx, ray->time); @@ -171,7 +171,7 @@ ccl_device_forceinline void mnee_setup_manifold_vertex(KernelGlobals kg, sd_vtx->u = isect->u; sd_vtx->v = isect->v; - sd_vtx->shader = kernel_tex_fetch(__tri_shader, sd_vtx->prim); + sd_vtx->shader = kernel_data_fetch(tri_shader, sd_vtx->prim); float3 verts[3]; float3 normals[3]; @@ -509,7 +509,7 @@ ccl_device_forceinline bool mnee_newton_solver(KernelGlobals kg, break; int hit_object = (projection_isect.object == OBJECT_NONE) ? - kernel_tex_fetch(__prim_object, projection_isect.prim) : + kernel_data_fetch(prim_object, projection_isect.prim) : projection_isect.object; if (hit_object == mv.object) { @@ -870,7 +870,7 @@ ccl_device_forceinline bool mnee_path_contribution(KernelGlobals kg, probe_ray.D = normalize_len(v.p - probe_ray.P, &probe_ray.t); if (scene_intersect(kg, &probe_ray, PATH_RAY_TRANSMIT, &probe_isect)) { int hit_object = (probe_isect.object == OBJECT_NONE) ? - kernel_tex_fetch(__prim_object, probe_isect.prim) : + kernel_data_fetch(prim_object, probe_isect.prim) : probe_isect.object; /* Test whether the ray hit the appropriate object at its intended location. */ if (hit_object != v.object || fabsf(probe_ray.t - probe_isect.t) > MNEE_MIN_DISTANCE) diff --git a/intern/cycles/kernel/integrator/shade_background.h b/intern/cycles/kernel/integrator/shade_background.h index 72ecf67e8a0..4791a963ae6 100644 --- a/intern/cycles/kernel/integrator/shade_background.h +++ b/intern/cycles/kernel/integrator/shade_background.h @@ -107,7 +107,7 @@ ccl_device_inline void integrate_background(KernelGlobals kg, for (int lamp = 0; lamp < kernel_data.integrator.num_all_lights; lamp++) { /* This path should have been resolved with mnee, it will * generate a firefly for small lights since it is improbable. */ - const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, lamp); + const ccl_global KernelLight *klight = &kernel_data_fetch(lights, lamp); if (klight->type == LIGHT_BACKGROUND && klight->use_caustics) { eval_background = false; break; @@ -160,7 +160,7 @@ ccl_device_inline void integrate_distant_lights(KernelGlobals kg, if (INTEGRATOR_STATE(state, path, mnee) & PATH_MNEE_CULL_LIGHT_CONNECTION) { /* This path should have been resolved with mnee, it will * generate a firefly for small lights since it is improbable. */ - const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, lamp); + const ccl_global KernelLight *klight = &kernel_data_fetch(lights, lamp); if (klight->use_caustics) return; } diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index ce1398859b7..e0a7f998a3f 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -141,7 +141,7 @@ ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg, { if (ls.lamp != LAMP_NONE) { /* Is this a caustic light? */ - const bool use_caustics = kernel_tex_fetch(__lights, ls.lamp).use_caustics; + const bool use_caustics = kernel_data_fetch(lights, ls.lamp).use_caustics; if (use_caustics) { /* Are we on a caustic caster? */ if (is_transmission && (sd->object_flag & SD_OBJECT_CAUSTICS_CASTER)) diff --git a/intern/cycles/kernel/integrator/shader_eval.h b/intern/cycles/kernel/integrator/shader_eval.h index 4da92929366..ed4d973e864 100644 --- a/intern/cycles/kernel/integrator/shader_eval.h +++ b/intern/cycles/kernel/integrator/shader_eval.h @@ -528,12 +528,12 @@ ccl_device bool shader_constant_emission_eval(KernelGlobals kg, ccl_private float3 *eval) { int shader_index = shader & SHADER_MASK; - int shader_flag = kernel_tex_fetch(__shaders, shader_index).flags; + int shader_flag = kernel_data_fetch(shaders, shader_index).flags; if (shader_flag & SD_HAS_CONSTANT_EMISSION) { - *eval = make_float3(kernel_tex_fetch(__shaders, shader_index).constant_emission[0], - kernel_tex_fetch(__shaders, shader_index).constant_emission[1], - kernel_tex_fetch(__shaders, shader_index).constant_emission[2]); + *eval = make_float3(kernel_data_fetch(shaders, shader_index).constant_emission[0], + kernel_data_fetch(shaders, shader_index).constant_emission[1], + kernel_data_fetch(shaders, shader_index).constant_emission[2]); return true; } @@ -821,11 +821,11 @@ ccl_device_inline void shader_eval_volume(KernelGlobals kg, sd->shader = entry.shader; sd->flag &= ~SD_SHADER_FLAGS; - sd->flag |= kernel_tex_fetch(__shaders, (sd->shader & SHADER_MASK)).flags; + sd->flag |= kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).flags; sd->object_flag &= ~SD_OBJECT_FLAGS; if (sd->object != OBJECT_NONE) { - sd->object_flag |= kernel_tex_fetch(__object_flag, sd->object); + sd->object_flag |= kernel_data_fetch(object_flag, sd->object); # ifdef __OBJECT_MOTION__ /* todo: this is inefficient for motion blur, we should be @@ -837,7 +837,7 @@ ccl_device_inline void shader_eval_volume(KernelGlobals kg, kernel_assert(v_desc.offset != ATTR_STD_NOT_FOUND); const float3 P = sd->P; - const float velocity_scale = kernel_tex_fetch(__objects, sd->object).velocity_scale; + const float velocity_scale = kernel_data_fetch(objects, sd->object).velocity_scale; const float time_offset = kernel_data.cam.motion_position == MOTION_POSITION_CENTER ? 0.5f : 0.0f; @@ -946,7 +946,7 @@ ccl_device void shader_eval_displacement(KernelGlobals kg, ccl_device float shader_cryptomatte_id(KernelGlobals kg, int shader) { - return kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).cryptomatte_id; + return kernel_data_fetch(shaders, (shader & SHADER_MASK)).cryptomatte_id; } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/integrator/subsurface.h b/intern/cycles/kernel/integrator/subsurface.h index b449f807290..1e6fcf4aff0 100644 --- a/intern/cycles/kernel/integrator/subsurface.h +++ b/intern/cycles/kernel/integrator/subsurface.h @@ -147,7 +147,7 @@ ccl_device_inline bool subsurface_scatter(KernelGlobals kg, IntegratorState stat /* Update volume stack if needed. */ if (kernel_data.integrator.use_volumes) { const int object = ss_isect.hits[0].object; - const int object_flag = kernel_tex_fetch(__object_flag, object); + const int object_flag = kernel_data_fetch(object_flag, object); if (object_flag & SD_OBJECT_INTERSECTS_VOLUME) { float3 P = INTEGRATOR_STATE(state, ray, P); @@ -170,7 +170,7 @@ ccl_device_inline bool subsurface_scatter(KernelGlobals kg, IntegratorState stat INTEGRATOR_STATE_WRITE(state, path, rng_offset) += PRNG_BOUNCE_NUM; const int shader = intersection_get_shader(kg, &ss_isect.hits[0]); - const int shader_flags = kernel_tex_fetch(__shaders, shader).flags; + const int shader_flags = kernel_data_fetch(shaders, shader).flags; const int object_flags = intersection_get_object_flags(kg, &ss_isect.hits[0]); const bool use_caustics = kernel_data.integrator.use_caustics && (object_flags & SD_OBJECT_CAUSTICS); diff --git a/intern/cycles/kernel/integrator/subsurface_disk.h b/intern/cycles/kernel/integrator/subsurface_disk.h index 34330671748..ae857c50493 100644 --- a/intern/cycles/kernel/integrator/subsurface_disk.h +++ b/intern/cycles/kernel/integrator/subsurface_disk.h @@ -113,7 +113,7 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg, for (int hit = 0; hit < num_eval_hits; hit++) { /* Get geometric normal. */ const int object = ss_isect.hits[hit].object; - const int object_flag = kernel_tex_fetch(__object_flag, object); + const int object_flag = kernel_data_fetch(object_flag, object); float3 hit_Ng = ss_isect.Ng[hit]; if (path_flag & PATH_RAY_SUBSURFACE_BACKFACING) { hit_Ng = -hit_Ng; diff --git a/intern/cycles/kernel/integrator/volume_stack.h b/intern/cycles/kernel/integrator/volume_stack.h index 5256349a0cc..97a0f0f386c 100644 --- a/intern/cycles/kernel/integrator/volume_stack.h +++ b/intern/cycles/kernel/integrator/volume_stack.h @@ -133,7 +133,7 @@ ccl_device float volume_stack_step_size(KernelGlobals kg, StackReadOp stack_read break; } - int shader_flag = kernel_tex_fetch(__shaders, (entry.shader & SHADER_MASK)).flags; + int shader_flag = kernel_data_fetch(shaders, (entry.shader & SHADER_MASK)).flags; bool heterogeneous = false; @@ -146,7 +146,7 @@ ccl_device float volume_stack_step_size(KernelGlobals kg, StackReadOp stack_read * heterogeneous volume objects may be using the same shader. */ int object = entry.object; if (object != OBJECT_NONE) { - int object_flag = kernel_tex_fetch(__object_flag, object); + int object_flag = kernel_data_fetch(object_flag, object); if (object_flag & SD_OBJECT_HAS_VOLUME_ATTRIBUTES) { heterogeneous = true; } @@ -180,7 +180,7 @@ ccl_device VolumeSampleMethod volume_stack_sample_method(KernelGlobals kg, Integ break; } - int shader_flag = kernel_tex_fetch(__shaders, (entry.shader & SHADER_MASK)).flags; + int shader_flag = kernel_data_fetch(shaders, (entry.shader & SHADER_MASK)).flags; if (shader_flag & SD_VOLUME_MIS) { /* Multiple importance sampling. */ -- cgit v1.2.3