fix: orient LUT thumbnails to host image origin without changing auto analysis
这个提交包含在:
1 父节点
2e7ab4b052
当前提交
dde98c8836
6 个文件已更改
+77
-14
没有与搜索条件相匹配的文件
+34
-2
@@ -50,8 +50,10 @@
|
||||
IOSurfaceRef _surface;
|
||||
FxRect _bounds;
|
||||
uint64_t _registry;
|
||||
FxImageOrigin _diagnosticOrigin;
|
||||
}
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height;
|
||||
- (void)setDiagnosticImageOrigin:(FxImageOrigin)origin;
|
||||
@end
|
||||
@implementation DYDiagnosticTile
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height {
|
||||
@@ -63,7 +65,7 @@
|
||||
MTLTextureDescriptor *d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:width height:height mipmapped:NO];
|
||||
d.storageMode=MTLStorageModeShared;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;
|
||||
if(_surface)_texture=[device newTextureWithDescriptor:d iosurface:_surface plane:0];
|
||||
_bounds=(FxRect){0,0,(SInt32)width,(SInt32)height};_registry=device.registryID;
|
||||
_bounds=(FxRect){0,0,(SInt32)width,(SInt32)height};_registry=device.registryID;_diagnosticOrigin=kFxImageOrigin_TOP_LEFT;
|
||||
if(!_surface||!_texture){[self release];return nil;}
|
||||
}return self;
|
||||
}
|
||||
@@ -73,7 +75,8 @@
|
||||
- (FxRect)tilePixelBounds {return _bounds;}
|
||||
- (FxRect)imagePixelBounds {return _bounds;}
|
||||
- (uint64_t)deviceRegistryID {return _registry;}
|
||||
- (FxImageOrigin)imageOrigin {return kFxImageOrigin_TOP_LEFT;}
|
||||
- (FxImageOrigin)imageOrigin {return _diagnosticOrigin;}
|
||||
- (void)setDiagnosticImageOrigin:(FxImageOrigin)origin {_diagnosticOrigin=origin;}
|
||||
@end
|
||||
|
||||
namespace {
|
||||
@@ -146,6 +149,35 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
NSData *preview=[renderer preview];bool previewFinite=preview.length==320*180*16;if(previewFinite){const float *data=(const float *)preview.bytes;for(NSUInteger i=0;i<preview.length/4;i++)previewFinite&=std::isfinite(data[i]);}
|
||||
run.record(@"renderer-analysis-320x180",previewFinite,@{@"bytes":@(preview.length)});
|
||||
NSDictionary *autoGrade=DYAutoGrade(preview);run.record(@"renderer-auto-grade-integration",autoGrade.count==10,autoGrade?:@{});
|
||||
// Vertical red/blue markers establish actual Metal texture row order.
|
||||
// Browser bitmaps need top-first rows; the auto-analysis bytes must not
|
||||
// be changed even when FxPlug supplies a bottom-left source texture.
|
||||
Pixels marker(width*height*4),bottomFirst(marker.size());
|
||||
for(NSUInteger y=0;y<height;y++)for(NSUInteger x=0;x<width;x++){
|
||||
size_t p=(y*width+x)*4;marker[p]=y<height/2?.8f:.03f;marker[p+1]=.04f+.1f*float(x)/(width-1);marker[p+2]=y<height/2?.02f:.7f;marker[p+3]=1;
|
||||
}
|
||||
for(NSUInteger y=0;y<height;y++)memcpy(bottomFirst.data()+y*width*4,marker.data()+(height-1-y)*width*4,width*8);
|
||||
DYRenderer *orientationRenderer=[[[DYRenderer alloc]init]autorelease];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:marker.data() bytesPerRow:width*8];
|
||||
error=nil;BOOL topRendered=[orientationRenderer renderSource:source destination:destination uniforms:defaults paths:@{} error:&error];
|
||||
NSData *topAnalysis=[orientationRenderer preview],*topLook=[orientationRenderer lookLUTPreview];
|
||||
bool topOrientation=topRendered&&topLook.length==320*180*16&&[topLook isEqualToData:topAnalysis];
|
||||
if(topOrientation){const float*p=(const float*)topLook.bytes;topOrientation=p[0]>p[2]&&p[(179*320)*4+2]>p[(179*320)*4];}
|
||||
run.record(@"look-preview-top-left-is-original-analysis",topOrientation,@{@"error":topRendered?@"":reason(error),@"bytes":@(topLook.length)});
|
||||
[orientationRenderer invalidatePreview];[source setDiagnosticImageOrigin:kFxImageOrigin_BOTTOM_LEFT];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:bottomFirst.data() bytesPerRow:width*8];
|
||||
error=nil;BOOL bottomRendered=[orientationRenderer renderSource:source destination:destination uniforms:defaults paths:@{} error:&error];
|
||||
NSData *bottomAnalysis=[orientationRenderer preview],*bottomLook=[orientationRenderer lookLUTPreview];
|
||||
bool bottomOrientation=bottomRendered&&bottomAnalysis.length==320*180*16&&bottomLook.length==bottomAnalysis.length;
|
||||
if(bottomOrientation){
|
||||
const float*a=(const float*)bottomAnalysis.bytes,*b=(const float*)bottomLook.bytes;
|
||||
bottomOrientation=a[2]>a[0]&&a[(179*320)*4]>a[(179*320)*4+2]&&b[0]>b[2]&&b[(179*320)*4+2]>b[(179*320)*4];
|
||||
for(NSUInteger y=0;y<180&&bottomOrientation;y++)bottomOrientation=memcmp((const uint8_t*)bottomLook.bytes+y*320*16,(const uint8_t*)bottomAnalysis.bytes+(179-y)*320*16,320*16)==0;
|
||||
}
|
||||
run.record(@"look-preview-bottom-left-flips-only-browser-rows",bottomOrientation,@{@"error":bottomRendered?@"":reason(error),@"analysisKeepsPhysicalRowOrder":@(bottomOrientation),@"all180RowsCompared":@(bottomOrientation)});
|
||||
[orientationRenderer invalidatePreview];run.record(@"preview-invalidation-clears-analysis-and-browser",![orientationRenderer preview]&&![orientationRenderer lookLUTPreview]);
|
||||
[source setDiagnosticImageOrigin:kFxImageOrigin_TOP_LEFT];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:input.data() bytesPerRow:width*8];
|
||||
DYUniforms u=defaults;u.exposure=.8f;Pixels exposed=render(run,renderer,source,destination,gpu,u,@{},@"renderer-exposure-pass");Difference exposureDifference=difference(neutral,exposed);run.record(@"exposure-affects-actual-frame",exposureDifference.nonfinite==0&&exposureDifference.different>100,measure(exposureDifference));
|
||||
u.baseSectionEnabled=0;Pixels bypass=render(run,renderer,source,destination,gpu,u,@{},@"renderer-base-bypass-pass");Difference bypassDifference=difference(neutral,bypass);run.record(@"base-group-bypass",bypassDifference.nonfinite==0&&bypassDifference.maximum==0,measure(bypassDifference));
|
||||
u=defaults;u.temperature=35;u.tint=-20;Pixels wb=render(run,renderer,source,destination,gpu,u,@{},@"renderer-white-balance-pass");Difference wbDifference=difference(neutral,wb);run.record(@"white-balance-real-table-frame",wbDifference.nonfinite==0&&wbDifference.different>100,measure(wbDifference));
|
||||
|
||||
+22
-6
@@ -13,7 +13,7 @@ static NSColor *DYAccent(void) { return DYThemeColor(@"accent"); }
|
||||
static NSColor *DYInk(void) { return DYThemeColor(@"text"); }
|
||||
static NSTextField *DYLabel(NSString *text, CGFloat size) {
|
||||
NSTextField *v=[NSTextField labelWithString:text?:@""];
|
||||
v.font=[NSFont systemFontOfSize:size weight:size==11?NSFontWeightMedium:NSFontWeightRegular]; v.textColor=DYInk();
|
||||
v.font=[NSFont systemFontOfSize:size weight:size==11?NSFontWeightMedium:NSFontWeightRegular]; v.textColor=DYThemeColor(@"slot15");
|
||||
v.lineBreakMode=NSLineBreakByTruncatingTail;
|
||||
return v;
|
||||
}
|
||||
@@ -29,10 +29,26 @@ static NSString *DYNumber(double value,NSDictionary *d) {
|
||||
}
|
||||
|
||||
|
||||
@interface DYBlueSliderCell : NSSliderCell @end
|
||||
@interface DYBlueSliderCell : NSSliderCell
|
||||
@property(copy) NSString *colorKey;
|
||||
@end
|
||||
@implementation DYBlueSliderCell
|
||||
- (void)dealloc {[_colorKey release];[super dealloc];}
|
||||
- (NSArray *)trackColors {
|
||||
if([_colorKey isEqual:@"temperature"])return @[[NSColor colorWithSRGBRed:.21 green:.45 blue:1 alpha:1],[NSColor colorWithSRGBRed:1 green:.78 blue:.27 alpha:1]];
|
||||
if([_colorKey isEqual:@"tint"])return @[[NSColor colorWithSRGBRed:.2 green:.85 blue:.36 alpha:1],[NSColor colorWithSRGBRed:.95 green:.23 blue:.88 alpha:1]];
|
||||
if([_colorKey isEqual:@"vibrance"]||[_colorKey isEqual:@"saturation"])return @[[NSColor colorWithWhite:.45 alpha:1],NSColor.systemYellowColor,NSColor.systemGreenColor,NSColor.systemBlueColor,NSColor.systemPinkColor];
|
||||
int axis=0,color=0;if(sscanf(_colorKey.UTF8String?:"","hsl%d_%d",&axis,&color)==2){
|
||||
double hue=((double[]){0,.08,.16,.33,.5,.61,.76,.9})[MAX(0,MIN(7,color))];NSColor *center=[NSColor colorWithCalibratedHue:hue saturation:.85 brightness:1 alpha:1];
|
||||
if(axis==0)return @[[NSColor colorWithCalibratedHue:fmod(hue+.9,1) saturation:.9 brightness:1 alpha:1],center,[NSColor colorWithCalibratedHue:fmod(hue+.1,1) saturation:.9 brightness:1 alpha:1]];
|
||||
if(axis==1)return @[[NSColor colorWithWhite:.45 alpha:1],center];
|
||||
return @[[NSColor blackColor],center,[center blendedColorWithFraction:.65 ofColor:NSColor.whiteColor]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped {
|
||||
NSRect track=NSMakeRect(rect.origin.x,NSMidY(rect)-2.5,rect.size.width,5);
|
||||
NSArray *colors=[self trackColors];if(colors){NSGradient *g=[[[NSGradient alloc]initWithColors:colors]autorelease];[g drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:track xRadius:2.5 yRadius:2.5] angle:0];return;}
|
||||
NSBezierPath *bar=[NSBezierPath bezierPathWithRoundedRect:track xRadius:2.5 yRadius:2.5];NSGradient *base=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"slot8"] endingColor:DYThemePalette()[@"slot9"]]autorelease];[base drawInBezierPath:bar angle:90];[[NSColor colorWithWhite:0 alpha:.28]setStroke];bar.lineWidth=.6;[bar stroke];
|
||||
double fraction=(self.doubleValue-self.minValue)/fmax(.000001,self.maxValue-self.minValue);
|
||||
NSRect active=track;active.size.width*=fmax(0,fmin(1,fraction));NSGradient *g=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"activeTop"] endingColor:DYThemePalette()[@"activeBottom"]]autorelease];[g drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:active xRadius:2 yRadius:2] angle:90];
|
||||
@@ -384,7 +400,7 @@ static NSImage *DYWheelImage(void) {
|
||||
self.wantsLayer=YES; self.layer.masksToBounds=YES;
|
||||
self.layer.backgroundColor=[DYThemePalette()[@"background"] CGColor];
|
||||
self.appearance=[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
||||
_brand=[DYLabel(@"◒ 大鱼调色",16) retain]; _brand.font=[NSFont boldSystemFontOfSize:16];
|
||||
_brand=[DYLabel(@"◒ 大鱼调色",16) retain]; _brand.font=[NSFont boldSystemFontOfSize:16];_brand.textColor=DYInk();
|
||||
_subtitle=[DYLabel(@"1.1",9) retain]; _subtitle.textColor=DYThemeColor(@"secondary");
|
||||
_resetAll=[DYButton(@"↺",self,@selector(resetAll:)) retain];_resetAll.bordered=NO; _resetAll.toolTip=@"恢复全部调色参数与 LUT";_resetAll.accessibilityLabel=@"全部还原";
|
||||
_save=[DYButton(@"保存预设",self,@selector(savePreset:)) retain];
|
||||
@@ -454,7 +470,7 @@ static NSImage *DYWheelImage(void) {
|
||||
[self setNeedsLayout:YES];NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification);
|
||||
}
|
||||
- (void)addLook:(id)sender {_visibleLooks=MIN(5,_visibleLooks+1);[self setNeedsLayout:YES];}
|
||||
- (void)previewChanged:(NSNotification *)note {if(_browser.visible)[_browser updatePreview:[_renderer preview]];}
|
||||
- (void)previewChanged:(NSNotification *)note {if(_browser.visible)[_browser updatePreview:[_renderer lookLUTPreview]];}
|
||||
- (void)buildCards {
|
||||
NSInteger index=0;
|
||||
for(NSDictionary *section in _sections) {
|
||||
@@ -533,7 +549,7 @@ static NSImage *DYWheelImage(void) {
|
||||
popup.accessibilityLabel=d[@"title"]; [row addSubview:popup]; record[@"popup"]=popup;
|
||||
} else {
|
||||
NSSlider *slider=[[[NSSlider alloc]initWithFrame:NSZeroRect]autorelease];
|
||||
DYBlueSliderCell *sliderCell=[[[DYBlueSliderCell alloc]init]autorelease];slider.cell=sliderCell;
|
||||
DYBlueSliderCell *sliderCell=[[[DYBlueSliderCell alloc]init]autorelease];sliderCell.colorKey=d[@"key"];slider.cell=sliderCell;
|
||||
slider.minValue=[d[@"min"]doubleValue];slider.maxValue=[d[@"max"]doubleValue];slider.doubleValue=[d[@"default"]doubleValue];slider.target=self;slider.action=@selector(scalarChanged:);
|
||||
slider.tag=[pid integerValue]; slider.continuous=YES; slider.controlSize=NSControlSizeSmall;
|
||||
slider.accessibilityLabel=d[@"title"]; [row addSubview:slider]; record[@"slider"]=slider;
|
||||
@@ -808,7 +824,7 @@ static NSImage *DYWheelImage(void) {
|
||||
[_browser close];[_browser release];_browser=nil;
|
||||
id<FxCustomParameterActionAPI_v4> a=[self actionAPI];if(!a)return;[a startAction:self];NSString *selected=nil;@try{selected=[DYReadAssets(_manager,a.currentTime).paths[sender.identifier]copy];}@finally{[a endAction:self];}
|
||||
__block DYInspector *owner=self;NSString *key=[[sender.identifier copy]autorelease];
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer preview] selectedPath:selected palette:DYThemePalette() selection:^(NSString *path){[owner setAssetPath:path forKey:key];}];[selected release];
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreview] selectedPath:selected palette:DYThemePalette() selection:^(NSString *path){[owner setAssetPath:path forKey:key];}];[selected release];
|
||||
id<FxRemoteWindowAPI> remote=[_manager apiForProtocol:@protocol(FxRemoteWindowAPI_v3)];
|
||||
if(!remote)remote=[_manager apiForProtocol:@protocol(FxRemoteWindowAPI_v2)];if(!remote)remote=[_manager apiForProtocol:@protocol(FxRemoteWindowAPI)];
|
||||
DYLUTBrowser *browser=_browser;id<FxRemoteWindowAPI_v3> closer=[_manager apiForProtocol:@protocol(FxRemoteWindowAPI_v3)];
|
||||
|
||||
@@ -6,5 +6,8 @@
|
||||
- (BOOL)renderSource:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
|
||||
- (NSData*)preview;
|
||||
/// Display-encoded float RGBA, 320×180, with the visually top row first.
|
||||
/// Analysis preview retains the host texture's original row order separately.
|
||||
- (NSData*)lookLUTPreview;
|
||||
- (void)invalidatePreview;
|
||||
@end
|
||||
+16
-4
@@ -11,15 +11,16 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
|
||||
@interface DYRenderer(){
|
||||
NSMutableDictionary *_devices,*_luts;
|
||||
DYColorTables *_tables;
|
||||
NSData *_preview;
|
||||
NSData *_preview,*_lookLUTPreview;
|
||||
CFTimeInterval _lastPreview;
|
||||
}
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
- (instancetype)init{if((self=[super init])){_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_devices release];[_luts release];[_tables release];[_preview release];[super dealloc];}
|
||||
- (void)invalidatePreview{@synchronized(self){[_preview release];_preview=nil;_lastPreview=0;}}
|
||||
- (void)dealloc{[_devices release];[_luts release];[_tables release];[_preview release];[_lookLUTPreview release];[super dealloc];}
|
||||
- (void)invalidatePreview{@synchronized(self){[_preview release];_preview=nil;[_lookLUTPreview release];_lookLUTPreview=nil;_lastPreview=0;}}
|
||||
- (NSData*)preview{@synchronized(self){return [[_preview retain]autorelease];}}
|
||||
- (NSData*)lookLUTPreview{@synchronized(self){return [[_lookLUTPreview retain]autorelease];}}
|
||||
- (NSMutableDictionary*)device:(uint64_t)registry error:(NSError**)err{
|
||||
NSNumber*k=@(registry);NSMutableDictionary*entry=_devices[k];if(entry)return entry;
|
||||
id<MTLDevice>d=nil;NSArray*all=MTLCopyAllDevices();for(id<MTLDevice>candidate in all)if(candidate.registryID==registry||!registry){d=[candidate retain];break;}[all release];if(!d){fail(err,@"宿主的 Metal 设备不可用");return nil;}
|
||||
@@ -60,7 +61,18 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
|
||||
DYVertex2D vs[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};
|
||||
if(dst.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(int i=0;i<4;i++)vs[i].position.y=-vs[i].position.y;
|
||||
vector_uint2 vp={(unsigned)output.width,(unsigned)output.height};[re setVertexBytes:vs length:sizeof(vs) atIndex:0];[re setVertexBytes:&vp length:sizeof(vp) atIndex:1];[re setViewport:(MTLViewport){0,0,w,h,0,1}];[re setFragmentTexture:straight atIndex:0];for(NSUInteger i=0;i<ts.count;i++)[re setFragmentTexture:ts[i] atIndex:i+1];[re setFragmentBytes:&u length:sizeof(u) atIndex:0];[re setFragmentBuffer:scene offset:0 atIndex:1];DYRenderOptions options={1,0,0,0};[re setFragmentBytes:&options length:sizeof(options) atIndex:2];[re drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];[re endEncoding];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted;
|
||||
if(ok&&pb){[_preview release];_preview=[[NSData alloc]initWithBytes:pb.contents length:320*180*16];_lastPreview=CACurrentMediaTime();dispatch_async(dispatch_get_main_queue(),^{[[NSNotificationCenter defaultCenter]postNotificationName:@"DYPreviewDidChange" object:self];});}
|
||||
if(ok&&pb){
|
||||
[_preview release];_preview=[[NSData alloc]initWithBytes:pb.contents length:320*180*16];
|
||||
// The analysis kernel reads physical texture rows. Its result remains intact
|
||||
// for auto grade; only the browser copy is normalized to top-first bitmap rows.
|
||||
[_lookLUTPreview release];
|
||||
if(src.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){
|
||||
const NSUInteger rowBytes=320*16;NSMutableData*topFirst=[NSMutableData dataWithLength:_preview.length];
|
||||
for(NSUInteger y=0;y<180;y++)memcpy((uint8_t*)topFirst.mutableBytes+y*rowBytes,(const uint8_t*)_preview.bytes+(179-y)*rowBytes,rowBytes);
|
||||
_lookLUTPreview=[topFirst copy];
|
||||
}else _lookLUTPreview=[_preview retain];
|
||||
_lastPreview=CACurrentMediaTime();dispatch_async(dispatch_get_main_queue(),^{[[NSNotificationCenter defaultCenter]postNotificationName:@"DYPreviewDidChange" object:self];});
|
||||
}
|
||||
if(!ok)fail(err,cb.error.localizedDescription);[pb release];[straight release];[scene release];return ok;
|
||||
}}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{@synchronized(self){
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4</string>
|
||||
<string>5</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4</string>
|
||||
<string>5</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户