WIP: native per-layer controls, host OSC and Metal mask tracking; GPU and callback regressions added, formal host acceptance pending

这个提交包含在:
mac 于 2026-11-01 21:49:38 +08:00 提交
1 父节点 f72aa2609d
当前提交 cec044f124
26 个文件已更改
+475 -40

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

+6 -3
查看文件
@@ -12,12 +12,13 @@ static BOOL fail(NSError**e,NSString*m){if(e)*e=[NSError errorWithDomain:@"com.d
static NSArray *inputFiles(){return @[@"",@"apple_log_to_rec709",@"arri_logc3_to_rec709",@"arri_logc4_to_rec709",@"blackmagic_film_gen5_to_rec709",@"canon_clog_bt709_to_rec709",@"canon_clog2_cinema_gamut_to_rec709",@"canon_clog3_cinema_gamut_to_rec709",@"dji_dlog_to_rec709",@"dji_dlog_m_to_rec709",@"fujifilm_flog_to_rec709",@"fujifilm_flog2_to_rec709",@"nikon_nlog_to_rec709",@"panasonic_vlog_vgamut_to_rec709",@"red_log3g10_rwg_to_rec709",@"sony_slog2_sgamut_to_rec709",@"sony_slog3_sgamut3cine_to_rec709",@"sony_hlg_bt2020_to_rec709"];}
static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){MTLTextureDescriptor*t=[MTLTextureDescriptor new];t.textureType=MTLTextureType3D;t.pixelFormat=MTLPixelFormatRGBA32Float;t.width=n;t.height=n;t.depth=n;t.storageMode=MTLStorageModeShared;t.usage=MTLTextureUsageShaderRead;id<MTLTexture>x=[d newTextureWithDescriptor:t];[t release];if(x)[x replaceRegion:MTLRegionMake3D(0,0,0,n,n,n) mipmapLevel:0 slice:0 withBytes:values bytesPerRow:n*16 bytesPerImage:n*n*16];return [x autorelease];}
// A synthetic texture lattice uses exactly the production render path for Cube export.
@interface DYExportTile : FxImageTile { id<MTLTexture> _tex; uint64_t _registry; FxRect _bounds;FxImageOrigin _origin; }
@interface DYExportTile : FxImageTile { id<MTLTexture> _tex; uint64_t _registry; FxRect _bounds;FxImageOrigin _origin; double _pixelAspect; }
- (instancetype)initWithTexture:(id<MTLTexture>)texture registry:(uint64_t)registry;
- (void)setBounds:(FxRect)bounds origin:(FxImageOrigin)origin;
- (void)setPixelAspect:(double)aspect;
@end
@implementation DYExportTile
- (instancetype)initWithTexture:(id<MTLTexture>)texture registry:(uint64_t)registry{if((self=[super init])){_tex=[texture retain];_registry=registry;_bounds=(FxRect){0,0,(SInt32)texture.width,(SInt32)texture.height};_origin=kFxImageOrigin_TOP_LEFT;}return self;}
- (instancetype)initWithTexture:(id<MTLTexture>)texture registry:(uint64_t)registry{if((self=[super init])){_tex=[texture retain];_registry=registry;_bounds=(FxRect){0,0,(SInt32)texture.width,(SInt32)texture.height};_origin=kFxImageOrigin_TOP_LEFT;_pixelAspect=1;}return self;}
- (void)dealloc{[_tex release];[super dealloc];}
- (id<MTLTexture>)metalTextureForDevice:(id<MTLDevice>)d{return d.registryID==_registry?_tex:nil;}
- (void)setBounds:(FxRect)bounds origin:(FxImageOrigin)origin{_bounds=bounds;_origin=origin;}
@@ -25,6 +26,8 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
- (FxRect)imagePixelBounds{return self.tilePixelBounds;}
- (uint64_t)deviceRegistryID{return _registry;}
- (FxImageOrigin)imageOrigin{return _origin;}
- (double)pixelAspect{return _pixelAspect;}
- (void)setPixelAspect:(double)aspect{_pixelAspect=aspect>0?aspect:1;}
@end
static BOOL managed(DYUniforms u,NSDictionary *paths){return u.cm.configured>=0&&(u.cm.configured>.5||(![paths[@"input"]length]&&u.inputProfile<.5));}
static BOOL identityCM(DYUniforms u){
@@ -144,7 +147,7 @@ static void bypassIdleSkin(DYUniforms *u){
}
if([e[@"spiderActive"]boolValue]){spiderBuffer=e[@"spiderBuffer"];spiderSize={ [e[@"spiderHues"]intValue],[e[@"spiderRings"]intValue]};}
}
DYToolMaskHeader maskHeader{};id<MTLBuffer>maskBuffer=[self maskBuffer:masks tile:src device:d header:&maskHeader];BOOL hasMasks=maskHeader.count>0;
DYToolMaskHeader maskHeader{};id<MTLBuffer>maskBuffer=masks.count?[self maskBuffer:masks tile:src device:d header:&maskHeader]:nil;BOOL hasMasks=maskHeader.count>0;
NSMutableDictionary*ps=e[@"pipelines"];NSString*format=[NSString stringWithFormat:@"%lu-%d",(unsigned long)output.pixelFormat,hasMasks];id<MTLRenderPipelineState>pipeline=ps[format];if(!pipeline){MTLRenderPipelineDescriptor*p=[MTLRenderPipelineDescriptor new];p.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];p.fragmentFunction=[e[@"library"]newFunctionWithName:hasMasks?@"dyMaskedFragment":@"dyFragment"];p.colorAttachments[0].pixelFormat=output.pixelFormat;pipeline=[d newRenderPipelineStateWithDescriptor:p error:err];[p.vertexFunction release];[p.fragmentFunction release];[p release];if(!pipeline)return NO;ps[format]=pipeline;[pipeline release];}
MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;id<MTLTexture>straight=[d newTextureWithDescriptor:td];if(!straight)return fail(err,@"无法分配调色缓冲区");
id<MTLCommandBuffer>cb=[e[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyUnpremultiply"]];[ce setTexture:input atIndex:0];[ce setTexture:straight atIndex:1];[ce dispatchThreads:MTLSizeMake(input.width,input.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];