WIP: native per-layer controls, host OSC and Metal mask tracking; GPU and callback regressions added, formal host acceptance pending
这个提交包含在:
1 父节点
f72aa2609d
当前提交
cec044f124
26 个文件已更改
+475
-40
没有与搜索条件相匹配的文件
@@ -27,15 +27,17 @@
|
||||
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];
|
||||
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]autorelease];[tile setBounds:src.tilePixelBounds origin:src.imageOrigin];[current release];
|
||||
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];
|
||||
@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){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];[next release];
|
||||
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];[blend release];nextTile=blended;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;
|
||||
tile=nextTile;
|
||||
}return [self copyTile:tile to:dst entry:entry error:error];
|
||||
[nextTile retain];[tile release];tile=nextTile;
|
||||
}}return [self copyTile:tile to:dst entry:entry error:error];
|
||||
}@finally{[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。请保存完整预设。");
|
||||
|
||||
在新工单中引用
屏蔽一个用户