减少多层调色 GPU 等待与检查器拖动写入
这个提交包含在:
1 父节点
79f1dd4545
当前提交
38e9fb25a2
19 个文件已更改
+427
-98
没有与搜索条件相匹配的文件
+42
-1
@@ -27,6 +27,36 @@
|
||||
#import "DYScopeSample.h"
|
||||
#include "DYLevelGeometry.h"
|
||||
static BOOL fail(NSError**e,NSString*m){if(e)*e=[NSError errorWithDomain:@"com.dayu.color" code:1 userInfo:@{NSLocalizedDescriptionKey:m?:@"Metal 调色失败"}];return NO;}
|
||||
// Keep a bounded group of ordered GPU passes. A CPU reader or another
|
||||
// queue finishes the group before accessing its result.
|
||||
struct DYManagedBatch {
|
||||
id<MTLCommandQueue> queue;
|
||||
NSError **error;
|
||||
id<MTLCommandBuffer> pending=nil;
|
||||
unsigned passes=0;
|
||||
BOOL failed=NO;
|
||||
|
||||
BOOL finish(){
|
||||
if(!pending)return !failed;
|
||||
[pending commit];[pending waitUntilCompleted];
|
||||
if(pending.status!=MTLCommandBufferStatusCompleted){failed=YES;fail(error,pending.error.localizedDescription);}
|
||||
pending=nil;passes=0;
|
||||
return !failed;
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> commands(){
|
||||
if(failed||(passes==16&&!finish()))return nil;
|
||||
if(!pending)pending=[queue commandBuffer];
|
||||
if(!pending){failed=YES;fail(error,@"无法分配调色命令缓冲区");return nil;}
|
||||
++passes;
|
||||
return pending;
|
||||
}
|
||||
};
|
||||
struct DYManagedPreviewReadback {
|
||||
id<MTLBuffer> analysis,standard,high;
|
||||
NSSize size,highSize;
|
||||
FxImageOrigin origin;
|
||||
};
|
||||
// MRC NSError out-parameters must outlive every nested render pool. Preserve
|
||||
// the same pointer across nested closures, then autorelease in the caller pool.
|
||||
template<class F> static BOOL DYRenderWithPool(NSError **error,F body){
|
||||
@@ -146,6 +176,8 @@ struct DYScopeReadback {
|
||||
CFTimeInterval _lastPreview;
|
||||
BOOL _exporting;
|
||||
NSDictionary *_toolDocument,*_colorContext,*_exportManagedState;
|
||||
CGColorSpaceRef _renderSourceSpace,_renderDestinationSpace;
|
||||
DYColorProfile *_renderOutputProfile;
|
||||
BOOL _managedFinishing;NSData *_faceEntries,*_faceInput,*_faceCachedEntries;CIContext *_faceContext;NSData *_mosaicRaster,*_mosaicEntries;NSDictionary *_mosaicFaceSnapshot;
|
||||
dispatch_queue_t _scopeQueue;
|
||||
BOOL _scopeEnabled,_scopeWorkerRunning,_outputObserved,_outputNotificationPending,_spiderScopeWorkerRunning;
|
||||
@@ -163,6 +195,15 @@ struct DYScopeReadback {
|
||||
DYColorProfile *_scopeProfile;
|
||||
NSObject *_scopeProfileLock;
|
||||
}
|
||||
- (BOOL)encodeManagedDispatch:(NSString*)name textures:(NSArray*)textures data:(const void*)data length:(NSUInteger)length
|
||||
extra:(const void*)extra extraLength:(NSUInteger)extraLength entry:(NSMutableDictionary*)entry
|
||||
commands:(id<MTLCommandBuffer>)commands error:(NSError**)error;
|
||||
- (DYManagedPreviewReadback)encodeManagedPreview:(id<MTLTexture>)texture source:(FxImageTile*)source
|
||||
entry:(NSMutableDictionary*)entry commands:(id<MTLCommandBuffer>)commands;
|
||||
- (void)publishManagedPreview:(DYManagedPreviewReadback)preview;
|
||||
- (DYColorProfile*)managedOutputProfile:(NSError**)error;
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest rotation:(double)angle entry:(NSMutableDictionary*)entry
|
||||
commands:(id<MTLCommandBuffer>)commands error:(NSError**)error;
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
// The caller holds the renderer lock. Unused tools never load a GPU function.
|
||||
@@ -244,7 +285,7 @@ static NSData *DYLookBufferData(id<MTLBuffer> buffer) {
|
||||
#include "DYFaceRender.inc.h"
|
||||
#include "DYToolRender.inc.h"
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_scopeProfileLock=[NSObject new];_scopeQueue=dispatch_queue_create("com.dayu.color.final-output-scopes",DISPATCH_QUEUE_SERIAL);_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_mosaicRaster release];[_mosaicEntries release];[_mosaicFaceSnapshot release];[_faceEntries release];[_faceInput release];[_faceCachedEntries release];[_faceContext release];[_scopePending release];[_scopeLatest release];[_spiderScopeRaster release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];[_scopeProfileLock release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreviewFrames release];[_colorContext release];[_previewLock release];[super dealloc];}
|
||||
- (void)dealloc{[_mosaicRaster release];[_mosaicEntries release];[_mosaicFaceSnapshot release];[_faceEntries release];[_faceInput release];[_faceCachedEntries release];[_faceContext release];[_scopePending release];[_scopeLatest release];[_spiderScopeRaster release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];[_scopeProfileLock release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreviewFrames release];[_renderOutputProfile release];if(_renderSourceSpace)CGColorSpaceRelease(_renderSourceSpace);if(_renderDestinationSpace)CGColorSpaceRelease(_renderDestinationSpace);[_colorContext release];[_previewLock release];[super dealloc];}
|
||||
- (void)trimPreparedLUTsKeeping:(NSString *)path {
|
||||
if(_preparedLUTs.count<=12)return;
|
||||
for(NSString *key in _preparedLUTs.allKeys)if(![_activeLUTPaths containsObject:key]&&![key isEqualToString:path])[_preparedLUTs removeObjectForKey:key];
|
||||
|
||||
在新工单中引用
屏蔽一个用户