Add reproducible default-preview benchmark before renderer fix
这个提交包含在:
1 父节点
5bf2a8428a
当前提交
b3597bb4e4
2 个文件已更改
+61
没有与搜索条件相匹配的文件
@@ -0,0 +1,41 @@
|
||||
// Headless renderer benchmark. Link against the reviewed Release objects; never
|
||||
// registers a plug-in, opens a host, or reads user media. Resources are read-only.
|
||||
#import "../大鱼调色/Plugin/DYRenderer.h"
|
||||
#import "../大鱼调色/Plugin/DYModel.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@interface DYDiagnosticTile : FxImageTile
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height;
|
||||
@end
|
||||
@interface DYRenderer (PerformanceProbe)
|
||||
- (void)prepareFaceSupport:(FxImageTile*)source;
|
||||
@end
|
||||
static NSUInteger faceCalls=0;
|
||||
@interface DYPreviewBenchmarkRenderer : DYRenderer
|
||||
@end
|
||||
@implementation DYPreviewBenchmarkRenderer
|
||||
- (void)prepareFaceSupport:(FxImageTile*)source {faceCalls++;[super prepareFaceSupport:source];}
|
||||
@end
|
||||
int main(int argc,const char*argv[]){@autoreleasepool{
|
||||
id<MTLDevice> gpu=MTLCreateSystemDefaultDevice();NSMutableArray *rows=[NSMutableArray array];
|
||||
for(int width:{1920,3840}){@autoreleasepool{
|
||||
int height=width*9/16;DYDiagnosticTile *src=[[DYDiagnosticTile alloc]initWithDevice:gpu width:width height:height],*dst=[[DYDiagnosticTile alloc]initWithDevice:gpu width:width height:height];
|
||||
std::vector<__fp16> pixels(width*height*4);for(int y=0;y<height;y++)for(int x=0;x<width;x++){int p=(y*width+x)*4;pixels[p]=(__fp16)(.03+.8*x/width);pixels[p+1]=(__fp16)(.03+.6*y/height);pixels[p+2]=.2;pixels[p+3]=1;}
|
||||
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;
|
||||
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.
|
||||
pixels[0]=(__fp16)(.05+i*.01);[input replaceRegion:MTLRegionMake2D(0,0,1,1) mipmapLevel:0 withBytes:pixels.data() bytesPerRow: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);
|
||||
}}
|
||||
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];
|
||||
}}[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;
|
||||
}}
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
"""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()
|
||||
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)
|
||||
(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')]
|
||||
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)
|
||||
print(a.output)
|
||||
在新工单中引用
屏蔽一个用户