Skip to content

asuint doesn't accept signed integer vector literals #6851

Closed as not planned
Closed as not planned

Description

Description
Validation fails when asuint is passed a vector literal of signed integers. Of course, this is something that only comes up in generated code where the literal isn't known ahead of time. If this is intended behavior, it seems like at least the error messaging should be improved.

Steps to Reproduce
dxc -T cs_6_6

RWByteAddressBuffer prevent_dce : register(u0);

[numthreads(1, 1, 1)]
void main() {
  int arg = -1;
  int3 vec = (-1).xxx;
  prevent_dce.Store3(0u, arg); // !!! WORKS
  prevent_dce.Store3(0u, asuint(-1)); // !!! WORKS
  prevent_dce.Store3(0u, vec); // !!! WORKS
  prevent_dce.Store3(0u, asuint((-1).xxx)); // !!! FAILS
  return;
}

https://godbolt.org/z/YcE8c1hqa

Expected Behavior
Compilation succeeds, or a relevant error message is produced.

Actual Behavior

error: validation errors
Invalid record
Validation failed.

Environment

  • DXC version: libdxcompiler.so: 1.8(dev;4705-99f2d498)
  • Host Operating System: Linux

Activity

  1. added
    bug
    needs-triage
    on Aug 7, 2024
  2. llvm-beanz commented on Aug 8, 2024

    @llvm-beanz
    Collaborator

    This one works in 202x. Unsure what exactly is happening here, but this is likely some odd explosion of the literal to 64-bits. We have some known issues with storing literals to ByteAddressBuffer causing 64-bit stores instead of 32-bit stores (see: #5493).

    I don't know if you're going to want to adopt an experimental in-development language version, but HLSL 202x fixes this issue as part of this feature proposal (https://github.com/microsoft/hlsl-specs/blob/main/proposals/0017-conforming-literals.md)

  3. damyanp commented on Aug 8, 2024

    @damyanp
    Member

    As this is fixed in 202x, no plans at moment to go back and address this for older language versions. Happy to hear feedback on why we should consider this higher priority.

  4. sudonatalie commented on Aug 8, 2024

    @sudonatalie
    CollaboratorAuthor

    No problem, we're working around it by extracting the literal to a var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions