如果我的计算着色器中有纹理输入,那么除了使用插值法以及使用索引与归一化坐标之外,使用索引运算符[]或使用采样器之间是否有显着差异?如果不需要插值,使用采样器时会不会有明显的性能损失?
RWTexture3D<float4> Output;
Texture3D<float4> Input;
SamplerState samplerInput;
[numthreads(8, 8, 8)]
void main(uint3 id : SV_DispatchThreadID)
{
float width, height, depth;
Output.GetDimensions(width, height, depth);
float3 dimensions = float3(width, height, depth);
float3 coords = id.xyz / dimensions;
float4 value;
// Sampler:
value = Input.SampleLevel(samplerInput, coords, 0);
// Index operator:
value = Input[id];
// ...
}