Add tracked clone stamps and reduce canvas redraw work
这个提交包含在:
1 父节点
504e08e425
当前提交
0782b5e654
17 个文件已更改
+347
-53
没有与搜索条件相匹配的文件
@@ -58,3 +58,45 @@ if(faceFixture.length){
|
||||
DYDiagnosticTile *twoSource=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:1024 height:512]autorelease],*twoDest=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:1024 height:512]autorelease];Pixels two(1024*512*4);for(NSUInteger y=0;y<512;y++)for(NSUInteger x=0;x<1024;x++)memcpy(two.data()+(y*1024+x)*4,portrait.data()+(y*512+x%512)*4,8);[[twoSource metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,1024,512)mipmapLevel:0 withBytes:two.data()bytesPerRow:1024*8];u.skinProtection.x=1;BOOL twoOK=[face renderSource:twoSource destination:twoDest uniforms:u paths:@{}error:&maskError];NSData *twoEntries=[face valueForKey:@"faceEntries"];const DYToolMaskEntry *twoMasks=(const DYToolMaskEntry*)twoEntries.bytes;NSInteger faceCount=0;for(NSUInteger i=0;i<twoEntries.length/sizeof(*twoMasks);i++)faceCount+=twoMasks[i].section==-100;run.record(@"face-multiple-people-build-independent-support-regions",twoOK&&faceCount==2,@{@"faces":@(faceCount)});
|
||||
Pixels noFace(w*h*4);for(NSUInteger i=0;i<w*h;i++){noFace[i*4]=.35;noFace[i*4+1]=.18;noFace[i*4+2]=.1;noFace[i*4+3]=1;}upload(noFace);u.skinVisualize=0;Pixels noFaceProtected=render(run,face,src,dst,gpu,u,@{},@"face-none-protected-render");u.skinProtection.x=0;Pixels noFacePlain=render(run,face,src,dst,gpu,u,@{},@"face-none-unprotected-reference");run.record(@"face-no-detection-clears-prior-frame-and-fails-closed",difference(noFaceProtected,noFacePlain).maximum<.002);
|
||||
}
|
||||
|
||||
|
||||
// Verify the real Metal input stage with a moving target and a fixed source.
|
||||
{
|
||||
const NSUInteger w=64,h=48;
|
||||
DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease];
|
||||
DYDiagnosticTile *dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease];
|
||||
Pixels input(w*h*4);
|
||||
for(NSUInteger y=0;y<h;y++)for(NSUInteger x=0;x<w;x++){
|
||||
NSUInteger i=(y*w+x)*4;
|
||||
input[i]=x/128.f;input[i+1]=y/96.f;input[i+2]=.15f;input[i+3]=1;
|
||||
}
|
||||
[[src metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,w,h) mipmapLevel:0 withBytes:input.data() bytesPerRow:w*8];
|
||||
DYRenderer *renderer=[[[DYRenderer alloc]init]autorelease];
|
||||
DYUniforms u=DYToolUniforms(@{@"type":@"lens"});
|
||||
Pixels baseline=render(run,renderer,src,dst,gpu,u,@{},@"clone-stamp-reference-render");
|
||||
NSMutableDictionary *doc=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);
|
||||
NSMutableDictionary *stamp=(id)DYAddSharedMask(doc,DYMaskEllipse);
|
||||
DYMaskParameters p=DYMaskAtTime(stamp,kCMTimeZero);
|
||||
p.centerX=48.5f/w;p.centerY=24.5f/h;p.width=.25f;p.height=.25f;
|
||||
stamp[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];
|
||||
stamp[@"stampSource"]=@[@(16.5f/w),@(12.5f/h),@.25,@.25];
|
||||
CMTime next=CMTimeMake(1,25);DYMaskParameters moved=p;moved.centerY=34.5f/h;
|
||||
run.record(@"clone-stamp-preserves-source-through-tracking-merge",DYMergeTracking(stamp,@[DYMaskKey(kCMTimeZero,p,NO,1),DYMaskKey(next,moved,NO,1)])&&[stamp[@"stampSource"] count]==4);
|
||||
auto frame=[&](CMTime t,NSString *label){
|
||||
NSError *failure=nil;
|
||||
BOOL ok=[renderer renderSource:src destination:dst uniforms:u paths:@{} spider:nil tools:DYToolRenderSnapshot(doc,t) colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&failure];
|
||||
run.need(label,ok,@{@"error":reason(failure)});return read(dst,gpu);
|
||||
};
|
||||
auto pixel=[&](const Pixels &a,NSUInteger x,NSUInteger y,const Pixels &b,NSUInteger u,NSUInteger v){
|
||||
double delta=0;for(int c=0;c<4;c++)delta=MAX(delta,fabs((float)a[(y*w+x)*4+c]-(float)b[(v*w+u)*4+c]));return delta;
|
||||
};
|
||||
Pixels first=frame(kCMTimeZero,@"clone-stamp-production-render");
|
||||
run.record(@"clone-stamp-copies-pixels-and-leaves-exterior-intact",pixel(first,48,24,baseline,16,12)<.002&&pixel(first,0,0,baseline,0,0)==0&&pixel(first,16,12,baseline,16,12)==0);
|
||||
Pixels second=frame(next,@"clone-stamp-tracked-production-render");
|
||||
run.record(@"clone-stamp-tracked-target-moves-while-sampling-the-same-source",pixel(second,48,34,baseline,16,12)<.002&&pixel(second,48,24,baseline,48,24)==0);
|
||||
stamp[@"enabled"]=@NO;Pixels disabled=frame(next,@"clone-stamp-disabled-render");
|
||||
run.record(@"clone-stamp-disabled-is-identical",difference(disabled,baseline).maximum==0);
|
||||
stamp[@"enabled"]=@YES;NSError *failure=nil;
|
||||
NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"unsupported-clone.cube"]];
|
||||
run.record(@"clone-stamp-spatial-state-refuses-static-cube-export",![renderer exportLUT:cube uniforms:u paths:@{} spider:nil tools:doc error:&failure]&&failure);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户