Support text-annotated Cube rows with Custom LUT zero-fill compatibility

这个提交包含在:
mac 于 2026-11-02 20:13:29 +08:00 提交
1 父节点 5c547100c1
当前提交 58a17de438
10 个文件已更改
+1307 -1072

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

+23
查看文件
@@ -362,6 +362,29 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
run.record(@"analysis-applies-selected-input-LUT",analysisDifferent&&analysisChanges>100,@{@"changedComponents":@(analysisChanges),@"maxAbsoluteError":@(analysisMaximum)});
NSString *lookFile=[runtime stringByAppendingPathComponent:@"diagnostic-look.cube"];NSMutableString *cube=[NSMutableString stringWithString:@"TITLE \"Self test look\"\nLUT_3D_SIZE 2\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];
for(int b=0;b<2;b++)for(int g=0;g<2;g++)for(int r=0;r<2;r++)[cube appendFormat:@"%.8f %.8f %.8f\n",.7f*r+.1f,.8f*g+.05f,.85f*b+.02f];error=nil;run.need(@"temporary-look-file",[cube writeToFile:lookFile atomically:YES encoding:NSUTF8StringEncoding error:&error],@{@"error":reason(error)});
NSString *noteFile=[runtime stringByAppendingPathComponent:@"noted.cube"],*noteOracle=[runtime stringByAppendingPathComponent:@"note-oracle.cube"];
NSString *noteRows=@"LUT_3D_SIZE 2\n0.25 v3文字 100 分\n1 0 说明99\n0 1 0 后记123\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n";
NSString *oracleRows=@"LUT_3D_SIZE 2\n0.25 0 0\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n";
run.need(@"lut-note-fixtures",[noteRows writeToFile:noteFile atomically:YES encoding:NSUTF8StringEncoding error:&error]&&[oracleRows writeToFile:noteOracle atomically:YES encoding:NSUTF8StringEncoding error:&error]);
std::vector<float> notedTable,oracleTable;NSUInteger notedSide=0,oracleSide=0;
run.record(@"lut-note-retains-prefix-zero-fills-without-row-shift",DYLUTReadCube(noteFile,notedTable,notedSide,&error)&&DYLUTReadCube(noteOracle,oracleTable,oracleSide,&error)&&notedSide==2&&oracleSide==2&&notedTable==oracleTable);
u=defaults;u.lookSectionEnabled=1;u.postLUTStrength=1;
Pixels notePixels=render(run,renderer,source,destination,gpu,u,@{@"look0":noteFile},@"lut-note-metal-render");
Pixels oraclePixels=render(run,renderer,source,destination,gpu,u,@{@"look0":noteOracle},@"lut-note-oracle-metal-render");
Difference noteDelta=difference(notePixels,oraclePixels);run.record(@"lut-note-metal-exact-canonical-colors",noteDelta.nonfinite==0&&noteDelta.maximum==0,measure(noteDelta));
NSString *userLUT=NSProcessInfo.processInfo.environment[@"DY_DIAGNOSTIC_LUT_FILE"],*userOracle=NSProcessInfo.processInfo.environment[@"DY_DIAGNOSTIC_LUT_ORACLE"];
if(userLUT.length&&userOracle.length){
NSData *original=[NSData dataWithContentsOfFile:userLUT];DYLUTLibrary *isolated=[[[DYLUTLibrary alloc]initWithRootURL:[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"user-lut-library"]]]autorelease];
NSArray *items=[isolated importURLs:@[[NSURL fileURLWithPath:userLUT]] error:&error];
run.need(@"user-lut-isolated-import",items.count==1,@{@"error":reason(error)});
NSString *imported=items[0][@"path"];std::vector<float> userTable,userExpected;NSUInteger userSide=0,expectedSide=0;
run.record(@"user-lut-exact-canonical-table",DYLUTReadCube(imported,userTable,userSide,&error)&&DYLUTReadCube(userOracle,userExpected,expectedSide,&error)&&userSide==expectedSide&&userTable==userExpected,@{@"dimension":@(userSide),@"rows":@(userTable.size()/4)});
run.record(@"user-lut-thumbnail",DYLUTThumbnail(imported,nil,0,0,NSMakeSize(160,90),&error)!=nil);
Pixels actual=render(run,renderer,source,destination,gpu,u,@{@"look0":imported},@"user-lut-metal-render");
Pixels expected=render(run,renderer,source,destination,gpu,u,@{@"look0":userOracle},@"user-lut-oracle-metal-render");
Difference delta=difference(actual,expected);run.record(@"user-lut-metal-exact-canonical-colors",delta.nonfinite==0&&delta.maximum==0,measure(delta));
run.record(@"user-lut-original-and-import-bytes-preserved",original&&[original isEqual:[NSData dataWithContentsOfFile:userLUT]]&&[original isEqual:[NSData dataWithContentsOfFile:imported]]);
}
NSDictionary *paths=@{@"look0":lookFile,@"look1":lookFile,@"look2":lookFile,@"look3":lookFile,@"look4":lookFile};u=defaults;u.lookSectionEnabled=1;u.postLUTStrength=.35f;u.extraPostLUTStrengths=(DYFloat4){.4f,.5f,.6f,.7f};Pixels looks=render(run,renderer,source,destination,gpu,u,paths,@"renderer-five-look-pass");Difference looksDifference=difference(neutral,looks);run.record(@"five-look-mixes-affect-frame",looksDifference.nonfinite==0&&looksDifference.different>100,measure(looksDifference));
checkFoldedGroup(u,offsetof(DYUniforms,lookSectionEnabled),paths,@"disabled-look-bypasses-retained-LUTs");
NSURL *exportURL=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"diagnostic-export.cube"]];error=nil;run.need(@"renderer-export-33cube",[renderer exportLUT:exportURL uniforms:u paths:paths error:&error],@{@"error":reason(error),@"path":exportURL.path});