Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpCapability only once #4185

Closed
jkwak-work opened this issue May 17, 2024 · 0 comments · Fixed by #4189
Closed

Add OpCapability only once #4185

jkwak-work opened this issue May 17, 2024 · 0 comments · Fixed by #4189
Assignees
Labels
GoodFirstBug Great bug for people getting going in slang codebase kind:cleanup tech debt and rough edges kind:performance things we wish were faster

Comments

@jkwak-work
Copy link
Collaborator

Problem description
It appears that we are adding the same OpCapability more than once unnecessarily.
As an example, when we call a texture sampling function, we add the required capability by calling a function, "__requireComputeDerivative()".

    T Sample(vector<float, Shape.dimensions+isArray> location)
    {
        __requireComputeDerivative();
        __target_switch
    ... omit the rest ...

When we call the function more than once, the emitted SPIR-V code gets more than one of the same lines.
I am putting the example below,

; SPIR-V
; Version: 1.5
; Generator: Khronos; 40
; Bound: 2805
; Schema: 0
OpCapability Sampled1D
OpCapability ImageQuery
OpCapability ImageBuffer
OpCapability StorageImageReadWithoutFormat
OpCapability StorageImageWriteWithoutFormat
OpCapability StorageImageMultisample
OpCapability ComputeDerivativeGroupQuadsNV
OpCapability ComputeDerivativeGroupQuadsNV
OpCapability ComputeDerivativeGroupQuadsNV
OpCapability ComputeDerivativeGroupQuadsNV
OpCapability ComputeDerivativeGroupQuadsNV
...omit the rest ...

Note that the same line is added multiple times near the end.

Ideally we should avoid adding the same line more than once.

Repro step
This can be reproduced with one of existing tests that calls Sample or any equivalent.
The examples are following,

  1. tests/glsl-intrinsic/intrinsic-texture.slang
  2. tests/glsl-intrinsic/compute-derivative/intrinsic-derivative-function-in-compute.slang

Goal
We should avoid adding the same OpCapability more than once.

@jkwak-work jkwak-work added kind:performance things we wish were faster kind:cleanup tech debt and rough edges labels May 17, 2024
@ArielG-NV ArielG-NV added the GoodFirstBug Great bug for people getting going in slang codebase label May 17, 2024
@ArielG-NV ArielG-NV self-assigned this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoodFirstBug Great bug for people getting going in slang codebase kind:cleanup tech debt and rough edges kind:performance things we wish were faster
Projects
None yet
2 participants