Skip to content

Compiler allows to use atomics on bitfields, despite not supporting it #4319

@Devaniti

Description

@Devaniti

This code compiles

struct ColorRGBA {
  uint R : 8;
  uint G : 8;
  uint B : 8;
  uint A : 8;
};

StructuredBuffer<ColorRGBA> testBuffer;

float4 PSMain() : SV_TARGET
{
    InterlockedAdd(testBuffer[0].G, 1);
	return 0.0f;
}

But generates 32 bit atomics

%3 = call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %2, i32 0, i32 0, i32 0, i32 undef, i32 1)  ; AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue)

It should not compile, since there are no instruction that could allow arbitrary bit width atomics

Tested on https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.6.2112

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashhlsl2021Pertaining to HLSL2021 features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions