Cleanup: various cleanups in Cycles kernel #120714

Merged
Weizhen Huang merged 7 commits from weizhen/blender:cycles-cleanup into main 2024-04-17 18:49:15 +02:00
Member

mostly about unused parameters and code duplication. See individual commits for details.

mostly about unused parameters and code duplication. See individual commits for details.
Weizhen Huang added the
Module
Render & Cycles
label 2024-04-16 19:17:10 +02:00
Weizhen Huang added 1 commit 2024-04-16 19:17:19 +02:00
e6cfcfbd02 Cleanup: remove unused function parameters
This is not a complete list of all the unused parameters in kernel, but
those I touch often, so I am more confident that it's safe to delete them.
Weizhen Huang force-pushed cycles-cleanup from 6439f33848 to 981734fe3e 2024-04-16 19:26:54 +02:00 Compare
Weizhen Huang reviewed 2024-04-16 19:33:28 +02:00
@ -422,6 +420,13 @@ ccl_device_inline float light_sample_mis_weight_forward_surface(KernelGlobals kg
const uint32_t path_flag,
const ccl_private ShaderData *sd)
{
const bool has_mis = (sd->type & PRIMITIVE_TRIANGLE) && !(path_flag & PATH_RAY_MIS_SKIP) &&
Author
Member

I removed the # ifdef __HAIR__ case here. It should be fine to check (sd->type & PRIMITIVE_TRIANGLE) even when __HAIR__ is not defined?

I removed the `# ifdef __HAIR__` case here. It should be fine to check `(sd->type & PRIMITIVE_TRIANGLE)` even when `__HAIR__` is not defined?

Functionality-wise I think it is fine, but it could have a performance impact for feature-optimized Cycles kernels, as it is probably an extra fetch and extra comparison.

Functionality-wise I think it is fine, but it could have a performance impact for feature-optimized Cycles kernels, as it is probably an extra fetch and extra comparison.
weizhen marked this conversation as resolved
Author
Member

@blender-bot build +gpu

@blender-bot build +gpu
Weizhen Huang requested review from Sergey Sharybin 2024-04-16 21:17:50 +02:00
Weizhen Huang requested review from Brecht Van Lommel 2024-04-16 21:17:59 +02:00
Sergey Sharybin reviewed 2024-04-17 11:02:46 +02:00
@ -346,2 +330,2 @@
bsdf_eval_mul(&bsdf_eval, mis_weight);
}
const float mis_weight = light_sample_mis_weight_nee(kg, ls.pdf, bsdf_pdf);
bsdf_eval_mul(&bsdf_eval, light_eval / ls.pdf * mis_weight);

This seems to change behavior when direct_light_sampling_type is set to DIRECT_LIGHT_SAMPLING_FORWARD and the light shader is not using MIS. Not sure whether I am missing something, or whether it is in fact an expected change. If that is a change and it is expected, then it should be presented as something else than a refactor.

This seems to change behavior when `direct_light_sampling_type` is set to `DIRECT_LIGHT_SAMPLING_FORWARD` and the light shader is not using MIS. Not sure whether I am missing something, or whether it is in fact an expected change. If that is a change and it is expected, then it should be presented as something else than a refactor.
Author
Member

Ah, this is my oversight.

In main the logic of direct_light_sampling_type is that whichever option you set, it should converge to the same result. So even if you choose forward sampling and the light actually can't be forward sampled, the MIS weight would still be treated as 1.0f. I think this a more meaningful behavior than what I do here, because direct_light_sampling_type is usually used to check whether all three options give the same result.

I will revert to the old behavior.

Ah, this is my oversight. In main the logic of `direct_light_sampling_type` is that whichever option you set, it should converge to the same result. So even if you choose forward sampling and the light actually can't be forward sampled, the MIS weight would still be treated as 1.0f. I think this a more meaningful behavior than what I do here, because `direct_light_sampling_type` is usually used to check whether all three options give the same result. I will revert to the old behavior.
weizhen marked this conversation as resolved
@ -871,10 +866,7 @@ ccl_device_forceinline void integrate_volume_direct_light(
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput_phase;
/* Write Light-group, +1 as light-group is int but we need to encode into a uint8_t. */
INTEGRATOR_STATE_WRITE(

Is great to see this shenanigans about light groups are finally tackled!

Is great to see this shenanigans about light groups are finally tackled!
Sergey Sharybin approved these changes 2024-04-17 14:02:53 +02:00
Sergey Sharybin left a comment
Owner

Looks good to me!
I did not see quality regression on AMD Metal, and M2 Metal did not have any performance impact either.

Looks good to me! I did not see quality regression on AMD Metal, and M2 Metal did not have any performance impact either.
Brecht Van Lommel approved these changes 2024-04-17 17:55:13 +02:00
Weizhen Huang force-pushed cycles-cleanup from 30c4ccf3b2 to cbaf9e0eb8 2024-04-17 18:29:55 +02:00 Compare
Author
Member

@blender-bot build

@blender-bot build
Weizhen Huang merged commit 8e5840359f into main 2024-04-17 18:49:15 +02:00
Weizhen Huang deleted branch cycles-cleanup 2024-04-17 18:49:17 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120714
No description provided.