perf: bound preview memory and reuse layer admission
这个提交包含在:
1 父节点
c2c71f3dbc
当前提交
90e512aabe
2 个文件已更改
+9
-8
没有与搜索条件相匹配的文件
@@ -309,11 +309,7 @@ struct DYScopeReadback {
|
||||
if(!direct){
|
||||
MTLTextureDescriptor *td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];
|
||||
td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;
|
||||
straight=segmented?nil:e[@"legacyStraight"];
|
||||
if(straight.width!=input.width||straight.height!=input.height){
|
||||
straight=[[d newTextureWithDescriptor:td]autorelease];
|
||||
if(straight&&!segmented)e[@"legacyStraight"]=straight;
|
||||
}
|
||||
straight=[[d newTextureWithDescriptor:td]autorelease];
|
||||
if(!straight)return fail(err,@"无法分配调色缓冲区");
|
||||
MTLSize grid=MTLSizeMake(input.width,input.height,1),group=MTLSizeMake(16,16,1);
|
||||
BOOL fused=useCM&&!hasMasks;
|
||||
|
||||
@@ -62,12 +62,17 @@
|
||||
if(!tools)tools=@{@"schema":@1,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");
|
||||
if(tools[@"sharedMasks"])tools=DYResolvedToolDocument(tools);
|
||||
DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil;
|
||||
NSArray *layers=tools[@"layers"];BOOL active=NO,anchored=NO;for(NSDictionary *node in layers)if(!DYToolIsNeutral(node)){active=YES;anchored|=![DYToolRootAnchor(tools,node[@"id"])isEqual:@"tail"];}
|
||||
NSMutableSet *activeIDs=nil;BOOL anchored=NO;
|
||||
for(NSDictionary *node in tools[@"layers"])if(!DYToolIsNeutral(node)){
|
||||
if(!activeIDs)activeIDs=[NSMutableSet set];
|
||||
[activeIDs addObject:node[@"id"]];
|
||||
anchored|=![DYToolRootAnchor(tools,node[@"id"])isEqual:@"tail"];
|
||||
}
|
||||
// No active extra tool keeps the exact historical fused path, including HDR.
|
||||
if(!active&&!DYChannelMixerActive(u)&&!DYFilmToolActive(u)&&(u.lensSectionEnabled<.5||(u.lensStrength==0&&u.lensScale==1)))return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];
|
||||
if(!activeIDs.count&&!DYChannelMixerActive(u)&&!DYFilmToolActive(u)&&(u.lensSectionEnabled<.5||(u.lensStrength==0&&u.lensScale==1)))return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];
|
||||
NSMutableDictionary *entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;id<MTLDevice>d=entry[@"device"];id<MTLTexture>input=[src metalTextureForDevice:d];if(!input)return fail(error,@"宿主图像纹理不可用");
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;
|
||||
DYExportTile *tile=nil,*skinReference=nil,*originalReference=nil;NSArray *order=DYToolDisplayOrder(tools);NSMutableDictionary *groups=[NSMutableDictionary dictionary];for(NSString *ID in order){NSDictionary *node=DYToolWithID(tools,ID);if(!node||DYToolIsNeutral(node))continue;NSString *root=DYToolRootAnchor(tools,ID);if(!groups[root])groups[root]=[NSMutableArray array];[groups[root]addObject:node];}
|
||||
DYExportTile *tile=nil,*skinReference=nil,*originalReference=nil;NSArray *order=DYToolDisplayOrder(tools);NSMutableDictionary *groups=[NSMutableDictionary dictionary];for(NSString *ID in order){if(![activeIDs containsObject:ID])continue;NSDictionary *node=DYToolWithID(tools,ID);NSString *root=DYToolRootAnchor(tools,ID);if(!groups[root])groups[root]=[NSMutableArray array];[groups[root]addObject:node];}
|
||||
auto makeTile=[&](){id<MTLTexture>texture=[d newTextureWithDescriptor:desc];if(!texture)return (DYExportTile*)nil;DYExportTile *result=[[DYExportTile alloc]initWithTexture:texture registry:d.registryID];[result setBounds:src.tilePixelBounds origin:src.imageOrigin];[result setPixelAspect:src.pixelAspect];[texture release];return result;};
|
||||
auto replace=[&](DYExportTile *next){[tile release];tile=next;};
|
||||
auto apply=[&](NSString *anchor){for(NSDictionary *node in groups[anchor]){if(!DYRenderWithPool(error,[&]()->BOOL{DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配新增工具缓冲区");BOOL ok=[self renderExtraTool:node source:tile original:src destination:next entry:entry error:error];if(!ok){[next release];return NO;}replace(next);return YES;}))return NO;}return YES;};
|
||||
|
||||
在新工单中引用
屏蔽一个用户