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

Various intrinsic functions do not produce integral constant results when fed integral constant expressions (HLSL 2021) #239

Open
jeremyong opened this issue May 15, 2024 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@jeremyong
Copy link

Description
For NTTP manipulation, it's helpful to use built-in intrinsics for decoding/encoding information (e.g. countbits, firstbitlow, etc.). However, attempt to use these intrinsics in NTTP expressions results in a compiler error.

Steps to Reproduce
Minimal example (CE):

struct PSInput
{
    float4 position : SV_Position;
    float4 color    : COLOR0;
};

template <int I>
struct Foo
{
    vector<float, countbits(I)> test;
};

float4 PSMain(PSInput input) : SV_Target0
{
    Foo<3> f;
    return input.color * input.color;

Actual Behavior

<source>:13:19: error: non-type template argument of type 'unsigned int' is not an integral constant expression
    vector<float, countbits(I)> test;
                  ^~~~~~~~~~~~
<source>:18:12: note: in instantiation of template class 'Foo<3>' requested here
    Foo<3> f;
           ^

Compiler returned: 5

Environment

  • DXC version 1.8.2403.2
@jeremyong jeremyong added bug Something isn't working needs-triage labels May 15, 2024
@devshgraphicsprogramming

Yeah this is basically lack of constexpr concept, I've come up against this before and had to make boost mpl style template abominations to do a compile time bit count etc.

@damyanp damyanp transferred this issue from microsoft/DirectXShaderCompiler May 16, 2024
@damyanp damyanp added enhancement New feature or request and removed bug Something isn't working needs-triage labels May 16, 2024
@damyanp damyanp added this to the HLSL Backlog milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Triaged
Development

No branches or pull requests

3 participants