WIP: insert initialized tools at anchors with matching render order, enlarge mask controls and rebuild native pen editing; integration checks pending
这个提交包含在:
1 父节点
745aa1626e
当前提交
38adc259e0
20 个文件已更改
+405
-105
没有与搜索条件相匹配的文件
+41
-12
@@ -21,23 +21,52 @@
|
||||
float w=b.width,h=b.height;DYVertex2D v[]={{{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(dest.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(auto &vertex:v)vertex.position.y=-vertex.position.y;
|
||||
vector_uint2 size={(unsigned)b.width,(unsigned)b.height};id<MTLCommandBuffer>cb=[e[@"queue"]commandBuffer];MTLRenderPassDescriptor *pass=[MTLRenderPassDescriptor renderPassDescriptor];pass.colorAttachments[0].texture=b;pass.colorAttachments[0].loadAction=MTLLoadActionDontCare;pass.colorAttachments[0].storeAction=MTLStoreActionStore;id<MTLRenderCommandEncoder>encoder=[cb renderCommandEncoderWithDescriptor:pass];[encoder setRenderPipelineState:pipeline];[encoder setVertexBytes:v length:sizeof(v) atIndex:0];[encoder setVertexBytes:&size length:sizeof(size) atIndex:1];[encoder setFragmentTexture:a atIndex:0];[encoder drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];[encoder endEncoding];[cb commit];[cb waitUntilCompleted];return cb.status==MTLCommandBufferStatusCompleted?YES:fail(error,cb.error.localizedDescription);
|
||||
}
|
||||
// Extra skin keeps the source reference used by the prior release. All other
|
||||
// extra tools reuse the same isolated native tool path and their own mask group.
|
||||
- (BOOL)renderExtraTool:(NSDictionary*)node source:(FxImageTile*)source original:(FxImageTile*)original destination:(FxImageTile*)destination entry:(NSMutableDictionary*)entry error:(NSError**)error {
|
||||
DYUniforms layer=DYToolUniforms(node);NSString *type=node[@"type"];
|
||||
if(![type isEqual:@"skin"])return [self renderLegacy:source destination:destination uniforms:layer paths:node[@"paths"] spider:node[@"spider"] masks:@{type:node[@"masks"]} error:error];
|
||||
id<MTLDevice>d=entry[@"device"];id<MTLTexture>before=[source metalTextureForDevice:d],input=[original metalTextureForDevice:d],after=[destination metalTextureForDevice:d];
|
||||
id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dyToolSkin"]];[ce setTexture:before atIndex:0];[ce setTexture:input atIndex:1];[ce setTexture:after atIndex:2];[ce setBytes:&layer length:sizeof(layer) atIndex:0];[ce dispatchThreads:MTLSizeMake(after.width,after.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);
|
||||
if(![node[@"masks"]count])return YES;
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:after.width height:after.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;id<MTLTexture>blend=[d newTextureWithDescriptor:desc];if(!blend)return fail(error,@"无法分配新增工具蒙版缓冲区");
|
||||
DYToolMaskHeader h{};h.section=3;id<MTLBuffer>buffer=[self maskBuffer:@{type:node[@"masks"]} tile:source device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:before after:after output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted;
|
||||
DYExportTile *blended=[[DYExportTile alloc]initWithTexture:blend registry:d.registryID];[blended setBounds:source.tilePixelBounds origin:source.imageOrigin];[blended setPixelAspect:source.pixelAspect];[blend release];if(ok)ok=[self copyTile:blended to:destination entry:entry error:error];else fail(error,cb.error.localizedDescription);[blended release];return ok;
|
||||
}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){@autoreleasepool{
|
||||
if(!tools)return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:@{} error:error];if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");
|
||||
NSArray *layers=tools[@"layers"];BOOL active=NO;for(NSDictionary *n in layers)active|=!DYToolIsNeutral(n);
|
||||
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"];}
|
||||
// No active extra tool keeps the exact historical fused path, including HDR.
|
||||
if(!active)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];
|
||||
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;
|
||||
id<MTLTexture>current=[d newTextureWithDescriptor:desc];if(!current)return fail(error,@"无法分配工具图层缓冲区");DYExportTile *tile=[[DYExportTile alloc]initWithTexture:current registry:d.registryID];[tile setBounds:src.tilePixelBounds origin:src.imageOrigin];[tile setPixelAspect:src.pixelAspect];[current release];
|
||||
DYExportTile *tile=nil,*skinReference=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];}
|
||||
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]){@autoreleasepool{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;};
|
||||
@try{
|
||||
if(![self renderLegacy:src destination:tile uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error])return NO;
|
||||
for(NSDictionary *node in layers){@autoreleasepool{if(DYToolIsNeutral(node))continue;DYUniforms layer=DYToolUniforms(node);NSString *type=node[@"type"];
|
||||
id<MTLTexture>next=[d newTextureWithDescriptor:desc];if(!next)return fail(error,@"无法分配新增工具缓冲区");DYExportTile *nextTile=[[[DYExportTile alloc]initWithTexture:next registry:d.registryID]autorelease];[nextTile setBounds:src.tilePixelBounds origin:src.imageOrigin];[nextTile setPixelAspect:src.pixelAspect];[next release];
|
||||
if([type isEqual:@"skin"]){id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dyToolSkin"]];[ce setTexture:[tile metalTextureForDevice:d] atIndex:0];[ce setTexture:input atIndex:1];[ce setTexture:[nextTile metalTextureForDevice:d] atIndex:2];[ce setBytes:&layer length:sizeof(layer) atIndex:0];[ce dispatchThreads:MTLSizeMake(input.width,input.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);
|
||||
if([node[@"masks"]count]){id<MTLTexture>blend=[d newTextureWithDescriptor:desc];DYToolMaskHeader h{};h.section=3;id<MTLBuffer>buffer=[self maskBuffer:@{type:node[@"masks"]} tile:tile device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:[tile metalTextureForDevice:d] after:[nextTile metalTextureForDevice:d] output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];DYExportTile *blended=[[[DYExportTile alloc]initWithTexture:blend registry:d.registryID]autorelease];[blended setBounds:src.tilePixelBounds origin:src.imageOrigin];[blended setPixelAspect:src.pixelAspect];[blend release];nextTile=blended;if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);}
|
||||
}else if(![self renderLegacy:tile destination:nextTile uniforms:layer paths:node[@"paths"] spider:node[@"spider"] masks:@{type:node[@"masks"]} error:error])return NO;
|
||||
[nextTile retain];[tile release];tile=nextTile;
|
||||
}}return [self copyTile:tile to:dst entry:entry error:error];
|
||||
}@finally{[tile release];}
|
||||
if(!anchored){DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配工具图层缓冲区");BOOL ok=[self renderLegacy:src destination:next uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];if(!ok){[next release];return NO;}replace(next);}
|
||||
else {
|
||||
// Preserve the actual native stage order, which predates the visual cards.
|
||||
// Basic adjustment spans stages 2/8, so its insertion point is after stage 8.
|
||||
// CST precedes stage 0; Spider stays after all twelve fused color stages.
|
||||
NSArray *anchors=@[@"base:primary",@"base:primaries",@"",@"base:curve",@"base:levels",@"base:balance",@"base:hsl",@"base:grading",@"base:base",@"base:blackwhite",@"base:look",@"base:skin"];
|
||||
NSInteger first=0;
|
||||
for(NSInteger last=0;last<12;last++)if(last==5||last==11||[groups[anchors[last]]count]){@autoreleasepool{
|
||||
DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配原生工具分段缓冲区");DYUniforms segment=u;
|
||||
if(first>0){segment.primarySectionEnabled=0;segment.inputSectionEnabled=0;segment.cm.basisEnabled=0;segment.cm.outputEnabled=0;}
|
||||
BOOL ok=[self renderLegacy:tile?:src destination:next uniforms:segment paths:paths spider:nil masks:tools[@"baseMasks"] stageFirst:first stageLast:last skinReference:skinReference error:error];if(!ok){[next release];return NO;}replace(next);
|
||||
if(!apply(anchors[last]))return NO;
|
||||
// Skin protects the native pre-HSL result, including tools inserted before it.
|
||||
if(last==5){[skinReference release];skinReference=[tile retain];}first=last+1;
|
||||
}}
|
||||
if(u.spiderSectionEnabled>.5&&u.spiderMix>0&&spider.length){DYUniforms sp=DYToolUniforms(@{@"type":@"spider"});sp.spiderSectionEnabled=u.spiderSectionEnabled;sp.spiderMix=u.spiderMix;DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配蜘蛛盘缓冲区");BOOL ok=[self renderLegacy:tile destination:next uniforms:sp paths:@{} spider:spider masks:@{@"spider":tools[@"baseMasks"][@"spider"]?:@[]} error:error];if(!ok){[next release];return NO;}replace(next);}
|
||||
if(!apply(@"base:spider"))return NO;
|
||||
}
|
||||
// Schema 1 extra layers (and children inserted after those layers) retain
|
||||
// their old end-of-chain order. Saving does not silently migrate old looks.
|
||||
if(!apply(@"tail"))return NO;return [self copyTile:tile to:dst entry:entry error:error];
|
||||
}@finally{[skinReference release];[tile release];}
|
||||
}}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){
|
||||
for(NSArray *masks in [tools[@"baseMasks"]allValues])if(masks.count)return fail(error,@"当前调色含空间蒙版或跟踪,Cube 无法保存这些信息。请先保存完整预设,或移除蒙版后导出。");for(NSDictionary *node in tools[@"layers"])if([node[@"masks"]count])return fail(error,@"新增工具含蒙版,无法完整导出为 Cube。请保存完整预设。");
|
||||
|
||||
在新工单中引用
屏蔽一个用户