post processing
[WindSway-HDRP.git] / Library / PackageCache / com.unity.render-pipelines.high-definition@4.10.0-preview / Runtime / Core / CoreResources / GPUCopy.cs
blob73ac18d5bb983662d0d9f4e16eb9b0f23b517407
1 // Autogenerated file. Do not edit by hand
2 using System;
3 using UnityEngine.Rendering;
5 namespace UnityEngine.Experimental.Rendering
7 public class GPUCopy
9 ComputeShader m_Shader;
10 int k_SampleKernel_xyzw2x_8;
11 int k_SampleKernel_xyzw2x_1;
13 public GPUCopy(ComputeShader shader)
15 m_Shader = 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(
24 CommandBuffer cmd,
25 RectInt rect,
26 int _source,
27 RenderTargetIdentifier source,
28 int _target,
29 RenderTargetIdentifier target,
30 int kernel8,
31 int kernel1)
33 RectInt main, topRow, rightCol, topRight;
34 unsafe
36 RectInt* dispatch1Rects = stackalloc RectInt[3];
37 int dispatch1RectCount = 0;
38 RectInt dispatch8Rect = RectInt.zero;
40 if (TileLayoutUtils.TryLayoutByTiles(
41 rect,
43 out main,
44 out topRow,
45 out rightCol,
46 out topRight))
48 if (topRow.width > 0 && topRow.height > 0)
50 dispatch1Rects[dispatch1RectCount] = topRow;
51 ++dispatch1RectCount;
53 if (rightCol.width > 0 && rightCol.height > 0)
55 dispatch1Rects[dispatch1RectCount] = rightCol;
56 ++dispatch1RectCount;
58 if (topRight.width > 0 && topRight.height > 0)
60 dispatch1Rects[dispatch1RectCount] = topRight;
61 ++dispatch1RectCount;
63 dispatch8Rect = main;
65 else if (rect.width > 0 && rect.height > 0)
67 dispatch1Rects[dispatch1RectCount] = rect;
68 ++dispatch1RectCount;
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);