1 // Autogenerated file. Do not edit by hand
3 using UnityEngine
.Rendering
;
5 namespace UnityEngine
.Experimental
.Rendering
9 ComputeShader m_Shader
;
10 int k_SampleKernel_xyzw2x_8
;
11 int k_SampleKernel_xyzw2x_1
;
13 public GPUCopy(ComputeShader shader
)
16 k_SampleKernel_xyzw2x_8
= m_Shader
.FindKernel("KSampleCopy4_1_x_8");
17 k_SampleKernel_xyzw2x_1
= m_Shader
.FindKernel("KSampleCopy4_1_x_1");
20 static readonly int _RectOffset
= Shader
.PropertyToID("_RectOffset");
21 static readonly int _Result1
= Shader
.PropertyToID("_Result1");
22 static readonly int _Source4
= Shader
.PropertyToID("_Source4");
23 void SampleCopyChannel(
27 RenderTargetIdentifier source
,
29 RenderTargetIdentifier target
,
33 RectInt main
, topRow
, rightCol
, topRight
;
36 RectInt
* dispatch1Rects
= stackalloc RectInt
[3];
37 int dispatch1RectCount
= 0;
38 RectInt dispatch8Rect
= RectInt
.zero
;
40 if (TileLayoutUtils
.TryLayoutByTiles(
48 if (topRow
.width
> 0 && topRow
.height
> 0)
50 dispatch1Rects
[dispatch1RectCount
] = topRow
;
53 if (rightCol
.width
> 0 && rightCol
.height
> 0)
55 dispatch1Rects
[dispatch1RectCount
] = rightCol
;
58 if (topRight
.width
> 0 && topRight
.height
> 0)
60 dispatch1Rects
[dispatch1RectCount
] = topRight
;
65 else if (rect
.width
> 0 && rect
.height
> 0)
67 dispatch1Rects
[dispatch1RectCount
] = rect
;
71 cmd
.SetComputeTextureParam(m_Shader
, kernel8
, _source
, source
);
72 cmd
.SetComputeTextureParam(m_Shader
, kernel1
, _source
, source
);
73 cmd
.SetComputeTextureParam(m_Shader
, kernel8
, _target
, target
);
74 cmd
.SetComputeTextureParam(m_Shader
, kernel1
, _target
, target
);
76 if (dispatch8Rect
.width
> 0 && dispatch8Rect
.height
> 0)
78 var r
= dispatch8Rect
;
79 // Caution: passing parameters to SetComputeIntParams() via params generate 48B several times at each frame here !
80 cmd
.SetComputeIntParams(m_Shader
, _RectOffset
, (int)r
.x
, (int)r
.y
);
81 cmd
.DispatchCompute(m_Shader
, kernel8
, (int)Mathf
.Max(r
.width
/ 8, 1), (int)Mathf
.Max(r
.height
/ 8, 1), 1);
84 for (int i
= 0, c
= dispatch1RectCount
; i
< c
; ++i
)
86 var r
= dispatch1Rects
[i
];
87 // Caution: passing parameters to SetComputeIntParams() via params generate 48B several times at each frame here !
88 cmd
.SetComputeIntParams(m_Shader
, _RectOffset
, (int)r
.x
, (int)r
.y
);
89 cmd
.DispatchCompute(m_Shader
, kernel1
, (int)Mathf
.Max(r
.width
, 1), (int)Mathf
.Max(r
.height
, 1), 1);
94 public void SampleCopyChannel_xyzw2x(CommandBuffer cmd
, RenderTargetIdentifier source
, RenderTargetIdentifier target
, RectInt rect
)
96 SampleCopyChannel(cmd
, rect
, _Source4
, source
, _Result1
, target
, k_SampleKernel_xyzw2x_8
, k_SampleKernel_xyzw2x_1
);