mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
Handle chroma co-siting in the Metal shaders
This commit is contained in:
@@ -10,6 +10,7 @@ struct CscParams
|
||||
{
|
||||
float3 matrix[3];
|
||||
float3 offsets;
|
||||
float2 chromaOffset;
|
||||
float bitnessScaleFactor;
|
||||
};
|
||||
|
||||
@@ -25,8 +26,10 @@ fragment float4 ps_draw_biplanar(Vertex v [[ stage_in ]],
|
||||
texture2d<float> luminancePlane [[ texture(0) ]],
|
||||
texture2d<float> chrominancePlane [[ texture(1) ]])
|
||||
{
|
||||
float2 chromaOffset = float2(cscParams.chromaOffset.x / chrominancePlane.get_width(),
|
||||
cscParams.chromaOffset.y / chrominancePlane.get_height());
|
||||
float3 yuv = float3(luminancePlane.sample(s, v.texCoords).r,
|
||||
chrominancePlane.sample(s, v.texCoords).rg);
|
||||
chrominancePlane.sample(s, v.texCoords + chromaOffset).rg);
|
||||
yuv *= cscParams.bitnessScaleFactor;
|
||||
yuv -= cscParams.offsets;
|
||||
|
||||
@@ -43,9 +46,13 @@ fragment float4 ps_draw_triplanar(Vertex v [[ stage_in ]],
|
||||
texture2d<float> chrominancePlaneU [[ texture(1) ]],
|
||||
texture2d<float> chrominancePlaneV [[ texture(2) ]])
|
||||
{
|
||||
float2 chromaOffsetU = float2(cscParams.chromaOffset.x / chrominancePlaneU.get_width(),
|
||||
cscParams.chromaOffset.y / chrominancePlaneU.get_height());
|
||||
float2 chromaOffsetV = float2(cscParams.chromaOffset.x / chrominancePlaneV.get_width(),
|
||||
cscParams.chromaOffset.y / chrominancePlaneV.get_height());
|
||||
float3 yuv = float3(luminancePlane.sample(s, v.texCoords).r,
|
||||
chrominancePlaneU.sample(s, v.texCoords).r,
|
||||
chrominancePlaneV.sample(s, v.texCoords).r);
|
||||
chrominancePlaneU.sample(s, v.texCoords + chromaOffsetU).r,
|
||||
chrominancePlaneV.sample(s, v.texCoords + chromaOffsetV).r);
|
||||
yuv *= cscParams.bitnessScaleFactor;
|
||||
yuv -= cscParams.offsets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user