[SPIR-V][Feature Request][SM6.7] Implement GatherRaw in the SPIR-V backend
Shader Model 6.7 added Raw Gather Methods which are currently unimplemented in the SPIR-V backend.
Texture2D<uint32_t> tex;
SamplerState samplerState;
float4 main() : SV_Target {
uint4 res = tex.GatherRaw(samplerState, float2(0, 0));
return float(res.x).xxxx;
}
dxc -T ps_6_7 shader.hlsl -spirv
shader.hlsl:5:19: error: intrinsic 'GatherRaw' method unimplemented
uint4 res = tex.GatherRaw(samplerState, float2(0, 0));
^
I don't think this can be implemented in a straight forward way. The problem is that the new instruction retrieves "a single value that represents a raw, bitwise copy of all of the element’s channels without any conversion of texture contents." As far a I can tell, no existing Vulkan instruction will do that.
FYI: https://docs.vulkan.org/spec/latest/chapters/textures.html#textures-format-conversion
When we talked about that, it seemed we'd need to to 4 OpImageGather calls to recombine the N components. But I saw the GatherRaw limits thew formats of the textures to single channels, or worst case, 2 channels textures. So doesn't this means in most cases, we would have a single OpImageGather to do? And in a very few cases 2?
The issue the the bitwise copy. AFAIK, all of the existing instructions will do a format conversion. The point of RawGather is to avoid the format conversion.
The existing error seems good enough, and we will not be implementing it because we cannot implement it in Vulkan.