WIP: reconstruct color kernels, camera tables and native inspector; integration checks pending
这个提交包含在:
1 父节点
10987dd6bc
当前提交
2f11e8bd0f
52 个文件已更改
+11421
-835
没有与搜索条件相匹配的文件
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the versioned AIR arithmetic and Dayu's authored Metal boundary."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--output', required=True, type=Path)
|
||||
parser.add_argument('--intermediates', required=True, type=Path)
|
||||
args = parser.parse_args()
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
work = args.intermediates.resolve()
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
objects = []
|
||||
for name in ('DYGradeKernel', 'DYStatisticsKernel', 'DYLUTExportKernel'):
|
||||
target = work / (name + '.air')
|
||||
subprocess.run(['xcrun', 'metal-opt', str(root / 'tools/kernels' / (name + '.ll')),
|
||||
'-o', str(target)], check=True)
|
||||
objects.append(str(target))
|
||||
wrapper = work / 'DYGradeWrapper.air'
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-std=metal3.1',
|
||||
'-mmacosx-version-min=14.6', '-c',
|
||||
str(root / '大鱼调色/Plugin/DYGrade.metal'), '-o', str(wrapper)], check=True)
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metallib', str(wrapper), *objects,
|
||||
'-o', str(args.output)], check=True)
|
||||
print(args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Review selected paths before invoking. Never stages unrelated paths."""
|
||||
import pathlib,os,hashlib,json,subprocess,shutil,sys
|
||||
root=pathlib.Path(__file__).resolve().parent.parent;remote='https://dayu.media/git/dayu/dayu-color.git';lock=pathlib.Path('/Users/mac/.codex/git-backup-locks')/(hashlib.sha256(remote.encode()).hexdigest()+'.lock')
|
||||
lock.parent.mkdir(parents=True,exist_ok=True);lock.mkdir();(lock/'owner.json').write_text(json.dumps(dict(PID=os.getpid(),cwd=str(root),remote=remote)))
|
||||
def run(*a):return subprocess.check_output(a,cwd=root,text=True).strip()
|
||||
try:
|
||||
run('git','add','-A','--',*sys.argv[2:]);print(run('git','diff','--cached','--stat'));print(run('git','commit','-m',sys.argv[1]));print(run('git','push','origin','HEAD'));sha=run('git','rev-parse','HEAD');assert run('git','ls-remote','origin','refs/heads/main').split()[0]==sha;print('REMOTE_VERIFIED '+sha)
|
||||
finally:shutil.rmtree(lock)
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""One-time extraction of the explicitly supplied app's input color tables.
|
||||
Production builds consume the committed compressed float tables, never the app.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import argparse,array,struct,zlib,hashlib,json
|
||||
p=argparse.ArgumentParser();p.add_argument('source',type=Path);a=p.parse_args()
|
||||
root=Path(__file__).resolve().parent.parent;out=root/'大鱼调色/Plugin/Resources/InputLUTs';out.mkdir(parents=True,exist_ok=True)
|
||||
manifest=[]
|
||||
for src in sorted(a.source.glob('*.cube')):
|
||||
n=0;rgb=array.array('f');lo=[0.,0.,0.];hi=[1.,1.,1.]
|
||||
for raw in src.read_text().splitlines():
|
||||
s=raw.split('#',1)[0].strip().split()
|
||||
if not s:continue
|
||||
if s[0]=='LUT_3D_SIZE':n=int(s[1])
|
||||
elif s[0]=='DOMAIN_MIN':lo=list(map(float,s[1:4]))
|
||||
elif s[0]=='DOMAIN_MAX':hi=list(map(float,s[1:4]))
|
||||
elif len(s)==3:
|
||||
try:rgb.extend([*map(float,s),1.])
|
||||
except ValueError:pass
|
||||
assert len(rgb)==n**3*4,(src,n,len(rgb))
|
||||
blob=struct.pack('<4sII6f',b'DYLT',n,len(rgb)*4,*lo,*hi)+zlib.compress(rgb.tobytes(),9)
|
||||
dest=out/(src.stem+'.dylut');dest.write_bytes(blob)
|
||||
manifest.append(dict(file=dest.name,dimension=n,source=src.name,sourceSHA256=hashlib.sha256(src.read_bytes()).hexdigest(),sha256=hashlib.sha256(blob).hexdigest()))
|
||||
(out/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n');print(len(manifest),'input LUTs imported')
|
||||
文件差异过大,未显示。
加载差异
文件差异过大,未显示。
加载差异
@@ -0,0 +1,683 @@
|
||||
; Reconstructed numeric instruction graph; see PROVENANCE.json.
|
||||
source_filename = "dyWhitesSceneStatistics"
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
|
||||
target triple = "air64_v26-apple-macosx14.6.0"
|
||||
|
||||
%"struct.metal::_atomic" = type { i32 }
|
||||
%struct._texture_2d_t = type opaque
|
||||
%struct._texture_3d_t = type opaque
|
||||
%struct.DYUniforms = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, <4 x float>, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, <4 x float>, float, float, float, float, float, float, float, float, float, float, float, float, <4 x float>, <2 x float>, <2 x float>, <2 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <3 x float>, <3 x float>, float, float, float, <4 x float>, <4 x float>, <3 x float>, <3 x float>, float, float, float, float, float, float, float, <3 x float>, <3 x float>, <3 x float>, <3 x float>, float, <3 x float>, float, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, float, <4 x float>, <2 x float>, <2 x float>, float, float, <3 x float>, <3 x float>, <3 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float> }
|
||||
%struct._sampler_t = type opaque
|
||||
|
||||
@_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram = internal addrspace(3) global [256 x %"struct.metal::_atomic"] zeroinitializer, align 4
|
||||
@_ZL14lgChromaScales = internal unnamed_addr addrspace(2) constant [6 x [7 x [33 x float]]] [[7 x [33 x float]] [[33 x float] [float 0x3FD5539260000000, float 0x3FD5C51660000000, float 0x3FD6369120000000, float 0x3FD6A820A0000000, float 0x3FD71B7180000000, float 0x3FD793B380000000, float 0x3FD8143720000000, float 0x3FD89EEBC0000000, float 0x3FD932D480000000, float 0x3FD9CC4500000000, float 0x3FDA66CA80000000, float 0x3FDAFFA180000000, float 0x3FDB9AC380000000, float 0x3FDC469EA0000000, float 0x3FDD1DF7A0000000, float 0x3FDE466680000000, float 0x3FDFEFC400000000, float 0x3FE128C5E0000000, float 0x3FE2D262C0000000, float 0x3FE50EF9A0000000, float 0x3FE7F41DC0000000, float 0x3FEB90E840000000, float 0x3FEFEDE5C0000000, float 0x3FF284E6E0000000, float 0x3FF56CF9E0000000, float 0x3FF8A4FB20000000, float 0x3FFC1E07C0000000, float 0x3FFFC4BCA0000000, float 0x4001C125C0000000, float 0x4003A22440000000, float 0x4005828680000000, float 0x400762A900000000, float 3.000000e+00], [33 x float] [float 0x3FE1F31A80000000, float 0x3FE24DE8E0000000, float 0x3FE2A8B740000000, float 0x3FE303BAE0000000, float 0x3FE35F6CA0000000, float 0x3FE3BC16C0000000, float 0x3FE4191BA0000000, float 0x3FE474DDE0000000, float 0x3FE4CCBE60000000, float 0x3FE51DE2E0000000, float 0x3FE5665720000000, float 0x3FE5A66EC0000000, float 0x3FE5E39FA0000000, float 0x3FE628DD60000000, float 0x3FE686D9C0000000, float 0x3FE712B8E0000000, float 0x3FE7E53BC0000000, float 0x3FE918EDE0000000, float 0x3FEAC65460000000, float 0x3FED000600000000, float 0x3FEFD1CBC0000000, float 0x3FF1A01C40000000, float 0x3FF3A49220000000, float 0x3FF5F09740000000, float 0x3FF87A2140000000, float 0x3FFB32BD40000000, float 0x3FFE07CFC0000000, float 0x4000716740000000, float 0x4001D82BA0000000, float 0x40033A7F80000000, float 0x40049B5280000000, float 0x4005FBE960000000, float 0x40075C77E0000000], [33 x float] [float 0x3FE7F5C200000000, float 0x3FE83A93C0000000, float 0x3FE87F6480000000, float 0x3FE8C44680000000, float 0x3FE90932A0000000, float 0x3FE94DB660000000, float 0x3FE990E6C0000000, float 0x3FE9D17D80000000, float 0x3FEA0E1F80000000, float 0x3FEA45F500000000, float 0x3FEA790DE0000000, float 0x3FEAA8C9E0000000, float 0x3FEAD89140000000, float 0x3FEB0D8580000000, float 0x3FEB4E9660000000, float 0x3FEBA37DE0000000, float 0x3FEC1491E0000000, float 0x3FECAA2A20000000, float 0x3FED6AEC40000000, float 0x3FEE5B2220000000, float 0x3FEF7D8160000000, float 0x3FF0699360000000, float 0x3FF12DD280000000, float 0x3FF20A4520000000, float 0x3FF2FCA360000000, float 0x3FF4018DA0000000, float 0x3FF5149A40000000, float 0x3FF63061C0000000, float 0x3FF74F84E0000000, float 0x3FF8702520000000, float 0x3FF9917700000000, float 0x3FFAB2EC00000000, float 0x3FFBD45F20000000], [33 x float] [float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00], [33 x float] [float 0x3FF504ADC0000000, float 0x3FF4CAC1C0000000, float 0x3FF490D400000000, float 0x3FF456E480000000, float 0x3FF41D6020000000, float 0x3FF3E50440000000, float 0x3FF3AE70C0000000, float 0x3FF379C960000000, float 0x3FF3467A40000000, float 0x3FF3133100000000, float 0x3FF2DDE360000000, float 0x3FF2A40480000000, float 0x3FF26314A0000000, float 0x3FF2195140000000, float 0x3FF1C5C000000000, float 0x3FF168BA40000000, float 0x3FF1032380000000, float 0x3FF095A6C0000000, float 0x3FF0209900000000, float 0x3FEF46E860000000, float 0x3FEE3A39C0000000, float 0x3FED19CC40000000, float 0x3FEBE56FC0000000, float 0x3FEA9DF900000000, float 0x3FE94531C0000000, float 0x3FE7DDEF20000000, float 0x3FE66C2280000000, float 0x3FE4F4A6A0000000, float 0x3FE37C2DE0000000, float 0x3FE203E780000000, float 0x3FE08BC2E0000000, float 0x3FDE274940000000, float 0x3FDB371320000000], [33 x float] [float 0x3FFB7E1FE0000000, float 0x3FFAD91140000000, float 0x3FFA33FE80000000, float 0x3FF98F0400000000, float 0x3FF8EB3BA0000000, float 0x3FF849DCE0000000, float 0x3FF7AB1A80000000, float 0x3FF70DCEE0000000, float 0x3FF66FC380000000, float 0x3FF5CE2DA0000000, float 0x3FF525E8A0000000, float 0x3FF4745D60000000, float 0x3FF3B89A20000000, float 0x3FF2F2E140000000, float 0x3FF223F0E0000000, float 0x3FF14E6A20000000, float 0x3FF0751420000000, float 0x3FEF338C60000000, float 0x3FED7B4CC0000000, float 0x3FEBC12040000000, float 0x3FEA02EA20000000, float 0x3FE83F26E0000000, float 0x3FE6755F40000000, float 0x3FE4A5FC40000000, float 0x3FE2D22AA0000000, float 0x3FE0FBC120000000, float 0x3FDE4AAF00000000, float 0x3Line truncated
|
||||
@_ZL12lgToneCurves = internal unnamed_addr addrspace(2) constant [6 x [7 x [33 x float]]] [[7 x [33 x float]] [[33 x float] [float 0.000000e+00, float 0x3F7EFB2800000000, float 0x3F92B7BF00000000, float 0x3F9DC082A0000000, float 0x3FA4701620000000, float 0x3FAA13EE40000000, float 0x3FAFD60B80000000, float 0x3FB2DED580000000, float 0x3FB5E8BC60000000, float 0x3FB90EAA20000000, float 0x3FBC562380000000, float 0x3FBFC3E500000000, float 0x3FC1AA9480000000, float 0x3FC3836200000000, float 0x3FC56C95E0000000, float 0x3FC76663C0000000, float 0x3FC972CBA0000000, float 0x3FCB9752E0000000, float 0x3FCDDA49A0000000, float 0x3FD0204540000000, float 0x3FD1658120000000, float 0x3FD2BE4620000000, float 0x3FD42C9C80000000, float 0x3FD5B32400000000, float 0x3FD753C8C0000000, float 0x3FD91188C0000000, float 0x3FDAF29A80000000, float 0x3FDD025C80000000, float 0x3FDF4FB240000000, float 0x3FE0ED37A0000000, float 0x3FE245FC00000000, float 0x3FE3A4C540000000, float 0x3FE504BAA0000000], [33 x float] [float 0.000000e+00, float 0x3F9095A5C0000000, float 0x3FA1B21240000000, float 0x3FAB1B1AE0000000, float 0x3FB2489580000000, float 0x3FB7168280000000, float 0x3FBC011E80000000, float 0x3FC0867C40000000, float 0x3FC31DE900000000, float 0x3FC5C74F20000000, float 0x3FC8805AE0000000, float 0x3FCB453100000000, float 0x3FCE118AA0000000, float 0x3FD0717940000000, float 0x3FD1DD37E0000000, float 0x3FD34D9520000000, float 0x3FD4C5D3C0000000, float 0x3FD64B2040000000, float 0x3FD7E28D80000000, float 0x3FD98FD200000000, float 0x3FDB53C960000000, float 0x3FDD2F94E0000000, float 0x3FDF245E20000000, float 0x3FE099B4E0000000, float 0x3FE1AEDF60000000, float 0x3FE2D36E60000000, float 0x3FE40BE240000000, float 0x3FE560CA20000000, float 0x3FE6DA1B00000000, float 0x3FE86DA020000000, float 0x3FEA0E3160000000, float 0x3FEBB263C0000000, float 0x3FED574A20000000], [33 x float] [float 0.000000e+00, float 0x3F973B9760000000, float 0x3FA7E40980000000, float 0x3FB2166020000000, float 0x3FB842B8E0000000, float 0x3FBE814D20000000, float 0x3FC26BF3C0000000, float 0x3FC5A3A200000000, float 0x3FC8E6E0A0000000, float 0x3FCC344100000000, float 0x3FCF8926A0000000, float 0x3FD17172A0000000, float 0x3FD31FB3A0000000, float 0x3FD4CEEBA0000000, float 0x3FD6800360000000, float 0x3FD834F7A0000000, float 0x3FD9F12D80000000, float 0x3FDBB92360000000, float 0x3FDD90A4A0000000, float 0x3FDF797860000000, float 0x3FE0B924C0000000, float 0x3FE1BCD960000000, float 0x3FE2C77460000000, float 0x3FE3D91600000000, float 0x3FE4F21220000000, float 0x3FE612F7C0000000, float 0x3FE73C8AA0000000, float 0x3FE86F7FC0000000, float 0x3FE9ABD640000000, float 0x3FEAEF1540000000, float 0x3FEC3614E0000000, float 0x3FED7E6080000000, float 0x3FEEC6FE40000000], [33 x float] [float 0.000000e+00, float 3.125000e-02, float 6.250000e-02, float 9.375000e-02, float 1.250000e-01, float 1.562500e-01, float 1.875000e-01, float 2.187500e-01, float 2.500000e-01, float 2.812500e-01, float 3.125000e-01, float 3.437500e-01, float 3.750000e-01, float 4.062500e-01, float 4.375000e-01, float 4.687500e-01, float 5.000000e-01, float 5.312500e-01, float 5.625000e-01, float 5.937500e-01, float 6.250000e-01, float 6.562500e-01, float 6.875000e-01, float 7.187500e-01, float 7.500000e-01, float 7.812500e-01, float 8.125000e-01, float 8.437500e-01, float 8.750000e-01, float 9.062500e-01, float 9.375000e-01, float 9.687500e-01, float 1.000000e+00], [33 x float] [float 0x3F66796E80000000, float 0x3FA6139860000000, float 0x3FB55F0060000000, float 0x3FBFABA880000000, float 0x3FC4EEFFC0000000, float 0x3FC9F30D60000000, float 0x3FCEE184A0000000, float 0x3FD1DF9C00000000, float 0x3FD448D240000000, float 0x3FD6AE2640000000, float 0x3FD91020C0000000, float 0x3FDB6D61E0000000, float 0x3FDDC32D80000000, float 0x3FE006EE80000000, float 0x3FE124AD60000000, float 0x3FE2397140000000, float 0x3FE344DBA0000000, float 0x3FE4474200000000, float 0x3FE541B340000000, float 0x3FE6356760000000, float 0x3FE723E2C0000000, float 0x3FE80D93E0000000, float 0x3FE8F20800000000, float 0x3FE9D032E0000000, float 0x3FEAA72C60000000, float 0x3FEB764340000000, float 0x3FEC3D3D00000000, float 0x3FECFCCCE0000000, float 0x3FEDB68340000000, float 0x3FEE6C52E0000000, float 0x3FEF2005E0000000, float 0x3FEFD2EE00000000, float 1.000000e+00], [33 x float] [float 0x3F7FEE9D60000000, float 0x3FAE6517E0000000, float 0x3FBC62A280000000, float 0x3FC4B98CA0000000, float 0x3FCB1A9FE0000000, float 0x3FD0A2B4A0000000, float 0x3FD39E8880000000, float 0x3FD68704E0000000, float 0x3FD9617000000000, float 0x3FDC2F5BE0000000, float 0x3FDEEDE940000000, float 0x3FE0CACDA0000000, float 0x3FE20FCE00000000, float 0x3FE3437C20000000, float 0x3FE4646780000000, float 0x3FE5733B40000000, float 0x3FE6716C20000000, float 0x3FE75FEE20000000, float 0x3FE83FFC40000000, float 0x3FE91338A0000000, float 0x3FE9DCA500000000, float 0x3FEA9D5CE0000000, float 0x3FEB549B00000000, float 0x3FEC005020000000, float 0x3FEC9EFBE0000000, float 0x3FED303E40000000, float 0x3FEDB53A20000000, float 0x3FEE3099A0000000, floLine truncated
|
||||
@_ZL11lgToneModes = internal unnamed_addr addrspace(2) constant [6 x [7 x float]] [[7 x float] [float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00], [7 x float] zeroinitializer, [7 x float] zeroinitializer, [7 x float] zeroinitializer, [7 x float] zeroinitializer, [7 x float] [float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00]], align 4
|
||||
@_ZL7lgStops = internal unnamed_addr addrspace(2) constant [7 x float] [float -1.000000e+02, float -5.000000e+01, float -2.500000e+01, float 0.000000e+00, float 2.500000e+01, float 5.000000e+01, float 1.000000e+02], align 4
|
||||
@__air_sampler_state = internal addrspace(2) constant i64 -9188470239253755319, align 8
|
||||
|
||||
; Function Attrs: convergent nounwind
|
||||
define void @dyWhitesSceneStatistics(%struct._texture_2d_t addrspace(1)* %0, %struct._texture_3d_t addrspace(1)* nocapture readonly %1, %struct.DYUniforms addrspace(2)* nocapture readnone dereferenceable(944) "air-buffer-no-alias" %2, float addrspace(1)* nocapture "air-buffer-no-alias" %3, i32 %4) local_unnamed_addr #0 {
|
||||
%6 = zext i32 %4 to i64
|
||||
%7 = getelementptr inbounds [256 x %"struct.metal::_atomic"], [256 x %"struct.metal::_atomic"] addrspace(3)* @_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram, i64 0, i64 %6, i32 0
|
||||
tail call void @air.atomic.local.store.i32(i32 addrspace(3)* nocapture %7, i32 0, i32 0, i32 1, i1 true) #2
|
||||
tail call void @air.wg.barrier(i32 2, i32 1) #7
|
||||
%8 = icmp ult i32 %4, 65536
|
||||
br i1 %8, label %9, label %13
|
||||
|
||||
9: ; preds = %5
|
||||
%10 = and i32 %4, 255
|
||||
%11 = tail call fast float @air.convert.f.f32.u.i32(i32 %10) #1
|
||||
%12 = insertelement <2 x float> undef, float %11, i64 0
|
||||
br label %15
|
||||
|
||||
13: ; preds = %78, %5
|
||||
tail call void @air.wg.barrier(i32 2, i32 1) #7
|
||||
%14 = icmp eq i32 %4, 0
|
||||
br i1 %14, label %84, label %130
|
||||
|
||||
15: ; preds = %78, %9
|
||||
%16 = phi i32 [ %79, %78 ], [ %4, %9 ]
|
||||
%17 = lshr i32 %16, 8
|
||||
%18 = tail call fast float @air.convert.f.f32.u.i32(i32 %17) #1
|
||||
%19 = insertelement <2 x float> %12, float %18, i64 1
|
||||
%20 = fadd fast <2 x float> %19, <float 5.000000e-01, float 5.000000e-01>
|
||||
%21 = fmul fast <2 x float> %20, <float 3.906250e-03, float 3.906250e-03>
|
||||
%22 = tail call { <4 x half>, i8 } @air.sample_texture_2d.v4f16(%struct._texture_2d_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* nocapture readonly bitcast (i64 addrspace(2)* @__air_sampler_state to %struct._sampler_t addrspace(2)*), <2 x float> %21, i1 true, <2 x i32> zeroinitializer, i1 false, float 0.000000e+00, float 0.000000e+00, i32 0) #4
|
||||
%23 = extractvalue { <4 x half>, i8 } %22, 0
|
||||
%24 = extractelement <4 x half> %23, i64 3
|
||||
%25 = fcmp fast ugt half %24, 0xH0000
|
||||
br i1 %25, label %26, label %78
|
||||
|
||||
26: ; preds = %15
|
||||
%27 = shufflevector <4 x half> %23, <4 x half> undef, <3 x i32> <i32 0, i32 1, i32 2>
|
||||
%28 = tail call fast <3 x float> @air.convert.f.v3f32.f.v3f16(<3 x half> %27) #1
|
||||
%29 = tail call fast <3 x float> @air.fast_fmax.v3f32(<3 x float> %28, <3 x float> zeroinitializer) #1
|
||||
%30 = tail call fast <3 x float> @air.fast_pow.v3f32(<3 x float> %29, <3 x float> <float 0x3FDAAAAAA0000000, float 0x3FDAAAAAA0000000, float 0x3FDAAAAAA0000000>) #1
|
||||
%31 = fmul fast <3 x float> %30, <float 0x3FF0E147A0000000, float 0x3FF0E147A0000000, float 0x3FF0E147A0000000>
|
||||
%32 = fadd fast <3 x float> %31, <float 0xBFAC28F5C0000000, float 0xBFAC28F5C0000000, float 0xBFAC28F5C0000000>
|
||||
%33 = fmul fast <3 x float> %28, <float 0x4029D70A40000000, float 0x4029D70A40000000, float 0x4029D70A40000000>
|
||||
%34 = fcmp fast ole <3 x float> %28, <float 0x3F69A5C380000000, float 0x3F69A5C380000000, float 0x3F69A5C380000000>
|
||||
%35 = select reassoc nsz arcp contract afn <3 x i1> %34, <3 x float> %33, <3 x float> %32
|
||||
%36 = tail call fast fastcc <3 x float> @_ZL13applyExposureDv3_fRU11MTLconstantK17DYUniforms(<3 x float> %35, %struct.DYUniforms addrspace(2)* dereferenceable(944) %2) #8
|
||||
%37 = tail call fast float @air.fast_clamp.f32(float 1.000000e+00, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%38 = fcmp fast ugt float %37, 0x3EE4F8B580000000
|
||||
br i1 %38, label %39, label %58
|
||||
|
||||
39: ; preds = %26
|
||||
%40 = tail call i32 @air.get_width_texture_3d(%struct._texture_3d_t addrspace(1)* nocapture readonly %1, i32 0) #5, !alias.scope !24, !noalias !27
|
||||
%41 = tail call fast float @air.convert.f.f32.u.i32(i32 %40) #1
|
||||
%42 = tail call fast <3 x float> @air.fast_clamp.v3f32(<3 x float> %36, <3 x float> zeroinitializer, <3 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>) #1
|
||||
%43 = fadd fast float %41, -1.000000e+00
|
||||
%44 = fdiv fast float %43, %41
|
||||
%45 = insertelement <3 x float> undef, float %44, i64 0
|
||||
%46 = shufflevector <3 x float> %45, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%47 = fmul fast <3 x float> %46, %42
|
||||
%48 = fdiv fast float 5.000000e-01, %41
|
||||
%49 = insertelement <3 x float> undef, float %48, i64 0
|
||||
%50 = shufflevector <3 x float> %49, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%51 = fadd fast <3 x float> %47, %50
|
||||
%52 = tail call { <4 x float>, i8 } @air.sample_texture_3d.v4f32(%struct._texture_3d_t addrspace(1)* nocapture readonly %1, %struct._sampler_t addrspace(2)* nocapture readonly bitcast (i64 addrspace(2)* @__air_sampler_state to %struct._sampler_t addrspace(2)*), <3 x float> %51, i1 true, <3 x i32> zeroinitializer, i1 false, float 0.000000e+00, float 0.000000e+00, i32 0) #4
|
||||
%53 = extractvalue { <4 x float>, i8 } %52, 0
|
||||
%54 = shufflevector <4 x float> %53, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
|
||||
%55 = insertelement <3 x float> undef, float %37, i64 0
|
||||
%56 = shufflevector <3 x float> %55, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%57 = tail call fast <3 x float> @air.mix.v3f32(<3 x float> %36, <3 x float> %54, <3 x float> %56) #1
|
||||
br label %58
|
||||
|
||||
58: ; preds = %39, %26
|
||||
%59 = phi <3 x float> [ %57, %39 ], [ %36, %26 ]
|
||||
%60 = tail call fast fastcc <3 x float> @_ZL26applyToneAfterWhiteBalanceDv3_fRU11MTLconstantK17DYUniforms(<3 x float> %59, %struct.DYUniforms addrspace(2)* dereferenceable(944) %2) #8
|
||||
%61 = tail call fast float @air.dot.v3f32(<3 x float> %60, <3 x float> <float 0x3FCB367A00000000, float 0x3FE6E2EB20000000, float 0x3FB27BB300000000>) #1
|
||||
%62 = tail call fast float @air.fast_clamp.f32(float %61, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%63 = fmul fast float %62, 2.550000e+02
|
||||
%64 = tail call i32 @air.convert.u.i32.f.f32(float %63) #1
|
||||
%65 = tail call i32 @air.min.u.i32(i32 %64, i32 254) #1
|
||||
%66 = tail call fast float @air.convert.f.f32.u.i32(i32 %65) #1
|
||||
%67 = fsub fast float %63, %66
|
||||
%68 = fmul fast float %67, 1.024000e+03
|
||||
%69 = tail call i32 @air.convert.u.i32.f.f32(float %68) #1
|
||||
%70 = zext i32 %65 to i64
|
||||
%71 = sub i32 1024, %69
|
||||
%72 = getelementptr inbounds [256 x %"struct.metal::_atomic"], [256 x %"struct.metal::_atomic"] addrspace(3)* @_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram, i64 0, i64 %70, i32 0
|
||||
%73 = tail call i32 @air.atomic.local.add.u.i32(i32 addrspace(3)* nocapture %72, i32 %71, i32 0, i32 1, i1 true) #2
|
||||
%74 = add i32 %65, 1
|
||||
%75 = zext i32 %74 to i64
|
||||
%76 = getelementptr inbounds [256 x %"struct.metal::_atomic"], [256 x %"struct.metal::_atomic"] addrspace(3)* @_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram, i64 0, i64 %75, i32 0
|
||||
%77 = tail call i32 @air.atomic.local.add.u.i32(i32 addrspace(3)* nocapture %76, i32 %69, i32 0, i32 1, i1 true) #2
|
||||
br label %78
|
||||
|
||||
78: ; preds = %58, %15
|
||||
%79 = add nuw nsw i32 %16, 256
|
||||
%80 = icmp ult i32 %16, 65280
|
||||
br i1 %80, label %15, label %13, !llvm.loop !30
|
||||
|
||||
81: ; preds = %84
|
||||
%82 = fmul fast float %91, 0x3FEEB851E0000000
|
||||
%83 = fmul fast float %91, 0x3FEFD70A40000000
|
||||
br label %96
|
||||
|
||||
84: ; preds = %84, %13
|
||||
%85 = phi float [ %91, %84 ], [ 0.000000e+00, %13 ]
|
||||
%86 = phi i32 [ %92, %84 ], [ 0, %13 ]
|
||||
%87 = zext i32 %86 to i64
|
||||
%88 = getelementptr inbounds [256 x %"struct.metal::_atomic"], [256 x %"struct.metal::_atomic"] addrspace(3)* @_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram, i64 0, i64 %87, i32 0
|
||||
%89 = tail call i32 @air.atomic.local.load.i32(i32 addrspace(3)* nocapture %88, i32 0, i32 1, i1 true) #2
|
||||
%90 = tail call fast float @air.convert.f.f32.u.i32(i32 %89) #1
|
||||
%91 = fadd fast float %90, %85
|
||||
%92 = add nuw nsw i32 %86, 1
|
||||
%93 = icmp eq i32 %92, 256
|
||||
br i1 %93, label %81, label %84, !llvm.loop !32
|
||||
|
||||
94: ; preds = %120
|
||||
%95 = fcmp fast ogt float %91, 0.000000e+00
|
||||
br i1 %95, label %124, label %128
|
||||
|
||||
96: ; preds = %120, %81
|
||||
%97 = phi i32 [ 0, %81 ], [ %122, %120 ]
|
||||
%98 = phi float [ 0.000000e+00, %81 ], [ %121, %120 ]
|
||||
%99 = phi float [ 0.000000e+00, %81 ], [ %105, %120 ]
|
||||
%100 = zext i32 %97 to i64
|
||||
%101 = getelementptr inbounds [256 x %"struct.metal::_atomic"], [256 x %"struct.metal::_atomic"] addrspace(3)* @_ZZ21dyWhitesSceneStatisticsN5metal9texture2dIDhLNS_6accessE0EvEENS_9texture3dIfLS1_0EvEERU11MTLconstantK17DYUniformsPU9MTLdevicefjE9histogram, i64 0, i64 %100, i32 0
|
||||
%102 = tail call i32 @air.atomic.local.load.i32(i32 addrspace(3)* nocapture %101, i32 0, i32 1, i1 true) #2
|
||||
%103 = tail call fast float @air.convert.f.f32.u.i32(i32 %102) #1
|
||||
%104 = tail call fast float @air.fast_fmax.f32(float %82, float %99) #1
|
||||
%105 = fadd fast float %103, %99
|
||||
%106 = tail call fast float @air.fast_fmin.f32(float %83, float %105) #1
|
||||
%107 = fcmp fast ogt float %106, %104
|
||||
br i1 %107, label %108, label %120
|
||||
|
||||
108: ; preds = %96
|
||||
%109 = tail call fast float @air.convert.f.f32.u.i32(i32 %97) #1
|
||||
%110 = fadd fast float %106, %104
|
||||
%111 = fmul fast float %110, 5.000000e-01
|
||||
%112 = fsub fast float %111, %99
|
||||
%113 = fdiv fast float %112, %103
|
||||
%114 = fadd fast float %113, -5.000000e-01
|
||||
%115 = fadd fast float %114, %109
|
||||
%116 = fsub fast float %106, %104
|
||||
%117 = fmul fast float %116, 0x3F70101020000000
|
||||
%118 = fmul fast float %117, %115
|
||||
%119 = fadd fast float %118, %98
|
||||
br label %120
|
||||
|
||||
120: ; preds = %108, %96
|
||||
%121 = phi float [ %119, %108 ], [ %98, %96 ]
|
||||
%122 = add nuw nsw i32 %97, 1
|
||||
%123 = icmp eq i32 %122, 256
|
||||
br i1 %123, label %94, label %96, !llvm.loop !33
|
||||
|
||||
124: ; preds = %94
|
||||
%125 = fmul fast float %91, 0x3FA1EB8600000000
|
||||
%126 = fdiv fast float %121, %125
|
||||
%127 = tail call fast float @air.fast_clamp.f32(float %126, float 0x3FD6666660000000, float 1.000000e+00) #1
|
||||
br label %128
|
||||
|
||||
128: ; preds = %124, %94
|
||||
%129 = phi float [ %127, %124 ], [ 1.000000e+00, %94 ]
|
||||
store float %129, float addrspace(1)* %3, align 4, !tbaa !34, !alias.scope !38, !noalias !39
|
||||
br label %130
|
||||
|
||||
130: ; preds = %128, %13
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.fast_clamp.f32(float, float, float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.fast_fmin.f32(float, float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.fast_fmax.f32(float, float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i32 @air.atomic.local.load.i32(i32 addrspace(3)* nocapture, i32, i32, i1) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i32 @air.atomic.local.add.u.i32(i32 addrspace(3)* nocapture, i32, i32, i32, i1) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i32 @air.convert.u.i32.f.f32(float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i32 @air.min.u.i32(i32, i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.dot.v3f32(<3 x float>, <3 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: inlinehint nounwind readnone
|
||||
define internal fastcc <3 x float> @_ZL26applyToneAfterWhiteBalanceDv3_fRU11MTLconstantK17DYUniforms(<3 x float> %0, %struct.DYUniforms addrspace(2)* nocapture readonly dereferenceable(944) %1) unnamed_addr #3 {
|
||||
%3 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 31
|
||||
%4 = load float, float addrspace(2)* %3, align 8, !tbaa !40
|
||||
%5 = fcmp fast ugt float %4, 5.000000e-01
|
||||
br i1 %5, label %6, label %122
|
||||
|
||||
6: ; preds = %2
|
||||
%7 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 18
|
||||
%8 = load float, float addrspace(2)* %7, align 4, !tbaa !42
|
||||
%9 = fcmp fast ogt float %8, 5.000000e-01
|
||||
%10 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 1
|
||||
%11 = load float, float addrspace(2)* %10, align 4
|
||||
%12 = select fast i1 %9, float %11, float 0.000000e+00
|
||||
%13 = tail call fast float @air.fast_fabs.f32(float %12) #1
|
||||
%14 = fcmp fast olt float %13, 0x3E7AD7F2A0000000
|
||||
br i1 %14, label %44, label %15
|
||||
|
||||
15: ; preds = %6
|
||||
%16 = tail call fast float @air.fast_clamp.f32(float %12, float -1.000000e+02, float 1.000000e+02) #1
|
||||
br label %17
|
||||
|
||||
17: ; preds = %20, %15
|
||||
%18 = phi i32 [ 0, %15 ], [ %21, %20 ]
|
||||
%19 = icmp eq i32 %18, 5
|
||||
br i1 %19, label %26, label %20
|
||||
|
||||
20: ; preds = %17
|
||||
%21 = add nuw nsw i32 %18, 1
|
||||
%22 = zext i32 %21 to i64
|
||||
%23 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %22
|
||||
%24 = load float, float addrspace(2)* %23, align 4, !tbaa !34
|
||||
%25 = fcmp fast ogt float %24, %16
|
||||
br i1 %25, label %26, label %17, !llvm.loop !43
|
||||
|
||||
26: ; preds = %20, %17
|
||||
%27 = icmp ult i32 %18, 5
|
||||
%28 = select i1 %27, i32 %18, i32 5
|
||||
%29 = zext i32 %28 to i64
|
||||
%30 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %29
|
||||
%31 = load float, float addrspace(2)* %30, align 4, !tbaa !34
|
||||
%32 = fsub fast float %16, %31
|
||||
%33 = add nuw nsw i32 %28, 1
|
||||
%34 = zext i32 %33 to i64
|
||||
%35 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %34
|
||||
%36 = load float, float addrspace(2)* %35, align 4, !tbaa !34
|
||||
%37 = fsub fast float %36, %31
|
||||
%38 = fdiv fast float %32, %37
|
||||
%39 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %0, i32 1, i32 %28) #9
|
||||
%40 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %0, i32 1, i32 %33) #9
|
||||
%41 = insertelement <3 x float> undef, float %38, i64 0
|
||||
%42 = shufflevector <3 x float> %41, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%43 = tail call fast <3 x float> @air.mix.v3f32(<3 x float> %39, <3 x float> %40, <3 x float> %42) #1
|
||||
br label %44
|
||||
|
||||
44: ; preds = %26, %6
|
||||
%45 = phi <3 x float> [ %43, %26 ], [ %0, %6 ]
|
||||
%46 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 19
|
||||
%47 = load float, float addrspace(2)* %46, align 8, !tbaa !44
|
||||
%48 = fcmp fast ogt float %47, 5.000000e-01
|
||||
%49 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 2
|
||||
%50 = load float, float addrspace(2)* %49, align 8
|
||||
%51 = select fast i1 %48, float %50, float 0.000000e+00
|
||||
%52 = tail call fast float @air.fast_fabs.f32(float %51) #1
|
||||
%53 = fcmp fast olt float %52, 0x3E7AD7F2A0000000
|
||||
br i1 %53, label %83, label %54
|
||||
|
||||
54: ; preds = %44
|
||||
%55 = tail call fast float @air.fast_clamp.f32(float %51, float -1.000000e+02, float 1.000000e+02) #1
|
||||
br label %56
|
||||
|
||||
56: ; preds = %59, %54
|
||||
%57 = phi i32 [ 0, %54 ], [ %60, %59 ]
|
||||
%58 = icmp eq i32 %57, 5
|
||||
br i1 %58, label %65, label %59
|
||||
|
||||
59: ; preds = %56
|
||||
%60 = add nuw nsw i32 %57, 1
|
||||
%61 = zext i32 %60 to i64
|
||||
%62 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %61
|
||||
%63 = load float, float addrspace(2)* %62, align 4, !tbaa !34
|
||||
%64 = fcmp fast ogt float %63, %55
|
||||
br i1 %64, label %65, label %56, !llvm.loop !43
|
||||
|
||||
65: ; preds = %59, %56
|
||||
%66 = icmp ult i32 %57, 5
|
||||
%67 = select i1 %66, i32 %57, i32 5
|
||||
%68 = zext i32 %67 to i64
|
||||
%69 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %68
|
||||
%70 = load float, float addrspace(2)* %69, align 4, !tbaa !34
|
||||
%71 = fsub fast float %55, %70
|
||||
%72 = add nuw nsw i32 %67, 1
|
||||
%73 = zext i32 %72 to i64
|
||||
%74 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %73
|
||||
%75 = load float, float addrspace(2)* %74, align 4, !tbaa !34
|
||||
%76 = fsub fast float %75, %70
|
||||
%77 = fdiv fast float %71, %76
|
||||
%78 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %45, i32 2, i32 %67) #9
|
||||
%79 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %45, i32 2, i32 %72) #9
|
||||
%80 = insertelement <3 x float> undef, float %77, i64 0
|
||||
%81 = shufflevector <3 x float> %80, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%82 = tail call fast <3 x float> @air.mix.v3f32(<3 x float> %78, <3 x float> %79, <3 x float> %81) #1
|
||||
br label %83
|
||||
|
||||
83: ; preds = %65, %44
|
||||
%84 = phi <3 x float> [ %82, %65 ], [ %45, %44 ]
|
||||
%85 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 20
|
||||
%86 = load float, float addrspace(2)* %85, align 4, !tbaa !45
|
||||
%87 = fcmp fast ogt float %86, 5.000000e-01
|
||||
%88 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 3
|
||||
%89 = load float, float addrspace(2)* %88, align 4
|
||||
%90 = select fast i1 %87, float %89, float 0.000000e+00
|
||||
%91 = tail call fast float @air.fast_fabs.f32(float %90) #1
|
||||
%92 = fcmp fast olt float %91, 0x3E7AD7F2A0000000
|
||||
br i1 %92, label %122, label %93
|
||||
|
||||
93: ; preds = %83
|
||||
%94 = tail call fast float @air.fast_clamp.f32(float %90, float -1.000000e+02, float 1.000000e+02) #1
|
||||
br label %95
|
||||
|
||||
95: ; preds = %98, %93
|
||||
%96 = phi i32 [ 0, %93 ], [ %99, %98 ]
|
||||
%97 = icmp eq i32 %96, 5
|
||||
br i1 %97, label %104, label %98
|
||||
|
||||
98: ; preds = %95
|
||||
%99 = add nuw nsw i32 %96, 1
|
||||
%100 = zext i32 %99 to i64
|
||||
%101 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %100
|
||||
%102 = load float, float addrspace(2)* %101, align 4, !tbaa !34
|
||||
%103 = fcmp fast ogt float %102, %94
|
||||
br i1 %103, label %104, label %95, !llvm.loop !43
|
||||
|
||||
104: ; preds = %98, %95
|
||||
%105 = icmp ult i32 %96, 5
|
||||
%106 = select i1 %105, i32 %96, i32 5
|
||||
%107 = zext i32 %106 to i64
|
||||
%108 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %107
|
||||
%109 = load float, float addrspace(2)* %108, align 4, !tbaa !34
|
||||
%110 = fsub fast float %94, %109
|
||||
%111 = add nuw nsw i32 %106, 1
|
||||
%112 = zext i32 %111 to i64
|
||||
%113 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %112
|
||||
%114 = load float, float addrspace(2)* %113, align 4, !tbaa !34
|
||||
%115 = fsub fast float %114, %109
|
||||
%116 = fdiv fast float %110, %115
|
||||
%117 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %84, i32 3, i32 %106) #9
|
||||
%118 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %84, i32 3, i32 %111) #9
|
||||
%119 = insertelement <3 x float> undef, float %116, i64 0
|
||||
%120 = shufflevector <3 x float> %119, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%121 = tail call fast <3 x float> @air.mix.v3f32(<3 x float> %117, <3 x float> %118, <3 x float> %120) #1
|
||||
br label %122
|
||||
|
||||
122: ; preds = %104, %83, %2
|
||||
%123 = phi <3 x float> [ %0, %2 ], [ %121, %104 ], [ %84, %83 ]
|
||||
ret <3 x float> %123
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare <3 x float> @air.mix.v3f32(<3 x float>, <3 x float>, <3 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: inlinehint nounwind readnone
|
||||
define internal fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %0, i32 %1, i32 %2) unnamed_addr #3 {
|
||||
%4 = icmp eq i32 %2, 3
|
||||
br i1 %4, label %91, label %5
|
||||
|
||||
5: ; preds = %3
|
||||
%6 = zext i32 %1 to i64
|
||||
%7 = sext i32 %2 to i64
|
||||
%8 = getelementptr inbounds [6 x [7 x float]], [6 x [7 x float]] addrspace(2)* @_ZL11lgToneModes, i64 0, i64 %6, i64 %7
|
||||
%9 = load float, float addrspace(2)* %8, align 4, !tbaa !34
|
||||
%10 = fcmp fast ogt float %9, 5.000000e-01
|
||||
br i1 %10, label %11, label %60
|
||||
|
||||
11: ; preds = %5
|
||||
%12 = extractelement <3 x float> %0, i64 0
|
||||
%13 = tail call fast float @air.fast_clamp.f32(float %12, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%14 = fmul fast float %13, 3.200000e+01
|
||||
%15 = tail call i32 @air.convert.s.i32.f.f32(float %14) #1
|
||||
%16 = tail call i32 @air.min.s.i32(i32 %15, i32 31) #1
|
||||
%17 = sext i32 %16 to i64
|
||||
%18 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %17
|
||||
%19 = load float, float addrspace(2)* %18, align 4, !tbaa !34
|
||||
%20 = add nsw i32 %16, 1
|
||||
%21 = sext i32 %20 to i64
|
||||
%22 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %21
|
||||
%23 = load float, float addrspace(2)* %22, align 4, !tbaa !34
|
||||
%24 = tail call fast float @air.convert.f.f32.s.i32(i32 %16) #1
|
||||
%25 = fsub fast float %14, %24
|
||||
%26 = tail call fast float @air.mix.f32(float %19, float %23, float %25) #1
|
||||
%27 = insertelement <3 x float> undef, float %26, i64 0
|
||||
%28 = extractelement <3 x float> %0, i64 1
|
||||
%29 = tail call fast float @air.fast_clamp.f32(float %28, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%30 = fmul fast float %29, 3.200000e+01
|
||||
%31 = tail call i32 @air.convert.s.i32.f.f32(float %30) #1
|
||||
%32 = tail call i32 @air.min.s.i32(i32 %31, i32 31) #1
|
||||
%33 = sext i32 %32 to i64
|
||||
%34 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %33
|
||||
%35 = load float, float addrspace(2)* %34, align 4, !tbaa !34
|
||||
%36 = add nsw i32 %32, 1
|
||||
%37 = sext i32 %36 to i64
|
||||
%38 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %37
|
||||
%39 = load float, float addrspace(2)* %38, align 4, !tbaa !34
|
||||
%40 = tail call fast float @air.convert.f.f32.s.i32(i32 %32) #1
|
||||
%41 = fsub fast float %30, %40
|
||||
%42 = tail call fast float @air.mix.f32(float %35, float %39, float %41) #1
|
||||
%43 = insertelement <3 x float> %27, float %42, i64 1
|
||||
%44 = extractelement <3 x float> %0, i64 2
|
||||
%45 = tail call fast float @air.fast_clamp.f32(float %44, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%46 = fmul fast float %45, 3.200000e+01
|
||||
%47 = tail call i32 @air.convert.s.i32.f.f32(float %46) #1
|
||||
%48 = tail call i32 @air.min.s.i32(i32 %47, i32 31) #1
|
||||
%49 = sext i32 %48 to i64
|
||||
%50 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %49
|
||||
%51 = load float, float addrspace(2)* %50, align 4, !tbaa !34
|
||||
%52 = add nsw i32 %48, 1
|
||||
%53 = sext i32 %52 to i64
|
||||
%54 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %53
|
||||
%55 = load float, float addrspace(2)* %54, align 4, !tbaa !34
|
||||
%56 = tail call fast float @air.convert.f.f32.s.i32(i32 %48) #1
|
||||
%57 = fsub fast float %46, %56
|
||||
%58 = tail call fast float @air.mix.f32(float %51, float %55, float %57) #1
|
||||
%59 = insertelement <3 x float> %43, float %58, i64 2
|
||||
br label %91
|
||||
|
||||
60: ; preds = %5
|
||||
%61 = tail call fast float @air.dot.v3f32(<3 x float> %0, <3 x float> <float 0x3FCB367A00000000, float 0x3FE6E2EB20000000, float 0x3FB27BB300000000>) #1
|
||||
%62 = tail call fast float @air.fast_clamp.f32(float %61, float 0.000000e+00, float 1.000000e+00) #1
|
||||
%63 = fmul fast float %62, 3.200000e+01
|
||||
%64 = tail call i32 @air.convert.s.i32.f.f32(float %63) #1
|
||||
%65 = tail call i32 @air.min.s.i32(i32 %64, i32 31) #1
|
||||
%66 = sext i32 %65 to i64
|
||||
%67 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %66
|
||||
%68 = load float, float addrspace(2)* %67, align 4, !tbaa !34
|
||||
%69 = add nsw i32 %65, 1
|
||||
%70 = sext i32 %69 to i64
|
||||
%71 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL12lgToneCurves, i64 0, i64 %6, i64 %7, i64 %70
|
||||
%72 = load float, float addrspace(2)* %71, align 4, !tbaa !34
|
||||
%73 = tail call fast float @air.convert.f.f32.s.i32(i32 %65) #1
|
||||
%74 = fsub fast float %63, %73
|
||||
%75 = tail call fast float @air.mix.f32(float %68, float %72, float %74) #1
|
||||
%76 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL14lgChromaScales, i64 0, i64 %6, i64 %7, i64 %66
|
||||
%77 = load float, float addrspace(2)* %76, align 4, !tbaa !34
|
||||
%78 = getelementptr inbounds [6 x [7 x [33 x float]]], [6 x [7 x [33 x float]]] addrspace(2)* @_ZL14lgChromaScales, i64 0, i64 %6, i64 %7, i64 %70
|
||||
%79 = load float, float addrspace(2)* %78, align 4, !tbaa !34
|
||||
%80 = tail call fast float @air.mix.f32(float %77, float %79, float %74) #1
|
||||
%81 = insertelement <3 x float> undef, float %75, i64 0
|
||||
%82 = shufflevector <3 x float> %81, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%83 = insertelement <3 x float> undef, float %61, i64 0
|
||||
%84 = shufflevector <3 x float> %83, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%85 = fsub fast <3 x float> %0, %84
|
||||
%86 = insertelement <3 x float> undef, float %80, i64 0
|
||||
%87 = shufflevector <3 x float> %86, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%88 = fmul fast <3 x float> %87, %85
|
||||
%89 = fadd fast <3 x float> %88, %82
|
||||
%90 = tail call fast <3 x float> @air.fast_clamp.v3f32(<3 x float> %89, <3 x float> zeroinitializer, <3 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>) #1
|
||||
br label %91
|
||||
|
||||
91: ; preds = %60, %11, %3
|
||||
%92 = phi <3 x float> [ %0, %3 ], [ %59, %11 ], [ %90, %60 ]
|
||||
ret <3 x float> %92
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare <3 x float> @air.fast_clamp.v3f32(<3 x float>, <3 x float>, <3 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.mix.f32(float, float, float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.convert.f.f32.s.i32(i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i32 @air.min.s.i32(i32, i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i32 @air.convert.s.i32.f.f32(float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.fast_fabs.f32(float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: argmemonly convergent nounwind readonly
|
||||
declare { <4 x float>, i8 } @air.sample_texture_3d.v4f32(%struct._texture_3d_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)* nocapture readonly, <3 x float>, i1, <3 x i32>, i1, float, float, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: argmemonly nounwind readonly
|
||||
declare i32 @air.get_width_texture_3d(%struct._texture_3d_t addrspace(1)* nocapture readonly, i32) local_unnamed_addr #5
|
||||
|
||||
; Function Attrs: inlinehint nounwind readnone
|
||||
define internal fastcc <3 x float> @_ZL13applyExposureDv3_fRU11MTLconstantK17DYUniforms(<3 x float> %0, %struct.DYUniforms addrspace(2)* nocapture readonly dereferenceable(944) %1) unnamed_addr #6 {
|
||||
%3 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 31
|
||||
%4 = load float, float addrspace(2)* %3, align 8, !tbaa !40
|
||||
%5 = fcmp fast ugt float %4, 5.000000e-01
|
||||
br i1 %5, label %6, label %73
|
||||
|
||||
6: ; preds = %2
|
||||
%7 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 17
|
||||
%8 = load float, float addrspace(2)* %7, align 16, !tbaa !46
|
||||
%9 = fcmp fast ogt float %8, 5.000000e-01
|
||||
br i1 %9, label %10, label %14
|
||||
|
||||
10: ; preds = %6
|
||||
%11 = getelementptr inbounds %struct.DYUniforms, %struct.DYUniforms addrspace(2)* %1, i64 0, i32 0
|
||||
%12 = load float, float addrspace(2)* %11, align 16, !tbaa !47
|
||||
%13 = tail call fast float @air.fast_clamp.f32(float %12, float -5.000000e+00, float 5.000000e+00) #1
|
||||
br label %14
|
||||
|
||||
14: ; preds = %10, %6
|
||||
%15 = phi float [ %13, %10 ], [ 0.000000e+00, %6 ]
|
||||
%16 = fmul fast float %15, 5.000000e+01
|
||||
%17 = tail call fast float @air.fast_fabs.f32(float %16) #1
|
||||
%18 = fcmp fast olt float %17, 0x3E7AD7F2A0000000
|
||||
br i1 %18, label %48, label %19
|
||||
|
||||
19: ; preds = %14
|
||||
%20 = tail call fast float @air.fast_clamp.f32(float %16, float -1.000000e+02, float 1.000000e+02) #1
|
||||
br label %21
|
||||
|
||||
21: ; preds = %24, %19
|
||||
%22 = phi i32 [ 0, %19 ], [ %25, %24 ]
|
||||
%23 = icmp eq i32 %22, 5
|
||||
br i1 %23, label %30, label %24
|
||||
|
||||
24: ; preds = %21
|
||||
%25 = add nuw nsw i32 %22, 1
|
||||
%26 = zext i32 %25 to i64
|
||||
%27 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %26
|
||||
%28 = load float, float addrspace(2)* %27, align 4, !tbaa !34
|
||||
%29 = fcmp fast ogt float %28, %20
|
||||
br i1 %29, label %30, label %21, !llvm.loop !43
|
||||
|
||||
30: ; preds = %24, %21
|
||||
%31 = icmp ult i32 %22, 5
|
||||
%32 = select i1 %31, i32 %22, i32 5
|
||||
%33 = zext i32 %32 to i64
|
||||
%34 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %33
|
||||
%35 = load float, float addrspace(2)* %34, align 4, !tbaa !34
|
||||
%36 = fsub fast float %20, %35
|
||||
%37 = add nuw nsw i32 %32, 1
|
||||
%38 = zext i32 %37 to i64
|
||||
%39 = getelementptr inbounds [7 x float], [7 x float] addrspace(2)* @_ZL7lgStops, i64 0, i64 %38
|
||||
%40 = load float, float addrspace(2)* %39, align 4, !tbaa !34
|
||||
%41 = fsub fast float %40, %35
|
||||
%42 = fdiv fast float %36, %41
|
||||
%43 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %0, i32 0, i32 %32) #9
|
||||
%44 = tail call fast fastcc <3 x float> @_ZL10toneAtStopDv3_fii(<3 x float> %0, i32 0, i32 %37) #9
|
||||
%45 = insertelement <3 x float> undef, float %42, i64 0
|
||||
%46 = shufflevector <3 x float> %45, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%47 = tail call fast <3 x float> @air.mix.v3f32(<3 x float> %43, <3 x float> %44, <3 x float> %46) #1
|
||||
br label %48
|
||||
|
||||
48: ; preds = %30, %14
|
||||
%49 = phi <3 x float> [ %47, %30 ], [ %0, %14 ]
|
||||
%50 = tail call fast float @air.fast_fabs.f32(float %15) #1
|
||||
%51 = fcmp fast ogt float %50, 2.000000e+00
|
||||
br i1 %51, label %52, label %73
|
||||
|
||||
52: ; preds = %48
|
||||
%53 = fadd fast <3 x float> %49, <float 0x3FAC28F5C0000000, float 0x3FAC28F5C0000000, float 0x3FAC28F5C0000000>
|
||||
%54 = fmul fast <3 x float> %53, <float 0x3FEE54EDE0000000, float 0x3FEE54EDE0000000, float 0x3FEE54EDE0000000>
|
||||
%55 = tail call fast <3 x float> @air.fast_fmax.v3f32(<3 x float> %54, <3 x float> zeroinitializer) #1
|
||||
%56 = tail call fast <3 x float> @air.fast_pow.v3f32(<3 x float> %55, <3 x float> <float 0x4003333340000000, float 0x4003333340000000, float 0x4003333340000000>) #1
|
||||
%57 = fmul fast <3 x float> %49, <float 0x3FB3D07220000000, float 0x3FB3D07220000000, float 0x3FB3D07220000000>
|
||||
%58 = fcmp fast ole <3 x float> %49, <float 0x3FA4B5DCC0000000, float 0x3FA4B5DCC0000000, float 0x3FA4B5DCC0000000>
|
||||
%59 = select reassoc nsz arcp contract afn <3 x i1> %58, <3 x float> %57, <3 x float> %56
|
||||
%60 = tail call fast float @air.fast_clamp.f32(float %15, float -2.000000e+00, float 2.000000e+00) #1
|
||||
%61 = fsub fast float %15, %60
|
||||
%62 = tail call fast float @air.fast_exp2.f32(float %61) #1
|
||||
%63 = insertelement <3 x float> undef, float %62, i64 0
|
||||
%64 = shufflevector <3 x float> %63, <3 x float> undef, <3 x i32> zeroinitializer
|
||||
%65 = fmul fast <3 x float> %64, %59
|
||||
%66 = tail call fast <3 x float> @air.fast_fmax.v3f32(<3 x float> %65, <3 x float> zeroinitializer) #1
|
||||
%67 = tail call fast <3 x float> @air.fast_pow.v3f32(<3 x float> %66, <3 x float> <float 0x3FDAAAAAA0000000, float 0x3FDAAAAAA0000000, float 0x3FDAAAAAA0000000>) #1
|
||||
%68 = fmul fast <3 x float> %67, <float 0x3FF0E147A0000000, float 0x3FF0E147A0000000, float 0x3FF0E147A0000000>
|
||||
%69 = fadd fast <3 x float> %68, <float 0xBFAC28F5C0000000, float 0xBFAC28F5C0000000, float 0xBFAC28F5C0000000>
|
||||
%70 = fmul fast <3 x float> %65, <float 0x4029D70A40000000, float 0x4029D70A40000000, float 0x4029D70A40000000>
|
||||
%71 = fcmp fast ole <3 x float> %65, <float 0x3F69A5C380000000, float 0x3F69A5C380000000, float 0x3F69A5C380000000>
|
||||
%72 = select reassoc nsz arcp contract afn <3 x i1> %71, <3 x float> %70, <3 x float> %69
|
||||
br label %73
|
||||
|
||||
73: ; preds = %52, %48, %2
|
||||
%74 = phi <3 x float> [ %0, %2 ], [ %72, %52 ], [ %49, %48 ]
|
||||
ret <3 x float> %74
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare <3 x float> @air.fast_pow.v3f32(<3 x float>, <3 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare <3 x float> @air.fast_fmax.v3f32(<3 x float>, <3 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare float @air.fast_exp2.f32(float) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare <3 x float> @air.convert.f.v3f32.f.v3f16(<3 x half>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: argmemonly convergent nounwind readonly
|
||||
declare { <4 x half>, i8 } @air.sample_texture_2d.v4f16(%struct._texture_2d_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)* nocapture readonly, <2 x float>, i1, <2 x i32>, i1, float, float, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: convergent nounwind
|
||||
declare void @air.wg.barrier(i32, i32) local_unnamed_addr #7
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @air.atomic.local.store.i32(i32 addrspace(3)* nocapture, i32, i32, i32, i1) local_unnamed_addr #2
|
||||
|
||||
attributes #0 = { convergent nounwind "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" }
|
||||
attributes #1 = { nounwind readnone }
|
||||
attributes #2 = { nounwind }
|
||||
attributes #3 = { inlinehint nounwind readnone "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" }
|
||||
attributes #4 = { argmemonly convergent nounwind readonly }
|
||||
attributes #5 = { argmemonly nounwind readonly }
|
||||
attributes #6 = { inlinehint nounwind readnone "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" }
|
||||
attributes #7 = { convergent nounwind }
|
||||
attributes #8 = { nobuiltin "no-builtins" }
|
||||
attributes #9 = { nobuiltin nounwind "no-builtins" }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7}
|
||||
!llvm.ident = !{!8}
|
||||
!air.version = !{!9}
|
||||
!air.language_version = !{!10}
|
||||
!air.compile_options = !{!11, !12, !13}
|
||||
!air.kernel = !{!14}
|
||||
!air.sampler_states = !{!23}
|
||||
|
||||
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 15, i32 5]}
|
||||
!1 = !{i32 1, !"wchar_size", i32 4}
|
||||
!2 = !{i32 7, !"air.max_device_buffers", i32 31}
|
||||
!3 = !{i32 7, !"air.max_constant_buffers", i32 31}
|
||||
!4 = !{i32 7, !"air.max_threadgroup_buffers", i32 31}
|
||||
!5 = !{i32 7, !"air.max_textures", i32 128}
|
||||
!6 = !{i32 7, !"air.max_read_write_textures", i32 8}
|
||||
!7 = !{i32 7, !"air.max_samplers", i32 16}
|
||||
!8 = !{!"Apple metal version 32023.620 (metalfe-32023.620)"}
|
||||
!9 = !{i32 2, i32 6, i32 0}
|
||||
!10 = !{!"Metal", i32 3, i32 0, i32 0}
|
||||
!11 = !{!"air.compile.denorms_disable"}
|
||||
!12 = !{!"air.compile.fast_math_enable"}
|
||||
!13 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!14 = !{void (%struct._texture_2d_t addrspace(1)*, %struct._texture_3d_t addrspace(1)*, %struct.DYUniforms addrspace(2)*, float addrspace(1)*, i32)* @dyWhitesSceneStatistics, !15, !16}
|
||||
!15 = !{}
|
||||
!16 = !{!17, !18, !19, !21, !22}
|
||||
!17 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<half, sample>", !"air.arg_name", !"source"}
|
||||
!18 = !{i32 1, !"air.texture", !"air.location_index", i32 1, i32 1, !"air.sample", !"air.arg_type_name", !"texture3d<float, sample>", !"air.arg_name", !"whiteBalanceTexture"}
|
||||
!19 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 944, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !20, !"air.arg_type_size", i32 944, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"DYUniforms", !"air.arg_name", !"uniforms"}
|
||||
!20 = !{i32 0, i32 4, i32 0, !"float", !"exposure", i32 4, i32 4, i32 0, !"float", !"contrast", i32 8, i32 4, i32 0, !"float", !"highlights", i32 12, i32 4, i32 0, !"float", !"shadows", i32 16, i32 4, i32 0, !"float", !"whites", i32 20, i32 4, i32 0, !"float", !"blacks", i32 24, i32 4, i32 0, !"float", !"temperature", i32 28, i32 4, i32 0, !"float", !"tint", i32 32, i32 4, i32 0, !"float", !"saturation", i32 36, i32 4, i32 0, !"float", !"vibrance", i32 40, i32 4, i32 0, !"float", !"texture", i32 44, i32 4, i32 0, !"float", !"clarity", i32 48, i32 4, i32 0, !"float", !"dehaze", i32 52, i32 4, i32 0, !"float", !"inputProfile", i32 56, i32 4, i32 0, !"float", !"preLUTStrength", i32 60, i32 4, i32 0, !"float", !"postLUTStrength", i32 64, i32 16, i32 0, !"float4", !"extraPostLUTStrengths", i32 80, i32 4, i32 0, !"float", !"exposureEnabled", i32 84, i32 4, i32 0, !"float", !"contrastEnabled", i32 88, i32 4, i32 0, !"float", !"highlightsEnabled", i32 92, i32 4, i32 0, !"float", !"shadowsEnabled", i32 96, i32 4, i32 0, !"float", !"whitesEnabled", i32 100, i32 4, i32 0, !"float", !"blacksEnabled", i32 104, i32 4, i32 0, !"float", !"temperatureEnabled", i32 108, i32 4, i32 0, !"float", !"tintEnabled", i32 112, i32 4, i32 0, !"float", !"saturationEnabled", i32 116, i32 4, i32 0, !"float", !"vibranceEnabled", i32 120, i32 4, i32 0, !"float", !"textureEnabled", i32 124, i32 4, i32 0, !"float", !"clarityEnabled", i32 128, i32 4, i32 0, !"float", !"dehazeEnabled", i32 132, i32 4, i32 0, !"float", !"inputSectionEnabled", i32 136, i32 4, i32 0, !"float", !"baseSectionEnabled", i32 140, i32 4, i32 0, !"float", !"colorSectionEnabled", i32 144, i32 4, i32 0, !"float", !"lookSectionEnabled", i32 160, i32 16, i32 0, !"float4", !"extraLookSectionEnableds", i32 176, i32 4, i32 0, !"float", !"curveSectionEnabled", i32 180, i32 4, i32 0, !"float", !"hslSectionEnabled", i32 184, i32 4, i32 0, !"float", !"curveShadows", i32 188, i32 4, i32 0, !"float", !"curveDarks", i32 192, i32 4, i32 0, !"float", !"curveLights", i32 196, i32 4, i32 0, !"float", !"curveHighlights", i32 200, i32 4, i32 0, !"float", !"redCurveShadows", i32 204, i32 4, i32 0, !"float", !"redCurveHighlights", i32 208, i32 4, i32 0, !"float", !"greenCurveShadows", i32 212, i32 4, i32 0, !"float", !"greenCurveHighlights", i32 216, i32 4, i32 0, !"float", !"blueCurveShadows", i32 220, i32 4, i32 0, !"float", !"blueCurveHighlights", i32 224, i32 16, i32 0, !"float4", !"curveX", i32 240, i32 8, i32 0, !"float2", !"redCurveX", i32 248, i32 8, i32 0, !"float2", !"greenCurveX", i32 256, i32 8, i32 0, !"float2", !"blueCurveX", i32 272, i32 16, i32 0, !"float4", !"hslHueA", i32 288, i32 16, i32 0, !"float4", !"hslHueB", i32 304, i32 16, i32 0, !"float4", !"hslSatA", i32 320, i32 16, i32 0, !"float4", !"hslSatB", i32 336, i32 16, i32 0, !"float4", !"hslLumA", i32 352, i32 16, i32 0, !"float4", !"hslLumB", i32 368, i32 16, i32 0, !"float3", !"hslCustomSample", i32 384, i32 16, i32 0, !"float3", !"hslCustomAdjust", i32 400, i32 4, i32 0, !"float", !"colorGradingSectionEnabled", i32 404, i32 4, i32 0, !"float", !"colorGradingBlending", i32 408, i32 4, i32 0, !"float", !"colorGradingBalance", i32 416, i32 16, i32 0, !"float4", !"colorGradingHueSatA", i32 432, i32 16, i32 0, !"float4", !"colorGradingHueSatB", i32 448, i32 16, i32 0, !"float3", !"colorGradingLuma", i32 464, i32 16, i32 0, !"float3", !"skinProtection", i32 480, i32 4, i32 0, !"float", !"primariesSectionEnabled", i32 484, i32 4, i32 0, !"float", !"redPrimaryHue", i32 488, i32 4, i32 0, !"float", !"redPrimarySaturation", i32 492, i32 4, i32 0, !"float", !"greenPrimaryHue", i32 496, i32 4, i32 0, !"float", !"greenPrimarySaturation", i32 500, i32 4, i32 0, !"float", !"bluePrimaryHue", i32 504, i32 4, i32 0, !"float", !"bluePrimarySaturation", i32 512, i32 16, i32 0, !"float3", !"primariesM0", i32 528, i32 16, i32 0, !"float3", !"primariesM1", i32 544, i32 16, i32 0, !"float3", !"primariesM2", i32 560, i32 16, i32 0, !"float3", !"hslCustomRange", i32 576, i32 4, i32 0, !"float", !"hslCustomVisualize", i32 592, i32 16, i32 0, !"float3", !"colorGradingGlobal", i32 608, i32 4, i32 0, !"float", !"levelsSectionEnabled", i32 624, i32 16, i32 0, !"float4", !"levelsInputBlack", i32 640, i32 16, i32 0, !"float4", !"levelsGamma", i32 656, i32 16, i32 0, !"float4", !"levelsInputWhite", i32 672, i32 16, i32 0, !"float4", !"levelsOutputBlack", i32 688, i32 16, i32 0, !"float4", !"levelsOutputWhite", i32 704, i32 4, i32 0, !"float", !"blackWhiteSectionEnabled", i32 720, i32 16, i32 0, !"float4", !"blackWhiteMixA", i32 736, i32 8, i32 0, !"float2", !"blackWhiteMixB", i32 744, i32 8, i32 0, !"float2", !"blackWhiteTint", i32 752, i32 4, i32 0, !"float", !"colorBalanceSectionEnabled", i32 756, i32 4, i32 0, !"float", !"colorBalancePreserveLuminosity", i32 768, i32 16, i32 0, !"float3", !"colorBalanceShadows", i32 784, i32 16, i32 0, !"float3", !"colorBalanceMidtones", i32 800, i32 16, i32 0, !"float3", !"colorBalanceHighlights", i32 816, i32 Line truncated
|
||||
!21 = !{i32 3, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"sceneLevel"}
|
||||
!22 = !{i32 4, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"}
|
||||
!23 = !{!"air.sampler_state", i64 addrspace(2)* @__air_sampler_state}
|
||||
!24 = !{!25}
|
||||
!25 = distinct !{!25, !26, !"air-alias-scope-textures"}
|
||||
!26 = distinct !{!26, !"air-alias-scopes(dyWhitesSceneStatistics)"}
|
||||
!27 = !{!28, !29}
|
||||
!28 = distinct !{!28, !26, !"air-alias-scope-arg(2)"}
|
||||
!29 = distinct !{!29, !26, !"air-alias-scope-arg(3)"}
|
||||
!30 = distinct !{!30, !31}
|
||||
!31 = !{!"llvm.loop.mustprogress"}
|
||||
!32 = distinct !{!32, !31}
|
||||
!33 = distinct !{!33, !31}
|
||||
!34 = !{!35, !35, i64 0}
|
||||
!35 = !{!"float", !36, i64 0}
|
||||
!36 = !{!"omnipotent char", !37, i64 0}
|
||||
!37 = !{!"Simple C++ TBAA"}
|
||||
!38 = !{!29}
|
||||
!39 = !{!25, !28}
|
||||
!40 = !{!41, !35, i64 136}
|
||||
!41 = !{!"_ZTS17DYUniforms", !35, i64 0, !35, i64 4, !35, i64 8, !35, i64 12, !35, i64 16, !35, i64 20, !35, i64 24, !35, i64 28, !35, i64 32, !35, i64 36, !35, i64 40, !35, i64 44, !35, i64 48, !35, i64 52, !35, i64 56, !35, i64 60, !36, i64 64, !35, i64 80, !35, i64 84, !35, i64 88, !35, i64 92, !35, i64 96, !35, i64 100, !35, i64 104, !35, i64 108, !35, i64 112, !35, i64 116, !35, i64 120, !35, i64 124, !35, i64 128, !35, i64 132, !35, i64 136, !35, i64 140, !35, i64 144, !36, i64 160, !35, i64 176, !35, i64 180, !35, i64 184, !35, i64 188, !35, i64 192, !35, i64 196, !35, i64 200, !35, i64 204, !35, i64 208, !35, i64 212, !35, i64 216, !35, i64 220, !36, i64 224, !36, i64 240, !36, i64 248, !36, i64 256, !36, i64 272, !36, i64 288, !36, i64 304, !36, i64 320, !36, i64 336, !36, i64 352, !36, i64 368, !36, i64 384, !35, i64 400, !35, i64 404, !35, i64 408, !36, i64 416, !36, i64 432, !36, i64 448, !36, i64 464, !35, i64 480, !35, i64 484, !35, i64 488, !35, i64 492, !35, i64 496, !35, i64 500, !35, i64 504, !36, i64 512, !36, i64 528, !36, i64 544, !36, i64 560, !35, i64 576, !36, i64 592, !35, i64 608, !36, i64 624, !36, i64 640, !36, i64 656, !36, i64 672, !36, i64 688, !35, i64 704, !36, i64 720, !36, i64 736, !36, i64 744, !35, i64 752, !35, i64 756, !36, i64 768, !36, i64 784, !36, i64 800, !36, i64 816, !36, i64 832, !36, i64 848, !36, i64 864, !36, i64 880, !36, i64 896, !36, i64 912, !36, i64 928}
|
||||
!42 = !{!41, !35, i64 84}
|
||||
!43 = distinct !{!43, !31}
|
||||
!44 = !{!41, !35, i64 88}
|
||||
!45 = !{!41, !35, i64 92}
|
||||
!46 = !{!41, !35, i64 80}
|
||||
!47 = !{!41, !35, i64 0}
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"artifact": "/Library/Plug-Ins/FxPlug/LumiGrade.app/Contents/PlugIns/LumiGrade XPC Service.pluginkit/Contents/Resources/default.metallib",
|
||||
"sha256": "dfb294c9584d3ff23d3ff660c2a2a80c506b31893caf731babd6f4ddddb8fb77",
|
||||
"size": 162272,
|
||||
"source_authority": "shipped-artifact; static instruction graph, not original source",
|
||||
"tool": "xcrun metal-opt -S (Apple Metal Toolchain 27.1)",
|
||||
"source_modules": [
|
||||
{
|
||||
"path": "module0.air",
|
||||
"offset": 971,
|
||||
"size": 26272,
|
||||
"bitcode_size": 26252,
|
||||
"cputype": 4294967295
|
||||
},
|
||||
{
|
||||
"path": "module1.air",
|
||||
"offset": 27243,
|
||||
"size": 50196,
|
||||
"bitcode_size": 50176,
|
||||
"cputype": 4294967295
|
||||
},
|
||||
{
|
||||
"path": "module2.air",
|
||||
"offset": 77451,
|
||||
"size": 3808,
|
||||
"bitcode_size": 3788,
|
||||
"cputype": 4294967295
|
||||
},
|
||||
{
|
||||
"path": "module3.air",
|
||||
"offset": 81259,
|
||||
"size": 57312,
|
||||
"bitcode_size": 57292,
|
||||
"cputype": 4294967295
|
||||
},
|
||||
{
|
||||
"path": "module4.air",
|
||||
"offset": 138571,
|
||||
"size": 4480,
|
||||
"bitcode_size": 4460,
|
||||
"cputype": 4294967295
|
||||
}
|
||||
],
|
||||
"changes": [
|
||||
"DYGradeKernel is callable color helper, texture-center sample and alpha boundary owned by DYGrade.metal",
|
||||
"Trial licensing/watermark entry paths, function, glyph table and metadata removed; no authorization or network logic included",
|
||||
"Uniform type renamed to DYUniforms with exact 944-byte layout",
|
||||
"Statistics and LUT export kernels renamed to Dayu names; math preserved",
|
||||
"CPU-generated white-balance, HSL-mixer, color-grading 3D LUT data remains external input",
|
||||
"AIR target deployment raised from macOS13.0/AIR2.5 to macOS14.6/AIR2.6 for linking with the current Metal toolchain; numeric operations unchanged",
|
||||
"Required sampler-state metadata preserved when extracting callable arithmetic helper"
|
||||
],
|
||||
"coverage": "Static exact arithmetic retained for finite target version; runtime parity requires independent GPU samples, CPU LUT generation and host integration.",
|
||||
"versioned_source_sha256": {
|
||||
"tools/kernels/DYGradeKernel.ll": "94901d0ba327d697272be669a5fc29aca0ec98295036ef9fb316584c15f0bf1e",
|
||||
"tools/kernels/DYStatisticsKernel.ll": "30b7a5108671247372a78944ecaf1d600fd5e40f41a9febb7d6e39265727d3e3",
|
||||
"tools/kernels/DYLUTExportKernel.ll": "f386258f59bbe5f429edd5977c0eaadba4315a2864ddc5c75e25c9dd4260de54"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# 可重建调色内核
|
||||
|
||||
生产构建只读取本目录的 LLVM AIR 文本和项目的 `DYGrade.metal`,不读取原厂 App、原始 metallib、网络或授权状态。来源、原始模块范围和改动见 `PROVENANCE.json`。这些文本是从已交付着色器还原的指令图,不是原始 Metal 源码。
|
||||
|
||||
```sh
|
||||
python3 tools/build_kernels.py --output /absolute/default.metallib --intermediates /absolute/cache
|
||||
```
|
||||
|
||||
`DYGradeKernel.ll` 保留参考颜色数学:线性输入转 sRGB 编码域 → 输入 LUT → RGB 三原色矩阵 → 曝光 → 白平衡 LUT → 对比/高光/阴影 → 自适应白场 → 黑场 → 局部纹理/清晰度/去雾 → 主及 RGB 曲线 → 主及 RGB 色阶 → 色彩平衡 → 8 色 HSL LUT 与自定义 HSL → 分级 LUT → 自然饱和/饱和度 → 黑白 → 5 层风格 LUT → 肤色保护 → 线性输出。中性参数直接返回输入;各章节和单项旁路保留。原许可、水印、字形表及其参数已移除。
|
||||
|
||||
CPU 和 Metal 共用 `DYUniforms.h`。大小 944 字节、16 字节对齐,102 个字段逐一检查偏移。普通调整中性为 0;色阶 white 为 255、gamma 为 1;黑白模式默认关闭;额外曲线点的 X 小于 0 表示该点不存在。白平衡、8 色 HSL 和分级由 CPU 生成 3D LUT,不能拿 identity 占位声称完成这些功能。
|
||||
|
||||
`dyVertex` 使用 buffer0 `DYVertex2D[4]`、buffer1 `uint2 viewport`;像素位置围绕输出中心,UV 对应输入纹理。`dyFragment` 绑定:
|
||||
|
||||
| 位置 | 纹理 |
|
||||
| --- | --- |
|
||||
| 0 | linear straight RGBA source |
|
||||
| 1 | 输入 3D LUT |
|
||||
| 2–6 | 按顺序混合的 5 层风格 LUT |
|
||||
| 7 | HSL mixer 3D LUT |
|
||||
| 8 | 白平衡 3D LUT |
|
||||
| 9 | 色彩分级 3D LUT |
|
||||
|
||||
fragment buffer0 为 `DYUniforms`,buffer1 为 `float sceneLevel`,buffer2 必须绑定 16 字节 `DYRenderOptions`。其首 uint `outputPremultiplied` 控制处理后是否乘回 alpha,其余为 0。source 应已是 straight RGB;若宿主提供预乘颜色,先运行 `dyUnpremultiply`(texture0 读源、texture1 写不同的 RGBA16Float 目标),统计与所有邻域采样都使用该 straight 纹理。alpha<=0 输出 RGBA0;非零 alpha 保留输入 alpha。半精度转换会产生量化误差。
|
||||
|
||||
`dyPreview` 为每实例缩略采样核:texture0 straight linear source、buffer0 写 `float4[4096]`;调度64×64,每格按归一化中心采样,RGB使用标准sRGB分段编码,alpha原样保留。不夹断HDR或负值;CPU用途自行决定显示、统计的有效范围。
|
||||
|
||||
局部滤镜最大采样半径 18×1.7=30.6 像素;tile 请求至少 32 像素 halo,并设置正确的 UV。自适应白场必须采用全帧统计;不能逐 tile 算独立白场。
|
||||
|
||||
`dyWhitesSceneStatistics` 绑定 texture0 source、texture1 白平衡 LUT、buffer0 uniforms、buffer1 写 float。必须只调度 1 个 threadgroup、每组 256 个线程。固定取 256×256 均匀网格,跳过 alpha<=0;统计 96%–99.5% 亮度区间,结果钳制 0.35–1。此路径按参考行为不执行输入 LUT/三原色矩阵。
|
||||
|
||||
`dyLUTExportKernel` 绑定 texture0–8 为上表 1–9;buffer0 uniforms、buffer1 写 float RGB、buffer2 uint cubeSize;调度 cubeSize³ 个线性线程。输出 red-fastest RGB triples(每格3个float)。空间纹理/清晰度无法写进 3D LUT,参考导出路径本身也省略这些操作。自适应白场按导出核既定逻辑处理,不能把导出 LUT 等同于任意画面渲染。
|
||||
|
||||
GPU 检查只运行命令行,不启动测试 App:
|
||||
|
||||
```sh
|
||||
xcrun clang++ -std=c++17 -fobjc-arc -framework Foundation -framework Metal tools/verify_gpu.mm -o /absolute/cache/verify_gpu
|
||||
/absolute/cache/verify_gpu /absolute/default.metallib verification/GPU.json
|
||||
```
|
||||
|
||||
验证工具只读加载安装的原厂着色器作为独立数学对照,不把其库放进交付物。测试状态、设备、哈希、最大误差和未覆盖范围保存在报告中。原 GPU 的 half 输入/输出在此保留,不能将报告解释为原生 32 位 HDR 精度或宿主导出验收。
|
||||
@@ -0,0 +1,78 @@
|
||||
// Focused reconstruction checks: source data integrity, texture axis order and table endpoints.
|
||||
#define DY_COLOR_TABLES_TESTING 1
|
||||
#import "../大鱼调色/Plugin/DYColorTables.h"
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
static void require(bool condition,const char *message){if(!condition){fprintf(stderr,"FAIL: %s\n",message);exit(1);}}
|
||||
static void closeColor(vector_float3 a,vector_float3 b,const char *message,float tolerance=3e-6f){require(simd_reduce_max(simd_abs(a-b))<=tolerance,message);}
|
||||
static vector_float3 cubeColor(NSData *data,int r,int g,int b){auto p=(const vector_float4 *)data.bytes;vector_float4 c=p[(b*33+g)*33+r];return {c.x,c.y,c.z};}
|
||||
static vector_float3 referenceSample(NSData *tables,int table,vector_float3 c){
|
||||
const uint8_t *bytes=(const uint8_t *)tables.bytes;
|
||||
int cell[3];double f[3],sum[3]={0,0,0};
|
||||
for(int i=0;i<3;i++){double position=std::fmin(1.,std::fmax(0.,double(c[i])))*16.;cell[i]=std::min(15,int(position));f[i]=position-cell[i];}
|
||||
for(int dr=0;dr<2;dr++)for(int dg=0;dg<2;dg++)for(int db=0;db<2;db++){
|
||||
double w=(dr?f[0]:1-f[0])*(dg?f[1]:1-f[1])*(db?f[2]:1-f[2]);
|
||||
size_t at=(table*17*17*17+((cell[0]+dr)*17+cell[1]+dg)*17+cell[2]+db)*3;
|
||||
for(int i=0;i<3;i++)sum[i]+=double(bytes[at+i])*w/255.;
|
||||
}
|
||||
return {(float)sum[0],(float)sum[1],(float)sum[2]};
|
||||
}
|
||||
int main(int argc,const char *argv[]){@autoreleasepool{
|
||||
require(argc==2,"usage: verify_color_tables <DayuColorTables.bin>");
|
||||
NSData *file=[NSData dataWithContentsOfFile:[NSString stringWithUTF8String:argv[1]]];require(file!=nil,"table resource exists");
|
||||
uint8_t digest[CC_SHA256_DIGEST_LENGTH];CC_SHA256(file.bytes,(CC_LONG)file.length,digest);
|
||||
char hex[65];for(int i=0;i<32;i++)snprintf(hex+i*2,3,"%02x",digest[i]);
|
||||
require(strcmp(hex,"e67ff4dbcce35cb7765752acff4405be5c934d913ef1396b2ca3fc6dc8a85190")==0,"MIT upstream source table SHA-256");
|
||||
NSError *error=nil;NSData *tables=DYDecodeColorTables(file,&error);require(tables.length==763*17*17*17*3,"decoded dimensions");require(error==nil,"successful decode has no error");
|
||||
require(DYDecodeColorTables([NSData dataWithBytes:"bad" length:3],&error)==nil&&error!=nil,"invalid resource is rejected");
|
||||
NSMutableData *wrong=[file mutableCopy];((uint8_t *)wrong.mutableBytes)[4]=16;error=nil;require(DYDecodeColorTables(wrong,&error)==nil&&error!=nil,"incompatible lattice is rejected");[wrong release];
|
||||
// Off-grid and boundary queries use an independent double-precision oracle.
|
||||
const vector_float3 samples[]={{0,0,0},{1,1,1},{.123f,.679f,.324f},{.95f,.02f,.38f},{.25f,.5f,.75f},{1.2f,-.1f,.66f}};
|
||||
for(int index:{0,40,80,285,325,365,455,601,637,762})for(auto c:samples)
|
||||
closeColor(DYSampleColorTable(tables,index,c),referenceSample(tables,index,c),"17³ source trilinear sampling");
|
||||
// White balance interpolates the four neighboring temperature/tint tables.
|
||||
NSData *wb=DYComposeWhiteBalance(tables,12.5f,-37.5f);
|
||||
for(int b:{0,7,32})for(int g:{0,19,32})for(int r:{0,11,32}){
|
||||
vector_float3 c={(float)r/32.f,(float)g/32.f,(float)b/32.f};
|
||||
vector_float3 expected=(referenceSample(tables,38,c)+referenceSample(tables,39,c)+referenceSample(tables,47,c)+referenceSample(tables,48,c))*.25f;
|
||||
closeColor(cubeColor(wb,r,g,b),expected,"WB bilinear table blend and R-fastest texture order");
|
||||
}
|
||||
float zero[8]={0};
|
||||
NSData *neutral=DYComposeHSL(tables,zero,zero,zero);
|
||||
for(int b:{0,13,32})for(int g:{0,7,32})for(int r:{0,21,32})
|
||||
closeColor(cubeColor(neutral,r,g,b),(vector_float3){r/32.f,g/32.f,b/32.f},"neutral HSL identity",0);
|
||||
for(int kind=0;kind<3;kind++)for(int color=0;color<8;color++){
|
||||
float h[8]={0},s[8]={0},l[8]={0};float *values[3]={l,s,h};values[kind][color]=100;
|
||||
NSData *out=DYComposeHSL(tables,h,s,l);
|
||||
int table=285+(kind*8+color)*5+4;
|
||||
vector_float3 c={.3125f,.6875f,.125f};
|
||||
closeColor(cubeColor(out,10,22,4),referenceSample(tables,table,c),"all 24 HSL controls select the correct endpoint table");
|
||||
}
|
||||
// A single full-strength wheel must reduce to its exact measured endpoint.
|
||||
const int endpoint[4]={601,529,565,637};
|
||||
for(int wheel=0;wheel<4;wheel++){
|
||||
float p[14]={0};p[wheel*3+1]=100;p[12]=50;
|
||||
NSData *out=DYComposeGrading(tables,p);
|
||||
closeColor(cubeColor(out,9,20,29),referenceSample(tables,endpoint[wheel],(vector_float3){9/32.f,20/32.f,29/32.f}),"grading wheel endpoint order");
|
||||
p[wheel*3]=360;NSData *wrapped=DYComposeGrading(tables,p);
|
||||
require([wrapped isEqualToData:out],"grading hue wraps 360 to zero");
|
||||
}
|
||||
const int luminanceEndpoint[4]={752,747,757,762};
|
||||
for(int wheel=0;wheel<4;wheel++){
|
||||
float p[14]={0};p[wheel*3+2]=100;
|
||||
NSData *out=DYComposeGrading(tables,p);
|
||||
closeColor(cubeColor(out,9,20,29),referenceSample(tables,luminanceEndpoint[wheel],(vector_float3){9/32.f,20/32.f,29/32.f}),"grading luminance endpoint order");
|
||||
}
|
||||
DYUniforms u={};[DYColorTables fillPrimaries:&u];
|
||||
closeColor(u.primariesM0,(vector_float3){1,0,0},"neutral primaries column0",0);closeColor(u.primariesM1,(vector_float3){0,1,0},"neutral primaries column1",0);closeColor(u.primariesM2,(vector_float3){0,0,1},"neutral primaries column2",0);
|
||||
for(int control=0;control<6;control++){
|
||||
DYUniforms v={};float *fields[]={&v.redPrimaryHue,&v.redPrimarySaturation,&v.greenPrimaryHue,&v.greenPrimarySaturation,&v.bluePrimaryHue,&v.bluePrimarySaturation};*fields[control]=50;[DYColorTables fillPrimaries:&v];
|
||||
closeColor(v.primariesM0+v.primariesM1+v.primariesM2,(vector_float3){1,1,1},"primaries preserves the D65 white point",2e-5f);
|
||||
require(simd_reduce_max(simd_abs(v.primariesM0-(vector_float3){1,0,0}))+simd_reduce_max(simd_abs(v.primariesM1-(vector_float3){0,1,0}))+simd_reduce_max(simd_abs(v.primariesM2-(vector_float3){0,0,1}))>1e-4f,"all six primary controls change the matrix");
|
||||
}
|
||||
printf("PASS: resource integrity, rejection, trilinear oracle, WB blend, 24 HSL endpoints, 4 grading wheels, hue wrapping, 4 luminance endpoints and 6 primaries\n");
|
||||
}}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
// Independent, headless oracle check. Reference application is read only and
|
||||
// never used by production builds. See tools/kernels/README.md for scope.
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "../大鱼调色/Plugin/DYUniforms.h"
|
||||
|
||||
static id<MTLDevice> gpu;
|
||||
static id<MTLCommandQueue> queue;
|
||||
using Pixels = std::vector<__fp16>;
|
||||
static void need(bool valid, NSString* message) {
|
||||
if (!valid) @throw [NSException exceptionWithName:@"GPUVerification" reason:message userInfo:nil];
|
||||
}
|
||||
static void finish(id<MTLCommandBuffer> commands) {
|
||||
[commands commit]; [commands waitUntilCompleted];
|
||||
need(commands.status == MTLCommandBufferStatusCompleted, commands.error.description ?: @"GPU command failed");
|
||||
}
|
||||
static NSString* digest(NSString* path) {
|
||||
NSData* data = [NSData dataWithContentsOfFile:path]; need(data != nil, path);
|
||||
unsigned char hash[CC_SHA256_DIGEST_LENGTH]; CC_SHA256(data.bytes, (CC_LONG)data.length, hash);
|
||||
NSMutableString* result = [NSMutableString string];
|
||||
for (unsigned char byte : hash) [result appendFormat:@"%02x", byte];
|
||||
return result;
|
||||
}
|
||||
static DYUniforms defaults() {
|
||||
DYUniforms u = {};
|
||||
u.exposureEnabled=u.contrastEnabled=u.highlightsEnabled=u.shadowsEnabled=1;
|
||||
u.whitesEnabled=u.blacksEnabled=u.temperatureEnabled=u.tintEnabled=1;
|
||||
u.saturationEnabled=u.vibranceEnabled=u.textureEnabled=u.clarityEnabled=u.dehazeEnabled=1;
|
||||
u.inputSectionEnabled=u.baseSectionEnabled=u.colorSectionEnabled=u.lookSectionEnabled=1;
|
||||
u.extraLookSectionEnableds = (DYFloat4){1,1,1,1};
|
||||
u.curveSectionEnabled = u.hslSectionEnabled = u.colorGradingSectionEnabled = 1;
|
||||
u.primariesSectionEnabled = u.levelsSectionEnabled = u.colorBalanceSectionEnabled = 1;
|
||||
u.levelsGamma = (DYFloat4){1,1,1,1};
|
||||
u.levelsInputWhite = u.levelsOutputWhite = (DYFloat4){255,255,255,255};
|
||||
u.curveX = (DYFloat4){.2f,.4f,.6f,.8f};
|
||||
u.redCurveX = u.greenCurveX = u.blueCurveX = (DYFloat2){.25f,.75f};
|
||||
u.curveExtraX = u.redCurveExtraX = u.greenCurveExtraX = u.blueCurveExtraX = (DYFloat4){-1,-1,-1,-1};
|
||||
u.primariesM0 = (DYFloat3){1,0,0}; u.primariesM1 = (DYFloat3){0,1,0}; u.primariesM2 = (DYFloat3){0,0,1};
|
||||
u.colorBalancePreserveLuminosity = 1;
|
||||
u.hslCustomRange = (DYFloat3){.08f,.4f,.4f};
|
||||
return u;
|
||||
}
|
||||
static id<MTLTexture> image(const Pixels& values, NSUInteger width, NSUInteger height) {
|
||||
MTLTextureDescriptor* d = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:width height:height mipmapped:NO];
|
||||
d.storageMode = MTLStorageModeShared; d.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget | MTLTextureUsageShaderWrite;
|
||||
id<MTLTexture> result = [gpu newTextureWithDescriptor:d]; need(result != nil, @"source texture");
|
||||
if (!values.empty()) [result replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:values.data() bytesPerRow:width*8];
|
||||
return result;
|
||||
}
|
||||
static id<MTLTexture> lut(bool transformed) {
|
||||
const NSUInteger n = 17;
|
||||
MTLTextureDescriptor* d = [[MTLTextureDescriptor alloc] init];
|
||||
d.textureType = MTLTextureType3D; d.pixelFormat = MTLPixelFormatRGBA32Float;
|
||||
d.width = d.height = d.depth = n; d.storageMode = MTLStorageModeShared; d.usage = MTLTextureUsageShaderRead;
|
||||
std::vector<float> values(n*n*n*4);
|
||||
for (NSUInteger z=0; z<n; ++z) for (NSUInteger y=0; y<n; ++y) for (NSUInteger x=0; x<n; ++x) {
|
||||
float r=float(x)/(n-1), g=float(y)/(n-1), b=float(z)/(n-1); NSUInteger p=((z*n+y)*n+x)*4;
|
||||
values[p] = transformed ? .82f*r+.09f*g+.02f : r;
|
||||
values[p+1] = transformed ? .87f*g+.03f*b+.01f : g;
|
||||
values[p+2] = transformed ? .78f*b+.07f*r+.03f : b;
|
||||
values[p+3] = 1;
|
||||
}
|
||||
id<MTLTexture> result = [gpu newTextureWithDescriptor:d]; need(result != nil, @"LUT texture");
|
||||
[result replaceRegion:MTLRegionMake3D(0,0,0,n,n,n) mipmapLevel:0 slice:0 withBytes:values.data() bytesPerRow:n*16 bytesPerImage:n*n*16];
|
||||
return result;
|
||||
}
|
||||
static id<MTLRenderPipelineState> renderPipeline(id<MTLLibrary> library, bool dayu) {
|
||||
MTLRenderPipelineDescriptor* d = [[MTLRenderPipelineDescriptor alloc] init];
|
||||
d.vertexFunction = [library newFunctionWithName:dayu ? @"dyVertex" : @"vertexShader"];
|
||||
d.fragmentFunction = [library newFunctionWithName:dayu ? @"dyFragment" : @"fragmentShader"];
|
||||
d.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA16Float;
|
||||
NSError* error = nil; id<MTLRenderPipelineState> p = [gpu newRenderPipelineStateWithDescriptor:d error:&error];
|
||||
need(p != nil, error.description ?: @"render pipeline"); return p;
|
||||
}
|
||||
static Pixels render(id<MTLRenderPipelineState> pipeline, bool dayu, id<MTLTexture> source,
|
||||
NSArray<id<MTLTexture>>* textures, const DYUniforms& u, NSUInteger width, NSUInteger height,
|
||||
float u0=0, float u1=1, bool premultiplied=false) {
|
||||
id<MTLTexture> destination=image({},width,height);
|
||||
MTLRenderPassDescriptor* pass=[MTLRenderPassDescriptor renderPassDescriptor];
|
||||
pass.colorAttachments[0].texture=destination; pass.colorAttachments[0].loadAction=MTLLoadActionClear;
|
||||
pass.colorAttachments[0].storeAction=MTLStoreActionStore;
|
||||
id<MTLCommandBuffer> commands=[queue commandBuffer]; id<MTLRenderCommandEncoder> e=[commands renderCommandEncoderWithDescriptor:pass];
|
||||
[e setRenderPipelineState:pipeline];
|
||||
float hw=width*.5f, hh=height*.5f;
|
||||
DYVertex2D vertices[]={{{hw,-hh},{u1,1}},{{-hw,-hh},{u0,1}},{{hw,hh},{u1,0}},{{-hw,hh},{u0,0}}};
|
||||
vector_uint2 viewport={(unsigned)width,(unsigned)height};
|
||||
[e setVertexBytes:vertices length:sizeof(vertices) atIndex:0]; [e setVertexBytes:&viewport length:sizeof(viewport) atIndex:1];
|
||||
[e setFragmentTexture:source atIndex:0];
|
||||
for (NSUInteger i=0;i<textures.count;++i) [e setFragmentTexture:textures[i] atIndex:i+1];
|
||||
[e setFragmentBytes:&u length:sizeof(u) atIndex:0]; float scene=.73f; [e setFragmentBytes:&scene length:4 atIndex:1];
|
||||
if(dayu) { DYRenderOptions options={}; options.outputPremultiplied=premultiplied; [e setFragmentBytes:&options length:sizeof(options) atIndex:2]; }
|
||||
else { float disabledWatermark[8]={}; [e setFragmentBytes:disabledWatermark length:sizeof(disabledWatermark) atIndex:2]; }
|
||||
[e drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; [e endEncoding]; finish(commands);
|
||||
Pixels output(width*height*4); [destination getBytes:output.data() bytesPerRow:width*8 fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0]; return output;
|
||||
}
|
||||
static NSDictionary* compare(NSString* name, const Pixels& a, const Pixels& b, bool skipZeroAlphaRGB=false, double tolerance=0) {
|
||||
need(a.size()==b.size(),@"image sizes differ"); size_t compared=0, different=0; double maxError=0;
|
||||
for(size_t i=0;i<a.size();++i) {
|
||||
if(skipZeroAlphaRGB && i%4!=3 && a[(i/4)*4+3]==0) continue;
|
||||
double delta=std::abs(double(a[i])-double(b[i]));
|
||||
need(std::isfinite(delta),@"non-finite output"); ++compared; if(delta>tolerance)++different; maxError=std::max(maxError,delta);
|
||||
}
|
||||
return @{@"name":name,@"components":@(compared),@"differentAboveTolerance":@(different),@"maxAbsoluteError":@(maxError),@"tolerance":@(tolerance),@"pass":@(different==0)};
|
||||
}
|
||||
static NSDictionary* statistics(id<MTLLibrary> reference,id<MTLLibrary> dayu,id<MTLTexture> source,id<MTLTexture> identity,const DYUniforms& u) {
|
||||
float values[2]={}; id<MTLLibrary> libraries[]={reference,dayu}; NSString* names[]={@"whitesSceneStatistics",@"dyWhitesSceneStatistics"};
|
||||
for(int i=0;i<2;++i) {
|
||||
NSError* error=nil; id<MTLComputePipelineState> p=[gpu newComputePipelineStateWithFunction:[libraries[i] newFunctionWithName:names[i]] error:&error]; need(p!=nil,error.description);
|
||||
id<MTLBuffer> result=[gpu newBufferWithLength:4 options:MTLResourceStorageModeShared];
|
||||
id<MTLCommandBuffer> cb=[queue commandBuffer];id<MTLComputeCommandEncoder> e=[cb computeCommandEncoder];[e setComputePipelineState:p];
|
||||
[e setTexture:source atIndex:0];[e setTexture:identity atIndex:1];[e setBytes:&u length:sizeof(u) atIndex:0];[e setBuffer:result offset:0 atIndex:1];
|
||||
[e dispatchThreadgroups:MTLSizeMake(1,1,1) threadsPerThreadgroup:MTLSizeMake(256,1,1)];[e endEncoding];finish(cb);memcpy(&values[i],result.contents,4);
|
||||
}
|
||||
return @{@"name":@"scene-statistics",@"reference":@(values[0]),@"dayu":@(values[1]),@"pass":@(memcmp(values,values+1,4)==0)};
|
||||
}
|
||||
static NSDictionary* exportLUT(id<MTLLibrary> reference,id<MTLLibrary> dayu,NSArray<id<MTLTexture>>* textures,const DYUniforms& u) {
|
||||
const unsigned n=17; const size_t components=n*n*n*3;std::vector<float> outputs[2];
|
||||
id<MTLLibrary> libraries[]={reference,dayu};NSString* names[]={@"lutExportKernel",@"dyLUTExportKernel"};
|
||||
for(int i=0;i<2;++i) {
|
||||
NSError* error=nil; id<MTLComputePipelineState> p=[gpu newComputePipelineStateWithFunction:[libraries[i] newFunctionWithName:names[i]] error:&error];need(p!=nil,error.description);
|
||||
id<MTLBuffer> result=[gpu newBufferWithLength:components*4 options:MTLResourceStorageModeShared];
|
||||
id<MTLCommandBuffer> cb=[queue commandBuffer];id<MTLComputeCommandEncoder> e=[cb computeCommandEncoder];[e setComputePipelineState:p];
|
||||
for(NSUInteger t=0;t<textures.count;++t)[e setTexture:textures[t] atIndex:t];
|
||||
[e setBytes:&u length:sizeof(u) atIndex:0];[e setBuffer:result offset:0 atIndex:1];[e setBytes:&n length:4 atIndex:2];
|
||||
[e dispatchThreads:MTLSizeMake(n*n*n,1,1) threadsPerThreadgroup:MTLSizeMake(64,1,1)];[e endEncoding];finish(cb);
|
||||
outputs[i].resize(components);memcpy(outputs[i].data(),result.contents,components*4);
|
||||
}
|
||||
size_t differences=0;double maxError=0;for(size_t j=0;j<components;++j){double d=std::abs(double(outputs[0][j])-outputs[1][j]);need(std::isfinite(d),@"nonfinite LUT");if(d>0)++differences;maxError=std::max(maxError,d);}
|
||||
return @{@"name":@"LUT-export-17",@"components":@(components),@"differentComponents":@(differences),@"maxAbsoluteError":@(maxError),@"pass":@(differences==0)};
|
||||
}
|
||||
static Pixels unpremultiply(id<MTLLibrary> library,id<MTLTexture> source) {
|
||||
NSError* error=nil;
|
||||
auto pipeline=[gpu newComputePipelineStateWithFunction:[library newFunctionWithName:@"dyUnpremultiply"] error:&error];need(pipeline!=nil,error.description);
|
||||
auto destination=image({},source.width,source.height);
|
||||
auto cb=[queue commandBuffer];auto e=[cb computeCommandEncoder];[e setComputePipelineState:pipeline];
|
||||
[e setTexture:source atIndex:0];[e setTexture:destination atIndex:1];
|
||||
[e dispatchThreads:MTLSizeMake(source.width,source.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[e endEncoding];finish(cb);
|
||||
Pixels output(source.width*source.height*4);[destination getBytes:output.data() bytesPerRow:source.width*8 fromRegion:MTLRegionMake2D(0,0,source.width,source.height) mipmapLevel:0];return output;
|
||||
}
|
||||
static NSDictionary* preview(id<MTLLibrary> library) {
|
||||
NSError* error=nil;auto pipeline=[gpu newComputePipelineStateWithFunction:[library newFunctionWithName:@"dyPreview"] error:&error];need(pipeline!=nil,error.description);
|
||||
size_t compared=0,different=0;double maxError=0;
|
||||
for(float level:{-.1f,0.f,.0031308f,.18f,1.f,2.f}) {
|
||||
Pixels input(8*8*4);for(size_t p=0;p<input.size();p+=4){input[p]=input[p+1]=input[p+2]=(__fp16)level;input[p+3]=(__fp16).375f;}
|
||||
auto source=image(input,8,8);auto output=[gpu newBufferWithLength:64*64*16 options:MTLResourceStorageModeShared];
|
||||
auto cb=[queue commandBuffer];auto e=[cb computeCommandEncoder];[e setComputePipelineState:pipeline];[e setTexture:source atIndex:0];[e setBuffer:output offset:0 atIndex:0];
|
||||
[e dispatchThreads:MTLSizeMake(64,64,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[e endEncoding];finish(cb);
|
||||
float value=float((__fp16)level),encoded=value<=.0031308f?value*12.92f:1.055f*std::pow(value,1.f/2.4f)-.055f;
|
||||
const float* actual=(const float*)output.contents;for(size_t p=0;p<64*64*4;++p){float target=p%4==3?.375f:encoded;double d=std::abs(double(actual[p])-target);need(std::isfinite(d),@"nonfinite preview");++compared;if(d>2e-6)++different;maxError=std::max(maxError,d);}
|
||||
}
|
||||
return @{@"name":@"64x64-preview-sRGB-alpha-HDR-negative",@"components":@(compared),@"differentAboveTolerance":@(different),@"maxAbsoluteError":@(maxError),@"tolerance":@(2e-6),@"pass":@(different==0)};
|
||||
}
|
||||
|
||||
int main(int argc,const char* argv[]) { @autoreleasepool { @try {
|
||||
need(argc==3,@"Usage: verify_gpu /absolute/dayu.metallib /absolute/report.json");
|
||||
gpu=MTLCreateSystemDefaultDevice();need(gpu!=nil,@"Metal unavailable");queue=[gpu newCommandQueue];
|
||||
NSString* original=@"/Library/Plug-Ins/FxPlug/LumiGrade.app/Contents/PlugIns/LumiGrade XPC Service.pluginkit/Contents/Resources/default.metallib";
|
||||
NSString* current=[NSString stringWithUTF8String:argv[1]];NSError* error=nil;
|
||||
id<MTLLibrary> ref=[gpu newLibraryWithURL:[NSURL fileURLWithPath:original] error:&error];need(ref!=nil,error.description);
|
||||
id<MTLLibrary> ours=[gpu newLibraryWithURL:[NSURL fileURLWithPath:current] error:&error];need(ours!=nil,error.description);
|
||||
auto rp=renderPipeline(ref,false), dp=renderPipeline(ours,true);auto identity=lut(false), altered=lut(true);
|
||||
NSArray* textures=@[identity,identity,identity,identity,identity,identity,identity,identity,identity];
|
||||
const NSUInteger w=256,h=128;Pixels input(w*h*4);uint32_t rng=0x75423981;
|
||||
for(NSUInteger y=0;y<h;++y)for(NSUInteger x=0;x<w;++x){size_t p=(y*w+x)*4;for(int c=0;c<3;++c){rng=rng*1664525+1013904223;float v=(rng>>8)*(1.0f/16777215);if(y<32)v=float(x)/255;if(y>=96)v=v*2-.1f;input[p+c]=(__fp16)v;}input[p+3]=1;}
|
||||
auto source=image(input,w,h);NSMutableArray* cases=[NSMutableArray array];
|
||||
auto runCase=[&](NSString* name,DYUniforms u,NSArray* tex){Pixels a=render(rp,false,source,tex,u,w,h),b=render(dp,true,source,tex,u,w,h);[cases addObject:compare(name,a,b)];};
|
||||
DYUniforms u=defaults();runCase(@"neutral",u,textures);
|
||||
for(float v:{-5.f,-1.25f,.65f,5.f}){u=defaults();u.exposure=v;runCase([NSString stringWithFormat:@"exposure-%g",v],u,textures);}
|
||||
u=defaults();u.contrast=55;u.highlights=-48;u.shadows=62;u.whites=70;u.blacks=-65;runCase(@"tone-combined",u,textures);
|
||||
u=defaults();u.contrast=-65;u.highlights=72;u.shadows=-55;u.whites=-72;u.blacks=48;runCase(@"tone-opposite",u,textures);
|
||||
for(float v:{-65.f,65.f}){u=defaults();u.texture=v;runCase([NSString stringWithFormat:@"texture-%g",v],u,textures);u=defaults();u.clarity=v;runCase([NSString stringWithFormat:@"clarity-%g",v],u,textures);u=defaults();u.dehaze=v;runCase([NSString stringWithFormat:@"dehaze-%g",v],u,textures);}
|
||||
u=defaults();u.saturation=38;u.vibrance=72;runCase(@"saturation-vibrance",u,textures);
|
||||
u=defaults();u.curveShadows=-12;u.curveDarks=8;u.curveLights=15;u.curveHighlights=-8;u.redCurveShadows=13;u.greenCurveHighlights=-9;u.blueCurveShadows=5;u.curveExtraX=(DYFloat4){.1f,.3f,-1,-1};u.curveExtra=(DYFloat4){3,-6,0,0};runCase(@"master-RGB-extra-curves",u,textures);
|
||||
u=defaults();u.levelsInputBlack=(DYFloat4){5,8,3,12};u.levelsInputWhite=(DYFloat4){246,238,241,245};u.levelsGamma=(DYFloat4){1.1f,.87f,1.25f,.94f};u.levelsOutputBlack=(DYFloat4){2,3,0,4};u.levelsOutputWhite=(DYFloat4){250,248,240,252};runCase(@"master-RGB-levels",u,textures);
|
||||
u=defaults();u.hslCustomSample=(DYFloat3){.05f,.5f,.5f};u.hslCustomAdjust=(DYFloat3){25,-35,20};runCase(@"custom-HSL",u,textures);u.hslCustomVisualize=1;runCase(@"custom-HSL-visualization",u,textures);
|
||||
u=defaults();u.blackWhiteSectionEnabled=1;u.blackWhiteMixA=(DYFloat4){25,-15,40,-30};u.blackWhiteMixB=(DYFloat2){15,-10};u.blackWhiteTint=(DYFloat2){.13f,.2f};runCase(@"black-white-mixer-tint",u,textures);
|
||||
u=defaults();u.colorBalanceShadows=(DYFloat3){18,-12,6};u.colorBalanceMidtones=(DYFloat3){-9,14,-6};u.colorBalanceHighlights=(DYFloat3){8,2,-15};runCase(@"color-balance-preserve",u,textures);u.colorBalancePreserveLuminosity=0;runCase(@"color-balance",u,textures);
|
||||
u=defaults();u.redPrimaryHue=25;u.primariesM0=(DYFloat3){.9f,.08f,.02f};u.primariesM1=(DYFloat3){.04f,.92f,.04f};u.primariesM2=(DYFloat3){.02f,.06f,.92f};runCase(@"primary-matrix",u,textures);
|
||||
NSArray* lookTextures=@[altered,altered,altered,altered,altered,altered,identity,identity,identity];
|
||||
u=defaults();u.preLUTStrength=.43f;u.postLUTStrength=.61f;u.extraPostLUTStrengths=(DYFloat4){.2f,.4f,.6f,.8f};runCase(@"pre-LUT-and-five-look-mixes",u,lookTextures);
|
||||
u.skinProtection=(DYFloat3){.65f,.4f,.2f};u.exposure=.7f;u.contrast=20;u.curveDarks=-5;u.texture=25;u.clarity=-15;u.saturation=10;runCase(@"mixed-chain-skin-protection",u,lookTextures);
|
||||
[cases addObject:statistics(ref,ours,source,identity,u)];[cases addObject:exportLUT(ref,ours,lookTextures,u)];
|
||||
// Real cropped input tile with a 32 px halo, not a resized full-frame sample.
|
||||
Pixels crop(192*h*4);for(NSUInteger y=0;y<h;++y)memcpy(crop.data()+y*192*4,input.data()+(y*w+32)*4,192*8);
|
||||
Pixels full=render(dp,true,source,textures,u,w,h), expected(128*h*4);
|
||||
for(NSUInteger y=0;y<h;++y)memcpy(expected.data()+y*128*4,full.data()+(y*w+64)*4,128*8);
|
||||
Pixels tile=render(dp,true,image(crop,192,h),textures,u,128,h,32.f/192,160.f/192);
|
||||
[cases addObject:compare(@"cropped-tile-32px-halo",expected,tile,false,.001)];
|
||||
// Alpha is tested against the declared Dayu boundary, independent of original
|
||||
// hidden RGB behavior at alpha zero. Premultiply only after grading.
|
||||
Pixels alphaInput=input;for(size_t p=0;p<alphaInput.size();p+=4){alphaInput[p+3]=(__fp16)((p/4)%5*.25f);if(alphaInput[p+3]==0)alphaInput[p]=alphaInput[p+1]=alphaInput[p+2]=0;}
|
||||
auto alphaSource=image(alphaInput,w,h);u=defaults();u.exposure=.65f;
|
||||
Pixels alphaRef=render(rp,false,alphaSource,textures,u,w,h),alphaDayu=render(dp,true,alphaSource,textures,u,w,h);
|
||||
[cases addObject:compare(@"straight-alpha-nonzero-oracle",alphaRef,alphaDayu,true)];
|
||||
Pixels premultExpected=alphaDayu;for(size_t p=0;p<premultExpected.size();p+=4)for(int c=0;c<3;++c)premultExpected[p+c]=(__fp16)(float(premultExpected[p+c])*float(premultExpected[p+3]));
|
||||
Pixels premult=render(dp,true,alphaSource,textures,u,w,h,0,1,true);[cases addObject:compare(@"output-premultiplication",premultExpected,premult)];
|
||||
size_t badTransparent=0;for(size_t p=0;p<alphaDayu.size();p+=4)if(alphaInput[p+3]==0)for(int c=0;c<4;++c)if(alphaDayu[p+c]!=0)++badTransparent;
|
||||
[cases addObject:@{@"name":@"zero-alpha-black",@"nonzeroComponents":@(badTransparent),@"pass":@(badTransparent==0)}];
|
||||
u=defaults();Pixels neutralAlpha=render(dp,true,alphaSource,textures,u,w,h);[cases addObject:compare(@"neutral-straight-alpha",alphaInput,neutralAlpha)];
|
||||
Pixels premultInput=alphaInput;for(size_t p=0;p<premultInput.size();p+=4)for(int c=0;c<3;++c)premultInput[p+c]=(__fp16)(float(premultInput[p+c])*float(premultInput[p+3]));
|
||||
Pixels unpremultExpected=premultInput;for(size_t p=0;p<unpremultExpected.size();p+=4)for(int c=0;c<3;++c)unpremultExpected[p+c]=unpremultExpected[p+3]>0?(__fp16)(float(unpremultExpected[p+c])/float(unpremultExpected[p+3])):(__fp16)0;
|
||||
Pixels recovered=unpremultiply(ours,image(premultInput,w,h));[cases addObject:compare(@"unpremultiply-compute-boundary",unpremultExpected,recovered)];
|
||||
Pixels neutralPremult=render(dp,true,image(recovered,w,h),textures,u,w,h,0,1,true);[cases addObject:compare(@"neutral-premultiplied-roundtrip",premultInput,neutralPremult,false,.001)];
|
||||
[cases addObject:preview(ours)];
|
||||
bool passed=true;for(NSDictionary* row in cases)if(![row[@"pass"] boolValue])passed=false;
|
||||
NSDictionary* report=@{@"pass":@(passed),@"gpu":gpu.name,@"os":[NSProcessInfo processInfo].operatingSystemVersionString,
|
||||
@"referenceMetallibSHA256":digest(original),@"reconstructedMetallibSHA256":digest(current),@"imageSize":@[@(w),@(h)],
|
||||
@"testCount":@(cases.count),@"cases":cases,@"scope":@"Direct GPU arithmetic and boundary checks; no GUI application was launched or modified.",
|
||||
@"limitations":@[@"White balance, 8-color HSL mixer and color-grading texture generation use identity placeholders; CPU lookup-table reconstruction is outside this report.",@"Finite sample states; not exhaustive values or every host/GPU.",@"Tile test uses 32-pixel horizontal halo, full vertical input, fixed shared scene statistic.",@"16-bit float source/output follows the reference GPU ABI; premultiplied conversion and tile coordinate rounding allow absolute 0.001 tolerance. Host dispatch, save/reopen and actual FCP export remain separate."]};
|
||||
NSData* data=[NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted error:&error];need(data!=nil,error.description);
|
||||
NSString* destination=[NSString stringWithUTF8String:argv[2]];need([data writeToFile:destination atomically:YES],destination);
|
||||
printf("%s: %lu GPU checks\n",passed?"PASS":"FAIL",(unsigned long)cases.count);return passed?0:1;
|
||||
} @catch(NSException* e) { fprintf(stderr,"%s\n",e.reason.UTF8String);return 2; } } }
|
||||
@@ -0,0 +1,287 @@
|
||||
{
|
||||
"pass" : true,
|
||||
"gpu" : "Apple M4",
|
||||
"os" : "Version 27.0.1 (Build 26A434)",
|
||||
"testCount" : 34,
|
||||
"cases" : [
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "neutral",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "exposure--5",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "exposure--1.25",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "exposure-0.65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "exposure-5",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "tone-combined",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "tone-opposite",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "texture--65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "clarity--65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "dehaze--65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "texture-65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "clarity-65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "dehaze-65",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "saturation-vibrance",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "master-RGB-extra-curves",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "master-RGB-levels",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "custom-HSL",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "custom-HSL-visualization",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "black-white-mixer-tint",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "color-balance-preserve",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "color-balance",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "primary-matrix",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "pre-LUT-and-five-look-mixes",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "mixed-chain-skin-protection",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"reference" : 0.99771362543106079,
|
||||
"dayu" : 0.99771362543106079,
|
||||
"name" : "scene-statistics",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 14739,
|
||||
"maxAbsoluteError" : 0,
|
||||
"name" : "LUT-export-17",
|
||||
"differentComponents" : 0,
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 65536,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0.001,
|
||||
"name" : "cropped-tile-32px-halo",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 111410,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "straight-alpha-nonzero-oracle",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "output-premultiplication",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"name" : "zero-alpha-black",
|
||||
"pass" : true,
|
||||
"nonzeroComponents" : 0
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "neutral-straight-alpha",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0,
|
||||
"name" : "unpremultiply-compute-boundary",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 131072,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 0,
|
||||
"tolerance" : 0.001,
|
||||
"name" : "neutral-premultiplied-roundtrip",
|
||||
"pass" : true
|
||||
},
|
||||
{
|
||||
"components" : 98304,
|
||||
"differentAboveTolerance" : 0,
|
||||
"maxAbsoluteError" : 2.9802322387695312e-08,
|
||||
"tolerance" : 1.9999999999999999e-06,
|
||||
"name" : "64x64-preview-sRGB-alpha-HDR-negative",
|
||||
"pass" : true
|
||||
}
|
||||
],
|
||||
"scope" : "Direct GPU arithmetic and boundary checks; no GUI application was launched or modified.",
|
||||
"limitations" : [
|
||||
"White balance, 8-color HSL mixer and color-grading texture generation use identity placeholders; CPU lookup-table reconstruction is outside this report.",
|
||||
"Finite sample states; not exhaustive values or every host\/GPU.",
|
||||
"Tile test uses 32-pixel horizontal halo, full vertical input, fixed shared scene statistic.",
|
||||
"16-bit float source\/output follows the reference GPU ABI; premultiplied conversion and tile coordinate rounding allow absolute 0.001 tolerance. Host dispatch, save\/reopen and actual FCP export remain separate."
|
||||
],
|
||||
"referenceMetallibSHA256" : "dfb294c9584d3ff23d3ff660c2a2a80c506b31893caf731babd6f4ddddb8fb77",
|
||||
"imageSize" : [
|
||||
256,
|
||||
128
|
||||
],
|
||||
"reconstructedMetallibSHA256" : "ce6f5085fd1a33a79f3faedcb6b3372d072c88caf2f4736ad6bd855b78a237c7"
|
||||
}
|
||||
+77
-22
@@ -62,12 +62,37 @@
|
||||
membershipExceptions = (
|
||||
"/Localized: Plugin/InfoPlist.strings",
|
||||
"/Localized: Plugin/Localizable.strings",
|
||||
"Plugin/____PlugIn.m",
|
||||
Plugin/Info.plist,
|
||||
Plugin/main.m,
|
||||
Plugin/MetalDeviceCache.m,
|
||||
Plugin/TileableRemoteBrightness.metal,
|
||||
"Wrapper Application/Info.plist",
|
||||
"Plugin/DYColorTables.mm",
|
||||
"Plugin/DYGrade.metal",
|
||||
"Plugin/DYInspector.mm",
|
||||
"Plugin/DYModel.mm",
|
||||
"Plugin/DYPlugIn.mm",
|
||||
"Plugin/DYRenderer.mm",
|
||||
"Plugin/Info.plist",
|
||||
"Plugin/Resources/DayuColorTables.bin",
|
||||
"Plugin/Resources/InputLUTs/apple_log_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/arri_logc3_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/arri_logc4_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/blackmagic_film_gen5_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog2_cinema_gamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog3_cinema_gamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog_bt709_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/dji_dlog_m_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/dji_dlog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/fujifilm_flog2_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/fujifilm_flog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/manifest.json",
|
||||
"Plugin/Resources/InputLUTs/nikon_nlog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/panasonic_vlog_vgamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/red_log3g10_rwg_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_hlg_bt2020_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_slog2_sgamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_slog3_sgamut3cine_to_rec709.dylut",
|
||||
"Plugin/Resources/THIRD-PARTY-NOTICES.txt",
|
||||
"Plugin/en.lproj/InfoPlist.strings",
|
||||
"Plugin/en.lproj/Localizable.strings",
|
||||
"Plugin/main.m",
|
||||
);
|
||||
target = 04962E513095058F009952AA /* Wrapper Application */;
|
||||
};
|
||||
@@ -81,6 +106,27 @@
|
||||
"Wrapper Application/AppDelegate.m",
|
||||
"Wrapper Application/Info.plist",
|
||||
"Wrapper Application/main.m",
|
||||
"Plugin/Resources/DayuColorTables.bin",
|
||||
"Plugin/Resources/InputLUTs/apple_log_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/arri_logc3_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/arri_logc4_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/blackmagic_film_gen5_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog2_cinema_gamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog3_cinema_gamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/canon_clog_bt709_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/dji_dlog_m_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/dji_dlog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/fujifilm_flog2_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/fujifilm_flog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/manifest.json",
|
||||
"Plugin/Resources/InputLUTs/nikon_nlog_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/panasonic_vlog_vgamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/red_log3g10_rwg_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_hlg_bt2020_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_slog2_sgamut_to_rec709.dylut",
|
||||
"Plugin/Resources/InputLUTs/sony_slog3_sgamut3cine_to_rec709.dylut",
|
||||
"Plugin/Resources/THIRD-PARTY-NOTICES.txt",
|
||||
"Plugin/DYGrade.metal",
|
||||
);
|
||||
target = 04962E5C3095058F009952AA /* XPC Service */;
|
||||
};
|
||||
@@ -165,7 +211,6 @@
|
||||
);
|
||||
dependencies = (
|
||||
04962E603095058F009952AA /* PBXTargetDependency */,
|
||||
04962E6C3095058F009952AA /* PBXTargetDependency */,
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
04962E6D3095058F009952AA /* 大鱼调色 */,
|
||||
@@ -182,6 +227,7 @@
|
||||
04962E573095058F009952AA /* Sources */,
|
||||
04962E583095058F009952AA /* Frameworks */,
|
||||
04962E593095058F009952AA /* Resources */,
|
||||
DADADADADADADADADADADADA /* Build Dayu Kernels */,
|
||||
04962E5A3095058F009952AA /* Copy and Code Sign FxPlug.framework */,
|
||||
04962E5B3095058F009952AA /* Copy and Code Sign PluginManager.framework */,
|
||||
);
|
||||
@@ -246,6 +292,7 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
DADADADADADADADADADADADA /* Build Dayu Kernels */ = {isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; buildActionMask = 2147483647; files = (); inputPaths = (); outputPaths = (); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "set -eu\n/usr/bin/python3 \"$SRCROOT/tools/build_kernels.py\" --output \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/default.metallib\" --intermediates \"$DERIVED_FILE_DIR/DayuKernels\"\n/usr/bin/python3 - \"$SRCROOT/大鱼调色/Plugin/Resources\" \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\" <<'PYBUILD'\nimport pathlib,shutil,sys\na,b=map(pathlib.Path,sys.argv[1:]);b.mkdir(parents=True,exist_ok=True)\nfor p in a.rglob(\"*\"):\n if p.is_file() and not p.name.startswith(\"._\"):\n d=b/p.relative_to(a);d.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,d)\nPYBUILD\n"; };
|
||||
04962E5A3095058F009952AA /* Copy and Code Sign FxPlug.framework */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
name = "Copy and Code Sign FxPlug.framework";
|
||||
@@ -303,10 +350,13 @@
|
||||
04962E943095058F009952AA /* Debug configuration for PBXNativeTarget "XPC Service" */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application: zhong luo (B3W25FX5H5)";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
DEVELOPMENT_TEAM = B3W25FX5H5;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = ("$(inherited)", "-framework", Metal, "-framework", QuartzCore, "-framework", Compression, "-lz");
|
||||
INFOPLIST_FILE = "大鱼调色/Plugin/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -314,9 +364,8 @@
|
||||
);
|
||||
MACH_O_TYPE = mh_execute;
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.dayu.color.XPC;
|
||||
PRODUCT_NAME = "大鱼调色 $(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "大鱼调色/Plugin/XPC Service-Bridging-Header.h";
|
||||
WRAPPER_EXTENSION = pluginkit;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -324,10 +373,13 @@
|
||||
04962E953095058F009952AA /* Release configuration for PBXNativeTarget "XPC Service" */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application: zhong luo (B3W25FX5H5)";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
DEVELOPMENT_TEAM = B3W25FX5H5;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = ("$(inherited)", "-framework", Metal, "-framework", QuartzCore, "-framework", Compression, "-lz");
|
||||
INFOPLIST_FILE = "大鱼调色/Plugin/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -335,9 +387,8 @@
|
||||
);
|
||||
MACH_O_TYPE = mh_execute;
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.dayu.color.XPC;
|
||||
PRODUCT_NAME = "大鱼调色 $(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "大鱼调色/Plugin/XPC Service-Bridging-Header.h";
|
||||
WRAPPER_EXTENSION = pluginkit;
|
||||
};
|
||||
name = Release;
|
||||
@@ -346,15 +397,17 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = "大鱼调色/Wrapper Application/SandboxEntitlements.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application: zhong luo (B3W25FX5H5)";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
DEVELOPMENT_TEAM = B3W25FX5H5;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = ("$(inherited)", "-framework", Metal, "-framework", QuartzCore, "-framework", Compression, "-lz");
|
||||
INFOPLIST_FILE = "大鱼调色/Wrapper Application/Info.plist";
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.dayu.color;
|
||||
PRODUCT_NAME = "大鱼调色";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "大鱼调色/Wrapper Application/Wrapper Application-Bridging-Header.h";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -362,15 +415,17 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = "大鱼调色/Wrapper Application/SandboxEntitlements.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application: zhong luo (B3W25FX5H5)";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
DEVELOPMENT_TEAM = B3W25FX5H5;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = ("$(inherited)", "-framework", Metal, "-framework", QuartzCore, "-framework", Compression, "-lz");
|
||||
INFOPLIST_FILE = "大鱼调色/Wrapper Application/Info.plist";
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.dayu.color;
|
||||
PRODUCT_NAME = "大鱼调色";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "大鱼调色/Wrapper Application/Wrapper Application-Bridging-Header.h";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -415,7 +470,7 @@
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
/Library/Frameworks,
|
||||
/Library/Developer/Frameworks,
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
@@ -434,7 +489,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 27.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@@ -484,7 +539,7 @@
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
/Library/Frameworks,
|
||||
/Library/Developer/Frameworks,
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
@@ -497,7 +552,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 27.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 14.6;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
#import "DYUniforms.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Camera Raw tables are the MIT-licensed Compositor dataset, not application code.
|
||||
/// Nil means a resource/GPU failure; inactive controls return an identity texture.
|
||||
@interface DYColorTables : NSObject
|
||||
@property (nonatomic, readonly, nullable) NSString *lastError;
|
||||
- (nullable id<MTLTexture>)whiteBalanceForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)uniforms;
|
||||
- (nullable id<MTLTexture>)hslForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)uniforms;
|
||||
- (nullable id<MTLTexture>)gradingForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)uniforms;
|
||||
+ (void)fillPrimaries:(DYUniforms *)uniforms;
|
||||
+ (BOOL)neutralizeColor:(vector_float3)color temperature:(float *)temperature tint:(float *)tint;
|
||||
@end
|
||||
|
||||
#ifdef DY_COLOR_TABLES_TESTING
|
||||
FOUNDATION_EXPORT NSData * _Nullable DYDecodeColorTables(NSData *file, NSError **error);
|
||||
FOUNDATION_EXPORT vector_float3 DYSampleColorTable(NSData *tables, NSInteger table, vector_float3 color);
|
||||
FOUNDATION_EXPORT NSData *DYComposeWhiteBalance(NSData *tables, float temperature, float tint);
|
||||
FOUNDATION_EXPORT NSData *DYComposeHSL(NSData *tables, const float *hue, const float *saturation, const float *luminance);
|
||||
FOUNDATION_EXPORT NSData *DYComposeGrading(NSData *tables, const float *parameters);
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,321 @@
|
||||
// Camera Raw table decoding and composition adapted from Compositor (MIT).
|
||||
// Upstream: https://github.com/robbietilton/Compositor
|
||||
// Commit: 92f5225afe7e921dbfa4c563462980e45db345fc
|
||||
// Table SHA-256: e67ff4dbcce35cb7765752acff4405be5c934d913ef1396b2ca3fc6dc8a85190
|
||||
// Float composition order checked against LumiGrade 3.0 build 56, arm64.
|
||||
#define DY_COLOR_TABLES_TESTING 1
|
||||
#import "DYColorTables.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr size_t kTableCells = 17 * 17 * 17;
|
||||
constexpr size_t kTableBytes = kTableCells * 3;
|
||||
constexpr size_t kTableCount = 763;
|
||||
constexpr size_t kGrid = 33;
|
||||
constexpr size_t kGridBytes = kGrid * kGrid * kGrid * sizeof(vector_float4);
|
||||
constexpr float kEpsilon = 1e-6f;
|
||||
using Color = vector_float3;
|
||||
struct Part { NSInteger table; float weight; }; // table -1 means identity.
|
||||
struct Stage : std::vector<Part> {
|
||||
using std::vector<Part>::vector;
|
||||
bool interpolatesPair=false;
|
||||
};
|
||||
using Stages = std::vector<Stage>;
|
||||
inline float safe(float value, float low, float high) { return std::isfinite(value) ? std::clamp(value,low,high) : std::clamp(0.f,low,high); }
|
||||
inline Color bounded(Color c) { return simd_clamp(c,(Color){0,0,0},(Color){1,1,1}); }
|
||||
std::pair<int,float> between(float value,float low,float step,int count) {
|
||||
float p=safe((value-low)/step,0.f,float(count-1));
|
||||
int index=std::min(count-2,int(p));
|
||||
return {index,p-float(index)};
|
||||
}
|
||||
Stage twoTables(NSInteger start,float value) {
|
||||
auto [index,up]=between(value,-100.f,50.f,5);
|
||||
return {{start+index,1.f-up},{start+index+1,up}};
|
||||
}
|
||||
Stage whiteBalanceStage(float temperature,float tint) {
|
||||
auto [row,down]=between(temperature,-100.f,25.f,9);
|
||||
auto [column,across]=between(tint,-100.f,25.f,9);
|
||||
NSInteger base=row*9+column;
|
||||
return {{base,(1.f-down)*(1.f-across)},{base+1,(1.f-down)*across},
|
||||
{base+9,down*(1.f-across)},{base+10,down*across}};
|
||||
}
|
||||
Stages mixerStages(const float hue[8],const float saturation[8],const float luminance[8]) {
|
||||
Stages stages;
|
||||
const float *values[3]={luminance,saturation,hue};
|
||||
for(int kind=0;kind<3;kind++)for(int color=0;color<8;color++) {
|
||||
float v=safe(values[kind][color],-100.f,100.f);
|
||||
if(std::fabs(v)>kEpsilon) {
|
||||
Stage stage=twoTables(285+(kind*8+color)*5,v);
|
||||
stage.interpolatesPair=true;
|
||||
stages.push_back(std::move(stage));
|
||||
}
|
||||
}
|
||||
return stages;
|
||||
}
|
||||
Stages gradingStages(const float parameters[14]) {
|
||||
// Input order: midtones, shadows, highlights, global (H,S,L), blending,balance.
|
||||
struct Wheel {float hue,saturation,luminance;};
|
||||
Wheel wheels[4]={{parameters[3],parameters[4],parameters[5]},
|
||||
{parameters[0],parameters[1],parameters[2]},
|
||||
{parameters[6],parameters[7],parameters[8]},
|
||||
{parameters[9],parameters[10],parameters[11]}};
|
||||
Stages stages;
|
||||
for(int i=0;i<4;i++)if(std::fabs(wheels[i].luminance)>kEpsilon)
|
||||
stages.push_back(twoTables(743+i*5,safe(wheels[i].luminance,-100,100)));
|
||||
float balance=safe(parameters[13],-100,100)/100.f;
|
||||
float highlightShare=std::max(0.f,balance<0?1.f+1.4f*balance:1.f+2.f*balance);
|
||||
float shadowShare=std::max(0.f,balance<0?1.f-1.2f*balance:1.f-1.4f*balance);
|
||||
auto [blendLow,blendUp]=between(parameters[12],0.f,50.f,3);
|
||||
const int order[4]={3,1,2,0};
|
||||
for(int index:order) {
|
||||
// Source table wheel numbering is shadows=0, highlights=1, midtones=2, global=3.
|
||||
int wheel=index==1?2:index==2?1:index;
|
||||
const Wheel &color=wheels[index];
|
||||
float share=index==0?shadowShare:index==2?highlightShare:1.f;
|
||||
float saturation=safe(color.saturation,0.f,100.f)*share;
|
||||
if(saturation<=kEpsilon)continue;
|
||||
float position=std::fmod(std::isfinite(color.hue)?color.hue:0.f,360.f)/30.f;
|
||||
if(position<0)position+=12.f;
|
||||
int first=int(position)%12,second=(first+1)%12;
|
||||
float around=position-float(int(position));
|
||||
float levelPosition=saturation<=25?saturation/25.f:saturation<=50?1.f+(saturation-25.f)/25.f:2.f+(saturation-50.f)/50.f;
|
||||
levelPosition=safe(levelPosition,0.f,3.f);
|
||||
int level=std::min(2,int(levelPosition));
|
||||
float up=levelPosition-float(level);
|
||||
bool blends=index==0||index==2;
|
||||
std::vector<std::pair<int,float>> blendings=blends?
|
||||
std::vector<std::pair<int,float>>{{blendLow,1.f-blendUp},{blendLow+1,blendUp}}:
|
||||
std::vector<std::pair<int,float>>{{1,1.f}};
|
||||
Stage stage;
|
||||
for(auto [blendIndex,blendWeight]:blendings) {
|
||||
int base=455+(blendIndex==0?0:blendIndex==1?72:216)+wheel*36;
|
||||
for(auto [hue,hueWeight]:std::array<std::pair<int,float>,2>{{{first,1.f-around},{second,around}}})
|
||||
for(auto [sat,satWeight]:std::array<std::pair<int,float>,2>{{{level,1.f-up},{level+1,up}}})
|
||||
stage.push_back({sat==0?-1:base+hue*3+sat-1,blendWeight*hueWeight*satWeight});
|
||||
}
|
||||
stages.push_back(std::move(stage));
|
||||
}
|
||||
return stages;
|
||||
}
|
||||
Color sample(const uint8_t *tables,NSInteger table,Color color) {
|
||||
if(table<0)return color;
|
||||
if(table>=NSInteger(kTableCount))return (Color){0,0,0};
|
||||
Color p=bounded(color)*16.f;
|
||||
vector_int3 cell={(int)p.x,(int)p.y,(int)p.z};
|
||||
cell=simd_min(cell,(vector_int3){15,15,15});
|
||||
Color f=p-__builtin_convertvector(cell,Color);
|
||||
Color out={0,0,0};
|
||||
for(int corner=0;corner<8;corner++) {
|
||||
int dr=corner>>2,dg=(corner>>1)&1,db=corner&1;
|
||||
float weight=(db?f.z:1.f-f.z)*(dr?f.x:1.f-f.x)*(dg?f.y:1.f-f.y);
|
||||
if(weight<=0)continue;
|
||||
size_t at=table*kTableBytes+(((cell.x+dr)*17+(cell.y+dg))*17+cell.z+db)*3;
|
||||
// Retain the reference's multiply-then-divide float operation order.
|
||||
out.x+=float(tables[at])*weight/255.f;
|
||||
out.y+=float(tables[at+1])*weight/255.f;
|
||||
out.z+=float(tables[at+2])*weight/255.f;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Color apply(const uint8_t *tables,const Stages &stages,Color color) {
|
||||
for(const Stage &stage:stages) {
|
||||
if(stage.interpolatesPair&&stage.size()==2) {
|
||||
Color low=sample(tables,stage[0].table,color);
|
||||
Color high=sample(tables,stage[1].table,color);
|
||||
color=bounded(low+(high-low)*stage[1].weight);
|
||||
continue;
|
||||
}
|
||||
Color out={0,0,0};
|
||||
for(const Part &p:stage)if(p.weight>0)out+=sample(tables,p.table,color)*p.weight;
|
||||
color=bounded(out);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
NSData *compose(NSData *tables,const Stages &stages) {
|
||||
NSMutableData *data=[NSMutableData dataWithLength:kGridBytes];
|
||||
vector_float4 *out=(vector_float4 *)data.mutableBytes;
|
||||
const uint8_t *bytes=(const uint8_t *)tables.bytes;
|
||||
// A Metal 3D texture is R-fastest; the source 17³ tables are B-fastest.
|
||||
dispatch_apply(kGrid,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0),^(size_t b){
|
||||
for(size_t g=0;g<kGrid;g++)for(size_t r=0;r<kGrid;r++) {
|
||||
Color c={(float)r/32.f,(float)g/32.f,(float)b/32.f};
|
||||
c=apply(bytes,stages,c);
|
||||
out[(b*kGrid+g)*kGrid+r]=(vector_float4){c.x,c.y,c.z,1.f};
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
NSError *resourceError(NSString *message) {
|
||||
return [NSError errorWithDomain:@"com.dayu.color.tables" code:1 userInfo:@{NSLocalizedDescriptionKey:message}];
|
||||
}
|
||||
NSData *sourceTables(NSString **diagnostic) {
|
||||
static NSData *tables=nil;
|
||||
static NSString *failure=nil;
|
||||
static dispatch_once_t once;
|
||||
dispatch_once(&once,^{
|
||||
NSBundle *bundle=[NSBundle bundleForClass:DYColorTables.class];
|
||||
NSURL *url=[bundle URLForResource:@"DayuColorTables" withExtension:@"bin"];
|
||||
if(!url)url=[bundle URLForResource:@"DayuColorTables" withExtension:@"bin" subdirectory:@"Resources"];
|
||||
NSError *error=nil;
|
||||
NSData *file=url?[NSData dataWithContentsOfURL:url options:0 error:&error]:nil;
|
||||
if(file)tables=[DYDecodeColorTables(file,&error) retain];
|
||||
if(!tables)failure=[(error.localizedDescription?:@"缺少 DayuColorTables.bin 调色数据") copy];
|
||||
});
|
||||
if(diagnostic)*diagnostic=failure;
|
||||
return tables;
|
||||
}
|
||||
Color rotatePrimary(Color primary,float shift) {
|
||||
const Color n={.5773502588272095f,.5773502588272095f,.5773502588272095f};
|
||||
const Color a={.7071067690849304f,-.7071067690849304f,0};
|
||||
const Color b={-.40824827551841736f,-.40824827551841736f,.8164965510368347f};
|
||||
float angle=shift/100.f*.5235987305641174f;
|
||||
float x=simd_dot(primary,a),y=simd_dot(primary,b),gray=simd_dot(primary,n);
|
||||
float sine=std::sin(angle),cosine=std::cos(angle);
|
||||
return n*gray+a*(cosine*x+sine*y)+b*(cosine*y-sine*x);
|
||||
}
|
||||
matrix_float3x3 satAxis(Color primary,float amount) {
|
||||
Color v=primary-(Color){1.f/3.f,1.f/3.f,1.f/3.f};
|
||||
float scale=amount/std::max(1e-8f,simd_dot(v,v));
|
||||
matrix_float3x3 result=matrix_identity_float3x3;
|
||||
for(int column=0;column<3;column++)result.columns[column]+=v*(scale*v[column]);
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Kept callable by the focused CPU verification tool; production loads one immutable dataset.
|
||||
NSData *DYDecodeColorTables(NSData *file,NSError **error) {
|
||||
if(error)*error=nil;
|
||||
if(file.length<=10||memcmp(file.bytes,"CRT3",4)!=0) {if(error)*error=resourceError(@"调色数据头无效");return nil;}
|
||||
const uint8_t *header=(const uint8_t *)file.bytes;
|
||||
auto word=[&](int at){return int(header[at])|(int(header[at+1])<<8);};
|
||||
int step=word(8);
|
||||
if(word(4)!=17||word(6)!=763||step<=0) {if(error)*error=resourceError(@"调色数据尺寸不兼容");return nil;}
|
||||
NSData *planes=[[file subdataWithRange:NSMakeRange(10,file.length-10)]decompressedDataUsingAlgorithm:NSDataCompressionAlgorithmLZMA error:error];
|
||||
if(planes.length!=kTableCount*kTableBytes) {if(error&&!*error)*error=resourceError(@"调色数据解压长度错误");return nil;}
|
||||
NSMutableData *result=[NSMutableData dataWithLength:planes.length];
|
||||
const uint8_t *bytes=(const uint8_t *)planes.bytes;
|
||||
uint8_t *out=(uint8_t *)result.mutableBytes;
|
||||
int levels[17];for(int i=0;i<17;i++)levels[i]=(int)std::round(double(i)*255.0/16.0);
|
||||
for(size_t table=0;table<kTableCount;table++)for(size_t channel=0;channel<3;channel++) {
|
||||
uint8_t running=0;
|
||||
size_t base=(table*3+channel)*kTableCells;
|
||||
for(size_t cell=0;cell<kTableCells;cell++) {
|
||||
running=uint8_t(running+bytes[base+cell]);
|
||||
size_t axis=channel==0?cell/(17*17):channel==1?(cell/17)%17:cell%17;
|
||||
int value=levels[axis]+int((int8_t)running)*step;
|
||||
out[table*kTableBytes+cell*3+channel]=(uint8_t)std::clamp(value,0,255);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Color DYSampleColorTable(NSData *tables,NSInteger table,Color color) {return sample((const uint8_t *)tables.bytes,table,color);}
|
||||
NSData *DYComposeWhiteBalance(NSData *tables,float temperature,float tint) {return compose(tables,{whiteBalanceStage(temperature,tint)});}
|
||||
NSData *DYComposeHSL(NSData *tables,const float hue[8],const float saturation[8],const float luminance[8]) {return compose(tables,mixerStages(hue,saturation,luminance));}
|
||||
NSData *DYComposeGrading(NSData *tables,const float parameters[14]) {return compose(tables,gradingStages(parameters));}
|
||||
|
||||
@implementation DYColorTables {
|
||||
NSLock *_lock;
|
||||
NSMutableDictionary *_textures;
|
||||
NSMutableArray *_order;
|
||||
NSString *_lastError;
|
||||
}
|
||||
- (instancetype)init {if((self=[super init])){_lock=[NSLock new];_textures=[NSMutableDictionary new];_order=[NSMutableArray new];}return self;}
|
||||
- (void)dealloc {[_lock release];[_textures release];[_order release];[_lastError release];[super dealloc];}
|
||||
- (NSString *)lastError {[_lock lock];NSString *value=[[_lastError retain]autorelease];[_lock unlock];return value;}
|
||||
- (id<MTLTexture>)textureForDevice:(id<MTLDevice>)device kind:(NSString *)kind key:(NSData *)parameters stages:(const Stages &)stages {
|
||||
[_lock lock];
|
||||
@try {
|
||||
NSArray *key=@[@(device.registryID),kind,parameters];
|
||||
id<MTLTexture> cached=_textures[key];
|
||||
if(cached){[_order removeObject:key];[_order addObject:key];return [[cached retain]autorelease];}
|
||||
NSString *diagnostic=nil;
|
||||
NSData *tables=sourceTables(&diagnostic);
|
||||
if(!tables){[_lastError release];_lastError=[diagnostic copy];return nil;}
|
||||
NSData *data=compose(tables,stages);
|
||||
MTLTextureDescriptor *descriptor=[[[MTLTextureDescriptor alloc]init]autorelease];
|
||||
descriptor.textureType=MTLTextureType3D;descriptor.pixelFormat=MTLPixelFormatRGBA32Float;
|
||||
descriptor.width=kGrid;descriptor.height=kGrid;descriptor.depth=kGrid;
|
||||
descriptor.mipmapLevelCount=1;descriptor.storageMode=MTLStorageModeShared;descriptor.usage=MTLTextureUsageShaderRead;
|
||||
id<MTLTexture> texture=[device newTextureWithDescriptor:descriptor];
|
||||
if(!texture){[_lastError release];_lastError=[@"无法创建调色 LUT 纹理" copy];return nil;}
|
||||
texture.label=[@"大鱼调色 " stringByAppendingString:kind];
|
||||
[texture replaceRegion:MTLRegionMake3D(0,0,0,kGrid,kGrid,kGrid) mipmapLevel:0 slice:0 withBytes:data.bytes bytesPerRow:kGrid*sizeof(vector_float4) bytesPerImage:kGrid*kGrid*sizeof(vector_float4)];
|
||||
_textures[key]=texture;[_order addObject:key];
|
||||
while(_order.count>12){id oldest=[[_order[0]retain]autorelease];[_textures removeObjectForKey:oldest];[_order removeObjectAtIndex:0];}
|
||||
[_lastError release];_lastError=nil;
|
||||
return [texture autorelease];
|
||||
} @finally {[_lock unlock];}
|
||||
}
|
||||
- (id<MTLTexture>)whiteBalanceForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)u {
|
||||
float p[2]={u->temperatureEnabled>.5f?safe(u->temperature,-100,100):0,u->tintEnabled>.5f?safe(u->tint,-100,100):0};
|
||||
Stages stages;if(std::fabs(p[0])+std::fabs(p[1])>kEpsilon)stages.push_back(whiteBalanceStage(p[0],p[1]));
|
||||
return [self textureForDevice:device kind:@"WhiteBalance" key:[NSData dataWithBytes:p length:sizeof(p)] stages:stages];
|
||||
}
|
||||
- (id<MTLTexture>)hslForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)u {
|
||||
float p[24]={0};
|
||||
if(u->hslSectionEnabled>.5f)for(int i=0;i<8;i++) {
|
||||
p[i]=i<4?u->hslHueA[i]:u->hslHueB[i-4];
|
||||
p[8+i]=i<4?u->hslSatA[i]:u->hslSatB[i-4];
|
||||
p[16+i]=i<4?u->hslLumA[i]:u->hslLumB[i-4];
|
||||
}
|
||||
return [self textureForDevice:device kind:@"HSL" key:[NSData dataWithBytes:p length:sizeof(p)] stages:mixerStages(p,p+8,p+16)];
|
||||
}
|
||||
- (id<MTLTexture>)gradingForDevice:(id<MTLDevice>)device uniforms:(const DYUniforms *)u {
|
||||
float p[14]={0};
|
||||
if(u->colorGradingSectionEnabled>.5f) {
|
||||
p[0]=u->colorGradingHueSatA.x;p[1]=u->colorGradingHueSatA.y;p[2]=u->colorGradingLuma.x;
|
||||
p[3]=u->colorGradingHueSatA.z;p[4]=u->colorGradingHueSatA.w;p[5]=u->colorGradingLuma.y;
|
||||
p[6]=u->colorGradingHueSatB.x;p[7]=u->colorGradingHueSatB.y;p[8]=u->colorGradingLuma.z;
|
||||
p[9]=u->colorGradingGlobal.x;p[10]=u->colorGradingGlobal.y;p[11]=u->colorGradingGlobal.z;
|
||||
p[12]=u->colorGradingBlending;p[13]=u->colorGradingBalance;
|
||||
}
|
||||
return [self textureForDevice:device kind:@"ColorGrading" key:[NSData dataWithBytes:p length:sizeof(p)] stages:gradingStages(p)];
|
||||
}
|
||||
+ (void)fillPrimaries:(DYUniforms *)u {
|
||||
matrix_float3x3 result=matrix_identity_float3x3;
|
||||
float total=std::fabs(u->redPrimaryHue)+std::fabs(u->greenPrimaryHue)+std::fabs(u->bluePrimaryHue)+std::fabs(u->redPrimarySaturation)+std::fabs(u->greenPrimarySaturation)+std::fabs(u->bluePrimarySaturation);
|
||||
if(total>=kEpsilon) {
|
||||
const matrix_float3x3 xyz=(matrix_float3x3){(Color){.4124564f,.2126729f,.0193339f},(Color){.3575761f,.7151522f,.119192f},(Color){.1804375f,.072175f,.9503041f}};
|
||||
matrix_float3x3 shifted=(matrix_float3x3){simd_mul(xyz,rotatePrimary((Color){1,0,0},u->redPrimaryHue)),simd_mul(xyz,rotatePrimary((Color){0,1,0},u->greenPrimaryHue)),simd_mul(xyz,rotatePrimary((Color){0,0,1},u->bluePrimaryHue))};
|
||||
if(std::fabs(simd_determinant(shifted))>1e-10f) {
|
||||
Color scale=simd_mul(simd_inverse(shifted),(Color){.95047003f,1.0000001f,1.08883f});
|
||||
if(simd_all(scale>(Color){.01f,.01f,.01f})) {
|
||||
for(int c=0;c<3;c++)shifted.columns[c]*=scale[c];
|
||||
result=simd_mul(simd_inverse(xyz),shifted);
|
||||
float amounts[3]={u->redPrimarySaturation/100.f*.55f,u->greenPrimarySaturation/100.f*.55f,u->bluePrimarySaturation/100.f*.55f};
|
||||
if(std::fabs(amounts[0])>kEpsilon||std::fabs(amounts[1])>kEpsilon||std::fabs(amounts[2])>kEpsilon)
|
||||
result=simd_mul(simd_mul(simd_mul(result,satAxis((Color){1,0,0},amounts[0])),satAxis((Color){0,1,0},amounts[1])),satAxis((Color){0,0,1},amounts[2]));
|
||||
float maxDeviation=0;
|
||||
for(int c=0;c<3;c++)for(int r=0;r<3;r++)maxDeviation=std::max(maxDeviation,std::fabs(result.columns[c][r]-(c==r?1.f:0.f)));
|
||||
if(maxDeviation>.6f) {
|
||||
float blend=safe((maxDeviation-.6f)/.4f,0.f,1.f);
|
||||
for(int c=0;c<3;c++)result.columns[c]=matrix_identity_float3x3.columns[c]*blend+result.columns[c]*(1.f-blend);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u->primariesM0=result.columns[0];u->primariesM1=result.columns[1];u->primariesM2=result.columns[2];
|
||||
}
|
||||
+ (BOOL)neutralizeColor:(Color)color temperature:(float *)temperature tint:(float *)tint {
|
||||
NSData *tables=sourceTables(nullptr);
|
||||
if(!tables||!simd_all(color>(Color){1e-4f,1e-4f,1e-4f})||!std::isfinite(color.x+color.y+color.z))return NO;
|
||||
const uint8_t *bytes=(const uint8_t *)tables.bytes;
|
||||
auto cast=[&](float t,float g){Color c=apply(bytes,{whiteBalanceStage(t,g)},color);return simd_reduce_max(c)-simd_reduce_min(c);};
|
||||
float bestTemperature=0,bestTint=0,bestCast=cast(0,0);
|
||||
const float steps[3]={10,2,.5f},reaches[3]={100,10,2};
|
||||
for(int pass=0;pass<3;pass++) {
|
||||
float centerT=bestTemperature,centerG=bestTint;
|
||||
for(float t=centerT-reaches[pass];t<=centerT+reaches[pass];t+=steps[pass])
|
||||
for(float g=centerG-reaches[pass];g<=centerG+reaches[pass];g+=steps[pass]) {
|
||||
if(std::fabs(t)>100||std::fabs(g)>100)continue;
|
||||
float found=cast(t,g);
|
||||
if(found<bestCast){bestTemperature=t;bestTint=g;bestCast=found;}
|
||||
}
|
||||
}
|
||||
if(temperature)*temperature=bestTemperature;if(tint)*tint=bestTint;return YES;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,80 @@
|
||||
#include <metal_stdlib>
|
||||
#include "DYUniforms.h"
|
||||
using namespace metal;
|
||||
|
||||
// The linked, versioned AIR helper owns color arithmetic only. Its source is in
|
||||
// tools/kernels; production builds never read the reference application.
|
||||
extern "C" half4 dy_grade(half4 sample, float2 uv, texture2d<half> source,
|
||||
texture3d<float> preLUT, texture3d<float> look1, texture3d<float> look2,
|
||||
texture3d<float> look3, texture3d<float> look4, texture3d<float> look5,
|
||||
texture3d<float> hslMixer, texture3d<float> whiteBalance,
|
||||
texture3d<float> colorGrading, constant DYUniforms& uniforms,
|
||||
constant float& sceneLevel);
|
||||
|
||||
struct DYRaster {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex DYRaster dyVertex(uint vertexID [[vertex_id]],
|
||||
constant DYVertex2D* vertices [[buffer(0)]],
|
||||
constant uint2& viewportSize [[buffer(1)]]) {
|
||||
DYRaster result;
|
||||
result.position = float4(vertices[vertexID].position / (float2(viewportSize) * 0.5f), 0.0f, 1.0f);
|
||||
result.uv = vertices[vertexID].textureCoordinate;
|
||||
return result;
|
||||
}
|
||||
|
||||
fragment half4 dyFragment(DYRaster in [[stage_in]],
|
||||
texture2d<half> source [[texture(0)]],
|
||||
texture3d<float> preLUT [[texture(1)]],
|
||||
texture3d<float> look1 [[texture(2)]],
|
||||
texture3d<float> look2 [[texture(3)]],
|
||||
texture3d<float> look3 [[texture(4)]],
|
||||
texture3d<float> look4 [[texture(5)]],
|
||||
texture3d<float> look5 [[texture(6)]],
|
||||
texture3d<float> hslMixer [[texture(7)]],
|
||||
texture3d<float> whiteBalance [[texture(8)]],
|
||||
texture3d<float> colorGrading [[texture(9)]],
|
||||
constant DYUniforms& uniforms [[buffer(0)]],
|
||||
constant float& sceneLevel [[buffer(1)]],
|
||||
constant DYRenderOptions& options [[buffer(2)]]) {
|
||||
constexpr sampler sampleFilter(coord::normalized, address::clamp_to_edge, filter::linear);
|
||||
half4 sample = source.sample(sampleFilter, in.uv);
|
||||
if (!(sample.a > half(0.0))) return half4(0.0h);
|
||||
half4 result = dy_grade(sample, in.uv, source, preLUT, look1, look2, look3,
|
||||
look4, look5, hslMixer, whiteBalance, colorGrading, uniforms, sceneLevel);
|
||||
result.a = sample.a;
|
||||
if (options.outputPremultiplied) result.rgb *= result.a;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Optional boundary conversion. Use this before both statistics and grading
|
||||
// when the host supplies premultiplied RGB; all neighborhood samples then see
|
||||
// the same straight RGB representation. Source and destination must differ.
|
||||
kernel void dyUnpremultiply(texture2d<float, access::read> source [[texture(0)]],
|
||||
texture2d<half, access::write> destination [[texture(1)]],
|
||||
uint2 pixel [[thread_position_in_grid]]) {
|
||||
if (pixel.x >= destination.get_width() || pixel.y >= destination.get_height()) return;
|
||||
float4 sample = source.read(pixel);
|
||||
if (!(sample.a > 0.0f) || !all(isfinite(sample))) {
|
||||
destination.write(half4(0.0h), pixel);
|
||||
return;
|
||||
}
|
||||
destination.write(half4(half3(sample.rgb / sample.a), half(sample.a)), pixel);
|
||||
}
|
||||
|
||||
// Per-instance CPU analysis thumbnail. Host dispatches exactly 64x64 threads;
|
||||
// RGB is sRGB encoded, alpha is unchanged. HDR and negative values are retained
|
||||
// by the standard piecewise transfer rather than silently clipping the sample.
|
||||
kernel void dyPreview(texture2d<half> source [[texture(0)]],
|
||||
device float4* outRGBA [[buffer(0)]],
|
||||
uint2 pixel [[thread_position_in_grid]]) {
|
||||
if (pixel.x >= 64 || pixel.y >= 64) return;
|
||||
constexpr sampler sampleFilter(coord::normalized, address::clamp_to_edge, filter::linear);
|
||||
half4 sample = source.sample(sampleFilter, (float2(pixel) + 0.5f) / 64.0f);
|
||||
float3 linear = float3(sample.rgb);
|
||||
float3 power = 1.055f * pow(max(linear, float3(0.0f)), float3(1.0f / 2.4f)) - 0.055f;
|
||||
float3 encoded = select(power, linear * 12.92f, linear <= 0.0031308f);
|
||||
outRGBA[pixel.y * 64 + pixel.x] = float4(encoded, float(sample.a));
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
|
||||
/// Per-instance custom inspector. All host reads and edits are bracketed actions.
|
||||
@interface DYInspector : NSView
|
||||
- (instancetype)initWithAPIManager:(id<PROAPIAccessing>)manager;
|
||||
- (void)refresh;
|
||||
@end
|
||||
@@ -0,0 +1,684 @@
|
||||
#import "DYInspector.h"
|
||||
#import "DYModel.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
static NSColor *DYAccent(void) { return [NSColor colorWithSRGBRed:.26 green:.73 blue:.98 alpha:1]; }
|
||||
static NSColor *DYInk(void) { return [NSColor colorWithSRGBRed:.83 green:.91 blue:.97 alpha:1]; }
|
||||
static NSTextField *DYLabel(NSString *text, CGFloat size) {
|
||||
NSTextField *v=[NSTextField labelWithString:text?:@""];
|
||||
v.font=[NSFont systemFontOfSize:size]; v.textColor=DYInk();
|
||||
v.lineBreakMode=NSLineBreakByTruncatingTail;
|
||||
return v;
|
||||
}
|
||||
static NSButton *DYButton(NSString *title,id target,SEL action) {
|
||||
NSButton *b=[NSButton buttonWithTitle:title target:target action:action];
|
||||
b.bezelStyle=NSBezelStyleRounded; b.font=[NSFont systemFontOfSize:11];
|
||||
b.contentTintColor=DYAccent(); return b;
|
||||
}
|
||||
static NSString *DYNumber(double value,NSDictionary *d) {
|
||||
double step=[d[@"step"] doubleValue];
|
||||
return [NSString stringWithFormat:step>0&&step<.1?@"%.2f":step>0&&step<1?@"%.1f":@"%.0f",value];
|
||||
}
|
||||
|
||||
|
||||
@interface DYBlueSliderCell : NSSliderCell @end
|
||||
@implementation DYBlueSliderCell
|
||||
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped {
|
||||
NSRect track=NSMakeRect(rect.origin.x,NSMidY(rect)-2,rect.size.width,4);
|
||||
[[NSColor colorWithSRGBRed:.19 green:.30 blue:.37 alpha:1] setFill];[[NSBezierPath bezierPathWithRoundedRect:track xRadius:2 yRadius:2] fill];
|
||||
double fraction=(self.doubleValue-self.minValue)/fmax(.000001,self.maxValue-self.minValue);
|
||||
NSRect active=track;active.size.width*=fmax(0,fmin(1,fraction));[DYAccent() setFill];[[NSBezierPath bezierPathWithRoundedRect:active xRadius:2 yRadius:2] fill];
|
||||
}
|
||||
- (void)drawKnob:(NSRect)knobRect {
|
||||
NSRect circle=NSInsetRect(knobRect,1,1);
|
||||
[[NSColor colorWithSRGBRed:.69 green:.88 blue:1 alpha:1] setFill];[[NSBezierPath bezierPathWithOvalInRect:circle] fill];
|
||||
[DYAccent() setStroke];NSBezierPath *ring=[NSBezierPath bezierPathWithOvalInRect:circle];ring.lineWidth=.7;[ring stroke];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DYFlippedView : NSView @end
|
||||
@implementation DYFlippedView
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
@end
|
||||
|
||||
@interface DYCard : DYFlippedView @end
|
||||
@implementation DYCard
|
||||
- (void)drawRect:(NSRect)rect {
|
||||
[[NSColor colorWithSRGBRed:.045 green:.135 blue:.20 alpha:1] setFill];
|
||||
NSBezierPath *path=[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(self.bounds,.5,.5) xRadius:11 yRadius:11];
|
||||
[path fill]; [[NSColor colorWithSRGBRed:.16 green:.34 blue:.45 alpha:1] setStroke];
|
||||
path.lineWidth=1; [path stroke];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DYHeader : NSButton
|
||||
@property SEL doubleClickAction;
|
||||
@end
|
||||
@implementation DYHeader
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
if(event.clickCount==2) [NSApp sendAction:self.doubleClickAction to:self.target from:self];
|
||||
else [super mouseDown:event];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@protocol DYGraphicDelegate <NSObject>
|
||||
- (void)writeGraphicValues:(NSDictionary *)values;
|
||||
@end
|
||||
|
||||
/// The graph uses the same sorted monotone Hermite tangent limiter as the GPU.
|
||||
@interface DYCurvePanel : DYFlippedView {
|
||||
NSDictionary *_values;
|
||||
NSSegmentedControl *_channels;
|
||||
NSInteger _channel;
|
||||
NSString *_dragXKey,*_dragYKey;
|
||||
}
|
||||
@property(nonatomic,assign) id<DYGraphicDelegate> delegate;
|
||||
- (void)setValues:(NSDictionary *)values;
|
||||
@end
|
||||
|
||||
@implementation DYCurvePanel
|
||||
- (instancetype)initWithFrame:(NSRect)frame {
|
||||
if((self=[super initWithFrame:frame])) {
|
||||
_values=[@{} copy];
|
||||
_channels=[[NSSegmentedControl segmentedControlWithLabels:@[@"RGB",@"红",@"绿",@"蓝"] trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(channelChanged:)] retain];
|
||||
_channels.selectedSegment=0; _channels.controlSize=NSControlSizeSmall; [self addSubview:_channels];
|
||||
self.accessibilityLabel=@"曲线点编辑器";self.toolTip=@"点击添加点;拖动调整;双击、右键或按住 Option 点击已有点可删除";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc { [_values release];[_channels release];[_dragXKey release];[_dragYKey release];[super dealloc]; }
|
||||
- (BOOL)acceptsFirstResponder { return YES; }
|
||||
- (void)setValues:(NSDictionary *)values { [_values release];_values=[values copy];[self setNeedsDisplay:YES]; }
|
||||
- (void)layout { [super layout];_channels.frame=NSMakeRect(12,4,self.bounds.size.width-24,24); }
|
||||
- (void)channelChanged:(NSSegmentedControl *)sender { _channel=sender.selectedSegment;[self setNeedsDisplay:YES]; }
|
||||
- (NSRect)plotRect { return NSMakeRect(16,37,MAX(50,self.bounds.size.width-32),MAX(50,self.bounds.size.height-56)); }
|
||||
- (NSArray *)slots {
|
||||
NSMutableArray *result=[NSMutableArray array];
|
||||
NSInteger n=_channel==0?4:2;
|
||||
for(NSInteger i=0;i<n;i++) {
|
||||
NSString *x=_channel==0?[NSString stringWithFormat:@"masterX%ld",(long)i]:[NSString stringWithFormat:@"channel%ldX%ld",(long)(_channel-1),(long)i];
|
||||
NSString *y=[NSString stringWithFormat:@"curveY%ld",(long)(_channel==0?i:4+(_channel-1)*2+i)];
|
||||
[result addObject:@{@"xKey":x,@"yKey":y}];
|
||||
}
|
||||
for(NSInteger i=0;i<4;i++) [result addObject:@{@"xKey":[NSString stringWithFormat:@"curve%ldExtraX%ld",(long)_channel,(long)i],@"yKey":[NSString stringWithFormat:@"curve%ldExtra%ld",(long)_channel,(long)i]}];
|
||||
return result;
|
||||
}
|
||||
- (NSArray *)activePoints {
|
||||
NSMutableArray *points=[NSMutableArray array];
|
||||
for(NSDictionary *slot in [self slots]) {
|
||||
NSNumber *xValue=_values[slot[@"xKey"]];double x=xValue?xValue.doubleValue:-1;
|
||||
if(x<0)continue;
|
||||
double y=fmax(0,fmin(1,x+[_values[slot[@"yKey"]] doubleValue]*.01));
|
||||
[points addObject:@{@"xKey":slot[@"xKey"],@"yKey":slot[@"yKey"],@"x":@(x),@"y":@(y)}];
|
||||
}
|
||||
[points sortUsingComparator:^NSComparisonResult(NSDictionary *a,NSDictionary *b) {return [a[@"x"] compare:b[@"x"]];}];
|
||||
return points;
|
||||
}
|
||||
- (NSPoint)positionOfPoint:(NSDictionary *)point {
|
||||
NSRect r=[self plotRect];return NSMakePoint(r.origin.x+[point[@"x"] doubleValue]*r.size.width,r.origin.y+(1-[point[@"y"] doubleValue])*r.size.height);
|
||||
}
|
||||
- (NSDictionary *)pointNear:(NSPoint)p {
|
||||
NSDictionary *closest=nil;double distance=13;
|
||||
for(NSDictionary *point in [self activePoints]) {NSPoint q=[self positionOfPoint:point];double d=hypot(q.x-p.x,q.y-p.y);if(d<distance){distance=d;closest=point;}}
|
||||
return closest;
|
||||
}
|
||||
- (void)drawRect:(NSRect)dirtyRect {
|
||||
NSRect r=[self plotRect];
|
||||
[[NSColor colorWithSRGBRed:.025 green:.085 blue:.13 alpha:1] setFill];[[NSBezierPath bezierPathWithRoundedRect:r xRadius:4 yRadius:4] fill];
|
||||
[[NSColor colorWithWhite:1 alpha:.1] setStroke];NSBezierPath *grid=[NSBezierPath bezierPath];grid.lineWidth=.5;
|
||||
for(int i=0;i<5;i++){CGFloat x=r.origin.x+r.size.width*i/4,y=r.origin.y+r.size.height*i/4;[grid moveToPoint:NSMakePoint(x,NSMinY(r))];[grid lineToPoint:NSMakePoint(x,NSMaxY(r))];[grid moveToPoint:NSMakePoint(NSMinX(r),y)];[grid lineToPoint:NSMakePoint(NSMaxX(r),y)];}[grid stroke];
|
||||
std::vector<NSPoint> p; p.push_back(NSMakePoint(0,0));
|
||||
NSArray *points=[self activePoints];for(NSDictionary *point in points)p.push_back(NSMakePoint([point[@"x"] doubleValue],[point[@"y"] doubleValue]));p.push_back(NSMakePoint(1,1));
|
||||
for(size_t i=1;i<p.size();i++)p[i].x=fmax(p[i].x,p[i-1].x+.0001);p.back().x=1;
|
||||
std::vector<double> slopes(p.size()-1),m(p.size());
|
||||
for(size_t i=0;i<slopes.size();i++)slopes[i]=(p[i+1].y-p[i].y)/fmax(.0001,p[i+1].x-p[i].x);
|
||||
m.front()=slopes.front();m.back()=slopes.back();
|
||||
for(size_t i=1;i+1<p.size();i++)m[i]=slopes[i-1]*slopes[i]>0?(slopes[i-1]+slopes[i])*.5:0;
|
||||
for(size_t i=0;i<slopes.size();i++) {
|
||||
if(fabs(slopes[i])<.00001)m[i]=m[i+1]=0;
|
||||
else {double a=m[i]/slopes[i],b=m[i+1]/slopes[i],v=hypot(a,b);if(v>3){m[i]=3*slopes[i]*a/v;m[i+1]=3*slopes[i]*b/v;}}
|
||||
}
|
||||
NSBezierPath *curve=[NSBezierPath bezierPath];curve.lineWidth=1.8;
|
||||
size_t segment=0;
|
||||
for(int sample=0;sample<=256;sample++) {
|
||||
double x=sample/256.;while(segment+2<p.size()&&x>p[segment+1].x)segment++;
|
||||
double width=fmax(.0001,p[segment+1].x-p[segment].x),t=fmax(0,fmin(1,(x-p[segment].x)/width));
|
||||
double t2=t*t,t3=t2*t;
|
||||
double y=(2*t3-3*t2+1)*p[segment].y+(t3-2*t2+t)*width*m[segment]+(-2*t3+3*t2)*p[segment+1].y+(t3-t2)*width*m[segment+1];
|
||||
NSPoint q=NSMakePoint(r.origin.x+x*r.size.width,r.origin.y+(1-fmax(0,fmin(1,y)))*r.size.height);
|
||||
if(sample==0)[curve moveToPoint:q];else[curve lineToPoint:q];
|
||||
}
|
||||
NSColor *color=_channel==0?DYAccent():_channel==1?[NSColor systemRedColor]:_channel==2?[NSColor systemGreenColor]:[NSColor systemBlueColor];[color setStroke];[curve stroke];
|
||||
for(NSDictionary *point in points) {NSPoint q=[self positionOfPoint:point];[color setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(q.x-4,q.y-4,8,8)] fill];[DYInk() setStroke];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(q.x-4,q.y-4,8,8)] stroke];}
|
||||
[@"点击添加 · 拖动调整 · 双击删除" drawAtPoint:NSMakePoint(16,self.bounds.size.height-16) withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:9],NSForegroundColorAttributeName:[NSColor colorWithWhite:.7 alpha:1]}];
|
||||
}
|
||||
- (void)sendValues:(NSDictionary *)values {
|
||||
NSMutableDictionary *merged=[[_values mutableCopy] autorelease];[merged addEntriesFromDictionary:values];[self setValues:merged];
|
||||
[self.delegate writeGraphicValues:values];
|
||||
}
|
||||
- (void)removePoint:(NSDictionary *)point { if(point)[self sendValues:@{point[@"xKey"]:@(-1),point[@"yKey"]:@0}]; }
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
NSPoint p=[self convertPoint:event.locationInWindow fromView:nil];if(!NSPointInRect(p,[self plotRect]))return;
|
||||
[self.window makeFirstResponder:self];NSDictionary *point=[self pointNear:p];
|
||||
if(point&&(event.clickCount==2||(event.modifierFlags&NSEventModifierFlagOption))) {[self removePoint:point];return;}
|
||||
if(!point) {
|
||||
NSDictionary *freeSlot=nil;for(NSDictionary *slot in [self slots]) {NSNumber *v=_values[slot[@"xKey"]];if(!v||v.doubleValue<0){freeSlot=slot;break;}}
|
||||
if(!freeSlot){NSBeep();return;}
|
||||
[_dragXKey release];_dragXKey=[freeSlot[@"xKey"] copy];[_dragYKey release];_dragYKey=[freeSlot[@"yKey"] copy];
|
||||
[self updateDragAt:p];return;
|
||||
}
|
||||
[_dragXKey release];_dragXKey=[point[@"xKey"] copy];[_dragYKey release];_dragYKey=[point[@"yKey"] copy];
|
||||
}
|
||||
- (void)updateDragAt:(NSPoint)p {
|
||||
if(!_dragXKey)return;NSRect r=[self plotRect];double x=fmax(.001,fmin(.999,(p.x-r.origin.x)/r.size.width)),y=fmax(0,fmin(1,1-(p.y-r.origin.y)/r.size.height));
|
||||
for(NSDictionary *point in [self activePoints])if(![point[@"xKey"] isEqual:_dragXKey]) {double other=[point[@"x"] doubleValue];if(fabs(x-other)<.001)x=x<other?other-.001:other+.001;}
|
||||
x=fmax(.001,fmin(.999,x));[self sendValues:@{_dragXKey:@(x),_dragYKey:@((y-x)*100)}];
|
||||
}
|
||||
- (void)mouseDragged:(NSEvent *)event { [self updateDragAt:[self convertPoint:event.locationInWindow fromView:nil]]; }
|
||||
- (void)mouseUp:(NSEvent *)event { if(_dragXKey)[self updateDragAt:[self convertPoint:event.locationInWindow fromView:nil]];[_dragXKey release];_dragXKey=nil;[_dragYKey release];_dragYKey=nil; }
|
||||
- (void)rightMouseDown:(NSEvent *)event { [self removePoint:[self pointNear:[self convertPoint:event.locationInWindow fromView:nil]]]; }
|
||||
- (void)keyDown:(NSEvent *)event { if(event.keyCode==51&&_dragXKey)[self sendValues:@{_dragXKey:@(-1),_dragYKey:@0}];else[super keyDown:event]; }
|
||||
@end
|
||||
|
||||
static NSImage *DYWheelImage(void) {
|
||||
static NSImage *image;static dispatch_once_t once;
|
||||
dispatch_once(&once,^{
|
||||
const NSInteger size=192;
|
||||
NSBitmapImageRep *rep=[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:size pixelsHigh:size bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:size*4 bitsPerPixel:32] autorelease];
|
||||
unsigned char *bytes=rep.bitmapData;
|
||||
for(NSInteger y=0;y<size;y++)for(NSInteger x=0;x<size;x++) {
|
||||
double dx=(x+.5-size*.5)/(size*.5-1),dy=(size*.5-y-.5)/(size*.5-1),sat=hypot(dx,dy),hue=atan2(dy,dx)/(2*M_PI);if(hue<0)hue+=1;
|
||||
double h=hue*6,c=fmin(1,sat),v=1-c,t=c*(1-fabs(fmod(h,2)-1)),r=0,g=0,b=0;
|
||||
if(h<1){r=c;g=t;}else if(h<2){r=t;g=c;}else if(h<3){g=c;b=t;}else if(h<4){g=t;b=c;}else if(h<5){r=t;b=c;}else{r=c;b=t;}
|
||||
NSInteger i=(y*size+x)*4;bytes[i]=(unsigned char)lrint((r+v)*255);bytes[i+1]=(unsigned char)lrint((g+v)*255);bytes[i+2]=(unsigned char)lrint((b+v)*255);bytes[i+3]=sat<=1?255:0;
|
||||
}
|
||||
image=[[NSImage alloc]initWithSize:NSMakeSize(size,size)];[image addRepresentation:rep];
|
||||
});return image;
|
||||
}
|
||||
|
||||
@interface DYColorWheel : DYFlippedView {
|
||||
NSInteger _index;
|
||||
double _hue,_sat;
|
||||
BOOL _dragging;
|
||||
}
|
||||
@property(nonatomic,assign) id<DYGraphicDelegate> delegate;
|
||||
- (instancetype)initWithIndex:(NSInteger)index;
|
||||
- (void)setHue:(double)hue saturation:(double)sat;
|
||||
@end
|
||||
@implementation DYColorWheel
|
||||
- (instancetype)initWithIndex:(NSInteger)index { if((self=[super initWithFrame:NSZeroRect])) {_index=index;self.accessibilityLabel=[@[@"阴影",@"中间调",@"高光",@"全局"][index] stringByAppendingString:@"色轮"];self.toolTip=@"拖动调整色相和饱和度;双击还原";}return self; }
|
||||
- (BOOL)acceptsFirstResponder { return YES; }
|
||||
- (NSRect)wheelRect {CGFloat diameter=MIN(self.bounds.size.width-12,self.bounds.size.height-26);return NSMakeRect((self.bounds.size.width-diameter)/2,22,diameter,diameter);}
|
||||
- (void)setHue:(double)hue saturation:(double)sat {_hue=hue;_sat=sat;[self setNeedsDisplay:YES];}
|
||||
- (void)drawRect:(NSRect)rect {
|
||||
NSString *title=@[@"阴影",@"中间调",@"高光",@"全局"][_index];
|
||||
NSDictionary *attrs=@{NSFontAttributeName:[NSFont systemFontOfSize:10],NSForegroundColorAttributeName:DYInk()};
|
||||
NSSize titleSize=[title sizeWithAttributes:attrs];[title drawAtPoint:NSMakePoint((self.bounds.size.width-titleSize.width)/2,3) withAttributes:attrs];
|
||||
NSRect r=[self wheelRect];[DYWheelImage() drawInRect:r fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:.85 respectFlipped:YES hints:nil];
|
||||
[[NSColor colorWithWhite:0 alpha:.35] setStroke];[[NSBezierPath bezierPathWithOvalInRect:r] stroke];
|
||||
double angle=_hue*M_PI/180,rad=r.size.width*.5*_sat/100;NSPoint p=NSMakePoint(NSMidX(r)+cos(angle)*rad,NSMidY(r)-sin(angle)*rad);
|
||||
[[NSColor colorWithWhite:0 alpha:.7] setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x-5,p.y-5,10,10)] fill];
|
||||
[[NSColor whiteColor] setStroke];NSBezierPath *knob=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x-4,p.y-4,8,8)];knob.lineWidth=1.6;[knob stroke];
|
||||
[[NSColor colorWithWhite:1 alpha:.45] setStroke];NSBezierPath *cross=[NSBezierPath bezierPath];[cross moveToPoint:NSMakePoint(NSMidX(r)-3,NSMidY(r))];[cross lineToPoint:NSMakePoint(NSMidX(r)+3,NSMidY(r))];[cross moveToPoint:NSMakePoint(NSMidX(r),NSMidY(r)-3)];[cross lineToPoint:NSMakePoint(NSMidX(r),NSMidY(r)+3)];cross.lineWidth=.5;[cross stroke];
|
||||
}
|
||||
- (void)sendHue:(double)hue saturation:(double)sat {
|
||||
[self setHue:hue saturation:sat];[self.delegate writeGraphicValues:@{[NSString stringWithFormat:@"grade%ld_0",(long)_index]:@(hue),[NSString stringWithFormat:@"grade%ld_1",(long)_index]:@(sat)}];
|
||||
}
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
_dragging=NO;
|
||||
NSPoint p=[self convertPoint:event.locationInWindow fromView:nil];NSRect r=[self wheelRect];
|
||||
if(hypot(p.x-NSMidX(r),p.y-NSMidY(r))>r.size.width*.5)return;
|
||||
if(event.clickCount==2){[self sendHue:0 saturation:0];return;}
|
||||
_dragging=YES;[self updateAt:p];
|
||||
}
|
||||
- (void)updateAt:(NSPoint)p {
|
||||
NSRect r=[self wheelRect];double dx=p.x-NSMidX(r),dy=NSMidY(r)-p.y,h=atan2(dy,dx)*180/M_PI;if(h<0)h+=360;
|
||||
[self sendHue:h saturation:fmin(100,hypot(dx,dy)/(r.size.width*.5)*100)];
|
||||
}
|
||||
- (void)mouseDragged:(NSEvent *)event {if(_dragging)[self updateAt:[self convertPoint:event.locationInWindow fromView:nil]];}
|
||||
- (void)mouseUp:(NSEvent *)event {if(_dragging)[self updateAt:[self convertPoint:event.locationInWindow fromView:nil]];_dragging=NO;}
|
||||
@end
|
||||
|
||||
@interface DYWheelPanel : DYFlippedView {
|
||||
NSArray *_wheels;
|
||||
}
|
||||
@property(nonatomic,assign) id<DYGraphicDelegate> delegate;
|
||||
- (void)setValues:(NSDictionary *)values;
|
||||
@end
|
||||
@implementation DYWheelPanel
|
||||
- (instancetype)initWithFrame:(NSRect)frame {if((self=[super initWithFrame:frame])){NSMutableArray *w=[NSMutableArray array];for(NSInteger i=0;i<4;i++){DYColorWheel *wheel=[[[DYColorWheel alloc]initWithIndex:i]autorelease];[self addSubview:wheel];[w addObject:wheel];}_wheels=[w copy];}return self;}
|
||||
- (void)dealloc {[_wheels release];[super dealloc];}
|
||||
- (void)setDelegate:(id<DYGraphicDelegate>)delegate {_delegate=delegate;for(DYColorWheel *wheel in _wheels)wheel.delegate=delegate;}
|
||||
- (void)setValues:(NSDictionary *)values {for(NSInteger i=0;i<4;i++)[_wheels[i] setHue:[values[[NSString stringWithFormat:@"grade%ld_0",(long)i]] doubleValue] saturation:[values[[NSString stringWithFormat:@"grade%ld_1",(long)i]] doubleValue]];}
|
||||
- (void)layout {[super layout];CGFloat w=self.bounds.size.width/2,h=self.bounds.size.height/2;for(NSInteger i=0;i<4;i++)[_wheels[i] setFrame:NSMakeRect((i%2)*w,(i/2)*h,w,h)];}
|
||||
@end
|
||||
|
||||
@interface DYInspector () <DYGraphicDelegate> {
|
||||
id<PROAPIAccessing> _manager;
|
||||
NSScrollView *_scroll;
|
||||
DYFlippedView *_document;
|
||||
NSTextField *_brand;
|
||||
NSTextField *_subtitle;
|
||||
NSButton *_resetAll, *_save, *_load, *_export;
|
||||
NSArray *_sections;
|
||||
NSMutableArray *_cards;
|
||||
NSMutableDictionary *_controls;
|
||||
NSMutableDictionary *_assetButtons;
|
||||
NSMutableArray *_graphics;
|
||||
NSColorSampler *_sampler;
|
||||
BOOL _refreshing;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation DYInspector
|
||||
- (instancetype)initWithAPIManager:(id<PROAPIAccessing>)manager {
|
||||
if((self=[super initWithFrame:NSMakeRect(0,0,360,780)])) {
|
||||
_manager=manager; _sections=[DYSections() copy];
|
||||
_cards=[[NSMutableArray alloc] init]; _controls=[[NSMutableDictionary alloc] init];
|
||||
_assetButtons=[[NSMutableDictionary alloc] init]; _graphics=[[NSMutableArray alloc] init];
|
||||
self.autoresizingMask=NSViewWidthSizable;
|
||||
self.wantsLayer=YES; self.layer.backgroundColor=[[NSColor colorWithSRGBRed:.018 green:.074 blue:.12 alpha:1] CGColor];
|
||||
_brand=[DYLabel(@"大鱼调色",20) retain]; _brand.font=[NSFont boldSystemFontOfSize:20];
|
||||
_subtitle=[DYLabel(@"颜色 · 光影 · 风格",10) retain]; _subtitle.textColor=DYAccent();
|
||||
_resetAll=[DYButton(@"全部还原",self,@selector(resetAll:)) retain]; _resetAll.toolTip=@"恢复全部调色参数与 LUT";
|
||||
_save=[DYButton(@"保存预设",self,@selector(savePreset:)) retain];
|
||||
_load=[DYButton(@"载入预设",self,@selector(loadPreset:)) retain];
|
||||
_export=[DYButton(@"导出 LUT",self,@selector(exportLUT:)) retain];
|
||||
for(NSView *v in @[_brand,_subtitle,_resetAll,_save,_load,_export]) [self addSubview:v];
|
||||
_scroll=[[NSScrollView alloc] initWithFrame:NSZeroRect];
|
||||
_scroll.hasVerticalScroller=YES; _scroll.hasHorizontalScroller=NO; _scroll.drawsBackground=NO;
|
||||
_scroll.autohidesScrollers=YES; _scroll.borderType=NSNoBorder;
|
||||
_document=[[DYFlippedView alloc] initWithFrame:NSMakeRect(0,0,360,1000)];
|
||||
_scroll.documentView=_document; [self addSubview:_scroll];
|
||||
[self buildCards];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modelChanged:) name:@"DYModelChanged" object:_manager];
|
||||
[self setAccessibilityLabel:@"大鱼调色检查器"];
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[_brand release]; [_subtitle release]; [_resetAll release]; [_save release]; [_load release]; [_export release];
|
||||
[_scroll release]; [_document release]; [_sections release]; [_cards release]; [_controls release]; [_assetButtons release]; [_graphics release]; [_sampler release];
|
||||
[super dealloc];
|
||||
}
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
- (NSSize)intrinsicContentSize { return NSMakeSize(360,780); }
|
||||
- (void)viewDidMoveToWindow { [super viewDidMoveToWindow]; if(self.window) [self refresh]; }
|
||||
- (void)modelChanged:(NSNotification *)n {
|
||||
if([NSThread isMainThread]) [self refresh];
|
||||
else dispatch_async(dispatch_get_main_queue(),^{ [self refresh]; });
|
||||
}
|
||||
- (void)buildCards {
|
||||
NSInteger index=0;
|
||||
for(NSDictionary *section in _sections) {
|
||||
DYCard *card=[[[DYCard alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
[_document addSubview:card];
|
||||
DYHeader *header=[[[DYHeader alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
header.title=[@"▾ " stringByAppendingString:section[@"title"]?:@""];
|
||||
header.bordered=NO; header.alignment=NSTextAlignmentLeft; header.font=[NSFont boldSystemFontOfSize:12];
|
||||
header.contentTintColor=DYInk(); header.target=self; header.action=@selector(toggleSection:); header.tag=index;
|
||||
header.doubleClickAction=@selector(resetSection:); header.toolTip=@"点击折叠;双击还原本组";
|
||||
[card addSubview:header];
|
||||
NSButton *enabled=[NSButton checkboxWithTitle:@"" target:self action:@selector(groupEnabled:)];
|
||||
enabled.tag=index; enabled.contentTintColor=DYAccent(); enabled.toolTip=@"启用或旁路本组";
|
||||
enabled.accessibilityLabel=[section[@"title"] stringByAppendingString:@"启用"];
|
||||
[card addSubview:enabled]; enabled.hidden=section[@"enabled"]==nil;
|
||||
NSButton *reset=DYButton(@"↺",self,@selector(resetSection:)); reset.tag=index;
|
||||
reset.toolTip=@"还原本组"; reset.accessibilityLabel=[section[@"title"] stringByAppendingString:@"还原"];
|
||||
[card addSubview:reset];
|
||||
NSMutableArray *body=[NSMutableArray array];
|
||||
NSString *key=section[@"key"]?:@"";
|
||||
if([key localizedCaseInsensitiveContainsString:@"input"]) {
|
||||
[body addObject:[self assetRowForKey:@"input" title:@"输入 LUT" inCard:card]];
|
||||
}
|
||||
if([key localizedCaseInsensitiveContainsString:@"look"]) {
|
||||
for(NSInteger i=0;i<5;i++) {
|
||||
NSString *slot=[NSString stringWithFormat:@"look%ld",(long)i];
|
||||
[body addObject:[self assetRowForKey:slot title:[NSString stringWithFormat:@"风格 LUT %ld",(long)(i+1)] inCard:card]];
|
||||
}
|
||||
}
|
||||
if([key isEqual:@"base"]) {
|
||||
DYFlippedView *actions=[[[DYFlippedView alloc]initWithFrame:NSZeroRect]autorelease];actions.identifier=@"autoControls";
|
||||
[actions addSubview:DYButton(@"自动调色",self,@selector(autoGrade:))];
|
||||
[actions addSubview:DYButton(@"自动白平衡",self,@selector(autoWhiteBalance:))];
|
||||
NSButton *picker=DYButton(@"白平衡吸管",self,@selector(sampleWhiteBalance:));picker.toolTip=@"在画面上吸取中性白色或灰色";[actions addSubview:picker];
|
||||
[card addSubview:actions];[body addObject:actions];
|
||||
}
|
||||
if([key isEqual:@"hsl"]) {
|
||||
DYFlippedView *actions=[[[DYFlippedView alloc]initWithFrame:NSZeroRect]autorelease];actions.identifier=@"sampleControls";
|
||||
NSButton *picker=DYButton(@"吸取自定义 HSL 颜色",self,@selector(sampleCustomColor:));[actions addSubview:picker];[card addSubview:actions];[body addObject:actions];
|
||||
}
|
||||
if([key isEqual:@"curve"]) {
|
||||
DYCurvePanel *graph=[[[DYCurvePanel alloc]initWithFrame:NSZeroRect]autorelease];graph.delegate=self;graph.identifier=@"curveGraph";[card addSubview:graph];[body addObject:graph];[_graphics addObject:graph];
|
||||
}
|
||||
if([key isEqual:@"grading"]) {
|
||||
DYWheelPanel *wheels=[[[DYWheelPanel alloc]initWithFrame:NSZeroRect]autorelease];wheels.delegate=self;wheels.identifier=@"gradingWheels";[card addSubview:wheels];[body addObject:wheels];[_graphics addObject:wheels];
|
||||
}
|
||||
for(NSDictionary *d in section[@"rows"]) {
|
||||
DYFlippedView *row=[[[DYFlippedView alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
[card addSubview:row]; [body addObject:row];
|
||||
NSNumber *pid=d[@"pid"]; if(!pid)continue;
|
||||
NSTextField *label=DYLabel(d[@"title"]?:d[@"key"],11); label.toolTip=d[@"title"];
|
||||
[row addSubview:label];
|
||||
NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"descriptor":d,@"row":row,@"label":label}];
|
||||
if(d[@"enabled"]) {
|
||||
NSButton *eye=DYButton(@"",self,@selector(itemEnabled:));eye.bordered=NO;[eye setButtonType:NSButtonTypePushOnPushOff];eye.image=[NSImage imageWithSystemSymbolName:@"eye" accessibilityDescription:@"启用"];eye.tag=[pid integerValue];eye.contentTintColor=DYAccent();eye.accessibilityLabel=[d[@"title"] stringByAppendingString:@"启用"];eye.toolTip=@"启用或旁路此项";[row addSubview:eye];record[@"itemEnabled"]=eye;
|
||||
}
|
||||
NSString *kind=d[@"kind"]?:@"float";
|
||||
if([kind isEqualToString:@"bool"]) {
|
||||
NSButton *toggle=[NSButton checkboxWithTitle:@"" target:self action:@selector(scalarChanged:)];
|
||||
toggle.tag=[pid integerValue]; toggle.contentTintColor=DYAccent(); toggle.accessibilityLabel=d[@"title"];
|
||||
[row addSubview:toggle]; record[@"toggle"]=toggle;
|
||||
} else if([kind isEqualToString:@"popup"]) {
|
||||
NSPopUpButton *popup=[[[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO] autorelease];
|
||||
[popup addItemsWithTitles:d[@"options"]?:@[]]; popup.font=[NSFont systemFontOfSize:11];
|
||||
popup.target=self; popup.action=@selector(scalarChanged:); popup.tag=[pid integerValue];
|
||||
popup.accessibilityLabel=d[@"title"]; [row addSubview:popup]; record[@"popup"]=popup;
|
||||
} else {
|
||||
NSSlider *slider=[[[NSSlider alloc]initWithFrame:NSZeroRect]autorelease];
|
||||
DYBlueSliderCell *sliderCell=[[[DYBlueSliderCell alloc]init]autorelease];slider.cell=sliderCell;
|
||||
slider.minValue=[d[@"min"]doubleValue];slider.maxValue=[d[@"max"]doubleValue];slider.doubleValue=[d[@"default"]doubleValue];slider.target=self;slider.action=@selector(scalarChanged:);
|
||||
slider.tag=[pid integerValue]; slider.continuous=YES; slider.controlSize=NSControlSizeSmall;
|
||||
slider.accessibilityLabel=d[@"title"]; [row addSubview:slider]; record[@"slider"]=slider;
|
||||
NSTextField *field=[[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
field.font=[NSFont monospacedDigitSystemFontOfSize:11 weight:NSFontWeightMedium];
|
||||
field.textColor=DYInk(); field.backgroundColor=[NSColor colorWithSRGBRed:.08 green:.20 blue:.28 alpha:1];
|
||||
field.bezeled=YES; field.bezelStyle=NSTextFieldRoundedBezel;
|
||||
field.alignment=NSTextAlignmentRight; field.target=self; field.action=@selector(scalarChanged:);
|
||||
field.tag=[pid integerValue]; field.accessibilityLabel=[d[@"title"] stringByAppendingString:@"数值"];
|
||||
[row addSubview:field]; record[@"field"]=field;
|
||||
}
|
||||
NSButton *itemReset=DYButton(@"↺",self,@selector(resetScalar:));
|
||||
itemReset.tag=[pid integerValue]; itemReset.toolTip=@"还原此项";
|
||||
itemReset.accessibilityLabel=[d[@"title"] stringByAppendingString:@"还原"];
|
||||
[row addSubview:itemReset]; record[@"reset"]=itemReset;
|
||||
_controls[pid]=record;
|
||||
}
|
||||
[_cards addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"section":section,@"view":card,@"header":header,@"enabled":enabled,@"reset":reset,@"body":body,@"collapsed":@NO}]];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
- (NSView *)assetRowForKey:(NSString *)key title:(NSString *)title inCard:(NSView *)card {
|
||||
DYFlippedView *row=[[[DYFlippedView alloc] initWithFrame:NSZeroRect] autorelease]; [card addSubview:row];
|
||||
NSTextField *label=DYLabel(title,11); [row addSubview:label];
|
||||
NSButton *choose=DYButton(@"无 · 点击选择…",self,@selector(chooseAsset:)); choose.identifier=key;
|
||||
choose.alignment=NSTextAlignmentLeft; choose.accessibilityLabel=title; [row addSubview:choose];
|
||||
NSButton *remove=DYButton(@"×",self,@selector(removeAsset:)); remove.identifier=key;
|
||||
remove.toolTip=@"移除此 LUT"; remove.accessibilityLabel=[title stringByAppendingString:@"移除"]; [row addSubview:remove];
|
||||
_assetButtons[key]=@{@"row":row,@"label":label,@"choose":choose,@"remove":remove};
|
||||
return row;
|
||||
}
|
||||
- (void)layout {
|
||||
[super layout];
|
||||
CGFloat w=MAX(240,self.bounds.size.width),h=self.bounds.size.height;
|
||||
_brand.frame=NSMakeRect(16,13,w-124,28); _subtitle.frame=NSMakeRect(17,43,w-124,16);
|
||||
_resetAll.frame=NSMakeRect(w-101,23,86,28);
|
||||
CGFloat gap=6,bw=(w-32-gap*2)/3;
|
||||
_save.frame=NSMakeRect(16,66,bw,27); _load.frame=NSMakeRect(16+bw+gap,66,bw,27); _export.frame=NSMakeRect(16+(bw+gap)*2,66,bw,27);
|
||||
_scroll.frame=NSMakeRect(0,104,w,MAX(80,h-104));
|
||||
CGFloat cw=MAX(220,_scroll.contentSize.width-24),y=7;
|
||||
for(NSMutableDictionary *c in _cards) {
|
||||
DYCard *card=c[@"view"]; BOOL collapsed=[c[@"collapsed"] boolValue];
|
||||
NSArray *body=c[@"body"];CGFloat contentHeight=0;
|
||||
for(NSView *row in body)contentHeight+=[row.identifier isEqual:@"curveGraph"]?240:[row.identifier isEqual:@"gradingWheels"]?292:35;
|
||||
CGFloat bh=collapsed?0:contentHeight+9;
|
||||
card.frame=NSMakeRect(12,y,cw,43+bh); y+=card.frame.size.height+12;
|
||||
[c[@"enabled"] setFrame:NSMakeRect(12,12,20,20)];
|
||||
[c[@"header"] setFrame:NSMakeRect(36,8,cw-82,28)];
|
||||
[c[@"reset"] setFrame:NSMakeRect(cw-39,10,27,24)];
|
||||
CGFloat rowY=43;
|
||||
for(NSView *row in body) {
|
||||
CGFloat rh=[row.identifier isEqual:@"curveGraph"]?240:[row.identifier isEqual:@"gradingWheels"]?292:35;row.hidden=collapsed;row.frame=NSMakeRect(10,rowY,cw-20,rh-2);rowY+=rh;
|
||||
if([row.identifier isEqual:@"autoControls"]||[row.identifier isEqual:@"sampleControls"]) {
|
||||
CGFloat buttonWidth=(row.bounds.size.width-8-4*(row.subviews.count-1))/MAX((NSUInteger)1,row.subviews.count);NSInteger buttonIndex=0;
|
||||
for(NSView *button in row.subviews)[button setFrame:NSMakeRect(4+(buttonWidth+4)*buttonIndex++,4,buttonWidth,26)];
|
||||
}
|
||||
}
|
||||
}
|
||||
for(NSDictionary *record in _controls.allValues) {
|
||||
CGFloat rw=[record[@"row"] bounds].size.width;
|
||||
CGFloat lw=MIN(111,MAX(76,rw*.34));
|
||||
CGFloat eyeWidth=record[@"itemEnabled"]?20:0;
|
||||
[record[@"itemEnabled"] setFrame:NSMakeRect(0,6,20,20)];
|
||||
[record[@"label"] setFrame:NSMakeRect(5+eyeWidth,8,lw-eyeWidth,18)];
|
||||
[record[@"reset"] setFrame:NSMakeRect(rw-27,5,25,24)];
|
||||
if(record[@"toggle"]) [record[@"toggle"] setFrame:NSMakeRect(lw+12,6,45,22)];
|
||||
if(record[@"popup"]) [record[@"popup"] setFrame:NSMakeRect(lw+8,5,rw-lw-41,25)];
|
||||
if(record[@"slider"]) {
|
||||
[record[@"slider"] setFrame:NSMakeRect(lw+8,8,MAX(25,rw-lw-103),18)];
|
||||
[record[@"field"] setFrame:NSMakeRect(rw-88,5,57,24)];
|
||||
}
|
||||
}
|
||||
for(NSDictionary *record in _assetButtons.allValues) {
|
||||
CGFloat rw=[record[@"row"] bounds].size.width;
|
||||
[record[@"label"] setFrame:NSMakeRect(5,8,88,18)];
|
||||
[record[@"choose"] setFrame:NSMakeRect(95,4,MAX(80,rw-127),26)];
|
||||
[record[@"remove"] setFrame:NSMakeRect(rw-27,5,25,24)];
|
||||
}
|
||||
[_document setFrameSize:NSMakeSize(_scroll.contentSize.width,MAX(y,_scroll.contentSize.height))];
|
||||
}
|
||||
- (id<FxCustomParameterActionAPI_v4>)actionAPI { return [_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)]; }
|
||||
- (void)refresh {
|
||||
if(_refreshing||!_manager)return;
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI]; if(!action)return;
|
||||
_refreshing=YES;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;
|
||||
id<FxParameterRetrievalAPI_v6> get=[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
|
||||
NSMutableDictionary *graphicValues=[NSMutableDictionary dictionary];
|
||||
for(NSNumber *pid in _controls) {
|
||||
NSDictionary *r=_controls[pid],*d=r[@"descriptor"]; double v=[d[@"default"] doubleValue];
|
||||
[get getFloatValue:&v fromParameter:pid.unsignedIntValue atTime:t];
|
||||
if(!std::isfinite(v))v=[d[@"default"] doubleValue];
|
||||
graphicValues[d[@"key"]]=@(v);
|
||||
if(d[@"enabled"]) {double enabled=1;[get getFloatValue:&enabled fromParameter:[d[@"enabled"] unsignedIntValue] atTime:t];[r[@"itemEnabled"] setState:enabled>=.5?NSControlStateValueOn:NSControlStateValueOff];[r[@"itemEnabled"] setImage:[NSImage imageWithSystemSymbolName:enabled>=.5?@"eye":@"eye.slash" accessibilityDescription:enabled>=.5?@"启用":@"旁路"]];for(NSString *control in @[@"slider",@"field",@"popup"]) [r[control] setAlphaValue:enabled>=.5?1:.45];}
|
||||
[r[@"slider"] setDoubleValue:v]; [r[@"field"] setStringValue:DYNumber(v,d)];
|
||||
[r[@"toggle"] setState:v>=.5?NSControlStateValueOn:NSControlStateValueOff];
|
||||
NSPopUpButton *popup=r[@"popup"]; if(popup.numberOfItems>0) [popup selectItemAtIndex:MAX(0,MIN((NSInteger)llround(v),popup.numberOfItems-1))];
|
||||
}
|
||||
for(id graphic in _graphics)[graphic setValues:graphicValues];
|
||||
for(NSDictionary *c in _cards) {
|
||||
NSNumber *pid=c[@"section"][@"enabled"];
|
||||
double v=1;if(pid)[get getFloatValue:&v fromParameter:pid.unsignedIntValue atTime:t];
|
||||
[c[@"enabled"] setState:v>=.5?NSControlStateValueOn:NSControlStateValueOff];
|
||||
for(NSView *row in c[@"body"])row.alphaValue=v>=.5?1:.45;
|
||||
}
|
||||
DYAssetState *assets=DYReadAssets(_manager,t);
|
||||
for(NSString *key in _assetButtons) {
|
||||
NSString *path=assets.paths[key]; NSButton *button=_assetButtons[key][@"choose"];
|
||||
button.title=path.length?path.lastPathComponent:@"无 · 点击选择…"; button.toolTip=path.length?path:@"选择 .cube 立体 LUT";
|
||||
[_assetButtons[key][@"remove"] setEnabled:path.length>0];
|
||||
}
|
||||
} @finally { [action endAction:self]; _refreshing=NO; }
|
||||
}
|
||||
- (void)postChanged { [[NSNotificationCenter defaultCenter] postNotificationName:@"DYModelChanged" object:_manager]; }
|
||||
- (void)scalarChanged:(NSControl *)sender {
|
||||
if(_refreshing)return;
|
||||
NSNumber *pid=@(sender.tag); NSDictionary *r=_controls[pid],*d=r[@"descriptor"]; if(!d)return;
|
||||
double v;
|
||||
if([sender isKindOfClass:[NSPopUpButton class]])v=[(NSPopUpButton *)sender indexOfSelectedItem];
|
||||
else if([sender isKindOfClass:[NSButton class]])v=[(NSButton *)sender state]==NSControlStateValueOn?1:0;
|
||||
else {
|
||||
if([sender isKindOfClass:[NSTextField class]]) {
|
||||
NSScanner *scanner=[NSScanner scannerWithString:sender.stringValue];
|
||||
if(![scanner scanDouble:&v]||!scanner.isAtEnd||!std::isfinite(v)){NSBeep();[self refresh];return;}
|
||||
} else v=sender.doubleValue;
|
||||
}
|
||||
v=fmax([d[@"min"] doubleValue],fmin([d[@"max"] doubleValue],v));
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try { id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)]; [set setFloatValue:v toParameter:pid.unsignedIntValue atTime:action.currentTime]; }
|
||||
@finally { [action endAction:self]; }
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)resetScalar:(NSControl *)sender {
|
||||
NSDictionary *r=_controls[@(sender.tag)],*d=r[@"descriptor"];if(!d)return;
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];[set setFloatValue:[d[@"default"] doubleValue] toParameter:(UInt32)sender.tag atTime:action.currentTime];}
|
||||
@finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)itemEnabled:(NSButton *)sender {
|
||||
NSDictionary *d=_controls[@(sender.tag)][@"descriptor"];NSNumber *pid=d[@"enabled"];if(!pid)return;
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];[set setFloatValue:sender.state==NSControlStateValueOn?1:0 toParameter:pid.unsignedIntValue atTime:action.currentTime];}
|
||||
@finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)writeGraphicValues:(NSDictionary *)values {
|
||||
NSMutableDictionary *byKey=[NSMutableDictionary dictionary];for(NSDictionary *d in DYDescriptors())byKey[d[@"key"]]=d;
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
|
||||
for(NSString *key in values) {NSDictionary *d=byKey[key];double v=[values[key] doubleValue];if(!d||!std::isfinite(v))continue;v=fmax([d[@"min"]doubleValue],fmin([d[@"max"]doubleValue],v));[set setFloatValue:v toParameter:[d[@"pid"]unsignedIntValue] atTime:t];}
|
||||
} @finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)groupEnabled:(NSButton *)sender {
|
||||
if(sender.tag>=_cards.count)return;
|
||||
NSNumber *pid=_cards[sender.tag][@"section"][@"enabled"];if(!pid)return;
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];[set setFloatValue:sender.state==NSControlStateValueOn?1:0 toParameter:pid.unsignedIntValue atTime:action.currentTime];}
|
||||
@finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)toggleSection:(NSButton *)sender {
|
||||
if(sender.tag>=_cards.count)return;
|
||||
NSMutableDictionary *card=_cards[sender.tag];BOOL collapsed=![card[@"collapsed"] boolValue];card[@"collapsed"]=@(collapsed);
|
||||
sender.title=[(collapsed?@"▸ ":@"▾ ") stringByAppendingString:card[@"section"][@"title"]?:@""];
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
- (void)resetSection:(NSButton *)sender {
|
||||
if(sender.tag>=_cards.count)return;
|
||||
NSDictionary *section=_cards[sender.tag][@"section"];
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
|
||||
for(NSDictionary *d in section[@"rows"]) {[set setFloatValue:[d[@"default"] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];if(d[@"enabled"])[set setFloatValue:1 toParameter:[d[@"enabled"] unsignedIntValue] atTime:t];}
|
||||
NSNumber *enabled=section[@"enabled"];if(enabled)[set setFloatValue:1 toParameter:enabled.unsignedIntValue atTime:t];
|
||||
NSString *key=section[@"key"]?:@"";
|
||||
if([key localizedCaseInsensitiveContainsString:@"input"]||[key localizedCaseInsensitiveContainsString:@"look"]) {
|
||||
DYAssetState *assets=[[DYReadAssets(_manager,t) copy] autorelease];
|
||||
if(!assets)assets=[[[DYAssetState alloc] init] autorelease];
|
||||
NSMutableDictionary *paths=[[assets.paths mutableCopy] autorelease];
|
||||
if(!paths)paths=[NSMutableDictionary dictionary];
|
||||
if([key localizedCaseInsensitiveContainsString:@"input"]) [paths removeObjectForKey:@"input"];
|
||||
if([key localizedCaseInsensitiveContainsString:@"look"])for(NSInteger i=0;i<5;i++)[paths removeObjectForKey:[NSString stringWithFormat:@"look%ld",(long)i]];
|
||||
assets.paths=paths;DYWriteAssets(_manager,assets,t);
|
||||
}
|
||||
} @finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)resetAll:(id)sender {
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
|
||||
for(NSDictionary *d in DYDescriptors())[set setFloatValue:[d[@"default"] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];
|
||||
DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=@{};DYWriteAssets(_manager,assets,t);
|
||||
} @finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)chooseAsset:(NSButton *)sender {
|
||||
NSOpenPanel *panel=[NSOpenPanel openPanel];panel.allowedFileTypes=@[@"cube"];panel.allowsMultipleSelection=NO;
|
||||
panel.canChooseDirectories=NO;panel.message=@"选择 .cube 立体 LUT";
|
||||
if([panel runModal]!=NSModalResponseOK)return;
|
||||
[self setAssetPath:panel.URL.path forKey:sender.identifier];
|
||||
}
|
||||
- (void)removeAsset:(NSButton *)sender { [self setAssetPath:nil forKey:sender.identifier]; }
|
||||
- (void)setAssetPath:(NSString *)path forKey:(NSString *)key {
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;DYAssetState *assets=[[DYReadAssets(_manager,t) copy] autorelease];
|
||||
if(!assets)assets=[[[DYAssetState alloc] init] autorelease];
|
||||
NSMutableDictionary *paths=[[assets.paths mutableCopy] autorelease];if(!paths)paths=[NSMutableDictionary dictionary];
|
||||
if(path.length)paths[key]=path;else [paths removeObjectForKey:key];
|
||||
assets.paths=paths;DYWriteAssets(_manager,assets,t);
|
||||
} @finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
}
|
||||
- (void)showError:(NSString *)message {
|
||||
NSAlert *a=[[[NSAlert alloc] init] autorelease];a.messageText=@"大鱼调色";a.informativeText=message?:@"操作未完成";[a addButtonWithTitle:@"好"];[a runModal];
|
||||
}
|
||||
- (NSDictionary *)presetSnapshot {
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return nil;
|
||||
NSMutableDictionary *values=[NSMutableDictionary dictionary];NSDictionary *paths=@{};
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterRetrievalAPI_v6> get=[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
|
||||
for(NSDictionary *d in DYDescriptors()) {double v=[d[@"default"] doubleValue];[get getFloatValue:&v fromParameter:[d[@"pid"] unsignedIntValue] atTime:t];if(std::isfinite(v))values[d[@"key"]]=@(v);}
|
||||
paths=[[DYReadAssets(_manager,t).paths copy] autorelease]?:@{};
|
||||
} @finally {[action endAction:self];}
|
||||
return @{@"format":@"com.dayu.color.preset",@"version":@1,@"values":values,@"paths":paths};
|
||||
}
|
||||
- (void)savePreset:(id)sender {
|
||||
NSDictionary *snapshot=[self presetSnapshot];if(!snapshot)return;
|
||||
NSSavePanel *panel=[NSSavePanel savePanel];panel.nameFieldStringValue=@"大鱼调色预设.json";panel.allowedFileTypes=@[@"json"];
|
||||
if([panel runModal]!=NSModalResponseOK)return;
|
||||
NSError *error=nil;NSData *data=[NSJSONSerialization dataWithJSONObject:snapshot options:NSJSONWritingPrettyPrinted error:&error];
|
||||
if(!data||![data writeToURL:panel.URL options:NSDataWritingAtomic error:&error])[self showError:error.localizedDescription];
|
||||
}
|
||||
- (void)loadPreset:(id)sender {
|
||||
NSOpenPanel *panel=[NSOpenPanel openPanel];panel.allowedFileTypes=@[@"json"];panel.allowsMultipleSelection=NO;panel.canChooseDirectories=NO;
|
||||
if([panel runModal]!=NSModalResponseOK)return;
|
||||
NSError *error=nil;NSData *data=[NSData dataWithContentsOfURL:panel.URL options:0 error:&error];
|
||||
if(!data||data.length>2*1024*1024){[self showError:error.localizedDescription?:@"预设文件过大"];return;}
|
||||
id json=[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
||||
if(![json isKindOfClass:NSDictionary.class]||![json[@"format"] isEqual:@"com.dayu.color.preset"]||![json[@"version"] isEqual:@1]||![json[@"values"] isKindOfClass:NSDictionary.class]||![json[@"paths"] isKindOfClass:NSDictionary.class]){[self showError:@"这不是有效的大鱼调色预设。"];return;}
|
||||
NSDictionary *values=json[@"values"],*paths=json[@"paths"];
|
||||
for(NSDictionary *d in DYDescriptors()) {
|
||||
id v=values[d[@"key"]];if(!v)continue;
|
||||
if(![v isKindOfClass:NSNumber.class]||!std::isfinite([v doubleValue])||[v doubleValue]<[d[@"min"] doubleValue]||[v doubleValue]>[d[@"max"] doubleValue]){[self showError:@"预设包含无效参数,尚未修改当前调色。"];return;}
|
||||
}
|
||||
NSMutableDictionary *validPaths=[NSMutableDictionary dictionary];NSMutableArray *missing=[NSMutableArray array];
|
||||
for(NSString *key in @[@"input",@"look0",@"look1",@"look2",@"look3",@"look4"]) {
|
||||
id path=paths[key];if(!path)continue;
|
||||
if(![path isKindOfClass:NSString.class]||![path isAbsolutePath]||![[path pathExtension].lowercaseString isEqual:@"cube"]){[self showError:@"预设包含无效 LUT 路径,尚未修改当前调色。"];return;}
|
||||
if([[NSFileManager defaultManager] isReadableFileAtPath:path])validPaths[key]=path;else [missing addObject:[path lastPathComponent]];
|
||||
}
|
||||
id<FxCustomParameterActionAPI_v4> action=[self actionAPI];if(!action)return;
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
|
||||
for(NSDictionary *d in DYDescriptors())if(values[d[@"key"]])[set setFloatValue:[values[d[@"key"]] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];
|
||||
DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=validPaths;DYWriteAssets(_manager,assets,t);
|
||||
} @finally {[action endAction:self];}
|
||||
[self postChanged];
|
||||
if(missing.count)[self showError:[@"调色参数已恢复,以下 LUT 文件需要重新选择:\n" stringByAppendingString:[missing componentsJoinedByString:@"\n"]]];
|
||||
}
|
||||
- (void)autoGrade:(id)sender { [[NSNotificationCenter defaultCenter]postNotificationName:@"DYAutoGrade" object:_manager]; }
|
||||
- (void)autoWhiteBalance:(id)sender { [[NSNotificationCenter defaultCenter]postNotificationName:@"DYAutoWhiteBalance" object:_manager]; }
|
||||
- (void)sampleWhiteBalance:(id)sender { [self sampleColorForWhiteBalance:YES]; }
|
||||
- (void)sampleCustomColor:(id)sender { [self sampleColorForWhiteBalance:NO]; }
|
||||
- (void)sampleColorForWhiteBalance:(BOOL)whiteBalance {
|
||||
if(_sampler)return;
|
||||
_sampler=[[NSColorSampler alloc]init];
|
||||
[_sampler showSamplerWithSelectionHandler:^(NSColor *selectedColor) {
|
||||
NSColor *color=[selectedColor colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
|
||||
if(color) {
|
||||
if(whiteBalance)[[NSNotificationCenter defaultCenter]postNotificationName:@"DYWhiteBalanceColor" object:_manager userInfo:@{@"color":color}];
|
||||
else [self writeGraphicValues:@{@"sample0":@(color.redComponent),@"sample1":@(color.greenComponent),@"sample2":@(color.blueComponent)}];
|
||||
}
|
||||
[_sampler release];_sampler=nil;
|
||||
}];
|
||||
}
|
||||
- (void)exportLUT:(id)sender {
|
||||
NSSavePanel *panel=[NSSavePanel savePanel];panel.allowedFileTypes=@[@"cube"];panel.nameFieldStringValue=@"大鱼调色.cube";
|
||||
panel.message=@"导出仅包含逐像素调色。纹理、清晰度和画面分析无法保存到 .cube LUT。";
|
||||
if([panel runModal]!=NSModalResponseOK)return;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"DYExportLUT" object:_manager userInfo:@{@"url":panel.URL}];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
#import "DYUniforms.h"
|
||||
|
||||
enum { DYInspectorParameterID=9000, DYAssetsParameterID=9001 };
|
||||
FOUNDATION_EXPORT NSString *const DYModelChanged;
|
||||
FOUNDATION_EXPORT NSArray<NSDictionary*> *DYSections(void);
|
||||
FOUNDATION_EXPORT NSArray<NSDictionary*> *DYDescriptors(void);
|
||||
FOUNDATION_EXPORT void DYDefaultUniforms(DYUniforms *u);
|
||||
FOUNDATION_EXPORT BOOL DYCreateParameters(id<PROAPIAccessing> manager,NSError **error);
|
||||
FOUNDATION_EXPORT void DYReadUniforms(id<PROAPIAccessing> manager,CMTime time,DYUniforms *u);
|
||||
|
||||
@interface DYAssetState : NSObject<NSSecureCoding,NSCopying,FxCustomParameterInterpolation_v2>
|
||||
@property(copy) NSDictionary *paths;
|
||||
@end
|
||||
@interface DYInspectorToken : NSObject<NSSecureCoding,NSCopying,FxCustomParameterInterpolation_v2>
|
||||
@end
|
||||
FOUNDATION_EXPORT DYAssetState *DYReadAssets(id<PROAPIAccessing> manager,CMTime time);
|
||||
FOUNDATION_EXPORT BOOL DYWriteAssets(id<PROAPIAccessing> manager,DYAssetState *assets,CMTime time);
|
||||
@@ -0,0 +1,82 @@
|
||||
#import "DYModel.h"
|
||||
#include <cmath>
|
||||
NSString *const DYModelChanged=@"DYModelChanged";
|
||||
static NSMutableArray *sections,*descriptors;
|
||||
static UInt32 PID(NSUInteger offset){return 2000+(UInt32)offset/4;}
|
||||
static NSDictionary *row(NSString*k,NSString*t,NSUInteger o,double lo,double hi,double d,NSString*kind){
|
||||
NSMutableDictionary*r=[@{@"key":k,@"title":t,@"pid":@(PID(o)),@"offset":@(o),@"min":@(lo),@"max":@(hi),@"default":@(d),@"step":@(hi-lo>10?1:.01),@"kind":kind?:@"float"}mutableCopy];
|
||||
[descriptors addObject:r];return [r autorelease];
|
||||
}
|
||||
static void section(NSString*k,NSString*t,NSUInteger offset,NSArray*rows,double def=1){
|
||||
NSDictionary*e=row([k stringByAppendingString:@"Enabled"],t,offset,0,1,def,@"bool");
|
||||
[sections addObject:@{@"key":k,@"title":t,@"enabled":e[@"pid"],@"rows":rows}];
|
||||
}
|
||||
static NSDictionary *scalar(NSString*k,NSString*t,NSUInteger o,double lo=-100,double hi=100,double def=0){return row(k,t,o,lo,hi,def,@"float");}
|
||||
static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{
|
||||
sections=[[NSMutableArray alloc]init];descriptors=[[NSMutableArray alloc]init];
|
||||
NSMutableDictionary*profile=[[scalar(@"inputProfile",@"相机输入",52,0,17)mutableCopy]autorelease];profile[@"kind"]=@"popup";profile[@"options"]=@[@"无",@"Apple Log",@"ARRI LogC3",@"ARRI LogC4",@"Blackmagic Film Gen5",@"Canon C-Log",@"Canon C-Log2",@"Canon C-Log3",@"DJI D-Log",@"DJI D-Log M",@"Fujifilm F-Log",@"Fujifilm F-Log2",@"Nikon N-Log",@"Panasonic V-Log",@"RED Log3G10",@"Sony S-Log2",@"Sony S-Log3",@"Sony HLG"];
|
||||
[descriptors replaceObjectAtIndex:0 withObject:profile];
|
||||
section(@"input",@"输入 / LUT",132,@[profile,scalar(@"preLUTStrength",@"输入强度",56,0,1,1)]);
|
||||
NSMutableArray*base=[NSMutableArray array];
|
||||
NSArray*names=@[@"曝光",@"对比度",@"高光",@"阴影",@"白色色阶",@"黑色色阶",@"色温",@"色调",@"饱和度",@"鲜艳度",@"纹理",@"清晰度",@"去朦胧"];
|
||||
NSArray*keys=@[@"exposure",@"contrast",@"highlights",@"shadows",@"whites",@"blacks",@"temperature",@"tint",@"saturation",@"vibrance",@"texture",@"clarity",@"dehaze"];
|
||||
for(NSUInteger i=0;i<keys.count;i++){
|
||||
NSMutableDictionary*r=[[scalar(keys[i],names[i],i*4,i==0?-5:-100,i==0?5:100)mutableCopy]autorelease];
|
||||
NSDictionary*e=row([keys[i]stringByAppendingString:@"Enabled"],[names[i]stringByAppendingString:@" 启用"],80+i*4,0,1,1,@"bool");r[@"enabled"]=e[@"pid"];
|
||||
[descriptors replaceObjectAtIndex:[descriptors indexOfObjectPassingTest:^BOOL(id obj,NSUInteger idx,BOOL*stop){return [obj[@"key"]isEqual:keys[i]];}] withObject:r];[base addObject:r];
|
||||
}
|
||||
section(@"base",@"基础调色",136,[base subarrayWithRange:NSMakeRange(0,8)]);
|
||||
section(@"color",@"颜色",140,@[base[9],base[8],base[10],base[11],base[12],row(@"skinProtection",@"肤色保护",464,0,1,0,@"bool"),scalar(@"skinHueRange",@"肤色色相范围",468,5,100,40),scalar(@"skinChromaRange",@"肤色饱和度范围",472,5,100,40)]);
|
||||
NSMutableArray*look=[NSMutableArray arrayWithObject:scalar(@"postLUTStrength",@"风格 1 强度",60,0,1,1)];
|
||||
for(int i=0;i<4;i++){[look addObject:row([NSString stringWithFormat:@"look%dEnabled",i+2],[NSString stringWithFormat:@"风格 %d 启用",i+2],160+i*4,0,1,1,@"bool")];[look addObject:scalar([NSString stringWithFormat:@"look%dStrength",i+2],[NSString stringWithFormat:@"风格 %d 强度",i+2],64+i*4,0,1,1)];}
|
||||
section(@"look",@"风格 LUT",144,look);
|
||||
NSMutableArray*curves=[NSMutableArray array];
|
||||
NSArray*cn=@[@"主曲线 阴影",@"主曲线 暗部",@"主曲线 亮部",@"主曲线 高光",@"红曲线 阴影",@"红曲线 高光",@"绿曲线 阴影",@"绿曲线 高光",@"蓝曲线 阴影",@"蓝曲线 高光"];
|
||||
for(int i=0;i<10;i++)[curves addObject:scalar([NSString stringWithFormat:@"curveY%d",i],cn[i],184+i*4)];
|
||||
for(int i=0;i<4;i++)[curves addObject:scalar([NSString stringWithFormat:@"masterX%d",i],[NSString stringWithFormat:@"主曲线 点%d X",i+1],224+i*4,-1,1,-1)];
|
||||
for(int c=0;c<3;c++)for(int i=0;i<2;i++)[curves addObject:scalar([NSString stringWithFormat:@"channel%dX%d",c,i],[NSString stringWithFormat:@"%@曲线 点%d X",@[@"红",@"绿",@"蓝"][c],i+1],240+c*8+i*4,-1,1,-1)];
|
||||
for(int c=0;c<4;c++)for(int i=0;i<4;i++){NSUInteger off=816+c*32;[curves addObject:scalar([NSString stringWithFormat:@"curve%dExtra%d",c,i],[NSString stringWithFormat:@"%@ 扩展点%d 偏移",@[@"主",@"红",@"绿",@"蓝"][c],i+1],off+i*4)];[curves addObject:scalar([NSString stringWithFormat:@"curve%dExtraX%d",c,i],[NSString stringWithFormat:@"%@ 扩展点%d X",@[@"主",@"红",@"绿",@"蓝"][c],i+1],off+16+i*4,-1,1,-1)];}
|
||||
section(@"curve",@"曲线",176,curves);
|
||||
NSMutableArray*hsl=[NSMutableArray array];NSArray*colors=@[@"红",@"橙",@"黄",@"绿",@"青",@"蓝",@"紫",@"洋红"];
|
||||
for(int a=0;a<3;a++)for(int c=0;c<8;c++)[hsl addObject:scalar([NSString stringWithFormat:@"hsl%d_%d",a,c],[NSString stringWithFormat:@"%@ %@",colors[c],@[@"色相",@"饱和度",@"明亮度"][a]],272+a*32+c*4)];
|
||||
for(int i=0;i<3;i++){[hsl addObject:scalar([NSString stringWithFormat:@"sample%d",i],[NSString stringWithFormat:@"自定义色 %@",@[@"R",@"G",@"B"][i]],368+i*4,0,1,i==0?1:i==1?.1:.58)];[hsl addObject:scalar([NSString stringWithFormat:@"custom%d",i],[NSString stringWithFormat:@"自定义 %@",@[@"色相",@"饱和度",@"明亮度"][i]],384+i*4)];[hsl addObject:scalar([NSString stringWithFormat:@"range%d",i],[NSString stringWithFormat:@"自定义 %@范围",@[@"色相",@"饱和度",@"明亮度"][i]],560+i*4,5,i==0?180:100,i==0?30:40)];}
|
||||
[hsl addObject:row(@"hslVisualize",@"显示自定义色选区",576,0,1,0,@"bool")];section(@"hsl",@"HSL 混色",180,hsl);
|
||||
NSMutableArray*grade=[NSMutableArray array];
|
||||
for(int c=0;c<4;c++){NSString*n=@[@"阴影",@"中间调",@"高光",@"全局"][c];int pair=c==0?424:c==1?416:c==2?432:592;int lum=c==0?452:c==1?448:c==2?456:600;
|
||||
for(int a=0;a<3;a++)[grade addObject:scalar([NSString stringWithFormat:@"grade%d_%d",c,a],[NSString stringWithFormat:@"%@ %@",n,@[@"色相",@"饱和度",@"明亮度"][a]],a==2?lum:pair+a*4,a==2?-100:0,a==0?360:100)];}
|
||||
[grade addObject:scalar(@"gradingBlending",@"混合",404,0,100,50)];[grade addObject:scalar(@"gradingBalance",@"平衡",408)];section(@"grading",@"颜色分级",400,grade);
|
||||
NSMutableArray*prim=[NSMutableArray array];for(int c=0;c<3;c++)for(int a=0;a<2;a++)[prim addObject:scalar([NSString stringWithFormat:@"primary%d_%d",c,a],[NSString stringWithFormat:@"%@原色 %@",@[@"红",@"绿",@"蓝"][c],a?@"饱和度":@"色相"],484+c*8+a*4)];section(@"primaries",@"三原色",480,prim);
|
||||
NSMutableArray*levels=[NSMutableArray array];for(int c=0;c<4;c++)for(int a=0;a<5;a++)[levels addObject:scalar([NSString stringWithFormat:@"level%d_%d",c,a],[NSString stringWithFormat:@"%@ %@",@[@"RGB",@"红",@"绿",@"蓝"][c],@[@"输入黑",@"伽马",@"输入白",@"输出黑",@"输出白"][a]],624+a*16+c*4,a==1?.1:0,a==1?10:255,a==1?1:(a==2||a==4)?255:0)];section(@"levels",@"色阶",608,levels);
|
||||
NSMutableArray*bw=[NSMutableArray array];for(int c=0;c<6;c++)[bw addObject:scalar([NSString stringWithFormat:@"bw%d",c],[NSString stringWithFormat:@"黑白 %@",@[@"红",@"黄",@"绿",@"青",@"蓝",@"洋红"][c]],c<4?720+c*4:736+(c-4)*4,0,200,100)];[bw addObject:scalar(@"bwHue",@"着色色相",744,0,360)];[bw addObject:scalar(@"bwSat",@"着色饱和度",748,0,100)];section(@"blackwhite",@"黑白混色",704,bw,0);
|
||||
NSMutableArray*balance=[NSMutableArray arrayWithObject:row(@"preserveLuma",@"保持明度",756,0,1,1,@"bool")];for(int c=0;c<3;c++)for(int a=0;a<3;a++)[balance addObject:scalar([NSString stringWithFormat:@"balance%d_%d",c,a],[NSString stringWithFormat:@"%@ %@",@[@"阴影",@"中间调",@"高光"][c],@[@"青 ↔ 红",@"洋红 ↔ 绿",@"黄 ↔ 蓝"][a]],768+c*16+a*4)];section(@"balance",@"色彩平衡",752,balance);
|
||||
});}
|
||||
NSArray *DYSections(){initialize();return sections;} NSArray *DYDescriptors(){initialize();return descriptors;}
|
||||
void DYDefaultUniforms(DYUniforms*u){memset(u,0,sizeof(*u));for(NSDictionary*r in DYDescriptors())*(float*)((uint8_t*)u+[r[@"offset"]unsignedIntegerValue])=[r[@"default"]floatValue];u->primariesM0=(DYFloat3){1,0,0};u->primariesM1=(DYFloat3){0,1,0};u->primariesM2=(DYFloat3){0,0,1};}
|
||||
void DYReadUniforms(id<PROAPIAccessing>m,CMTime t,DYUniforms*u){DYDefaultUniforms(u);id<FxParameterRetrievalAPI_v6>g=[m apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];for(NSDictionary*r in DYDescriptors()){double v=[r[@"default"]doubleValue];if([g getFloatValue:&v fromParameter:[r[@"pid"]unsignedIntValue] atTime:t]&&std::isfinite(v))*(float*)((uint8_t*)u+[r[@"offset"]unsignedIntegerValue])=fmin([r[@"max"]doubleValue],fmax([r[@"min"]doubleValue],v));}}
|
||||
BOOL DYCreateParameters(id<PROAPIAccessing>m,NSError**error){id<FxParameterCreationAPI_v5>a=[m apiForProtocol:@protocol(FxParameterCreationAPI_v5)];BOOL ok=a!=nil;
|
||||
ok=[a addCustomParameterWithName:@"大鱼调色" parameterID:DYInspectorParameterID defaultValue:[[[DYInspectorToken alloc]init]autorelease] parameterFlags:kFxParameterFlag_CUSTOM_UI|kFxParameterFlag_USE_FULL_VIEW_WIDTH|kFxParameterFlag_DONT_DISPLAY_IN_DASHBOARD|kFxParameterFlag_NOT_ANIMATABLE]&&ok;
|
||||
for(NSDictionary*r in DYDescriptors())ok=[a addFloatSliderWithName:r[@"title"] parameterID:[r[@"pid"]unsignedIntValue] defaultValue:[r[@"default"]doubleValue] parameterMin:[r[@"min"]doubleValue] parameterMax:[r[@"max"]doubleValue] sliderMin:[r[@"min"]doubleValue] sliderMax:[r[@"max"]doubleValue] delta:[r[@"step"]doubleValue] parameterFlags:kFxParameterFlag_HIDDEN]&&ok;
|
||||
ok=[a addCustomParameterWithName:@"LUT 文件" parameterID:DYAssetsParameterID defaultValue:[[[DYAssetState alloc]init]autorelease] parameterFlags:kFxParameterFlag_HIDDEN|kFxParameterFlag_NOT_ANIMATABLE]&&ok;
|
||||
if(!ok&&error)*error=[NSError errorWithDomain:FxPlugErrorDomain code:kFxError_InvalidParameter userInfo:@{NSLocalizedDescriptionKey:@"无法创建大鱼调色参数"}];return ok;}
|
||||
@implementation DYAssetState
|
||||
+ (BOOL)supportsSecureCoding{return YES;}
|
||||
- (instancetype)init{if((self=[super init]))_paths=[@{}copy];return self;}
|
||||
- (void)dealloc{[_paths release];[super dealloc];}
|
||||
- (void)encodeWithCoder:(NSCoder*)c{[c encodeObject:_paths forKey:@"paths"];}
|
||||
- (instancetype)initWithCoder:(NSCoder*)c{if((self=[self init])){NSSet*s=[NSSet setWithObjects:NSDictionary.class,NSString.class,nil];NSDictionary*d=[c decodeObjectOfClasses:s forKey:@"paths"];if(d)self.paths=d;}return self;}
|
||||
- (id)copyWithZone:(NSZone*)z{DYAssetState*v=[[[self class]allocWithZone:z]init];v.paths=_paths;return v;}
|
||||
- (id)interpolateBetween:(id)r withWeight:(float)w{return w<.5?[[self copy]autorelease]:[[r copy]autorelease];}
|
||||
- (BOOL)isEqual:(id)o{return [o isKindOfClass:self.class]&&[_paths isEqual:[o paths]];}
|
||||
- (NSUInteger)hash{return _paths.hash;}
|
||||
@end
|
||||
@implementation DYInspectorToken
|
||||
+ (BOOL)supportsSecureCoding{return YES;}
|
||||
- (void)encodeWithCoder:(NSCoder*)c{[c encodeInt:1 forKey:@"schema"];}
|
||||
- (instancetype)initWithCoder:(NSCoder*)c{return [self init];}
|
||||
- (id)copyWithZone:(NSZone*)z{return [[[self class]allocWithZone:z]init];}
|
||||
- (id)interpolateBetween:(id)r withWeight:(float)w{return [[self copy]autorelease];}
|
||||
- (BOOL)isEqual:(id)o{return [o isKindOfClass:self.class];}
|
||||
- (NSUInteger)hash{return 1;}
|
||||
@end
|
||||
DYAssetState*DYReadAssets(id<PROAPIAccessing>m,CMTime t){DYAssetState*v=nil;id<FxParameterRetrievalAPI_v6>g=[m apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];[g getCustomParameterValue:&v fromParameter:DYAssetsParameterID atTime:t];return [v isKindOfClass:DYAssetState.class]?v:[[[DYAssetState alloc]init]autorelease];}
|
||||
BOOL DYWriteAssets(id<PROAPIAccessing>m,DYAssetState*v,CMTime t){id<FxParameterSettingAPI_v6>s=[m apiForProtocol:@protocol(FxParameterSettingAPI_v6)];return [s setCustomParameterValue:v toParameter:DYAssetsParameterID atTime:t];}
|
||||
@@ -0,0 +1,4 @@
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
@interface DYPlugIn : NSObject<FxTileableEffect,FxCustomParameterViewHost_v2>
|
||||
@property(assign) id<PROAPIAccessing> apiManager;
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
#import "DYPlugIn.h"
|
||||
#import "DYModel.h"
|
||||
#import "DYRenderer.h"
|
||||
#import "DYInspector.h"
|
||||
#import "DYColorTables.h"
|
||||
#import "DYAutoGrade.h"
|
||||
@implementation DYPlugIn {
|
||||
DYRenderer *_renderer;
|
||||
}
|
||||
- (instancetype)initWithAPIManager:(id<PROAPIAccessing>)manager{if((self=[super init])){_apiManager=manager;_renderer=[DYRenderer new];NSNotificationCenter*n=NSNotificationCenter.defaultCenter;[n addObserver:self selector:@selector(exportRequested:) name:@"DYExportLUT" object:manager];[n addObserver:self selector:@selector(autoRequested:) name:@"DYAutoGrade" object:manager];[n addObserver:self selector:@selector(autoRequested:) name:@"DYAutoWhiteBalance" object:manager];[n addObserver:self selector:@selector(whiteBalanceRequested:) name:@"DYWhiteBalanceColor" object:manager];}return self;}
|
||||
- (void)dealloc{[NSNotificationCenter.defaultCenter removeObserver:self];[_renderer release];[super dealloc];}
|
||||
- (BOOL)properties:(NSDictionary**)p error:(NSError**)e{*p=@{kFxPropertyKey_MayRemapTime:@NO,kFxPropertyKey_PixelTransformSupport:@(kFxPixelTransform_ScaleTranslate),kFxPropertyKey_VariesWhenParamsAreStatic:@NO,kFxPropertyKey_DesiredProcessingColorInfo:@(kFxImageColorInfo_RGB_LINEAR),kFxPropertyKey_NeedsFullBuffer:@YES};return YES;}
|
||||
- (BOOL)addParametersWithError:(NSError**)e{return DYCreateParameters(_apiManager,e);}
|
||||
- (NSSet<Class>*)classesForCustomParameterID:(UInt32)pid{return pid==DYAssetsParameterID?[NSSet setWithObjects:DYAssetState.class,NSDictionary.class,NSString.class,nil]:[NSSet setWithObject:DYInspectorToken.class];}
|
||||
- (NSView*)createViewForParameterID:(UInt32)pid{return pid==DYInspectorParameterID?[[DYInspector alloc]initWithAPIManager:_apiManager]:[[NSView alloc]initWithFrame:NSZeroRect];}
|
||||
- (BOOL)parameterChanged:(UInt32)pid atTime:(CMTime)t error:(NSError**)e{dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self.apiManager];});return YES;}
|
||||
- (BOOL)pluginState:(NSData**)state atTime:(CMTime)t quality:(FxQuality)q error:(NSError**)e{
|
||||
DYUniforms u;DYReadUniforms(_apiManager,t,&u);DYAssetState*a=DYReadAssets(_apiManager,t);NSDictionary*s=@{@"schema":@1,@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{}};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil;
|
||||
}
|
||||
- (BOOL)destinationImageRect:(FxRect*)rect sourceImages:(NSArray<FxImageTile*>*)src destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(!src.count)return NO;*rect=src[0].imagePixelBounds;return YES;}
|
||||
- (BOOL)sourceTileRect:(FxRect*)rect sourceImageIndex:(NSUInteger)i sourceImages:(NSArray<FxImageTile*>*)src destinationTileRect:(FxRect)dstRect destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(i>=src.count)return NO;*rect=src[i].imagePixelBounds;return YES;}
|
||||
- (BOOL)renderDestinationImage:(FxImageTile*)dst sourceImages:(NSArray<FxImageTile*>*)src pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{
|
||||
if(!src.count||!src[0].ioSurface||!dst.ioSurface||!s.length)return NO;NSDictionary*p=[NSPropertyListSerialization propertyListWithData:s options:NSPropertyListImmutable format:NULL error:e];NSData*b=p[@"uniforms"];if(![p isKindOfClass:NSDictionary.class]||![p[@"schema"]isEqual:@1]||![b isKindOfClass:NSData.class]||b.length!=sizeof(DYUniforms)||![p[@"paths"]isKindOfClass:NSDictionary.class])return NO;DYUniforms u;[b getBytes:&u length:sizeof(u)];return [_renderer renderSource:src[0] destination:dst uniforms:u paths:p[@"paths"] error:e];
|
||||
}
|
||||
- (void)alert:(NSString*)message{dispatch_async(dispatch_get_main_queue(),^{NSAlert*a=[NSAlert new];a.messageText=@"大鱼调色";a.informativeText=message?:@"操作未完成";[a runModal];[a release];});}
|
||||
- (void)exportRequested:(NSNotification*)n{
|
||||
NSURL*url=n.userInfo[@"url"];if(![url isKindOfClass:NSURL.class])return;id<FxCustomParameterActionAPI_v4>a=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];DYUniforms u;DYReadUniforms(_apiManager,a.currentTime,&u);NSDictionary*paths=[DYReadAssets(_apiManager,a.currentTime).paths copy];[a endAction:self];NSError*e=nil;BOOL ok=[_renderer exportLUT:url uniforms:u paths:paths error:&e];[paths release];if(!ok)[self alert:e.localizedDescription];
|
||||
}
|
||||
- (void)applyValues:(NSDictionary*)values{if(!values){[self alert:@"尚未拿到当前片段画面,请移动播放头后重试。"];return;}id<FxCustomParameterActionAPI_v4>a=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];@try{id<FxParameterSettingAPI_v6>s=[_apiManager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];for(NSDictionary*r in DYDescriptors()){NSNumber*v=values[r[@"key"]];if(v)[s setFloatValue:v.doubleValue toParameter:[r[@"pid"]unsignedIntValue] atTime:a.currentTime];}}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_apiManager];}
|
||||
- (void)autoRequested:(NSNotification*)n{NSData*frame=[_renderer preview];[self applyValues:[n.name isEqual:@"DYAutoGrade"]?DYAutoGrade(frame):DYAutoWhiteBalance(frame)];}
|
||||
- (void)whiteBalanceRequested:(NSNotification*)n{NSColor*c=[n.userInfo[@"color"]colorUsingColorSpace:NSColorSpace.sRGBColorSpace];if(!c)return;float temp=0,tint=0;if([DYColorTables neutralizeColor:(vector_float3){(float)c.redComponent,(float)c.greenComponent,(float)c.blueComponent} temperature:&temp tint:&tint])[self applyValues:@{@"temperature":@(temp),@"tint":@(tint)}];else [self alert:@"所选颜色过暗,请选择白色或中性灰区域。"];}
|
||||
@end
|
||||
@@ -0,0 +1,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
#import "DYUniforms.h"
|
||||
@interface DYRenderer : NSObject
|
||||
- (BOOL)renderSource:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
|
||||
- (NSData*)preview;
|
||||
@end
|
||||
@@ -0,0 +1,89 @@
|
||||
#import "DYRenderer.h"
|
||||
#import "DYColorTables.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include <zlib.h>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
static BOOL fail(NSError**e,NSString*m){if(e)*e=[NSError errorWithDomain:@"com.dayu.color" code:1 userInfo:@{NSLocalizedDescriptionKey:m?:@"Metal 调色失败"}];return NO;}
|
||||
static NSArray *inputFiles(){return @[@"",@"apple_log_to_rec709",@"arri_logc3_to_rec709",@"arri_logc4_to_rec709",@"blackmagic_film_gen5_to_rec709",@"canon_clog_bt709_to_rec709",@"canon_clog2_cinema_gamut_to_rec709",@"canon_clog3_cinema_gamut_to_rec709",@"dji_dlog_to_rec709",@"dji_dlog_m_to_rec709",@"fujifilm_flog_to_rec709",@"fujifilm_flog2_to_rec709",@"nikon_nlog_to_rec709",@"panasonic_vlog_vgamut_to_rec709",@"red_log3g10_rwg_to_rec709",@"sony_slog2_sgamut_to_rec709",@"sony_slog3_sgamut3cine_to_rec709",@"sony_hlg_bt2020_to_rec709"];}
|
||||
static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){MTLTextureDescriptor*t=[MTLTextureDescriptor new];t.textureType=MTLTextureType3D;t.pixelFormat=MTLPixelFormatRGBA32Float;t.width=n;t.height=n;t.depth=n;t.storageMode=MTLStorageModeShared;t.usage=MTLTextureUsageShaderRead;id<MTLTexture>x=[d newTextureWithDescriptor:t];[t release];if(x)[x replaceRegion:MTLRegionMake3D(0,0,0,n,n,n) mipmapLevel:0 slice:0 withBytes:values bytesPerRow:n*16 bytesPerImage:n*n*16];return [x autorelease];}
|
||||
static BOOL loadCube(NSString*path,std::vector<float>&data,NSUInteger&size,NSError**err){
|
||||
NSData*b=[NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:err];if(!b)return NO;
|
||||
if([path.pathExtension.lowercaseString isEqual:@"dylut"]){
|
||||
if(b.length<36||memcmp(b.bytes,"DYLT",4))return fail(err,@"输入 LUT 格式损坏");uint32_t n=0,bytes=0;memcpy(&n,(uint8_t*)b.bytes+4,4);memcpy(&bytes,(uint8_t*)b.bytes+8,4);if(n<2||n>128||bytes!=n*n*n*16)return fail(err,@"输入 LUT 尺寸无效");data.resize(bytes/4);uLongf len=bytes;if(uncompress((Bytef*)data.data(),&len,(Bytef*)b.bytes+36,b.length-36)!=Z_OK||len!=bytes)return fail(err,@"输入 LUT 解压失败");size=n;return YES;
|
||||
}
|
||||
NSString*s=[[[NSString alloc]initWithData:b encoding:NSUTF8StringEncoding]autorelease];if(!s)return fail(err,@"LUT 必须是 UTF-8 文本");
|
||||
size=0;float domainMin[3]={0,0,0},domainMax[3]={1,1,1};
|
||||
for(NSString*line in [s componentsSeparatedByCharactersInSet:NSCharacterSet.newlineCharacterSet]){
|
||||
NSString*clean=[[[line componentsSeparatedByString:@"#"]firstObject]stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];if(!clean.length)continue;
|
||||
const char*c=clean.UTF8String;int n=0;float r,g,bl;
|
||||
if(sscanf(c,"LUT_3D_SIZE %d",&n)==1){if(n<2||n>128)return fail(err,@"LUT 尺寸应为 2–128");size=n;}
|
||||
else if(sscanf(c,"DOMAIN_MIN %f %f %f",&r,&g,&bl)==3){domainMin[0]=r;domainMin[1]=g;domainMin[2]=bl;}
|
||||
else if(sscanf(c,"DOMAIN_MAX %f %f %f",&r,&g,&bl)==3){domainMax[0]=r;domainMax[1]=g;domainMax[2]=bl;}
|
||||
else if(sscanf(c,"%f %f %f",&r,&g,&bl)==3){if(!std::isfinite(r)||!std::isfinite(g)||!std::isfinite(bl))return fail(err,@"LUT 含无效数字");data.insert(data.end(),{r,g,bl,1});if(data.size()>128*128*128*4)return fail(err,@"LUT 数据过多");}
|
||||
else if([clean hasPrefix:@"LUT_1D_SIZE"])return fail(err,@"请选择三维 .cube LUT");
|
||||
}
|
||||
if(size<2||data.size()!=size*size*size*4)return fail(err,@"LUT 数据数量与尺寸不符");
|
||||
bool resample=false;for(int c=0;c<3;c++){if(!std::isfinite(domainMin[c])||!std::isfinite(domainMax[c])||domainMax[c]<=domainMin[c])return fail(err,@"LUT DOMAIN 范围无效");resample|=domainMin[c]!=0||domainMax[c]!=1;}
|
||||
if(resample){std::vector<float>src=data;for(NSUInteger z=0;z<size;z++)for(NSUInteger y=0;y<size;y++)for(NSUInteger x=0;x<size;x++){float v[3];NSUInteger i[3];NSUInteger pos[3]={x,y,z};for(int c=0;c<3;c++){v[c]=fminf(1,fmaxf(0,(float(pos[c])/(size-1)-domainMin[c])/(domainMax[c]-domainMin[c])))*(size-1);i[c]=fmin(size-2,(NSUInteger)v[c]);v[c]-=i[c];}size_t dest=((z*size+y)*size+x)*4;for(int c=0;c<3;c++){float sum=0;for(int k=0;k<8;k++){int a=k&1,b=(k>>1)&1,d=(k>>2)&1;sum+=src[(((i[2]+d)*size+i[1]+b)*size+i[0]+a)*4+c]*(a?v[0]:1-v[0])*(b?v[1]:1-v[1])*(d?v[2]:1-v[2]);}data[dest+c]=sum;}}}
|
||||
return YES;
|
||||
}
|
||||
@interface DYRenderer(){
|
||||
NSMutableDictionary *_devices,*_luts;
|
||||
DYColorTables *_tables;
|
||||
NSData *_preview;
|
||||
CFTimeInterval _lastPreview;
|
||||
}
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
- (instancetype)init{if((self=[super init])){_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_devices release];[_luts release];[_tables release];[_preview release];[super dealloc];}
|
||||
- (NSData*)preview{@synchronized(self){return [[_preview retain]autorelease];}}
|
||||
- (NSMutableDictionary*)device:(uint64_t)registry error:(NSError**)err{
|
||||
NSNumber*k=@(registry);NSMutableDictionary*entry=_devices[k];if(entry)return entry;
|
||||
id<MTLDevice>d=nil;NSArray*all=MTLCopyAllDevices();for(id<MTLDevice>candidate in all)if(candidate.registryID==registry||!registry){d=[candidate retain];break;}[all release];if(!d){fail(err,@"宿主的 Metal 设备不可用");return nil;}
|
||||
NSURL*url=[[NSBundle bundleForClass:self.class]URLForResource:@"default" withExtension:@"metallib"];
|
||||
id<MTLLibrary>lib=[d newLibraryWithURL:url error:err];if(!lib){[d release];return nil;}
|
||||
id<MTLCommandQueue>q=[d newCommandQueue];entry=[NSMutableDictionary dictionaryWithDictionary:@{@"device":d,@"library":lib,@"queue":q,@"pipelines":[NSMutableDictionary dictionary]}];
|
||||
for(NSString*fn in @[@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyPreview"]){id<MTLFunction>f=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}id<MTLComputePipelineState>p=[d newComputePipelineStateWithFunction:f error:err];[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];}
|
||||
float identity[32];for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){int i=((z*2+y)*2+x)*4;identity[i]=x;identity[i+1]=y;identity[i+2]=z;identity[i+3]=1;}id<MTLTexture>neutral=texture3D(d,identity,2);if(!neutral){fail(err,@"无法分配中性 LUT");return nil;}entry[@"identity"]=neutral;
|
||||
_devices[k]=entry;[d release];[lib release];[q release];return entry;
|
||||
}
|
||||
- (id<MTLTexture>)lut:(NSString*)path entry:(NSDictionary*)e error:(NSError**)err{
|
||||
if(!path.length)return e[@"identity"];
|
||||
NSDictionary*attrs=[[NSFileManager defaultManager]attributesOfItemAtPath:path error:err];if(!attrs)return nil;
|
||||
NSString*key=[NSString stringWithFormat:@"%llu|%@|%@|%@",[e[@"device"]registryID],path,attrs[NSFileModificationDate],attrs[NSFileSize]];id<MTLTexture>t=_luts[key];if(t)return t;
|
||||
std::vector<float>v;NSUInteger n=0;if(!loadCube(path,v,n,err))return nil;t=texture3D(e[@"device"],v.data(),n);if(!t){fail(err,@"LUT 纹理分配失败");return nil;}if(_luts.count>=12)[_luts removeAllObjects];_luts[key]=t;return t;
|
||||
}
|
||||
- (NSArray*)textures:(NSDictionary*)paths uniforms:(DYUniforms*)u entry:(NSDictionary*)e error:(NSError**)err{
|
||||
NSString*input=paths[@"input"];int profile=(int)roundf(u->inputProfile);
|
||||
if(!input.length&&profile>0&&profile<(int)inputFiles().count)input=[[NSBundle bundleForClass:self.class]pathForResource:inputFiles()[profile] ofType:@"dylut" inDirectory:@"InputLUTs"];
|
||||
if(profile>0&&!input.length){fail(err,@"相机输入转换资源缺失");return nil;}
|
||||
NSMutableArray*ts=[NSMutableArray array];id<MTLTexture>t=[self lut:input entry:e error:err];if(!t)return nil;[ts addObject:t];if(!input.length)u->preLUTStrength=0;
|
||||
for(int i=0;i<5;i++){NSString*p=paths[[NSString stringWithFormat:@"look%d",i]];t=[self lut:p entry:e error:err];if(!t)return nil;[ts addObject:t];if(!p.length){if(i==0)u->postLUTStrength=0;else u->extraPostLUTStrengths[i-1]=0;}}
|
||||
[DYColorTables fillPrimaries:u];id<MTLDevice>d=e[@"device"];
|
||||
id<MTLTexture>h=[_tables hslForDevice:d uniforms:u],w=[_tables whiteBalanceForDevice:d uniforms:u],g=[_tables gradingForDevice:d uniforms:u];if(!h||!w||!g){fail(err,@"颜色查表构建失败");return nil;}[ts addObjectsFromArray:@[h,w,g]];return ts;
|
||||
}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{@synchronized(self){@autoreleasepool{
|
||||
NSMutableDictionary*e=[self device:dst.deviceRegistryID error:err];if(!e)return NO;id<MTLDevice>d=e[@"device"];id<MTLTexture>input=[src metalTextureForDevice:d],output=[dst metalTextureForDevice:d];if(!input||!output)return fail(err,@"宿主图像纹理不可用");
|
||||
NSArray*ts=[self textures:paths uniforms:&u entry:e error:err];if(!ts)return NO;
|
||||
NSMutableDictionary*ps=e[@"pipelines"];NSNumber*format=@(output.pixelFormat);id<MTLRenderPipelineState>pipeline=ps[format];if(!pipeline){MTLRenderPipelineDescriptor*p=[MTLRenderPipelineDescriptor new];p.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];p.fragmentFunction=[e[@"library"]newFunctionWithName:@"dyFragment"];p.colorAttachments[0].pixelFormat=output.pixelFormat;pipeline=[d newRenderPipelineStateWithDescriptor:p error:err];[p.vertexFunction release];[p.fragmentFunction release];[p release];if(!pipeline)return NO;ps[format]=pipeline;[pipeline release];}
|
||||
MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;id<MTLTexture>straight=[d newTextureWithDescriptor:td];if(!straight)return fail(err,@"无法分配调色缓冲区");
|
||||
id<MTLCommandBuffer>cb=[e[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyUnpremultiply"]];[ce setTexture:input atIndex:0];[ce setTexture:straight atIndex:1];[ce dispatchThreads:MTLSizeMake(input.width,input.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];
|
||||
float level=.5;id<MTLBuffer>scene=[d newBufferWithBytes:&level length:4 options:MTLResourceStorageModeShared];
|
||||
if(u.whites>0&&u.whitesEnabled>.5&&u.baseSectionEnabled>.5){ce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyWhitesSceneStatistics"]];[ce setTexture:straight atIndex:0];[ce setTexture:ts[7] atIndex:1];[ce setBytes:&u length:sizeof(u) atIndex:0];[ce setBuffer:scene offset:0 atIndex:1];[ce dispatchThreadgroups:MTLSizeMake(1,1,1) threadsPerThreadgroup:MTLSizeMake(256,1,1)];[ce endEncoding];}
|
||||
BOOL preview=CACurrentMediaTime()-_lastPreview>.5;id<MTLBuffer>pb=nil;if(preview){pb=[d newBufferWithLength:64*64*16 options:MTLResourceStorageModeShared];ce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyPreview"]];[ce setTexture:straight atIndex:0];[ce setBuffer:pb offset:0 atIndex:0];[ce dispatchThreads:MTLSizeMake(64,64,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];[ce endEncoding];}
|
||||
MTLRenderPassDescriptor*rp=[MTLRenderPassDescriptor renderPassDescriptor];rp.colorAttachments[0].texture=output;rp.colorAttachments[0].loadAction=MTLLoadActionDontCare;rp.colorAttachments[0].storeAction=MTLStoreActionStore;id<MTLRenderCommandEncoder>re=[cb renderCommandEncoderWithDescriptor:rp];[re setRenderPipelineState:pipeline];
|
||||
float w=output.width,h=output.height;FxRect s=src.tilePixelBounds,t=dst.tilePixelBounds;float sw=s.right-s.left,sh=s.top-s.bottom;float l=(t.left-s.left)/sw,r=(t.right-s.left)/sw,top=(s.top-t.top)/sh,bottom=(s.top-t.bottom)/sh;
|
||||
if(src.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){top=1-top;bottom=1-bottom;}
|
||||
DYVertex2D vs[]={{{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(dst.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(int i=0;i<4;i++)vs[i].position.y=-vs[i].position.y;
|
||||
vector_uint2 vp={(unsigned)output.width,(unsigned)output.height};[re setVertexBytes:vs length:sizeof(vs) atIndex:0];[re setVertexBytes:&vp length:sizeof(vp) atIndex:1];[re setViewport:(MTLViewport){0,0,w,h,0,1}];[re setFragmentTexture:straight atIndex:0];for(NSUInteger i=0;i<ts.count;i++)[re setFragmentTexture:ts[i] atIndex:i+1];[re setFragmentBytes:&u length:sizeof(u) atIndex:0];[re setFragmentBuffer:scene offset:0 atIndex:1];DYRenderOptions options={1,0,0,0};[re setFragmentBytes:&options length:sizeof(options) atIndex:2];[re drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];[re endEncoding];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted;
|
||||
if(ok&&pb){[_preview release];_preview=[[NSData alloc]initWithBytes:pb.contents length:64*64*16];_lastPreview=CACurrentMediaTime();}
|
||||
if(!ok)fail(err,cb.error.localizedDescription);[pb release];[straight release];[scene release];return ok;
|
||||
}}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{@synchronized(self){
|
||||
NSMutableDictionary*e=[self device:0 error:err];if(!e)return NO;NSArray*ts=[self textures:paths uniforms:&u entry:e error:err];if(!ts)return NO;id<MTLDevice>d=e[@"device"];uint32_t n=33;NSUInteger count=n*n*n;id<MTLBuffer>out=[d newBufferWithLength:count*3*4 options:MTLResourceStorageModeShared];if(!out)return fail(err,@"无法分配 LUT 输出");id<MTLCommandBuffer>cb=[e[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyLUTExportKernel"]];for(NSUInteger i=0;i<ts.count;i++)[ce setTexture:ts[i] atIndex:i];[ce setBytes:&u length:sizeof(u) atIndex:0];[ce setBuffer:out offset:0 atIndex:1];[ce setBytes:&n length:4 atIndex:2];[ce dispatchThreads:MTLSizeMake(count,1,1) threadsPerThreadgroup:MTLSizeMake(64,1,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted){[out release];return fail(err,cb.error.localizedDescription);}
|
||||
NSMutableString*s=[NSMutableString stringWithString:@"TITLE \"大鱼调色\"\n# 仅包含逐像素颜色;纹理、清晰度和画面分析不写入 LUT。\nLUT_3D_SIZE 33\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];float*v=(float*)out.contents;for(NSUInteger i=0;i<count;i++){if(!std::isfinite(v[i*3])||!std::isfinite(v[i*3+1])||!std::isfinite(v[i*3+2])){[out release];return fail(err,@"LUT GPU 输出含无效值");}[s appendFormat:@"%.8f %.8f %.8f\n",v[i*3],v[i*3+1],v[i*3+2]];}[out release];return [s writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error:err];
|
||||
}}
|
||||
@end
|
||||
@@ -0,0 +1,240 @@
|
||||
// Stable CPU/Metal ABI, reconstructed from shipped reflection. See tools/kernels/PROVENANCE.json.
|
||||
#pragma once
|
||||
#ifdef __METAL_VERSION__
|
||||
#include <metal_stdlib>
|
||||
typedef metal::float2 DYFloat2;
|
||||
typedef metal::float3 DYFloat3;
|
||||
typedef metal::float4 DYFloat4;
|
||||
typedef metal::uint DYUInt;
|
||||
#else
|
||||
#include <simd/simd.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
typedef vector_float2 DYFloat2;
|
||||
typedef vector_float3 DYFloat3;
|
||||
typedef vector_float4 DYFloat4;
|
||||
typedef uint32_t DYUInt;
|
||||
#endif
|
||||
|
||||
typedef struct DYUniforms {
|
||||
float exposure; // offset 0
|
||||
float contrast; // offset 4
|
||||
float highlights; // offset 8
|
||||
float shadows; // offset 12
|
||||
float whites; // offset 16
|
||||
float blacks; // offset 20
|
||||
float temperature; // offset 24
|
||||
float tint; // offset 28
|
||||
float saturation; // offset 32
|
||||
float vibrance; // offset 36
|
||||
float texture; // offset 40
|
||||
float clarity; // offset 44
|
||||
float dehaze; // offset 48
|
||||
float inputProfile; // offset 52
|
||||
float preLUTStrength; // offset 56
|
||||
float postLUTStrength; // offset 60
|
||||
DYFloat4 extraPostLUTStrengths; // offset 64
|
||||
float exposureEnabled; // offset 80
|
||||
float contrastEnabled; // offset 84
|
||||
float highlightsEnabled; // offset 88
|
||||
float shadowsEnabled; // offset 92
|
||||
float whitesEnabled; // offset 96
|
||||
float blacksEnabled; // offset 100
|
||||
float temperatureEnabled; // offset 104
|
||||
float tintEnabled; // offset 108
|
||||
float saturationEnabled; // offset 112
|
||||
float vibranceEnabled; // offset 116
|
||||
float textureEnabled; // offset 120
|
||||
float clarityEnabled; // offset 124
|
||||
float dehazeEnabled; // offset 128
|
||||
float inputSectionEnabled; // offset 132
|
||||
float baseSectionEnabled; // offset 136
|
||||
float colorSectionEnabled; // offset 140
|
||||
float lookSectionEnabled; // offset 144
|
||||
DYFloat4 extraLookSectionEnableds; // offset 160
|
||||
float curveSectionEnabled; // offset 176
|
||||
float hslSectionEnabled; // offset 180
|
||||
float curveShadows; // offset 184
|
||||
float curveDarks; // offset 188
|
||||
float curveLights; // offset 192
|
||||
float curveHighlights; // offset 196
|
||||
float redCurveShadows; // offset 200
|
||||
float redCurveHighlights; // offset 204
|
||||
float greenCurveShadows; // offset 208
|
||||
float greenCurveHighlights; // offset 212
|
||||
float blueCurveShadows; // offset 216
|
||||
float blueCurveHighlights; // offset 220
|
||||
DYFloat4 curveX; // offset 224
|
||||
DYFloat2 redCurveX; // offset 240
|
||||
DYFloat2 greenCurveX; // offset 248
|
||||
DYFloat2 blueCurveX; // offset 256
|
||||
DYFloat4 hslHueA; // offset 272
|
||||
DYFloat4 hslHueB; // offset 288
|
||||
DYFloat4 hslSatA; // offset 304
|
||||
DYFloat4 hslSatB; // offset 320
|
||||
DYFloat4 hslLumA; // offset 336
|
||||
DYFloat4 hslLumB; // offset 352
|
||||
DYFloat3 hslCustomSample; // offset 368
|
||||
DYFloat3 hslCustomAdjust; // offset 384
|
||||
float colorGradingSectionEnabled; // offset 400
|
||||
float colorGradingBlending; // offset 404
|
||||
float colorGradingBalance; // offset 408
|
||||
DYFloat4 colorGradingHueSatA; // offset 416
|
||||
DYFloat4 colorGradingHueSatB; // offset 432
|
||||
DYFloat3 colorGradingLuma; // offset 448
|
||||
DYFloat3 skinProtection; // offset 464
|
||||
float primariesSectionEnabled; // offset 480
|
||||
float redPrimaryHue; // offset 484
|
||||
float redPrimarySaturation; // offset 488
|
||||
float greenPrimaryHue; // offset 492
|
||||
float greenPrimarySaturation; // offset 496
|
||||
float bluePrimaryHue; // offset 500
|
||||
float bluePrimarySaturation; // offset 504
|
||||
DYFloat3 primariesM0; // offset 512
|
||||
DYFloat3 primariesM1; // offset 528
|
||||
DYFloat3 primariesM2; // offset 544
|
||||
DYFloat3 hslCustomRange; // offset 560
|
||||
float hslCustomVisualize; // offset 576
|
||||
DYFloat3 colorGradingGlobal; // offset 592
|
||||
float levelsSectionEnabled; // offset 608
|
||||
DYFloat4 levelsInputBlack; // offset 624
|
||||
DYFloat4 levelsGamma; // offset 640
|
||||
DYFloat4 levelsInputWhite; // offset 656
|
||||
DYFloat4 levelsOutputBlack; // offset 672
|
||||
DYFloat4 levelsOutputWhite; // offset 688
|
||||
float blackWhiteSectionEnabled; // offset 704
|
||||
DYFloat4 blackWhiteMixA; // offset 720
|
||||
DYFloat2 blackWhiteMixB; // offset 736
|
||||
DYFloat2 blackWhiteTint; // offset 744
|
||||
float colorBalanceSectionEnabled; // offset 752
|
||||
float colorBalancePreserveLuminosity; // offset 756
|
||||
DYFloat3 colorBalanceShadows; // offset 768
|
||||
DYFloat3 colorBalanceMidtones; // offset 784
|
||||
DYFloat3 colorBalanceHighlights; // offset 800
|
||||
DYFloat4 curveExtra; // offset 816
|
||||
DYFloat4 curveExtraX; // offset 832
|
||||
DYFloat4 redCurveExtra; // offset 848
|
||||
DYFloat4 redCurveExtraX; // offset 864
|
||||
DYFloat4 greenCurveExtra; // offset 880
|
||||
DYFloat4 greenCurveExtraX; // offset 896
|
||||
DYFloat4 blueCurveExtra; // offset 912
|
||||
DYFloat4 blueCurveExtraX; // offset 928
|
||||
} DYUniforms;
|
||||
|
||||
typedef struct DYVertex2D { DYFloat2 position; DYFloat2 textureCoordinate; } DYVertex2D;
|
||||
typedef struct DYRenderOptions {
|
||||
DYUInt outputPremultiplied;
|
||||
DYUInt reserved[3];
|
||||
} DYRenderOptions;
|
||||
|
||||
#ifndef __METAL_VERSION__
|
||||
#if defined(__cplusplus)
|
||||
#define DY_ABI_ASSERT static_assert
|
||||
#else
|
||||
#define DY_ABI_ASSERT _Static_assert
|
||||
#endif
|
||||
DY_ABI_ASSERT(sizeof(DYUniforms) == 944, "DYUniforms must match recovered GPU ABI");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, exposure) == 0, "exposure offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, contrast) == 4, "contrast offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, highlights) == 8, "highlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, shadows) == 12, "shadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, whites) == 16, "whites offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blacks) == 20, "blacks offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, temperature) == 24, "temperature offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, tint) == 28, "tint offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, saturation) == 32, "saturation offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, vibrance) == 36, "vibrance offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, texture) == 40, "texture offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, clarity) == 44, "clarity offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, dehaze) == 48, "dehaze offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, inputProfile) == 52, "inputProfile offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, preLUTStrength) == 56, "preLUTStrength offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, postLUTStrength) == 60, "postLUTStrength offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, extraPostLUTStrengths) == 64, "extraPostLUTStrengths offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, exposureEnabled) == 80, "exposureEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, contrastEnabled) == 84, "contrastEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, highlightsEnabled) == 88, "highlightsEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, shadowsEnabled) == 92, "shadowsEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, whitesEnabled) == 96, "whitesEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blacksEnabled) == 100, "blacksEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, temperatureEnabled) == 104, "temperatureEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, tintEnabled) == 108, "tintEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, saturationEnabled) == 112, "saturationEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, vibranceEnabled) == 116, "vibranceEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, textureEnabled) == 120, "textureEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, clarityEnabled) == 124, "clarityEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, dehazeEnabled) == 128, "dehazeEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, inputSectionEnabled) == 132, "inputSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, baseSectionEnabled) == 136, "baseSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorSectionEnabled) == 140, "colorSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, lookSectionEnabled) == 144, "lookSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, extraLookSectionEnableds) == 160, "extraLookSectionEnableds offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveSectionEnabled) == 176, "curveSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslSectionEnabled) == 180, "hslSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveShadows) == 184, "curveShadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveDarks) == 188, "curveDarks offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveLights) == 192, "curveLights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveHighlights) == 196, "curveHighlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redCurveShadows) == 200, "redCurveShadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redCurveHighlights) == 204, "redCurveHighlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenCurveShadows) == 208, "greenCurveShadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenCurveHighlights) == 212, "greenCurveHighlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blueCurveShadows) == 216, "blueCurveShadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blueCurveHighlights) == 220, "blueCurveHighlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveX) == 224, "curveX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redCurveX) == 240, "redCurveX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenCurveX) == 248, "greenCurveX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blueCurveX) == 256, "blueCurveX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslHueA) == 272, "hslHueA offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslHueB) == 288, "hslHueB offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslSatA) == 304, "hslSatA offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslSatB) == 320, "hslSatB offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslLumA) == 336, "hslLumA offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslLumB) == 352, "hslLumB offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslCustomSample) == 368, "hslCustomSample offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslCustomAdjust) == 384, "hslCustomAdjust offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingSectionEnabled) == 400, "colorGradingSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingBlending) == 404, "colorGradingBlending offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingBalance) == 408, "colorGradingBalance offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingHueSatA) == 416, "colorGradingHueSatA offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingHueSatB) == 432, "colorGradingHueSatB offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingLuma) == 448, "colorGradingLuma offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, skinProtection) == 464, "skinProtection offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, primariesSectionEnabled) == 480, "primariesSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redPrimaryHue) == 484, "redPrimaryHue offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redPrimarySaturation) == 488, "redPrimarySaturation offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenPrimaryHue) == 492, "greenPrimaryHue offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenPrimarySaturation) == 496, "greenPrimarySaturation offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, bluePrimaryHue) == 500, "bluePrimaryHue offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, bluePrimarySaturation) == 504, "bluePrimarySaturation offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, primariesM0) == 512, "primariesM0 offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, primariesM1) == 528, "primariesM1 offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, primariesM2) == 544, "primariesM2 offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslCustomRange) == 560, "hslCustomRange offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, hslCustomVisualize) == 576, "hslCustomVisualize offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorGradingGlobal) == 592, "colorGradingGlobal offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsSectionEnabled) == 608, "levelsSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsInputBlack) == 624, "levelsInputBlack offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsGamma) == 640, "levelsGamma offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsInputWhite) == 656, "levelsInputWhite offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsOutputBlack) == 672, "levelsOutputBlack offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, levelsOutputWhite) == 688, "levelsOutputWhite offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blackWhiteSectionEnabled) == 704, "blackWhiteSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blackWhiteMixA) == 720, "blackWhiteMixA offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blackWhiteMixB) == 736, "blackWhiteMixB offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blackWhiteTint) == 744, "blackWhiteTint offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorBalanceSectionEnabled) == 752, "colorBalanceSectionEnabled offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorBalancePreserveLuminosity) == 756, "colorBalancePreserveLuminosity offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorBalanceShadows) == 768, "colorBalanceShadows offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorBalanceMidtones) == 784, "colorBalanceMidtones offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, colorBalanceHighlights) == 800, "colorBalanceHighlights offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveExtra) == 816, "curveExtra offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, curveExtraX) == 832, "curveExtraX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redCurveExtra) == 848, "redCurveExtra offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, redCurveExtraX) == 864, "redCurveExtraX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenCurveExtra) == 880, "greenCurveExtra offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, greenCurveExtraX) == 896, "greenCurveExtraX offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blueCurveExtra) == 912, "blueCurveExtra offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, blueCurveExtraX) == 928, "blueCurveExtraX offset");
|
||||
#undef DY_ABI_ASSERT
|
||||
#endif
|
||||
+6
-6
@@ -5,7 +5,7 @@
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>____XPCService</string>
|
||||
<string>大鱼调色</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
@@ -48,7 +48,7 @@
|
||||
<array>
|
||||
<dict>
|
||||
<key>groupName</key>
|
||||
<string>大鱼调色 Group</string>
|
||||
<string>大鱼调色</string>
|
||||
<key>uuid</key>
|
||||
<string>19E2727A-6BCD-4656-B270-7E2BF482A692</string>
|
||||
</dict>
|
||||
@@ -57,13 +57,13 @@
|
||||
<array>
|
||||
<dict>
|
||||
<key>className</key>
|
||||
<string>____PlugIn</string>
|
||||
<string>DYPlugIn</string>
|
||||
<key>displayName</key>
|
||||
<string>____::FxPlug Name</string>
|
||||
<string>大鱼调色</string>
|
||||
<key>group</key>
|
||||
<string>19E2727A-6BCD-4656-B270-7E2BF482A692</string>
|
||||
<key>infoString</key>
|
||||
<string>____::FxPlug Description</string>
|
||||
<string>输入转换、光影、曲线、HSL 与风格调色</string>
|
||||
<key>protocolNames</key>
|
||||
<array>
|
||||
<string>FxFilter</string>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// MetalDeviceCache.h
|
||||
// 大鱼调色
|
||||
//
|
||||
// Created by mac on 2026/10/31.
|
||||
//
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
|
||||
@class MetalDeviceCacheItem;
|
||||
|
||||
@interface MetalDeviceCache : NSObject
|
||||
{
|
||||
NSMutableArray<MetalDeviceCacheItem*>* deviceCaches;
|
||||
}
|
||||
|
||||
+ (MetalDeviceCache*)deviceCache;
|
||||
+ (MTLPixelFormat)MTLPixelFormatForImageTile:(FxImageTile*)imageTile;
|
||||
|
||||
- (id<MTLDevice>)deviceWithRegistryID:(uint64_t)registryID;
|
||||
- (id<MTLRenderPipelineState>)pipelineStateWithRegistryID:(uint64_t)registryID
|
||||
pixelFormat:(MTLPixelFormat)pixFormat;
|
||||
- (id<MTLCommandQueue>)commandQueueWithRegistryID:(uint64_t)registryID
|
||||
pixelFormat:(MTLPixelFormat)pixFormat;
|
||||
- (void)returnCommandQueueToCache:(id<MTLCommandQueue>)commandQueue;
|
||||
|
||||
@end
|
||||
@@ -1,339 +0,0 @@
|
||||
//
|
||||
// MetalDeviceCache.m
|
||||
// 大鱼调色
|
||||
//
|
||||
// Created by mac on 2026/10/31.
|
||||
//
|
||||
|
||||
#import "MetalDeviceCache.h"
|
||||
|
||||
const NSUInteger kMaxCommandQueues = 5;
|
||||
static NSString* kKey_InUse = @"InUse";
|
||||
static NSString* kKey_CommandQueue = @"CommandQueue";
|
||||
|
||||
static MetalDeviceCache* gDeviceCache = nil;
|
||||
|
||||
@interface MetalDeviceCacheItem : NSObject
|
||||
|
||||
@property (readonly) id<MTLDevice> gpuDevice;
|
||||
@property (readonly) id<MTLRenderPipelineState> pipelineState;
|
||||
@property (retain) NSMutableArray<NSMutableDictionary*>* commandQueueCache;
|
||||
@property (readonly) NSLock* commandQueueCacheLock;
|
||||
@property (readonly) MTLPixelFormat pixelFormat;
|
||||
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device
|
||||
pixelFormat:(MTLPixelFormat)pixFormat;
|
||||
- (id<MTLCommandQueue>)getNextFreeCommandQueue;
|
||||
- (void)returnCommandQueue:(id<MTLCommandQueue>)commandQueue;
|
||||
- (BOOL)containsCommandQueue:(id<MTLCommandQueue>)commandQueue;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MetalDeviceCacheItem
|
||||
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device
|
||||
pixelFormat:(MTLPixelFormat)pixFormat;
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self != nil)
|
||||
{
|
||||
_gpuDevice = [device retain];
|
||||
|
||||
_commandQueueCache = [[NSMutableArray alloc] initWithCapacity:kMaxCommandQueues];
|
||||
for (NSUInteger i = 0; (_commandQueueCache != nil) && (i < kMaxCommandQueues); i++)
|
||||
{
|
||||
NSMutableDictionary* commandDict = [NSMutableDictionary dictionary];
|
||||
[commandDict setObject:[NSNumber numberWithBool:NO]
|
||||
forKey:kKey_InUse];
|
||||
|
||||
id<MTLCommandQueue> commandQueue = [_gpuDevice newCommandQueue];
|
||||
[commandDict setObject:commandQueue
|
||||
forKey:kKey_CommandQueue];
|
||||
|
||||
[_commandQueueCache addObject:commandDict];
|
||||
}
|
||||
|
||||
// Load all the shader files with a .metal file extension in the project
|
||||
id<MTLLibrary> defaultLibrary = [[_gpuDevice newDefaultLibrary] autorelease];
|
||||
|
||||
// Load the vertex function from the library
|
||||
id<MTLFunction> vertexFunction = [[defaultLibrary newFunctionWithName:@"vertexShader"] autorelease];
|
||||
|
||||
// Load the fragment function from the library
|
||||
id<MTLFunction> fragmentFunction = [[defaultLibrary newFunctionWithName:@"fragmentShader"] autorelease];
|
||||
|
||||
// Configure a pipeline descriptor that is used to create a pipeline state
|
||||
MTLRenderPipelineDescriptor *pipelineStateDescriptor = [[[MTLRenderPipelineDescriptor alloc] init] autorelease];
|
||||
pipelineStateDescriptor.label = @"Simple Pipeline";
|
||||
pipelineStateDescriptor.vertexFunction = vertexFunction;
|
||||
pipelineStateDescriptor.fragmentFunction = fragmentFunction;
|
||||
pipelineStateDescriptor.colorAttachments[0].pixelFormat = pixFormat;
|
||||
_pixelFormat = pixFormat;
|
||||
|
||||
NSError* error = nil;
|
||||
_pipelineState = [_gpuDevice newRenderPipelineStateWithDescriptor:pipelineStateDescriptor
|
||||
error:&error];
|
||||
if (error != nil)
|
||||
{
|
||||
NSLog (@"Error generating brightness pipeline state: %@", error);
|
||||
}
|
||||
|
||||
if (_commandQueueCache != nil)
|
||||
{
|
||||
_commandQueueCacheLock = [[NSLock alloc] init];
|
||||
}
|
||||
|
||||
if ((_gpuDevice == nil) || (_commandQueueCache == nil) || (_commandQueueCacheLock == nil) ||
|
||||
(_pipelineState == nil))
|
||||
{
|
||||
[self release];
|
||||
self = nil;
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_gpuDevice release];
|
||||
[_commandQueueCache release];
|
||||
[_commandQueueCacheLock release];
|
||||
[_pipelineState release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id<MTLCommandQueue>)getNextFreeCommandQueue
|
||||
{
|
||||
id<MTLCommandQueue> result = nil;
|
||||
|
||||
[_commandQueueCacheLock lock];
|
||||
NSUInteger index = 0;
|
||||
while ((result == nil) && (index < kMaxCommandQueues))
|
||||
{
|
||||
NSMutableDictionary* nextCommandQueue = [_commandQueueCache objectAtIndex:index];
|
||||
NSNumber* inUse = [nextCommandQueue objectForKey:kKey_InUse];
|
||||
if (![inUse boolValue])
|
||||
{
|
||||
[nextCommandQueue setObject:[NSNumber numberWithBool:YES]
|
||||
forKey:kKey_InUse];
|
||||
result = [nextCommandQueue objectForKey:kKey_CommandQueue];
|
||||
}
|
||||
index++;
|
||||
}
|
||||
[_commandQueueCacheLock unlock];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)returnCommandQueue:(id<MTLCommandQueue>)commandQueue
|
||||
{
|
||||
[_commandQueueCacheLock lock];
|
||||
|
||||
BOOL found = false;
|
||||
NSUInteger index = 0;
|
||||
while ((!found) && (index < kMaxCommandQueues))
|
||||
{
|
||||
NSMutableDictionary* nextCommandQueuDict = [_commandQueueCache objectAtIndex:index];
|
||||
id<MTLCommandQueue> nextCommandQueue = [nextCommandQueuDict objectForKey:kKey_CommandQueue];
|
||||
if (nextCommandQueue == commandQueue)
|
||||
{
|
||||
found = YES;
|
||||
[nextCommandQueuDict setObject:[NSNumber numberWithBool:NO]
|
||||
forKey:kKey_InUse];
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
[_commandQueueCacheLock unlock];
|
||||
}
|
||||
|
||||
- (BOOL)containsCommandQueue:(id<MTLCommandQueue>)commandQueue
|
||||
{
|
||||
BOOL found = NO;
|
||||
NSUInteger index = 0;
|
||||
while ((!found) && (index < kMaxCommandQueues))
|
||||
{
|
||||
NSMutableDictionary* nextCommandQueuDict = [_commandQueueCache objectAtIndex:index];
|
||||
id<MTLCommandQueue> nextCommandQueue = [nextCommandQueuDict objectForKey:kKey_CommandQueue];
|
||||
if (nextCommandQueue == commandQueue)
|
||||
{
|
||||
found = YES;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MetalDeviceCache
|
||||
|
||||
+ (MTLPixelFormat)MTLPixelFormatForImageTile:(FxImageTile*)imageTile
|
||||
{
|
||||
MTLPixelFormat result = MTLPixelFormatRGBA16Float;
|
||||
|
||||
switch (imageTile.ioSurface.pixelFormat)
|
||||
{
|
||||
case kCVPixelFormatType_128RGBAFloat:
|
||||
result = MTLPixelFormatRGBA32Float;
|
||||
break;
|
||||
|
||||
case kCVPixelFormatType_32BGRA:
|
||||
result = MTLPixelFormatBGRA8Unorm;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (MetalDeviceCache*)deviceCache;
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
gDeviceCache = [[MetalDeviceCache alloc] init];
|
||||
});
|
||||
|
||||
return gDeviceCache;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self != nil)
|
||||
{
|
||||
NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices();
|
||||
|
||||
deviceCaches = [[NSMutableArray alloc] initWithCapacity:devices.count];
|
||||
|
||||
for (id<MTLDevice> nextDevice in devices)
|
||||
{
|
||||
MetalDeviceCacheItem* newCacheItem = [[[MetalDeviceCacheItem alloc] initWithDevice:nextDevice
|
||||
pixelFormat:MTLPixelFormatRGBA16Float]
|
||||
autorelease];
|
||||
[deviceCaches addObject:newCacheItem];
|
||||
}
|
||||
|
||||
[devices release];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[deviceCaches release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id<MTLDevice>)deviceWithRegistryID:(uint64_t)registryID
|
||||
{
|
||||
for (MetalDeviceCacheItem* nextCacheItem in deviceCaches)
|
||||
{
|
||||
if (nextCacheItem.gpuDevice.registryID == registryID)
|
||||
{
|
||||
return nextCacheItem.gpuDevice;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id<MTLRenderPipelineState>)pipelineStateWithRegistryID:(uint64_t)registryID
|
||||
pixelFormat:(MTLPixelFormat)pixFormat
|
||||
{
|
||||
for (MetalDeviceCacheItem* nextCacheItem in deviceCaches)
|
||||
{
|
||||
if ((nextCacheItem.gpuDevice.registryID == registryID) &&
|
||||
(nextCacheItem.pixelFormat == pixFormat))
|
||||
{
|
||||
return nextCacheItem.pipelineState;
|
||||
}
|
||||
}
|
||||
// Didn't find one, so create one with the right settings
|
||||
NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices();
|
||||
id<MTLDevice> device = nil;
|
||||
for (id<MTLDevice> nextDevice in devices)
|
||||
{
|
||||
if (nextDevice.registryID == registryID)
|
||||
{
|
||||
device = nextDevice;
|
||||
}
|
||||
}
|
||||
|
||||
id<MTLRenderPipelineState> result = nil;
|
||||
if (device != nil)
|
||||
{
|
||||
MetalDeviceCacheItem* newCacheItem = [[[MetalDeviceCacheItem alloc] initWithDevice:device
|
||||
pixelFormat:pixFormat]
|
||||
autorelease];
|
||||
if (newCacheItem != nil)
|
||||
{
|
||||
[deviceCaches addObject:newCacheItem];
|
||||
result = newCacheItem.pipelineState;
|
||||
}
|
||||
}
|
||||
[devices release];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (id<MTLCommandQueue>)commandQueueWithRegistryID:(uint64_t)registryID
|
||||
pixelFormat:(MTLPixelFormat)pixFormat;
|
||||
{
|
||||
for (MetalDeviceCacheItem* nextCacheItem in deviceCaches)
|
||||
{
|
||||
if ((nextCacheItem.gpuDevice.registryID == registryID) &&
|
||||
(nextCacheItem.pixelFormat == pixFormat))
|
||||
{
|
||||
return [nextCacheItem getNextFreeCommandQueue];
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't find one, so create one with the right settings
|
||||
NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices();
|
||||
id<MTLDevice> device = nil;
|
||||
for (id<MTLDevice> nextDevice in devices)
|
||||
{
|
||||
if (nextDevice.registryID == registryID)
|
||||
{
|
||||
device = nextDevice;
|
||||
}
|
||||
}
|
||||
|
||||
id<MTLCommandQueue> result = nil;
|
||||
if (device != nil)
|
||||
{
|
||||
MetalDeviceCacheItem* newCacheItem = [[[MetalDeviceCacheItem alloc] initWithDevice:device
|
||||
pixelFormat:pixFormat]
|
||||
autorelease];
|
||||
if (newCacheItem != nil)
|
||||
{
|
||||
[deviceCaches addObject:newCacheItem];
|
||||
result = [newCacheItem getNextFreeCommandQueue];
|
||||
}
|
||||
}
|
||||
[devices release];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)returnCommandQueueToCache:(id<MTLCommandQueue>)commandQueue;
|
||||
{
|
||||
for (MetalDeviceCacheItem* nextCacheItem in deviceCaches)
|
||||
{
|
||||
if ([nextCacheItem containsCommandQueue:commandQueue])
|
||||
{
|
||||
[nextCacheItem returnCommandQueue:commandQueue];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
二进制文件未显示。
二进制文件未显示。
@@ -0,0 +1,121 @@
|
||||
[
|
||||
{
|
||||
"file": "apple_log_to_rec709.dylut",
|
||||
"dimension": 65,
|
||||
"source": "apple_log_to_rec709.cube",
|
||||
"sourceSHA256": "a2080a4e4be9505bf95ebda07e5a911beed03dff359a235bab30457213be21e0",
|
||||
"sha256": "d98f0a02cbe440bcbaff3d5b0c524a4720d3e0915553953ff00d331d25b8413d"
|
||||
},
|
||||
{
|
||||
"file": "arri_logc3_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "arri_logc3_to_rec709.cube",
|
||||
"sourceSHA256": "241aff344709aa90b468f8658144888db38f29f9aa1b3c0d917cf327ca3b354e",
|
||||
"sha256": "e5b3c99c692e5ca903b5f2df8fa4a54faad5640f36d00a3fd9f9ad09a337bac8"
|
||||
},
|
||||
{
|
||||
"file": "arri_logc4_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "arri_logc4_to_rec709.cube",
|
||||
"sourceSHA256": "ab9618bc72dc3fab3e1d23a0c25ffd9cfb0491ed715448a629e44939cbd3f4b4",
|
||||
"sha256": "2bae85e04d87dd79cc24b69a6e4897fa04dee16c62f1da413dd63ca9ecb36866"
|
||||
},
|
||||
{
|
||||
"file": "blackmagic_film_gen5_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "blackmagic_film_gen5_to_rec709.cube",
|
||||
"sourceSHA256": "c1424b30899da95708ef346e1e386496b28fe742b6d29f704f43dfea8f616c5f",
|
||||
"sha256": "b5ccc9537f3de78ea48414a03ac2e64492510ac35ecc678ef5689902129805cc"
|
||||
},
|
||||
{
|
||||
"file": "canon_clog2_cinema_gamut_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "canon_clog2_cinema_gamut_to_rec709.cube",
|
||||
"sourceSHA256": "522fd5d8f3c853954224b7742c609c920b6bd3f9cdae6fbdf26ac9c643278c48",
|
||||
"sha256": "fe4ec3e6a83e25530fba5cf14ea1d4c8c01df3f3b8507418697b33ad5dc125e9"
|
||||
},
|
||||
{
|
||||
"file": "canon_clog3_cinema_gamut_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "canon_clog3_cinema_gamut_to_rec709.cube",
|
||||
"sourceSHA256": "7ec33910d4aa1910021d8276b467a3ef0ff4a52a75e648deb93e5f908c1f21e4",
|
||||
"sha256": "68326395ab1358fe1c568a3bf5fcb950e7e5fd07a468e812fdc6f770a20f6d0b"
|
||||
},
|
||||
{
|
||||
"file": "canon_clog_bt709_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "canon_clog_bt709_to_rec709.cube",
|
||||
"sourceSHA256": "7c9c4162a3f00b60ba8f6a95aa24502b7c04471306dc7ae7b5996f542dcf4060",
|
||||
"sha256": "7c6a6a2fd2f78c0013ebf01205e615238f16bef07e0b8b72bcfd9e970fa43e22"
|
||||
},
|
||||
{
|
||||
"file": "dji_dlog_m_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "dji_dlog_m_to_rec709.cube",
|
||||
"sourceSHA256": "ac3e114ba6467d27f97295bf91532428bddc05fb61922635d9271d57ecbc9d48",
|
||||
"sha256": "cb37af7934b5658e814ad36e4a042cbe82d4da3b96150f2aa7969e71a8291f0e"
|
||||
},
|
||||
{
|
||||
"file": "dji_dlog_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "dji_dlog_to_rec709.cube",
|
||||
"sourceSHA256": "ca8bc7d3bf382512ed9501137c8b88d1829ae9b22a84965d7d2e1339f615de72",
|
||||
"sha256": "997b3e6d106eaee13702bd218271a0c2e467000273fb4522ff66676ce05bb6f5"
|
||||
},
|
||||
{
|
||||
"file": "fujifilm_flog2_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "fujifilm_flog2_to_rec709.cube",
|
||||
"sourceSHA256": "6c0e327c2ba055e6ca539717c85b509aca91a14a6aa86b092474ed567d3873cf",
|
||||
"sha256": "08afea18a6bb2e746f845f96d5389db016bde0d46ee6e0ff75af1bee0c7c8523"
|
||||
},
|
||||
{
|
||||
"file": "fujifilm_flog_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "fujifilm_flog_to_rec709.cube",
|
||||
"sourceSHA256": "6c0e327c2ba055e6ca539717c85b509aca91a14a6aa86b092474ed567d3873cf",
|
||||
"sha256": "08afea18a6bb2e746f845f96d5389db016bde0d46ee6e0ff75af1bee0c7c8523"
|
||||
},
|
||||
{
|
||||
"file": "nikon_nlog_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "nikon_nlog_to_rec709.cube",
|
||||
"sourceSHA256": "e898acc5c7d00b145ff64d28ada99fec3aa9c3e321fc9cbfcc1dfdc83de356d5",
|
||||
"sha256": "d5a102958b48da213520029d2dab9831af47d6a64b9cc84966b55baf372ac614"
|
||||
},
|
||||
{
|
||||
"file": "panasonic_vlog_vgamut_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "panasonic_vlog_vgamut_to_rec709.cube",
|
||||
"sourceSHA256": "f99223675b29933952da2153bdb3137dd749d12964d0753db85e47576ca4578d",
|
||||
"sha256": "bf65022ae5021189afb14cede57a98a5fcf6469574e97ffce1a3cf5b2c08b428"
|
||||
},
|
||||
{
|
||||
"file": "red_log3g10_rwg_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "red_log3g10_rwg_to_rec709.cube",
|
||||
"sourceSHA256": "15014c07170c770d626fb49424a3995a1f23b64cc9ec00dc01de4e317fa1057c",
|
||||
"sha256": "2ef8f2b1b70ceedcff66e00b5dfb49184846c9b0c667f347714fa3e68f4251b5"
|
||||
},
|
||||
{
|
||||
"file": "sony_hlg_bt2020_to_rec709.dylut",
|
||||
"dimension": 33,
|
||||
"source": "sony_hlg_bt2020_to_rec709.cube",
|
||||
"sourceSHA256": "f4f75e99e2a81a9288166486920ad27a5894f97661976f00f81ebe4e1a425964",
|
||||
"sha256": "49b9526785f94d288fd9538358379d509720f3ea3b5685430a125117aa6aeee3"
|
||||
},
|
||||
{
|
||||
"file": "sony_slog2_sgamut_to_rec709.dylut",
|
||||
"dimension": 65,
|
||||
"source": "sony_slog2_sgamut_to_rec709.cube",
|
||||
"sourceSHA256": "315b6a01d16b44f0449cb5450c1ccda8fcd54f7efaa5470bcd92f2844d60ae9f",
|
||||
"sha256": "62230c479abd04d53c104a9016d53255441f58f7ff6a6f1b6139529bf6d08ad8"
|
||||
},
|
||||
{
|
||||
"file": "sony_slog3_sgamut3cine_to_rec709.dylut",
|
||||
"dimension": 65,
|
||||
"source": "sony_slog3_sgamut3cine_to_rec709.cube",
|
||||
"sourceSHA256": "286d5eaa3e4f5f46ccc9119c2594c59c7b0502cb140941dd6c01aeb08474ec94",
|
||||
"sha256": "4e60f55f717635293249e0c6f17be5f0864bf42aadebf3addcd6dd56fe9af265"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,27 @@
|
||||
Dayu Color uses Camera Raw lookup-table data and composition behavior adapted from Compositor.
|
||||
https://github.com/robbietilton/Compositor
|
||||
Upstream commit: 92f5225afe7e921dbfa4c563462980e45db345fc
|
||||
DayuColorTables.bin is byte-identical to upstream CameraRawTables.bin.
|
||||
SHA-256: e67ff4dbcce35cb7765752acff4405be5c934d913ef1396b2ca3fc6dc8a85190
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Wonder Assembly LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// TileableRemoteBrightness.metal
|
||||
// 大鱼调色
|
||||
//
|
||||
// Created by mac on 2026/10/31.
|
||||
//
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
#include "TileableRemoteBrightnessShaderTypes.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// The [[position]] attribute of this member indicates that this value is the clip space
|
||||
// position of the vertex when this structure is returned from the vertex function
|
||||
float4 clipSpacePosition [[position]];
|
||||
|
||||
// Since this member does not have a special attribute, the rasterizer interpolates
|
||||
// its value with the values of the other triangle vertices and then passes
|
||||
// the interpolated value to the fragment shader for each fragment in the triangle
|
||||
float2 textureCoordinate;
|
||||
|
||||
} RasterizerData;
|
||||
|
||||
vertex RasterizerData
|
||||
vertexShader(uint vertexID [[vertex_id]],
|
||||
constant Vertex2D *vertexArray [[buffer(BVI_Vertices)]],
|
||||
constant vector_uint2 *viewportSizePointer [[buffer(BVI_ViewportSize)]])
|
||||
{
|
||||
RasterizerData out;
|
||||
|
||||
// Index into our array of positions to get the current vertex
|
||||
// Our positions are specified in pixel dimensions (i.e. a value of 100 is 100 pixels from
|
||||
// the origin)
|
||||
float2 pixelSpacePosition = vertexArray[vertexID].position.xy;
|
||||
|
||||
// Get the size of the drawable so that we can convert to normalized device coordinates,
|
||||
float2 viewportSize = float2(*viewportSizePointer);
|
||||
|
||||
// The output position of every vertex shader is in clip space (also known as normalized device
|
||||
// coordinate space, or NDC). A value of (-1.0, -1.0) in clip-space represents the
|
||||
// lower-left corner of the viewport whereas (1.0, 1.0) represents the upper-right corner of
|
||||
// the viewport.
|
||||
|
||||
// In order to convert from positions in pixel space to positions in clip space we divide the
|
||||
// pixel coordinates by half the size of the viewport.
|
||||
out.clipSpacePosition.xy = pixelSpacePosition / (viewportSize / 2.0);
|
||||
|
||||
// Set the z component of our clip space position 0 (since we're only rendering in
|
||||
// 2-Dimensions for this sample)
|
||||
out.clipSpacePosition.z = 0.0;
|
||||
|
||||
// Set the w component to 1.0 since we don't need a perspective divide, which is also not
|
||||
// necessary when rendering in 2-Dimensions
|
||||
out.clipSpacePosition.w = 1.0;
|
||||
|
||||
// Pass our input textureCoordinate straight to our output RasterizerData. This value will be
|
||||
// interpolated with the other textureCoordinate values in the vertices that make up the
|
||||
// triangle.
|
||||
out.textureCoordinate = vertexArray[vertexID].textureCoordinate;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// Fragment function
|
||||
fragment float4 fragmentShader(RasterizerData in [[stage_in]],
|
||||
texture2d<half> colorTexture [[ texture(BTI_InputImage) ]],
|
||||
constant float* brightness [[ buffer(BFI_Brightness) ]])
|
||||
{
|
||||
constexpr sampler textureSampler (mag_filter::linear,
|
||||
min_filter::linear);
|
||||
|
||||
// Sample the texture to obtain a color
|
||||
half4 colorSample = colorTexture.sample(textureSampler, in.textureCoordinate);
|
||||
const half hBrightness = static_cast<half>(*brightness);
|
||||
colorSample.rgb = colorSample.rgb * hBrightness;
|
||||
|
||||
// We return the color of the texture
|
||||
return float4(colorSample);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// TileableRemoteBrightnessShaderTypes.h
|
||||
// 大鱼调色
|
||||
//
|
||||
// Created by mac on 2026/10/31.
|
||||
//
|
||||
|
||||
#ifndef TileableRemoteBrightnessShaderTypes_h
|
||||
#define TileableRemoteBrightnessShaderTypes_h
|
||||
|
||||
#import <simd/simd.h>
|
||||
|
||||
typedef enum BrightnessVertexInputIndex {
|
||||
BVI_Vertices = 0,
|
||||
BVI_ViewportSize = 1
|
||||
} BrightnessVertexInputIndex;
|
||||
|
||||
typedef enum BrightnessTextureIndex {
|
||||
BTI_InputImage = 0
|
||||
} BrightnessTextureIndex;
|
||||
|
||||
typedef enum BrightnessFragmentIndex {
|
||||
BFI_Brightness = 0
|
||||
} BrightnessFragmentIndex;
|
||||
|
||||
typedef struct Vertex2D {
|
||||
vector_float2 position;
|
||||
vector_float2 textureCoordinate;
|
||||
} Vertex2D;
|
||||
|
||||
|
||||
#endif /* TileableRemoteBrightnessShaderTypes_h */
|
||||
@@ -1,8 +0,0 @@
|
||||
//___FILEHEADER___
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <FxPlug/FxPlugSDK.h>
|
||||
|
||||
@interface ___PACKAGENAMEASIDENTIFIER___PlugIn : NSObject <FxTileableEffect>
|
||||
@property (assign) id<PROAPIAccessing> apiManager;
|
||||
@end
|
||||
@@ -1,315 +0,0 @@
|
||||
//___FILEHEADER___
|
||||
|
||||
#import "___PACKAGENAMEASIDENTIFIER___PlugIn.h"
|
||||
#import <IOSurface/IOSurfaceObjC.h>
|
||||
#import "TileableRemoteBrightnessShaderTypes.h"
|
||||
#import "MetalDeviceCache.h"
|
||||
|
||||
@implementation ___PACKAGENAMEASIDENTIFIER___PlugIn
|
||||
|
||||
//---------------------------------------------------------
|
||||
// initWithAPIManager:
|
||||
//
|
||||
// This method is called when a plug-in is first loaded, and
|
||||
// is a good point to conduct any checks for anti-piracy or
|
||||
// system compatibility. Returning NULL means that a plug-in
|
||||
// chooses not to be accessible for some reason.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (nullable instancetype)initWithAPIManager:(id<PROAPIAccessing>)newApiManager;
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_apiManager = newApiManager;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// properties
|
||||
//
|
||||
// This method should return an NSDictionary defining the
|
||||
// properties of the effect.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)properties:(NSDictionary * _Nonnull *)properties
|
||||
error:(NSError * _Nullable *)error
|
||||
{
|
||||
*properties = @{
|
||||
kFxPropertyKey_MayRemapTime : [NSNumber numberWithBool:NO],
|
||||
kFxPropertyKey_PixelTransformSupport : [NSNumber numberWithInt:kFxPixelTransform_ScaleTranslate],
|
||||
kFxPropertyKey_VariesWhenParamsAreStatic : [NSNumber numberWithBool:NO]
|
||||
};
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// addParametersWithError
|
||||
//
|
||||
// This method is where a plug-in defines its list of parameters.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)addParametersWithError:(NSError**)error
|
||||
{
|
||||
id<FxParameterCreationAPI_v5> paramAPI = [_apiManager apiForProtocol:@protocol(FxParameterCreationAPI_v5)];
|
||||
if (paramAPI == nil)
|
||||
{
|
||||
NSDictionary* userInfo = @{
|
||||
NSLocalizedDescriptionKey : @"Unable to obtain an FxPlug API Object"
|
||||
};
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:FxPlugErrorDomain
|
||||
code:kFxError_APIUnavailable
|
||||
userInfo:userInfo];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![paramAPI addFloatSliderWithName:@"Brightness"
|
||||
parameterID:1
|
||||
defaultValue:1.0
|
||||
parameterMin:0.0
|
||||
parameterMax:100.0
|
||||
sliderMin:0.0
|
||||
sliderMax:10.0
|
||||
delta:0.1
|
||||
parameterFlags:kFxParameterFlag_DEFAULT])
|
||||
{
|
||||
NSDictionary* userInfo = @{
|
||||
NSLocalizedDescriptionKey : @"Unable to add brightness slider"
|
||||
};
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:FxPlugErrorDomain
|
||||
code:kFxError_InvalidParameter
|
||||
userInfo:userInfo];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// pluginState:atTime:quality:error
|
||||
//
|
||||
// Your plug-in should get its parameter values, do any calculations it needs to
|
||||
// from those values, and package up the result to be used later with rendering.
|
||||
// The host application will call this method before rendering. The
|
||||
// FxParameterRetrievalAPI* is valid during this call. Use it to get the values of
|
||||
// your plug-in's parameters, then put those values or the results of any calculations
|
||||
// you need to do with those parameters to render into an NSData that you return
|
||||
// to the host application. The host will pass it back to you during subsequent calls.
|
||||
// Do not re-use the NSData; always create a new one as this method may be called
|
||||
// on multiple threads at the same time.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)pluginState:(NSData**)pluginState
|
||||
atTime:(CMTime)renderTime
|
||||
quality:(FxQuality)qualityLevel
|
||||
error:(NSError**)error
|
||||
{
|
||||
BOOL succeeded = NO;
|
||||
id<FxParameterRetrievalAPI_v6> paramGetAPI = [_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
|
||||
if (paramGetAPI != nil)
|
||||
{
|
||||
double brightness = 1.0;
|
||||
[paramGetAPI getFloatValue:&brightness
|
||||
fromParameter:1
|
||||
atTime:renderTime];
|
||||
|
||||
*pluginState = [NSData dataWithBytes:&brightness
|
||||
length:sizeof(brightness)];
|
||||
|
||||
if (*pluginState != nil)
|
||||
{
|
||||
succeeded = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:FxPlugErrorDomain
|
||||
code:kFxError_ThirdPartyDeveloperStart + 20
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey :
|
||||
@"Unable to retrieve FxParameterRetrievalAPI_v6 in \
|
||||
[-pluginStateAtTime:]" }];
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// destinationImageRect:sourceImages:destinationImage:pluginState:atTime:error
|
||||
//
|
||||
// This method will calculate the rectangular bounds of the output
|
||||
// image given the various inputs and plug-in state
|
||||
// at the given render time.
|
||||
// It will pass in an array of images, the plug-in state
|
||||
// returned from your plug-in's -pluginStateAtTime:error: method,
|
||||
// and the render time.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)destinationImageRect:(FxRect *)destinationImageRect
|
||||
sourceImages:(NSArray<FxImageTile *> *)sourceImages
|
||||
destinationImage:(nonnull FxImageTile *)destinationImage
|
||||
pluginState:(NSData *)pluginState
|
||||
atTime:(CMTime)renderTime
|
||||
error:(NSError * _Nullable *)outError
|
||||
{
|
||||
if (sourceImages.count < 1)
|
||||
{
|
||||
NSLog (@"No inputImages list");
|
||||
return NO;
|
||||
}
|
||||
|
||||
// In the case of a filter that only changed RGB values,
|
||||
// the output rect is the same as the input rect.
|
||||
*destinationImageRect = sourceImages [ 0 ].imagePixelBounds;
|
||||
|
||||
return YES;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// sourceTileRect:sourceImageIndex:sourceImages:destinationTileRect:destinationImage:pluginState:atTime:error
|
||||
//
|
||||
// Calculate tile of the source image we need
|
||||
// to render the given output tile.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)sourceTileRect:(FxRect *)sourceTileRect
|
||||
sourceImageIndex:(NSUInteger)sourceImageIndex
|
||||
sourceImages:(NSArray<FxImageTile *> *)sourceImages
|
||||
destinationTileRect:(FxRect)destinationTileRect
|
||||
destinationImage:(FxImageTile *)destinationImage
|
||||
pluginState:(NSData *)pluginState
|
||||
atTime:(CMTime)renderTime
|
||||
error:(NSError * _Nullable *)outError
|
||||
{
|
||||
// Since this is a color-only filter, the input tile will be the same size as the output tile
|
||||
*sourceTileRect = destinationTileRect;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// renderDestinationImage:sourceImages:pluginState:atTime:error:
|
||||
//
|
||||
// The host will call this method when it wants your plug-in to render an image
|
||||
// tile of the output image. It will pass in each of the input tiles needed as well
|
||||
// as the plug-in state needed for the calculations. Your plug-in should do all its
|
||||
// rendering in this method. It should not attempt to use the FxParameterRetrievalAPI*
|
||||
// object as it is invalid at this time. Note that this method will be called on
|
||||
// multiple threads at the same time.
|
||||
//---------------------------------------------------------
|
||||
|
||||
- (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
|
||||
sourceImages:(NSArray<FxImageTile *> *)sourceImages
|
||||
pluginState:(NSData *)pluginState
|
||||
atTime:(CMTime)renderTime
|
||||
error:(NSError * _Nullable *)outError
|
||||
{
|
||||
if ((pluginState == nil) || (sourceImages [ 0 ].ioSurface == nil) || (destinationImage.ioSurface == nil))
|
||||
{
|
||||
NSDictionary* userInfo = @{
|
||||
NSLocalizedDescriptionKey : @"Invalid plugin state received from host"
|
||||
};
|
||||
if (outError != NULL)
|
||||
*outError = [NSError errorWithDomain:FxPlugErrorDomain
|
||||
code:kFxError_InvalidParameter
|
||||
userInfo:userInfo];
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This is where you would access parameter values and other info about the source tile
|
||||
// from the pluginState.
|
||||
double brightness = 0.0;
|
||||
[pluginState getBytes:&brightness
|
||||
length:sizeof(brightness)];
|
||||
|
||||
// Set up the renderer, in this case we are using Metal.
|
||||
|
||||
MetalDeviceCache* deviceCache = [MetalDeviceCache deviceCache];
|
||||
MTLPixelFormat pixelFormat = [MetalDeviceCache MTLPixelFormatForImageTile:destinationImage];
|
||||
id<MTLCommandQueue> commandQueue = [deviceCache commandQueueWithRegistryID:sourceImages[0].deviceRegistryID
|
||||
pixelFormat:pixelFormat];
|
||||
if (commandQueue == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
|
||||
commandBuffer.label = @"DynamicRegXPC Command Buffer";
|
||||
[commandBuffer enqueue];
|
||||
|
||||
id<MTLTexture> inputTexture = [sourceImages[0] metalTextureForDevice:[deviceCache deviceWithRegistryID:sourceImages[0].deviceRegistryID]];
|
||||
id<MTLTexture> outputTexture = [destinationImage metalTextureForDevice:[deviceCache deviceWithRegistryID:destinationImage.deviceRegistryID]];
|
||||
|
||||
MTLRenderPassColorAttachmentDescriptor* colorAttachmentDescriptor = [[MTLRenderPassColorAttachmentDescriptor alloc] init];
|
||||
colorAttachmentDescriptor.texture = outputTexture;
|
||||
colorAttachmentDescriptor.clearColor = MTLClearColorMake(1.0, 0.5, 0.0, 1.0);
|
||||
colorAttachmentDescriptor.loadAction = MTLLoadActionClear;
|
||||
MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor];
|
||||
renderPassDescriptor.colorAttachments [ 0 ] = colorAttachmentDescriptor;
|
||||
id<MTLRenderCommandEncoder> commandEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||
|
||||
// Rendering
|
||||
float outputWidth = (float)(destinationImage.tilePixelBounds.right - destinationImage.tilePixelBounds.left);
|
||||
float outputHeight = (float)(destinationImage.tilePixelBounds.top - destinationImage.tilePixelBounds.bottom);
|
||||
Vertex2D vertices[] = {
|
||||
{ { outputWidth / 2.0, -outputHeight / 2.0 }, { 1.0, 1.0 } },
|
||||
{ { -outputWidth / 2.0, -outputHeight / 2.0 }, { 0.0, 1.0 } },
|
||||
{ { outputWidth / 2.0, outputHeight / 2.0 }, { 1.0, 0.0 } },
|
||||
{ { -outputWidth / 2.0, outputHeight / 2.0 }, { 0.0, 0.0 } }
|
||||
};
|
||||
|
||||
MTLViewport viewport = {
|
||||
0, 0, outputWidth, outputHeight, -1.0, 1.0
|
||||
};
|
||||
[commandEncoder setViewport:viewport];
|
||||
|
||||
id<MTLRenderPipelineState> pipelineState = [deviceCache pipelineStateWithRegistryID:sourceImages[0].deviceRegistryID
|
||||
pixelFormat:pixelFormat];
|
||||
[commandEncoder setRenderPipelineState:pipelineState];
|
||||
|
||||
[commandEncoder setVertexBytes:vertices
|
||||
length:sizeof(vertices)
|
||||
atIndex:BVI_Vertices];
|
||||
|
||||
simd_uint2 viewportSize = {
|
||||
(unsigned int)(outputWidth),
|
||||
(unsigned int)(outputHeight)
|
||||
};
|
||||
[commandEncoder setVertexBytes:&viewportSize
|
||||
length:sizeof(viewportSize)
|
||||
atIndex:BVI_ViewportSize];
|
||||
|
||||
[commandEncoder setFragmentTexture:inputTexture
|
||||
atIndex:BTI_InputImage];
|
||||
|
||||
float fragmentBrightness = (float)brightness;
|
||||
[commandEncoder setFragmentBytes:&fragmentBrightness
|
||||
length:sizeof(fragmentBrightness)
|
||||
atIndex:BFI_Brightness];
|
||||
|
||||
[commandEncoder drawPrimitives:MTLPrimitiveTypeTriangleStrip
|
||||
vertexStart:0
|
||||
vertexCount:4];
|
||||
|
||||
[commandEncoder endEncoding];
|
||||
[commandBuffer commit];
|
||||
|
||||
[commandBuffer waitUntilCompleted];
|
||||
|
||||
[colorAttachmentDescriptor release];
|
||||
|
||||
[deviceCache returnCommandQueueToCache:commandQueue];
|
||||
|
||||
return YES;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -17,13 +17,13 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<string>大鱼调色</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.video</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户