减少多层调色 GPU 等待与检查器拖动写入
这个提交包含在:
1 父节点
79f1dd4545
当前提交
38e9fb25a2
19 个文件已更改
+427
-98
没有与搜索条件相匹配的文件
@@ -13,6 +13,8 @@
|
||||
if(![m[@"enabled"]boolValue])continue;
|
||||
DYToolMaskEntry entry{};entry.section=(int)section;entry.combine=[m[@"combine"]intValue];
|
||||
[m[@"parameters"]getBytes:&entry.mask.parameters length:sizeof(DYMaskParameters)];entry.mask.parameters.imageAspect=w/ht;
|
||||
if(entry.mask.parameters.kind>=DYMaskHSLKey)
|
||||
h->keySources|=entry.mask.parameters.sourceStage==DYMaskSourceOriginal?DYToolMaskOriginalKey:DYToolMaskLayerKey;
|
||||
NSData *nodes=m[@"nodes"];auto &path=entry.mask.path;
|
||||
path=dyFlattenMask((const DYBezierNode*)nodes.bytes,nodes.length/sizeof(DYBezierNode));
|
||||
if(mosaic&&entry.mask.parameters.kind==DYMaskBezier&&path.count>=3){
|
||||
@@ -25,12 +27,18 @@
|
||||
}
|
||||
- (BOOL)encodeBlend:(id<MTLTexture>)before after:(id<MTLTexture>)after output:(id<MTLTexture>)output masks:(id<MTLBuffer>)masks header:(DYToolMaskHeader)h entry:(NSMutableDictionary*)entry commands:(id<MTLCommandBuffer>)commands error:(NSError**)error {
|
||||
id<MTLComputePipelineState> pipeline=[self computePipeline:@"dyToolBlend" entry:entry error:error];if(!pipeline)return NO;
|
||||
id<MTLComputeCommandEncoder>encoder=[commands computeCommandEncoder];[encoder setComputePipelineState:pipeline];[encoder setTexture:before atIndex:0];[encoder setTexture:after atIndex:1];[encoder setTexture:output atIndex:2];[encoder setBuffer:masks offset:0 atIndex:0];[encoder setBytes:&h length:sizeof(h) atIndex:1];[encoder dispatchThreads:MTLSizeMake(output.width,output.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding];return YES;
|
||||
id<MTLComputeCommandEncoder>encoder=masks?[commands computeCommandEncoder]:nil;if(!encoder)return fail(error,@"无法创建蒙版混合编码器");[encoder setComputePipelineState:pipeline];[encoder setTexture:before atIndex:0];[encoder setTexture:after atIndex:1];[encoder setTexture:output atIndex:2];[encoder setBuffer:masks offset:0 atIndex:0];[encoder setBytes:&h length:sizeof(h) atIndex:1];[encoder dispatchThreads:MTLSizeMake(output.width,output.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding];return YES;
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest entry:(NSMutableDictionary*)e error:(NSError**)error {
|
||||
return [self copyTile:source to:dest rotation:0 entry:e error:error];
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest rotation:(double)angle entry:(NSMutableDictionary*)e error:(NSError**)error {
|
||||
id<MTLCommandBuffer>commands=[e[@"queue"] commandBuffer];
|
||||
if(!commands)return fail(error,@"无法分配图像输出命令");
|
||||
return [self copyTile:source to:dest rotation:angle entry:e commands:commands error:error];
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest rotation:(double)angle entry:(NSMutableDictionary*)e commands:(id<MTLCommandBuffer>)commands error:(NSError**)error {
|
||||
if(!commands)return NO;
|
||||
id<MTLDevice>device=e[@"device"];id<MTLTexture>a=[source metalTextureForDevice:device],b=[dest metalTextureForDevice:device];
|
||||
if(!a||!b)return fail(error,@"宿主图像纹理不可用");
|
||||
BOOL useFloat=_managedFinishing||angle!=0;
|
||||
@@ -49,7 +57,7 @@
|
||||
if(source.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)vertex.textureCoordinate.y=1-vertex.textureCoordinate.y;
|
||||
if(dest.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)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];return [self completeCommands:cb destination:dest texture:b entry:e]?YES:fail(error,cb.error.localizedDescription);
|
||||
vector_uint2 size={(unsigned)b.width,(unsigned)b.height};MTLRenderPassDescriptor *pass=[MTLRenderPassDescriptor renderPassDescriptor];pass.colorAttachments[0].texture=b;pass.colorAttachments[0].loadAction=MTLLoadActionDontCare;pass.colorAttachments[0].storeAction=MTLStoreActionStore;id<MTLRenderCommandEncoder>encoder=[commands renderCommandEncoderWithDescriptor:pass];if(!encoder)return fail(error,@"无法创建图像输出编码器");[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];return [self completeCommands:commands destination:dest texture:b entry:e]?YES:fail(error,commands.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.
|
||||
|
||||
在新工单中引用
屏蔽一个用户