From 5212187cc8150150984be7217edf9246c2d0a650 Mon Sep 17 00:00:00 2001 From: mac Date: Mon, 2 Nov 2026 23:26:23 +0800 Subject: [PATCH] Add deletion regressions for fourteen modules, animation reset, fresh re-add and neutral rendering --- 大鱼调色/Plugin/DYDiagnostics.mm | 14 +++-- .../Plugin/DYToolDeletionDiagnostics.inc.h | 53 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 大鱼调色/Plugin/DYToolDeletionDiagnostics.inc.h diff --git a/大鱼调色/Plugin/DYDiagnostics.mm b/大鱼调色/Plugin/DYDiagnostics.mm index dde1808..705ffd6 100644 --- a/大鱼调色/Plugin/DYDiagnostics.mm +++ b/大鱼调色/Plugin/DYDiagnostics.mm @@ -23,6 +23,7 @@ @interface DYDiagnosticManager : NSObject { @public NSMutableDictionary *_values,*_custom; + NSMutableDictionary *_keyframes;BOOL _keyframeQueryFailure; BOOL _duplicate; @public int _undoStarts,_undoEnds;BOOL _undoActive; @@ -31,6 +32,9 @@ @interface DYInspector (DiagnosticActions) - (void)refresh; - (void)resetAll:(id)sender; +- (void)removeTool:(NSButton *)sender; +- (void)addModule:(NSMenuItem *)sender; +- (NSDictionary *)presetPayload; @end @protocol DYSpiderProbe @property(nonatomic,copy) NSData *meshData; @@ -46,12 +50,15 @@ - (void)resetSelected; @end @implementation DYDiagnosticManager -- (instancetype)init {if((self=[super init])){_values=[NSMutableDictionary new];_custom=[NSMutableDictionary new];}return self;} -- (void)dealloc {[_values release];[_custom release];[super dealloc];} +- (instancetype)init {if((self=[super init])){_values=[NSMutableDictionary new];_custom=[NSMutableDictionary new];_keyframes=[NSMutableDictionary new];}return self;} +- (void)dealloc {[_values release];[_custom release];[_keyframes release];[super dealloc];} - (id)apiForProtocol:(Protocol *)protocol { NSString *name=NSStringFromProtocol(protocol); - return [@[@"FxParameterCreationAPI_v5",@"FxParameterRetrievalAPI_v6",@"FxParameterSettingAPI_v6",@"FxCustomParameterActionAPI_v4",@"FxUndoAPI"]containsObject:name]?self:nil; + return [@[@"FxParameterCreationAPI_v5",@"FxParameterRetrievalAPI_v6",@"FxParameterSettingAPI_v6",@"FxCustomParameterActionAPI_v4",@"FxUndoAPI",@"FxKeyframeAPI_v3"]containsObject:name]?self:nil; } +- (NSError *)channelCount:(NSUInteger *)count forParameter:(NSUInteger)pid{if(_keyframeQueryFailure)return [NSError errorWithDomain:@"probe" code:1 userInfo:nil];if(count)*count=1;return nil;} +- (NSError *)keyframeCount:(NSUInteger *)count forParameter:(NSUInteger)pid andChannel:(NSUInteger)channel{if(count)*count=[_keyframes[@(pid)]unsignedIntegerValue];return nil;} +- (NSError *)removeAllKeyframesForParameter:(NSUInteger)pid andChannel:(NSUInteger)channel{[_keyframes removeObjectForKey:@(pid)];return nil;} - (BOOL)startUndoGroup:(NSString *)title{_undoStarts++;_undoActive=YES;return YES;} - (BOOL)endUndoGroup{_undoEnds++;_undoActive=NO;return YES;} - (void)startAction:(id)sender{} @@ -480,6 +487,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool { } #include "DYToolDiagnostics.inc.h" #include "DYToolInsertionDiagnostics.inc.h" + #include "DYToolDeletionDiagnostics.inc.h" #include "DYFilmDiagnostics.inc.h" #include "DYToolTrackingDiagnostics.inc.h" #include "DYToolCanvasDiagnostics.inc.h" diff --git a/大鱼调色/Plugin/DYToolDeletionDiagnostics.inc.h b/大鱼调色/Plugin/DYToolDeletionDiagnostics.inc.h new file mode 100644 index 0000000..ba91520 --- /dev/null +++ b/大鱼调色/Plugin/DYToolDeletionDiagnostics.inc.h @@ -0,0 +1,53 @@ +// Deleting a card is an author-state edit, not a cosmetic hide. Exercise the +// actual header actions on isolated hosts, then feed stale state to rendering. +{ + auto pumpDeletion=[](){double end=NSProcessInfo.processInfo.systemUptime+.035;while(NSProcessInfo.processInfo.systemUptime_values[d[@"pid"]]=@(value);if(![d[@"notAnimatable"]boolValue])host->_keyframes[d[@"pid"]]=@3;} + NSDictionary *neighbor=nil;for(NSDictionary *d in DYDescriptors())if(![ownedIDs containsObject:d[@"pid"]]&&([d[@"key"]isEqual:@"hsl0_0"]||[d[@"key"]isEqual:@"curveY0"])){neighbor=d;break;} + host->_values[neighbor[@"pid"]]=@19;host->_keyframes[neighbor[@"pid"]]=@2; + DYAssetState *assets=[[[DYAssetState alloc]init]autorelease];assets.paths=@{@"input":@"/tmp/dayu-deletion-input.cube",@"look0":@"/tmp/dayu-deletion-look.cube",@"look4":@"/tmp/dayu-deletion-look4.cube"};auto mesh=dy::neutralMesh(6,6);assets.spiderMesh=[NSData dataWithBytes:&mesh length:sizeof(mesh)];assets.spiderLinked=NO;DYWriteAssets(host,assets,kCMTimeZero); + NSMutableDictionary *doc=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);doc[@"baseMasks"][type]=[NSMutableArray arrayWithObject:DYNewMask(DYMaskEllipse)];NSString *other=[type isEqual:@"hsl"]?@"curve":@"hsl";doc[@"baseMasks"][other]=[NSMutableArray arrayWithObject:DYNewMask(DYMaskRectangle)];NSDictionary *sibling=DYInsertTool(doc,other,[@"base:" stringByAppendingString:other]);NSString *siblingID=sibling[@"id"];DYWriteTools(host,doc,kCMTimeZero); + DYInspector *view=[[[DYInspector alloc]initWithAPIManager:host]autorelease];[view refresh];[view setFrameSize:NSMakeSize(360,780)]; + NSMutableDictionary *card=nil;for(NSMutableDictionary *c in [view valueForKey:@"cards"])if([c[@"section"][@"key"]isEqual:type])card=c; + card[@"collapsed"]=@YES;[view setNeedsLayout:YES];[view layoutSubtreeIfNeeded];NSButton *remove=card[@"removeButton"]; + everyButton&=remove&&!remove.hidden&&!remove.superview.hidden&&NSContainsRect(remove.superview.bounds,remove.frame); + int undo=host->_undoStarts;[view removeTool:remove];pumpDeletion();[view refresh];[view layoutSubtreeIfNeeded];NSDictionary *deleted=DYReadTools(host,kCMTimeZero).document; + NSMutableSet *flags=[NSMutableSet setWithObject:card[@"section"][@"enabled"]];if(card[@"section"][@"extraEnabled"])[flags addObject:card[@"section"][@"extraEnabled"]];[flags addObjectsFromArray:card[@"section"][@"enableParameters"]?:@[]]; + for(NSDictionary *d in owned)everyReset&=[host->_values[d[@"pid"]]doubleValue]==([flags containsObject:d[@"pid"]]?0:[d[@"default"]doubleValue])&&host->_keyframes[d[@"pid"]]==nil; + everyReset&=[host->_values[neighbor[@"pid"]]doubleValue]==19&&[host->_keyframes[neighbor[@"pid"]]intValue]==2&&DYBaseToolRemoved(deleted,type)&&[(NSView *)card[@"view"]isHidden]&&![DYMasksForTool(deleted,[@"base:" stringByAppendingString:type])count]&&[deleted[@"baseMasks"][other]isEqual:doc[@"baseMasks"][other]]&&DYToolWithID(deleted,siblingID)!=nil; + everyUndo&=host->_undoStarts==undo+1&&host->_undoStarts==host->_undoEnds&&!host->_undoActive; + DYAssetState *cleared=DYReadAssets(host,kCMTimeZero);NSMutableDictionary *expected=[[assets.paths mutableCopy]autorelease];if([type isEqual:@"primary"])[expected removeObjectForKey:@"input"];if([type isEqual:@"look"]){[expected removeObjectForKey:@"look0"];[expected removeObjectForKey:@"look4"];} + everyAsset&=[cleared.paths isEqual:expected]&&([type isEqual:@"spider"]?cleared.spiderMesh==nil&&cleared.spiderLinked:[cleared.spiderMesh isEqual:assets.spiderMesh]&&!cleared.spiderLinked); + NSDictionary *preset=[view presetPayload];NSData *toolData=[[[NSData alloc]initWithBase64EncodedString:preset[@"tools"] options:0]autorelease];NSDictionary *presetDoc=[NSPropertyListSerialization propertyListWithData:toolData options:0 format:NULL error:nil]; + DYToolDocument *author=DYReadTools(host,kCMTimeZero);NSData *encoded=[NSKeyedArchiver archivedDataWithRootObject:author requiringSecureCoding:YES error:nil];DYToolDocument *restored=[NSKeyedUnarchiver unarchivedObjectOfClass:DYToolDocument.class fromData:encoded error:nil]; + DYInspector *reopened=[[[DYInspector alloc]initWithAPIManager:host]autorelease];[reopened refresh];BOOL hiddenAgain=NO;for(NSDictionary *c in [reopened valueForKey:@"cards"])if([c[@"section"][@"key"]isEqual:type])hiddenAgain=[c[@"removed"]boolValue];everyReopen&=hiddenAgain&&DYBaseToolRemoved(presetDoc,type)&&[restored.document isEqual:deleted]; + NSMenuItem *add=[[[NSMenuItem alloc]init]autorelease];add.representedObject=type;[view addModule:add];pumpDeletion();NSDictionary *added=DYReadTools(host,kCMTimeZero).document;NSDictionary *fresh=nil;for(NSDictionary *n in added[@"layers"])if([n[@"type"]isEqual:type]&&![n[@"id"]isEqual:siblingID]){fresh=n;break;} + everyFresh&=fresh&&[fresh[@"values"]isEqual:DYNewTool(type)[@"values"]]&&![fresh[@"paths"]count]&&![fresh[@"masks"]count]&&fresh[@"spider"]==nil&&DYBaseToolRemoved(added,type); + DYInspector *child=[view valueForKey:@"stackViews"][fresh[@"id"]];NSDictionary *childCard=[[child valueForKey:@"cards"]firstObject];[child setFrameSize:NSMakeSize(280,500)];[child layoutSubtreeIfNeeded]; + for(NSString *key in @[@"repeatButton",@"removeButton",@"maskButton",@"reset"])everyLayout&=NSContainsRect([childCard[@"view"]bounds],[childCard[key]frame]); + NSString *freshID=[[fresh[@"id"]copy]autorelease];NSMutableDictionary *modified=DYMutablePlist(added);NSMutableDictionary *node=(id)DYToolWithID(modified,freshID);node[@"values"][[owned firstObject][@"key"]]=[[owned firstObject]objectForKey:@"max"];node[@"masks"]=[NSMutableArray arrayWithObject:DYNewMask(DYMaskEllipse)];NSDictionary *successor=DYInsertTool(modified,type,freshID);NSString *successorID=successor[@"id"];DYWriteTools(host,modified,kCMTimeZero);[child refresh];[child removeTool:childCard[@"removeButton"]];pumpDeletion();NSDictionary *removed=DYReadTools(host,kCMTimeZero).document; + everyExtra&=!DYToolWithID(removed,freshID)&&DYToolWithID(removed,successorID)&&DYToolWithID(removed,siblingID)&&[DYToolRootAnchor(removed,successorID)isEqual:[@"base:" stringByAppendingString:type]]; + }} + run.record(@"all-fourteen-base-modules-have-delete-buttons-while-collapsed",everyButton); + run.record(@"deletion-resets-all-owned-values-and-keyframes-without-changing-neighbor",everyReset); + run.record(@"deletion-clears-only-owned-lut-or-spider-assets",everyAsset); + run.record(@"each-base-deletion-is-one-balanced-undo-group",everyUndo); + run.record(@"deleted-modules-persist-in-preset-archive-and-reopened-inspector",everyReopen); + run.record(@"add-module-creates-initialized-independent-layer-without-inheriting-deleted-values",everyFresh); + run.record(@"deleting-extra-layer-removes-its-state-and-keeps-child-and-neighbor",everyExtra); + run.record(@"narrow-header-keeps-mask-add-delete-and-reset-within-card",everyLayout); + DYDiagnosticManager *failureHost=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(failureHost,nil);failureHost->_keyframeQueryFailure=YES;failureHost->_values[@2000]=@2;NSError *resetFailure=nil;run.record(@"keyframe-query-failure-leaves-author-parameters-unchanged",!DYResetToolParameters(failureHost,DYBaseToolDescriptors(@"base"),kCMTimeZero,&resetFailure)&&resetFailure&&[failureHost->_values[@2000]intValue]==2); + NSMutableDictionary *bad=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);bad[@"removedBase"]=@[@"hsl",@"hsl"];run.record(@"removed-base-document-rejects-duplicates",!DYValidToolDocument(bad));bad[@"removedBase"]=@[@"unknown"];run.record(@"removed-base-document-rejects-unknown-modules",!DYValidToolDocument(bad)); + // A stale host value from another time must not affect a deleted module. + [[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:input.data() bytesPerRow:width*8]; + auto pixelsForDeletion=[&](NSDictionary *doc,DYUniforms u,NSDictionary *paths,NSString *name){NSError *failure=nil;BOOL ok=[renderer renderSource:source destination:destination uniforms:u paths:paths spider:nil tools:doc error:&failure];run.need(name,ok,@{@"error":reason(failure)});return read(destination,gpu);}; + NSDictionary *empty=[[[DYToolDocument alloc]init]autorelease].document;Pixels neutral=pixelsForDeletion(empty,DYToolUniforms(@{@"type":@"hsl"}),@{},@"delete-neutral-render-reference"); + NSMutableDictionary *doc=DYMutablePlist(empty);DYSetBaseToolRemoved(doc,@"hsl",YES);DYUniforms stale=DYToolUniforms(@{@"type":@"hsl",@"values":@{@"hsl0_0":@75,@"hsl1_1":@60}});Pixels active=pixelsForDeletion(empty,stale,@{},@"delete-active-hsl-reference");Pixels hidden=pixelsForDeletion(doc,stale,@{},@"delete-stale-hsl-render");run.record(@"deleted-base-is-neutral-even-with-stale-nonzero-host-values",difference(active,neutral).different>20&&difference(hidden,neutral).maximum<.0001); + doc=DYMutablePlist(empty);DYSetBaseToolRemoved(doc,@"look",YES);stale=DYToolUniforms(@{@"type":@"look"});hidden=pixelsForDeletion(doc,stale,@{@"look0":@"/missing/deleted-look.cube"},@"deleted-look-does-not-load-stale-file");run.record(@"deleted-lut-does-not-load-or-inherit-stale-file-reference",difference(hidden,neutral).maximum<.0001); + doc=DYMutablePlist(empty);for(NSString *type in DYToolTypes())DYSetBaseToolRemoved(doc,type,YES);stale=DYToolUniforms(@{@"type":@"film"});stale.film.grainEnabled=1;stale.film.grainAmount=.8;stale.hslHueA.x=80;stale.hslSectionEnabled=1;hidden=pixelsForDeletion(doc,stale,@{@"input":@"/missing/input.cube",@"look0":@"/missing/look.cube"},@"all-deleted-base-modules-render");run.record(@"all-modules-can-be-removed-without-hidden-render-adjustments",difference(hidden,neutral).maximum<.0001); + NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"deleted-film-export.cube"]];NSError *failure=nil;run.record(@"deleted-spatial-film-does-not-block-lut-export",[renderer exportLUT:cube uniforms:stale paths:@{} spider:nil tools:doc error:&failure]); +}