DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V][Feature Request][SM6.7] Implement GatherRaw in the SPIR-V backend

Open Keenuts opened this issue 1 year ago • 4 comments

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));
                  ^

Keenuts avatar May 13 '24 12:05 Keenuts

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.

s-perron avatar May 31 '24 18:05 s-perron

FYI: https://docs.vulkan.org/spec/latest/chapters/textures.html#textures-format-conversion

s-perron avatar May 31 '24 18:05 s-perron

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?

Keenuts avatar Jun 06 '24 15:06 Keenuts

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.

s-perron avatar Jun 06 '24 15:06 s-perron

The existing error seems good enough, and we will not be implementing it because we cannot implement it in Vulkan.

s-perron avatar Aug 02 '24 17:08 s-perron