Skip to content

[SPIR-V] Fails to add linkage capability to module #6738

Closed

Description

Description

I'm currently trying to mark a function Export using SPIR-V's Linkage capability.

I get to this compilation error:

fatal error: generated SPIR-V is invalid: Operand 2 of Decorate requires one of these capabilities: Linkage
  OpDecorate %eval_sdf LinkageAttributes "eval_sdf" Export

But I can't find a way to add [[vk::ext_capability(/* Linkage */ 5)]] to the right location.

Adding it to the function in question does nothing, decorating the entry point does nothing as well.
Just adding it to the top of my file gives the error error: an attribute list cannot appear here which makes sense, given the rules described here

Am I missing something, or is this just not possible at the moment?

Steps to Reproduce

see this example code. It includes adding the capability to both, the function in question, as well as the entry point.

Actual Behavior

The compiler fails with:

fatal error: generated SPIR-V is invalid: Operand 2 of Decorate requires one of these capabilities: Linkage 
  OpDecorate %eval_sdf LinkageAttributes "eval_sdf" Export

So the function is already decorated Export, but the Linkage capability is missing.

Environment

  • DXC version: libdxcompiler.so: 1.7(dev;4006-69e54e29)
  • Host Operating System: (Arch)Linux

Activity

  1. added
    bug
    needs-triage
    spirv
    on Jun 30, 2024
  2. s-perron commented on Jul 15, 2024

    @s-perron
    Collaborator

    You can make this work with the latest top of tree: https://godbolt.org/z/9fzdeoGYT. You can add the attribute to the entry point, and use the universal1.5 target env (-fspv-target-env=universal1.5).

    However, the [[vk::ext_capability(/* Linkage */ 5)]] attribute is meant to be used when you are using other inline spir-v that requires the extension. The linkage capability would be added automatically by the compiler, but at this time it only adds the capability if there are no entry points in the module. This condition should be updated. This is a bug in the compiler that needs to be fixed.

  3. moved this from For Google to Triaged in HLSL Triageon Jul 26, 2024
  4. added a commit that references this issue on Sep 5, 2024
    475b9f3
  5. moved this from New to In review in HLSL Roadmapon Sep 5, 2024
  6. moved this from In review to Done in HLSL Roadmapon Sep 6, 2024
  7. added a commit that references this issue on Sep 6, 2024
    937c8c8
  8. added a commit that references this issue on Jul 24, 2025
    8a09503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugspirv

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions