WIP restore primary CST controls and defer main output; shader and Release build pass
这个提交包含在:
1 父节点
2cf93fafe5
当前提交
0b1b4454b4
16 个文件已更改
+130
-24
没有与搜索条件相匹配的文件
@@ -3634,12 +3634,12 @@
|
||||
],
|
||||
"sourceSHA256": {
|
||||
"template/tools/dump_model.mm": "04e04446aa351d774913bc25b06512fefe7969bdf4c6e471a91f1e9d6c4fc3b5",
|
||||
"大鱼调色/Plugin/DYCSTTypes.h": "3372e3cd77248eeb374e54675d2902befceea8e00a2afc4f9543116ef3027696",
|
||||
"大鱼调色/Plugin/DYCSTTypes.h": "ed5ba7e7ae35d1bba10e80a81184fa26b1f7eb582e47b2e45c3edd294889c76a",
|
||||
"大鱼调色/Plugin/DYColorManagement.h": "b0a4cd1b8c45dbce90a7b4f30f72ebf95ecd382895e74e3bfeda0f7cdb185157",
|
||||
"大鱼调色/Plugin/DYFilmMath.h": "945b7036c6aa6d27941a3bf96c4d70dec65a14b1747fba618e650738fa7108f0",
|
||||
"大鱼调色/Plugin/DYFilmTypes.h": "c35a43b5b93988e8517e5db8f281da0dfd1e02f5b0e7bfb62e7345cec444a36d",
|
||||
"大鱼调色/Plugin/DYManagedColor.h": "616c7919bf0889f767ebb68d4b37b775183451b213b8d2d979eeb293be69010c",
|
||||
"大鱼调色/Plugin/DYManagedColor.mm": "8c9276003ea75c21c8e631122fe9a910bac26b12db69c76e626ec2100a6cbfd1",
|
||||
"大鱼调色/Plugin/DYManagedColor.h": "227b9149cdc743b6e8908eda9cff648e0b9e366805d60689066b714a10e075b1",
|
||||
"大鱼调色/Plugin/DYManagedColor.mm": "dc045653448497cd3efa1ba0dced083db911d1a28f68d63eb332ceb37961ad53",
|
||||
"大鱼调色/Plugin/DYModel.h": "a28652bd53aa9e1d085af1108c344b5d673c5e1b3731531e1bb2982efeb8708c",
|
||||
"大鱼调色/Plugin/DYModel.mm": "29fea6064d3131119933401f554cc04e48cadf07d0c62f25b8d66795201396f8",
|
||||
"大鱼调色/Plugin/DYSpiderState.h": "0c80747e41e8fc97762e301b011bd08c18865a825eaafde086ed79ace37b22f9",
|
||||
|
||||
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
import argparse
|
||||
import subprocess
|
||||
from build_masked_kernel import masked_kernel
|
||||
from float_air_boundary import float_boundary
|
||||
|
||||
|
||||
def main():
|
||||
@@ -23,6 +24,10 @@ def main():
|
||||
generated = work / 'DYGradeMasked.ll'
|
||||
generated.write_text(masked_kernel(source.read_text()))
|
||||
source = generated
|
||||
if name in ('CSTKernel', 'BasisKernel'):
|
||||
generated = work / (name + 'Float.ll')
|
||||
generated.write_text(float_boundary(source.read_text(), name))
|
||||
source = generated
|
||||
subprocess.run(['xcrun', 'metal-opt', str(source),
|
||||
'-o', str(target)], check=True)
|
||||
objects.append(str(target))
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Add float boundary entry points; preserve all original AIR and arithmetic.
|
||||
|
||||
The recovered arithmetic already calculates in float. Only its sample entry and
|
||||
return were half. The new CST pipeline must not quantize every domain crossing.
|
||||
Legacy entry points remain byte-for-byte in the module and keep their behavior.
|
||||
"""
|
||||
import re
|
||||
|
||||
|
||||
def float_boundary(source, kind):
|
||||
name, size, first, rgb, tag = {
|
||||
'CSTKernel': ('cst', '9CSTParams', (7, 8), 2040, 6),
|
||||
'BasisKernel': ('basis', '11BasisParams', (8, 9), 247, 8),
|
||||
}[kind]
|
||||
old = f'_Z{len(name)+4}{name}_airDv4_DhRU11MTLconstantK{size}'
|
||||
new_name = name + '_float_air'
|
||||
new = f'_Z{len(new_name)}{new_name}Dv4_fRU11MTLconstantK{size}'
|
||||
match = re.search(r'define <4 x float> @' + re.escape(old) + r'\(.*?\n}', source, re.S)
|
||||
assert match, 'Versioned AIR entry changed; review the boundary adapter'
|
||||
function = match.group().replace(old, new, 1).replace('<4 x half> noundef %sample', '<4 x float> noundef %sample', 1)
|
||||
entry = (f' %v{first[0]} = shufflevector <4 x half> %sample, <4 x half> poison, <3 x i32> <i32 0, i32 1, i32 2>\n'
|
||||
f' %v{first[1]} = tail call fast <3 x float> @air.convert.f.v3f32.f.v3f16(<3 x half> %v{first[0]}) #{tag}')
|
||||
assert function.count(entry) == 1
|
||||
function = function.replace(entry, f' %v{first[1]} = shufflevector <4 x float> %sample, <4 x float> poison, <3 x i32> <i32 0, i32 1, i32 2>')
|
||||
exit = (f' %v{rgb+1} = tail call fast <3 x half> @air.convert.f.v3f16.f.v3f32(<3 x float> %v{rgb}) #{tag}\n'
|
||||
f' %v{rgb+2} = shufflevector <3 x half> %v{rgb+1}, <3 x half> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>\n'
|
||||
f' %v{rgb+3} = shufflevector <4 x half> %v{rgb+2}, <4 x half> %sample, <4 x i32> <i32 0, i32 1, i32 2, i32 7>\n'
|
||||
f' %v{rgb+4} = tail call fast <4 x float> @air.convert.f.v4f32.f.v4f16(<4 x half> %v{rgb+3}) #{tag}\n'
|
||||
f' ret <4 x float> %v{rgb+4}')
|
||||
assert function.count(exit) == 1
|
||||
function = function.replace(exit, f' %dayuRGB = shufflevector <3 x float> %v{rgb}, <3 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>\n %dayuRGBA = shufflevector <4 x float> %dayuRGB, <4 x float> %sample, <4 x i32> <i32 0, i32 1, i32 2, i32 7>\n ret <4 x float> %dayuRGBA')
|
||||
return source[:match.end()] + '\n\n; Dayu float boundary, arithmetic unchanged.\n' + function + source[match.end():]
|
||||
@@ -21,6 +21,8 @@ typedef struct DayuRenderParams {
|
||||
CSTParams basisInput;
|
||||
CSTParams basisOutput;
|
||||
} DayuRenderParams;
|
||||
// New pipeline only; the original parameter and uniform layouts stay fixed.
|
||||
typedef struct DYCSTMixParams { CSTParams toLinear, fromLinear; float amount; } DYCSTMixParams;
|
||||
#ifndef __METAL_VERSION__
|
||||
_Static_assert(sizeof(CSTParams)==20, "CST target layout");
|
||||
_Static_assert(sizeof(BasisParams)==80, "BASIS target layout");
|
||||
|
||||
@@ -326,3 +326,4 @@ fragment half4 dyToolCopyFragment(DYRaster in [[stage_in]],texture2d<half> sourc
|
||||
|
||||
#include "DYFilmKernels.inc.h"
|
||||
#include "DYManagedKernels.inc.h"
|
||||
#include "DYPrimaryKernels.inc.h"
|
||||
@@ -691,7 +691,7 @@ static NSImage *DYWheelImage(void) {
|
||||
if([row.identifier isEqual:@"toolMasks"])return [(DYToolMaskPanel*)row contentHeight]>0;
|
||||
NSString *key=row.identifier?:@"";NSInteger tab=[_tabs[section]integerValue];
|
||||
if(!_embedded&&[section isEqual:@"base"]&&[key isEqual:@"skinEnabled"])for(NSDictionary *card in _cards)if([card[@"section"][@"key"]isEqual:@"skin"])return ![card[@"removed"]boolValue];
|
||||
if([key isEqual:@"legacyInput"])return ![_tabs[@"managedColor"]boolValue]&&[_tabs[@"legacyInput"]boolValue];
|
||||
if([key isEqual:@"legacyInput"])return ![_tabs[@"primaryCMS"]boolValue]&&![_tabs[@"managedColor"]boolValue]&&[_tabs[@"legacyInput"]boolValue];
|
||||
if([section isEqual:@"primary"]&&[_tabs[@"managedColor"]boolValue]){if([@[@"heading:input",@"heading:output"]containsObject:key])return NO;if([key isEqual:@"cmmix"])return YES;for(NSDictionary*d in DYDescriptors())if([d[@"key"]isEqual:key]&&d[@"cmTab"]&&[d[@"cmTab"]integerValue]!=1)return NO;}
|
||||
if([section isEqual:@"curve"] && ![key isEqual:@"curveGraph"])return NO;
|
||||
if([section isEqual:@"hsl"]) {
|
||||
@@ -810,8 +810,8 @@ static NSImage *DYWheelImage(void) {
|
||||
[(DYMaskCountBadge*)card[@"maskBadge"]setCount:count];NSString *hint=count?[NSString stringWithFormat:@"已有 %lu 个蒙版;点击添加独立蒙版",(unsigned long)count]:@"添加本工具的独立蒙版";
|
||||
[card[@"maskButton"]setToolTip:hint];[card[@"maskButton"]setAccessibilityHelp:hint];
|
||||
}
|
||||
DYAssetState *assets=DYReadAssets(_manager,t);_tabs[@"managedColor"]=@((_embedded?DYReadAssets([(DYToolManager*)_manager host],t).colorManagement:assets.colorManagement).count>0);[_managedPanel refreshWithState:assets.colorManagement context:[_renderer colorContext]];[_managedPanel setInputLUTPath:assets.paths[@"input"]];for(NSDictionary *r in _controls.allValues)if([r[@"descriptor"][@"key"]isEqual:@"cmmix"])[r[@"label"]setStringValue:[_tabs[@"managedColor"]boolValue]?@"调色混合":@"CST 混合"];
|
||||
if([_tabs[@"managedColor"]boolValue])for(NSDictionary *c in _cards)if([c[@"section"][@"key"]isEqual:@"primary"]){[c[@"enabled"]setToolTip:@"启停此层一级调色;全局色彩管理保持当前方式"];[c[@"enabled"]setAccessibilityHelp:[c[@"enabled"]toolTip]];}
|
||||
DYAssetState *assets=DYReadAssets(_manager,t);NSDictionary *cms=_embedded?DYReadAssets([(DYToolManager*)_manager host],t).colorManagement:assets.colorManagement;_tabs[@"managedColor"]=@(cms.count>0&&!DYPrimaryColorState(cms));_tabs[@"primaryCMS"]=@(DYPrimaryColorState(cms));[_managedPanel refreshWithState:assets.colorManagement context:[_renderer colorContext]];[_managedPanel setInputLUTPath:assets.paths[@"input"]];for(NSDictionary *r in _controls.allValues)if([r[@"descriptor"][@"key"]isEqual:@"cmmix"])[r[@"label"]setStringValue:([_tabs[@"managedColor"]boolValue]||[_tabs[@"primaryCMS"]boolValue])?@"调色混合":@"CST 混合"];
|
||||
for(NSDictionary *c in _cards)if([c[@"section"][@"key"]isEqual:@"primary"]){[c[@"enabled"]setToolTip:[_tabs[@"managedColor"]boolValue]?@"启停此层一级调色;全局色彩管理保持当前方式":@"启停此层输入、一级调色与输出转换"];[c[@"enabled"]setAccessibilityHelp:[c[@"enabled"]toolTip]];}
|
||||
[_spiderPanel setMesh:assets.spiderMesh linked:assets.spiderLinked];
|
||||
double profile=0,configured=0;[get getFloatValue:&profile fromParameter:2013 atTime:t];[get getFloatValue:&configured fromParameter:2236 atTime:t];
|
||||
DYInspectorToken *oldToken=nil;[get getCustomParameterValue:&oldToken fromParameter:DYInspectorParameterID atTime:t];
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
// Separate authoring state; absent state always selects the unchanged v1 renderer.
|
||||
FOUNDATION_EXPORT NSDictionary *DYManagedColorDefaults(void);
|
||||
FOUNDATION_EXPORT NSDictionary *DYPrimaryColorDefaults(void);
|
||||
FOUNDATION_EXPORT BOOL DYPrimaryColorState(NSDictionary *state);
|
||||
FOUNDATION_EXPORT void DYSeedPrimaryWorkingSpace(NSMutableDictionary *node,float transfer,float gamut);
|
||||
FOUNDATION_EXPORT BOOL DYManagedColorValid(id state,NSError **error);
|
||||
FOUNDATION_EXPORT NSArray<NSDictionary*> *DYManagedInputSpaces(void);
|
||||
FOUNDATION_EXPORT NSArray<NSDictionary*> *DYManagedOutputSpaces(void);
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <cmath>
|
||||
NSDictionary *DYManagedColorDefaults(void){return @{@"version":@2,@"mode":@1,@"input":@109,@"output":@1,@"gamutCompression":@YES,@"engine":@"OpenColorIO-2.5.2",@"config":@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"};}
|
||||
NSDictionary *DYPrimaryColorDefaults(void){return @{@"version":@3,@"mode":@4,@"engine":@"Dayu-CST-f32",@"config":@"primary-parameters-v1"};}
|
||||
BOOL DYPrimaryColorState(NSDictionary *s){return [s isKindOfClass:NSDictionary.class]&&[s[@"version"]isEqual:@3]&&[s[@"mode"]isEqual:@4];}
|
||||
void DYSeedPrimaryWorkingSpace(NSMutableDictionary *node,float transfer,float gamut){if(![node[@"type"]isEqual:@"primary"])return;NSMutableDictionary*v=node[@"values"];for(NSString *part in @[@"input",@"working",@"output"]){NSString*t=[NSString stringWithFormat:@"cm%@Transfer",part],*g=[NSString stringWithFormat:@"cm%@Gamut",part];if(!v[t])v[t]=@(transfer);if(!v[g])v[g]=@(gamut);}}
|
||||
NSArray<NSDictionary*> *DYManagedInputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::spaces())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;}
|
||||
NSArray<NSDictionary*> *DYManagedOutputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::outputs())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;}
|
||||
BOOL DYManagedColorValid(id state,NSError **error){
|
||||
if(DYPrimaryColorState(state)){BOOL valid=[state isEqual:DYPrimaryColorDefaults()];if(!valid&&error)*error=[NSError errorWithDomain:@"com.dayu.color.cms" code:1 userInfo:@{NSLocalizedDescriptionKey:@"一级 CST 设置版本不匹配。"}];return valid;}
|
||||
BOOL valid=[state isKindOfClass:NSDictionary.class]&&[state count]==7&&[state[@"version"]isEqual:@2]&&[state[@"engine"]isEqual:@"OpenColorIO-2.5.2"]&&[state[@"config"]isEqual:@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"];
|
||||
for(NSString *key in @[@"mode",@"input",@"output",@"gamutCompression"]){id v=[state isKindOfClass:NSDictionary.class]?state[key]:nil;double n=[v isKindOfClass:NSNumber.class]?[v doubleValue]:NAN;valid&=std::isfinite(n)&&n==floor(n);}
|
||||
if(valid){valid=[@[@1,@2,@3]containsObject:state[@"mode"]]&&[@[@0,@1]containsObject:state[@"gamutCompression"]];BOOL input=NO,output=NO;for(NSDictionary *s in DYManagedInputSpaces())input|=[s[@"id"]isEqual:state[@"input"]];for(NSDictionary *s in DYManagedOutputSpaces())output|=[s[@"id"]isEqual:state[@"output"]];valid&=input&&output;}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#import "DYModel.h"
|
||||
#import "DYRenderer.h"
|
||||
#import "DYTheme.h"
|
||||
#import "DYToolState.h"
|
||||
@protocol DYManagedAssetTarget <NSObject>
|
||||
- (NSProgress*)setAssetPath:(NSString*)path forKey:(NSString*)key completion:(void(^)(NSError*))completion;
|
||||
@end
|
||||
@@ -12,11 +13,11 @@
|
||||
NSDictionary *_state;NSString *_inputLUTPath;NSUInteger _selectionGeneration;BOOL _refreshing;
|
||||
}
|
||||
- (BOOL)isFlipped{return YES;}
|
||||
- (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?112:m==1?190:302;}
|
||||
- (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?112:(m==1||m==4)?204:302;}
|
||||
static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabelWithString:s];l.font=[NSFont systemFontOfSize:11];l.textColor=DYThemeColor(@"text");return l;}
|
||||
- (instancetype)initWithManager:(id<PROAPIAccessing>)m renderer:(DYRenderer*)r assetTarget:(id)target {
|
||||
if((self=[super initWithFrame:NSZeroRect])){_manager=m;_renderer=[r retain];_assetTarget=target;self.identifier=@"managedColor";
|
||||
_mode=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"色彩管理 · 旧版兼容",@"色彩管理 · 跟随 FCP",@"相机编码 → ACES",@"输入 LUT → ACES"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式";
|
||||
_mode=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"一级 CST · 原有流程",@"1.8 兼容 · 跟随 FCP",@"1.8 兼容 · 相机 → ACES",@"1.8 兼容 · LUT → ACES",@"一级 CST · 延后输出(推荐)"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式";
|
||||
_inputLabel=[cmsLabel(@"输入空间")retain];_outputLabel=[cmsLabel(@"输出目标")retain];
|
||||
_input=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedInputSpaces()){[_input addItemWithTitle:s[@"name"]];_input.lastItem.representedObject=s[@"id"];} _input.target=self;_input.action=@selector(settingsChanged:);_input.accessibilityLabel=@"新版输入空间";
|
||||
_output=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedOutputSpaces()){[_output addItemWithTitle:s[@"name"]];_output.lastItem.representedObject=s[@"id"];} _output.target=self;_output.action=@selector(settingsChanged:);_output.accessibilityLabel=@"新版输出目标";
|
||||
@@ -27,25 +28,25 @@ static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabe
|
||||
}return self;
|
||||
}
|
||||
- (void)dealloc{[_renderer release];[_state release];[_inputLUTPath release];for(id v in @[_mode,_input,_output,_gamut,_lut,_inputLabel,_outputLabel,_help,_context])[v release];[super dealloc];}
|
||||
- (void)layout{[super layout];CGFloat w=self.bounds.size.width;_mode.frame=NSMakeRect(0,3,w,26);_inputLabel.frame=NSMakeRect(2,36,70,22);_input.frame=NSMakeRect(72,32,w-72,26);_outputLabel.frame=NSMakeRect(2,67,70,22);_output.frame=NSMakeRect(72,63,w-72,26);_gamut.frame=NSMakeRect(0,94,w,22);_lut.frame=NSMakeRect(0,120,w,25);_help.frame=NSMakeRect(2,152,w-4,96);_context.frame=NSMakeRect(2,252,w-4,47);if([_state[@"mode"]integerValue]<2){_help.frame=NSMakeRect(2,36,w-4,90);_context.frame=NSMakeRect(2,132,w-4,54);}}
|
||||
- (void)layout{[super layout];CGFloat w=self.bounds.size.width;_mode.frame=NSMakeRect(0,3,w,26);_inputLabel.frame=NSMakeRect(2,36,70,22);_input.frame=NSMakeRect(72,32,w-72,26);_outputLabel.frame=NSMakeRect(2,67,70,22);_output.frame=NSMakeRect(72,63,w-72,26);_gamut.frame=NSMakeRect(0,94,w,22);_lut.frame=NSMakeRect(0,120,w,25);_help.frame=NSMakeRect(2,152,w-4,96);_context.frame=NSMakeRect(2,252,w-4,47);if([_state[@"mode"]integerValue]<2||DYPrimaryColorState(_state)){_help.frame=NSMakeRect(2,36,w-4,104);_context.frame=NSMakeRect(2,144,w-4,54);}}
|
||||
- (void)refreshWithState:(NSDictionary*)s context:(NSDictionary*)context {
|
||||
_refreshing=YES;NSDictionary *saved=[s copy];[_state release];_state=saved;NSInteger mode=s.count?[s[@"mode"]integerValue]:0;[_mode selectItemAtIndex:mode];
|
||||
NSDictionary *values=s.count?s:DYManagedColorDefaults();for(NSMenuItem*i in _input.itemArray)if([i.representedObject isEqual:values[@"input"]])[_input selectItem:i];for(NSMenuItem*i in _output.itemArray)if([i.representedObject isEqual:values[@"output"]])[_output selectItem:i];
|
||||
_input.hidden=_inputLabel.hidden=_output.hidden=_outputLabel.hidden=_gamut.hidden=mode<2;_context.hidden=mode==0;_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标";
|
||||
_help.stringValue=mode==0?@"保留当前工程的原有颜色。选择新版后,一级层在 ACEScct 中调色,印片位于输出之前;可撤销或切回兼容方式。":mode==1?@"按宿主实际空间处理,不重复还原或映射。顺序:一级层 → 印片 → SDR 修饰。Rec.2020 宿主暂限一级与印片。":mode==2?@"按所选相机编码解释兼容码值。请确认上游未还原、未自动符合;选择准确输入与输出目标。PQ/HLG 仅支持一级与印片,其他工具用于 SDR。":@"使用输入 LUT,并按“LUT 输出”解释其结果;再进入 ACEScct 和所选输出变换。";
|
||||
_context.stringValue=context.count?[NSString stringWithFormat:@"%@ → ACEScct → %@",context[@"source"]?:@"未知",context[@"destination"]?:@"未知"]:@"宿主颜色信息将在渲染后显示。";_refreshing=NO;[self setNeedsLayout:YES];
|
||||
NSDictionary *values=s.count&&!DYPrimaryColorState(s)?s:DYManagedColorDefaults();for(NSMenuItem*i in _input.itemArray)if([i.representedObject isEqual:values[@"input"]])[_input selectItem:i];for(NSMenuItem*i in _output.itemArray)if([i.representedObject isEqual:values[@"output"]])[_output selectItem:i];
|
||||
_input.hidden=_inputLabel.hidden=_output.hidden=_outputLabel.hidden=_gamut.hidden=mode<2||mode==4;_context.hidden=mode==0;_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标";
|
||||
_help.stringValue=mode==4?@"输入、工作空间及输出均使用下面的一级 CST 设置。一级与印片完成后才执行主输出;其余工具为输出后的 SDR 修饰。请核对上游相机 LUT 与颜色符合,插件无法恢复上游已裁切的信息。":mode==0?@"保留原有处理顺序。选择“延后输出”后,使用一级 CST 的输入和工作空间,在一级与印片之后执行主输出。":mode==1?@"保留 1.8.0 的固定 ACEScct 流程,一级 CST 转换由全局管理接管。宿主已还原的画面无法重新获得原始 Log 信息。":mode==2?@"按所选相机编码解释兼容码值。请确认上游未还原、未自动符合;选择准确输入与输出目标。PQ/HLG 仅支持一级与印片,其他工具用于 SDR。":@"使用输入 LUT,并按“LUT 输出”解释其结果;再进入 ACEScct 和所选输出变换。";
|
||||
_context.stringValue=mode==4?@"码值载体 → 一级输入 CST → 所选工作域调色与印片 → 一级输出 CST → 宿主":context.count?[NSString stringWithFormat:@"%@ → ACEScct → %@",context[@"source"]?:@"未知",context[@"destination"]?:@"未知"]:@"宿主颜色信息将在渲染后显示。";_refreshing=NO;[self setNeedsLayout:YES];
|
||||
}
|
||||
- (void)setInputLUTPath:(NSString*)path{NSString *saved=[path copy];[_inputLUTPath release];_inputLUTPath=saved;_lut.title=path.length?path.lastPathComponent:@"选择输入 LUT…";_lut.toolTip=path.length?path:@"选择 LUT,并准确指定其输出编码";_lut.accessibilityLabel=path.length?[@"输入 LUT:" stringByAppendingString:path.lastPathComponent]:@"选择输入 LUT";}
|
||||
- (void)refreshContext{[self refreshWithState:_state context:[_renderer colorContext]];}
|
||||
- (void)writeState:(NSDictionary*)state {
|
||||
if(state&&!DYManagedColorValid(state,nil))return;id<FxCustomParameterActionAPI_v4>a=[_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{id<FxUndoAPI>undo=[_manager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"更改色彩管理方式"];DYAssetState*assets=[[DYReadAssets(_manager,a.currentTime)copy]autorelease];assets.colorManagement=state;DYWriteAssets(_manager,assets,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[_renderer invalidatePreview];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_manager];
|
||||
if(state&&!DYManagedColorValid(state,nil))return;id<FxCustomParameterActionAPI_v4>a=[_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{id<FxUndoAPI>undo=[_manager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"更改色彩管理方式"];DYAssetState*assets=[[DYReadAssets(_manager,a.currentTime)copy]autorelease];assets.colorManagement=state;DYWriteAssets(_manager,assets,a.currentTime);if(DYPrimaryColorState(state)&&!DYPrimaryColorState(_state)){DYUniforms u;DYReadUniforms(_manager,a.currentTime,&u);NSMutableDictionary*doc=DYMutablePlist(DYReadTools(_manager,a.currentTime).document);for(NSMutableDictionary*node in doc[@"layers"])DYSeedPrimaryWorkingSpace(node,u.cm.workingTransfer,u.cm.workingGamut);DYWriteTools(_manager,doc,a.currentTime);}[undo endUndoGroup];}@finally{[a endAction:self];}[_renderer invalidatePreview];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_manager];
|
||||
}
|
||||
- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;_selectionGeneration++;if(mode==3&&(!_inputLUTPath.length||![NSFileManager.defaultManager fileExistsAtPath:_inputLUTPath])){[self refreshWithState:_state context:[_renderer colorContext]];[self selectInputLUTAndEnable:YES];return;}if(!mode){[self writeState:nil];return;}NSMutableDictionary *s=[[_state?:DYManagedColorDefaults() mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];}
|
||||
- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;_selectionGeneration++;if(mode==3&&(!_inputLUTPath.length||![NSFileManager.defaultManager fileExistsAtPath:_inputLUTPath])){[self refreshWithState:_state context:[_renderer colorContext]];[self selectInputLUTAndEnable:YES];return;}if(!mode){[self writeState:nil];return;}if(mode==4){[self writeState:DYPrimaryColorDefaults()];return;}NSMutableDictionary *s=[[(_state&&!DYPrimaryColorState(_state)?_state:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];}
|
||||
- (void)settingsChanged:(id)sender {if(_refreshing||!_state)return;NSMutableDictionary*s=[[_state mutableCopy]autorelease];s[@"input"]=_input.selectedItem.representedObject;s[@"output"]=_output.selectedItem.representedObject;s[@"gamutCompression"]=@(_gamut.state==NSControlStateValueOn);[self writeState:s];}
|
||||
- (void)selectInputLUTAndEnable:(BOOL)enable {
|
||||
NSUInteger generation=_selectionGeneration;NSOpenPanel *panel=[NSOpenPanel openPanel];panel.allowedFileTypes=@[@"cube"];panel.allowsMultipleSelection=NO;panel.canChooseDirectories=NO;panel.message=@"选择输入 LUT,再指定 LUT 的输出编码";
|
||||
if([panel runModal]!=NSModalResponseOK||!self.window)return;
|
||||
[(id<DYManagedAssetTarget>)_assetTarget setAssetPath:panel.URL.path forKey:@"input" completion:^(NSError *error){if(error||!enable||!self.window||generation!=_selectionGeneration)return;NSMutableDictionary *s=[[(_state?:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@3;[self writeState:s];}];
|
||||
[(id<DYManagedAssetTarget>)_assetTarget setAssetPath:panel.URL.path forKey:@"input" completion:^(NSError *error){if(error||!enable||!self.window||generation!=_selectionGeneration)return;NSMutableDictionary *s=[[(_state&&!DYPrimaryColorState(_state)?_state:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@3;[self writeState:s];}];
|
||||
}
|
||||
- (void)chooseLUT:(id)sender {[self selectInputLUTAndEnable:NO];}
|
||||
@end
|
||||
@@ -29,6 +29,7 @@
|
||||
NSDictionary*context=DYHostColorContext(src,dst,primaries);@synchronized(_previewLock){[_colorContext release];_colorContext=[context copy];}
|
||||
if(!state.count)return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools error:error];
|
||||
if(!DYManagedColorValid(state,error))return NO;if(!tools)tools=@{@"schema":@2,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"调色层或蒙版数据无效。");
|
||||
if(DYPrimaryColorState(state))return [self renderPrimarySource:src destination:dst uniforms:u paths:paths spider:spider tools:tools hostPrimaries:primaries error:error];
|
||||
NSMutableDictionary*entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;id<MTLDevice>d=entry[@"device"];id<MTLTexture>source=[src metalTextureForDevice:d];if(!source)return fail(error,@"色彩管理输入纹理不可用。");
|
||||
uint64_t pixels=uint64_t(source.width)*source.height;if(!pixels||pixels>64ull*1024*1024||pixels*16*8>MAX(768ull*1024*1024,MIN(2ull*1024*1024*1024,d.recommendedMaxWorkingSetSize/2)))return fail(error,@"当前画面超过色彩管理内存预算。");
|
||||
CGColorSpaceRef srcSpace=DYManagedTileSpace(src,primaries),dstSpace=DYManagedTileSpace(dst,primaries),aces=CGColorSpaceCreateWithName(kCGColorSpaceACESCGLinear),linear709=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// V3 uses the user's declared working encoding, never a hardcoded display space.
|
||||
float4 cst_float_air(float4 sample, constant CSTParams& params);
|
||||
float4 basis_float_air(float4 sample, constant BasisParams& params);
|
||||
constant CSTParams dyPrimaryAP1To709={2,20,22,20,0};
|
||||
kernel void dyPrimaryCST(texture2d<float,access::read> a [[texture(0)]],texture2d<float,access::write> b [[texture(1)]],constant CSTParams& p [[buffer(0)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0)c.rgb=cst_float_air(float4(c.rgb/c.a,1),p).rgb*c.a;b.write(c,xy);
|
||||
}
|
||||
kernel void dyPrimaryGrade(texture2d<float,access::read> a [[texture(0)]],texture2d<float,access::write> b [[texture(1)]],constant DayuRenderParams& p [[buffer(0)]],constant CSTParams& back [[buffer(1)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0){float4 v=float4(c.rgb/c.a,1);if(p.stages&1)v=cst_float_air(v,p.input);if(p.stages&2){if(p.reserved&8)v=cst_float_air(v,p.basisInput);v=basis_float_air(v,p.basis);if(p.reserved&8)v=cst_float_air(v,p.basisOutput);}if(p.stages&4)v=cst_float_air(v,p.output);v=cst_float_air(v,back);c.rgb=v.rgb*c.a;}b.write(c,xy);
|
||||
}
|
||||
kernel void dyPrimaryBlend(texture2d<float,access::read> before [[texture(0)]],texture2d<float,access::read> after [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant DYCSTMixParams& p [[buffer(2)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(output.get_width(),output.get_height())))return;float4 a=before.read(xy),b=after.read(xy);if(!(a.a>0)||!(b.a>0)){output.write(a,xy);return;}float3 ac=cst_float_air(float4(a.rgb/a.a,1),p.toLinear).rgb,bc=cst_float_air(float4(b.rgb/b.a,1),p.toLinear).rgb;
|
||||
float2 uv=(float2(xy)+.5f)/float2(output.get_width(),output.get_height());float w=p.amount;if(h.count)w*=dyToolCoverage(uv,dyToolEncode(cst_float_air(float4(ac,1),dyPrimaryAP1To709).rgb),masks,h,h.section);
|
||||
if(w<=0){output.write(a,xy);return;}if(w>=1){output.write(b,xy);return;}output.write(float4(cst_float_air(float4(mix(ac,bc,w),1),p.fromLinear).rgb*a.a,a.a),xy);
|
||||
}
|
||||
kernel void dyPrimaryCodeOutput(texture2d<float,access::read> a [[texture(0)]],texture2d<float,access::write> b [[texture(1)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0)c.rgb=dyDecode(c.rgb/c.a)*c.a;b.write(c,xy);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Opt-in V3. The root primary owns input/working/output; V1/V2 stay frozen.
|
||||
- (BOOL)renderPrimarySource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools hostPrimaries:(NSInteger)primaries error:(NSError**)error {
|
||||
NSMutableDictionary*entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;id<MTLDevice>d=entry[@"device"];id<MTLTexture>source=[src metalTextureForDevice:d];if(!source)return fail(error,@"一级 CST 输入纹理不可用。");
|
||||
uint64_t pixels=uint64_t(source.width)*source.height;if(!pixels||pixels>64ull*1024*1024||pixels*16*8>MAX(768ull*1024*1024,MIN(2ull*1024*1024*1024,d.recommendedMaxWorkingSetSize/2)))return fail(error,@"当前画面超过一级 CST 内存预算。");
|
||||
DYApplyRemovedBaseTools(&u,tools);BOOL root=u.primarySectionEnabled>.5;int wt=lroundf(u.cm.workingTransfer),wg=lroundf(u.cm.workingGamut);
|
||||
NSMutableArray*pool=[NSMutableArray array];NSMutableSet*pinned=[NSMutableSet set];id<MTLTexture>current=nil;
|
||||
auto next=[&]()->id<MTLTexture>{for(id<MTLTexture>t in pool)if(t!=current&&![pinned containsObject:t])return t;MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:source.width height:source.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;id<MTLTexture>t=[d newTextureWithDescriptor:td];if(t){[pool addObject:t];[t release];}return t;};
|
||||
auto dispatch=[&](NSString*name,const void*params,NSUInteger length,const void*extra=nullptr,NSUInteger extraLength=0){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配一级 CST 缓冲区。");BOOL ok=[self managedDispatch:name textures:@[current,out] data:params length:length extra:extra extraLength:extraLength entry:entry error:error];if(ok)current=out;return ok;};
|
||||
auto transform=[&](CSTParams p){if(p.inputTransfer==p.outputTransfer&&p.inputGamut==p.outputGamut&&!p.toneMapping)return YES;return dispatch(@"dyPrimaryCST",&p,sizeof(p));};
|
||||
auto tile=[&](id<MTLTexture>t){DYExportTile*v=[[[DYExportTile alloc]initWithTexture:t registry:d.registryID]autorelease];[v setBounds:src.tilePixelBounds origin:src.imageOrigin];[v setPixelAspect:src.pixelAspect];return v;};
|
||||
auto blend=[&](id<MTLTexture>before,NSArray*masks,float amount,NSString*type){if(!masks.count&&amount>=1)return YES;id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配一级混合缓冲区。");DYToolMaskHeader h{};id<MTLBuffer>mb=[self maskBuffer:@{type:masks?:@[]} tile:src device:d header:&h];h.section=(int)[DYToolTypes()indexOfObject:type];DYCSTMixParams p={{wg,wt,2,20,0},{2,20,wg,wt,0},amount};id<MTLComputePipelineState>pipeline=[self managedKernel:@"dyPrimaryBlend" entry:entry error:error];if(!pipeline||!mb)return NO;id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:pipeline];[ce setTexture:before atIndex:0];[ce setTexture:current atIndex:1];[ce setTexture:out atIndex:2];[ce setBuffer:mb offset:0 atIndex:0];[ce setBytes:&h length:sizeof(h) atIndex:1];[ce setBytes:&p length:sizeof(p) atIndex:2];[ce dispatchThreads:MTLSizeMake(source.width,source.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);current=out;return YES;};
|
||||
auto grade=[&](DYUniforms values,NSArray*masks,BOOL local){if(values.primarySectionEnabled<.5||values.cm.mix<=0)return YES;DYUniforms neutral=values;neutral.inputSectionEnabled=neutral.cm.outputEnabled=0;BOOL gradeNeutral=identityCM(neutral);if(!local&&gradeNeutral)return YES;if(local&&identityCM(values))return YES;
|
||||
DayuRenderParams p=DYCMRender(values.cm);p.input.toneMapping=0;CSTParams back={wg,wt,wg,wt,0};
|
||||
if(local){p.stages=(values.inputSectionEnabled>.5?1:0)|(gradeNeutral?0:2)|(values.cm.outputEnabled>.5?4:0);back={values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputGamut):(int)lroundf(values.cm.workingGamut),values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputTransfer):(int)lroundf(values.cm.workingTransfer),wg,wt,0};}
|
||||
else{p.stages=2;}
|
||||
id<MTLTexture>before=current;[pinned addObject:before];BOOL ok=dispatch(@"dyPrimaryGrade",&p,sizeof(p),&back,sizeof(back));if(ok)ok=blend(before,masks,values.cm.mix,@"primary");[pinned removeObject:before];return ok;
|
||||
};
|
||||
auto print=[&](DYUniforms values,NSArray*masks){if(!DYFilmPrintActive(values))return YES;NSArray*names=@[@"",@"kodak_2383",@"kodak_2393",@"kodak_2302_bw",@"fuji_3510",@"fuji_3513",@"fuji_3519",@"fuji_3521",@"agfa_cp30"];NSString*path=[[NSBundle bundleForClass:self.class]pathForResource:names[(int)values.filmPrint.x] ofType:@"dylut" inDirectory:@"PrintLooks"];id<MTLTexture>cube=path?[self lut:path entry:entry error:error]:nil;if(!cube)return fail(error,@"印片资源不可用。");id<MTLTexture>before=current;[pinned addObject:before];BOOL ok=transform({wg,wt,2,1,0});float amount=values.filmPrint.y*values.film.mix;if(ok){id<MTLTexture>out=next();ok=out&&[self managedDispatch:@"dyManagedPrint" textures:@[current,cube,out] data:&amount length:4 extra:nullptr extraLength:0 entry:entry error:error];if(ok)current=out;}if(ok)ok=transform({2,1,wg,wt,0});if(ok)ok=blend(before,masks,1,@"film");[pinned removeObject:before];return ok;};
|
||||
// Recover only the pre-existing explicit code-value carrier. No display
|
||||
// transform or host-profile-to-709 conversion precedes the declared input.
|
||||
current=source;id<MTLTexture>carrier=next();uint32_t noLUT=0;if(!carrier||![self managedDispatch:@"dyManagedCarrier" textures:@[current,carrier,entry[@"identity"]] data:&noLUT length:4 extra:nullptr extraLength:0 entry:entry error:error])return NO;current=carrier;
|
||||
if(root&&u.inputSectionEnabled>.5&&!transform({(int)lroundf(u.cm.inputGamut),(int)lroundf(u.cm.inputTransfer),wg,wt,0}))return NO;
|
||||
if(!grade(u,tools[@"baseMasks"][@"primary"],NO))return NO;
|
||||
NSMutableDictionary*finishing=DYMutablePlist(tools);NSMutableSet*scene=[NSMutableSet set];for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"primary"]){if(!grade(DYToolUniforms(node),node[@"masks"],YES))return NO;[scene addObject:ID];}}
|
||||
if(!print(u,tools[@"baseMasks"][@"film"]))return NO;for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"film"]&&!print(DYToolUniforms(node),node[@"masks"]))return NO;}
|
||||
for(NSString*ID in scene)DYRemoveTool(finishing,ID);for(NSMutableDictionary*node in finishing[@"layers"])if([node[@"type"]isEqual:@"film"])node[@"values"][@"filmPrintLook"]=@0;
|
||||
BOOL outputEnabled=root&&u.cm.outputEnabled>.5;int ot=outputEnabled?lroundf(u.cm.outputTransfer):wt,og=outputEnabled?lroundf(u.cm.outputGamut):wg;
|
||||
// Only this stage owns the main display rendering / tone mapping.
|
||||
if(outputEnabled&&!transform(DYCMRender(u.cm).output))return NO;
|
||||
u.primarySectionEnabled=0;u.cm.configured=-1;u.inputProfile=u.preLUTStrength=0;u.filmPrint.x=0;NSDictionary*finishPaths=DYVisibleBaseToolPaths(paths,finishing);NSArray*activeFinish=DYManagedActiveFinishing(u,finishPaths,spider,finishing);
|
||||
BOOL display=outputEnabled&&ot>=1001&&ot<=1003;
|
||||
if(!display&&activeFinish.count)return fail(error,@"当前是 Log/线性码值输出。SDR 修饰工具需要显示输出,请选择 Gamma 输出,或关闭这些工具并保存完整预设。");
|
||||
if(display&&_exporting&&!activeFinish.count){if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}else if(display){if(!transform({og,ot,22,20,0}))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
if(activeFinish.count){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配 SDR 修饰缓冲区。");_managedFinishing=YES;BOOL ok=NO;@try{ok=[self renderSource:tile(current) destination:tile(out) uniforms:u paths:finishPaths spider:spider tools:finishing error:error];}@finally{_managedFinishing=NO;}if(!ok)return NO;current=out;}
|
||||
if(_exporting){if(!transform({22,20,og,ot,0})||!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}else{CGColorSpaceRef from=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB),to=DYManagedTileSpace(dst,primaries);DYColorProfile*p=to?[[[DYColorProfile alloc]initWithSource:from target:to error:error]autorelease]:nil;CGColorSpaceRelease(from);if(to)CGColorSpaceRelease(to);if(!p)return fail(error,@"宿主未提供明确的目标颜色空间。");id<MTLTexture>out=next();if(!out||![self managedProfile:p input:current output:out entry:entry error:error])return NO;current=out;}
|
||||
}else{if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];}
|
||||
_managedFinishing=YES;@try{return [self copyTile:tile(current) to:dst entry:entry error:error];}@finally{_managedFinishing=NO;}
|
||||
}
|
||||
@@ -98,6 +98,7 @@ static NSArray *DYManagedActiveFinishing(DYUniforms u,NSDictionary *paths,NSData
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
#include "DYFilmRender.inc.h"
|
||||
#include "DYPrimaryRender.inc.h"
|
||||
#include "DYManagedRender.inc.h"
|
||||
#include "DYToolRender.inc.h"
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;}
|
||||
@@ -238,7 +239,7 @@ static NSArray *DYManagedActiveFinishing(DYUniforms u,NSDictionary *paths,NSData
|
||||
if(ok)[output getBytes:_exportManagedState?(void*)precise.data():(void*)values.data() bytesPerRow:width*(_exportManagedState?16:8) fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0];[input release];[output release];if(!ok)return NO;
|
||||
NSMutableString *text=[NSMutableString stringWithString:@"TITLE \"大鱼调色\"\n# 包含 CST 与逐像素颜色;不包含纹理、清晰度和逐画面分析。\nLUT_3D_SIZE 33\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];
|
||||
for(NSUInteger i=0;i<count;i++){float rgb[3];for(int c=0;c<3;c++){float v=_exportManagedState?precise[i*4+c]:(float)values[i*4+c];rgb[c]=v<=.0031308f?v*12.92f:1.055f*powf(v,1/2.4f)-.055f;if(!std::isfinite(rgb[c]))return fail(err,@"LUT 输出含无效值");}[text appendFormat:@"%.8f %.8f %.8f\n",rgb[0],rgb[1],rgb[2]];}
|
||||
if(_exportManagedState){NSData *metadata=[NSJSONSerialization dataWithJSONObject:_exportManagedState options:NSJSONWritingSortedKeys error:nil];if(metadata)[text insertString:[NSString stringWithFormat:@"# DAYU_CMS_STATE %@\n",[[[NSString alloc]initWithData:metadata encoding:NSUTF8StringEncoding]autorelease]] atIndex:0];[text replaceOccurrencesOfString:@"LUT_3D_SIZE 33" withString:@"LUT_3D_SIZE 65" options:0 range:NSMakeRange(0,text.length)];[text insertString:@"# V2 input: declared camera/LUT code values, or sRGB in host mode. Output: sRGB / Rec.709.\n" atIndex:0];}
|
||||
if(_exportManagedState){NSData *metadata=[NSJSONSerialization dataWithJSONObject:_exportManagedState options:NSJSONWritingSortedKeys error:nil];if(metadata)[text insertString:[NSString stringWithFormat:@"# DAYU_CMS_STATE %@\n",[[[NSString alloc]initWithData:metadata encoding:NSUTF8StringEncoding]autorelease]] atIndex:0];[text replaceOccurrencesOfString:@"LUT_3D_SIZE 33" withString:@"LUT_3D_SIZE 65" options:0 range:NSMakeRange(0,text.length)];if(DYPrimaryColorState(_exportManagedState)){[text insertString:[NSString stringWithFormat:@"# V3 input: primary CST declared code values. Output: declared primary CST encoding.\n# PRIMARY_CST input=%d/%d working=%d/%d output=%d/%d mapping=%d\n",(int)u.cm.inputTransfer,(int)u.cm.inputGamut,(int)u.cm.workingTransfer,(int)u.cm.workingGamut,(int)u.cm.outputTransfer,(int)u.cm.outputGamut,(int)u.cm.toneMapping] atIndex:0];}else [text insertString:@"# V2 input: declared camera/LUT code values, or sRGB in host mode. Output: sRGB / Rec.709.\n" atIndex:0];}
|
||||
return [text writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error:err];
|
||||
}}
|
||||
@end
|
||||
@@ -12,7 +12,7 @@
|
||||
- (void)toolMask:(NSButton*)sender{if(sender.tag<0||sender.tag>=_cards.count)return;[(DYToolMaskPanel*)_cards[sender.tag][@"maskPanel"]addMenu:sender];}
|
||||
- (void)repeatTool:(NSButton*)sender{
|
||||
if(sender.tag<0||sender.tag>=_cards.count)return;id<PROAPIAccessing>host=_embedded?[(DYToolManager*)_manager host]:_manager;id<FxCustomParameterActionAPI_v4>a=[host apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];
|
||||
NSString *addedID=nil;@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(host,a.currentTime).document);if([doc[@"layers"]count]>=DYToolLimit){[self showError:@"最多可添加 32 个独立工具层。"];return;}NSString *type=_cards[sender.tag][@"section"][@"key"],*anchor=_embedded?[(DYToolManager*)_manager nodeID]:[@"base:" stringByAppendingString:type];NSDictionary *node=DYInsertTool(doc,type,anchor);if(!node)return;addedID=[node[@"id"]copy];id<FxUndoAPI>undo=[host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"再加一层初始化工具"];DYWriteTools(host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:host userInfo:@{@"scrollToTool":addedID?:@""}];[addedID release];
|
||||
NSString *addedID=nil;@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(host,a.currentTime).document);if([doc[@"layers"]count]>=DYToolLimit){[self showError:@"最多可添加 32 个独立工具层。"];return;}NSString *type=_cards[sender.tag][@"section"][@"key"],*anchor=_embedded?[(DYToolManager*)_manager nodeID]:[@"base:" stringByAppendingString:type];NSMutableDictionary *node=(id)DYInsertTool(doc,type,anchor);if(!node)return;if(DYPrimaryColorState(DYReadAssets(host,a.currentTime).colorManagement)){DYUniforms root;DYReadUniforms(host,a.currentTime,&root);DYSeedPrimaryWorkingSpace(node,root.cm.workingTransfer,root.cm.workingGamut);}addedID=[node[@"id"]copy];id<FxUndoAPI>undo=[host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"再加一层初始化工具"];DYWriteTools(host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:host userInfo:@{@"scrollToTool":addedID?:@""}];[addedID release];
|
||||
}
|
||||
- (void)addModule:(NSMenuItem *)sender{
|
||||
if(_embedded)return;NSString *type=sender.representedObject;for(NSUInteger i=0;i<_cards.count;i++)if([_cards[i][@"section"][@"key"]isEqual:type]){NSButton *source=[[[NSButton alloc]init]autorelease];source.tag=i;[self repeatTool:source];return;}
|
||||
@@ -51,4 +51,4 @@
|
||||
|
||||
- (CGFloat)layoutRepeatedToolsAfter:(NSString*)anchor y:(CGFloat)y width:(CGFloat)w {if(_embedded)return y;for(NSString *ID in _stackOrder)if([_stackRoots[ID]isEqual:anchor]){DYInspector *child=_stackViews[ID];child.frame=NSMakeRect(0,y,w,MAX(60,child->_stackHeight));[child layoutSubtreeIfNeeded];CGFloat height=MAX(60,child->_stackHeight);child.frame=NSMakeRect(0,y,w,height);y+=height;}return y;}
|
||||
|
||||
- (void)resetRepeatedTool{if(!_embedded)return;id<PROAPIAccessing>host=[(DYToolManager*)_manager host];id<FxCustomParameterActionAPI_v4>a=[host apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(host,a.currentTime).document);NSMutableDictionary *node=(id)DYToolWithID(doc,[(DYToolManager*)_manager nodeID]);if(!node)return;NSDictionary *fresh=DYNewTool(node[@"type"]);node[@"values"]=fresh[@"values"];node[@"paths"]=@{};[node removeObjectForKey:@"spider"];node[@"spiderLinked"]=@YES;id<FxUndoAPI>undo=[host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"还原独立工具层"];DYWriteTools(host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[self postChanged];}
|
||||
- (void)resetRepeatedTool{if(!_embedded)return;id<PROAPIAccessing>host=[(DYToolManager*)_manager host];id<FxCustomParameterActionAPI_v4>a=[host apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(host,a.currentTime).document);NSMutableDictionary *node=(id)DYToolWithID(doc,[(DYToolManager*)_manager nodeID]);if(!node)return;NSDictionary *fresh=DYNewTool(node[@"type"]);node[@"values"]=DYMutablePlist(fresh[@"values"]);if(DYPrimaryColorState(DYReadAssets(host,a.currentTime).colorManagement)){DYUniforms root;DYReadUniforms(host,a.currentTime,&root);DYSeedPrimaryWorkingSpace(node,root.cm.workingTransfer,root.cm.workingGamut);}node[@"paths"]=@{};[node removeObjectForKey:@"spider"];node[@"spiderLinked"]=@YES;id<FxUndoAPI>undo=[host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"还原独立工具层"];DYWriteTools(host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[self postChanged];}
|
||||
+3
-3
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.8.0</string>
|
||||
<string>1.8.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>55</string>
|
||||
<string>56</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
@@ -71,7 +71,7 @@
|
||||
<key>uuid</key>
|
||||
<string>1C17B73B-F229-4C09-A434-EAF6DFF5F22A</string>
|
||||
<key>version</key>
|
||||
<string>1.8.0</string>
|
||||
<string>1.8.1</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>className</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.8.0</string>
|
||||
<string>1.8.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>55</string>
|
||||
<string>56</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户