fix: replay paused scopes and bound per-pixel face masks

这个提交包含在:
mac 于 2026-11-08 16:41:55 +08:00 提交
1 父节点 cdf6ddc1d7
当前提交 8a434b8e40
14 个文件已更改
+105 -52

没有与搜索条件相匹配的文件

+13 -5
查看文件
@@ -6,6 +6,7 @@
#include <algorithm>
#include <vector>
#include <cmath>
#import <CommonCrypto/CommonDigest.h>
@interface DYDiagnosticTile : FxImageTile
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height;
@end
@@ -13,12 +14,14 @@
- (void)prepareFaceSupport:(FxImageTile*)source;
@end
static NSUInteger faceCalls=0;
static double facePreparationMs=0;
@interface DYPreviewBenchmarkRenderer : DYRenderer
@end
@implementation DYPreviewBenchmarkRenderer
- (void)prepareFaceSupport:(FxImageTile*)source {faceCalls++;[super prepareFaceSupport:source];}
- (void)prepareFaceSupport:(FxImageTile*)source {faceCalls++;double start=CACurrentMediaTime();[super prepareFaceSupport:source];facePreparationMs+=(CACurrentMediaTime()-start)*1000;}
@end
int main(int argc,const char*argv[]){@autoreleasepool{
bool activeFace=argc>1&&strcmp(argv[1],"--active-face")==0;
id<MTLDevice> gpu=MTLCreateSystemDefaultDevice();NSMutableArray *rows=[NSMutableArray array];
NSBitmapImageRep *portrait=(NSBitmapImageRep*)[NSBitmapImageRep imageRepWithContentsOfFile:@"tools/fixtures/astronaut.png"];
if(portrait.pixelsWide!=512||portrait.pixelsHigh!=512){fputs("Missing 512x512 public portrait fixture\n",stderr);return 1;}
@@ -30,17 +33,22 @@ int main(int argc,const char*argv[]){@autoreleasepool{
const auto reference=pixels;
id<MTLTexture> input=[src metalTextureForDevice:gpu];[input replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:pixels.data() bytesPerRow:width*8];
for(int mode=0;mode<3;mode++){@autoreleasepool{
DYRenderer *renderer=[DYPreviewBenchmarkRenderer new];DYUniforms u;DYDefaultUniforms(&u);if(mode==1)u.skinFaceOnly=0;if(mode==2){u.skinProtection.x=0;u.skinFaceOnly=0;}
std::vector<double> milliseconds;NSUInteger before=faceCalls;NSError *error=nil;BOOL ok=YES;
DYRenderer *renderer=[DYPreviewBenchmarkRenderer new];DYUniforms u;DYDefaultUniforms(&u);if(activeFace){u=DYToolUniforms(@{@"type":@"hsl"});u.hslHueA=(DYFloat4){40,40,40,40};u.hslHueB=u.hslHueA;u.skinProtection=(DYFloat3){1,100,28};u.skinFaceOnly=1;}if(mode==1)u.skinFaceOnly=0;if(mode==2){u.skinProtection.x=0;u.skinFaceOnly=0;}
facePreparationMs=0;std::vector<double> milliseconds;NSUInteger before=faceCalls;NSError *error=nil;BOOL ok=YES;
for(int i=0;i<14;i++){@autoreleasepool{
// A different real input each frame prevents the face raster cache from
// disguising unnecessary inference as a still-frame-only workload.
for(size_t p=0;p<pixels.size();p++)pixels[p]=p%4==3?reference[p]:(__fp16)(reference[p]*(.92+i*.01));[input replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:pixels.data() bytesPerRow:width*8];
double start=CACurrentMediaTime();ok=[renderer renderSource:src destination:dst uniforms:u paths:@{} spider:nil tools:nil colorManagement:nil hostPrimaries:-1 error:&error];
if(!ok){fprintf(stderr,"%s\n",error.description.UTF8String);return 1;}if(i>=2)milliseconds.push_back((CACurrentMediaTime()-start)*1000);
if(!ok){fprintf(stderr,"%s\n",error.description.UTF8String);return 1;}if(i==1)facePreparationMs=0;if(i>=2)milliseconds.push_back((CACurrentMediaTime()-start)*1000);
}}
std::sort(milliseconds.begin(),milliseconds.end());double sum=0;for(double v:milliseconds)sum+=v;
[rows addObject:@{@"width":@(width),@"height":@(height),@"mode":@[@"default",@"faceOnlyOff",@"skinOff"][mode],@"frames":@(milliseconds.size()),@"meanMs":@(sum/milliseconds.size()),@"medianMs":@(milliseconds[milliseconds.size()/2]),@"maxMs":@(milliseconds.back()),@"faceCalls":@(faceCalls-before)}];[renderer release];
id<MTLTexture> output=[dst metalTextureForDevice:gpu];
[output getBytes:pixels.data() bytesPerRow:width*8 fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0];
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
CC_SHA256(pixels.data(),(CC_LONG)(pixels.size()*sizeof(__fp16)),digest);
NSMutableString *hash=[NSMutableString string];for(unsigned char byte:digest)[hash appendFormat:@"%02x",byte];
[rows addObject:@{@"width":@(width),@"height":@(height),@"mode":@[activeFace?@"faceOnly":@"default",@"faceOnlyOff",@"skinOff"][mode],@"outputSHA256":hash,@"meanFacePreparationMs":@(facePreparationMs/milliseconds.size()),@"frames":@(milliseconds.size()),@"meanMs":@(sum/milliseconds.size()),@"medianMs":@(milliseconds[milliseconds.size()/2]),@"maxMs":@(milliseconds.back()),@"faceCalls":@(faceCalls-before)}];[renderer release];
}}[src release];[dst release];
}}
NSData *json=[NSJSONSerialization dataWithJSONObject:@{@"gpu":gpu.name,@"cases":rows} options:NSJSONWritingPrettyPrinted error:nil];fwrite(json.bytes,1,json.length,stdout);puts("");[gpu release];return 0;
+8 -4
查看文件
@@ -2,13 +2,15 @@
"""Link a headless benchmark against existing Release objects and run it."""
from pathlib import Path
import argparse, plistlib, subprocess
p=argparse.ArgumentParser();p.add_argument('--output',type=Path,required=True);a=p.parse_args()
p=argparse.ArgumentParser();p.add_argument('--output',type=Path,required=True);p.add_argument('--resources',type=Path);p.add_argument('--active-face',action='store_true');a=p.parse_args()
root=Path(__file__).resolve().parent.parent
cache=Path('/Users/mac/Library/Caches/CodexBuilds/com.dayu.color')
objects=cache/'DerivedData/Build/Intermediates.noindex/大鱼调色.build/Release/XPC Service.build/Objects-normal/arm64'
work=cache/'performance-1.19.1/benchmark.bundle/Contents';(work/'MacOS').mkdir(parents=True,exist_ok=True)
resources=Path('/Library/Plug-Ins/FxPlug/大鱼调色.app/Contents/PlugIns/大鱼调色 XPC Service.pluginkit/Contents/Resources')
if not (work/'Resources').exists():(work/'Resources').symlink_to(resources)
resources=a.resources or Path('/Library/Plug-Ins/FxPlug/大鱼调色.app/Contents/PlugIns/大鱼调色 XPC Service.pluginkit/Contents/Resources')
resource_link=work/'Resources'
if resource_link.is_symlink():resource_link.unlink()
resource_link.symlink_to(resources.resolve(strict=True))
(work/'Info.plist').write_bytes(plistlib.dumps({'CFBundleExecutable':'benchmark','CFBundleIdentifier':'com.dayu.color.headless-benchmark','CFBundlePackageType':'BNDL'}))
cmd=['xcrun','clang++','-std=c++17','-O2','-mmacosx-version-min=14.6','-fno-objc-arc','-F/Library/Developer/SDKs/FxPlug.sdk/Library/Frameworks','-F/Library/Developer/Frameworks',str(root/'tools/benchmark_default_preview.mm')]
cmd += [str(x) for x in objects.glob('*.o') if x.name!='main.o' and not x.name.endswith('_lto.o')]
@@ -16,5 +18,7 @@ cmd += ['@'+str(cache/'cms-runtime/bridge-link.rsp')]
for f in ['Metal','MetalPerformanceShaders','Vision','QuartzCore','Accelerate','PluginManager','Foundation','AppKit','FxPlug','Security','CoreVideo','IOSurface','CoreMedia','CoreImage','CoreGraphics','ImageIO','UniformTypeIdentifiers','AVFoundation']:cmd+=['-framework',f]
cmd+=['-lcompression','-lz','-Wl,-rpath,/Library/Developer/Frameworks','-o',str(work/'MacOS/benchmark')]
subprocess.run(cmd,check=True,cwd=root)
with a.output.open('w') as out:subprocess.run([str(work/'MacOS/benchmark')],stdout=out,check=True,cwd=root)
benchmark=[str(work/'MacOS/benchmark')]
if a.active_face:benchmark.append('--active-face')
with a.output.open('w') as out:subprocess.run(benchmark,stdout=out,check=True,cwd=root)
print(a.output)
+3 -4
查看文件
@@ -8,7 +8,6 @@
#import "DYManagedColor.h"
#include "DYSpiderScopeDrawing.h"
#include "DYScopeDisplayTime.h"
#import <os/log.h>
#include <cmath>
static NSButton *DYWorkspaceButton(NSString *title,id target,SEL action){NSButton *b=[NSButton buttonWithTitle:title target:target action:action];b.bezelStyle=NSBezelStyleRounded;b.bordered=NO;b.font=[NSFont systemFontOfSize:11];b.accessibilityLabel=title;return b;}
@@ -215,10 +214,10 @@ static BOOL DYWorkspaceEnabled(DYUniforms u,NSString *type){if([type isEqual:@"b
}
- (void)pageChanged:(id)sender{
if(_editorMode==2)[self bindLUTTarget];_scopePane.hidden=NO;_lutPane.hidden=_editorMode!=2;_lutExplanation.hidden=YES;_toolEditor.hidden=_editorMode!=0;_maskPane.hidden=_editorMode!=1;_selectionTitle.hidden=_editorMode==2;
CMTime displayTime=_toolTime;id<FxCustomParameterActionAPI_v4>action=[self actionAPI];if(_visible&&!_renderer.scopeEnabled&&action){[action startAction:self];@try{
displayTime=DYHostDisplayedFrameTime([self rootHost],_toolTime);if(CMTimeCompare(displayTime,_toolTime)!=0)os_log(OS_LOG_DEFAULT,"dayu_scope_end_boundary requested=%{public}.9f display=%{public}.9f",CMTimeGetSeconds(_toolTime),CMTimeGetSeconds(displayTime));
CMTime displayTime=_toolTime,frameDuration=kCMTimeInvalid;id<FxCustomParameterActionAPI_v4>action=[self actionAPI];if(_visible&&!_renderer.scopeEnabled&&action){[action startAction:self];@try{
displayTime=DYHostDisplayedFrameTime([self rootHost],action.currentTime,&frameDuration);
}@finally{[action endAction:self];}}
[_renderer setScopeEnabled:_visible atTime:displayTime];if(_editorMode==2)[self ensureBrowser];[self scopeChanged:nil];[self layoutWorkspace];
[_renderer setScopeEnabled:_visible atTime:displayTime frameDuration:frameDuration];if(_editorMode==2)[self ensureBrowser];[self scopeChanged:nil];[self layoutWorkspace];
}
- (void)toggleHostScopes:(id)sender{
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];NSError *error=nil;BOOL done=NO;if(action){[action startAction:self];@try{id<FxCommandAPI> commands=[_manager apiForProtocol:@protocol(FxCommandAPI)];done=[commands performCommand:kFxCommand_ToggleWaveforms error:&error];}@finally{[action endAction:self];}}
+19 -12
查看文件
@@ -3,7 +3,7 @@
- (void)prepareFaceSupport:(FxImageTile*)source {
[_faceEntries release];_faceEntries=nil;std::vector<DYToolMaskEntry> entries;
FxRect image=source.imagePixelBounds,tile=source.tilePixelBounds;
if(image.left!=tile.left||image.right!=tile.right||image.top!=tile.top||image.bottom!=tile.bottom){[_faceEntries release];_faceEntries=nil;[_faceInput release];_faceInput=nil;return;}
if(image.left!=tile.left||image.right!=tile.right||image.top!=tile.top||image.bottom!=tile.bottom)return;
NSMutableDictionary *device=[self device:source.deviceRegistryID error:nil];id<MTLTexture>texture=[source metalTextureForDevice:device[@"device"]];if(!texture)return;
if(!_faceContext)_faceContext=[[CIContext contextWithMTLDevice:device[@"device"] options:@{kCIContextCacheIntermediates:@NO}]retain];
CGColorSpaceRef linear=CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
@@ -12,27 +12,34 @@
if(source.imageOrigin==kFxImageOrigin_TOP_LEFT)input=[input imageByApplyingTransform:CGAffineTransformMake(1,0,0,-1,0,input.extent.size.height)];
CGFloat scale=MIN(1.,960./MAX(input.extent.size.width,input.extent.size.height));input=[input imageByApplyingTransform:CGAffineTransformMakeScale(scale,scale)];
CGColorSpaceRef srgb=CGColorSpaceCreateWithName(kCGColorSpaceSRGB);CGImageRef cg=[_faceContext createCGImage:input fromRect:input.extent format:kCIFormatRGBA8 colorSpace:srgb];CGColorSpaceRelease(srgb);if(!cg)return;
CFDataRef raster=CGDataProviderCopyData(CGImageGetDataProvider(cg));BOOL same=raster&&[_faceInput isEqual:(NSData*)raster];if(same){_faceEntries=[_faceCachedEntries retain];CFRelease(raster);CGImageRelease(cg);return;}[_faceInput release];_faceInput=raster?[(NSData*)raster copy]:nil;if(raster)CFRelease(raster);[_faceEntries release];_faceEntries=nil;
NSData *raster=[(NSData*)CGDataProviderCopyData(CGImageGetDataProvider(cg)) autorelease];
if(raster&&[_faceInput isEqualToData:raster]){_faceEntries=[_faceCachedEntries retain];CGImageRelease(cg);return;}
VNDetectFaceLandmarksRequest *request=[VNDetectFaceLandmarksRequest new];request.revision=VNDetectFaceLandmarksRequestRevision3;request.constellation=VNRequestFaceLandmarksConstellation76Points;
VNImageRequestHandler *handler=[[VNImageRequestHandler alloc]initWithCGImage:cg orientation:kCGImagePropertyOrientationUp options:@{}];CGImageRelease(cg);
if([handler performRequests:@[request] error:nil])for(VNFaceObservation *face in request.results){
if(entries.size()>64||face.confidence<.5||!face.landmarks.faceContour.pointCount)continue;CGRect box=face.boundingBox;if(box.size.width<.015||box.size.height<.015)continue;
// Privacy coverage includes eyes, brows and mouth. Skin's feature holes must
// never punch through the mosaic. A padded rectangle covers the full face.
DYToolMaskEntry privacy{};privacy.section=-102;privacy.mask.parameters=dyDefaultMaskParameters();
privacy.mask.parameters.kind=DYMaskRectangle;privacy.mask.parameters.centerX=CGRectGetMidX(box);privacy.mask.parameters.centerY=1-CGRectGetMidY(box);
privacy.mask.parameters.width=box.size.width*1.2;privacy.mask.parameters.height=box.size.height*1.25;privacy.mask.parameters.feather=0;entries.push_back(privacy);
BOOL detected=[handler performRequests:@[request] error:nil];NSUInteger originalEntryCount=0;
if(detected)for(VNFaceObservation *face in request.results){
if(originalEntryCount>64||face.confidence<.5||face.landmarks.faceContour.pointCount<3||face.landmarks.faceContour.pointCount>243)continue;CGRect box=face.boundingBox;if(box.size.width<.015||box.size.height<.015)continue;
DYToolMaskEntry support{};support.section=-100;support.mask.parameters=dyDefaultMaskParameters();auto &p=support.mask.parameters;p.kind=DYMaskBezier;p.centerX=CGRectGetMidX(box);p.centerY=1-CGRectGetMidY(box);p.width=box.size.width;p.height=box.size.height;p.feather=.1;
auto &path=support.mask.path;VNFaceLandmarkRegion2D *contour=face.landmarks.faceContour;
for(NSUInteger i=0;i<contour.pointCount;i++){CGPoint q=contour.normalizedPoints[i];path.x[path.count]=q.x-.5;path.y[path.count]=.5-q.y;path.count++;}
// Close the jaw along a soft forehead cap, instead of selecting the whole box.
BOOL forward=path.x[path.count-1]>path.x[0];for(int i=0;i<=12;i++){float t=i/12.f,x=forward?1-t:t;path.x[path.count]=x-.5;path.y[path.count]=-.28-.28*sinf(t*M_PI);path.count++;}entries.push_back(support);
BOOL forward=path.x[path.count-1]>path.x[0];for(int i=0;i<=12;i++){float t=i/12.f,x=forward?1-t:t;path.x[path.count]=x-.5;path.y[path.count]=-.28-.28*sinf(t*M_PI);path.count++;}
auto xs=std::minmax_element(path.x,path.x+path.count),ys=std::minmax_element(path.y,path.y+path.count);
// Small padding protects the conservative bound against GPU rounding.
constexpr float padding=1e-5f;
support.minX=p.centerX+*xs.first*p.width-padding;support.maxX=p.centerX+*xs.second*p.width+padding;
support.minY=p.centerY+*ys.first*p.height-padding;support.maxY=p.centerY+*ys.second*p.height+padding;
entries.push_back(support);originalEntryCount+=2;
for(VNFaceLandmarkRegion2D *region in @[face.landmarks.leftEye?:[NSNull null],face.landmarks.rightEye?:[NSNull null],face.landmarks.outerLips?:[NSNull null],face.landmarks.leftEyebrow?:[NSNull null],face.landmarks.rightEyebrow?:[NSNull null]]){
if(![region isKindOfClass:VNFaceLandmarkRegion2D.class]||!region.pointCount)continue;CGFloat loX=1,loY=1,hiX=0,hiY=0;for(NSUInteger i=0;i<region.pointCount;i++){CGPoint q=region.normalizedPoints[i];loX=MIN(loX,q.x);hiX=MAX(hiX,q.x);loY=MIN(loY,q.y);hiY=MAX(hiY,q.y);}
DYToolMaskEntry hole{};hole.section=-101;hole.mask.parameters=dyDefaultMaskParameters();auto &h=hole.mask.parameters;h.kind=DYMaskEllipse;h.centerX=box.origin.x+(loX+hiX)*.5*box.size.width;h.centerY=1-(box.origin.y+(loY+hiY)*.5*box.size.height);h.width=(hiX-loX)*box.size.width*1.2;h.height=MAX(.035,hiY-loY)*box.size.height*1.6;h.feather=.35;entries.push_back(hole);
DYToolMaskEntry hole{};hole.section=-101;hole.mask.parameters=dyDefaultMaskParameters();auto &h=hole.mask.parameters;h.kind=DYMaskEllipse;h.centerX=box.origin.x+(loX+hiX)*.5*box.size.width;h.centerY=1-(box.origin.y+(loY+hiY)*.5*box.size.height);h.width=(hiX-loX)*box.size.width*1.2;h.height=MAX(.035,hiY-loY)*box.size.height*1.6;h.feather=.35;entries.push_back(hole);originalEntryCount++;
}
}
[handler release];[request release];_faceEntries=[[NSData alloc]initWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry)];[_faceCachedEntries release];_faceCachedEntries=[_faceEntries copy];
[handler release];[request release];
if(!detected)return;
_faceEntries=[[NSData alloc]initWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry)];
[_faceInput release];_faceInput=[raster retain];
[_faceCachedEntries release];_faceCachedEntries=[_faceEntries retain];
}
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){
DYUniforms effective=DYEffectiveFaceUniforms(u,paths,tools);BOOL face=effective.skinProtection.x>.5&&(effective.skinProtection.y>0||effective.skinVisualize>.5)&&(effective.skinFaceOnly>.5||effective.skinVisualize>.5);for(NSDictionary *node in tools[@"layers"]){
+16 -7
查看文件
@@ -105,7 +105,7 @@ inline float dyToolMaskHSLWeight(float3 source,thread const DYMaskParameters& p)
if(p.flags&DYMaskLightnessEnabled)weight*=dyToolMaskRangeWeight(hsl.z,p.lightnessRange);
return weight;
}
inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters& p,thread const DYMaskPath& path){
inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters& p,device const DYMaskPath& path){
float dx=(x-p.centerX)*p.imageAspect,dy=y-p.centerY,ca=cos(p.angle),sa=sin(p.angle);
float px=dx*ca+dy*sa,py=-dx*sa+dy*ca;
if(p.kind==DYMaskLinearGradient){
@@ -125,14 +125,14 @@ inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters
}
if(!inside)return 0;if(p.feather==0)return 1;return dyToolMaskSoftStep(0,p.feather*.5f,sqrt(distance2));
}
inline float dyToolMaskRawCoverage(float x,float y,float3 source,thread const DYMaskParameters& p,thread const DYMaskPath& path){return p.kind==DYMaskHSLKey?dyToolMaskHSLWeight(source,p):(p.kind==DYMaskLumaKey?dyLuma(dyLimit(source)):dyToolMaskShapeWeight(x,y,p,path));}
inline float dyToolMaskOperator(float x,float y,float3 source,thread const DYMaskParameters& p,thread const DYMaskPath& path){
inline float dyToolMaskRawCoverage(float x,float y,float3 source,thread const DYMaskParameters& p,device const DYMaskPath& path){return p.kind==DYMaskHSLKey?dyToolMaskHSLWeight(source,p):(p.kind==DYMaskLumaKey?dyLuma(dyLimit(source)):dyToolMaskShapeWeight(x,y,p,path));}
inline float dyToolMaskOperator(float x,float y,float3 source,thread const DYMaskParameters& p,device const DYMaskPath& path){
if((p.version!=1&&p.version!=2)||p.kind>DYMaskLumaKey)return 0;
float raw=dyToolMaskRawCoverage(x,y,source,p,path);
return dyToolMaskLevels(raw,p);
}
inline float dyToolMask(float x,float y,float3 source,device const DYResolvedMask& value){DYResolvedMask local=value;return dyToolMaskOperator(x,y,source,local.parameters,local.path);}
inline float dyToolMask(float x,float y,float3 source,device const DYResolvedMask& value){DYMaskParameters parameters=value.parameters;return dyToolMaskOperator(x,y,source,parameters,value.path);}
inline float3 dyToolEncode(float3 linear){return select(1.055f*pow(max(linear,float3(0)),float3(1.f/2.4f))-.055f,linear*12.92f,linear<=.0031308f);}
@@ -140,12 +140,21 @@ inline float3 dyToolDecode(float3 encoded){return select(pow(max((encoded+.055f)
inline float dyToolCoverage(float2 uv,float3 source,device const DYToolMaskEntry* masks,constant DYToolMaskHeader& h,int section){
float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;float coverage=1;bool found=false;
for(uint i=0;i<h.count;i++){if(masks[i].section!=section)continue;
// Copy device data to thread storage; shared mask math accepts constant
// descriptors, so evaluate through the address-space-neutral copy below.
float a=dyToolMask(x,y,source,masks[i].mask);
if(!found){coverage=masks[i].combine==1?1-a:a;found=true;}
else if(masks[i].combine==1)coverage*=1-a;else if(masks[i].combine==2)coverage*=a;else coverage=1-(1-coverage)*(1-a);
}if(section==3&&h.faceOnly){float face=0;for(uint i=0;i<h.count;i++)if(masks[i].section==-100)face=1-(1-face)*(1-dyToolMask(x,y,source,masks[i].mask));for(uint i=0;i<h.count;i++)if(masks[i].section==-101)face*=1-dyToolMask(x,y,source,masks[i].mask);coverage*=face;}return clamp(coverage,0.f,1.f);
}
if(section==3&&h.faceOnly){
float face=0;
for(uint i=0;i<h.count;i++){
device const DYToolMaskEntry &entry=masks[i];
if(entry.section==-100&&x>=entry.minX&&x<=entry.maxX&&y>=entry.minY&&y<=entry.maxY)
face=1-(1-face)*(1-dyToolMask(x,y,source,entry.mask));
}
if(face>0)for(uint i=0;i<h.count;i++)if(masks[i].section==-101)face*=1-dyToolMask(x,y,source,masks[i].mask);
coverage*=face;
}
return clamp(coverage,0.f,1.f);
}
fragment half4 dyMaskedFragment(DYRaster in [[stage_in]],
+1 -1
查看文件
@@ -32,7 +32,7 @@
/// sample per instance so opening a paused workspace needs no parameter edit.
- (BOOL)scopeEnabled;
- (void)setScopeEnabled:(BOOL)enabled;
- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time;
- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration;
/// Call after the final destination render succeeds, while the tile is valid.
/// Only the small GPU readback waits here; conversion/statistics are coalesced
/// on a worker. No main-queue wait or host API is performed by this method.
+3 -1
查看文件
@@ -1,7 +1,9 @@
#include "DYScopeDisplayTime.h"
#import <os/log.h>
#import "DYManagedColor.h"
#import "../../ColorManagement/Sources/DYColorManagementGPU.h"
#import "../../ColorManagement/Sources/DYColorProfile.h"
#include <algorithm>
#include <map>
#include <mutex>
#import "DYRenderer.h"
@@ -148,7 +150,7 @@ struct DYScopeReadback {
uint64_t _spiderScopeSerial;
NSUInteger _scopeGeneration;
DYScopeSample *_scopePending,*_scopeLatest;
uint64_t _scopeCaptureSerial,_scopeLatestSerial;CMTime _scopeRequestedTime;
uint64_t _scopeCaptureSerial,_scopeLatestSerial;CMTime _scopeRequestedTime,_scopeRequestedFrameDuration;
FxImageTile *_scopeDestination; // borrowed for one locked host render
CMTime _scopeRenderTime;
BOOL _scopeCaptured;
+8 -8
查看文件
@@ -1,15 +1,15 @@
// Included in DYRenderer's implementation; final destination sampling is kept
// separate from the earlier input-analysis thumbnail used by auto-grade/LUTs.
- (BOOL)scopeEnabled{@synchronized(_previewLock){return _scopeEnabled;}}
- (void)setScopeEnabled:(BOOL)enabled{[self setScopeEnabled:enabled atTime:kCMTimeInvalid];}
- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time{
- (void)setScopeEnabled:(BOOL)enabled{[self setScopeEnabled:enabled atTime:kCMTimeInvalid frameDuration:kCMTimeInvalid];}
- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration{
BOOL start=NO;@synchronized(_previewLock){if(_scopeEnabled==enabled)return;_scopeEnabled=enabled;_scopeGeneration++;[_scopePending release];_scopePending=nil;
if(enabled){_scopeRequestedTime=time;[_scopePreview release];_scopePreview=nil;[_scopeMetadata release];_scopeMetadata=nil;
if(enabled){_scopeRequestedTime=time;_scopeRequestedFrameDuration=frameDuration;[_scopePreview release];_scopePreview=nil;[_scopeMetadata release];_scopeMetadata=nil;
CMTime cached=_scopeLatest?CMTimeMakeWithEpoch([_scopeLatest.metadata[@"timeValue"]longLongValue],[_scopeLatest.metadata[@"timeScale"]intValue],[_scopeLatest.metadata[@"timeEpoch"]longLongValue]):kCMTimeInvalid;
os_log(OS_LOG_DEFAULT,"dayu_scope_open requested=%{public}.9f cached=%{public}.9f",CMTimeGetSeconds(time),CMTimeGetSeconds(cached));
// Replay only this instance's actual final output at the requested host time.
// A panel opening must not require a parameter mutation or a fresh render.
if(_scopeLatest&&(!CMTIME_IS_NUMERIC(time)||(CMTIME_IS_NUMERIC(cached)&&CMTimeCompare(cached,time)==0))){DYScopeSample *sample=[DYScopeSample new];sample.pixels=_scopeLatest.pixels;sample.space=_scopeLatest.space;sample.metadata=_scopeLatest.metadata;sample.generation=_scopeGeneration;_scopePending=sample;if(!_scopeWorkerRunning){_scopeWorkerRunning=YES;start=YES;}}
BOOL replay=_scopeLatest&&(!CMTIME_IS_NUMERIC(time)||DYScopeFrameContainsTime(cached,time,frameDuration));
os_log(OS_LOG_DEFAULT,"dayu_scope_open requested=%{public}.9f cached=%{public}.9f frame=%{public}.9f replay=%{public}d",CMTimeGetSeconds(time),CMTimeGetSeconds(cached),CMTimeGetSeconds(frameDuration),replay);
// Reuse this instance's final output when the host is still on that frame.
if(replay){DYScopeSample *sample=[DYScopeSample new];sample.pixels=_scopeLatest.pixels;sample.space=_scopeLatest.space;sample.metadata=_scopeLatest.metadata;sample.generation=_scopeGeneration;_scopePending=sample;if(!_scopeWorkerRunning){_scopeWorkerRunning=YES;start=YES;}}
}
}
if(start)dispatch_async(_scopeQueue,^{[self processPendingScopeSamples];});
@@ -119,7 +119,7 @@
[_scopeLatest release];_scopeLatest=[sample retain];_scopeLatestSerial=readback.serial;
if(_outputObserved&&!_outputNotificationPending){_outputNotificationPending=YES;notifyOutput=YES;}
}
if(_scopeEnabled&&readback.serial==_scopeLatestSerial&&(readback.generation==_scopeGeneration||!CMTIME_IS_NUMERIC(_scopeRequestedTime)||CMTimeCompare(time,_scopeRequestedTime)==0)){
if(_scopeEnabled&&readback.serial==_scopeLatestSerial&&(readback.generation==_scopeGeneration||!CMTIME_IS_NUMERIC(_scopeRequestedTime)||DYScopeFrameContainsTime(time,_scopeRequestedTime,_scopeRequestedFrameDuration))){
sample.generation=_scopeGeneration;[_scopePending release];_scopePending=[sample retain];
if(!_scopeWorkerRunning){_scopeWorkerRunning=YES;start=YES;}
}
+12 -1
查看文件
@@ -8,11 +8,22 @@ static inline CMTime DYScopeDisplayTime(CMTime requested,CMTime start,CMTime dur
CMTime last=CMTimeSubtract(end,frame);return CMTimeCompare(last,start)<0?start:last;
}
// Custom-view time can land between rendered input frames. A cached frame
// covers its own interval only; the next frame boundary must get a fresh sample.
static inline bool DYScopeFrameContainsTime(CMTime captured,CMTime requested,CMTime frame){
if(!CMTIME_IS_NUMERIC(captured)||!CMTIME_IS_NUMERIC(requested)||captured.epoch!=requested.epoch)return false;
int comparison=CMTimeCompare(captured,requested);
if(comparison==0)return true;
return comparison<0&&CMTIME_IS_NUMERIC(frame)&&frame.value>0&&!frame.epoch&&
CMTimeCompare(CMTimeSubtract(requested,captured),frame)<0;
}
#import <FxPlug/FxPlugSDK.h>
// Caller must already hold a custom parameter action. OSC events keep their
// provided time; this only normalizes the custom-view clock used to guard them.
static inline CMTime DYHostDisplayedFrameTime(id<PROAPIAccessing> host,CMTime current){
static inline CMTime DYHostDisplayedFrameTime(id<PROAPIAccessing> host,CMTime current,CMTime *frameDuration=nullptr){
id<FxTimingAPI_v4>timing=[host apiForProtocol:@protocol(FxTimingAPI_v4)];CMTime start=kCMTimeInvalid,duration=kCMTimeInvalid,frame=kCMTimeInvalid;
if([timing respondsToSelector:@selector(startTimeOfInputToFilter:)]&&[timing respondsToSelector:@selector(durationTimeOfInputToFilter:)]&&[timing respondsToSelector:@selector(frameDuration:)]){[timing startTimeOfInputToFilter:&start];[timing durationTimeOfInputToFilter:&duration];[timing frameDuration:&frame];}
if(frameDuration)*frameDuration=frame;
return DYScopeDisplayTime(current,start,duration,frame);
}
+6 -1
查看文件
@@ -1,6 +1,11 @@
#pragma once
#include "MaskCore/DYMaskOperator.h"
struct DYToolMaskEntry {DYResolvedMask mask;int section,combine;};
struct DYToolMaskEntry {
DYResolvedMask mask;
int section,combine;
// Image-normalized bounds of a detected face contour (section -100).
float minX,minY,maxX,maxY;
};
struct DYToolMaskHeader {unsigned count;float offsetX,offsetY,scaleX,scaleY;int section,premultiplied,faceOnly,skinPreview;};
struct DYToolStageRange {int first,last,suppressBlackWhite;};
@@ -111,11 +111,11 @@
run.record(@"workspace-final-output-worker-publishes-real-scope-rasters",[scopeData[@"waveform"]length]==320*256*4&&[scopeData[@"parade"]length]==3*320*256*4&&[scopeData[@"histogram"]length]==4*256*4&&[scopeData[@"vectorscope"]length]==256*256*4&&[scopeData[@"wholeImage"]boolValue]);
[scopeRenderer setScopeEnabled:NO];[scopeRenderer captureScopeTile:finalTile atTime:CMTimeMake(8,24)];workspaceDrain();DYScopeSample *hiddenSample=[scopeRenderer valueForKey:@"scopeLatest"];
run.record(@"workspace-hidden-scope-retains-only-one-small-final-sample-without-processing",[scopeRenderer.scopeMetadata isEqual:scopeData]&&hiddenSample.pixels.length==320*180*16&&[hiddenSample.metadata[@"timeValue"]longLongValue]==8&&![scopeRenderer valueForKey:@"scopePending"]);
[scopeRenderer setScopeEnabled:YES atTime:CMTimeMake(8,24)];scopeDeadline=NSProcessInfo.processInfo.systemUptime+5;while(!scopeRenderer.scopeMetadata&&NSProcessInfo.processInfo.systemUptime<scopeDeadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];
run.record(@"workspace-opening-paused-frame-replays-cached-final-output-without-render-or-parameter-edit",[scopeRenderer.scopeMetadata[@"timeValue"]longLongValue]==8&&scopeRenderer.scopePreview.length==320*180*16&&[scopeRenderer.scopeMetadata[@"vectorscope"]length]==256*256*4);
[scopeRenderer setScopeEnabled:NO];[scopeRenderer setScopeEnabled:YES atTime:CMTimeMake(9,24)];workspaceDrain();run.record(@"workspace-opening-another-time-never-presents-a-stale-frame",!scopeRenderer.scopeMetadata&&!scopeRenderer.scopePreview);
[scopeRenderer setScopeEnabled:YES atTime:CMTimeAdd(CMTimeMake(8,24),CMTimeMake(7,300)) frameDuration:CMTimeMake(1,24)];scopeDeadline=NSProcessInfo.processInfo.systemUptime+5;while(!scopeRenderer.scopeMetadata&&NSProcessInfo.processInfo.systemUptime<scopeDeadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];
run.record(@"workspace-opening-between-frame-boundaries-replays-current-final-output",[scopeRenderer.scopeMetadata[@"timeValue"]longLongValue]==8&&scopeRenderer.scopePreview.length==320*180*16&&[scopeRenderer.scopeMetadata[@"vectorscope"]length]==256*256*4);
[scopeRenderer setScopeEnabled:NO];[scopeRenderer setScopeEnabled:YES atTime:CMTimeMake(9,24) frameDuration:CMTimeMake(1,24)];workspaceDrain();run.record(@"workspace-opening-another-time-never-presents-a-stale-frame",!scopeRenderer.scopeMetadata&&!scopeRenderer.scopePreview);
[scopeRenderer captureScopeTile:finalTile atTime:CMTimeMake(9,24)];scopeDeadline=NSProcessInfo.processInfo.systemUptime+5;while(!scopeRenderer.scopeMetadata&&NSProcessInfo.processInfo.systemUptime<scopeDeadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];run.record(@"workspace-new-live-frame-replaces-rejected-cache",[scopeRenderer.scopeMetadata[@"timeValue"]longLongValue]==9);
DYWorkspaceDiagnosticRenderer *otherScope=[[[DYWorkspaceDiagnosticRenderer alloc]init]autorelease];[otherScope setScopeEnabled:YES atTime:CMTimeMake(9,24)];workspaceDrain();run.record(@"workspace-scope-cache-never-crosses-plugin-instances",!otherScope.scopeMetadata&&!otherScope.scopePreview);
DYWorkspaceDiagnosticRenderer *otherScope=[[[DYWorkspaceDiagnosticRenderer alloc]init]autorelease];[otherScope setScopeEnabled:YES atTime:CMTimeMake(9,24) frameDuration:CMTimeMake(1,24)];workspaceDrain();run.record(@"workspace-scope-cache-never-crosses-plugin-instances",!otherScope.scopeMetadata&&!otherScope.scopePreview);
[otherScope setScopeEnabled:NO];[scopeRenderer setScopeEnabled:NO];
// The spider reuses the same frame, including when the full scopes are closed.
+2 -2
查看文件
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.21.0</string>
<string>1.21.1</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>PlugInKit</key>
+2 -2
查看文件
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.21.0</string>
<string>1.21.1</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
+8
查看文件
@@ -2,6 +2,14 @@
更新于 2026-11-08(Asia/Shanghai)。这是新对话的接手入口。历史设计和实现细节按需查阅专项交接,复现和交付证据以对应版本的报告为准。
## 1.21.1(115)首次示波器与人脸肤色保护
用户反馈首次打开控制面板没有波形、人脸相关预览卡顿。控制面板从宿主动作读取当前时间,并按帧长验证本效果实例最后一次最终输出。缓存时间相同或播放头仍在该帧区间时立即送测量队列,下一帧边界等待对应渲染。参数写入与蜘蛛盘仍用原时间规则。
Skin 的 Vision 轮廓、眼眉嘴排除及强度沿用原算法。Metal 先检查实际轮廓外接范围,外部跳过多边形计算,无覆盖时跳过五官权重;按需读取设备端路径。人脸马赛克仍独立检测每个不同画面的矩形。4K 活跃人脸肤色保护旧版中位 1176.07 ms,其中取样及 Vision 平均 10.73 ms,主要耗时在逐像素轮廓。M4 同一公开人像的 12 帧中位数降至 21.78 ms,1080p 从 308.08 降至 10.07 ms;六组末帧 SHA-256 完全一致。以上是渲染器耗时。
两个 Release 目标进入正式交付,等待已公证版本的原生自检及 FCP 暂停首开验收,再打包和发布。既有项目文件的 Security 引用排序未纳入本轮。
## 1.21.0(114)流畅性优化
按首帧、连续渲染和检查器刷新优化。Metal 管线首次使用才创建,中性画面跳过通用调色与查找纹理,保留原来的半精度透明度规则;无蒙版 CST 将解除预乘并入原转换内核。最终画面取样合并进输出命令并复用小缓冲,仍保留暂停帧的示波器样本。检查器复用本轮的宿主读参和工具文档,只在切换色彩管理模式时移动输出控件。胶片颗粒未参与时省去宿主帧时序查询。