浏览代码

[GPUCopy] Fixed warning when copying with a compute shader fewer pixels than the numthreads

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
5ea37e58
共有 3 个文件被更改,包括 5 次插入9 次删除
  1. 4
      ScriptableRenderPipeline/Core/Resources/GPUCopy.compute
  2. 4
      ScriptableRenderPipeline/Core/Resources/GPUCopy.cs
  3. 6
      ScriptableRenderPipeline/Core/Resources/GPUCopyAsset.cs

4
ScriptableRenderPipeline/Core/Resources/GPUCopy.compute


// Autogenerated file. Do not edit by hand
#include "ShaderLibrary/Common.hlsl"
#include "../ShaderLibrary/Common.hlsl"
SamplerState sampler_LinearClamp;

RWTexture2D<float1> _Result1;
TEXTURE2D(_Source4);
Texture2D<float4> _Source4;
#pragma kernel KSampleCopy4_1_x

4
ScriptableRenderPipeline/Core/Resources/GPUCopy.cs


static readonly int _Size = Shader.PropertyToID("_Size");
public void SampleCopyChannel_xyzw2x(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier target, Vector2 size)
{
if (size.x < 8 || size.y < 8)
Debug.LogWarning("Trying to copy a channel from a texture smaller than 8x* or *x8. ComputeShader cannot perform it.");
cmd.DispatchCompute(m_Shader, k_SampleKernel_xyzw2x, (int)(size.x) / 8, (int)(size.y) / 8, 1);
cmd.DispatchCompute(m_Shader, k_SampleKernel_xyzw2x, (int)Mathf.Max((size.x) / 8, 1), (int)Mathf.Max((size.y) / 8, 1), 1);
}
}

6
ScriptableRenderPipeline/Core/Resources/GPUCopyAsset.cs


using System;
using System;
using System.Collections.Generic;
using System.Text;

// 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(string.Format(" if (size.x < {0} || size.y < {0})", k_KernelSize.ToString()));
csm.AppendLine(" Debug.LogWarning(\"Trying to copy a channel from a texture smaller than 8x* or *x8. ComputeShader cannot perform it.\");");
csm.AppendLine(string.Format(" cmd.DispatchCompute(m_Shader, {0}, (int)(size.x) / {1}, (int)(size.y) / {1}, 1);", kernelIndexName, k_KernelSize.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()));
csm.AppendLine(" }");
}
csc.AppendLine(" }");

正在加载...
取消
保存