|
|
|
|
|
|
csc.AppendLine(" public GPUCopy(ComputeShader shader)"); |
|
|
|
csc.AppendLine(" {"); |
|
|
|
csc.AppendLine(" m_Shader = shader;"); |
|
|
|
csm.AppendLine(" static readonly int _Size = Shader.PropertyToID(\"_Size\");"); |
|
|
|
for (var i = 0; i < operations.Length; i++) |
|
|
|
{ |
|
|
|
var o = operations[i]; |
|
|
|
|
|
|
// CSharp method
|
|
|
|
csm.AppendLine(string.Format(@" public void SampleCopyChannel_{0}2{1}(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier target, Vector2 size)", channelName, o.subscript)); |
|
|
|
csm.AppendLine(" {"); |
|
|
|
csm.AppendLine(" var s = new Vector4(size.x, size.y, 1f / size.x, 1f / size.y);"); |
|
|
|
csm.AppendLine(" cmd.SetComputeVectorParam(m_Shader, _Size, s);"); |
|
|
|
csm.AppendLine(string.Format(" cmd.SetComputeTextureParam(m_Shader, {0}, _Source{1}, source);", kernelIndexName, o.sourceChannel.ToString())); |
|
|
|
csm.AppendLine(string.Format(" cmd.SetComputeTextureParam(m_Shader, {0}, _Result{1}, target);", kernelIndexName, o.targetChannel.ToString())); |
|
|
|
csm.AppendLine(string.Format(" cmd.DispatchCompute(m_Shader, {0}, (int)Mathf.Max((size.x) / {1}, 1), (int)Mathf.Max((size.y) / {1}, 1), 1);", kernelIndexName, k_KernelSize.ToString())); |
|
|
|
|
|
|
cc.AppendLine(@"// Autogenerated file. Do not edit by hand"); |
|
|
|
cc.AppendLine(); |
|
|
|
cc.AppendLine(@"#include ""../ShaderLibrary/Common.hlsl"""); |
|
|
|
cc.AppendLine(); |
|
|
|
cc.AppendLine(@"SamplerState sampler_LinearClamp;"); |
|
|
|
cc.AppendLine(); |
|
|
|
cc.AppendLine(@"CBUFFER_START(cb)"); |
|
|
|
cc.AppendLine(@" float4 _Size;"); |
|
|
|
cc.AppendLine(@"CBUFFER_END"); |
|
|
|
cc.AppendLine(ccp.ToString()); // Properties
|
|
|
|
cc.AppendLine(cck.ToString()); // Kernels
|
|
|
|
|
|
|
|