Skip to content

[SPIR-V] Use of only QuadReadAcross* intrinsics results in OpExtension SPV_KHR_compute_shader_derivatives not being emitted which leads to unexpected behavior #7943

@Narvin-Chana

Description

@Narvin-Chana

Description
I have a shader which uses QuadReadAcross* intrinsics. On the C++ side, I have enabled the VK_KHR_compute_shader_derivatives extension in order to have derivatives available. Under this logic, I would be able to access neighbouring thread's data using QuadReadAcross*.

The issue however is that since my shader does not use Sample(), ddx(), or any other derivative requiring operation, the generated SPIRV for my shader does not contain the SPV_KHR_compute_shader_derivatives OpExtension, thus the result of QuadReadAcross* is not the same as when I target DX12.

Steps to Reproduce

Godbolt examples:

In the first example, the result of QuadReadAcrossX does not match what DXIL would give me.
In the second example, once I add ddx() the resulting spirv contains SPV_KHR_compute_shader_derivatives, which causes the shader to now be consistent between spirv and DXIL.

Actual Behavior
I would expect that the use of QuadReadAcross* would mean the compiler emits SPV_KHR_compute_shader_derivatives as a required extension, since using QuadReadAcross* with non-2x2 grouped threads doesn't make much sense.

Environment

  • DXC version 1.8.2505 in godbolt, locally I have the same issue with dxcompiler.dll: 1.9 - 1.8.0.4973 (8f5595872)
  • Host Operating System Windows 11 (24H2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions