Realtime Compositor: Allow more result types #112414
No reviewers
Labels
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#112414
Loading…
Reference in New Issue
No description provided.
Delete Branch "OmarEmaraDev/blender:allow-more-result-types"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously, the Result class was reserved for inputs and outputs of
operations, so its allowed types were naturally those exposed to the
user. However, we now use the Result class internally for intermediate
results, so it now makes sense to expend the allowed types.
The types are now divided into two categories, those that are user
facing and need to be handled in implicit operations and those that are
internal can be exempt from such handling. Internal types are reserved
for texture results, as the single value mechanism is only there for
user facing results.
The patch merely adjusts the switch cases across the code base, adding
one new internal type as an example.
Generally looks fine.
Have a little comment about use of
default
which I try to avoid in own code. Use some common sense though, it might very well be that the places where it is used is not genetic enough (i.e. limited by the socket type of a specific node -- aka, purely user-facing things).Do not consider it as a stopper and if you believe the code as it is in the current PR is better that trying to do things explicitly please just go ahead and commit :)
@ -42,6 +44,9 @@ static Result detect_edges(Context &context,
GPU_shader_uniform_3fv(shader, "luminance_coefficients", luminance_coefficients);
break;
}
default:
Typically in such situations I try to avoid
default
as it helps a lot when new types are added and do an assert if none of the explicit cases matched. It might be easier to do if this piece of code is moved to own small function likeset_shader_luminance_coefficients
so that early return in place ofbreak
are possible.The reason for this is that if a new type is added in the future it is easier to see where its handling might be needed by utilizing compiler's warnings.
But if we don't have a default, we will always get such warnings:
This is the code I have:
Or should we add empty assert casses for
Int2
and other similar types with a comment that says why they aren't handled?But, again, it was more of a generic comment. To keep it practical we can say: if the items to be handled in the switch depends on the node configuration then the current
default
approach is cleaner and there is no need to make things more verbose than they should be. However, if the addition of a new data type requires update of thisswitch
statement then its better not to havedefault
branch. Hope it makes sense :)@ -26,0 +28,4 @@
case ResultType::Vector:
case ResultType::Color:
return "compositor_symmetric_separable_blur_color";
default:
Move the content outside of the
switch
.Thanks for the update! Makes more sense now. Also nice to see explicit comments about unexpected code paths in certain
case
branches!