减少多层调色 GPU 等待与检查器拖动写入

这个提交包含在:
mac 于 2026-11-09 12:05:43 +08:00 提交
1 父节点 79f1dd4545
当前提交 38e9fb25a2
19 个文件已更改
+427 -98

没有与搜索条件相匹配的文件

+35 -7
查看文件
@@ -372,7 +372,13 @@ kernel void dyColorManagement(texture2d<float,access::read> source [[texture(0)]
// Premultiplication is preserved by mixing the two equally-alpha images.
kernel void dyToolBlend(texture2d<float,access::read> before [[texture(0)]],texture2d<float,access::read> after [[texture(1)]],texture2d<half,access::write> output [[texture(2)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],uint2 pos [[thread_position_in_grid]]){
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;float4 a=before.read(pos),b=after.read(pos);float2 uv=(float2(pos)+.5f)/float2(output.get_width(),output.get_height());float amount=dyToolCoverage(uv,dyToolEncode(a.a>0?(h.premultiplied?a.rgb/a.a:a.rgb):float3(0)),masks,h,h.section);output.write(half4(h.skinPreview?float4(b.rgb*amount,a.a):mix(a,b,amount)),pos);
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;
float4 a=before.read(pos),b=after.read(pos);
float2 uv=(float2(pos)+.5f)/float2(output.get_width(),output.get_height());
float3 keyColor=float3(0);
if(h.keySources&&a.a>0)keyColor=dyToolEncode(h.premultiplied?a.rgb/a.a:a.rgb);
float amount=dyToolCoverage(uv,keyColor,masks,h,h.section);
output.write(half4(h.skinPreview?float4(b.rgb*amount,a.a):mix(a,b,amount)),pos);
}
extern "C" float dy_skinWeight(float3 color,float3 reference,constant DYUniforms& uniforms);
extern "C" float3 dy_skinExtra(float3 color,float3 reference,constant DYUniforms& uniforms);
@@ -495,12 +501,34 @@ kernel void dyUnifiedBridgeOut(texture2d<float,access::read> raw [[texture(0)]],
struct DYUnifiedMix {CSTParams toLinear,fromLinear,originalTo709;float amount;};
kernel void dyUnifiedBlend(texture2d<float,access::read> before [[texture(0)]],texture2d<float,access::read> after [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],texture2d<float,access::read> original [[texture(3)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant DYUnifiedMix& p [[buffer(2)]],uint2 xy [[thread_position_in_grid]]){
if(any(xy>=uint2(output.get_width(),output.get_height())))return;float4 a=before.read(xy),b=after.read(xy),o=original.read(xy);if(!(a.a>0)||!(b.a>0)){output.write(a,xy);return;}
float3 ac=cst_float_air(float4(a.rgb/a.a,1),p.toLinear).rgb,bc=cst_float_air(float4(b.rgb/b.a,1),p.toLinear).rgb;
float3 code=dyToolEncode(cst_float_air(float4(ac,1),dyPrimaryAP1To709).rgb),source=o.a>0?dyToolEncode(cst_float_air(float4(o.rgb/o.a,1),p.originalTo709).rgb):float3(0);
float2 uv=(float2(xy)+.5f)/float2(output.get_width(),output.get_height());float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;float coverage=1;bool found=false;
for(uint i=0;i<h.count;i++)if(masks[i].section==h.section){float w=dyToolMask(x,y,masks[i].mask.parameters.sourceStage==DYMaskSourceOriginal?source:code,masks[i].mask);if(!found){coverage=masks[i].combine==1?1-w:w;found=true;}else if(masks[i].combine==1)coverage*=1-w;else if(masks[i].combine==2)coverage*=w;else coverage=1-(1-coverage)*(1-w);}
float w=coverage*p.amount;if(w<=0){output.write(a,xy);return;}if(w>=1){output.write(b,xy);return;}output.write(float4(cst_float_air(float4(mix(ac,bc,w),1),p.fromLinear).rgb*a.a,a.a),xy);
if(any(xy>=uint2(output.get_width(),output.get_height())))return;
float4 a=before.read(xy),b=after.read(xy);
if(!(a.a>0)||!(b.a>0)){output.write(a,xy);return;}
float3 ac=0,code=0,source=0;
if(h.keySources&DYToolMaskLayerKey){
ac=cst_float_air(float4(a.rgb/a.a,1),p.toLinear).rgb;
code=dyToolEncode(cst_float_air(float4(ac,1),dyPrimaryAP1To709).rgb);
}
if(h.keySources&DYToolMaskOriginalKey){
float4 o=original.read(xy);
if(o.a>0)source=dyToolEncode(cst_float_air(float4(o.rgb/o.a,1),p.originalTo709).rgb);
}
float2 uv=(float2(xy)+.5f)/float2(output.get_width(),output.get_height());
float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;
float coverage=1;bool found=false;
for(uint i=0;i<h.count;i++)if(masks[i].section==h.section){
float weight=dyToolMask(x,y,masks[i].mask.parameters.sourceStage==DYMaskSourceOriginal?source:code,masks[i].mask);
if(!found){coverage=masks[i].combine==1?1-weight:weight;found=true;}
else if(masks[i].combine==1)coverage*=1-weight;
else if(masks[i].combine==2)coverage*=weight;
else coverage=1-(1-coverage)*(1-weight);
}
float w=coverage*p.amount;
if(w<=0){output.write(a,xy);return;}
if(w>=1){output.write(b,xy);return;}
if(!(h.keySources&DYToolMaskLayerKey))ac=cst_float_air(float4(a.rgb/a.a,1),p.toLinear).rgb;
float3 bc=cst_float_air(float4(b.rgb/b.a,1),p.toLinear).rgb;
output.write(float4(cst_float_air(float4(mix(ac,bc,w),1),p.fromLinear).rgb*a.a,a.a),xy);
}
kernel void dyUnifiedExposure(texture2d<float,access::read> a [[texture(0)]],texture2d<float,access::write> b [[texture(1)]],constant float& gain [[buffer(0)]],uint2 p [[thread_position_in_grid]]){
if(any(p>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(p);if(c.a>0)c.rgb*=gain;b.write(c,p);